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
@shazow
shazow / gist:789309
Created January 21, 2011 06:08
SQLAlchemy declarative base with __export__ and __import__ useful for exporting and importing fixtures.
"""SQLAlchemy Metadata and Session object"""
from sqlalchemy import MetaData, types
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from datetime import datetime, date
__all__ = ['Session', 'metadata', 'BaseModel']
Session = scoped_session(sessionmaker(expire_on_commit=False))
@kosso
kosso / background_demo.js
Created March 12, 2011 17:55
Background Service notification for Titanium
/* Kosso : March 12th 2011
This the only way I managed to do this without the app crashing on resume.
Done slightly differently to the KS example, since they unregister the service and
do not use a setInterval timer.
*/
//############ in app.js :
// test for iOS 4+
@garethr
garethr / build.xml
Created March 20, 2011 15:07
Sample ant build file for running rsync and scp base flat file deployment
<project name="{{ name }}" default="help" basedir=".">
<property name="username" value="{{ username }}"/>
<property name="host" value="{{ host }}"/>
<property name="dir" value="/srv/{{ path }}/"/>
<tstamp>
<format property="TODAY_UK" pattern="yyyyMMddhhmmss" locale="en,UK"/>
</tstamp>
@pazdera
pazdera / gist:1098129
Created July 21, 2011 20:29
Singleton example in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Example of Singleton design pattern
# Copyright (C) 2011 Radek Pazdera
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
@rduplain
rduplain / README.md
Created October 17, 2011 20:04
Connect to MSSQL using FreeTDS / ODBC in Python.

Goal: Connect to MSSQL using FreeTDS / ODBC in Python.

Host: Ubuntu 11.10 x86_64

Install:

sudo apt-get install freetds-dev freetds-bin unixodbc-dev tdsodbc
pip install pyodbc sqlalchemy

In /etc/odbcinst.ini:

@timtadh
timtadh / newegg.py
Created November 7, 2011 12:10
How to extract all of the items (name, price) from Newegg.
import itertools
import requests, lxml, lxml.html
import json
# 7603 Hard Drives
# 7611 RAM
# 6642 random store
def newegg_stores_req():
r = requests.api.get('http://www.ows.newegg.com/Stores.egg/Menus')
return [store['StoreID'] for store in json.loads(r.content)]
@tsabat
tsabat / supervisor.conf
Created December 28, 2011 15:09
Sample supervisor config file
; Sample supervisor config file.
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
;chmod=0700 ; sockef file mode (default 0700)
;chown=nobody:nogroup ; socket file uid:gid owner
;username=user ; (default is no username (open server))
;password=123 ; (default is no password (open server))
;[inet_http_server] ; inet (TCP) server disabled by default
@gonzedge
gonzedge / application_controller.rb
Created January 5, 2012 02:34
Rails 3.1 - Adding custom 404 and 500 error pages
class ApplicationController < ActionController::Base
# ...
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, with: lambda { |exception| render_error 500, exception }
rescue_from ActionController::RoutingError, ActionController::UnknownController, ::AbstractController::ActionNotFound, ActiveRecord::RecordNotFound, with: lambda { |exception| render_error 404, exception }
end
private
def render_error(status, exception)
@sj26
sj26 / README.md
Created January 19, 2012 07:41
Run MailCatcher in the background, always, on OS X

Place me.mailcatcher.plist into ~/Library/LaunchAgents, then run launchctl load ~/Library/LaunchAgents/me.mailcatcher.plist.

If you use pow, echo 1080 > ~/.pow/mailcatcher and go to http://mailcatcher.dev, otherwise use http://localhost:1080.

Currently pow doesn't seem to pass websockets through correctly. Looking into this.