Skip to content

Instantly share code, notes, and snippets.

@micaiahparker
micaiahparker / bfz.zig
Last active October 30, 2019 19:31
BF interpreter in Zig
const std = @import("std");
const io = std.io;
const File = std.fs.File;
const debug = std.debug;
const process = std.process;
const mem = std.mem;
const assert = debug.assert;
const warn = debug.warn;
const allocator = debug.global_allocator;

Keybase proof

I hereby claim:

  • I am micaiahparker on github.
  • I am micparke (https://keybase.io/micparke) on keybase.
  • I have a public key whose fingerprint is 6408 7079 A855 D083 A2BA 53B7 76BD 330A 1759 4100

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am micaiahparker on github.
  • I am micparke (https://keybase.io/micparke) on keybase.
  • I have a public key ASASNSTmmw_csuFBituAY3en7SN3BWxHa2D-elcK6Jdm4Ao

To claim this, I am signing this object:

Hey there, this is a test gist.
@micaiahparker
micaiahparker / gifextract.py
Last active July 28, 2016 02:09 — forked from BigglesZX/gifextract.py
Extract frames from an animated GIF, correctly handling palettes and frame update modes
import os
from PIL import Image
import sys
'''
I searched high and low for solutions to the "extract animated GIF frames in Python"
problem, and after much trial and error came up with the following solution based
on several partial examples around the web (mostly Stack Overflow).
class Node:
def __init__(self, key, value, parent):
self.key = key
self.value = value
self.parent = parent
self.left = None
self.right = None
self.set_children()
def add(self, key, value):
class Build:
tag = 'build'
known = {}
def __init__(self, xml):
self.name = ""
self.desc = ""
self.contents = {}
self.get_known()
self.build(xml)
class Grid():
def __init__(self, rows, cols, fill = 0):
self.rows = rows
self.cols = cols
self.fill = fill
self.grid = self.make_grid(self.rows, self.cols, self.fill)
def make_grid(self, rows, cols, fill):
#return [[self.fill for col in range(self.cols)] for row in range(self.rows)]
local = []
for row in range(self.rows):
def is_prime_short(number):
return number == 2 or number > 1 and number % 2 != 0 and not any(i for i in range(3, int(math.sqrt(number)+1), 2) if number % i == 0)
"""
Its actually pretty simple
First - if its 1 or less - false
Second - if its 2 - true
Third - if its even - false
Fourth - the speedy meat - check between 3 and the square root of the number you want rounded up + 1 and only check odd numbers.
if the number you are checking is divisible by (i) you are not prime - false
Fifth - True
import math
def isPrime(number):
return number > 1 and number % 2 != 0 and not any([i for i in range(3, int(math.sqrt(number)+1),2) if number % i == 0])