Skip to content

Instantly share code, notes, and snippets.

@mjc
mjc / jetpack-status.php
Created April 5, 2013 16:16
Super Quick PHP Script to print out status information for the Verizon MiFi JetPack 5510L
#!/usr/bin/env php
<?php
$statusurl = 'http://my.jetpack/srv/status';
/*
returned data looks like this:
array(
'notificationFlag' => 1,
'statusBarActivityVisible' => 1,
@mjc
mjc / iso8601_to_datetime.sql
Created November 28, 2012 23:17
MySQL function to convert from ISO8601 to DATETIME
delimiter $$
CREATE FUNCTION ISO8601_DATETIME(iso varchar(26))
RETURNS DATETIME
DETERMINISTIC
BEGIN
RETURN CONVERT_TZ(
STR_TO_DATE(
CONCAT(SUBSTRING(iso, 1, 10),
' ',
SUBSTRING(iso, 12, 8)),
@mjc
mjc / Makefile
Created June 27, 2012 03:56
Example Q&D makefile. untested.
CFLAGS="-g -Wall"
DEPS="foo.o bar.o baz.o"
TARGET=progname
.PHONY: clean all
$(TARGET): $(DEPS)
$(CXX) -o $(TARGET) $(CFLAGS) $(CXXFLAGS) $(DEPS)
/****************************************************
Author: Brian J Clifton
Url: http://www.advanced-web-metrics.com
This script is free to use as long as this info is left in
DESCRIPTION: Script for tracking regional and custom search engines. Requires ga.js
READ: http://www.advanced-web-metrics.com/blog/2008/09/14/customising-the-list-of-search-engines-in-google-analytics/
All scripts presented have been tested and validated by the author and are believed to be correct
as of the date of publication or posting. The Google Analytics software on which they depend is
@mjc
mjc / gist:765198
Created January 4, 2011 18:52
bug in id3v2 handling, lyrics removed from paste for brevity
id3v2 tag info for 09 Like The Weather.mp3:
UFID (Unique file identifier): http://musicbrainz.org, 36 bytes
TIT2 (Title/songname/content description): Like The Weather
TPE1 (Lead performer(s)/Soloist(s)): 10,000 Maniacs
TALB (Album/Movie/Show title): MTV Unplugged
TCON (Content type): Folk Rock (255)
TRCK (Track number/Position in set): 09/14
TYER (Year): 1993
USLT (Unsynchronized lyric/text transcription): ()[eng]:
TXXX (User defined text information): (ALBUMARTISTSORT): 10,000 Maniacsss
<?php
/*
Plugin Name: Get OSCommerce Cart Contents from session
Plugin URI: http://325i.org/osc
Description: allows you to retrieve the cart contents from your OSCommerce install. Requires that your cookie path would include both OSC and wordpress. Works with OSCommerce 2.2RC2.
Author: Michael J. Cohen <mjc@kernel.org>
Version: 1
Author URI: http://325i.org
*/
// THIS IS A HACK
$value_query = tep_db_query("select value from " . TABLE_SESSIONS . " where sesskey = '" . tep_db_input($HTTP_COOKIE_VARS['osCsid']) . "' and expiry > '" . time() . "'");
$fakecart = preg_replace("/^\w+\|(.+)$/","$1",tep_db_fetch_array($value_query));
$cart = new shoppingCart;
$cart->unserialize($fakecart);
function tep_redirect($url) {
if ( (strstr($url, "\n") != false) || (strstr($url, "\r") != false) ) {
tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false));
}
if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page
if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url
$url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL
}
}
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
localhost:~ mjc$ DYLD_PRINT_STATISTICS=YES /Applications/Firefox.app/Contents/MacOS/firefox-bin
total time: 125.81 milliseconds (100.0%)
total images loaded: 120 (106 from dyld shared cache, 0 needed no fixups)
total segments mapped: 52, into 4715 pages with 655 pages pre-fetched
total images loading time: 35.40 milliseconds (28.1%)
total dtrace DOF registration time: 0.09 milliseconds (0.0%)
total rebase fixups: 150,516
total rebase fixups time: 30.54 milliseconds (24.2%)
total binding fixups: 4,374
total binding symbol lookups: 343, average images searched per symbol: 0.5