Skip to content

Instantly share code, notes, and snippets.

@mjc
mjc / DD32s-combine-plugin.php
Created December 5, 2008 04:38
WIP: Combine Javascript and CSS in wordpress
<?php
/*
Plugin Name: The Combiner
Plugin URI: http://dd32.id.au/wordpress-plugins/?plugin=combine-css-js
Description: Combine CSS & JS into one large monolithic file
Author: DD32
Version: 1.0
Author URI: http://dd32.id.au/
*/
@mjc
mjc / gist:37996785f47f565eb431dca19b56cf84
Created March 29, 2022 22:04
M1 macs: Preserving HDR, convert all mkv in a folder to 1080P using HandBrakeCLI. Uses VideoToolbox for hardware encoding.
#!/usr/bin/env bash
read -r -d '' profile <<'EOF'
{
"PresetList" : [
{
"AlignAVStart" : true,
"AudioCopyMask" : [
"copy:aac",
"copy:ac3",
@mjc
mjc / optimizeimages.sh
Last active October 21, 2019 22:06 — forked from mstroeck/optimizeimages.sh
Shell script to recursively optimize all image in the current directory. WARNING: THIS OVERWRITES YOUR ORIGINALS AND REMOVES METADATA!
#!/bin/sh
set -o errexit
# @TODO detect fd and fallback to find
pngs=$(fd -e png .)
jpgs=$(fd -e jpg .)
#pngs=$(find . -iname "*.png")
#jpgs=$(find . -iname "*.jpg")
optimize_a_png() {
@mjc
mjc / fizz_buzz_test.exs
Last active July 13, 2019 14:53
test for fizzbuzz
defmodule FizzBuzzTest do
use ExUnit.Case
# to run tests: mix test
# to get an irb equivalent with your code loaded in it: iex -S mix
# to get a pry in your code: `require IEx;IEx.pry()`
# Phase 1: make the test pass.
# Phase 2: implement the fizz/buzz check as a pattern match
# Phase 3: move the pattern match into multiple function clauses.
@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 / README.md
Last active February 10, 2017 17:53 — forked from erikwennerberg/README.md

Setup

Add the following gems to your Gemfile:

gem 'activeresource'
gem 'newrelic_api'

Update your bundle:

<?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 / config.ru
Last active January 3, 2016 06:09 — forked from ngs/config.ru
config.ru for running CakePHP apps under Pow. Includes an app/webroot rewrite and some other things from the rack-legacy example.
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
webroot = File.join(Dir.getwd,'app','webroot')
use Rack::Rewrite do
rewrite %r{/(.*)}, lambda { |match, rack_env|
File.exists?(File.join(webroot,match[1])) ? File.join('app','webroot',match[1]) : '/app/webroot/index.php/%s' % match[1]
}
@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']
@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'