Skip to content

Instantly share code, notes, and snippets.

@henrik
henrik / hash_deep_diff.rb
Created July 14, 2009 08:38
Recursively diff two Ruby hashes.
# Recursively diff two hashes, showing only the differing values.
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license.
#
# Example:
#
# a = {
# "same" => "same",
# "diff" => "a",
# "only a" => "a",
# "nest" => {
@hipertracker
hipertracker / gist:214210
Created October 20, 2009 12:05
NGinx -> TorqueBox
/etc/hosts:
127.0.0.1 myhost jboss_server
NGINX:
server {
listen myhost:80;
server_name myhost;
location / {
proxy_set_header X-Real-IP $remote_addr;
@bkutil
bkutil / deploy.rb
Created December 4, 2011 22:22 — forked from andruby/deploy.rb
Start and Stop tasks for resque workers and resque scheduler with capistrano deploy hook (without God)
after "deploy:symlink", "deploy:restart_workers"
after "deploy:restart_workers", "deploy:restart_scheduler"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
@chetan
chetan / yardoc_cheatsheet.md
Last active May 4, 2024 11:12
YARD cheatsheet
@ladyada
ladyada / adafruit_mcp3008.py
Last active April 7, 2024 18:32
Raspbery Pi Analog Input with MCP3008
#!/usr/bin/env python
# Written by Limor "Ladyada" Fried for Adafruit Industries, (c) 2015
# This code is released into the public domain
import time
import os
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
@momer
momer / explain_analyze.sql
Last active December 16, 2015 11:29
Super Fast Random Postgres Queries
--
-- Person's unoptimized query
--
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Seq Scan on keyword_tracked_tweets (cost=0.06..484854.06 rows=50015 width=172) (actual time=16639.692..32543.957 rows=1 loops=1)
Filter: ((id)::double precision = trunc((random() * ($1)::double precision)))
InitPlan 2 (returns $1)
-> Result (cost=0.05..0.06 rows=1 width=0) (actual time=0.045..0.047 rows=1 loops=1)
@willurd
willurd / web-servers.md
Last active May 7, 2024 14:57
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@rjmunro
rjmunro / .gitignore
Created June 21, 2013 13:54
gitignore for cordova cli projects
# Android
platforms/android/assets/www
platforms/android/bin/
platforms/android/gen/
platforms/android/res/xml/config.xml
# iOS
platforms/ios/build/
platforms/ios/CordovaLib/build/
platforms/ios/www
@nilbus
nilbus / java_for_rubyists.md
Last active January 25, 2023 18:49
Some Java basics for Rubyists
  1. Java uses static, declared typing:

    String hello = "Hello, World!";
    List<String> phrases = new ArrayList<String>;
    phrases.add(hello);
    phrases.add(null);
    phrases.add(123); // Compile error! Not a string.
@0x6e6562
0x6e6562 / main.go
Created January 31, 2014 08:21
Simple gocql batch example
package main
import (
"github.com/tux21b/gocql"
"log"
)
// create table foo (
// bar bigint,
// baz ascii,