Skip to content

Instantly share code, notes, and snippets.

View un33k's full-sized avatar
🎯
Focusing

Val N. un33k

🎯
Focusing
View GitHub Profile
import datetime
import mechanize
from xml.etree import cElementTree
USERNAME = '...'
PASSWORD = '...'
NUMBER = '2025551212'
br = mechanize.Browser()
br.open('https://ebillpay.verizonwireless.com/vzw/accountholder/overview/AccountOverview.action')
@un33k
un33k / gist:1007493
Created June 4, 2011 02:31 — forked from jacobian/gist:336445
Installing GeoDjango deps on Ubuntu 9.10
### Install some packages. Ignore the errors.
aptitude install binutils libgdal1-1.5.0 postgresql-8.3-postgis postgresql-server-dev-8.3 python-psycopg2 python-setuptools
### Make connecting to postgres easier
echo "local all all trust" > /etc/postgresql/8.3/main/pg_hba.conf
invoke-rc.d postgresql-8.3 reload
### Become the Postgres user to create a spatial template database:
@un33k
un33k / add_user_info_to_request_middleware.py
Created June 5, 2011 03:51 — forked from sidmitra/add_user_info_to_request_middleware.py
Middleware to add user info to the current django request
class ExceptionUserInfoMiddleware(object):
"""
Adds user details to request context on receiving an exception, so that they show up in the error emails.
Add to settings.MIDDLEWARE_CLASSES and keep it outermost(i.e. on top if possible). This allows
it to catch exceptions in other middlewares as well.
"""
def process_exception(self, request, exception):
"""
@un33k
un33k / middleware.py
Created June 5, 2011 03:54 — forked from pmclanahan/middleware.py
Django 1.2+ middleware that allows you to set cookies from a request object.
from types import MethodType
from django.http import CompatCookie, HttpRequest
def _set_cookie(self, key, value='', max_age=None, expires=None, path='/',
domain=None, secure=False):
self._resp_cookies[key] = value
self.COOKIES[key] = value
if max_age is not None:
@un33k
un33k / config
Created August 12, 2011 18:27
Ssh Alias Config
# create a file called .ssh/config
Host aliasname
HostName your.domain.name
User your_ssh_username
Port 1234
# Example
Host web1
HostName 192.168.2.122
@un33k
un33k / gmail notification
Created August 15, 2011 14:04
Gmail Notification On OSX to checke every minute
# Open Terminal and paste in the following:
defaults write com.google.GmailNotifier AutocheckInterval 1
@un33k
un33k / gist:1161554
Created August 22, 2011 02:47
Reset spotlight on osx and Start indexing again
To reset the data cache on your Mac’s hard drive,
sudo mdutil -E /
To force Spotlight to immediately start re-indexing your hard drive (this might take a few hours and is probably best left to run overnight), enter this command:
sudo mdutil -i on /
@un33k
un33k / sed cheatsheet
Created August 22, 2011 13:28
magic of sed -- find and replace "text" in a string or a file
FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
@un33k
un33k / bash-args-options
Created August 23, 2011 13:42
Bash - Simple Skeleton for arg parsing in bash
#!/bin/bash
# Argument = -t test -r server -p password -v
usage()
{
cat << EOF
usage: $0 options
This script run the test1 or test2 over a machine.
@un33k
un33k / colourful logs (txt)
Created September 21, 2011 02:17
Take some text and print each line in different colour based on regex input (http://code.google.com/p/c4lt/)
#!/usr/bin/python -u
#
# c4lt - simple log lines colorer filter
#
# Copyright (C) 2011 Yaroslav Pogrebnyak <yyyaroslav@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.