Skip to content

Instantly share code, notes, and snippets.

View kristopolous's full-sized avatar
💣
New releases are coming soon!

chris mckenzie kristopolous

💣
New releases are coming soon!
View GitHub Profile
@kristopolous
kristopolous / omnilog.rb
Created June 29, 2012 20:46
OmniLogger
class OmniLog
attr_reader :available
def initialize(path)
@real = Logger.new(path)
@fake = Logger.new("/dev/null")
@available = Set.new
end
def add!(which)
@kristopolous
kristopolous / MontyHall.rb
Created September 12, 2012 00:36
Monty Hall Simulation done in readable ruby.
#!/usr/bin/ruby
$door_count = 3
$door_list = 0.upto($door_count - 1).to_a
$game_count = 10 * 1000
def percent(numerator, denominator)
return "%5.2f%" %[100 * numerator.to_f / denominator.to_f]
end
@kristopolous
kristopolous / cartalk_solution.rb
Created September 26, 2012 02:50
Simpsons Paradox puzzler solution
set = []
8.upto(1000).each { | x |
pop = []
8.step(x - 8, 8).each { | y |
popeye_2 = y
popeye_1 = x - y
bats = popeye_1 * 0.250
if bats.to_i == bats
hits = 3 * popeye_2 / 8 + bats
pop << [hits, popeye_1, popeye_2]
@kristopolous
kristopolous / SJT-Permutation.js
Last active August 28, 2016 16:01
The Steinhaus-Johnson-Trotter permutation algorithm in Javascript
function permute(array) {
// Identity
if(!array.length) {
return [];
}
var ret = [array],
len = array.length,
modlen = len - 1,
mover = array[modlen],
#include<ppm.h>
#include<math.h>
#include<string.h>
typedef float mask;
#define HEIGHT 512
#define WIDTH 512
#define PI 3.14159265
typedef struct
#!/bin/bash
#############################################################
# #
# Program: mzoom #
# Author: dw #
# Date: 2007-07-07 #
# Purpose: Explore the Mandelbrot set in bash! #
# Usage: See below #
# Version: 1.01.6930 #
@kristopolous
kristopolous / gist:5757818
Last active December 18, 2015 08:59
quick post scrpit
<!doctype html>
<html>
<head>
<style>
textarea,input { width: 600px}
iframe { width: 800px; height: 300px}
span { display:inline-block; width: 100px;vertical-align:top}
</style>
</head>
<body>
@kristopolous
kristopolous / yo-dawg-toplevel.js
Last active August 29, 2015 14:02
Yo dawg, I heard you liked PHP and Javascript so I made your Javascript work like PHP...
//
// toplevel.js
//
// TopLevel enables you to template your HTML, CSS, and Javascript at the Top Level
// (c) 2014 chris mckenzie. see LICENSE for more details.
// https://github.com/kristopolous/TopLevel for the latest version.
//
// Parts of this code use Jeremy Ashkenas' underscore library, available at
// https://github.com/jashkenas/underscore and protected by the license specified
// therein.
@kristopolous
kristopolous / gist:a48600348341007af943
Created June 23, 2014 20:20
weird shift behavior
#!/bin/bash
. ../ticktick.sh
``
key = [
{ "a" : [ 0, 1 ] },
{ "b" : [ 2, 3 ] }
]
``
@kristopolous
kristopolous / hn_seach.js
Last active July 24, 2023 04:12
hn job query search
// Usage:
// Copy and paste all of this into a debug console window of the "Who is Hiring?" comment thread
// then use as follows:
//
// query(term | [term, term, ...], term | [term, term, ...], ...)
//
// When arguments are in an array then that means an "or" and when they are seperate that means "and"
//
// Term is of the format:
// ((-)text/RegExp) ( '-' means negation )