Skip to content

Instantly share code, notes, and snippets.

View lxneng's full-sized avatar
🎯
Focusing

Eric Luo lxneng

🎯
Focusing
View GitHub Profile
@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 = [
@lxneng
lxneng / uri.py
Created February 23, 2010 05:50 — forked from dsc/uri.py
#!/usr/bin/env python
# encoding: utf-8
""" A simple URI Encoding/Decoding commandline tool.
"""
__author__ = 'David Schoonover <dsc@less.ly>'
__date__ = '2009-06-05'
__version__ = (0, 0, 1)
import sys, select, urllib
$ 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:
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
#!/bin/sh
# Install ImageMagick on Snow Leopard: by kain, improved by mislav and samsoffes
# http://www.icoretech.org/2009/08/install-imagemagick-in-leopard-snow-leopard/
# Work with 64bit kernel mode
set -e
PREFIX=/usr/local
# Passenger users: amend your Apache global configuration with the following directive
# SetEnv PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
@lxneng
lxneng / generic.py
Created February 25, 2010 01:50 — forked from jacobian/generic.py
#
# Further reading:
# Template builtins: http://docs.djangoproject.com/en/1.1/ref/templates/builtins/
# Generic view reference: http://docs.djangoproject.com/en/1.1/ref/generic-views/
#
#### entries/urls.py
from django.conf.urls.defaults import *
@lxneng
lxneng / readutf.java
Created February 25, 2010 01:51 — forked from mmalone/readutf.java
Java vs. Python
/**
* Reads from the
* stream <code>in</code> a representation
* of a Unicode character string encoded in
* <a href="DataInput.html#modified-utf-8">modified UTF-8</a> format;
* this string of characters is then returned as a <code>String</code>.
* The details of the modified UTF-8 representation
* are exactly the same as for the <code>readUTF</code>
* method of <code>DataInput</code>.
*
@lxneng
lxneng / routes_1.rb
Created February 25, 2010 01:54 — forked from ryanb/routes_1.rb
get "/about" => 'info#about', :as => 'about'
get "/privacy" => 'info#privacy', :as => 'privacy'
get "/license" => 'info#license', :as => 'license'
get "/mission" => 'info#mission', :as => 'mission'
get "/contact" => 'info#contact', :as => 'contact'