Skip to content

Instantly share code, notes, and snippets.

View glittershark's full-sized avatar
🏳️‍⚧️

Aspen Smith glittershark

🏳️‍⚧️
View GitHub Profile
@glittershark
glittershark / ob-babel-python-session-exceptions.el
Created February 1, 2024 16:44
Get exceptions in org-babel-python when using sessions
(defun ob-python--eval-python-session-with-exceptions
(orig session body &rest args)
(let* ((exc-file (make-temp-file "session-exception")))
(unwind-protect
(let* ((body (format "\
try:
%s
except:
import traceback
@glittershark
glittershark / main.rs
Created August 9, 2023 16:11
tokio broadcast perf
use std::thread;
use std::time::Instant;
use std::{sync::Arc, time::Duration};
use tokio::select;
use tokio::sync::broadcast;
use tokio::time::sleep;
const BUFFER_SIZE: usize = 64;
2020-07-03 16:47:38.104119755 [ThreadId 5] -
haskell-lsp:Starting up server ...
2020-07-03 16:47:38.104424879 [ThreadId 5] - ---> {"jsonrpc":"2.0","method":"initialize","params":{"processId":null,"rootPath":"/home/grfn/code/depot","clientInfo":{"name":"emacs","version":"GNU Emacs 27.0.91 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.13)"},"rootUri":"file:///home/grfn/code/depot","capabilities":{"workspace":{"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"]},"applyEdit":true,"symbol":{"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":false},"workspaceFolders":true,"configuration":true},"textDocument":{"declaration":{"linkSupport":true},"definition":{"linkSupport":true},"implementation":{"linkSupport":true},"typeDefinition":{"linkSupport":true},"synchronization":{"willSave":true,"didSave":true,"willSaveWaitUntil":true},"documentSymbol":{"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8
{ fetchFromGitHub
, buildPythonPackage
, notmuch
, pygobject2
, notify2
, gobject-introspection
, libnotify
, pyinotify
, notify
}:
@glittershark
glittershark / orjson.nix
Created March 28, 2020 18:46
Horrible, hacky packaging of orjson with Nix
{ fetchFromGitHub
, python
, maturin
, arrow
, dataclasses
, numpy
, pendulum
, psutil
, pytest
, pytz
benchmarking Binary Encoding/big data/Data.Binary
time 216.2 ms (183.5 ms .. 245.8 ms)
0.993 R² (0.978 R² .. 1.000 R²)
mean 162.9 ms (136.6 ms .. 184.9 ms)
std dev 26.37 ms (20.48 ms .. 30.39 ms)
variance introduced by outliers: 38% (moderately inflated)
benchmarking Binary Encoding/big data/Codec.Serialise
time 218.2 ms (186.3 ms .. 246.4 ms)
0.993 R² (0.979 R² .. 1.000 R²)
{-# LANGUAGE DerivingStrategies, GeneralizedNewtypeDeriving, DeriveAnyClass, FunctionalDependencies, DeriveGeneric #-}
module Lib where
import Control.Lens
import Control.Monad.Writer
import Control.Monad.Except
import Data.Monoid
import GHC.Generics
@glittershark
glittershark / aws_ssh.sh
Created June 7, 2017 22:25
SSH to an AWS server by name
function instance_by_name() {
aws ec2 describe-instances \
--filters "Name=tag:Name,Values=$1" \
| jq -r '.Reservations | map(.Instances) | flatten | map(.NetworkInterfaces) | flatten | map(.Association.PublicIp) | first'
}
SSH_KEY="/path/to/ssh/key"
alias staging='ssh -i $SSH_KEY ec2-user@$(instance_by_name staging)'
alias production='ssh -i $SSH_KEY ec2-user@$(instance_by_name production)'

This doesn't work

  module Mixin
    def def_a_method
      define_method(:foo) { puts 'mixin' }
    end
  end

  class Thing
@glittershark
glittershark / shrug.sh
Created August 27, 2015 15:52
Xdotool script to type the shrug emoji
#!/bin/bash
echo -en "¯\\_(\xe3\x83\x84)_/¯" | xsel
xdotool key Shift+Insert