Skip to content

Instantly share code, notes, and snippets.

@paulirish
paulirish / bling.js
Last active September 13, 2025 12:13
bling dot js
/* bling.js */
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); };
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); };
@imjasonh
imjasonh / markdown.css
Last active September 3, 2025 22:12
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@havenwood
havenwood / roshambo.rb
Created February 10, 2015 18:04
Example of Comparable with Roshambo
class Roshambo
OPTIONS = [:rock, :paper, :scissors]
WINNERS = OPTIONS.rotate.zip(OPTIONS).to_h
LOSERS = WINNERS.invert
attr_reader :value
include Comparable
def initialize value = OPTIONS.sample
@havenwood
havenwood / proc_compose.rb
Last active August 29, 2015 14:14
Composing with Procs
class Proc
class << self
def compose *others
others.map(&:to_proc).inject :*
end
end
def * other
proc { |*args| other.call self.call *args }
end
@havenwood
havenwood / matrix_fib.rb
Last active October 24, 2016 23:32
nth fib with Matrix exponentiation in Ruby
require 'matrix'
def fib n
matrix = Matrix[[0, 1], [1, 1]] ** n.pred
matrix[1, 1].to_i
end
require 'minitest/autorun'
require 'minitest/pride'

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

anonymous
anonymous / idc.d.d
Created January 6, 2015 03:55
idc.d
module idc; // Internet delay chat! Yay!
import tools.fixed_socket, tools.base;
import tools.log, tools.threads, tools.threadpool;
import tools.time;
import readback;
string download(string url, bool first = false) {
if (url.find("://") == -1) url = "http://"~url;
@u8sand
u8sand / QtUiCleaner
Created December 24, 2014 00:20
Sometimes Qt Creator doesn't clean up after itself--this should take care of that.
#!/bin/python3
import sys;
from lxml import etree;
def clean(f):
print("Processing "+f+"...")
tree = etree.parse(f)
root = tree.getroot()
used_actions=[]
@whylom
whylom / README.md
Created December 4, 2014 23:43
A parser for Heroku log messages

A parser for Heroku log messages

This parser uses the Parslet to define rules for parsing a log message in the simple key=value format used by Heroku, eg:

at=error code=H12 desc="Request timeout" method=GET path="/foo" dyno=web.3 connect=1ms service=30000ms status=503 bytes=0

Given a message in the above format, the parser returns a hash of the key/value pairs:

@epitron
epitron / lugcast.js
Last active July 3, 2016 18:18
An audio player I wrote for the SteamLUG Podcast (https://steamlug.org/cast). It highlights the transcript as the audio is playing, and lets you jump around in the audio by clicking the transcript.
(function () {
"use strict";
function time_to_seconds(time) {
var s = time.attributes.datetime.value.split(":");
return parseInt(s[0] * 3600, 10) + parseInt(s[1] * 60, 10) + parseInt(s[2], 10);
}
var highlighter = {