This file contains 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
Environment: | |
Request Method: GET | |
Request URL: http://ihomeaudio.biz/iH22LV/ | |
Django Version: 1.2.3 | |
Python Version: 2.6.5 | |
Installed Applications: | |
['django.contrib.auth', | |
'django.contrib.contenttypes', | |
'django.contrib.sessions', |
This file contains 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 http://www.last.fm/robots.txt | |
User-Agent: * | |
Disallow: /music? | |
Disallow: /widgets/radio? | |
Disallow: /show_ads.php | |
Disallow: /affiliate/ | |
Disallow: /affiliate_redirect.php | |
Disallow: /affiliate_sendto.php |
This file contains 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
// Provides a device_scale class on iOS devices for scaling user | |
// interface elements relative to the current zoom factor. | |
// | |
// http://37signals.com/svn/posts/2407-device-scale-user-interface-elements-in-ios-mobile-safari | |
// Copyright (c) 2010 37signals. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
This file contains 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, sys | |
sys.path.append('/var/django/ihome') | |
# redirect print statements to the apache log | |
sys.stdout = sys.stderr | |
os.environ['DJANGO_SETTINGS_MODULE'] = 'ihome.settings' | |
import django.core.handlers.wsgi |
This file contains 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
{ | |
"id": "16231442", | |
"created": "2008-06-18T01:27:55Z", | |
"modified": "2008-07-01T00:26:16Z", | |
"name": "Upper Lofts at Canal Walk", | |
"source": "js", | |
"url": "", | |
"location_id": "", | |
"tags": [ | |
This file contains 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
### Appending URL to SQL query for logging | |
via http://chris-lamb.co.uk/2010/06/01/appending-request-url-sql-statements-django/ | |
Now your SQL statements look like: | |
SELECT "auth_user"."id", [..] WHERE "auth_user"."id" = 1 -- /login | |
This allows you to quickly go from a misbehaving query in your production environment to the view that is executing it. |
This file contains 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 | |
east=1 | |
while [ 1 -eq 1 ] | |
do | |
echo "toggle" | |
if [ $east -eq 1 ] ; then | |
curl "http://tracks.emerick.org/api/broadcast?token=7d0bc705c04c4c6ebd4cfcc29e18eca5&lat=37.648387&long=-77.619488" | |
east=0 |
This file contains 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
// create a spannable string | |
SpannableString spanstring = new SpannableString("bold\ntumblelog"); | |
// make the first 4 chars bold | |
spanstring.setSpan(new StyleSpan(Typeface.BOLD), 0, 4, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); | |
// set the text of the button | |
sendButton.setText(spanstring); |
This file contains 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
// To open up a gallery browser | |
Intent intent = new Intent(); | |
intent.setType("image/*"); | |
intent.setAction(Intent.ACTION_GET_CONTENT); | |
startActivityForResult(Intent.createChooser(intent, "Select Picture"),1); | |
// To handle when an image is selected from the browser, add the following to your Activity | |
@Override | |
public void onActivityResult(int requestCode, int resultCode, Intent data) { |
This file contains 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
""" | |
Simple timer class. Example usage: | |
t = Timer() | |
for url in ('http://www.google.com/', 'http://www.yahoo.com/'): | |
t.start('fetch url') | |
content = urllib.urlopen(url).read() | |
t.stop('fetch url') | |
t.start('reorder bytes') | |
bytes = list(content) |