Skip to content

Instantly share code, notes, and snippets.

View kalmas's full-sized avatar

Kyle Almas kalmas

View GitHub Profile
@kalmas
kalmas / diff-urls.sh
Last active June 26, 2017 16:12 — forked from thetristan/diff_url
Diff the response from 2 or more URLs.
#!/bin/bash
# Diff the JSON response from 2 or more URLs.
name=`basename $0`
if [ $# -lt 3 ]
then
echo "Usage: $NAME <path> <host 1> <host 2> <...>" 1>&2
echo "Example: $NAME /foo https://www.example.com https://www.google.com https://www.amazon.com" 1>&2
exit 1
@kalmas
kalmas / index.js
Created December 28, 2014 15:51
Bunyan File Logging With Cluster
'use strict';
var cluster = require('cluster');
var bunyan = require('bunyan');
if(cluster.isMaster) {
console.log('Master starting up! PID: ' + process.pid);
// Fork 20 workers.
for (var i = 0; i < 20; i = i + 1) {
/*
Example of
if() {
if() {
async()
}
}
then another async
@kalmas
kalmas / csv_find_n_replace
Created January 2, 2014 15:42
read through a 2 column csv. if a the first column value matches a key in the replacements dictionary, replace column 2 with the key value. just some boring throw away code that I feel like I'm always rewriting.
public function rewrite(){
$replacements = <<<EOD
{
"apple" : "fruit",
"tomato" : "fruit",
"kale" : "vegetable"
}
EOD;
$replacements = json_decode($replacements, true);
@kalmas
kalmas / proof1.js
Created February 1, 2013 18:38
Proof: JS Doesn't Execute After Navigation
(function () {
var $ = window.jQuery;
function init(){
logIt("1");
setTimeout(function(){logIt("2")}, 1000);
setTimeout(function(){logIt("3")}, 2000);
setTimeout(function(){logIt("4")}, 4000);
setTimeout(function(){logIt("5")}, 6000);
setTimeout(function(){logIt("6")}, 8000);
}
<?php
/*
Plugin Name: RSS Featured Image
Description: Add feature images to your blog rss.
*/
/*
* Code minimized from
* WP RSS Images (http://web-argument.com/wp-rss-images-wordpress-plugin/)
*/