Skip to content

Instantly share code, notes, and snippets.

@mjc
mjc / optimizeimages.sh
Last active Oct 21, 2019 — forked from mstroeck/optimizeimages.sh
Shell script to recursively optimize all image in the current directory. WARNING: THIS OVERWRITES YOUR ORIGINALS AND REMOVES METADATA!
View optimizeimages.sh
#!/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() {
View README.md

Setup

Add the following gems to your Gemfile:

gem 'activeresource'
gem 'newrelic_api'

Update your bundle:

@mjc
mjc / config.ru
Last active Jan 3, 2016 — 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.
View config.ru
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 / bench.rb
Created Nov 20, 2015 — forked from jurre/bench.rb
roar vs ams
View bench.rb
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
View .gitignore
# 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
@mjc
mjc / primalitytest6.rb
Last active Aug 29, 2015 — forked from jzakiya/primalitytest6.rb
primalitytest6.rb
View 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 Aug 29, 2015 — forked from eirc/.rvmrc
Message format benchmarks
View Gemfile
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