Skip to content

Instantly share code, notes, and snippets.

View jonlabelle's full-sized avatar

Jon LaBelle jonlabelle

View GitHub Profile
(function() {
var jonJS = {
version: "1.1"
};
jonJS.Browser = function() {
var ua = navigator.userAgent.toLowerCase();
// -------------------------
@jonlabelle
jonlabelle / speedtracer-chrome.sh
Created June 13, 2012 18:30
Launch Google Chrome w/ SpeedTracer enabled
#!/bin/sh
open /Applications/Google\ Chrome.app --args --enable-extension-timeline-api
@jonlabelle
jonlabelle / update-macports.sh
Created June 15, 2012 22:10
Update MacPorts bash script
#!/bin/bash
# script for daily maintenance of mac ports
# upgrades to packages
# discards orphaned packages, etc.
# check for user id (must be run as root)
if [ ${EUID} != 0 ]; then
echo "script must be run as root! Recalling with sudo"
sudo $0
@jonlabelle
jonlabelle / sublime_text_console_event_logger.py
Last active October 12, 2015 07:18
Quick-and-dirty Sublime Text 2 console event logger.
import sublime
import sublime_plugin
import time
class EventLog(sublime_plugin.EventListener):
def __init__(self):
print "--- Event Log Initialized ---"
sublime.status_message('--- Event Log Initialized ---')
@jonlabelle
jonlabelle / string-utils.js
Last active December 15, 2024 21:36
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str) {
return str.toLowerCase();
@jonlabelle
jonlabelle / secureRouteFilter.php
Last active December 18, 2015 20:49
A Laravel 4 route filter that redirects an HTTP request to HTTPS.
Route::filter('scrf', function()
{
if ( !Request::secure() ) return Redirect::secure( Request::path('/toSecureURL') );
});
@jonlabelle
jonlabelle / laravel4-log-sql-queries-and-url.php
Created July 8, 2013 18:06
Laravel 4: Log all SQL queries and request URL. You can add it in `app/routes.php`.
Event::listen('illuminate.query', function($sql)
{
Log::info('Request URL: '.Request::url() .' Query: '.$sql);
});
@jonlabelle
jonlabelle / m3u.py
Last active December 17, 2022 17:34
Generate an mp3 playlist file (.m3u), sorted by album track number.
#!/usr/bin/env python
import os
import sys
import glob
from mutagen.mp3 import MP3
from mutagen.easyid3 import EasyID3
#
# MP3 playlist generator
@jonlabelle
jonlabelle / sublime-text-shortcuts.txt
Last active December 21, 2015 12:19
Sublime Text keyboard shortcuts.
-----------------------------------------------------------------------------
General
-----------------------------------------------------------------------------
Command palette:
cmd + shift + p
Go to method:
cmd + r
@jonlabelle
jonlabelle / strip_tag_attribs.md
Last active September 7, 2024 05:03
This Regular Expression removes all attributes and values from an HTML tag, preserving the tag itself and textual content (if found).

Strip HTML Attributes

<([a-z][a-z0-9]*)[^>]*?(/?)>
token explanation
< match < at beginning of tags
( start capture group $1 - tag name
[a-z] match a through z