This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| First, install it from http://www.sublimetext.com/2 | |
| Next, install the package control extension from here: | |
| http://wbond.net/sublime_packages/package_control | |
| Installation instructions here: http://wbond.net/sublime_packages/package_control/installation | |
| Restart Sublime, then hit Shift+Apple+P and search for "Package Control: Install Package" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| localhost:~$ ssh example.com | |
| ubuntu@example.com:~$ | |
| ... ooh, I could really do with a port forwarding to something on here ... | |
| Type ENTER TILDE CAPITAL-C | |
| ssh> | |
| Secret SSH shell! | |
| ssh> -L8080:localhost:8080 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jQuery.fn.multiscrape = function(opts) { | |
| var scraped = []; | |
| this.each(function() { | |
| var $this = jQuery(this); | |
| var obj = {}; | |
| jQuery.each(opts, function(key, value) { | |
| var val; | |
| if (jQuery.isFunction(value)) { | |
| val = value.apply($this); | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| leading_tab_re = re.compile('^(\t+)') | |
| class ReindentingMiddleware(object): | |
| def process_response(self, request, response): | |
| return response | |
| if not response['Content-Type'].startswith('text/html'): | |
| return response | |
| content = response.content | |
| lines = content.split('\n') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json, datetime | |
| class RoundTripEncoder(json.JSONEncoder): | |
| DATE_FORMAT = "%Y-%m-%d" | |
| TIME_FORMAT = "%H:%M:%S" | |
| def default(self, obj): | |
| if isinstance(obj, datetime.datetime): | |
| return { | |
| "_type": "datetime", | |
| "value": obj.strftime("%s %s" % ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Convert numbers from base 10 integers to base X strings and back again. | |
| Sample usage: | |
| >>> base20 = BaseConverter('0123456789abcdefghij') | |
| >>> base20.from_int(1234) | |
| '31e' | |
| >>> base20.to_int('31e') | |
| 1234 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| 1. GET | |
| extract csrf token <input type='hidden' name='csrfmiddlewaretoken' value='1RNvCJoYdwKwtoOAd7kM73sBKJxhzN50' /> | |
| 2. POST https://www.pix-star.com/accounts/login/ | |
| next:/ | |
| username:... | |
| password:... | |
| csrfmiddlewaretoken:1RNvCJoYdwKwtoOAd7kM73sBKJxhzN50 | |
| - keep the cookies | |
| 3. POST album ID to https://www.pix-star.com/album/is2/downloading2/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.http import HttpResponse | |
| PIXEL_GIF_DATA = """ | |
| R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 | |
| """.strip().decode('base64') | |
| def pixel_gif(request): | |
| return HttpResponse(PIXEL_GIF_DATA, content_type='image/gif') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| daemon off; | |
| events { | |
| worker_connections 1024; | |
| } | |
| http { | |
| access_log /dev/stdout; | |
| error_log /dev/stderr; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ $# -ge 1 ]; then | |
| PORT=$1 | |
| else | |
| PORT=8000 | |
| fi | |
| CONF_PATH=$(mktemp /tmp/nginx-tmp-config.XXXXXXXX) || { echo "Failed to create temp file"; exit 1; } | |
| cat > $CONF_PATH <<- EOF | |
| daemon off; |