Skip to content

Instantly share code, notes, and snippets.

View Lambdanaut's full-sized avatar
👁️‍🗨️
λ

Joshua Quirk Lambdanaut

👁️‍🗨️
λ
View GitHub Profile
@Lambdanaut
Lambdanaut / SheezyArtSpider.hs
Created July 20, 2011 04:54
A spider for crawling Sheezyart.com and determining social connections between users. It has also been confirmed to work on Deviantart.com with slight adjustment.
module SAScan where
import Network.Shpider
import System.Posix.Unistd
import Data.List
import Char
firstUser = "theprototype"
toLoad = False
savedFile = "SASaved"
@Lambdanaut
Lambdanaut / GPA Calculator
Created July 22, 2011 20:25
A snippet for calculating a Grade Point Average based on letter grades
;A list of your grades. Change this to reflect your grades and run the program.
( def grades '(\a \b \c \d \f \d \c \b \a) )
;Function for mapping grades to numbers and then averaging them.
( def gpaList '{\a 4, \b 3, \c 2, \d 1, \f 0} )
( defn gpa [grades] (double (/ ( reduce + (map (fn [x] (get gpaList x)) grades ) ) (count grades) ) ) )
;Prints out your GPA
( println (gpa grades ) )
@Lambdanaut
Lambdanaut / Board.txt
Created September 3, 2011 17:22
A Haskell game of life using SDL for graphics. I moved it from a repository to keep things tidy.
------------------------------------
------------------------------------
------------------------------------
------------------------------------
------------------------------------
------------------------------------
------------------------------------
------------------------------------
------------------------------------
--------------xx--------------------
@Lambdanaut
Lambdanaut / Python GE
Created September 3, 2011 17:24
A Simple Genetic Algorithm in Python for finding the best way to represent a number as a (limited) polynomial.
from random import randint
#GE
#Constants
gens = 150
popNum = 30
mutRate = 20 # Rate of mutation = 1/mutRate
goal = 97
chromosomeLength = 24 # Must be a multiple of 5 - 1. Example: 14, 19, 24, 29, 34
@Lambdanaut
Lambdanaut / Haskell Naturally Selecting Algorithm
Created September 5, 2011 06:03
I've got a pain fetish so I decided to wrestle a program making heavy use of System.Random WITHOUT a State Monad. When I got to the point where I needed to add a mutation rate I decided it works fine enough as it is without one, so here you go! (Technical
module GE where
import System.Random
import Data.List (elemIndex)
import Control.Monad (foldM)
type Aminal = [Int]
type Population = [Aminal]
gen = 10 {- GENERATIONS -}
pop = 10 {- POPULATION NUMBER -}
@Lambdanaut
Lambdanaut / gist:1209033
Created September 11, 2011 01:07
A Falling Sand game made using Python2 & SDL
#!/usr/bin/python
#An experimental falling(or rising, in this case) sand game coded by Lambdanaut
import pygame, sys, os, random
from pygame.locals import *
if sys.platform == 'win32' or sys.platform == 'win64':
os.environ['SDL_VIDEO_CENTERED'] = '1'
#Init Variables
def popRoom(x,y):
room = []
@Lambdanaut
Lambdanaut / todo.py
Created September 22, 2011 02:45
A tool for managing tasks.
#! /usr/bin/python
import sys, os, pickle
header = "todo.py: A tool for managing tasks\n==================================\n "
def path():
pathname = os.path.dirname(sys.argv[0])
return os.path.abspath(pathname)
@Lambdanaut
Lambdanaut / love.py
Created January 20, 2012 19:26
A Genetic Algorithm that I wrote for Catherine K
#! /usr/bin/python
import random
#goal = "This message evolves like my love for you. I'll always love you, Cat. -Josh <3"
goal = "I Love You Cat"
generations = None
popSize = 25
mutation = 150 #Bigger = Less mutation
@Lambdanaut
Lambdanaut / index.html
Created March 10, 2012 22:09
A Proof of Concept simulation of a bunch of different types of cells that can connect to make larger organisms. Requires JsGameSoup
<html>
<head>
<script src="jsGameSoup/js/jsgamesoup.js"></script>
<script src="jsGameSoup/js/random.js"></script>
<script src="jsGameSoup/js/sprite.js"></script>
<script src="jsGameSoup/js/collisions.js"></script>
<script src="main.js"></script>
</head>
<style>
html, body {
@Lambdanaut
Lambdanaut / Classify.py
Created April 2, 2012 06:54
A Naive Bayesian Classifier. The Classifier class can be trained by "classifier.train(True,'I am so happy!')" or "classifier.train(False,'I am a sad man. ')". To check if something falls in either the True or the False category.
#! /usr/bin/python2
from __future__ import division
from ignoreWords import *
class Classifier:
def __init__ (self):
self.examples = []