An introduction to curl using GitHub's API
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
Demo |
Disclaimer: This file is called .a_README.markdown
so that it'll appear first in the gist view (sorry for the horrible name)
Because this script prompts for user input, you have to execute it in a bit of an odd way. From a new command prompt simply copy and paste the following command and press return:
exec 3<&1;bash <&3 <(curl https://raw.github.com/gist/2040114/vim.sh 2> /dev/null)
import requests | |
def example(): | |
# grab some lat/long coords from wherever. For this example, | |
# I just opened a javascript console in the browser and ran: | |
# | |
# navigator.geolocation.getCurrentPosition(function(p) { | |
# console.log(p); | |
# }) |
import urllib | |
import urllib2 | |
from cookielib import CookieJar | |
from BeautifulSoup import BeautifulSoup | |
import re | |
""" | |
watch -d -n 5 'python 4irik.py' |
from datetime import datetime | |
import BeautifulSoup as soup | |
import requests | |
host = 'http://news.ycombinator.com' | |
def chunks(l, n): | |
""" Yield successive n-sized chunks from l. | |
""" | |
for i in xrange(0, len(l), n): |
import requests | |
from bs4 import BeautifulSoup as Sup | |
page_url = "http://www.bi.go.id/biweb/Templates/Moneter/Default_Kurs_EN.aspx?NRMODE=Published&NRNODEGUID=%7bEC4BBAA9-A1A8-4A4F-AC22-EDDA954C1B6A%7d&NRORIGINALURL=%2fweb%2fen%2fMoneter%2fKurs%2bBank%2bIndonesia%2fKurs%2bTransaksi%2f&NRCACHEHINT=Guest" | |
payload = { | |
'__VIEWSTATE' : 'dDw3MjU3NDM1OTQ7dDw7bDxpPDA+O2k8MT47PjtsPHQ8cDxsPFRleHQ7PjtsPGRlZmF1bHQgLSBDZW50cmFsIEJhbmsgb2YgUmVwdWJsaWMgb2YgSW5kb25lc2lhOz4+Ozs+O3Q8O2w8aTwxPjtpPDI+O2k8MTQ+Oz47bDx0PHA8bDxUZXh0Oz47bDxcPGltZyBzcmM9Ii9iaXdlYi9SZXNvdXJjZXMvaW1hZ2VzL2hlYWRfdGl0bGVfbW9uZXRlcl9lbi5naWYiXD47Pj47Oz47dDxwPGw8VGV4dDs+O2w8XDxpbWcgc3JjPSIvYml3ZWIvUmVzb3VyY2VzL2ltYWdlcy9oZWFkX2lsbHVzdHJhdGlvbl9tb25ldGVyLmpwZyJcPjs+Pjs7Pjt0PDtsPGk8MD47aTwyPjs+O2w8dDxwPGw8VmlzaWJsZTs+O2w8bzxmPjs+PjtsPGk8MT47aTwzPjtpPDU+O2k8Nz47aTw5PjtpPDExPjs+O2w8dDxwPGw8VmlzaWJsZTs+O2w8bzxmPjs+PjtsPGk8MT47PjtsPHQ8cDxsPFZpc2libGU7PjtsPG88Zj47Pj47Oz47Pj47dDxwPGw8VmlzaWJsZTs+O2w8bzxmPjs+PjtsPGk8MT47aTwzPjtpPDU+O2k8Nz47aTw5PjtpPDExPjtpPDEzPjt |
#!/usr/bin/env python | |
import urllib2 | |
import tempfile | |
import zipfile | |
top5 = [ | |
{ 'name': 'Microsoft .NET Framework Assistant', 'url': 'https://addons.mozilla.org/addon/9449', 'amo_id': 9449 }, | |
{ 'name': 'Adblock Plus', 'url': 'https://addons.mozilla.org/addon/1865', 'amo_id': 1865 }, | |
{ 'name': 'Yahoo! Toolbar', 'url': 'https://addons.mozilla.org/addon/2032', 'amo_id': 2032 }, |
''' Word filter for speeding up hamming-distance-of-1 searches. | |
Narrows down the search space by filtering out words that | |
can't possibly match because their 'total' is out of | |
the range +/- 26 from the origin word. Should reduce your | |
search space by at least half (depending on the word list). | |
Part of a solution for Proggit quiz #5: http://proggitquiz.com/challenge/5/ | |
''' |
import random | |
def random_words(num, separator='-'): | |
""" | |
Return `num`-random concatinated to each other. | |
They will be joined by `separator` | |
""" | |
words = [] |