Skip to content

Instantly share code, notes, and snippets.

View stianeikeland's full-sized avatar

Stian Eikeland stianeikeland

View GitHub Profile
import png
import random
imgsize = 900
img = [[random.randint(0, 255) for x in range(imgsize)] for y in range(imgsize)]
f = open('rnd.png', 'wb')
w = png.Writer(imgsize, imgsize, greyscale=True)
w.write(f, img)
@stianeikeland
stianeikeland / test.md
Last active December 19, 2015 00:09
Tasklist
  • this is a complete item
  • this is an incomplete item
@stianeikeland
stianeikeland / fromRoman.coffee
Created April 4, 2013 10:16
Bergen coding dojo - Roman numerals
_ = require 'underscore'
class FromRomanNumerals
baseValues: {
"I": 1
"V": 5
"X": 10
"L": 50

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@stianeikeland
stianeikeland / redirect-news.user.js
Created February 28, 2013 11:30
Avoid the stupid celebrity news at vg.no / db.no
// ==UserScript==
// @name          redirect
// @description    redirect
// @include        http://www.vg.no/
// @include http://www.dagbladet.no/
// @version        1.0
// ==/UserScript==
if (window.location == 'http://www.vg.no/')
window.location = 'http://www.vg.no/nyheter/'
@stianeikeland
stianeikeland / test.md
Created December 20, 2012 11:43
Markdown gist.io test

Dette er en test

Bacon ipsum dolor sit amet meatball tongue turkey ribeye. Ribeye meatball kielbasa pork turkey bresaola pork belly tongue, shoulder andouille beef ribs fatback. Capicola tri-tip bresaola, meatball drumstick leberkas sausage filet mignon andouille tongue beef strip steak jerky cow. Short loin sausage leberkas, ham rump meatball ball tip. Andouille turkey sirloin strip steak kielbasa short ribs, boudin ground round fatback sausage beef doner.

Corned beef cow prosciutto leberkas shankle, capicola boudin. Flank bacon pancetta brisket capicola beef ball tip beef ribs boudin short loin shank tail. Pork pastrami short loin bacon sausage meatball t-bone pork belly bresaola pork chop jerky meatloaf brisket kielbasa. Pork belly ball tip strip steak leberkas tongue. Ball tip jowl meatball brisket.

Sausage flank venison shoulder, meatball brisket jerky capicola salami pancetta pastrami swine pork loin biltong. Spare ribs ground round shank, drumstick t-bone corned beef sausage hamburger. Pork salami

@stianeikeland
stianeikeland / Program.cs
Created November 30, 2012 10:10
RabbitMQ consumer/producer
using System;
using System.Reactive.Linq;
using System.Text;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
namespace RabbitTest
{
class Program
{
#!/usr/bin/env bash
for i in {0..255} ; do
printf "\x1b[38;5;${i}mcolour${i}\n"
done
@stianeikeland
stianeikeland / msgbuspower.coffee
Created October 20, 2012 14:31
Power control on the message bus
power = new Power new MessageBus
# Power coffeemaker off 60 minutes after it was powered on:
power.on 'kitchen-coffeemaker', (event) ->
turnOff = () ->
power.send {
command: "off",
location: "kitchen-coffeemaker" }
setTimeout turnOff, 60*60*1000 if event.command is "on"
@stianeikeland
stianeikeland / subexample.coffee
Created September 24, 2012 16:13
Subscribe to sensor data.
sub = (require 'zmq').socket 'sub'
sub.connect 'tcp://raspberrypi:9999'
sub.subscribe 'sensor'
sub.on 'message', (topic, data) -> console.log "#{topic} => #{data}"