Skip to content

Instantly share code, notes, and snippets.

View iandioch's full-sized avatar
Ag déanamh tada

Noah Ó Donnaile iandioch

Ag déanamh tada
View GitHub Profile
@iandioch
iandioch / totients.go
Created December 31, 2015 02:28
Golang implementation of Euler's totient/phi function
/*
* Go implementation of Euler's product formula to find for the totient function (aka. phi function)
* https://en.wikipedia.org/wiki/Euler's_totient_function#Euler.27s_product_formula
*/
package main
import (
"fmt"
)
@iandioch
iandioch / permute.go
Created December 30, 2015 04:00
Basic permutation functions for Ints and Bytes in Go
// to use these functions, place this file in ./permute/permute.go and import "./permute"
// uses the "recursive algorithm" method from here: http://www.cut-the-knot.org/do_you_know/AllPerm.shtml
package permute
var level int
var value []int
var N int
var num int
var intPerms [][]int
var bytePerms [][]byte
@iandioch
iandioch / corpus_cleaner.py
Created November 26, 2015 05:43
Grabs just the tweet text from sentiment140 tweet corpus and discards the noise
# loads the CSV corpus file from the links here (http://help.sentiment140.com/for-students) and outputs just the tweet text
lines = []
with open("testdata.manual.2009.06.14.clean.txt", "w") as outfile:
with open("testdata.manual.2009.06.14.csv", 'r') as infile:
lines = infile.readlines()
for line in lines:
bits = line.split(",")
text = ",".join(bits[5:]).replace("&amp;", "&").replace("&lt;", "<").replace("&gt;", ">")
text = text[1:-2]
@iandioch
iandioch / average_colour.pde
Created October 2, 2015 16:24
Finds the average of a number of colours. Makes interesting palettes.
color a = color(255, 152, 145);
color b = color(52, 81, 255);
void setup(){
size(500,500);
}
void draw(){
fill(a);
noStroke();