Skip to content

Instantly share code, notes, and snippets.

View leostratus's full-sized avatar

Leo Stratus leostratus

View GitHub Profile
dotproto / apply.js
Last active February 14, 2024 01:55
Function application as a service
function buildApply() {
var args =, 0);
var fn = args.shift();
// proxy function
return function bindProxy() {
var proxyArgs =, 0);
return fn.apply(null, args.concat(proxyArgs));
rwaldron / complete-character-set.js
Last active October 23, 2021 02:07
Character set: 0-9, A-Z, a-z for seven segment displays
"0": 0x7E,
"1": 0x30,
"2": 0x6D,
"3": 0x79,
"4": 0x33,
"5": 0x5B,
"6": 0x5F,
"7": 0x70,
"8": 0x7F,
dglazkov / gist:efd2deec54f65aa86f2e
Last active April 29, 2023 14:54
The Shadow DOM Diaries

#The Shadow DOM Diaries

Feature design is hard, and takes time. With time, it doesn't matter how public and consistent you are with communication during design process. In the end, it all will look like a jumbled mess of emails and bug comments. That seems bad. To make things less bad, I decided to start writing these little docs. Here they are. I may add more. Or not. Whatevs.

Sometimes You Need to Build a Larger Thing First looks back at the road we've traveled.

Shadow DOM Evolution outlines the path forward.

Why Do We Only Allow Children in Insertion Points provides a glimpse into the reasoning behind current insertion point design.

<x-control name="comment">
<div class="comment">
<label>User: <span class="user"></span></label>
<br />
<span class="date"></span>
Protonk / approx.js
Last active December 16, 2015 13:39
Hey guys, I totally fixed that floating point comparison problem.
var approx = function(a, b, eps) {
eps = eps || 5e-16;
return |a - b| < eps;
approx(0.1 * 0.2, 0.02) // true
/*** Option 1 - no ES6, all using defaults ***/
<element tagname="x-foo">
// By default, the tag name is used to generate the
// named constructor object - without rebinding 'this' = ...
domenic / 1-index.html
Last active October 7, 2015 05:27
Proof of concept of ES5 data binding
<!DOCTYPE html>
<title>ES5 Data Binding Proof of Concept</title>
<input data-bind="name" type="text" />
amcgregor / BDHost.m
Created October 5, 2011 18:35
Useful Objective-C methods, classes, objects, and categories. Basically a snippit collection.
// From:
// MIT license
// Remember to add CFNetwork.framework to your project using Add=>Existing Frameworks.
#import "BDHost.h"
#import <CFNetwork/CFNetwork.h>
#import <netinet/in.h>
#import <netdb.h>
#import <ifaddrs.h>
alkema / deploy.rb
Created July 9, 2011 20:01
Capistrano task for a Node.js app with github Forever and NPM.
set :application, "appname"
set :deploy_to, "/var/www"
set :scm, :git
set :repository, ""
default_run_options[:pty] = true
set :user, "www-data"
set :domain, "foo.tld"
set :normalize_asset_timestamps, false
seth / yui_compressor.rb
Created January 11, 2011 04:23
A Nanoc filter for minifying CSS and Javascript using the YUI Compressor
YUI_JAR = File.dirname(__FILE__) + "/../tools/yuicompressor-2.4.2.jar"
class YuiCompressor < Nanoc3::Filter
identifier :yui_compress
type :text => :binary
def run(content, params={})
type = type_from_extension
cmd = "java -jar #{YUI_JAR} --type #{type} -o #{output_filename}"
IO.popen(cmd, 'w') { |f| f.write(content) }
raise "yuicompressor exited with #{$?} for '#{cmd}'" unless $? == 0