Skip to content

Instantly share code, notes, and snippets.

Avatar

Steve Purcell purcell

View GitHub Profile
@purcell
purcell / auto-python-venv.md
Last active Jul 27, 2021
Sane automatic python + virtualenv
View auto-python-venv.md

Automatic python version plus venv

Goal

For easy editor integration and command-line usage, we'd like to be able to specify a Python version per project, with its own virtualenv to isolate its libraries from those of other projects.

We're willing to change $PATH globally once, but not per project. And we'd like to avoid having to run every python command invocation in a special subshell created by a shell wrapper. Instead, simply invoking "python" or "pip" etc. should do the right thing, based on the directory in which it is invoked.

It turns out this is possible!

@purcell
purcell / eglot-with-flycheck.el
Created Oct 10, 2019
Make eglot use flycheck
View eglot-with-flycheck.el
(defvar-local flycheck-eglot-current-errors nil)
(defun flycheck-eglot-report-fn (diags &rest _)
(setq flycheck-eglot-current-errors
(mapcar (lambda (diag)
(save-excursion
(goto-char (flymake--diag-beg diag))
(flycheck-error-new-at (line-number-at-pos)
(1+ (- (point) (line-beginning-position)))
(pcase (flymake--diag-type diag)
@purcell
purcell / 0001-Use-upstreamed-poetry2nix-overrides-for-hid-and-pyus.patch
Created May 11, 2021
Use upstreamed poetry2nix overrides for hid and pyusb
View 0001-Use-upstreamed-poetry2nix-overrides-for-hid-and-pyus.patch
From 96f7801fd773242cb584d68415b6c72b7db1e123 Mon Sep 17 00:00:00 2001
From: Steve Purcell <steve@sanityinc.com>
Date: Tue, 11 May 2021 15:10:45 +1200
Subject: [PATCH] Use upstreamed poetry2nix overrides for hid and pyusb
---
nix/sources.json | 12 ++++++++++++
shell.nix | 32 +++++---------------------------
2 files changed, 17 insertions(+), 27 deletions(-)
@purcell
purcell / taskqueues.sql
Last active Mar 19, 2021
Easy task queues using PostgreSQL
View taskqueues.sql
-- Let's say you have a table full of work:
CREATE TABLE tasks (
id UUID PRIMARY KEY NOT NULL DEFAULT gen_random_uuid(),
status TEXT NOT NULL DEFAULT 'pending',
payload JSON NOT NULL, -- or just have meaningful columns!
created_at TIMESTAMP NOT NULL DEFAULT NOW()
);
@purcell
purcell / code-font-user-styles.css
Last active Oct 22, 2020
User styles for coding fonts on sites with lots of code
View code-font-user-styles.css
@-moz-document domain("github.com"), domain("gist.github.com") {
tt, code, pre, .file-data pre, textarea, .blob-line-code, .blob-code, .blob-code-inner, .diff-line-code {
font-family: "Iosevka Fixed SS08", "Iosevka Fixed", "Iosevka Term", "Iosevka", "Input Mono Condensed", "PragmataPro", "Ubuntu Mono", "Menlo";
font-weight: 400;
}
}
@-moz-document domain("gitlab.com") {
tt, code, pre, textarea, .code, .file-content.code pre code {
font-family: "Iosevka Fixed SS08", "Iosevka Fixed", "Iosevka Term", "Iosevka", "Input Mono Condensed", "PragmataPro", "Ubuntu Mono", "Menlo";
@purcell
purcell / iosevka
Last active Jun 13, 2020
Mac custom-build of Iosevka with Pragmata-like features
View iosevka
#!/bin/sh -e
# https://github.com/be5invis/Iosevka#build-your-own-style
DIR=~/Projects/External/iosevka
if [ -d "$DIR" ]; then
(cd $DIR && git pull)
else
git clone --depth 1 https://github.com/be5invis/Iosevka $DIR
fi
@purcell
purcell / shell.nix
Last active May 22, 2020
shell.nix with nimlsp
View shell.nix
let
# Assumes niv sources, which should include the repos for
# nimlsp, ast-pattern-matching and jsonschema.
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {};
unpackedSource = d: d.overrideAttrs (orig: {
name = "${orig.pname}-source";
phases = ["unpackPhase" "patchPhase" "installPhase"];
installPhase = "mkdir $out; cp -aR . $out/.";
@purcell
purcell / Aggregation.purs
Last active Nov 18, 2019
Multiple aggregates in a single pass, using Purescript
View Aggregation.purs
-- This is based on ideas from the excellent article "Beautiful Aggregations
-- with Haskell" by Evan Borden: https://tech.freckle.com/2017/09/22/aggregations/
module Aggregation where
import Prelude
import Data.Foldable (foldMap)
import Data.Monoid.Additive (Additive(..))
import Data.Newtype (un)
View Req-reformatted.hs
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
View fullscreen.patch
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index 157b2dd..f3807b7 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -1263,6 +1263,11 @@ the operating system.")
(add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
+(declare-function ns-toggle-fullscreen-internal "nsfns.m" ())
+(defun ns-toggle-fullscreen ()