Skip to content

Instantly share code, notes, and snippets.

View DataKinds's full-sized avatar
💖
new blog theme! check it out at https://datakinds.github.io/

Tyler DataKinds

💖
new blog theme! check it out at https://datakinds.github.io/
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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
{-# 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