Skip to content

Instantly share code, notes, and snippets.

View jasonsperske's full-sized avatar

Jason Sperske jasonsperske

View GitHub Profile
var page = require('webpage').create();
page.open('http://github.com/', function() {
page.render('github.png');
phantom.exit();
});

Keybase proof

I hereby claim:

  • I am jasonsperske on github.
  • I am sperske (https://keybase.io/sperske) on keybase.
  • I have a public key whose fingerprint is E40C A8A8 8284 94A9 823C 951D 7865 73E7 33D8 50FA

To claim this, I am signing this object:

@jasonsperske
jasonsperske / so.scheme
Created August 19, 2014 20:46
Nested for loops in scheme
(define (SO x y)
(let* ((x! (car x)) (y! (car y)))
(while (< x! (car (cdr x)))
(set! y! (car y))
(while (< y! (car (cdr y)))
(print (string-append (number->string x!) "-" (number->string y!)))
(set! y! (+ y! 1))
)
(set! x! (+ x! 1))
)
@jasonsperske
jasonsperske / GRPParser.py
Last active April 16, 2022 00:55
Like my WADParser.py but for Duke Nukem 3D MAP files
#!/usr/bin/env python3
import struct
import re
import io
from collections import namedtuple
GrpFileDefinition = namedtuple('GrpFileDefinition', 'name size')
Line = namedtuple('Line', 'a b is_one_sided')
@jasonsperske
jasonsperske / car_cdr.playground
Last active August 29, 2015 14:02
Getting aquainted with a new langauge. Really wish there was a splatter operator.
func car<T>(l: Array<T>?) -> T? {
if l == nil || l!.count <= 0 {
return nil
} else {
return l![0]
}
}
func cdr<T>(l: Array<T>?) -> Array<T>? {
if l == nil || l!.count <= 1 {
@jasonsperske
jasonsperske / MIT-LICENSE
Last active March 1, 2023 03:06
A simple Python program that can read DOOM.Hexen IWAD and PWAD files and render them as SVG see examples at http://jason.sperske.com/wad/
MIT License
Copyright (c) 2018 Jason Sperske
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@jasonsperske
jasonsperske / highlight.html
Created May 15, 2014 00:29
Basic System to highlight keywords in a textarea (http://jsfiddle.net/KcP7m/)
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<title>Textarea Highlighter</title>
<script src="//code.jquery.com/jquery-1.11.0.js" type="text/javascript"></script>
<style type="text/css">
#Status, #Highlighter {
width: 96%;
height: 250px;
font-family: Helvetica, Arial, 'lucida grande', tahoma, verdana, arial, sans-serif;
@jasonsperske
jasonsperske / Wave_Writer.cpp
Last active August 29, 2015 14:01
Small utility that generates a clean set of WAV files from any supported format of game-music-emu
// Game_Music_Emu 0.6.0. http://www.slack.net/~ant/
#include "Wave_Writer.h"
#include <assert.h>
#include <stdlib.h>
/* Copyright (C) 2003-2006 by Shay Green. Permission is hereby granted, free
of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without
@jasonsperske
jasonsperske / deepestNode.js
Last active July 12, 2017 20:44
Find the deepest left most node in a binary tree (and it's depth). A working demo can be found at: http://jsfiddle.net/YfLx6/5/
var Node = function(name, left, right) {
this.name = name;
this.left = left;
this.right = right;
},
findDeepest = function(node, depth) {
var left, right, depth = depth || 0;
if(typeof node !== 'undefined') {
left = findDeepest(node.left, depth+1);
right = findDeepest(node.right, depth+1);
@jasonsperske
jasonsperske / FencePainter.js
Last active February 3, 2018 03:43
Another Google technical interview question that left me stumped. "Write an algorithm that counts the number of ways you can paint a fence with N posts using K colors such that no more than 2 adjacent fence posts are painted with the same color". Here is a recursive approach:
var paint = function (posts, colors, display) {
var painter = function (posts, colors, fence, count, display) {
var color, total = count;
if (posts === 0) {
//Would you like to see them? Pass a display function
if(display) {
display(fence);
}
return 1;
} else {