Skip to content

Instantly share code, notes, and snippets.

View DataKinds's full-sized avatar
🏳️‍⚧️
owo

Tyler DataKinds

🏳️‍⚧️
owo
View GitHub Profile
{-# LANGUAGE BangPatterns #-}
--Enables strict arguments, the X in mandelbrot
import Data.Complex
import Data.List
maxIter :: Int
maxIter = 50
xMin, xMax, xPrecision, yMin, yMax, yPrecision :: Double
@DataKinds
DataKinds / gol.hs
Last active August 29, 2015 14:07
Fun little game of life implementation, based on https://www.youtube.com/watch?v=a9xAKttWgP4
import Control.Applicative
import Control.Concurrent
import System.Console.ANSI
import Data.List.Split
import Data.Char
mainGridString :: IO String
mainGridString = readFile "grid"
parseGrid :: String -> Grid
@DataKinds
DataKinds / lsystem.py
Last active August 29, 2015 14:10
L-System stuff
import turtle, random
from lsystemconfig import *
stack = []
def iterateLSystem(system, rule):
mutatedLSystem = ""
for char in system:
charAccountedFor = False
for oneRule in rule:
@DataKinds
DataKinds / mandelgolf.hs
Last active August 29, 2015 14:10
Codegolfed Mandelbrot Renderer
import Data.Complex
import Data.List
main=let(q,w,e,r,t,y,u)=(-2,1,0.01,-1.25,1.25,0.01,9)in writeFile"m.pgm"(("P2\n"++(show$length[q,(q+e)..w])++" "++(show$length[t,(t-y)..r])++"\n1\n")++((unlines.map(unwords.map(unwords.map show)))$((map.map)(\x->if x==(-1)then[0]else[x]))((map.map)(\c->(\c->if(magnitude$((iterate((\b a->a^2+b)c)(0:+0))!!u))>2then-1else 1)c)[[a:+b|a<-[q,(q+e)..w]]|b <-[t,(t-y)..r]])))
@DataKinds
DataKinds / ircbot.rb
Last active August 29, 2015 14:10
Code Runner Cinch IRC Bot
require 'cinch'
class CodeRunner
include Cinch::Plugin
match /(ruby|python|haskell|perl|cjam):.+/, use_prefix: false
def runCode(code, interpreter)
badKeywords = ["\`", "popen", "gets", "STDIN", "interact", "input", "system", "File", "file", "IO", "eval", "exec", "open", "write", "read", "Socket"]
@DataKinds
DataKinds / newton.py
Last active September 11, 2016 01:36
Newton Fractal Renderer
import numpy as np
import colorsys
import cmath
import math
from multiprocessing import Process, Queue
# max: maximum coord to render to
# min: minimum coord to render to
# step: how much 1 pixel counts as
# chunkFactor: how many images to split it up into - allows for multithreading
@DataKinds
DataKinds / cursorhandler.py
Last active August 29, 2015 14:10
Fungeoid IDE
def safeMoveCursor(stdscr, direction, screenPosition, screenSize, cursorPosition, padX, padY):
if direction == "up":
if cursorPosition[0] == 0:
if screenPosition[0] > 0:
screenPosition[0] -= 1
else:
stdscr.move(cursorPosition[0] - 1, cursorPosition[1])
elif direction == "down":
if cursorPosition[0] == screenSize[0] - 1:
if screenPosition[0] < padY - screenSize[0]:
@DataKinds
DataKinds / simplefunge.rb
Created December 10, 2014 02:45
Simplefunge Ruby Onefiler
if ARGV.length != 1
puts "Must take input file as single argument."
exit
end
program = ARGF.read.split(?\n)#.map{|line| line.split() }
pointer = [0, 0]
direction = :right #left up down
stack = []
ins = ""
@DataKinds
DataKinds / bueue.rb
Last active August 29, 2015 14:11
Bueue fun
# Language specification
# A @bueue program is a simple number
# The @bueue interpreter generates the collatz sequence
# of that number and interprets each number in it as
# a small subprogramm.
#
# There is a queue available which can store bits.
# Opcodes mod 10:
# 0 - enque 0
# 1 - enque 1
@DataKinds
DataKinds / randombf.rb
Created December 13, 2014 04:52
Random BF Generator
def genBF(seed, length)
prng = Random.new(seed)
program = ""
loopDepth = 0
length.times do
ins = [?+, ?-, ?<, ?>, ?,, ?., ?+, ?-, ?<, ?>, ?,, ?., ?[, ?]].sample(random: prng)
ins = ?[ if loopDepth <= 0 and ins == ?]
loopDepth += 1 if ins == ?[
loopDepth -= 1 if ins == ?]
program += ins