Skip to content

Instantly share code, notes, and snippets.

@cyx
cyx / redis_multiple
Created December 10, 2012 19:19 — forked from anonymous/redis_multiple
Multi node redis library
'''
Created on Jun 25, 2012
@author: andres.rangel
'''
import logging
import os
import re
from redis.client import Redis, BasePipeline, ConnectionError, StrictRedis, Script, NoScriptError
from redis.connection import ConnectionPool, Connection, DefaultParser
@cyx
cyx / gsdeplode
Created March 8, 2013 22:46 — forked from djanowski/gsdeplode
#!/bin/sh
# Assuming you use gs(1) and dep(1), this program
# implodes your .gs directory and installs all gems
# listed in your .gems file with a single call to gem(1).
#
# gs(1): https://github.com/soveran/gs
# dep(1): https://github.com/cyx/dep
set -e
@cyx
cyx / gist:5241445
Created March 25, 2013 22:31 — forked from gonz/gist:1686815
import re, sys
keys = ('abc', 'def', 'ghi', 'jkl', 'mno', 'pqrs', 'tuv', 'wxyz')
m = dict((l, str(n)) for n, letters in enumerate(keys, start=2) for l in letters)
data, ocurrences = {}, {}
wmatch = re.compile('[^a-z]+')
def learn(word):
num = ''.join(m[c] for c in word)
for i in xrange(1, len(word) + 1):
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /home/t/nginx/conf/mime.types;
default_type application/octet-stream;
@cyx
cyx / foo.diff
Created October 3, 2013 01:28 — forked from oren/gist:6803198
diff --git a/tests/models/listing_test.js b/tests/models/listing_test.js
index 14c3d14..c04b7a6 100644
--- a/tests/models/listing_test.js
+++ b/tests/models/listing_test.js
@@ -10,6 +10,7 @@ var dict = {
'Name': 'CPK',
'HeadingText': 'Restaurants',
'PrimaryCollection': 'food',
+ 'Personalization.TotalNotes': '10'
};

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

var randomNumbers = [42, 12, 88, 62, 63, 56, 1, 77, 88, 97, 97, 20, 45, 91, 62, 2, 15, 31, 59, 5]
func partition(v: Int[], left: Int, right: Int) -> Int {
var i = left
for j in (left + 1)..(right + 1) {
if v[j] < v[left] {
i += 1
(v[i], v[j]) = (v[j], v[i])
}
}
var h = require('mercury').h;
var css = require('./index.css');
var insert = require('insert-css');
module.exports = function component(state) {
insert(css);
return h('.foo')
}
// github.com/nu7hatch/gouuid
BenchmarkV4 1000000 1426 ns/op
BenchmarkV5 2000000 910 ns/op
// github.com/streadway/simpleuuid
BenchmarkV5 5000000 689 ns/op
// github.com/tux21b/gocql/tree/master/uuid
BenchmarkRandomUUID 1000000 1470 ns/op
@cyx
cyx / sse.go
Last active August 29, 2015 14:15 — forked from ismasan/sse.go
package main
import (
"fmt"
"log"
"net/http"
"time"
)
// Example SSE server in Golang.