Skip to content

Instantly share code, notes, and snippets.

View hallettj's full-sized avatar

Jesse Hallett hallettj

View GitHub Profile
@hallettj
hallettj / rust-on-nix.md
Created March 8, 2024 15:22
Building Rust binaries with Nix draft

#nix #rust

Packaging Rust Binaries

Requires flakes to be enabled. {.is-warning}

There are a few pieces that make up a complete Nix workflow for building Rust crates:

@hallettj
hallettj / _redirects
Created November 20, 2022 23:24
Netlify configuration to redirect a Mastodon handle
# Netlify configuration to set up a Mastodon handle for your own domain that
# forwards to your real account. This configuration allows people to search for
# me with @[email protected], and to find me @[email protected].
#
# Put a configuration like this in a file called _redirects in the *publish
# directory* of your Netlify project. For my Gatsby site I put the file in
# static/_redirects, and at build time it gets copied to public/_redirects.
#
# Redirect documentation for Netlify is at https://docs.netlify.com/routing/redirects/redirect-options/
# Test redirect rules in the playground, https://play.netlify.com/redirects
@hallettj
hallettj / fractional-scaling-mutter.md
Last active September 16, 2024 01:16
How I set up fractional scaling in Gnome

Fractional Scaling

With a bigger display 2x scaling might be too big. I'm trying out experimental support for fractional scaling in Gnome. To opt out again it is necessary to undo this experimental features setting:

$ gsettings set org.gnome.mutter experimental-features "['scale-monitor-framebuffer']"

In addition to fractional scaling that setting allows different scaling factors per monitor!

The only issue I'm seeing so far is that apps running with XWayland look fuzzy. That includes web browsers. But! Firefox and Chrome both have opt-in support for Wayland which fixes the problem.

@hallettj
hallettj / lazy-promise.js
Last active January 23, 2022 21:27
Lazily-evaluated promise example
// Run with: deno run lazy-promise.js
// See https://github.com/sindresorhus/p-lazy
import PLazy from "https://cdn.skypack.dev/p-lazy"
const a = new PLazy(resolve => {
console.log("this code does not execute")
resolve()
})
@hallettj
hallettj / datetime.tsx
Last active April 27, 2020 06:49
Custom timezone-aware datetime input component for Sanity CMS
import styles from "part:@sanity/base/theme/forms/text-input-style"
import FormField from "part:@sanity/components/formfields/default"
import { withDocument } from "part:@sanity/form-builder"
import PatchEvent, { set, unset } from "part:@sanity/form-builder/patch-event"
import * as React from "react"
import Datetime from "react-datetime"
class DatetimeInputRaw extends React.Component {
render() {
@hallettj
hallettj / HKT.js
Last active June 27, 2019 15:19
Concept for emulating higher-kinded types in Flow via type-level functions
/*
* 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
Last active November 5, 2024 01:08
Customize Firefox Quantum to hide tab bar, and to hide navigation bar when it is not focused. Press Ctrl+L to reveal navigation bar. To make this work open about:config and set toolkit.legacyUserProfileCustomizations.stylesheets to true. Put this file in ~/.mozilla/firefox/<profile-name>/chrome/
@-moz-document url(chrome://browser/content/browser.xul),
url(chrome://browser/content/browser.xhtml) {
/* 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) {
@hallettj
hallettj / FloatFullScreenFirefox.hs
Created October 21, 2017 18:19
Attempt to hack full screen support for Firefox in XMonad
{-# LANGUAGE NamedFieldPuns #-}
--------------------------------------------------------------------------------
-- |
-- Module : Custom.Hooks.FloatFullScreenFirefox
--
-- Maintainer : Jesse Hallett <[email protected]>
--
-- 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 September 25, 2017 18:32
Flow type for a function that modifies an input function while preserving argument arity and types
function promisify<T, Args: *> (
taskFn: (...args: Args) => Task<T>
): Task<(...args: Args) => Promise<T>> {
/* ... */
}
@hallettj
hallettj / routes.elm
Last active May 30, 2017 19:52
Example of a graph in 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
}