Skip to content

Instantly share code, notes, and snippets.

View dreampuf's full-sized avatar

Dreampuf dreampuf

View GitHub Profile
@typehorror
typehorror / Flask-SQLAlchemy Caching.md
Last active February 15, 2024 14:44
Flask SQLAlchemy Caching

Flask-SQLAlchemy Caching

The following gist is an extract of the article Flask-SQLAlchemy Caching. It allows automated simple cache query and invalidation of cache relations through event among other features.

Usage

retrieve one object

# pulling one User object

user = User.query.get(1)

@zxvdr
zxvdr / ssh
Created January 2, 2014 23:41
SSH proxy
package main
import (
"bytes"
"code.google.com/p/go.crypto/ssh"
"fmt"
"log"
"net"
"os"
)
@tima
tima / testrsync.yml
Created May 17, 2013 23:28
A playbook for testing of ansible-rsync
---
-
hosts: remote_host
gather_facts: no
name: "Testing synchronize"
vars:
start_time: "{{ lookup('pipe','date') }}"
test_files:
- test1
- test2
@klovadis
klovadis / gist:5170446
Created March 15, 2013 14:59
Two Lua scripts for Redis to turn HGETALL and HMGET into dictionary tables
-- 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
@josegonzalez
josegonzalez / access.lua
Created December 3, 2012 18:26
Simple lua file enabling oauth support for nginx via nginx-lua and access_by_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"
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active April 18, 2024 10:01
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

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

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@schuster-rainer
schuster-rainer / rx_websocket_protokol.html
Created February 20, 2012 21:58
WebSocket Demo using ws4py, cherrypy to echo incomming traffic. CoffeeScript, jQuery, RxJS, websock.js for the Client
<!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>
@baali
baali / speech2text.py
Created December 6, 2011 04:03
A Python script to break audio into chunks of smaller audios and using Google API to get Speech to Text.
'''
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