Skip to content

Instantly share code, notes, and snippets.

View alcarney's full-sized avatar

Alex Carney alcarney

View GitHub Profile
@alcarney
alcarney / stylo-cmd.py
Last active March 22, 2019 23:19
Full code listing for a blogpost of mine - https://alcarney.me/blog/til-python-cmd/
import cmd
import textwrap
import matplotlib.pyplot as plt
from stylo import __version__
from stylo.color import FillColor
from stylo.image import LayeredImage
from stylo.shape import Circle, Square
@alcarney
alcarney / L_system.py
Created February 7, 2017 17:10
Using an L-System this draws the Sierpinski Triangle to a given level
import turtle
def run_system(seed, rule, iterations):
"""
Given the inital seed for the system and the rule function
run the system for the given number of iterations
"""
string = seed
@alcarney
alcarney / animation.py
Created June 21, 2016 16:24
This is the code used to generate the animation data for the video you can see here https://www.youtube.com/watch?v=AYvpyuF1bY0
import bpy
import csv
# This file is an attempt to work out the code needed to map
# results from Ciw to an animation in blender
# It requires the existence of objects with the following names
# in a blender scene:
# - Customer
# - Wait
# - Queue 1 Arrive
@alcarney
alcarney / CountLines.hs
Created November 19, 2015 16:26
A simple Haskell program to count the number of lines in a given file.
import System.Environment (getArgs)
countLines :: String -> IO Int
countLines file = do
contents <- readFile file
return (length $ lines contents)
main :: IO ()
main = do
args <- getArgs
@alcarney
alcarney / HelloWorld.hs
Created November 19, 2015 15:32
A Hello World program in haskell
main :: IO ()
main = putStrLn "Hello, World!"
@alcarney
alcarney / count_lines.c
Last active August 29, 2015 14:11
A simple C program to count all the lines in a file
#include <stdio.h>
#include <stdbool.h>
int main(int argc, char* argv[])
{
// Check that enough arguments were given
if(argc != 2)
{
fprintf(stderr, "Usage:\n\tcount_lines <filename>\n");
return 1;
@alcarney
alcarney / hello_world.c
Last active August 29, 2015 14:11
A Hello World program in C
#include <stdio.h>
int main (int argc, char* argv[])
{
printf("Hello, World!\n");
return 0;
}