Skip to content

Instantly share code, notes, and snippets.

Avatar
Caffeinating from Home

Jesse Donat donatj

Caffeinating from Home
View GitHub Profile
@donatj
donatj / ordmaker.php
Created Sep 25, 2014
Convert String to Escaped Hexadecimal Notation
View ordmaker.php
#! /usr/bin/env php
<?php
$data = $argv[1];
$split = str_split($data);
foreach($split as $ord) {
echo "\\x" . dechex(ord($ord));
}
@donatj
donatj / arrays_are_similar.php
Created Jul 22, 2014
Similar Array Checker - Regardless of Key Order
View arrays_are_similar.php
<?php
function arrays_are_similar( $aSide, $bSide ) {
$keys = array_unique(array_merge(
array_keys($aSide),
array_keys($bSide)
));
foreach( $keys as $key ) {
@donatj
donatj / _ScaledSpriteMap.scss
Last active Aug 29, 2015
SCSS Scaled Sprite Map
View _ScaledSpriteMap.scss
@mixin scaled-sprite-background($name, $scale, $spritemap) {
background: $spritemap;
$spritePath: sprite-path($spritemap);
@include background-size(image-width($spritePath) * $scale);
$position: sprite-position($spritemap, $name);
background-position: (nth($position, 1) * $scale) (nth($position, 2) * $scale);
height: image-height(sprite-file($spritemap, $name)) * $scale;
@donatj
donatj / getinfo.sh
Created Sep 20, 2013
Displays the OS X Finder "Get Info" dialog.
View getinfo.sh
#!/bin/sh
# Requires a POSIX-ish shell.
#
# Originally From: http://hayne.net/MacDev/Bash/show_getinfo
#
# show_getinfo
# This script opens the Finder's "Get Info" window
# for the file or folder specified as a command-line argument.
@donatj
donatj / index.php
Last active Dec 22, 2015
Turn the Penny Arcade DLC page into a *real* podcast.
View index.php
<?php
date_default_timezone_set('America/Chicago');
$subject = file_get_contents("http://penny-arcade.com/dlc");
preg_match_all('%<li[ >].*?<h4>(?P<title>.*?)</h4>.*?class="paDLCLink"[^>]href="(?P<file>.*?)".*?</li%si', $subject, $result, PREG_SET_ORDER);
header('Content-Type: application/rss+xml');
echo '<?xml version="1.0" encoding="UTF-8"?>';
@donatj
donatj / a_gearnan.log
Last active Dec 18, 2015
Gearman Compile Issue
View a_gearnan.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by gearmand configure 1.1.7, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure --prefix=/usr/local/Cellar/gearman/1.1.7 --with-mysql
## --------- ##
## Platform. ##
@donatj
donatj / sql_percent.php
Created May 29, 2013
Add percent markers to a SQL file for importing. Currently limited to 2 gigs in size.
View sql_percent.php
#!/usr/bin/env php
<?php
$file = @$argv[1];
if( !is_file($file) ) {
die('Please provide a SQL file' . PHP_EOL);
}
$file_size = filesize($file);
@donatj
donatj / jdonat.zsh-theme
Created May 8, 2013
My oh-my-zsh theme
View jdonat.zsh-theme
# local color_array=(cyan white yellow magenta black blue red default grey green)
# hostname | md5 -qr | cut -c1
if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
local return_code="%(?..%{$fg[red]%}%?↵%{$reset_color%})"
local time_code="%{%(?.$reset_color.$fg[red])%}%*%{$reset_color%}"
PROMPT='%{%(?.$fg[$NCOLOR].$fg[red])%}%n%{$fg[green]%}@%m%{$reset_color%} %(?..%{$fg[red]%})%~ \
$(git_prompt_info)\
%{$fg[red]%}%(!.#.»)%{$reset_color%} '
@donatj
donatj / 256color.php
Created Apr 4, 2013
Nearest Terminal Color Calculator
View 256color.php
<?php
$CLUT = array(
'00' => array( 0, 0, 0 ), '01' => array( 128, 0, 0 ),
'02' => array( 0, 128, 0 ), '03' => array( 128, 128, 0 ),
'04' => array( 0, 0, 128 ), '05' => array( 128, 0, 128 ),
'06' => array( 0, 128, 128 ), '07' => array( 192, 192, 192 ),
'08' => array( 128, 128, 128 ), '09' => array( 255, 0, 0 ),
'10' => array( 0, 255, 0 ), '11' => array( 255, 255, 0 ),
'12' => array( 0, 0, 255 ), '13' => array( 255, 0, 255 ),
@donatj
donatj / stupid.sh
Last active Dec 15, 2015
Stupid Bash Script
View stupid.sh
for (( ; ; ))
do
yes '-' | head -n$(($LINES * $COLUMNS)) | tr -d '\n'
sleep .3
yes '/' | head -n$(($LINES * $COLUMNS)) | tr -d '\n'
sleep .3
yes '|' | head -n$(($LINES * $COLUMNS)) | tr -d '\n'
sleep .3
yes '\' | head -n$(($LINES * $COLUMNS)) | tr -d '\n'
sleep .3