Skip to content

Instantly share code, notes, and snippets.

@keyurdg
keyurdg / mysql_query_multiplexer.go
Created March 18, 2013 19:01
Read output from pt-query-digest and multiplex queries to MySQL over multiple threads.
package main
import (
"bufio"
"bytes"
_ "github.com/Go-SQL-Driver/MySQL"
"database/sql"
"flag"
"fmt"
"io"
@moderation
moderation / raspberrypi_tips
Last active October 3, 2016 22:43
Raspberry Pi tips including setting up Go and Node.js
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=34&t=10781
Adjust your environment to include:
GOARM=5
GOOS=linux
GOARCH=arm
GOPATH=<root for packages>
$ sudo apt-get install mercurial # get mercurial
$ sudo apt-get install git # for go get ...
@NorthIsUp
NorthIsUp / spawn.py
Created July 5, 2012 12:46
gevent spawn helpers
"""
realertime.lib.spawn
~~~~~~~~~~~~~~~~~~~~
:author: Adam Hitchcock
:copyright: (c) 2012 DISQUS.
:license: Apache License 2.0, see LICENSE for more details.
"""
from __future__ import absolute_import
Setup
=====
[stunnel acccept port 443 connect 8443]
||
[haproxy
* accept port 80
default: connect 8080 (nginx)
host: 'push.*' => connect 8090 (node)
* accept port 8443
@dvv
dvv / bnoguchi-redis-node
Created May 14, 2011 18:32
redis-clients-leaking
published 100000 freemem 579334144
published 200000 freemem 524353536
published 300000 freemem 471535616
published 400000 freemem 404111360
published 500000 freemem 345575424
published 600000 freemem 285134848
published 700000 freemem 240693248
published 800000 freemem 175812608
published 900000 freemem 106991616
published 1000000 freemem 54648832
@jonah-williams
jonah-williams / build.sh
Created April 30, 2011 17:46
Command line iOS project builds and over-the-air distribution
#!/bin/bash
# https://gist.github.com/949831
# http://blog.carbonfive.com/2011/05/04/automated-ad-hoc-builds-using-xcode-4/
# command line OTA distribution references and examples
# http://nachbaur.com/blog/how-to-automate-your-iphone-app-builds-with-hudson
# http://nachbaur.com/blog/building-ios-apps-for-over-the-air-adhoc-distribution
# http://blog.octo.com/en/automating-over-the-air-deployment-for-iphone/
# http://www.neat.io/posts/2010/10/27/automated-ota-ios-app-distribution.html
@tmc
tmc / gist:777085
Created January 12, 2011 23:08
multiprocessing gevent chat example
import sys
import gevent
from gevent.monkey import patch_all; patch_all()
from gevent import server, event, socket
from multiprocessing import Process, current_process, cpu_count
"""
Simple multiprocess StreamServer that proxies messages between clients.
Avoids using a multiprocessing.Event since it blocks on a semaphore.
@tmc
tmc / gist:776364
Created January 12, 2011 16:12
simple multiprocessing gevent echo server
import sys
from gevent import server
from multiprocessing import Process, current_process, cpu_count
def note(format, *args):
sys.stderr.write('[%s]\t%s\n' % (current_process().name, format%args))
def echo(socket, address):
print 'New connection from %s:%s' % address
// DySlim is complicated and requires writing 6GB to disk (if only temporarily).
// This lets you mount the dyld shared cache via FUSE; the resulting files are weird but readable by things like otool and strings.
//
// gcc -std=gnu99 -I/opt/local/include -L/opt/local/lib -D_FILE_OFFSET_BITS=64 -o dsc dsc.c -lfuse -framework CoreFoundation
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
import gevent
from thrift.server.TServer import TServer
# XXX Hackish, but should be safe: monkey patch gevent socket support into
# Thrift. Overall I think this is cleaner than reimplementing all of TSocket.
from thrift.transport import TSocket; TSocket.socket = gevent.socket
from thrift.transport.TTransport import TTransportException
class TGEventServer(TServer):
"""Gevent socket server."""