Skip to content

Instantly share code, notes, and snippets.

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
@frangio
frangio / ltn12-posix.lua
Last active October 8, 2015 20:53
LTN12 wrappers for POSIX read and write.
local unistd = require('posix.unistd')
local ltn12 = require('ltn12')
local _M = {}
-- creates a source from a file descriptor
function _M.source(fd, err)
if fd then
return function ()
local chunk = unistd.read(fd, ltn12.BLOCKSIZE) -- [TODO] stat(fd).st_blksize?
@frangio
frangio / dmenu_run
Last active March 24, 2016 23:43
Enhanced `dmenu_run`.
#!/bin/sh
set -o errexit
is_graphical() {
desktop=/usr/share/applications/"$1".desktop
[ -f "$desktop" ] && ! grep -Fq Terminal=true "$desktop" \
|| ldd "$(which "$1")" | grep -Fq libX11
}
var TelegramBot = require('node-telegram-bot-api');
var token = 'TOKEN';
var bot = new TelegramBot(token, {polling: true});
bot.getMe().then(function (me) {
console.log('%s on', me.username);
});
bot.on('text', function (msg) {
@frangio
frangio / i3-empty-ws
Created August 14, 2015 06:13
Lua script to switch to next empty workspace in i3wm. Depends on i3ipc-lua.
#!/usr/bin/env lua
i3ipc = require 'i3ipc'
conn = i3ipc.Connection()
tree = conn:get_tree()
ws = {}
for _, w in pairs(tree:workspaces()) do
if w.focused then