Skip to content

Instantly share code, notes, and snippets.

View fengs's full-sized avatar

Sophia Feng fengs

View GitHub Profile
@fengs
fengs / 0_reuse_code.js
Created April 16, 2014 03:15
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
>>> from fractions import gcd
>>> gcd(20,8)
4
>>> print inspect.getsource(gcd)
def gcd(a, b):
"""Calculate the Greatest Common Divisor of a and b.
Unless b==0, the result will have the same sign as b (so that when
@fengs
fengs / ParsePhoneNumber.py
Created April 19, 2014 21:20
Parse American phone numbers, with optional extension
import re
phonePattern = re.compile(r'''
(\d{3}) #area code
\D*
(\d{3}) #trunk
\D*
(\d{4}) #number
\D*
(\d*) #optional extension
@fengs
fengs / scp
Created April 21, 2014 01:17
Secure copy to/from remote host using scp and ssh
# make sure ssh-client is installed
# login
$ ssh user@remotehost
# generating key pairs
$ ssh-keygen -t dsa
# install the key by either of the commands
$ scp ~/.ssh/id_dsa.pub user@remotehost:.ssh/authorized_keys
@fengs
fengs / OSPath.py
Created April 21, 2014 05:34
Usage of os.path method of the os module. From http://www.diveintopython3.net/comprehensions.html
>>> import os
>>> print(os.path.join('/Users/pilgrim/diveintopython3/examples/', 'humansize.py'))
/Users/pilgrim/diveintopython3/examples/humansize.py
>>> print(os.path.join('/Users/pilgrim/diveintopython3/examples', 'humansize.py'))
/Users/pilgrim/diveintopython3/examples\humansize.py
>>> print(os.path.expanduser('~'))
c:\Users\pilgrim
>>> print(os.path.join(os.path.expanduser('~'), 'diveintopython3', 'examples', 'humansize.py'))
c:\Users\pilgrim\diveintopython3\examples\humansize.py
@fengs
fengs / tumblr-photo-ripper.rb
Last active August 29, 2015 14:26 — forked from jamiew/tumblr-photo-ripper.rb
Download all the images from a Tumblr blog
# Usage:
# [sudo] gem install mechanize
# ruby tumblr-photo-ripper.rb
require 'rubygems'
require 'mechanize'
# Your Tumblr subdomain, e.g. "jamiew" for "jamiew.tumblr.com"
site = "doctorwho"
@fengs
fengs / vr_listing.xml
Last active September 14, 2017 19:43 — forked from zhouxingxing1992/vr_listing.xml
vr_listing
<?xml version="1.0"?>
<listing xmlns="http://www.airbnb.com/schemas/airbnb-listing/v1" schemaVersion="1.0">
<lastUpdated>2017-08-29T16:36:15Z</lastUpdated>
<published>true</published>
<basicDetails>
<bathrooms>1</bathrooms>
<bedrooms>1</bedrooms>
<propertyType>house</propertyType>
<listingType>entire_home</listingType>
<amenities>
@fengs
fengs / Smart_Cat_large_image.xml
Last active January 26, 2018 04:27
smart cat
<?xml version="1.0"?>
<listing xmlns="http://www.airbnb.com/schemas/airbnb-listing/v1" schemaVersion="1.0">
<lastUpdated>2017-04-15T17:27:40Z</lastUpdated>
<published>true</published>
<basicDetails>
<bathrooms>3</bathrooms>
<bedrooms>3</bedrooms>
<propertyType>house</propertyType>
<listingType>entire_home</listingType>
<amenities>