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() {
@mjc
mjc / fizz_buzz_test.exs
Last active Jul 13, 2019
test for fizzbuzz
View fizz_buzz_test.exs
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.
View keybase.md

Keybase proof

I hereby claim:

  • I am mjc on github.
  • I am projct (https://keybase.io/projct) on keybase.
  • I have a public key ASD4cqm9IEAT8sbSVfLXVPJNRFi66uua7_7BHZEToAf9WAo

To claim this, I am signing this object:

@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
@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
Class vs Struct vs OpenStruct
View Gemfile
source 'https://rubygems.org'
gem 'benchmark-ips'
gem 'ruby-progressbar'
@mjc
mjc / jruby-bench.md
Last active Aug 29, 2015
JRuby benchmark
View jruby-bench.md

blank rails 4.2.1 app with blank controller in production mode with torquebox 4 alpha 1 started with rails s -e production torquebox

JRuby be07196

wrk -c 50 -d 10m -t 1 http://localhost:3000 once for warmup and second time for actual run

warmup:

@mjc
mjc / securecrt_export_sshconfig.rb
Created Mar 31, 2015
export users and hostnames to ssh_config format
View securecrt_export_sshconfig.rb
#!/usr/bin/env ruby
require 'pathname'
path = Pathname.new(ENV['HOME']).join("Library","Application Support","VanDyke","SecureCRT","Config”,”Sessions”,”**.ini")
paths = Dir.glob(path)
paths.each do |path|
lines = File.readlines(path)
hostname = nil
username = nil
lines.each do |line|
result = line.match(/S:"(.+)"=(.+)/)
@mjc
mjc / jruby-bench-results.md
Last active Aug 29, 2015
All benchmarks run on a Late 2013 15" Retina Macbook Pro (2.3GHz Core i7, 16GB, 512GB SSD)
View jruby-bench-results.md

Rails

Blank rails app with puma, serving a high_voltage static homepage (https://github.com/mjc/blankrails), warmed with 5 minutes of traffic.

MRI 2.1.2: 4 puma workers

Running 15s test @ http://localhost:3000
  1 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
View iso4217.yaml
---
AED:
code: AED
name: Dirhams
AFN:
code: AFN
name: Afghanis
symbol: ؋
unicode_hex: 1547
ALL: