Skip to content

Instantly share code, notes, and snippets.

@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 / bench.rb
Created November 20, 2015 22:06 — forked from jurre/bench.rb
roar vs ams
require "bundler"
require "active_model_serializers"
require "roar"
require "roar/json/json_api"
require "benchmark"
require "ffaker"
Post = Struct.new(:id, :author, :body, :draft) do
include ActiveModel::Serializers::JSON
end
@mjc
mjc / primalitytest6.rb
Last active August 29, 2015 14:27 — forked from jzakiya/primalitytest6.rb
primalitytest6.rb
#!/usr/local/bin/ruby -w
require 'rational' if RUBY_VERSION =~ /^(1.8)/ # for 'gcd' method
class Integer
def primz?
residues = [1,7,11,13,17,19,23,29,31,37,41,43,47,49,53,59,61]
res1 = [1,13,17,29,37,41,49,53]
res2 = [7,19,31,43]
@mjc
mjc / Gemfile
Last active August 29, 2015 13:57 — forked from eirc/.rvmrc
Message format benchmarks
source 'https://rubygems.org'
gem 'benchmark-ips'
gem 'json'
gem 'multi_json'
gem 'oj', platform: [:mri, :rbx]
gem 'yajl-ruby', platform: [:mri, :rbx], require: 'yajl'
gem 'jrjackson', platform: :jruby
gem 'gson', platform: :jruby
@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 / 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:

# 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