Skip to content

Instantly share code, notes, and snippets.

@cronin101
cronin101 / labweekexercise.hs
Last active December 23, 2015 17:29
Any example of how not to complete a first-year Haskell lab.
-- Informatics 1 - Functional Programming
-- Lab Week Exercise
--
-- Week 2 - due: Friday, Oct. 1, 5pm
--
-- Insert your name and matriculation number here:
-- Name: Willip Fodler
-- Nr. : 01
@cronin101
cronin101 / labweekchess.hs
Created September 23, 2013 13:17
Functional programming beginners lab, exercises from 'Haskell: The Craft of Functional Programming'
-- Informatics 1 - Functional Programming
-- Lab week tutorial part II
--
--
import PicturesSVG
import Test.QuickCheck
import Control.Monad
data PieceColour = Black | White
@cronin101
cronin101 / pubkey
Created October 1, 2013 14:17
pub key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCwCOLe9uVcvLLP6d7RElk7wHSoDxqoDcbiMcfQqtufGhzO8+UgpC2AcZXyS3TYLgw3Ebf6/O8po+wUWJJp3l4FzFqqg/PuODFQ/aUOWBe5m050jSp7SRgDK8dXNm3XOITeJQ7tIBUJMMgQ2kFlZ5A+DOzHa2gYyY44u3gB5AZ4CL5XeCSb0+2DsAwM26XtsGIz7YJv19GaUlA2ocFYLwEOhyvdzftngCiT35oDlIiiBlx0snuwVrcH6aLizDnLgYfrpRNpSa35ApL9MKiv+S61ZLVoPy7RISp1aj5hLpmUMCHh/PlOwtikRXH527ry0nCppWsULm94ayjDBYq65vn cronin@espeon
@cronin101
cronin101 / errday_im_testing.py
Created October 5, 2013 12:05
wow, such reliability, much coverage
from tokenize import StringTokenizer
from overlap import OverlapScorer
import unittest
class TestOverlapScorer(unittest.TestCase):
def test_no_overlaps(self):
'''Queries share no words with documents so the scores should be 0'''
query_lines = [
'1 How to roll up pants?',
'2 How r babby formed?',
@cronin101
cronin101 / bees.py
Created October 5, 2013 13:18
More tests
from tokenize import StringTokenizer
from tfidf import TFIDFScorer
import unittest
class TestTFIDFScorer(unittest.TestCase):
def test_C_constant(self):
'''C should be set equal to the number of documents in the collection'''
def tokenize(line): return StringTokenizer(line)
document_lines = [
@cronin101
cronin101 / profile.sh
Last active December 25, 2015 01:09
How2profile
#!/usr/bin/env sh
python -m cProfile -o $1.prof $1.py
gprof2dot -f pstats -o $1.dot $1.prof
dot -o $1.png -Tpng $1.dot
echo "Open $1.png to view."
@cronin101
cronin101 / cheat.md
Last active December 25, 2015 10:59
Cheating with friends

#Cheating at 'scramble with friends'

Just to prove a point, horrible python but hacked together so excusable. Scored 800 points in a test round.

(ENV)λ  Python git:(master) ✗ time python scramble.py
Please enter line 1 delimited by spaces:
o e s e
Please enter line 2 delimited by spaces:
y s r u
@cronin101
cronin101 / redstone.md
Last active December 25, 2015 16:19
Redstone circuit ideas
@cronin101
cronin101 / demo.md
Last active December 26, 2015 07:39
no more $ hadoop dfs -

Starting up:

[bw1425n01]s0925570: ./hshell.rb

Clearing previous output:

s0925570@hadoop $ rmr ~/data/output
Deleted hdfs://bw1425n01.inf.ed.ac.uk/user/s0925570/data/output
@cronin101
cronin101 / tty
Created October 26, 2013 15:51
Testing random name generation for an anonymised chat client. Sometimes random selection works very nicely.
λ server git:(client/server-model) ✗ ruby pearserver.rb
# Connection from 1
<Ryan White(1)> yo
# Connection from 2
# Connection from 3
<James Maverick(2)> hey
<Daniel Harris(3)> what's up?
# Connection from 4
<Daniel Lannister(4)> hey
# Connection from 5