Skip to content

Instantly share code, notes, and snippets.

💚
what a dumb feature

chris mckenzie kristopolous

Block or report user

Report or block kristopolous

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kristopolous
kristopolous / tcpdump-on-device.md
Created May 31, 2017
tcpdump on a device without disk space
View tcpdump-on-device.md

On the device to capture from we set up a FIFO that will be pushed off to another device on the network with disk, in this case we are using 192.168.1.11 as the "host"

On the host, we start up netcat that will be pushed into a capture file that we can analyze later, in this instance, we are listening on port 5001 $ nc -l -p 5001 > capture.cap

In a terminal on the device we make a fifo and then push it out over the network through netcat $ mknod /tmp/fifo p $ cat fifo | nc 192.168.1.11 5001

@kristopolous
kristopolous / simple-us-regex-phone-formatter
Created May 9, 2017
simple us regex phone formatter in JS
View simple-us-regex-phone-formatter
function phoneFormat(str) {
return str.replace(/[+1]*(\d{3})(\d{3})(.*)/, '1 ($1) $2-$3');
}
@kristopolous
kristopolous / Random selection from weighted set
Created Nov 22, 2016
An effecient random selector observing weighted sets
View Random selection from weighted set
(function(){
function verify(weights, chosen, trialCount) {
var variance = 0, ttl = chosen.length;
for(var ix = 0; ix < ttl; ix++) {
console.log(weights[ix], chosen[ix] / trialCount);
variance += Math.sqrt(Math.abs(Math.pow(weights[ix], 2) - Math.pow(chosen[ix] / trialCount, 2)));
}
console.log(variance / ttl);
}
@kristopolous
kristopolous / laravel3to5.md
Last active Jul 22, 2016
Getting Input to work in laravel5
View laravel3to5.md

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 Mar 10, 2016
A Javascript Priority Queue based on Array
View priority_queue.js
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 Apr 7, 2019
hn job query search
View hn_seach.js
function query() {
var
// HN is done with very unsemantic classes.
job_list = Array.prototype.slice.call(document.querySelectorAll('.c5a,.cae,.c00,.c9c,.cdd,.c73,.c88')),
query_list = Array.prototype.slice.call(arguments),
shown = 0, total = job_list.length;
// Traverses up the dom stack trying to find a match of a specific class
function up_to(node, klass) {
if (node.classList.contains(klass)) {
View gist:a48600348341007af943
#!/bin/bash
. ../ticktick.sh
``
key = [
{ "a" : [ 0, 1 ] },
{ "b" : [ 2, 3 ] }
]
``
@kristopolous
kristopolous / yo-dawg-toplevel.js
Last active Aug 29, 2015
Yo dawg, I heard you liked PHP and Javascript so I made your Javascript work like PHP...
View yo-dawg-toplevel.js
//
// 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 Dec 18, 2015
quick post scrpit
View gist:5757818
<!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>
View gist:5475117
#!/bin/bash
#############################################################
# #
# Program: mzoom #
# Author: dw #
# Date: 2007-07-07 #
# Purpose: Explore the Mandelbrot set in bash! #
# Usage: See below #
# Version: 1.01.6930 #
You can’t perform that action at this time.