Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -euo pipefail
if [[ ${#} -lt 1 ]]; then
echo "Usage: git-reset-date-order BRANCH_UPSTREAM
Resets the author and committer dates of each commit of a branch so they are in order. The
reference date is the committer date of the HEAD commit, and the date gets decremented by 1 minute
for every parent commits.
@BenoitZugmeyer
BenoitZugmeyer / Counter.js
Last active August 28, 2019 10:34
Quick and dirty experiment to render a dynamic Web UI mostly from the server side.
// This (kind of ugly) syntax emulates a JSX output
module.exports = function Counter(state, setState) {
return [
"div",
{},
[
"button",
{
disabled: state.count > 0 ? false : "disabled",
type TypeOfSchema<T extends any> =
T extends { type: "null" } ?
null :
T extends { type: "boolean" } ?
boolean :
T extends { type: "object" } ?
{ [K in keyof T["properties"]]: TypeOfSchema<T["properties"][K]> } :
T extends { type: "array" } ?
T extends { items: infer U } ?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Improved</title>
</head>
<body>
<div id="leader" style="height: 40px; width: 40px; background: red; position: absolute; border-radius: 50%"></div>
<script type="module">
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("viewBox", `0 0 ${width} ${height}`)
.attr("style", "background-color: grey; margin: 10px")
const cellsPerDomain = 24
const assert = require('assert')
const rowCount = 7
const maxCellsCount = 40
const cellsPerDomain = 24
const domainCount = Math.floor(maxCellsCount / cellsPerDomain)
const cellsCount = domainCount * cellsPerDomain
const columnCount = Math.ceil(cellsCount / rowCount)
const cellRow = c => rowCount - 1 - c % rowCount
const cellColumn = c => columnCount - 1 - Math.floor(c / rowCount)
const domainFirstCell = d => d * cellsPerDomain
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
@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)*)
@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