Skip to content

Instantly share code, notes, and snippets.

// 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);
<?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
*/
@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
/****************************************************
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 / 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)
@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 / 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 / gist:6029403
Created July 18, 2013 13:43
fix for HTTParty in rbx 2.0 mode
diff --git a/lib/20/net/http.rb b/lib/20/net/http.rb
index fd8c802..2266617 100644
--- a/lib/20/net/http.rb
+++ b/lib/20/net/http.rb
@@ -321,7 +321,7 @@ module Net #:nodoc:
# HTTPResetContent:: 205
# HTTPPartialContent:: 206
# HTTPRedirection:: 3xx
- # HTTPMultipleChoice:: 300
+ # HTTPMultipleChoices:: 300
@mjc
mjc / gist:6029781
Created July 18, 2013 14:27
rbx error differences
class Moo
def self.moo
a = 50a
end
end
# require './moo.rb' in pry
# rbx:
# SyntaxError: /usr/local/rvm/rubies/rbx-head/runtime/melbourne.rbc:81: expecting keyword_end
# from /usr/local/rvm/rubies/rbx-head/runtime/melbourne.rbc:81:in `syntax_error'
@mjc
mjc / activemerchant.gemspec.diff
Created July 30, 2013 17:11
trying to add fake extension to activemerchant to allow conditionally requiring nokogiri based on ruby version at gem install time
index 652e40c..233d9df 100644
--- a/activemerchant.gemspec
+++ b/activemerchant.gemspec
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
s.homepage = 'http://activemerchant.org/'
s.rubyforge_project = 'activemerchant'
- s.files = Dir['CHANGELOG', 'README.md', 'MIT-LICENSE', 'CONTRIBUTORS', 'gem-public_cert.pem', 'lib/**/*', 'vendor/**/*']
- s.require_path = 'lib'
+ s.files = Dir['CHANGELOG', 'README.md', 'MIT-LICENSE', 'CONTRIBUTORS', 'gem-public_cert.pem', 'lib/**/*', 'vendor/**/*', 'ext/nokogiri_conf.rb']