Skip to content

Instantly share code, notes, and snippets.

@zspine
zspine / countries.csv
Last active October 14, 2025 11:57
Country Code, ISO and Nationality ( Please use https://mledoze.github.io/countries/ )
CCA2 Name CCA3 Nationality
AD Andorra AND Andorran
AE United Arab Emirates ARE Emirati
AF Afghanistan AFG Afghan
AG Antigua and Barbuda ATG Antiguan, Barbudan
AI Anguilla AIA Anguillian
AL Albania ALB Albanian
AM Armenia ARM Armenian
AN Netherlands Antilles ANT Dutch
AO Angola AGO Angolan
@MollsReis
MollsReis / image_resizer.rb
Created April 20, 2012 19:54
Image processing server using Sinatra and MiniMagick
require 'mini_magick'
class ImageResizer
attr_accessor :height, :width, :padding, :stretch, :grayscale
def initialize(path)
@image = MiniMagick::Image.open(path)
end
@g3d
g3d / gist:2709563
Last active May 15, 2025 07:00 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan
@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

@khoan
khoan / devise.rb
Created July 20, 2012 02:36
Devise Authentication unscoped
# config/initializers/devise.rb
#
# We now ask Warden to use :vip_authenticatable when authenticating.
#
# Also, we instruct Warden to load User from session without any default scoping.
#
Devise.setup do |config|
config.warden do |manager|
require Rails.root+'lib/vip_authenticable'
manager.default_strategies(scope: :user).unshift :vip_authenticatable
@danopia
danopia / FlagBot.rb
Created August 25, 2012 12:44
IRC bot to run a Stripe CTF2 level8 cracking command automatically. Integrates with XChat.
#!/usr/bin/env ruby
$server = 'irc.stripe.com'
$channel = '#level8'
$nick = 'FlagBot'
$chanfile = '~/.xchat2/xchatlogs/NETWORK-\#level8.log'
$sshpath = '[email protected]'
$command = 'ruby bot.rb'
$store = './flags.rb'
(function($) {
function parseImagesFromCSS(doc) {
var i, j,
rule,
image,
pattern = /url\((.*)\)/,
properties = ['background-image', '-webkit-border-image'],
images = {};
if (doc.styleSheets) {
@bilke
bilke / db_connection.rb
Created September 6, 2012 07:02
Connect to MongoLab with Mongomapper on Heroku
require 'rubygems'
require "mongo_mapper"
regex_match = /.*:\/\/(.*):(.*)@(.*):(.*)\//.match(ENV['MONGOLAB_URI'])
host = regex_match[3]
port = regex_match[4]
db_name = regex_match[1]
pw = regex_match[2]
MongoMapper.connection = Mongo::Connection.new(host, port)
@cyx
cyx / gist:3690597
Created September 10, 2012 12:13 — forked from inkel/gist:3690584
Monit Redis
check process redis-server
with pidfile "/var/run/redis.pid"
start program = "/etc/init.d/redis-server start"
stop program = "/etc/init.d/redis-server stop"
if 2 restarts within 3 cycles then timeout
if totalmem > 100 Mb then alert
if children > 255 for 5 cycles then stop
if cpu usage > 95% for 3 cycles then restart
if failed host 127.0.0.1 port 6379 then restart
if 5 restarts within 5 cycles then timeout
@joho
joho / gist:3735740
Created September 17, 2012 05:40 — forked from rafaelss/gist:3700977
PostgreSQL 9.2 upgrade steps
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. brew update
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. cp /usr/local/Cellar/postgresql/9.2.0/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/