Skip to content

Instantly share code, notes, and snippets.

Jesse Hallett hallettj

Block or report user

Report or block hallettj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hallettj
hallettj / HKT.js
Last active Jun 27, 2019
Concept for emulating higher-kinded types in Flow via type-level functions
View HKT.js
/*
* Concept for emulating higher-kinded types using Flow. Instead of passing
* a type that has not been applied to parameters, this pattern passes
* a type-level function that will map a parameter type to the desired
* higher-kinded type applied to the given parameter.
*
* @flow
*/
// a higher-kinded type is represented indirectly via a type-level function from
@hallettj
hallettj / userChrome.css
Created Nov 14, 2017
Customize Firefox Quantum to hide tabs, and hide navigation bar when it is not focused
View userChrome.css
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
/* hide horizontal tabs at the top of the window */
#TabsToolbar > * {
visibility: collapse;
}
/* hide navigation bar when it is not focused; use Ctrl+L to get focus */
#main-window:not([customizing]) #navigator-toolbox:not(:focus-within):not(:hover) {
margin-top: -45px;
@hallettj
hallettj / FloatFullScreenFirefox.hs
Created Oct 21, 2017
Attempt to hack full screen support for Firefox in XMonad
View FloatFullScreenFirefox.hs
{-# LANGUAGE NamedFieldPuns #-}
--------------------------------------------------------------------------------
-- |
-- Module : Custom.Hooks.FloatFullScreenFirefox
--
-- Maintainer : Jesse Hallett <jesse@sitr.us>
--
-- As of version 57 Firefox for Linux does not set full screen state in Xorg
-- when entering full screen mode. This module exports an event hook that
@hallettj
hallettj / promisify.js
Created Sep 25, 2017
Flow type for a function that modifies an input function while preserving argument arity and types
View promisify.js
function promisify<T, Args: *> (
taskFn: (...args: Args) => Task<T>
): Task<(...args: Args) => Promise<T>> {
/* ... */
}
@hallettj
hallettj / routes.elm
Last active May 30, 2017
Example of a graph in Elm
View routes.elm
import Html exposing (text)
import List exposing (concatMap, filter)
import List.Extra exposing (uniqueBy)
type alias CityId = Int
type alias City =
{ id: CityId
, name: String
}
@hallettj
hallettj / blocker.go
Last active Mar 21, 2017
Experiment to see if saturating the goroutine worker pool with long-running tasks delays goroutines that are queued later
View blocker.go
// This is a test to get a better understanding of Go's scheduling.
// The hypothesis is that if the goroutine worker pool is saturated with
// long-running tasks, then a goroutine that is queued later will not be
// scheduled until the long-running tasks complete.
//
// Tested in Go 1.7 using this command:
//
// go build -gcflags '-N -l' blocker.go && ./blocker
//
// The `gcflags` setting is my attempt to disable inlining, to give
@hallettj
hallettj / Makefile
Last active Mar 4, 2019
Makefile for transpiling with Babel & Flow in a Node app, or in a client- or server-side shared library
View Makefile
# Makefile for transpiling with Babel in a Node app, or in a client- or
# server-side shared library.
.PHONY: all clean
# Install `babel-cli` in a project to get the transpiler.
babel := node_modules/.bin/babel
# Identify modules to be transpiled by recursively searching the `src/`
# directory.
@hallettj
hallettj / adt.js
Last active Jun 5, 2019
Sealed algebraic data type (ADT) in Javascript with Flow
View adt.js
/* @flow */
// Helper function for matching against an ADT.
export function match<A,B>(matcher: A): (match: (matcher: A) => B) => B {
return match => match(matcher)
}
@hallettj
hallettj / 50-vpn-up
Created Jun 6, 2016
Place in /etc/NetworkManager/dispatcher.d/ to automatically connect to VPN on network changes
View 50-vpn-up
#!/bin/bash
WIRED_ONSITE="eth0"
WIFI_ONSITE="onsite_ssid"
VPN_ONSITE="vpn-onsite"
VPN_OFFSITE="vpn-offsite"
function online {
nmcli con show --active | grep -qs "^$1"
return $?
}
@hallettj
hallettj / adt.js
Last active Mar 21, 2019
Proposed implementation of GADTs with Javascript and Flow
View adt.js
/*
* `match` is a helper function for writing pattern matches on types that are
* implemented using Scott encoding.
*
* @flow
*/
export function match<A,B>(matcher: A): (match: (matcher: A) => B) => B {
return match => match(matcher)
}
You can’t perform that action at this time.