Skip to content

Instantly share code, notes, and snippets.

@mikhailov
mikhailov / installation.sh
Created November 23, 2010 15:18
nginx+passenger (real production config)
# NOTICE: to get Nginx+Unicorn best-practices configuration see the gist https://gist.github.com/3052776
$ cd /usr/src
$ wget http://nginx.org/download/nginx-1.2.1.tar.gz
$ tar xzvf ./nginx-1.2.1.tar.gz && rm -f ./nginx-1.2.1.tar.gz
$ wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
$ tar xzvf pcre-8.30.tar.gz && rm -f ./pcre-8.30.tar.gz
$ wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
@igrigorik
igrigorik / ruby-1.9-tips.rb
Created February 3, 2011 17:19
Ruby 1.9 features, tips & tricks you may not know about...
def tip(msg); puts; puts msg; puts "-"*100; end
#
# 30 Ruby 1.9 Tips, Tricks & Features:
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/
#
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2"
tip "Ruby 1.9 supports named captures in regular expressions!"
@fxn
fxn / post.md
Created May 23, 2011 21:08
GeoPlanet data with ancestor chain cache imported in 10 minutes

GeoPlanet data with ancestor chain cache imported in 10 minutes

Yahoo! provides its GeoPlanet data as three separate TSV files, available for download here.

That's a database with some 17 million records:

  • 5.7 million records: locations (aka places).
  • 2.2 million records: alternative names for each place (aka aliases).
  • 9.6 million records: matrix of neighbourhoods per place (aka adjacencies).
@javier
javier / jazzfonica.rb
Created June 14, 2011 11:29 — forked from ace/jazzfonica.rb
jazzfonica
#!/usr/bin/env ruby
# jazzfonica.rb for Mac OS X
# Scans the visible networks for JAZZTEL_XXXX or WLAN_XXXX and calculates the password
# Ported from PHP example at http://kz.ath.cx/wlan/codigo.txt
# Download and execute with ruby (e.g. ruby jazzfonica.rb) from a Terminal
#ported to ubuntu from https://gist.github.com/1024587
#it will ask for sudo privileges.
#if your wlan card is not "wlan0" change the "my_wifi_card" variable
@techandfaith
techandfaith / christianity.rb
Created October 3, 2011 17:17
Christianity described in Ruby code
#!/usr/bin/env ruby
require 'singleton'
require 'date'
Infinity = 1.0 / 0
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# In the beginning, there was God.
class God
# He is the only God.
@raul
raul / retry_upto.rb
Created October 7, 2011 06:42
retry_upto.rb
# Ruby `retry` with steroids:
#
# - retry up to 5 times without waiting between them and retrying after any exception
#
# retry_upto(5) do ... end
#
# - retry up to 5 times, waiting 2 seconds between retries
#
# retry_upto(5, :wait => 2) do ... end
#
@joneskoo
joneskoo / ssh-knownhosts-cleanup.py
Last active April 4, 2025 19:00
SSH known hosts cleanup script. Combines same fingerprints to one line.
#!/usr/bin/env python3
# encoding: utf-8
# By Joonas Kuorilehto 2011, MIT license
#
# The script combines .ssh/known_hosts so that each fingerprint is only
# listed once.
import re
import sys
import os
@eLafo
eLafo / code-review-1.markdown
Created November 2, 2011 10:00
Enunciado del problema 1 para la code review

#GENERACIÓN ALEATORIA DE NUBES DE TAGS A PARTIR DE KEYWORDS

##Problema real A partir de un fichero con 2574 keywords, hay que generar un número determinado de nubes de forma que:

  • Cada nube se comprondrá de 20 keywords
  • Cada keyword aparezca 50 veces, en nubes diferentes
  • Una keyword no puede aparecer repetida en una misma nube
  • Todas las nubes han de ser diferentes, considerándose como diferentes dos nubes que, al menos, difieran en una keyword y teniendo en cuenta que la posición de cada keyword dentro de la nube de no es relevante.
  • Este proceso se ejecutará una sola vez.
@fxn
fxn / top_ten_instantiated_classes.rb
Created February 9, 2012 10:32
Top ten instantiated classes by instance count on Ruby 1.9.3 startup (MRI)
classes = Hash.new(0)
ObjectSpace.each_object do |object|
classes[object.class] += 1
end
top_ten = classes.values.uniq.sort.reverse[9]
classes.select {|_, c| c >= top_ten}.sort_by {|_, c| -c}.each do |klass, c|
puts "#{klass}: #{c}"
end
@prellele
prellele / gist:1825744
Created February 14, 2012 10:48
Using StartSSL Certs with Nginx-Webserver

NOTE: You can check, if your config here:
http://www.sslshopper.com/ssl-checker.html

Decrypt the private key using the password you entered when you created your key:
openssl rsa -in ssl.key -out /etc/nginx/conf/ssl.key

Protect your key from prying eyes:
chmod 600 /etc/nginx/conf/ssl.key