Skip to content

Instantly share code, notes, and snippets.

Tom Manderson TRManderson

Block or report user

Report or block TRManderson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@TRManderson
TRManderson / graph.png
Last active Aug 29, 2015
In a meta-post on Lesswrong, Metus suggested someone plot a curve of comments over time, so I did. (see here: http://lesswrong.com/r/discussion/lw/lev/short_meta_should_open_threads_be_more_frequent/)
View gist:9249f3c761671a547ab7
set nocompatible
filetype off
set hidden
set wildmenu
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
"Bundle 'powerline/powerline', {'rtp': 'powerline/bindings/vim/'}
Bundle 'scrooloose/nerdtree'
Plugin 'bling/vim-airline'
View map.cs
static IEnumerable<R> Map<T, R>(this IEnumerable<T> seq, Func<T, R> f)
{
foreach (var t in seq)
yield return f(t);
}
@TRManderson
TRManderson / printout.py
Created Dec 11, 2015
Simple decorator to print evaluation result
View printout.py
def printout(f):
from functools import wraps
@wraps(f)
def g(*args, **kwargs):
r = f(*args, **kwargs)
print f.__name__+":",r
return r
return g
@TRManderson
TRManderson / Bytelandian-Exchange-1.py
Last active Dec 16, 2015
Solution to Reddit's r/dailyprogrammer challenge #121 [Easy] (Bytelandian Exchange 1)
View Bytelandian-Exchange-1.py
#http://www.reddit.com/r/dailyprogrammer/comments/19mn2d/030413_challenge_121_easy_bytelandian_exchange_1/
def coins (inputCoin):
if inputCoin == 0:
return 1
else:
return coins(inputCoin//2)+coins(inputCoin//3)+coins(inputCoin//4)
@TRManderson
TRManderson / Sum-Them-Digits.py
Last active Dec 16, 2015
Solution to Reddit's r/dailyprogrammer challenge #122 [Easy] (Sum them digits)
View Sum-Them-Digits.py
#http://www.reddit.com/r/dailyprogrammer/comments/1berjh/040113_challenge_122_easy_sum_them_digits/
def digitalRoot(number):
if number <= 10:
if number==10:
return 1
else:
return number
else:
digitSum=0
for i in str(number):
@TRManderson
TRManderson / Sum-Them-Digits.hs
Last active Dec 16, 2015
Solution to Reddit's r/dailyprogrammer challenge #122 [Easy] (Sum them digits) Haskell re-implementation of RDP-122-E.py
View Sum-Them-Digits.hs
#http://www.reddit.com/r/dailyprogrammer/comments/1berjh/040113_challenge_122_easy_sum_them_digits/
digitalRoot :: Integer -> Integer
digitalRoot n = if (n `mod` 9 == 0 && n > 0) then 9 else n `mod` 9
@TRManderson
TRManderson / Bytelandian-Exchange-2.py
Last active Dec 16, 2015
Solution to Reddit's r/dailyprogrammer challenge #121 [Intermediate] (Bytelandian Exchange 2)
View Bytelandian-Exchange-2.py
#http://www.reddit.com/r/dailyprogrammer/comments/1a7ca0/031313_challenge_121_intermediate_bytelandian/
def maxValue(coin):
if coin<=1:
return coin
else:
return max(coin,maxValue(coin/2)+maxValue(coin/3)+maxValue(coin/4))
@TRManderson
TRManderson / check_gh.py
Last active Jan 28, 2016
Repeatedly hit the Github status API to see if it's down or not (py2/3 compatible and cross-platform)
View check_gh.py
from __future__ import print_function
import requests
import os
import time
if os.name == "posix":
def sound():
os.system("play --no-show-progress --null --channels 1 synth 5 sin 440")
else:
@TRManderson
TRManderson / Makefile
Created Feb 20, 2016
My AVR makefile for a uni course last year
View Makefile
# Name: Makefile
# Author: Tom Manderson
# Based on https://github.com/obdev/CrossPack-AVR/
DEVICE = atmega324a
CLOCK = 8000000
PROGRAMMER = -c avrispmkii
OBJECTS = project.o buttons.o game.o ledmatrix.o score.o scrolling_char_display.o serialio.o spi.o terminalio.o timer0.o
AVRDUDE = avrdude $(PROGRAMMER) -p m324pa -F
COMPILE = avr-gcc -Wall -Os -std=c99 -DF_CPU=$(CLOCK) -mmcu=$(DEVICE)
You can’t perform that action at this time.