Skip to content

Instantly share code, notes, and snippets.

View lambda-fairy's full-sized avatar

Chris Wong lambda-fairy

View GitHub Profile
@lambda-fairy
lambda-fairy / gist:4425147
Last active December 10, 2015 11:08
KoL tiny plastic results
You open the blind-pack capsules and dump out the toys inside:
You acquire an item: tiny plastic Charity the Zombie Hunter
You acquire 2 tiny plastic fire servants
You acquire an item: tiny plastic Scott the Miner
You acquire an item: tiny plastic beebee queue
You acquire an item: tiny plastic cavebugbear
You acquire 2 tiny plastic the Free Men
You acquire 2 tiny plastic Queen Bees
You acquire 2 tiny plastic angry space marines
You acquire an item: tiny plastic Norville Rogers
@lambda-fairy
lambda-fairy / kol_turkey.py
Created December 14, 2012 22:36
Parse the KoL price log
"""Parse the file at <http://hogsofdestiny.com/kol/pricegun/dailyprice.log>"""
from urllib2 import urlopen
def read_prices(lines):
"""Given an iterator yielding the lines of the input file, return a dictionary mapping item IDs to prices."""
result = {}
for line in lines:
# Ignore comments
if line.startswith('#'):
@lambda-fairy
lambda-fairy / gist:4247514
Created December 9, 2012 23:38
Maze activity crash
Traceback (most recent call last):
File "/usr/bin/sugar-activity", line 146, in <module>
main()
File "/usr/bin/sugar-activity", line 104, in main
module = __import__(module_name)
File "/home/liveuser/Activities/Maze(GTK3).activity/activity.py", line 6, in <module>
from gi.repository import Gtk
File "/usr/lib64/python2.7/site-packages/gi/__init__.py", line 23, in <module>
from ._gi import _API, Repository
ImportError: could not import gobject (error was: ImportError('When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".',))
@lambda-fairy
lambda-fairy / prims.js
Created December 6, 2012 04:38
Prim's algorithm, naive implementation
/**
* Prim's algorithm
*
* __(')< written by lambda fairy
* \___)
*/
function reset_graph(g) {
function reset(thing) {
thing.set_type(0)
@lambda-fairy
lambda-fairy / pqueue.js
Created December 6, 2012 02:51
Inefficient priority queue
/**
* Extremely inefficient priority queue.
*
* In a real program this would probably be implemented as a heap,
* but this is good enough for this demonstration.
*/
function PQueue(comparator) {
this.comparator = comparator || function(x, y) { return x - y }
this.array = []
}
@lambda-fairy
lambda-fairy / ControlTest.hs
Created October 8, 2012 00:42
Thread spamming yay
import Data.Vector.Unboxed as V
main :: IO ()
main = print $ sumVector ones
sumVector :: (Num a, Unbox a) => Vector a -> a
sumVector = V.foldl' (+) 0
{-# NOINLINE ones #-}
ones :: Vector Int
@lambda-fairy
lambda-fairy / treasureChestgui.py
Created October 2, 2012 00:07
Treasure Chest GUI
#!/usr/bin/env python
"""
----------------
Treasure Chest
----------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
@lambda-fairy
lambda-fairy / parallel2.lua
Created September 15, 2012 08:38
parallel2 - a better parallel module
--[[
parallel2 - a better parallel module
====================================
@author Lambda Fairy (https://github.com/lfairy)
**parallel2** is a complete rewrite of the ComputerCraft parallel API.
It gives you many features over the original, including:
@lambda-fairy
lambda-fairy / Temperatures.hs
Created September 3, 2012 04:53
Solution for Lab 6 Exercise 2
-- | Solution for Lab 6 Exercise 2
module Temperatures where
import Control.Applicative
import Control.Arrow
import Data.Char
import Text.Printf
type Row = [Double]
@lambda-fairy
lambda-fairy / technic.py
Created August 28, 2012 08:17
Epic Technic downloader thingy
#!/usr/bin/env python
from argparse import ArgumentParser
from collections import namedtuple
import os
import requests
import yaml
TECHNIC_URL = 'https://github.com/TechnicPack/Technic/raw/master'