Skip to content

Instantly share code, notes, and snippets.

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

Joshua Quirk Lambdanaut

👁️‍🗨️
λ
View GitHub Profile
@Lambdanaut
Lambdanaut / ann.hs
Created March 10, 2014 21:53
Artificial Neural Network
module Main where
config_input_cells = 1 :: Int
config_hidden_layer_cells = 10 :: Int
config_hidden_layers = 2 :: Int
config_output_cells = 1 :: Int
-- [ [ (Threshhold, [Connection Weights] ) ] ]
type Net = [ [ (Double, [Double] ) ] ]
@Lambdanaut
Lambdanaut / vq.py
Created June 9, 2014 22:33
Integer Vector Quantization
""" Classifies a point as belonging to a cluster of points """
from math import sqrt
from random import shuffle
WIDTH = 28
HEIGHT = 28
POINT_TO_CLASSIFY = (2,4)
@Lambdanaut
Lambdanaut / gist:d980fb47e66a1a6dbd9b
Last active August 29, 2015 14:07
PHP Candidate interview questions
## Q
CSS:
Explain the difference between visibility:hidden; and display:none;
## A
Visibility:Hidden; - It is not visible but takes up it's original space.
Display:None; - It is hidden and takes up absolutely no space as if it was never there.
import random
class MM(object):
def __init__(self):
# Wordlist form = ['this','is','words']
# Graph form = [((1,1)],[(2,1)],[]]
# [((count, index)],[(count, index)],[]]
self.wordlist = []
self.graphlist = []
@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 = []