Skip to content

Instantly share code, notes, and snippets.

@BenoitZugmeyer
BenoitZugmeyer / LICENSE.txt
Created June 23, 2011 22:32 — forked from 140bytes/LICENSE.txt
Array.prototype.reduce
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Benoît Zugmeyer <alk at graou dot fr>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@BenoitZugmeyer
BenoitZugmeyer / nodelist_array.js
Created December 17, 2014 16:01
NodeList Array
Object.getOwnPropertyNames(Array.prototype).forEach(function (name) {
if (!(name in NodeList.prototype))
Object.defineProperty(NodeList.prototype, name, Object.getOwnPropertyDescriptor(Array.prototype, name));
});
/* ... */
/* Profit! */
document.querySelectorAll('div').slice(3, 10);
document.body.childNodes.reduce(function (total, el) { return total + el.offsetHeight; }, 0);
function dd(chunks) {
const variables = [].slice.call(arguments, 1);
let formated = "";
for (let i = 0; i < chunks.length; i += 1) {
formated += chunks[i]
if (i < chunks.length - 1) {
formated += variables[i];
}
#!/bin/python
import usb
import subprocess
import time
import json
# Put:
# SUBSYSTEMS=="usb", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7403", GROUP="users",
# MODE="0666"
@BenoitZugmeyer
BenoitZugmeyer / It.js
Created February 23, 2016 18:59
Iterator utils
var It = (function () {
var STOP = {};
function Iterator(next) {
this._next = next;
this._item = {};
this._index = -1;
}
Iterator.prototype = {
@BenoitZugmeyer
BenoitZugmeyer / README.md
Last active March 7, 2016 13:04
Prints the size of each modules included in a webpack bundle

Prints the size of each modules included in a webpack bundle. Add pathinfo: true, in the output property of your webpack configuration, then run node webpack-packages-size.js path_to_the_bundle.js.

@BenoitZugmeyer
BenoitZugmeyer / generate_certificates.sh
Last active March 11, 2016 14:52
Generate SSL certificates
#!/bin/bash
set -euo pipefail
if [[ $# -eq 0 ]]; then
echo "Usage: $0 mydomain.com"
exit 1
fi
name=$1
@BenoitZugmeyer
BenoitZugmeyer / hyperscript.rs
Last active May 29, 2016 21:31
hyperscript.rs
extern crate kuchiki;
#[macro_use]
extern crate string_cache;
macro_rules! h{
($name:tt) => {
h!($name { } =>)
};
($name:tt => $($other:expr)*) => {
h!($name { } => $($other)*)
const colors = ["red", "blue", "yellow", "white", "black"]
function createChart(width, height) {
const svg = d3.select("body")
.append("svg")
.attr("width", width)
.attr("height", height)
.attr("style", "background-color: grey; margin: 10px")
const minCellSize = 16
const cellSpacing = 6