Skip to content

Instantly share code, notes, and snippets.

View leandro's full-sized avatar
🏠
Working from home

Leandro Camargo leandro

🏠
Working from home
View GitHub Profile
@leandro
leandro / gist:1713746
Created January 31, 2012 23:23
nginx log format
log_format complete '[$time_local] REQ_TIME:$request_time UPS_TIME:$upstream_response_time C:$remote_addr H:$host '
'URI:$request_uri ($request_method) ST:$status SZ:$bytes_sent '
'REFERER:http_referer AGENT:$http_user_agent';
Index: sapi/cli/config.w32
===================================================================
--- sapi/cli/config.w32 (revision 308839)
+++ sapi/cli/config.w32 (working copy)
@@ -6,7 +6,8 @@
ARG_ENABLE('cli-win32', 'Build console-less CLI version of PHP', 'no');
if (PHP_CLI == "yes") {
- SAPI('cli', 'php_cli.c', 'php.exe');
+ SAPI('cli', 'php_cli.c php_http_parser.c php_cli_server.c', 'php.exe');
@leandro
leandro / gist:949177
Created April 29, 2011 22:51
SHOW DATABASES' SIZES FROM MYSQL CONSOLE
SELECT table_schema "Data Base Name", sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB"
FROM information_schema.TABLES GROUP BY table_schema;
user nginx;
worker_processes 5;
error_log /var/log/nginx.error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
require 'json'
require 'hpricot'
require 'open-uri'
module SimpleFlickr
AUTH_URL = 'http://flickr.com/services/auth/'.freeze
API_URL = 'http://api.flickr.com/services/rest/'.freeze
# USAGE
var
a = [1,2,3,4,5],
b = [2,3],
subset_of = function(arr, arr_sub) { return new RegExp("-" + arr_sub.join('-') + "-").test("-" + arr.join('-') + "-"); };
console.log(subset_of(a, b)); // true
console.log(subset_of(a, b.reverse())); // false
require 'benchmark'
class Hash
def hash_from_1(*keys)
keys.inject({}) { |memo, obj| memo.merge(obj => self[obj]) }
end
def hash_from_2(*keys)
self.dup.delete_if { |k, v| !keys.include? k }
require 'benchmark'
class Hash
def hash_from_1(*keys)
keys.inject({}) { |memo, obj| memo.merge(obj => self[obj]) }
end
def hash_from_2(*keys)
self.dup.delete_if { |k, v| !keys.include? k }
class Hash
def hash_from(*keys)
keys.inject({}) { |memo, obj| memo.merge(obj => self[obj]) }
end
end
# example:
# >> a = {:foo => 1, :bar => 2, :foobar => 3}
#!/bin/sh
# Usage: unicorn_github
# Script used to start unicorn in GitHub staging and production environments.
# This is called primarily by god.
set -e
# configure GC settings
export RUBY_HEAP_MIN_SLOTS=800000
export RUBY_HEAP_FREE_MIN=100000
export RUBY_HEAP_SLOTS_INCREMENT=300000