Skip to content

Instantly share code, notes, and snippets.

View mlsteele's full-sized avatar

Miles Steele mlsteele

View GitHub Profile
#!/usr/bin/env python
import plyvel
import sys
import collections
db = plyvel.DB(sys.argv[1])
tab = {
b"00": "DBUser",
@mlsteele
mlsteele / justmerged
Created February 12, 2019 20:49
You just ran `git merge origin/master`. But what happened?
#!/usr/bin/env bash
# You just ran `git merge origin/master`. But what happened?
# Shows the diff between
# - your changes from old master before merging
# - your changes from NEW master AFTER merging
COMMON_ANCESTOR=$(git merge-base $(git show -s --pretty=%P HEAD))
git d $COMMON_ANCESTOR..HEAD^1 > /tmp/diff1.txt
git d HEAD^2..HEAD > /tmp/diff2.txt
kdiff3 /tmp/diff{1,2}.txt
@mlsteele
mlsteele / multiesc.iced
Created November 5, 2018 16:14
Return through esc multiple times
{make_esc} = require "iced-error"
bounce = (f) ->
setTimeout f, 0
f = ({ok}, cb) ->
bounce ->
console.log "f #{ok}"
if ok
cb null
package main
import (
"fmt"
)
func f() (int, int) {
return 3, 4
}
@mlsteele
mlsteele / addrslice.go
Last active May 14, 2018 21:42
Don't take the address of an element of a slice
// https://play.golang.org/p/ZVV6drJRqva
package main
import (
"fmt"
)
type S struct {
i int64
}
@mlsteele
mlsteele / git-force-push-ask
Created April 27, 2018 15:07
Script to run 'git push origin currentbranch' but ask for confirmation first
# Add this to ~/.gitconfig
[alias]
# Force push this branch, but with a confirmation.
force = !~/bin/git-force-push-ask
@mlsteele
mlsteele / signalsnoop.go
Created January 29, 2018 19:52
Go intercept and print all signals
func Signalsnoop() {
ch := make(chan os.Signal, 500)
go func() {
for {
s := <-ch
fmt.Printf("SIGNAL: %+v\n", s)
}
}()
signal.Notify(ch)
}
@mlsteele
mlsteele / un.h
Created September 13, 2017 21:34
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/un.h
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
@mlsteele
mlsteele / un.h
Created September 13, 2017 21:34
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/un.h
/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
@mlsteele
mlsteele / 1346.coffee
Last active February 11, 2017 20:59
1346 Puzzle Solution with Amb
# Puzzle solution
# Using the numbers [1, 3, 4, 6] and operations [+, -, *, /],
# find an expression that equals 24.
# Use each number exactly once.
# The puzzle is fun! Don't read this until you've solved it.
# Uses amb, the (super cool) ambiguity operator. (Explained below)
# Print in continuation passing style.
# A continuation (k) is basically a word a callback.
# It's the function that represents what to do next.