Skip to content

Instantly share code, notes, and snippets.

View zephster's full-sized avatar

Brandon zephster

View GitHub Profile

Keybase proof

I hereby claim:

  • I am zephster on github.
  • I am zeph (https://keybase.io/zeph) on keybase.
  • I have a public key whose fingerprint is 391C F44B 0E38 89A7 CC01 B53C FA52 656B F3DE 41A4

To claim this, I am signing this object:

@zephster
zephster / gist:eeda67968dda6561d3b2
Created February 23, 2016 17:44
_recursive_array_search php
// returns null if $needle is not found anywhere in $haystack,
// or an array of $haystack keys to reference $needle where it is located within $haystack
// eg. [0]departure [1]connecting [2]0 => $haystack[departure][connecting][0] == $needle
private function _recursive_array_search($needle, $haystack)
{
foreach ($haystack as $key => $value)
{
if ($needle === $value)
{
return array($key);
@zephster
zephster / gist:942adc9cdfd9c6345a2d
Last active October 5, 2015 17:21
handlebars.js misc helpers
Handlebars.registerHelper({
// usage: {{inc @index}}
inc: function(value)
{
return parseInt(value) + 1;
},
// usage: {{#if_eq a b}} or {{^if_eq a b}} for not equal
if_eq: function(a, b, c, options)
{
if (typeof(c) === "object")
@zephster
zephster / gist:63b56047d585d396066a
Created June 30, 2015 15:45
css striped animated progress bar
<style>
.progress-bar {
padding: 5px;
height : 20px;
}
.progress-bar > span {
height : 100%;
display : block;
overflow : hidden;
@zephster
zephster / awmonitor.htm
Last active August 29, 2015 14:23
apple watch availability checker
<!doctype html>
<html>
<head>
<title>AWmonitor</title>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
</head>
<body>
<p>
AWmonitor, by brandon
</p>
@zephster
zephster / gist:8e5df481ad44800b1e49
Created April 10, 2015 14:42
pure css star ratings
<style>
.search-minimum-rating {
border : none;
float : left;
padding: 0;
}
.search-minimum-rating > input {
display: none;
}
.search-minimum-rating > label:before {
private function _diff($old, $new)
{
$diffs = array();
foreach ($old as $section => $v)
{
if (is_array($v))
{
$array_diffs = $this->_diff($v, $new[$section]);
@zephster
zephster / gist:efdf22a4126cce9bed87
Created October 24, 2014 18:55
twbs modal stacking
$(document).on('hidden.bs.modal', '.modal', function(e)
{
$(this).removeClass('bs-modal-stack');
$('body').data('bs_open_modals', $('body').data('bs_open_modals') - 1);
if ($(this).hasClass('is-clone'))
$(this).remove();
});
$(document).on('shown.bs.modal', '.modal', function (e)
@zephster
zephster / gist:11379095
Created April 28, 2014 17:48
js haversine
function calculateNearestCity(myGeo, cityGeo)
{
//using the Haversine formula - http://en.wikipedia.org/wiki/Haversine_formula
var deg2rad = Math.PI / 180,
cos = Math.cos,
sin = Math.sin,
earth = 6371; //radius of earth in km
var derivedLat = (cityGeo.lat - myGeo.lat) * deg2rad,
derivedLon = (cityGeo.lon - myGeo.lon) * deg2rad;
@zephster
zephster / gist:71888a897159835ce4f3
Created April 26, 2012 17:21
arbitrary uksort()
function custom_sort($a, $b) {
if ($a == $b) { return 0; }
$order = array("things", "i", "want", "in", "order");
$position = array_search($a, $order);
$position2 = array_search($b, $order);
if ($position !== false && $position2 !== false) return ($position < $position2) ? -1 : 1;
if ($position !== false) { return -1; }