Skip to content

Instantly share code, notes, and snippets.

@kgleeson
kgleeson / number.py
Created January 12, 2012 14:30
Find phone numbers in a file given as a command line argument
import re
import sys
with open(sys.argv[1]) as f:
text = f.read()
numberRE = re.compile('08[3-8][0-9]{7}')
for w in numberRE.findall(text):
print w
@kgleeson
kgleeson / gist:1666310
Created January 23, 2012 23:18
Finds all *.ext in path and appends to matches
import fnmatch
import os
matches = []
for root, dirnames, filenames in os.walk(path):
for filename in fnmatch.filter(filenames, '*.ext'):
matches.append(os.path.join(root, filename))
@kgleeson
kgleeson / buze_updater.py
Created February 10, 2012 19:44 — forked from zeffii/buze_updater.py
slow start.
'''
py 2.7
assumptions:
- buze is currently running in a dir located outside of program files
- the dir is either formatted like: buze-x.x.x or buze-x.x.x-revision
[x]- read externally the name of latest version and revision.
[ ]- if version and revision equal current, offer to cease now.
[x]- get current buze path, go up level.
'''
py 2.7
assumptions:
- buze is currently running in a dir located outside of program files
- the dir is either formatted like: buze-x.x.x or buze-x.x.x-revision
[x]- read externally the name of latest version and revision.
[ ]- if version and revision equal current, offer to cease now.
[x]- get current buze path, go up level.
import re, urllib
def openurl(number):
base_url = "http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing="
url = base_url + str(number)
webpage = urllib.urlopen(url)
body = webpage.read()
if not re.search('^and the next nothing is', body):
print body
return re.search('\d+$', body).group()
import csv
text = csv.reader(open('evoreg.csv', 'rb'), delimiter=';')
idList = ['Name', 'Boards', 'Age', 'Email', 'Games', 'Date']
for row in text:
gamesList = row[5].split(',')
print '='*80
for id, data in enumerate(row[1:7]):
if not id == 4:
require 'formula'
class Mysql < Formula
homepage 'http://dev.mysql.com/doc/refman/5.5/en/'
url 'http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.20.tar.gz'
md5 '375794ebf84b4c7b63f1676bc7416cd0'
depends_on 'cmake' => :build
depends_on 'readline'
depends_on 'pidof'
#include <stdio.h>
void print_options(){
printf(" Please choose an option \n");
printf(" 1: Balance Enquiry \n");
printf(" 2: Withdraw Funds \n");
printf(" 3: Quit \n");
}
void print_welcome(){
#!/usr/bin/env python
import pygame
pygame.init()
width, height = 500, 500
screen = pygame.display.set_mode((width, height))
running = True
colorRed = (255,0,0)
@kgleeson
kgleeson / gist:3035304
Created July 2, 2012 19:52
Python template
#!/usr/bin/env python
# encoding: utf-8
"""
untitled.py
Created by XXX XXX on YYYY-MM-DD.
Copyright (c) YYYY __MyCompanyName__. All rights reserved.
"""
import sys