Skip to content

Instantly share code, notes, and snippets.

@shanna
shanna / App.svelte
Last active April 19, 2022 18:14
Wails OIDC OAuth2 minimal inline hack.
<script>
const login = async () => {
window.location.href = await window.go.main.App.AuthURL();
};
let email;
window.go.main.App.AuthEmail()
.then(e => {
if (!e) login();
email = e;
@shanna
shanna / keybase.md
Created October 5, 2017 23:00
keybase.md

Keybase proof

I hereby claim:

  • I am shanna on github.
  • I am shanna (https://keybase.io/shanna) on keybase.
  • I have a public key ASB7WctqxheSQaiFSOvDLCvRe47lFZMirPn1NQiv4ePUcQo

To claim this, I am signing this object:

@shanna
shanna / main.c
Created March 6, 2017 23:31
Minimal webkit2gtk segfault on macOS runs on Linux.
#include <webkit2/webkit2.h>
#include <JavaScriptCore/JavaScript.h>
int main(int argc, char **argv) {
gtk_init(&argc, &argv);
GtkWidget *main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
GtkWidget *webkit_view = webkit_web_view_new();
gtk_container_add(GTK_CONTAINER(main_window), webkit_view);
@shanna
shanna / example.rb
Last active February 8, 2017 14:33
Jaccard coeff against shingles.
require 'shingles'
compare = %w{
foo foo
foo bar
baz boz
foofoo foobar
}.each_slice(2)
compare.each do |a, b|
@shanna
shanna / brokenimage.js
Created October 19, 2016 10:11
Broken image JS.
// MIT https://github.com/alexrabarts/jquery-brokenimage minus the jquery.
function BrokenImage(selector, options) {
'use strict';
options = options || {};
var defaults = {
timeout: 2500
};
for (var key in defaults) {
@shanna
shanna / pg-install
Created September 6, 2016 14:14
Postgres install from source on OSX when homebrew won't give you a specific version.
#!/usr/bin/env bash
set -e
# Homebrew homebrew/versions was broken when I went to install postgres.
# This shell script just documents my install from source.
release=9.4.6
prefix=$HOME/local
mkdir -p $prefix
@shanna
shanna / psql-migrate
Last active May 23, 2016 06:07
Postgres migration script.
#!/usr/bin/env sh
set -eu
if [ $# -ne 0 ]; then
cat <<-USAGE
psql-migrate
Takes a sorted list of filenames from stdin and writes psql migrations sql
to stdout.
@shanna
shanna / short-prompt.sh
Last active May 4, 2016 07:25
A short, smart, prompt.
# [ -e ~/.config/short-prompt.sh ] && source ~/.config/short-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=true
__git_ps1() { PS1="$1$2"; }
[ -e ~/.config/git-prompt.sh ] && source ~/.config/git-prompt.sh
__short_ps1() {
local exit=$?
local __short_ps1_host=""
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
@shanna
shanna / go-env
Last active May 3, 2016 15:11
Symlink Go packages into local project directory.
#!/usr/bin/env sh
# Setup Go environment.
#
# source ~/local/bin/go-env
# http://superuser.com/questions/39751/add-directory-to-path-if-its-not-already-there
__util_env_path_prepend() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="$1:$PATH"
@shanna
shanna / jlink
Created October 25, 2015 10:58
jlink wrapper script for debugging and flashing.