Skip to content

Instantly share code, notes, and snippets.

View tomByrer's full-sized avatar
🎦
researching video players

Tom Byrer tomByrer

🎦
researching video players
View GitHub Profile
void function(){
var p = require('combigreater')
var liberate = require('liberate')
var call = liberate(Function.prototype.call)
var slice = liberate(Array.prototype.slice)
var R = require('rationals')
var ZERO = R(0)
var ONE = R(1)
import StringIO
import gzip
import os
import subprocess
import time
def compiler(path):
cmd = 'java -jar compiler-latest/compiler.jar -O advanced'.split()
cmd.append(path)
@emilbjorklund
emilbjorklund / breakpoints_via_css.html
Created April 24, 2012 16:03
Width detection via sneaky CSS rules
<!DOCTYPE html>
<!--[if IE 8]> <html lang="sv-SE" class="no-js ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="sv-SE" class="no-js"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<title>Breakpoint detection test</title>
<style type="text/css" media="screen">
@media screen and (min-width: 320px) {
#page:after {
content: 'smallest'; /* represent the current width-bracket */
@nepsilon
nepsilon / understanding-http-transfer-encoding-chunked.md
Last active December 2, 2016 09:25
Understanding HTTP’s Transfer-Encoding: chunked — First published in fullweb.io issue #74

Understanding HTTP’s Transfer-Encoding: chunked

Simply put, Transfer-Encoding: chunked, in a HTTP response header, tells us the body will be received in several chunks.

This is ideal in 2 scenarios:

  1. When the size of the body isn’t known in advance, like when generating output from a database.
  2. When the size of the body is too big to be fully loaded in RAM before being sent to the client.

In practice, the body has each of its chunks separated with X\r\n, where X is the size of the chunk in hexadecimal. For instance:

@nepsilon
nepsilon / 2-front-end-tips-to-keep-in-mind.md
Last active December 2, 2016 09:34
2 front-end tips to keep in mind — First published in fullweb.io issue #68

2 front-end tips to keep in mind

1. Stop using .innerHTML = ''; when removing children to a DOM element.

On modern browsers it seems to be about 400× (!!) slower than this DOM-friendly method:

while (el.firstChild)
    el.removeChild(el.firstChild);
@nepsilon
nepsilon / how-to-append-line-numbers-in-front-of-each-line-in-a-file.md
Last active February 8, 2017 09:10
How to append line numbers in front of each line in a file? — First published in fullweb.io issue #86

How to append line numbers in front of each line in a file?

Just use cat. No kidding, cat has the -n option to number the output lines, starting at 1:

cat -n file.txt

This works well both on Linux and Mac. Use the shell redirection to keep the output in a new file (don’t override the original file with the redirection though).

@nepsilon
nepsilon / comm-cli-tip.md
Last active February 19, 2017 13:31
CLI: Output the difference between 2 files — First published on fullweb.io issue #43

CLI: Output the difference between 2 files

Thinking of using diff? Try comm, its sole purpose is to compare 2 sorted files line by line.

Show lines in A.txt but NOT in B.txt:

comm -2 -3 A.txt B.txt

If the files aren’t sorted, use:

@slevithan
slevithan / es6-unicode-shims.js
Created April 3, 2012 09:14
ES6 Unicode Shims for ES3+
/*!
* ES6 Unicode Shims 0.1
* (c) 2012 Steven Levithan <http://slevithan.com/>
* MIT License
*/
/**
* Returns a string created using the specified sequence of Unicode code points. Accepts integers
* between 0 and 0x10FFFF. Code points above 0xFFFF are converted to surrogate pairs. If a provided
* integer is in the surrogate range, it produces an unpaired surrogate. Comes from accepted ES6
@efedorenko
efedorenko / gist:2028193
Created March 13, 2012 11:22
Function for alpha blending
// Turns out this function already exists in Sass: mix(fg, bg, %) (http://d.pr/mGqa)
// Alpha blending
@function blend($bg, $fg) {
$r: red($fg) * alpha($fg) + red($bg) * (1 - alpha($fg));
$g: green($fg) * alpha($fg) + green($bg) * (1 - alpha($fg));
$b: blue($fg) * alpha($fg) + blue($bg) * (1 - alpha($fg));
@psd
psd / csvg
Created June 17, 2010 19:49
csvg — create SVG from a bitmap image
#!/bin/sh
#
# convert bitmap to SVG, works well with pen and ink drawings ..
#
set -e
for file in "$@"
do
# lose suffix to grab file basename
suffix=$(echo "$file" | sed 's/.*\.//')
svg=$(basename "$file" ".$suffix").svg