Skip to content

Instantly share code, notes, and snippets.

@alexstone
alexstone / hash_params.js
Created April 9, 2018 15:54
Functions to help with fetching and updating parameters from the URI hash
/*
|--------------------------------------------------------------------------
| Get parameters from the URI hash
|--------------------------------------------------------------------------
*/
function getParamsFromHash() {
var rawHash = window.location.hash.substr(1);
var hashParts = rawHash.split(';');
var paramData = {};
hashParts.forEach(function(part) {
@alexstone
alexstone / delay.js
Created April 9, 2018 15:53
Function for delaying input from a user to prevent firing events on every keyUp
var delay = (function(){
var timer = 0;
return function(callback, ms) { clearTimeout (timer); timer = setTimeout(callback, ms); };
})();
@alexstone
alexstone / comichron_sales_parse.php
Created June 8, 2014 17:27
Parse through Chomicron page for comic book sales figures
<?php
system("clear");
$data = file_get_contents("http://www.comichron.com/monthlycomicssales/2014/2014-04.html");
$dom = new domDocument;
@$dom->loadHTML($data);
$dom->preserveWhiteSpace = false;
$tables = $dom->getElementsByTagName("table");
// Find the largest table to isolate the table we want to work with
@alexstone
alexstone / slack_notification.php
Created March 3, 2014 06:54
Fire a Slack Notification via CURL
<?php
// (string) $message - message to be passed to Slack
// (string) $room - room in which to write the message, too
// (string) $icon - You can set up custom emoji icons to use with each message
public static function slack($message, $room = "engineering", $icon = ":longbox:") {
$room = ($room) ? $room : "engineering";
$data = "payload=" . json_encode(array(
"channel" => "#{$room}",
"text" => $message,
@alexstone
alexstone / comixology_parse.php
Created February 27, 2014 09:51
Script to parse Comixology titles in to title, volume number, and issue number
<?php
system('clear');
// $string = "Iron Man Vol. 5 #23.NOW";
// $string = "Ms. Marvel (2014-) (Vol. 13) #2.NOW";
// $string = "Uncanny X-Men Vol. 3 #19.NOW";
$string = "Winter Soldier: The Bitter March #2 (of 5)";
echo $string . "\n";
// Parse out the ttle for the key
@alexstone
alexstone / spectre
Created January 20, 2014 16:29
"Spectre" Tumblr theme code
<!DOCTYPE html>
<html>
<head>
<title>{Title}</title>
{block:Description}
<meta name="description" content="{MetaDescription}">
{/block:Description}
</head>
<body>
<h1 class="title">{Title}</h1>
@alexstone
alexstone / Dropbox_Connect_Route.php
Created December 19, 2013 23:24
Routes I used to connect my app to Dropbox. Not shown is the Dropbox config file I made. it contains an array of the app key and app secret.
<?php
/*
|--------------------------------------------------------------------------
| Connect to Dropbox
|--------------------------------------------------------------------------
*/
Route::get('connect/dropbox', array('before' => 'auth', function() {
$app_info = Dropbox\AppInfo::loadFromJson(Config::get('dropbox.credentials'));
$webAuth = new Dropbox\WebAuthNoRedirect($app_info, "PHP-Example/1.0");