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
def try_sending_email(): | |
import os, smtplib, mimetypes | |
from email.MIMEMultipart import MIMEMultipart | |
from email.MIMEBase import MIMEBase | |
from email.MIMEText import MIMEText | |
from email.Encoders import encode_base64 | |
gmail_user = '[user]@gmail.com' | |
gmail_password = '[password]' | |
recipient = '[recipient]' | |
msg = MIMEMultipart() |
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
# 2010-10-02 14h00 | |
# Update created field in user_prefs table | |
def migrate(db): | |
with db.select('user_id, created', from_='users'): | |
all_users = db.fetchall() | |
for user in all_users: | |
with db.update('user_prefs') as obj: | |
obj.created = user['created'] | |
db.where('user_id = %s', user['user_id']) |
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
#!/usr/bin/env python | |
"""\ | |
gexport.py | |
Export Google Docs to a local directory. | |
Requires the GData Python client library: | |
http://code.google.com/p/gdata-python-client/ | |
""" |
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
# sqlwitch tries to give you just the right amount of abstraction for fast MySQL-based web applications. | |
# Avoid complex and memory hungry ORM libraries while keeping your code easy to maintain: | |
def get_db_handler(db_auth): | |
conn = MySQLdb.connect(**db_auth) | |
cursor = conn.cursor(MySQLdb.cursors.DictCursor) | |
conn.set_character_set('utf8') | |
cursor.execute('set names utf8;') | |
cursor.execute('set character_set_connection = utf8;') | |
return sqlwitch(cursor, conn) |
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_random_id = function(len) { | |
var id = '', i = Math.ceil(len/2); | |
with(Math) while(i--) | |
id += (floor(random()*(256-16))+16).toString(16); | |
return id.substr(0, len); | |
} |
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
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAyoM5qaqZCLSYoB5IIH4uDMOR8VF2NPqc9pd2gMQYZKoc9pNlcBClfz9ZwT92TZejgG7EqHy/LYRY4w2Fp7y3im6zhGvMgcysUfRKUv6wViZDkEoOrVJl8eJAhuwugVGtkuE7kkq37+IcEjoUmMg53KCbrkW8tRiJz4c62MT49U5m5T08hyFsGoZl4QEEwJ1VQmDKuD4YMK9ekbWEafr7NKMgUXW5iKEKnCtiwtPI6z6/QYzW9Ci2gPkgvJERfBBdjYI1DCvFJI13rJ+kJLatXkMtjm2eBxec5eIAMuClBnV1sxcOnvGgJnd4BIrXAGTRAkxpvj4zWxDKu4i0+foElQ== jonas@celine |
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
utils = { | |
subset_of: function(arr) { | |
for(var i = arr.length, d = {}; i--;) d[arr[i]] = 1; | |
var p, before = 0, after = 0; | |
for(p in d) before++; | |
for(i = this.length; i--;) d[this[i]] = 1; | |
for(p in d) after++; | |
return after == before; | |
} | |
} |
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
// I wonder if there's anything like this already (there probably is) | |
Tag = function(name, content) { | |
this.name = name; | |
if(typeof content == 'function') { | |
this.content = content.call(null, this).toString(); | |
} else { | |
this.content = content; | |
} | |
}; |
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
var div = $('<div/>', { | |
id: 'example', | |
css: { | |
height: '100px', | |
width: '100px', | |
color: 'blue', | |
backgroundColor: 'green' | |
}, | |
click: function() { | |
$(this).css('backgroundColor', 'red'); |
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
// jQuery.fn.or | |
// | |
// $('.dont-exist').or('.does-exist') //=> [.does-exist]; | |
// $('.does-exist').or('.dont-exist') //=> [.does-exist]; | |
$.fn.extend({ | |
or: function(selector, context) { | |
if ($(this).length > 0) { | |
return $(this); | |
} else { |