Skip to content

Instantly share code, notes, and snippets.

Dreampuf dreampuf

Block or report user

Report or block dreampuf

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:500145
// The `quickEach` method will pass a non-unique jQuery instance
// to the callback meaning that there will be no need to instantiate
// a fresh jQuery instance on each iteration. Most of the slow-down
// inherent in jQuery's native iterator method (`each`) is the constant
// need to have access to jQuery's methods, and so most developers
// see constructing multiple instances as no issue... E.g.
// $(...).each(function(){ $(this)... $(this)... $(this)... });
// A better approach would be `quickEach`.
jQuery.fn.quickEach = (function(){
@shnjp
shnjp / tunnel.py
Created Mar 5, 2011
ssh tunnel for Fabric
View tunnel.py
"""
Fabric tunneling utilities
by shn@glucose.jp
class ForwardServer and relates things are refere Robey Pointer's paramiko example.
(http://bazaar.launchpad.net/~robey/paramiko/trunk/annotate/head%3A/demos/forward.py)
usage::
with make_tunnel('user@192.168.0.2:10022') as t:
@baali
baali / speech2text.py
Created Dec 6, 2011
A Python script to break audio into chunks of smaller audios and using Google API to get Speech to Text.
View speech2text.py
'''
A hack based on this http://mikepultz.com/2011/03/accessing-google-speech-api-chrome-11/. While with smaller voice samples google speech to text works really good, as length increases quality decreases. So here using audiolab and numPy we are breaking audio sample, in smaller chunks, and removing blank/empty spaces from audio signal and then pushing them to google for processing.
It takes wav file format as input but can be changed to other formats too.
'''
from scikits.audiolab import wavread, play, flacwrite
from numpy import average, array, hstack
import os
import sys
@schuster-rainer
schuster-rainer / rx_websocket_protokol.html
Created Feb 20, 2012
WebSocket Demo using ws4py, cherrypy to echo incomming traffic. CoffeeScript, jQuery, RxJS, websock.js for the Client
View rx_websocket_protokol.html
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<title>Pushing with Rx and websock.js</title>
<script src="script/jquery-1.7.1.js" type="text/javascript"></script>
<script src="script/rx.min.js" type="text/javascript"></script>
<script src="script/rx.jquery.js" type="text/javascript"></script>
<script src="script/rx.time.min.js" type="text/javascript"></script>
<script src="script/base64.js"></script>
View tmux_cheatsheet.markdown

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 — forked from jboner/latency.txt
Latency numbers every programmer should know
View latency.markdown

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns  = 250 µs
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@josegonzalez
josegonzalez / access.lua
Created Dec 3, 2012
Simple lua file enabling oauth support for nginx via nginx-lua and access_by_lua.
View access.lua
- certain endpoints are always blocked
if nginx_uri == "/_access_token" or nginx_uri == "/_me" then
ngx.exit(403)
end
-- import requirements
local cjson = require "cjson"
-- setup some app-level vars
local app_id = "APP_ID"
@klovadis
klovadis / gist:5170446
Created Mar 15, 2013
Two Lua scripts for Redis to turn HGETALL and HMGET into dictionary tables
View gist:5170446
-- gets all fields from a hash as a dictionary
local hgetall = function (key)
local bulk = redis.call('HGETALL', key)
local result = {}
local nextkey
for i, v in ipairs(bulk) do
if i % 2 == 1 then
nextkey = v
else
result[nextkey] = v
View ssh
package main
import (
"bytes"
"code.google.com/p/go.crypto/ssh"
"fmt"
"log"
"net"
"os"
)
You can’t perform that action at this time.