Skip to content

Instantly share code, notes, and snippets.

View solidsnack's full-sized avatar

Jason Dusek solidsnack

  • Dallas, TX
  • 05:40 (UTC)
View GitHub Profile
@solidsnack
solidsnack / ad-astra.rs
Last active August 28, 2016 05:17
Aster for module generation
#[allow(dead_code, non_upper_case_globals)]
pub mod code {
const x: &'static str = "X string";
const y: &'static str = "Y string";
const z: &'static str = "another string";
}
@solidsnack
solidsnack / 16.04-ami-amd64.json
Last active May 27, 2016 23:36
CFN region mapping for Ubuntu 16.04 LTS AMI
{
"AWSRegionArch2AMI": {
"ap-northeast-1": {
"amd64XhvmXebsXssd": "ami-5d38d93c",
"amd64XhvmXephemeral": "ami-0b31d06a",
"amd64XebsXssd": "ami-f537d694",
"amd64Xephemeral": "ami-0522c364"
},
"ap-southeast-1": {
"amd64XhvmXebsXssd": "ami-a35284c0",
@solidsnack
solidsnack / asl-store-all.bash
Created May 19, 2016 05:29
Enable debug and info level logs for ASL (Syslog on Mac OS X)
#!/bin/bash
set -o errexit -o nounset -o pipefail
sudo patch -p0 <<\ASLCONF
--- /etc/asl.conf 2016-05-18 22:05:48.000000000 -0700
+++ /etc/asl.conf 2016-05-18 22:06:16.000000000 -0700
@@ -20,8 +20,8 @@
# ignore "internal" facility
? [= Facility internal] ignore
SELECT *,
now() - xact_start AS duration
FROM pg_stat_activity,
LATERAL (SELECT array_agg(relation::regclass) AS locks
FROM pg_locks JOIN pg_class ON (pg_class.oid = relation)
WHERE relkind = 'r' AND pg_stat_activity.pid = pg_locks.pid)
AS _
WHERE pid != pg_backend_pid();
@solidsnack
solidsnack / data64decode.bash
Last active February 29, 2016 09:30
Decode data URIs in pure bash
#!/bin/bash
set -o errexit -o nounset -o pipefail
# This is not fast...8K/s on a 30cm MacBook
function base64decode {
local b64='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
local shifts=( 16 8 0 )
local n=0 val=0 idx=0 padding=0 suffix= code= char=
cut -d, -f2 | # Throw away data:..., if data URI
tr -c "$b64=" -d | # Throw away formatting
@solidsnack
solidsnack / fsdict.py
Created December 21, 2015 07:36
Thread safe, multiprocess python dictionary implementation backed with a directory
from collections import MutableMapping
from contextlib import contextmanager
import errno
from fcntl import flock, LOCK_EX, LOCK_NB, LOCK_SH, LOCK_UN
import itertools
import os
import signal
from threading import RLock
@solidsnack
solidsnack / gist:d902a761877b0f797835
Last active December 4, 2015 07:44
Trace of Linux Swift trying to open SwiftShims.swiftmodule
# strace -s 80 -o /tmp/swift.log -- swift <(echo '1 + 1') ; fgrep -C 40 'opening import' /tmp/swift.log
# <unknown>:0: error: opening import file for module 'SwiftShims': No such file or directory
stat("/usr/local/lib/swift/clang/include", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/usr/local/include", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
stat("/usr/local/usr/include", 0x7ffe1f9c52c0) = -1 ENOENT (No such file or directory)
stat("/usr/local/usr", 0x7ffe1f9c51d0) = -1 ENOENT (No such file or directory)
open("/usr/local/System/Library/CoreServices/SystemVersion.plist", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/tmp/org.llvm.clang.root/ModuleCache/modules.timestamp", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
brk(0x6481000) = 0x6481000
@solidsnack
solidsnack / XGH - PT-BR.txt
Last active September 25, 2015 04:44 — forked from banaslee/XGH - de-de.txt
eXtreme Go-Horse Process
Fonte: http://gohorseprocess.wordpress.com
1- Pensou, não é XGH.
XGH não pensa, faz a primeira coisa que vem à mente. Não existe
segunda opção, a única opção é a mais rápida.
2- Existem 3 formas de se resolver um problema, a correta, a errada e
a XGH, que é igual à errada, só que mais rápida.
@solidsnack
solidsnack / namedtuple.py
Last active August 29, 2015 14:28
Namedtuple annotation for Python -- derive namedtuple definition from the signature of __init__()!
"""Namedtuple annotation.
Creates a namedtuple out of a class, based on the signature of that class's
__init__ function. Defaults are respected. After namedtuple's initializer is
run, the original __init__ is run as well, allowing one to assign synthetic
parameters and internal book-keeping variables. (Note that the original
__init__ may not assign to the variables in its signature, because these
variables are made immutable by namedtuple).
The class must not have varargs or keyword args.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.gnupg.gpg-agent</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/gpg-agent</string>