Skip to content

Instantly share code, notes, and snippets.

View lxneng's full-sized avatar
🎯
Focusing

Eric Luo lxneng

🎯
Focusing
View GitHub Profile
@kyriacos
kyriacos / dbdocs.rb
Created January 22, 2011 12:09 — forked from adelevie/dbdocs.rb
require 'sinatra'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => 'mysql',
:encoding => 'utf8',
:database => 'foo',
:username => 'bar',
:password => 'baz',
:host => 'localhost'
@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!"
@errriclee
errriclee / drop
Created February 18, 2011 02:14
pick
#!/bin/sh
run cp -v {} .
@rmoriz
rmoriz / Gemfile
Last active September 23, 2024 03:00
UUID primary keys in Rails 3
# Gemfile
gem 'uuidtools'
@esperlu
esperlu / mysql2sqlite.sh
Created April 27, 2011 05:46
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@kennethreitz
kennethreitz / 0_urllib2.py
Created May 16, 2011 00:17
urllib2 vs requests
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
gh_url = 'https://api.github.com'
req = urllib2.Request(gh_url)
password_manager = urllib2.HTTPPasswordMgrWithDefaultRealm()
@groner
groner / command.py
Created May 19, 2011 16:58
pyramid paster command template
import logging
import os.path as path
from paste.script.command import Command, BadCommand
from paste.deploy import loadapp
from pyramid.threadlocal import manager as threadlocal_manager
@ChuckJHardy
ChuckJHardy / app.rake
Created May 29, 2011 12:34
Rake Task for Database Population
------------ From Rake Task
namespace :app do
# Checks and ensures task is not run in production.
task :ensure_development_environment => :environment do
if Rails.env.production?
raise "\nI'm sorry, I can't do that.\n(You're asking me to drop your production database.)"
end
end
@philippeowagner
philippeowagner / fabfile.py
Created June 7, 2011 07:26 — forked from onyxfish/fabfile.py
Chicago Tribune News Applications fabric deployment script
from fabric.api import *
"""
Base configuration
"""
env.project_name = '$(project)'
env.database_password = '$(db_password)'
env.site_media_prefix = "site_media"
env.admin_media_prefix = "admin_media"
env.newsapps_media_prefix = "na_media"
@baijum
baijum / flask.rst
Created July 10, 2011 18:03
Flask Notes