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 yaml | |
| DEFAULT_IGNORE = [ | |
| '__unicode__', '__module__', '_meta', 'MultipleObjectsReturned', '_base_manager', | |
| 'objects', 'DoesNotExist', '__doc__', '_default_manager', '_curried', | |
| ] | |
| def analyze_model(model, ignore=[], default_ignore=True): | |
| """Analyze a Django Model to return a list of methods along with | |
| the methods docstring""" |
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 | |
| import urllib2 | |
| def get_vimeo_thumbnail(vimeo_video_id, size='large'): | |
| """Fetches a thumbnail URL for a given video (and size) from Vimeo metadata API""" | |
| assert size in ['small', 'medium', 'large'], 'You must specify a valid size! small/medium/large' | |
| req = urllib2.urlopen('http://vimeo.com/api/v2/video/%s.json' % vimeo_video_id) |
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, HttpResponseForbidden | |
| def _auth_request(realm): | |
| response = HttpResponse() | |
| response.status_code = 401 | |
| response['WWW-Authenticate'] = 'Basic realm="%s"' % realm | |
| return response | |
| def http_basic_auth(username=None, password=None, realm='Authorization required'): |
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 urllib | |
| import urllib2 | |
| import json | |
| def geocode(address): | |
| """Quick & Dirty utility to get geocoded lat/lng from Google Geocode API""" | |
| address = urllib.quote(address.replace(' ', '+').encode('utf-8')) | |
| query = 'http://maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false' % address | |
| raw_json = None |
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 os.path | |
| from deploy.utils.importing import import_object | |
| def _get_variation_path(path, variation): | |
| return os.path.join( | |
| os.path.dirname(path), | |
| variation.lower().replace(' ', '-'), | |
| os.path.basename(path) | |
| ) |
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
| curl -s http://checkip.dyndns.org/ 2>&1 | sed 's/.*\(<body>.*\s\(.*\)<\/body>\).*/\2/' |
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 urls | |
| def show_urls(urllist, depth=0): | |
| for entry in urllist: | |
| print "-" * depth, entry.regex.pattern | |
| if hasattr(entry, 'url_patterns'): | |
| show_urls(entry.url_patterns, depth + 1) | |
| show_urls(urls.urlpatterns) |
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
| ioreg -lw0 | grep \"EDID\" | sed "/[^<]*</s///" | xxd -p -r | strings -6 |
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
| javascript:inputs=document.getElementsByTagName('input');for(i=0;i<inputs.length;i++){if(inputs[i].type&&inputs[i].type=='checkbox'){inputs[i].checked=true;}} |
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 | |
| target_hosts="dynhost.does-not-exist.com another-host.does-not-exist.com" | |
| if [ -f "/root/mysql-allow-hosts-current" ]; then | |
| mv /root/mysql-allow-hosts-current /root/mysql-allow-hosts-prev | |
| fi | |
| touch /root/mysql-allow-hosts-current |