Skip to content

Instantly share code, notes, and snippets.

View lsloan's full-sized avatar

Mr. Lance E Sloan «UMich» lsloan

  • Teaching and Learning (@tl-its-umich-edu) at University of Michigan: Information and Technology Services
  • Ann Arbor, Michigan, USA
  • 20:47 (UTC -04:00)
  • X @lsloan_umich
View GitHub Profile
@lsloan
lsloan / SplEnumPlus.php
Created June 12, 2015 14:26
My subclass of PHP's enum class, SplEnum, from the spl_types extension on PECL. Adds a method to indicate whether an enum has a desired key.
<?php
class SplEnumPlus extends \SplEnum {
static function hasKey($key) {
$foundKey = false;
try {
$enumClassName = get_called_class();
new $enumClassName($key);
$foundKey = true;
} finally {
@lsloan
lsloan / Basic LTI Launcher
Last active August 29, 2015 14:24
Basic LTI Launcher
See the entry point in file "blti-launch.html".
@lsloan
lsloan / api_config.ini
Created July 14, 2015 16:07
Using arrays from config files with Zend Framework
analytic_sensor_id = "05D2D6AB-B9CE-4BAC-98FB-EB96F25F0D29"
analytic_endpoint_url[localhost8000] = "http://localhost:8000/"
analytic_api_key[localhost8000] = "snafu"
analytic_endpoint_url[localhost9000] = "http://localhost:9000/"
analytic_api_key[localhost9000] = "fubar"
@lsloan
lsloan / stack_trace.php
Last active August 29, 2015 14:25
A one-line solution to send an edited stack trace to the error log.
<?php
// Print stack trace, removing repeated absolute path on each file
error_log(str_replace($_SERVER['DOCUMENT_ROOT'], '', (new Exception())->getTraceAsString()));
@lsloan
lsloan / requestbin_timestamp.js
Created July 16, 2015 18:39
Replace RequestBin's relative times with absolute ones.
$('div.span2 span').each(function() {
$span = $(this);
$span.text($span.attr('title'));
});
@lsloan
lsloan / JsonPlus.php
Last active August 29, 2015 14:26
JsonPlus is a wrapper for PHP's json_encode(), which shamefully lacks the ability to automatically remove certain values from the JSON it produces.
<?php
/**
* Class JsonPlus
*/
class JsonPlus {
/**
* A wrapper for json_encode() with the ability to run a filter on the data first.
*
* @param mixed $value
@lsloan
lsloan / QuickLook text selection.md
Created September 18, 2015 15:21
A command to enable text selection from Apple OS X Finder QuickLook windows.

Run this in your terminal to allow text selection in the QuickLook window:

defaults write com.apple.finder QLEnableTextSelection -bool true && killall Finder
@lsloan
lsloan / dart.txt
Last active September 27, 2015 13:18 — forked from paulmillr/dart.md
Leaked internal Google Dart email
---------- Forwarded message ----------
From: Mark S. Miller <erights@google.com>
Date: Tue, Nov 16, 2010 at 3:44 PM
Subject: "Future of Javascript" doc from our internal "JavaScript Summit"
last week
To: javascript-standard@google.com
On November 10th and 11th, a number of Google teams representing a variety
of viewpoints on client-side languages met to agree on a common vision for
the future of Javascript.
# Very simple class just to represent some business logic implementation
# which has nothing to do with the UI or any caller that uses this class.
class HelloWorldImpl():
def __init__(self):
pass
def sayHelloWorld(self):
print 'Hello World from Sheldon Wosnick'
def sayGoodbyeWorld(self):