Skip to content

Instantly share code, notes, and snippets.

View kimmobrunfeldt's full-sized avatar

Kimmo Brunfeldt kimmobrunfeldt

View GitHub Profile
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from unicodedata import category
class Text(object):
def __init__(self, text):
@kimmobrunfeldt
kimmobrunfeldt / infinite.py
Created May 20, 2013 08:48
Haskell-style infinite "list" testing with Python.
"""
Haskell-style infinite "list" testing.
"""
def infinite_range(step):
i = 0
while True:
yield i
i += step
@kimmobrunfeldt
kimmobrunfeldt / bitcoin-watch.py
Created December 6, 2013 16:33
Watches bitcoin price at Bitstamp and sends alerts.
import json
import time
import urllib2
from decimal import Decimal
import smtplib
# Amount of percentage highest bitcoin bid order can change in time_window
# If this is exceeded, alert is called
@kimmobrunfeldt
kimmobrunfeldt / list-region-ec2.py
Created December 11, 2013 18:26
Lists all amazon EC2 instances in given region
from pprint import pprint
from boto import ec2
def main():
ec2conn = ec2.connection.EC2Connection(region=ec2.get_region('eu-west-1'))
reservations = ec2conn.get_all_instances()
instances = [i for r in reservations for i in r.instances]
for i in instances:
pprint(i.__dict__)
@kimmobrunfeldt
kimmobrunfeldt / blog-backend-api.py
Last active August 29, 2015 13:57
Simple blog REST API with Eve http://python-eve.org/. Install Mongo and Eve and you're good to go!
"""
1. Install Mongo
2. pip install eve
3. python blog-backend-api.py
"""
# Mongo setup
MONGO_PORT = 27017
MONGO_USERNAME = 'test-blog'
MONGO_PASSWORD = 'test-blog'
@kimmobrunfeldt
kimmobrunfeldt / 0-setup-osx.md
Last active August 29, 2015 13:58
How I setup my Mac for web development

How to setup OS X for web development

  • Download Command Line Tools for your OS X version from: https://developer.apple.com/downloads/

  • Install Homebrew, it's a third party package manager for OS X: http://brew.sh/

  • System preferences

    • Set key repeat fast and delay minimum from system preferences
    • Set screen auto dimming off
  • Disable rubber band scrolling

@kimmobrunfeldt
kimmobrunfeldt / johtika.sql
Created April 8, 2014 10:53
Find your points in Johtika
SELECT * from Opiskelija, Suoritus, Suorite WHERE SUORITUS.Opiskelija = Opiskelija.Opnum AND Suoritus.Suorite = Suorite.SuoriteID AND Opnum='XXXXXX';
#!/usr/bin/python
# -*- coding: UTF-8 -*-
#
# Written by Kimmo Brunfeldt
# IRClog stats generator.
import re
import sys
import time
import logger