This file contains hidden or 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
# coding: utf-8 | |
try: | |
import cPickle as pickle | |
except ImportError: | |
import pickle | |
try: | |
import hashlib | |
sha1 = hashlib.sha1 |
This file contains hidden or 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
# http://zh.wikipedia.org/wiki/中文数字 | |
# http://china.younosuke.com/03_013.html | |
module ChineseNum | |
extend self | |
UPPER_ZERO = '零' | |
LOWER_ZERO = '〇' | |
UPPER_DIGITS = %w[壹 贰 叁 肆 伍 陆 柒 捌 玖].unshift nil | |
LOWER_DIGITS = %w[一 二 三 四 五 六 七 八 九].unshift nil |
This file contains hidden or 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains hidden or 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
test: | |
clear | |
nosetests --with-coverage --cover-package name_utils test_name_utils.py | |
clean: | |
find -regex '.*\.pyc' -exec rm {} \; | |
find -regex '.*~' -exec rm {} \; | |
.PHONY: test clean |
This file contains hidden or 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 collections | |
import sqlalchemy.types | |
class Hstore(sqlalchemy.types.UserDefinedType, sqlalchemy.types.MutableType): | |
"""The ``hstore`` type that stores a dictionary. It can take an any | |
instance of :class:`collections.Mapping`. | |
It can be extended to store other types than string e.g.:: |
This file contains hidden or 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
#Call this inside ~/.ipython/ipy_user_conf.py main() | |
import sys | |
import subprocess | |
from os import environ | |
if 'VIRTUAL_ENV' in environ: | |
#This is kludgy but it works; grab the right sys.path from the virtualenv python install: | |
path = subprocess.Popen(['python', '-c','import sys;print(repr(sys.path))'], | |
stdout=subprocess.PIPE).communicate()[0] |
This file contains hidden or 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
//quick online/offline check | |
function hasInternets() { | |
var s = $.ajax({ | |
type: "HEAD", | |
url: window.location.href.split("?")[0] + "?" + Math.random(), | |
async: false | |
}).status; | |
//thx http://www.louisremi.com/2011/04/22/navigator-online-alternative-serverreachable/ | |
return s >= 200 && s < 300 || s === 304; | |
}; |
-
The new rake task assets:clean removes precompiled assets. [fxn]
-
Application and plugin generation run bundle install unless
--skip-gemfile
or--skip-bundle
. [fxn] -
Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]
-
Template generation for jdbcpostgresql #jruby [Vishnu Atrai]
- https://gist.github.com/958283
- https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/milestones/71470-31
- http://hemju.com/2011/02/23/rails-3-1-release-rumors-and-news-about-features/
- http://www.hagenburger.net/TALKS/rails-3.1-frontend-performance.html#slide1
Console shows SQL queries right there.