Skip to content

Instantly share code, notes, and snippets.

@gaotongfei
gaotongfei / Rakefile
Created August 18, 2017 09:05 — forked from schickling/Rakefile
Activerecord without Rails
require "active_record"
namespace :db do
db_config = YAML::load(File.open('config/database.yml'))
db_config_admin = db_config.merge({'database' => 'postgres', 'schema_search_path' => 'public'})
desc "Create the database"
task :create do
ActiveRecord::Base.establish_connection(db_config_admin)
@gaotongfei
gaotongfei / extract_emails_from_text.py
Created June 26, 2016 07:08 — forked from dideler/example.md
A python script for extracting email addresses from text files. You can pass it multiple files. It prints the email addresses to stdout, one address per line. For ease of use, remove the .py extension and place it in your $PATH (e.g. /usr/local/bin/) to run it like a built-in command.
#!/usr/bin/env python
#
# Extracts email addresses from one or more plain text files.
#
# Notes:
# - Does not save to file (pipe the output to a file if you want it saved).
# - Does not check for duplicates (which can easily be done in the terminal).
#
# (c) 2013 Dennis Ideler <ideler.dennis@gmail.com>
@gaotongfei
gaotongfei / _usage.md
Created May 30, 2016 01:09 — forked from tbranyen/_usage.md
OpenWeatherMap / Weather Icons integration
  1. Include Weather Icons in your app: https://github.com/erikflowers/weather-icons

  2. Include the below JSON in your application, for example purposes, lets assume it's a global named weatherIcons.

  3. Make a request to OpenWeatherMap:

req = $.getJSON('http://api.openweathermap.org/data/2.5/weather?q=London,uk&callback=?');
@gaotongfei
gaotongfei / 0_reuse_code.js
Created December 26, 2015 07:24
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
@gaotongfei
gaotongfei / print_cookies.py
Created November 21, 2015 03:44 — forked from iiska/print_cookies.py
Using urllib2 and cookielib to print cookies from GET request
import urllib2
import cookielib
cookie_jar = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie_jar))
urllib2.install_opener(opener)
request = urllib2.Request('http://www.google.com')
urllib2.urlopen(request)
@gaotongfei
gaotongfei / PyTorStemPrivoxy.md
Created November 21, 2015 03:20 — forked from KhepryQuixote/PyTorStemPrivoxy.md
Python script to connect to Tor via Stem and Privoxy, requesting a new connection (hence a new IP as well) as desired.

Crawling Anonymously with Tor in Python

adapted from the article "Crawling anonymously with Tor in Python" by S. Acharya, Nov 2, 2013.

The most common use-case is to be able to hide one's identity using TOR or being able to change identities programmatically, for example when you are crawling a website like Google and you don’t want to be rate-limited or blocked via IP address.

Tor

Install Tor.

@gaotongfei
gaotongfei / tor.py
Created October 26, 2015 09:45 — forked from jefftriplett/tor.py
Python Requests + Tor (Socks5)
"""
setup:
pip install requesocks
super helpful:
http://packetforger.wordpress.com/2013/08/27/pythons-requests-module-with-socks-support-requesocks/
"""
import requests
import requesocks