Skip to content

Instantly share code, notes, and snippets.

View samsonjs's full-sized avatar

Sami Samhuri samsonjs

View GitHub Profile
var sys = require("sys"),
http = require("http"),
port = 12345,
spawn = require("child_process").spawn;
function gzipStr (str, callback) {
var child = spawn("gzip", ["-c", "-f", "-n"]),
stdout = "", stderr = "";
child.stdout.addListener("data", function (chunk) {
# Config for Nginx to act as a front-end for Riak
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc)
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_)
# Config is in /etc/nginx/sites-available/default or somewhere like that
# Set up load-balancing to send requests to all nodes in the Riak cluster
# Replace these IPs/ports with the locations of your Riak nodes
upstream riak_hosts {
server 127.0.0.1:8098;
var assert = require('assert')
, subclass = function(type, proto){
// make sure we are extending a global constructor
// accepted: [Boolean, Number, String, Array, Object, Function, RegExp, Date]
if(!global[type.name] || global[type.name].name != type.name) throw new Error();
var constructor = proto.constructor,
keys = Object.keys(proto),
Obj = process.binding('evals').Script.runInNewContext('x = '+type.name), // eval ftw
@samsonjs
samsonjs / some.sh
Created October 12, 2012 05:13 — forked from tj/some.sh
change terminal tab name on cd
tabname() {
printf "\e]1;$1\a"
}
cd() {
if [[ $# -gt 0 ]]; then
builtin cd "$*"
else
builtin cd
fi
@samsonjs
samsonjs / gist:4076746
Created November 15, 2012 04:56 — forked from palexander/gist:2975305
Compiling and running mosh on Dreamhost
PREFIX=$HOME
VERSION=1.2.3
# Install Protocol Buffers
wget http://protobuf.googlecode.com/files/protobuf-2.4.1.tar.bz2
tar -xf protobuf-2.4.1.tar.bz2
cd protobuf-2.4.1
./configure --prefix=$PREFIX
make
make install
@implementation UITextView (RSExtras)
static BOOL stringCharacterIsAllowedAsPartOfLink(NSString *s) {
/*[s length] is assumed to be 0 or 1. s may be nil.
Totally not a strict check.*/
if (s == nil || [s length] < 1)
return NO;
#!/usr/bin/ruby
# restart-rainbows: Graceful restart for Rainbows
# depends on Linux's proc(5)
#
# MIT License: Copyright(c)2011 MATSUYAMA Kengo
require 'scanf'
require 'timeout'
class ProcFS
//
// Copyright (c) 2013 Tap for Tap. All rights reserved.
//
#import "MPBannerCustomEvent.h"
#import "TFTTapForTap.h"
@interface TFTMoPubBanner : MPBannerCustomEvent <TFTBannerDelegate>
@property (nonatomic, retain) TFTBanner *banner;
package com.tapfortap.mopub;
import android.content.Context;
import com.mopub.mobileads.CustomEventBanner;
import com.mopub.mobileads.MoPubErrorCode;
import com.tapfortap.Banner;
import com.tapfortap.TapForTap;
import java.util.Map;
@samsonjs
samsonjs / generate_html.rb
Created December 5, 2013 08:20 — forked from brentsimmons/generate_html.rb
A slightly more idiomatic version of Brent Simmon's program to convert a folder of Markdown files to HTML.
#!/usr/bin/env ruby
# PBS 4 Dec. 2013
# Renders HTML for all the .markdown files in the current directory.
# Gives each file a .html suffix.
# Saves them in a subfolder called HTML.
require 'rdiscount'
require 'find'
require 'fileutils'