An introduction to curl using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
| data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script> |
| #!/bin/bash | |
| # | |
| # Binary search tree is of the form: | |
| # 10 | |
| # / \ | |
| # / \ | |
| # 4 16 | |
| # / \ / | |
| # 1 7 12 | |
| # |
| <?php | |
| // Full disclosure: I wrote this while writing a Twitter Bootstrap enabled site, so the class tags are Twitter bootstrap enabled. Shouldn't be hard to style, though. | |
| $subReddit = "webdev"; // Enter the subreddit name here with no /r/ in front | |
| $selfTextLimit = 250; // Character limit for self text entries | |
| $pageData = json_decode( file_get_contents( "http://www.reddit.com/r/$subReddit/.json" ) ); | |
| foreach( $pageData->data->children as $post ): ?> |
| import sys | |
| t={} | |
| def w(o): | |
| c=t | |
| for l in o: | |
| c[l]=c[l]if l in c else{} | |
| c=c[l] | |
| c[None]=None | |
| g=lambda t,b,i:reduce(lambda i,l:i+[b]if l is None else g(t[l],b+l,i),t,i) | |
| map(w,open(sys.argv[1]).read().split("\n")) |
| stack = [] | |
| compileStacks = [] | |
| words = {} | |
| builtins = {} | |
| lambdaType = type(lambda x: x) #cannot compare against the function type directly for some reason | |
| def prn(o): | |
| print(o) | |
| def clr(l): |
| # nanoshorten - a very tiny URL shortener Web application written in Bottle and sqlite | |
| # copyright (c) 2012 darkf | |
| # licensed under the WTFPL (WTF Public License) | |
| # see http://sam.zoy.org/wtfpl/ for details | |
| from bottle import get, request, run | |
| import sqlite3, random, string | |
| con = sqlite3.connect('short.db') | |
| c = con.cursor() |
An introduction to curl using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| #301 Redirects for .htaccess | |
| #Redirect a single page: | |
| Redirect 301 /pagename.php http://www.domain.com/pagename.html | |
| #Redirect an entire site: | |
| Redirect 301 / http://www.domain.com/ | |
| #Redirect an entire site to a sub folder | |
| Redirect 301 / http://www.domain.com/subfolder/ |