Skip to content

Instantly share code, notes, and snippets.

"""ajaxgoogle.py - Simple bindings to the AJAX Google Search API
(Just the JSON-over-HTTP bit of it, nothing to do with AJAX per se)
http://code.google.com/apis/ajaxsearch/documentation/reference.html#_intro_fonje
brendan o'connor - gist.github.com/28405 - anyall.org"""
try:
import json
except ImportError:
import simplejson as json
import urllib, urllib2
@mvaz
mvaz / .gitattributes
Created December 1, 2009 11:35 — forked from program247365/.gitattributes
git configuration files for xcode projects
*.pbxproj -crlf -diff -merge
@mvaz
mvaz / renameBrokenSymlinks.py
Created December 13, 2009 21:34
rename broken symlinks
@mvaz
mvaz / Singleton Pattern
Created January 11, 2010 15:02
Thread-safe singleton pattern
public class Singleton {
private Singleton INSTANCE;
public static Singleton getInstance() {
if ( instance == NULL ) {
synchronized(Singleton.class) {
INSTANCE = new Singleton();
}
}
@mvaz
mvaz / testing.sql
Created February 3, 2010 17:25
SQL examples
CREATE DATABASE oinc;
USE oinc;
CREATE TABLE Employee (
ID INT(2) auto_increment primary key,
first_name VARCHAR(20),
last_name VARCHAR(30),
start_date DATE,
salary int(6),
@mvaz
mvaz / x.js
Created March 19, 2010 14:47 — forked from anonymous/x.js
/*var noun_type_train_station_start = {
name: "Train station",
label: "station",
default: "Stuttgart Hbf",
};*/
var noun_type_train_station = {
name: "Train station",
label: "station",
default: "Stuttgart Hbf",
@mvaz
mvaz / .htaccess
Created March 19, 2010 15:11 — forked from leebyron/.htaccess
Redirect links to dropbox
Options +FollowSymlinks
RewriteEngine on
# No intersticial for direct reference and self-reference
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://box.leebyron.com/.*$ [NC]
# Add a line item for every website you don't need an intersticial for
# I've added my own website, gmail and facebook
RewriteCond %{HTTP_REFERER} !^http(s)?://([^\.]*.)?leebyron.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://mail.google.com/.*$ [NC]
@mvaz
mvaz / gist:756055
Created December 27, 2010 11:16
Python main() functions
# taken from http://www.artima.com/weblogs/viewpost.jsp?thread=4829
import sys
import getopt
class Usage(Exception):
def __init__(self, msg):
self.msg = msg
def main(argv=None):
if argv is None:
@mvaz
mvaz / gist:756057
Created December 27, 2010 11:19
Using MySQLdb
import MySQLdb
conn = MySQLdb.Connect(host="localhost", port=3306, user="mvaz", passwd="whatever", db="trades")
cursor = conn.cursor()
sql = "select * from Users"
cursor.execute(sql)
rows = cursor.fetchall()
for row in rows:
print row
package de.tutorials;
import java.util.Date;
import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;