This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"mostViewsCity" : { | |
"name" : "Washington", | |
"views" : 62371 | |
}, | |
"leastViewsCity" : { | |
"name" : "Washington", | |
"views" : 62371 | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var slice; | |
slice = Array.prototype.slice; | |
return this.events = { | |
events: {}, | |
on: function(topic, handler, context) { | |
if (context == null) { | |
context = this; | |
} | |
this.events[topic] = this.events[topic] || []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(-> | |
slice = Array::slice | |
@events = | |
events: {} | |
on: (topic, handler, context) -> | |
context = this unless context? | |
@events[topic] = @events[topic] or [] | |
@events[topic].push | |
handler: handler | |
context: context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd ~ | |
sudo apt-get update | |
sudo apt-get install openjdk-7-jre-headless -y | |
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below | |
# NEW WAY / EASY WAY | |
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.2.deb | |
sudo dpkg -i elasticsearch-0.90.2.deb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Documentation for HAProxy | |
# http://code.google.com/p/haproxy-docs/w/list | |
# http://haproxy.1wt.eu/download/1.2/doc/architecture.txt | |
# NOTES: | |
# open files limits need to be > 256000, use ulimit -n to set (on most POSIX systems) | |
global | |
log 127.0.0.1 local0 | |
log 127.0.0.1 local1 notice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# relatively efficient way to empty a bucket in Riak | |
def empty_bucket bucket_name | |
bucket = Riak.bucket(bucket_name) | |
bucket.keys do |keys| | |
keys.each do |key| | |
bucket.delete(key) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'json' | |
require 'net/http' | |
# Sentiments on tweets | |
# http://data.tweetsentiments.com:8080/api/search.json?topic=<topic to analyze> | |
url = "http://data.tweetsentiments.com:8080/api/analyze.json?q=i%20am%20happy" | |
resp = Net::HTTP.get_response(URI.parse(url)) | |
data = resp.body | |
result = JSON.parse(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# script to refresh local git or svn repos | |
def pull_or_update (level = 1) | |
if (level > 0) | |
Dir.glob("*").each {|e| | |
Dir.chdir(e) do | |
if File.directory?(".git") | |
puts "\n========== pulling #{e} ==========" | |
system 'git pull' | |
elsif File.directory?(".svn") |
NewerOlder