Skip to content

Instantly share code, notes, and snippets.

View leostratus's full-sized avatar
⌨️
computering

Leo Stratus leostratus

⌨️
computering
View GitHub Profile
@dotproto
dotproto / apply.js
Last active February 14, 2024 01:55
Function application as a service
function buildApply() {
var args = Array.prototype.slice.call(arguments, 0);
var fn = args.shift();
// proxy function
return function bindProxy() {
var proxyArgs = Array.prototype.slice.call(arguments, 0);
return fn.apply(null, args.concat(proxyArgs));
}
}
@rwaldron
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
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">
<template>
<div class="comment">
<label>User: <span class="user"></span></label>
<p></p>
<br />
<span class="date"></span>
<button>Update</button>
<ul></ul>
</div>
@Protonk
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) {
// http://en.wikipedia.org/wiki/Machine_epsilon
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">
<script>
// By default, the tag name is used to generate the
// named constructor object - without rebinding 'this'
XFooElement.prototype.bar = ...
</script>
</element>
@domenic
domenic / 1-index.html
Last active October 7, 2015 05:27
Proof of concept of ES5 data binding
<!DOCTYPE html>
<html>
<head>
<title>ES5 Data Binding Proof of Concept</title>
</head>
<body>
<section>
<label>
Name:
<input data-bind="name" type="text" />
@amcgregor
amcgregor / BDHost.m
Created October 5, 2011 18:35
Useful Objective-C methods, classes, objects, and categories. Basically a snippit collection.
// From: http://www.bdunagan.com/2009/11/28/iphone-tip-no-nshost/
// 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
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, "git@github.com:user/app.git"
default_run_options[:pty] = true
set :user, "www-data"
set :domain, "foo.tld"
set :normalize_asset_timestamps, false
@seth
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