Skip to content

Instantly share code, notes, and snippets.

View z5h's full-sized avatar
🕳️

Mark Bolusmjak z5h

🕳️
View GitHub Profile

Keybase proof

I hereby claim:

  • I am z5h on github.
  • I am bolusmjak (https://keybase.io/bolusmjak) on keybase.
  • I have a public key whose fingerprint is RETU RN T HIS. PGP. GET_ FING ERPR INT( ); }

To claim this, I am signing this object:

@z5h
z5h / update.js
Last active August 29, 2015 14:13
Get the result of updating a Javascript object while treating it as immutable.
/**
* Get the result of updating `obj` with `props`, while treating `obj`
* as immutable.
*/
var update = function(obj, props){
var keys = Object.keys(props),
key,
changed = false,
i;
@z5h
z5h / StickierDiv.jsx
Last active November 17, 2016 13:46
sticky header div react js
/** @jsx React.DOM */
"use strict";
var util = {
// findPos() by quirksmode.org
// Finds the absolute position of an element on a page
findPos: function (obj) {
var curleft = 0,
curtop = 0;
@z5h
z5h / join-on
Last active August 29, 2015 14:05
does a join on 2 files based on 1st capture of regex. e.g.: join-on Gemfile "gem '([^']*)'" Gemfile.lock " *([^ ]*)"
#!/usr/bin/env ruby
# example use: join-on Gemfile "gem '([^']*)'" Gemfile.lock " *([^ ]*)"
file1, cap1, file2, cap2 = *ARGV
r1 = Regexp.new(cap1)
r2 = Regexp.new(cap2)
line_match_number = []
n = 0
max_len = 0
File.open(file1).each do |line|
@z5h
z5h / ycombinator.clj
Created March 6, 2013 20:25
Applicative-Order Y Combinator (Clojure Version)
; Stumbling towards Y (Clojure Version)
;
; (this tutorial can be cut & pasted into your IDE / editor)
;
; The applicative-order Y combinator is a function that allows one to create a
; recursive function without using define.
; This may seem strange, because usually a recursive function has to call
; itself, and thus relies on itself having been defined.
;
; Regardless, here we will stumble towards the implementation of the Y combinator.
#lang scheme
(define grammar1
'((T (R))
(T ("a" T "c"))
(R ())
(R (R "b" R))))
(define grammar2
'((T (R))
; Stumbling towards Y
;
; The applicative-order Y combinator is a function that allows one
; to create a recursive function without using define.
; This may seem strange. Usually a recursive function has to call
; itself, and thus relies on itself having been defined.
;
; Regardless, here we will stumble towards the implementation of the
; Y combinator (in Scheme).