Skip to content

Instantly share code, notes, and snippets.

View palfrey's full-sized avatar

Tom Parker-Shemilt palfrey

View GitHub Profile
@palfrey
palfrey / zero-punctuation.py
Last active September 25, 2015 00:48
Zero Punctuation downloader
#!/usr/bin/python
from urlgrab import Cache
from BeautifulSoup import MinimalSoup as BeautifulSoup
from re import compile
from os.path import exists, getsize, dirname, join
from urllib import urlretrieve, urlencode, quote
from sys import argv
import demjson
import zlib
@palfrey
palfrey / gist:987722
Created May 23, 2011 22:03
Build your own Expression's
var lam = Expression.Lambda<Func<string, bool>>
(
Expression.Call
(
Expression.Invoke(
Expression.Lambda
(
Expression.Call
(
paramExpr,
@palfrey
palfrey / gist:987734
Created May 23, 2011 22:11
StringLike for EDMX
<Function Name="StringLike" ReturnType="Edm.Boolean">
<Parameter Name="searchingIn" Type="Edm.String" />
<Parameter Name="lookingFor" Type="Edm.String" />
<DefiningExpression>
searchingIn LIKE lookingFor
</DefiningExpression>
</Function>
@palfrey
palfrey / gist:987752
Created May 23, 2011 22:19
StringLike C# function
using System;
using System.Text.RegularExpressions;
public static class StringExtensions
{
[System.Data.Objects.DataClasses.EdmFunction("Your.Namespace", "StringLike")]
public static Boolean StringLike(this String searchingIn, String lookingFor)
{
if (searchingIn == null)
return false;
@palfrey
palfrey / create_author_collections.py
Created October 17, 2011 22:37
Create Author collections for Kindle
from kindle import *
from sys import argv, exit
if len(argv) == 1:
print "Usage: %s <kindle root folder>"%argv[0]
exit(-1)
k = Kindle(argv[1])
k.init_data()
try:
@palfrey
palfrey / HelloWorldApplet.py
Created February 28, 2012 23:06
Example applet stub
try:
from gi.repository import Gtk
except ImportError:
import gtk as Gtk
def applet_factory(applet, iid, data = None):
button = Gtk.Button("It works!")
applet.add(button)
applet.show_all()
return True
@palfrey
palfrey / gist:2221058
Created March 27, 2012 22:36
taskdef example
<taskdef name="echoFail" >
<stringparams>
<stringparam name="task" />
<stringparam name="message" required="false" />
</stringparams>
<do>
<property name="customMessage" value="__message__" />
<if test="${customMessage == ''}" >
<property name="customMessage" value="this is a default message" />
@palfrey
palfrey / gist:2221164
Created March 27, 2012 22:45
funcdef example
<funcdef name="testFunc" namespace="tests">
<funcparams>
<funcparam name="test" type="string" />
</funcparams>
<do>
<property name="__$return__" value="__test__" />
</do>
</funcdef>
<fail unless="${tests::testFunc('foo') == 'foo'}" />
@palfrey
palfrey / grabber.py
Created August 12, 2012 11:58
Price checker for olympic tickets
  1. Download grabber.py and settings.py.example. Rename the latter to settings.py and edit as appropriate for your local system.
  2. git clone https://github.com/palfrey/urlgrab.git urlgrab
  3. Run python grabber.py <event id> <max price> (where event id is from a page like http://www.tickets.london2012.com/eventdetails?id=000046BFAE4D12A7 and is that id field at the end)

You will now get emailed once a ticket becomes available at that price, and every time after that when prices drop further.

@palfrey
palfrey / gist:7021931
Created October 17, 2013 09:32
Broken CloudFormation setup
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Test servers",
"Parameters" : {
"Environment" : {
"Type" : "String",
"Default" : "dev",
"Description" : "Environment name",