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
import java.util.Collection; | |
import java.util.SortedMap; | |
import java.util.TreeMap; | |
public class ConsistentHash<T> { | |
private final HashFunction hashFunction; | |
private final int numberOfReplicas; | |
private final SortedMap<Integer, T> circle = new TreeMap<Integer, T>(); | |
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
# In the example below, the command we want to run is `php -f "$DIR/../run.php"` - change this on lines 30 and 46 | |
# $DIR is just the directory containing this script file (computed automatically, but you can hardcode it if you want). | |
# Use $DIR to specify paths relative to the script's path. | |
# The PROCESS_NAME variable is the name of the process to kill and restart | |
# You must ensure your process has the same name each time it runs (we use a file at $DIR/../servername to store the name) | |
# Alternatively, you can hard code the PROCESS_NAME on line 15 if you like | |
#!/bin/bash |
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
# References: | |
# http://blog.mixu.net/2011/08/13/nginx-websockets-ssl-and-socket-io-deployment/ | |
# http://blog.exceliance.fr/2012/09/10/how-to-get-ssl-with-haproxy-getting-rid-of-stunnel-stud-nginx-or-pound/ | |
# | |
global | |
nbproc 2 | |
maxconn 16384 | |
defaults |
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
(def path ["abc" "def" "xyz" "ref" "fed"]) | |
(defn a [] | |
(->> path | |
(interpose "/") | |
(into ["/"]) | |
(apply str))) | |
(defn b [] | |
(str "/" (clojure.string/join #"/" path))) |
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
module B | |
def print | |
puts C::A | |
end | |
end | |
class C | |
A = 10 | |
include B | |
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
class C | |
class << self | |
define_method(:a) do |msg| | |
"hello #{msg}" | |
end | |
end | |
end | |
puts C.a("world") |
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
url_params = "a=b&c=d&e=f&g=h" | |
dict([i.split('=') for i in url_params.split("&")]) |
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
package main | |
import ( | |
"context" | |
"fmt" | |
"log" | |
"net/http" | |
"os" | |
"os/signal" | |
"strconv" |
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
#colleague asks | |
class A | |
attr_accessor :b,:d | |
def a | |
self.b = 10 | |
@d = 20 | |
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
<html> | |
<head> | |
<script type="text/javascript" src="http://cdn.clappr.io/latest/clappr.min.js"></script> | |
<script type="text/javascript" src="http://cdn.jsdelivr.net/clappr.rtmp/0.0.2/rtmp.min.js"></script> | |
</head> | |
<body> | |
<div id="player"></div> | |
<script> | |
window.onload = function() { | |
var player = new Clappr.Player({ |