Skip to content

Instantly share code, notes, and snippets.

View jbeluch's full-sized avatar

Jonathan Beluch jbeluch

View GitHub Profile
from sqlalchemy.sql.expression import Insert
from sqlalchemy.ext.compiler import compiles
class Upsert(Insert):
'''Compiles an upsert expression for use with mysql.
Requires a keyword arg ``upsert_fields`` which lists field names to be updated in
the ON DUPLICATE KEY UPDATE clause.
'''
@jbeluch
jbeluch / gmailer.py
Created November 16, 2010 19:43
Send email from a gmail address
#!/usr/bin/env python
import smtplib
class GMail(object):
hostname = 'smtp.gmail.com'
port = 587
def __init__(self, username=None, password=None):
self.server = smtplib.SMTP(self.hostname, self.port)
self.server.ehlo()
@jbeluch
jbeluch / RTM-emailer.py
Created November 16, 2010 22:01
RTM Task Emailer
#!/usr/bin/env python
"""
RTM Task emailer
Emails all current incomplete RTM tasks. It uses a gmail account to
send the email.
SETUP:
Edit RTM_USERNAME, USERNAME, PASSWORD below
The first time you run the script, run it with the "auth" argument
#!/usr/bin/env python
# Copyright (C) 2011 by Jonathan Beluch
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
@jbeluch
jbeluch / scrape.py
Created March 1, 2011 22:21
Scrapes movies listed on classiccinemaonline.com and creates a histogram of movies per year.
#!/usr/bin/env python
'''
Jonathan Beluch - web@jonathanbeluch.com
Scrapes movie titles from http://www.classiccinemaonline.com and
creates a histogram showing the distribution of titles by year.
Requires BeautifulSoup, matplotlib and numpy.
'''
import xbmc, xbmcgui
url = 'rtmp://69.31.76.55:1935/ondemand/flvstream?_fcs_vhost=cp94207.edgefcs.net&akmfv=1.7/webtv_afrique/3125822'
playpath = 'webtv_afrique/3125822'
li = xbmcgui.ListItem(path=url)
li.setProperty('PlayPath', playpath)
li.setProperty('TcUrl', url)
xbmc.Player(xbmc.PLAYER_CORE_AUTO).play(url, li)
@jbeluch
jbeluch / aljazeera.sh
Created April 15, 2011 14:46
Stream AlJazeera Live (English) - http://english.aljazeera.net/watch_now/
#!/bin/sh
# Stream AlJazeera Live (English) - http://english.aljazeera.net/watch_now/
rtmpdump -v -r rtmp://livestfslivefs.fplive.net/livestfslive-live/ -y "aljazeera_en_veryhigh?videoId=747084146001&lineUpId=&pubId=665003303001&playerId=751182905001&affiliateId=" -W "http://admin.brightcove.com/viewer/us1.24.04.08.2011-01-14072625/federatedVideoUI/BrightcovePlayer.swf -p "http://english.aljazeera.net/watch_now/ -a "aljazeeraflashlive-live?videoId=747084146001&lineUpId=&pubId=665003303001&playerId=751182905001&affiliateId=" | mplayer -
@jbeluch
jbeluch / getfacebookidsfromemail.py
Created June 29, 2011 03:03
Get facebook ids for a list of email addresses.
#!/usr/bin/env python
'''A simple script for finding facebook profile ids for a given list of email
addresses.
Requires eventlet to be installed.
$ pip install eventlet
Also, currently requires a list of contacts exported from Google contacts.
Choose the outlook format and name the file 'contacts.csv' in this dir.'''
import XMonad
import XMonad.Hooks.FadeInactive
import XMonad.Config.Gnome
import XMonad.Hooks.ManageDocks
import qualified Data.Map as M
import XMonad.Util.EZConfig(additionalKeys)
import qualified XMonad.StackSet as W
import XMonad.Hooks.ManageHelpers
import XMonad.Layout.NoBorders
#!/usr/bin/env python
from xbmcswift import Plugin, download_page
from BeautifulSoup import BeautifulSoup as BS, SoupStrainer as SS
from urlparse import urljoin
import re
__plugin_name__ = 'Academic Earth'
__plugin_id__ = 'plugin.video.academicearth'
plugin = Plugin(__plugin_name__, __plugin_id__)