Skip to content

Instantly share code, notes, and snippets.

View vicentereig's full-sized avatar
🐢

Vicente Reig vicentereig

🐢
View GitHub Profile
@wkrsz
wkrsz / devise.rb
Created January 9, 2013 11:48
Support for token HTTP header authentication in Devise
#config/initializers/devise.rb
config.warden do |manager|
manager.strategies.add :token_header_authenticable, TokenHeaderAuthenticable
manager.default_strategies(:scope => :user).unshift :token_header_authenticable
end
@ndarville
ndarville / business-models.md
Last active February 27, 2025 10:00
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@glebm
glebm / gist:4240917
Created December 8, 2012 16:37
ActionView::Template::Error (not opened for writing)
125642:ActionView::Template::Error (not opened for writing):
125643- 3: .sign_inner.location-selector
125644- 4: .selects
125645- 5: - selected = localiser.application_location.world? ? nil : localiser.application_location
125646- 6: - cache "#{localiser.locale.cache_key}/#{selected.try(:cache_key) || "w"}/main_loc_selector", expires_in: 24.hours do
125647- 7: = country_select selected: selected.try(:country).try(:id), class: 'combobox'
125648- 8: - if selected.try(:country).try(:has_children?)
125649- 9: = region_and_city_select selected, :class => "combobox"
125650- org/jruby/ext/stringio/RubyStringIO.java:992:in `write'
125651- org/jruby/RubyIO.java:2376:in `write'
@chen206
chen206 / gist:4030441
Created November 7, 2012 09:45
Install Postgresql 9.2 on Ubuntu 12.04
#!/bin/bash
#
# Install Postgres 9.2 on a clean Ubuntu 12.04
"""
LC_ALL issue
comment out the AcceptEnv LANG LC_* line in the remote /etc/ssh/sshd_config file.
sudo apt-get install language-pack-en-base
sudo dpkg-reconfigure locales
comment out the SendEnv LANG LC_* line in the local /etc/ssh/ssh_config file.
@jdelacueva
jdelacueva / consejo_ministros.py
Created November 1, 2012 23:40
Script para la obtención de las URLs de las referencias del Consejo de Ministros del Gobierno central
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Copyright: Javier de la Cueva
Licencia: Affero GPL V3
Script para generar un archivo csv con las URLs de las páginas web
con las referencias de los Consejos de Ministros habidas hasta la
fecha de ejecución del script. Util como punto de partida para
*scraping* del contenido de las referencias.
@rafaelss
rafaelss / gist:3700977
Created September 11, 2012 19:04
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. pg_ctl -D /usr/local/var/postgres stop -s -m fast
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. curl https://raw.github.com/fragility/homebrew/737af01178590950749cf5e841f2d086c57c5a80/Library/Formula/postgresql.rb > /usr/local/Library/Formula/postgresql.rb
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. pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
@fcurella
fcurella / psql.py
Created August 27, 2012 16:22
postgres PubSub vs Redis
#!/usr/bin/env python
import select
import time
import psycopg2
import psycopg2.extensions
import sys
def get_cursor():
conn = psycopg2.connect("dbname=pgpubsub")
@danielwaterworth
danielwaterworth / article.md
Created August 9, 2012 07:48
How much of your codebase is only understood by one person?

How much of your codebase is only understood by one person?

Have you seen this question before? If you're a programmer then you're likely to have. It's a question that is strongly related the concept of a bus factor; the minimum number of people that understand any part of a system. This question annoys me though, because by asking it you are assuming that the system in question is so complicated and ill documented that at least parts of it can only be understood by the people that created it or those who that knowledge was shared with.

Why is this the norm? Why is it that we accept complexity? Edsger Dijkstra famously said "Simplicity is prerequisite for reliability" and I don't anyone who would disagree. When we accept complexity by not striving for simplicity, we accept unreliability and bugs.

@rlivsey
rlivsey / pdf_generator.rb
Created June 28, 2012 10:22
HTML -> PDF with JRuby and Flying Saucer
require 'java'
require 'flying_saucer'
java_import org.xhtmlrenderer.pdf.ITextRenderer
class PDFGenerator
def self.generate(html)
new(html).generate
end
@maccman
maccman / juggernaut_channels.rb
Created June 26, 2012 04:56
Sinatra Server Side Event streaming with private channels.
# Usage: redis-cli publish message.achannel hello
require 'sinatra'
require 'redis'
conns = Hash.new {|h, k| h[k] = [] }
Thread.abort_on_exception = true
get '/' do