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 / 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 / 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]
#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 / laravel3to5.md
Last active July 22, 2016 04:57
Getting Input to work in laravel5

Laravel 5 decided to remove the global Input class. What are the implications to existing code bases? As usual the answer is "eh who cares? fuck em."

How does a responsible adult deal with a bunch of finickey novelty-obsessed designers who change specs and pull the rug out from you every 6 months?

Unfortunately I have no general answer to this confounding and dumbfounding lack of even the most basic discipline, but in the case of Input I do!

Adding a backwards-compatible Input into your laravel5 project

This can be reliably achieved through middleware.

This probably isn't the "right" way of doing things, but if you are one of those dweebs advocating to break every thing every month then sorry, you don't get a seat at the table.

@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],