Skip to content

Instantly share code, notes, and snippets.

@myusuf3
myusuf3 / americancensorship.html
Created November 16, 2011 15:26
Add this to all your websites
<script type="text/javascript" src="http://americancensorship.org/js"></script>
<!-- for long page issues -->
<style type="text/css">
#signupmodal-overlay {
height: 10000% !important;
}
div#signupmodal-lightbox {
@myusuf3
myusuf3 / tasks.py
Created October 19, 2011 07:17
Checking the state of a task
#assume that task upload already exsists
>>> task = upload_to(note, **kwargs):
>>> print task.state
'PENDING'
# if you are having problem with your 500 pages not rendering properly.
from django.conf.urls.defaults import *
#bad python practice but makes this easier
handler500 = 'webcomic.views.server_error'
# in views!
def server_error(request):
return render(request, '500.html')
@myusuf3
myusuf3 / fa.sh
Created September 27, 2011 04:06
» echo $PATH
/usr/local/lib:/home/myusuf3/Node/node/bin:/home/myusuf3/android_sdk/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
from haystack.query import SearchQuerySet
class MyResource(Resource):
def build_filters(self, filters=None):
if filters is None:
filters = {}
orm_filters = super(MyResource, self).build_filters(filters)
if "q" in filters:
# to enable new site.
sudo a2ensite brodidyouhear.com
# reload apache
sudo /etc/init.d/apache2 reload
@myusuf3
myusuf3 / apachesite.sh
Created September 14, 2011 03:05
apache site for wsgi application
# i would suggest naming the file that this is contained in after the website.
# this will respond to everything on port 80 regardless of the site.
<VirtualHost *:80>
# this will limit it to requests coming to brodidyouhear.com
ServerName brodidyouhear.com
# apps directory
DocumentRoot /srv/www/brodidyouhear.com/brodidyouhear
<Directory /srv/www/brodidyouhear.com/brodidyouhear>
import os
import sys
# this line is added so python is aware of the application
# this is absolute path to the app.
sys.path.append('/srv/www/brodidyouhear.com/brodidyouhear')
# this is simply a check to see if the site is in syspath as well this is one directory up from application
path = '/srv/www/brodidyouhear.com'
if path not in sys.path:
@myusuf3
myusuf3 / django-db.sh
Created September 14, 2011 02:14
connecting to database with mysql
# First you will need to install python drivers for mysql
sudo apt-get install python-mysqldb
# Now go to your settings.py, enter the credentials you setup during the database creation process of the tutorial
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'testdb',# Or path to database file if using sqlite3.
'USER': 'testuser', # Not used with sqlite3.
@myusuf3
myusuf3 / sh.sh
Created September 14, 2011 02:03
# connect as root to the MySQL server
# all this is saying connect as user 'root' with password i am going to provide.
# you will be prompted for password after you press enter.
mysql -u root -p
# Once you are connected you will be presented with the following prompt
mysql>
# if you want to learn type in
mysql> /h