Skip to content

Instantly share code, notes, and snippets.

View artursapek's full-sized avatar

Artur Sapek artursapek

View GitHub Profile
@artursapek
artursapek / scrape_comet.py
Created October 17, 2011 06:12
comet_scrape
from BeautifulSoup import BeautifulSoup
from mechanize import Browser
def CometScrape(date):
br = Browser()
entry = None
br.open('http://www.comettavern.com/shows.php')
br.select_form(nr=0)
form = br.form
month = ['January', 'Feburary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][int(date[0:2]) - 1]
@artursapek
artursapek / gist:1708801
Created January 31, 2012 04:25
earliestTime(x)
def earliestTime(x):
conv = {}
for t in x:
a, b = t[:t.find('m')-1].split(':') if ':' in t else (t[:t.find('m')-1], 0)
conv[(int(a) * 60) + int(b) - (720 if 'am' in t else 0)] = t
return conv[min(conv.keys())].strip()
@artursapek
artursapek / looseSearch.py
Created February 17, 2012 23:17
A tolerant search function
import re
class finder():
# I got these dicts from someone on Stackoverflow. They translate common letters to visually similar unicode keys.
# This will let us match an N with a tilde to a regular N, for example
global unicode_to_text_Matches
unicode_to_text_Matches = { 161: '!', 192: 'A', 193: 'A', 194: 'A', 195: 'A', 196: 'A', 197: 'A', 198: 'Ae', 199: 'C', 200: 'E', 201: 'E', 202: 'E', 203: 'E', 204: 'I', 205: 'I',
206: 'I', 207: 'I', 208: 'Th', 209: 'N', 210: 'O', 211: 'O', 212: 'O', 213: 'O', 214: 'O', 216: 'O', 217: 'U', 218: 'U', 219: 'U', 220: 'U', 221: 'Y', 222: 'th', 223: 'ss', 224: 'a',
225: 'a', 226: 'a', 227: 'a', 228: 'a', 229: 'a', 230: 'ae', 231: 'c', 232: 'e', 233: 'e', 234: 'e', 235: 'e', 236: 'i', 237: 'i', 238: 'i', 239: 'i', 240: 'th', 241: 'n', 242: 'o',
@artursapek
artursapek / vmarker.js
Created February 22, 2012 20:03
this is an object library I wrote that creates interactive markers that represent venues on a map
// bandscape vmarker library written by Artur Sapek
// puts a venue's custom marker on the map and makes it interact with the Hub
vmarker = function(args){
for (var a in args){
this[a] = args[a];
}
this.draw(this.x, this.y, this.name);
}
vmarker.prototype.draw = function(x, y, name){
@artursapek
artursapek / jamLever Django template.html
Created February 22, 2012 20:07
Hearo.fm needed a "jam lever" that the user "pulls" (clicks) to set their status as "down to jam". This recursively preloads the images and animates it
<script type="text/javascript">
csrfTOKEN = '{{ csrf_token }}';
profileID = '{{ user.profile.id }}';
function setDownToJam(bool){
$.ajax({
type: 'POST',
url: '/jam/down-to-jam-ajax/',
data: {'csrfmiddlewaretoken': csrfTOKEN,
@artursapek
artursapek / UIobjects.js
Created February 22, 2012 20:19
Basically all of the UI objects we were using for bandscape (the concert aggregator)
// DOM objects used in bandscape main view
// author: Artur Sapek
// bandscape 2011
// pre: nothing
// post: returns top-right control on the map, date and city (city doesn't do anything) and injects into DOM
function dateControl(){
var me = this;
this.dropdownFairGame = true;
this.keepopen = false;
@artursapek
artursapek / elements.css
Created February 22, 2012 20:20
Stylesheet for bandscape
/*
bandscape CSS
author: Artur Sapek
*/
html, body{
height:100%;
margin:0px;
overflow:hidden;
background:#F5F5F6;
@artursapek
artursapek / fizzbuzz.py
Created February 22, 2012 21:22
fizz buzz
for i in range(0, 101):
d = {}
d[i % 3], d[i % 5] = 'Fizz', 'Buzz'
if 0 in d:
if len(d) == 1:
print 'FizzBuzz'
else:
print d[0]
else:
print i
@artursapek
artursapek / dis.py
Created April 20, 2012 18:23
.jpeg distorting
import random
image = open('e.jpg', 'r')
lines = ''.join(image.readlines())
image.close()
ran = int(random.random() * len(lines))
for i in range(0, int(str(ran)[:1])/2):
ran = int(random.random() * len(lines))
t = lines[ran:ran+ran*6]
cm.destroy(key)
.on('complete', function(){
$('span[item="' + key + '"]').remove();
})