Skip to content

Instantly share code, notes, and snippets.

View lxneng's full-sized avatar
🎯
Focusing

Eric Luo lxneng

🎯
Focusing
View GitHub Profile
#!/usr/bin/env python
# encoding: utf-8
class DictToObject(object):
def __init__(self, dictionary):
def _traverse(k, v):
if isinstance(v, dict):
return k, DictToObject(v)
@lxneng
lxneng / gist:1483ebf3503775d49ce6
Last active August 29, 2015 14:04
install scipy on ubuntu
apt-get install libatlas-base-dev gfortran
pip install scipy
@lxneng
lxneng / 0_reuse_code.js
Created August 8, 2014 03:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@lxneng
lxneng / gist:01b5e2182c4d6f616749
Created October 15, 2014 03:01
(MongoDB) Drop all databases
db.adminCommand("listDatabases").databases.forEach( function (d) {
if (d.name != "local" && d.name != "admin" && d.name != "config")
db.getSiblingDB(d.name).dropDatabase();
})
# 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
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install mongodb-org
@lxneng
lxneng / new9.py
Created February 21, 2010 15:17 — forked from qingfeng/new9.py
#!/usr/bin/env python
# encoding: utf-8
# Author: qingfeng@douban.com
from __future__ import with_statement
from optparse import OptionParser
import os
parser = OptionParser(version="new9 command v1.0 -- by qingfeng@douban.com")
parser.add_option("-p", "--install",
@lxneng
lxneng / sp.py
Created February 21, 2010 15:20 — forked from qingfeng/sp.py
from scrapy import log
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.xpath.selector import HtmlXPathSelector
from scrapy.item import ScrapedItem
def safecn(i):
try:
return unichr(int(i))
except:
@lxneng
lxneng / snippet.txt
Created February 21, 2010 15:23 — forked from qingfeng/snippet.txt
#!/usr/bin/env python
# encoding: utf-8
from twill import *
import urllib2,re
USERNAME = 'YOUR USERNAME'
PASSWORD = 'YOUR PASSWORD'
BLOG_LIST = [
$ brew install postgresql
==> Downloading http://ftp2.uk.postgresql.org/sites/ftp.postgresql.org/source/v8.4.2/postgresql-8.4.2.tar.bz2
######################################################################## 100.0%
==> ./configure --enable-thread-safety --with-bonjour --with-python --with-perl --with-gssapi --with-krb5 --with-openssl --with-libxml --with-libxsl
==> make install
==> Caveats
If this is your first install, create a database with:
initdb /usr/local/var/postgres
Automatically load on login with: