Skip to content

Instantly share code, notes, and snippets.

View krisleech's full-sized avatar

Kris Leech krisleech

View GitHub Profile
@krisleech
krisleech / 00-NOTES.md
Last active April 24, 2024 19:02
Notes on Clojure ring handlers and middleware

Ring handler a function which accepts a request (map) and returns a response (map).

Ring middleware

function (handler, &args -> function(request -> response) because it is a closure handler and &args are in scope within the returned handler function.

a function which accepts a "next handler" (the next handler in the chain) + any extra arguments and returns a handler (function), which will accept a request and return a response.

@krisleech
krisleech / renew-gpgkey.md
Last active April 22, 2024 20:13
Renew Expired GPG key

Renew GPG key

Given that your key has expired.

$ gpg --list-keys
$ gpg --edit-key KEYID

Use the expire command to set a new expire date:

@krisleech
krisleech / 00-README.md
Created August 3, 2017 11:43
UptimeRobot Ansible and v2 API notes

When an interger is sent for monitor>type an internal error occurs. If a string is sent as in the main.yml example it is okay.

When an internal error occurs a 200 response not 500 is sent.

When an error occurs (e.g. monitor already exists) a 200 response is sent.

@krisleech
krisleech / steps.md
Last active December 12, 2023 23:36
Convert Postgres to MySQL

Software:

Steps

  • dump and gzip postgres (source)
pg_dump -Ox -T sessions -U mos mos_staging > ~/mos_staging.sql
@krisleech
krisleech / INFO.md
Created July 6, 2023 16:00
Re-signing an expired certificate for publishing gems
$ gem build wisper.gemspec
Enter PEM pass phrase:
INFO:  Your certificate has expired, trying to re-sign it...
ERROR:  While executing gem ... (Gem::Security::Exception)
    certificate /CN=kris.leech\/DC=gmail\/DC=com not valid after 2020-10-15 18:13:45 UTC   
$ gem cert --re-sign -C gem-public_cert.pem -K ~/.ssh/gem-private_key.pem
@krisleech
krisleech / spec.rb
Created April 24, 2023 16:10
ephemeral ActiveRecord model for specs
let(:model_class) do
Class.new(ApplicationRecord) do
self.table_name = "model_class_#{SecureRandom.uuid.delete('-')}"
def self.up
connection.execute("CREATE TABLE #{table_name}(id INTEGER PRIMARY KEY AUTOINCREMENT)")
end
def self.down
ApplicationRecord.connection.execute("DROP TABLE #{table_name}")
@krisleech
krisleech / 00-ideavimrc
Last active March 8, 2023 14:23
vimrc for IDEAvim plugin for IntelliJ IDEA IDE with Cursive plugin. #clojure #vim
set surround
set hlsearch
set scrolloff=3
set ignorecase smartcase
set showmode
set history=1000
set relativenumber
set number
@krisleech
krisleech / clipboard.md
Last active June 7, 2022 08:16
3 ways to copy to clipboard in Javascript
if(document.queryCommandSupported('copy')) {
        if(text=='') { text = ' '; } // empty inputs do not get selected

        // copy text to off-screen input
        $('#clipboard').val(text);

        // 1.) does copy empty inputs, but adds newline before content
        var range = document.createRange();
 range.selectNode(document.querySelector('#clipboard'));
@krisleech
krisleech / HOWTO_PUSH_TO_SPEAK_MUTE.md
Created January 11, 2020 15:03
Push to Speak, via command line

This works for all mics including webcam mics.

bin/mic-on

#!/usr/bin/env bash

# toggle webcam mic
amixer -c 1 sset Mic cap
# toggle default mic
@krisleech
krisleech / solution.md
Created February 20, 2017 18:54
`Cannot find Elasticsearch launch script from [elasticsearch]` Error

Error: No such file or directory - Cannot find Elasticsearch launch script from [elasticsearch] -- did you pass a correct path? When using ElasticSearch gems.

Ubuntu elasticsearch package changed, so no longer does which elasticsearch return anything, which means the gem can not find the binary.

Solution: suppy command option to ES to tell it where the binary is, either use the existing binary, mine was at /usr/shared/elasticsearch/bin/elasticsearch, or symlink the same binary to somewhere in $PATH or install a new version to $PATH.

To install a new version download and untar to somewhere in $PATH, e.g. ~/bin You can find downloads such as this one: https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.3.tar.gz