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 / 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 / priority_queue.js
Created March 10, 2016 01:06
A Javascript Priority Queue based on Array
var Priority = (function(){
function sort(pri) {
if(pri.dirty) {
var sorted = pri.sort(function(a, b) {
return 1000000 * (b.priority - a.priority) + 0.0001 * (a.id - b.id);
});
pri.dirty = false;
pri.splice.apply([], [0, 0].concat(sorted));
@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 )
@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 / 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: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>
#!/bin/bash
#############################################################
# #
# Program: mzoom #
# Author: dw #
# Date: 2007-07-07 #
# Purpose: Explore the Mandelbrot set in bash! #
# Usage: See below #
# Version: 1.01.6930 #
#include<ppm.h>
#include<math.h>
#include<string.h>
typedef float mask;
#define HEIGHT 512
#define WIDTH 512
#define PI 3.14159265
typedef struct
@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],
@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]