Skip to content

Instantly share code, notes, and snippets.

Jonah jonahx

Block or report user

Report or block jonahx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View destructure_method.rb
def destructure(method_name)
# Intercept the original class
meta_klass = class << self; self end
# Save the original method as a proc
method_proc = method(method_name)
# We only want to do this for keyword argument type
# methods
unless method_proc.parameters.all? { |t, _| t == :key }
xsot /
Last active Feb 1, 2020
sed maze solver


sed -E -f solver.sed input where input is a file containing the maze.

For best results, resize your terminal to match the height of the maze. To disable animations, delete the lines containing p.

Maze format

The solver assumes the following:

  • The maze only contains the characters # \nSE
  • Every line has the same number of characters
  • There is only one start (S) and end (E)
solnic / type_safe_entity_vs_ar.rb
Last active Feb 5, 2016
Fetching type-safe entity with rom repo vs AR
View type_safe_entity_vs_ar.rb
Calculating -------------------------------------
type-safe users 273.000 i/100ms
ar user models 257.000 i/100ms
type-safe users 2.813k (± 1.7%) i/s - 14.196k
ar user models 2.574k (±10.7%) i/s - 12.850k
type-safe users: 2812.7 i/s
ar user models: 2574.2 i/s - 1.09x slower
Wunkolo / compact.cpp
Last active Jan 23, 2020
Ascii Raymarcher(old)
View compact.cpp
#include <math.h>
#include <algorithm>
#include <string>
#include <immintrin.h>
using namespace std;typedef float R;
#define _W 79
#define _H 39
#define EP 0.01f
#define OP operator
#define C const
barneycarroll / animator.js
Last active Mar 9, 2017
A factory for decorating Mithril modules / views / elements with incoming and outgoing animations.
View animator.js
var animating = false;
// Define an animator consisting of optional incoming and outgoing animations.
// alwaysAnimate is false unless specified as true: false means an incoming animation will only trigger if an outgoing animation is also in progress.
// forcing dontClone to true means the outward animation will use the original element rather than a clone. This could improve performance by recycling elements, but can lead to trouble: clones have the advantage of being stripped of all event listeners.
function animator( incoming, outgoing, alwaysAnimate, dontClone ){
// The resulting animator can be applied to any number of components
return function animate( x, y, z ){
var config;
var parent;
kachayev /
Last active Mar 29, 2020
Channels Are Not Enough or Why Pipelining Is Not That Easy
Integralist / Hash Keys to Symbols.rb
Last active Nov 7, 2019
Convert Ruby Hash keys into symbols
View Hash Keys to Symbols.rb
hash = { 'foo' => 'bar' }
# Version 1
hash = Hash[ { |k, v| [k.to_sym, v] }]
# Version 2
hash = hash.reduce({}) do |memo, (k, v)|
memo.tap { |m| m[k.to_sym] = v }
lelandbatey /
Last active Apr 8, 2020
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!


This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"


substack / dotslashtaskdotjs.markdown
Created Jan 8, 2014
introducing ./task.js, THE new javascript task runner automation framework
View dotslashtaskdotjs.markdown

why ./task.js?

One word: task automation. It's basically zero effort and you can use the ./task.js package manager to handle any repetitive tasks. You can use ./task.js to automate everything with minimum effort.

./task.js provides the structure, order, and authority that you as a developer so desperately crave. ./task.js will also take responsibility for your actions if you need it to. It's what everybody is using now. ./task.js is the new hotness. It's all about ./task.js now, just like that.

This is compared to npm run/bash scripts, which are:

lilianchisca / picturefill.html
Last active Mar 6, 2019
Lazy load reesponsive webp images with jpeg fallback using Modernizr.on // based on
View picturefill.html
<div itemprop="image" data-picture="lazy" data-alt="Don't forget to change the alt text!">
<div data-src="assets/images/example-s"></div>
<div data-src="assets/images/example-m" data-media="(min-width: 700px)"></div>
<div data-src="assets/images/example-l" data-media="(min-width: 1200px)"></div>
<img src="assets/images/example-s.jpg" alt="Don't forget to change the alt text!">
You can’t perform that action at this time.