Skip to content

Instantly share code, notes, and snippets.

View ecounysis's full-sized avatar

Eric Christensen ecounysis

View GitHub Profile
@ecounysis
ecounysis / fib.py
Last active August 29, 2015 14:01
memoized fibonacci function in Python
import datetime
def fib(a):
if (a>2):
return fib(a-1) + fib (a-2)
elif (a==1 or a==2):
return 1
elif (a<1):
return 0
@ecounysis
ecounysis / add_junk.js
Last active August 29, 2015 14:01
Adds junk
while (document.body.childNodes.length>0) {
document.body.childNodes[0].remove();
}
var can=document.createElement("CANVAS");
can.width=1500;
can.height=1000;
can.id="t1000_500";
document.body.appendChild(can);
var ctx=can.getContext("2d");
@ecounysis
ecounysis / static.py
Created May 13, 2014 22:54
static in jython
from java.awt import Color
from javax.swing import JFrame
from java.awt.image import BufferedImage
from java.util import Random
from java.lang import Thread
def getBackground(WIDTH,HEIGHT,size):
rand=Random()
background = BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB)
@ecounysis
ecounysis / index.html
Created May 13, 2014 22:53
crazy graphics
<html>
<head>
<title>Canvas tutorial</title>
</head>
<body>
<canvas id="tutorial" width="1000" height="700"></canvas>
<script type="text/javascript">
var can=document.getElementById("tutorial");
import java.awt.*;
import javax.swing.*;
import java.awt.image.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.util.Random;
public class Static extends JFrame
{
static int HEIGHT;
@ecounysis
ecounysis / AShape.java
Last active August 29, 2015 14:01
the beginnings of a weird little game in java
import java.awt.*;
import javax.swing.*;
import java.awt.image.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.util.Random;
public class AShape
{
public int scale;
@ecounysis
ecounysis / creeper.py
Created May 9, 2014 05:31
the beginnings of a weird little game
import time, random, sys, pygame
from pygame.locals import *
i=0
rows=600
cols=1200
def getBackground(r,c,size):
@ecounysis
ecounysis / conway.py
Last active August 29, 2015 14:01
Conway's Game of Life stuff for kicks
import time, random, sys
myrules = [2, # <2 life->death, >=2 life->life
4, # <=4 life->life, >4 life-> death
3] # =3 death->life (REPRODUCE)
conwayrules = [2,3,3]
rules = conwayrules
startprob = float(sys.argv[1]) # a random selection of all cells will begin alive
@ecounysis
ecounysis / automata.py
Last active August 29, 2015 14:01
Elementary cellular automaton
import time
def st(a):
return "".join([str(k).replace("0","-").replace("1","X") for k in a])
def iter(a,r):
x=zeroes(width)
ww=width-1
@ecounysis
ecounysis / mymail.py
Last active August 29, 2015 14:00
CL email sender based on mailer.py (embedded)
FROM = 'default from address'
SERVER = 'default mailer server'
########################################################################################################################
# begin mailer.py
"""
mailer module
Simple front end to the smtplib and email modules,
to simplify sending email.