Skip to content

Instantly share code, notes, and snippets.

@kaolian
kaolian / gist:9475826
Created March 10, 2014 22:27
java http get
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
String url = "http://...";
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
from flask import Flask
from flask import request
app = Flask(__name__)
#@app.route('/<int:test_id>', methods=['GET', 'POST'])
@app.route('/', defaults={'path': ''})
@app.route('/<path:path>')
def index(path):
print str(request.url)
# -*- mode: ruby -*-
# vi: set ft=ruby :
$master_script = <<SCRIPT
#!/bin/bash
cat > /etc/hosts <<EOF
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
@kaolian
kaolian / setup.sh
Last active December 29, 2015 12:09
Vagrant provisioning script for kafka
#!/bin/sh
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
wget -nv http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.0.6.0/hdp.repo -O /etc/yum.repos.d/hdp.repo
cp /vagrant/files/jdk-7u45-linux-x64.rpm .
rpm -Uvh jdk-7u45-linux-x64.rpm
@kaolian
kaolian / Vagrantfile
Created November 26, 2013 23:23
ubuntu 12.04 + hadoop1.2 cluster
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = "base-hadoop"
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "manifests"
puppet.manifest_file = "base-hadoop.pp"
puppet.module_path = "modules"
end
@kaolian
kaolian / Vagrantfile
Created November 26, 2013 23:22
ubuntu 12.04 + kafka
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64-for-kafka"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
@kaolian
kaolian / Vagrantfile
Last active December 29, 2015 12:08
centos-6.4
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "centos-6.4"
config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.4-x86_64-v20130731.box"
import urllib2
from time import gmtime, strftime
for i in range(0, 1000):
try:
body = '{"message":%d,"@timestamp":"%s", data:"hello", "@version":"1","type":"myTest","host":"myHost"}' % (i, strftime('%Y/%m/%dT%H:%M:%S'))
print body
request = urllib2.Request('http://192.168.56.201/', body, {'Content-Type': 'application/json'})
response = urllib2.urlopen(request).read()
#print response
import urllib2
for i in range(0, 100):
try:
response = urllib2.urlopen("http://sandbox:5000/%d/" % i)
#print response.read()
except:
pass
@kaolian
kaolian / gist:7590999
Last active December 29, 2015 01:09
POST json with ab
ab -n 100 -p test.json -T "application/json; charset=utf-8" http://192.168.56.201/