This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/char_converter.rb | |
require 'uri' | |
module Support | |
class CharConverter | |
SANITIZE_ENV_KEYS = [ | |
"HTTP_COOKIE", # bad cookie encodings kill rack: https://github.com/rack/rack/issues/225 | |
"HTTP_REFERER", | |
"PATH_INFO", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/char_converter.rb | |
require 'uri' | |
module Support | |
class CharConverter | |
def initialize(app) | |
@app = app | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Steps to install and run PostgreSQL 9.3 using Homebrew (Mac OS X) | |
(if you aren't using version 9.2.4, change to the correct version) | |
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | |
mv /usr/local/var/postgres /usr/local/var/postgres92 | |
brew upgrade postgresql | |
initdb /usr/local/var/postgres -E utf8 | |
pg_upgrade -b /usr/local/Cellar/postgresql/9.2.4/bin -B /usr/local/Cellar/postgresql/9.3.0/bin -d /usr/local/var/postgres92 -D /usr/local/var/postgres | |
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthenticationsController < ApplicationController | |
def index | |
if current_user | |
@authentications = current_user.authentications | |
else | |
redirect_to root_path | |
end | |
end | |
def create |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Delayed | |
module Plugins | |
class Airbrake < Plugin | |
module Notify | |
def error(job, error) | |
::Airbrake.notify_or_ignore(error) | |
super | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import simplejson | |
import subprocess | |
import datetime | |
f = open('latitude.json', 'r') | |
locdata = simplejson.loads(f.read()); | |
fd = open('latitude.gpx', 'w') | |
fd.write("""# <?xml version="1.0" encoding="UTF-8" standalone="no" ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pids=() | |
# Snooooze for two seconds | |
function do_stuff { | |
sleep 2 | |
} | |
# Starts 10 processes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
layout :resolve_layout | |
# .... | |
private | |
def resolve_layout | |
layout ||= params[:layout] | |
layout ||= cookies[:layout] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from logging.handlers import SysLogHandler import socket | |
def syslogger(hostname, tag): | |
logger = logging.getLogger() | |
logger.setLevel(logging.INFO) | |
syslog = SysLogHandler(address=('syslogserver', 514), facility="local4") | |
formatter = logging.Formatter(hostname + ' ' + tag + ' %(levelname)s %(message)s') | |
syslog.setFormatter(formatter) | |
logger.addHandler(syslog) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'CSV' | |
require 'rest_client' | |
require 'json' | |
USERNAME="" | |
PASSWORD="" | |
URL_POSTFIX = "&api_user=#{USERNAME}&api_key=#{PASSWORD}" | |
SOURCE_LIST="" | |
NEW_LIST="" | |
CSV_FILE="" |