Skip to content

Instantly share code, notes, and snippets.

View un33k's full-sized avatar
🎯
Focusing

Val N. un33k

🎯
Focusing
View GitHub Profile
import re
import inspect
import pygraphviz as pgv
from django.conf import settings; settings.configure()
from django.views import generic
class GenericViewGraph(pgv.AGraph):
_ignore_types = (None, object)
def __init__(self, *args, **kwargs):
@un33k
un33k / deleting_file_field.py
Created September 23, 2011 04:28 — forked from jacobian/deleting_file_field.py
DeletingFileField
from django.db import models
from django.db.models import signals
class DeletingFileField(models.FileField):
"""
FileField subclass that deletes the refernced file when the model object
itself is deleted.
WARNING: Be careful using this class - it can cause data loss! This class
makes at attempt to see if the file's referenced elsewhere, but it can get
sudo apt-get update
sudo apt-get install python-dev python-software-properties
sudo add-apt-repository ppa:pitti/postgresql
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
@un33k
un33k / Facebook-commandline-reader.py
Created October 12, 2011 15:06
Facebook feed reader in command line
#http://blog.carduner.net/2010/05/26/authenticating-with-facebook-on-the-command-line-using-python/
#!/usr/bin/python2.6
import os.path
import json
import urllib2
import urllib
import urlparse
import BaseHTTPServer
import webbrowser
@un33k
un33k / facebook-connect.py
Created October 12, 2011 15:19
code required to connect to Facebook in python / django
import urllib
from django.http import HttpResponseRedirect
from django.conf import settings
from django.contrib.auth import login as auth_login
from django.contrib.auth import authenticate
from django.core.urlresolvers import reverse
# Step 1. when facebook login is clicked, this function is hit
# Things to know: we have an app_id and app_secret from facebook for out app / site
@un33k
un33k / config
Created October 18, 2011 01:58
create a config file in your .ssh file and set easy aliases (ssh web1), it will pass your name in as well
#vi .ssh/config
# add the following, you can repeat the pattern for each of your hosts
Host web1
HostName 192.168.15.129
User val
Port 22
@un33k
un33k / headless.command.sh
Created October 18, 2011 20:42
run vmware (linux) headless on mac of course
#!/bin/bash
/Library/Application\ Support/VMware\ Fusion/vmrun -T fusion start /Users/val/Documents/Virtual\ Machines.localized/db1.vmwarevm/db1.vmx nogui
@un33k
un33k / pickle.py
Created October 24, 2011 13:34
simple serialization of a python object
try:
import cPickle as pickle
except:
import pickle
import pprint
data1 = [ { 'a':'A', 'b':2, 'c':3.0 } ]
print 'BEFORE:',
pprint.pprint(data1)
@un33k
un33k / admin.py
Created October 25, 2011 02:00 — forked from uhop/admin.py
Adding Dojo's rich editor to Django's Admin.
# Example how to add rich editor capabilities to your models in admin.
from django.contrib.admin import site, ModelAdmin
import models
# we define our resources to add to admin pages
class CommonMedia:
js = (
'https://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js',
@un33k
un33k / reset_spotlight.txt
Created November 9, 2011 00:33
reset spot light metadata and disable it
To display the status of indexing
# mdutil -s /
To clear the metadata store
Turn indexing off for /
# mdutil -i off /
Clear the metadata store for /
# mdutil -E /
Turn indexing back on for /
# mdutil -i on /