Skip to content

Instantly share code, notes, and snippets.

View ahacop's full-sized avatar

Ara Hacopian ahacop

View GitHub Profile
### Keybase proof
I hereby claim:
* I am ahacop on github.
* I am arahacopian (https://keybase.io/arahacopian) on keybase.
* I have a public key ASDLzEBNJ5jujRJ_Ei7ZsSf12Ruowgs_ScrIRr9NiQd7tgo
To claim this, I am signing this object:
@ahacop
ahacop / gem-mysql2.sh
Last active January 3, 2022 12:46 — forked from megamvb/gem-mysql2.sh
Gem MySQL2 in Mac M1
bundle config --local build.mysql2 "--with-opt-dir="$(brew --prefix openssl) "--with-ldflags=-L"$(brew --prefix zstd)"/lib"
# https://stackoverflow.com/questions/67840691/ld-library-not-found-for-lzstd-while-bundle-install-for-mysql2-gem-ruby-on-mac
@ahacop
ahacop / using-functions.js
Last active December 5, 2019 15:29
The final "slide" in the "Using Functions" talk given at CharmCityJS on 2019-12-04.
const identity = x => x
const flip = f => x => y => f(y)(x)
const prepend = x => y => x.concat(y)
const append = flip(prepend)
const exec = (x, f) => f(x)
const pipe = (...fns) => x => fns.reduce(exec, x)
const wrap = x => y => pipe(
prepend(x),
append(y)
)
@ahacop
ahacop / gist:5723112
Created June 6, 2013 17:06
Image similarity matcher using RMagick.
require "rmagick"
RSpec::Matchers.define :be_similar_image do |expected_blob, max_error = 0.001|
expected = Magick::Image.from_blob(expected_blob)[0].adaptive_resize(60, 60)
match do |actual_blob|
actual = Magick::Image.from_blob(actual_blob)[0].adaptive_resize(60, 60)
_, normalized_mean_error, _ = actual.difference(expected)
expect(normalized_mean_error).to be <= max_error
end