Skip to content

Instantly share code, notes, and snippets.

$ node -r time-require -r solc-0.6.8 -e ''
Start time: (2020-07-02 16:09:07 UTC) [treshold=1%]
# module time %
1 ./soljson.js (node_modules/solc-0.6.8/soljson.js) 2.2s ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 99%
2 solc-0.6.8 (node_modules/solc-0.6.8/index.js) 2.3s ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100%
Total require(): 26
Total time: 2.3s
$ node -r time-require -r solc-0.6.9 -e ''
@frangio
frangio / async-router.js
Last active April 15, 2020 03:32
A way to use async/await in Express routes
const express = require('express');
const methods = require('methods');
function AsyncRouter(options) {
const router = express.Router(options);
Object.setPrototypeOf(router, AsyncRouter.prototype);
return router;
}
Object.setPrototypeOf(AsyncRouter.prototype, express.Router);
[Unit]
Description=Lock all consoles
Documentation=man:physlock(1)
Before=sleep.target
OnFailure=hibernate.target
[Service]
Type=forking
ExecStart=physlock -d
@frangio
frangio / rs
Last active February 8, 2024 19:56
ripsed: use ripgrep as a sed replacement. requires sponge from moreutils
#!/usr/bin/env bash
set -o errexit -o pipefail
if [ "$#" -eq 0 ]
then
echo "usage: rs PATTERN REPLACEMENT [PATH...]" > /dev/stderr
exit 1
fi
pragma solidity ^0.4.21;
contract PausableHook {
modifier pausable() {
_;
}
}
contract Pausable is PausableHook {
bool private paused;
@frangio
frangio / spotify.sh
Last active December 24, 2017 01:17
Launch Spotify with automatic DPI scale
#!/usr/bin/env sh
dpi="$(xrdb -query | grep -Fm1 Xft.dpi | cut -f2)"
scale="$((dpi / 96))"
exec "$(which --skip-tilde spotify)" --force-device-scale-factor="$scale"
@frangio
frangio / miniKanren.scm
Created July 9, 2017 18:49
miniKanren implementation taken from William E. Byrd and Daniel P. Friedman, "From Variadic Functions to Variadic Relations: A miniKanren Perspective", Proceedings of the 2006 Scheme and Functional Programming Workshop, University of Chicago Technical Report TR-2006-06, 2006, pp. 105-117
; miniKanren evolved from Kanren [1]; its implementation comprises three kinds
; of operators: functions such as unify and reify, which take substitutions
; explicitly; goal constructors ==, conde, and fresh, which take substitutions
; implicitly; and the interface operator run. We represent substitutions as
; association lists associating variables with values.
; unify is based on the triangular model of substitutions (See Baader and
; Snyder [2], for example). Vectors should not occur in arguments passed to
; unify, since we represent variables as vectors.
@frangio
frangio / git-npm-clone
Last active May 26, 2017 21:06
Git subcommand to clone an npm package's repository
#!/usr/bin/env sh
# usage: git npm-clone left-pad
set -o errexit
pkg="$1"
shift

Keybase proof

I hereby claim:

  • I am frangio on github.
  • I am frangio (https://keybase.io/frangio) on keybase.
  • I have a public key ASBbMtbuaHvF_wEB2-erBEkWduHAvJ3kQzRAISn7zH5ONwo

To claim this, I am signing this object:

@frangio
frangio / parens.sed
Created June 2, 2016 03:13
Filter lines consisting of balanced parentheses
h
x
s/$/0/
x
: shift
/^(/ {
s///
x
s/$/1/
x