Skip to content

Instantly share code, notes, and snippets.

View laat's full-sized avatar
💤

Sigurd Fosseng laat

💤
View GitHub Profile
@laat
laat / soek.py
Created November 14, 2011 17:35
# coding=utf-8
"""
Simpel twittersøker skrevet i python
"""
from sys import stdin
from urllib import urlencode
import urllib2
import simplejson
@laat
laat / .vimrc
Created February 9, 2012 17:04
" window movement
no <C-L> <C-W>l
no <C-H> <C-W>h
no <C-J> <C-W>j
no <C-K> <C-W>k
@laat
laat / profile
Created February 27, 2012 09:47
JAVA_HOME="/usr/lib/jvm/java-6-sun"
export JAVA_HOME
# -*- coding: utf-8 -*-
"""
Copyright 2012 Sigurd Fosseng
You can do whatever you want with this stuff. If we meet some day, and
you think this stuff is worth it, you can buy me a beer or a coffee in
return.
Description:
Exports Spotify playlists that you own to *.xspf.
@laat
laat / gist:5007525
Created February 21, 2013 19:43
4+1 rette i lotto
(ncr(7,4) * (ncr(3,1) * ncr(24,2) + ncr(3,2) * ncr(24,1) + 1))/ncr(34,7)
@laat
laat / debatten.py
Last active December 17, 2015 22:19
Debatten på nrk
#!/usr/bin/env python
har_ordet = 1
partiledere = ["Erna", "Jens"]
while(True):
print partiledere[har_ordet % 2] + ": NEI NEI NEI, dette er fakta."
har_ordet += 1
@laat
laat / util.py
Created July 30, 2013 19:33
Enkel rendring av *text* templates med django. dvs, ikke html.
#encoding=utf-8
from django.core.mail import send_mail as djsend_mail
from django.template.loader import get_template
from django.template import Context
#>>> util.send_mail('events/index.html', "lol", "fra", "til", {'events': "dette er events"})
def send_mail(template, subject, fra , to, context):
if(isinstance(to, str)): # to can be both a list of strings or a string.
@laat
laat / fizzbuzz.py
Created September 26, 2013 10:41
fizzbuzz
import sys
map(lambda x: sys.stdout.write( x + "\n"), ["fizzbuzz" if not x % 15 else ("fizz" if not x % 3 else ("buzz" if not x % 5 else str(x))) for x in range(1, 101)])
@laat
laat / x-foo.html
Created March 21, 2014 16:39
Creating a custom element and polyfill css with Polymer platform.js
<script src="//cdnjs.cloudflare.com/ajax/libs/polymer/0.2.1/platform.js"></script>
<x-foo red></x-foo>
<template id="foo">
<style>
:host[red] {background-color: red;}
</style>
foo
</template>
@laat
laat / index.html
Created March 21, 2014 20:31
Ecmascript 6 Web Component.
<html>
<head>
<link rel="import" href="x-foo.html">
</head>
<body>
<x-foo></x-foo>
</body>
</html>