Skip to content

Instantly share code, notes, and snippets.

View jonJS.Browser.js
(function() {
var jonJS = {
version: "1.1"
};
jonJS.Browser = function() {
var ua = navigator.userAgent.toLowerCase();
// -------------------------
@jonlabelle
jonlabelle / speedtracer-chrome.sh
Created Jun 13, 2012
Launch Google Chrome w/ SpeedTracer enabled
View speedtracer-chrome.sh
#!/bin/sh
open /Applications/Google\ Chrome.app --args --enable-extension-timeline-api
@jonlabelle
jonlabelle / update-macports.sh
Created Jun 15, 2012
Update MacPorts bash script
View update-macports.sh
#!/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 Oct 12, 2015
Quick-and-dirty Sublime Text 2 console event logger.
View sublime_text_console_event_logger.py
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 Jun 10, 2022
Useful collection of JavaScript string utilities.
View string-utils.js
// 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 Dec 18, 2015
A Laravel 4 route filter that redirects an HTTP request to HTTPS.
View secureRouteFilter.php
Route::filter('scrf', function()
{
if ( !Request::secure() ) return Redirect::secure( Request::path('/toSecureURL') );
});
@jonlabelle
jonlabelle / laravel4-log-sql-queries-and-url.php
Created Jul 8, 2013
Laravel 4: Log all SQL queries and request URL. You can add it in `app/routes.php`.
View laravel4-log-sql-queries-and-url.php
Event::listen('illuminate.query', function($sql)
{
Log::info('Request URL: '.Request::url() .' Query: '.$sql);
});
@jonlabelle
jonlabelle / m3u.py
Last active Jan 6, 2020
Generate an mp3 playlist file (.m3u), sorted by album track number.
View m3u.py
#!/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 Dec 21, 2015
Sublime Text keyboard shortcuts.
View sublime-text-shortcuts.txt
-----------------------------------------------------------------------------
General
-----------------------------------------------------------------------------
Command palette:
cmd + shift + p
Go to method:
cmd + r
@jonlabelle
jonlabelle / strip_tag_attribs.md
Last active Jun 7, 2022
This Regular Expression removes all attributes and values from an HTML tag, preserving the tag itself and textual content (if found).
View strip_tag_attribs.md

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