Skip to content

Instantly share code, notes, and snippets.

@agam
agam / replace_rest_extension.sh
Last active February 4, 2020 05:40
Shell script with separate function to read and write out while appending to given multi-line section
#INPUT_FILE=/Users/abrahma/tmp/missing.properties
#OUTPUT_FILE=/Users/abrahma/tmp/output1.properties
#EXISTING_FILE=/Users/abrahma/tmp/existing.properties
EXISTING_FILE=/Users/abrahma/tmp/spaces.properties
OUTPUT_FILE=/Users/abrahma/tmp/output.properties
KEY="^\s*rest.extension.classes"
NEWVAL="io.confluent.connect.replicator.monitoring.ReplicatorMonitoringExtension"
@agam
agam / emacsclient.zsh
Last active October 4, 2019 23:34
Convient file-based access to running GUI Emacs (Spacemacs!)
alias e="emacsclient --no-wait --socket-name=/Users/abrahma/.emacs.d/server/server"
# Previous errors about `-error Unknown&_command:` were fixed after upgrading emacsclient to match the Emacs version
# `brew cask install emacsclient` and `brew cask install emacs' worked for me.
@agam
agam / emacs.sh
Created August 22, 2019 22:56
Quickstart Emacs for Remote editing
# Note: this was on Ubuntu 18.04
## We don't need no gui on the terminal
$ sudo apt-get install emacs25-nox
## All spacemacs requires is your `.emacs` preferences ...
$ git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
## Run emacs, select the defaults, you're good to go!
@agam
agam / mosh-enable.sh
Created May 24, 2019 23:31
Get mosh working again
$ sudo iptables -I INPUT 1 -p udp --dport 60000:61000 -j ACCEPT
@agam
agam / fzf-nix.zsh
Last active May 22, 2019 05:46
Getting the path to fzf keybindings within zsh when installed by Nix
# Add this to the end of ~/.zshrc:
source $(nix-env --query fzf --out-path | sed 's/.*bin=\(.*\);.*/\1/g' | awk '{print $1"/share/fzf/key-bindings.zsh"}')
@agam
agam / nix-haskell.sh
Created April 3, 2019 19:21
Quick 'n' dirty GHC shell with given packages
function nix-haskell() {
pkgs=$@
echo "Starting haskell shell, pkgs = $pkgs"
nix-shell -p "haskellPackages.ghcWithPackages (pkgs: with pkgs; [$pkgs])"
}
@agam
agam / show-doc.clj
Created January 14, 2019 19:20
Show documentation for vars in a namespace
(defn get-vars
[n]
(map #(ns-resolve n %1) (clojure.repl/dir-fn n)))
(defn show-doc
[v]
(vector (:name (meta v))
(:doc (meta v))))
(defn get-docs
@agam
agam / info.clj
Created January 9, 2019 00:15
A helpful clojure mini-tool
(defn info
"Show `type` and `class` of an object"
[x]
(println x ": type(" (type x) "), class(" (class x) ")"))
@agam
agam / dummy.agda
Created December 4, 2018 20:42
First steps with Agda
module Dummy where
-- Initial definition
data N : Set where
zero : N
suc : N -> N
-- Allow us to use shorthand
@agam
agam / dummy.agda
Created December 4, 2018 20:42
First steps with Agda
module Dummy where
-- Initial definition
data N : Set where
zero : N
suc : N -> N
-- Allow us to use shorthand