Skip to content

Instantly share code, notes, and snippets.

Miles Steele mlsteele

View GitHub Profile
View ldbsizes.py
#!/usr/bin/env python
import plyvel
import sys
import collections
db = plyvel.DB(sys.argv[1])
tab = {
b"00": "DBUser",
@mlsteele
mlsteele / justmerged
Created Feb 12, 2019
You just ran `git merge origin/master`. But what happened?
View justmerged
#!/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 Nov 5, 2018
Return through esc multiple times
View multiesc.iced
{make_esc} = require "iced-error"
bounce = (f) ->
setTimeout f, 0
f = ({ok}, cb) ->
bounce ->
console.log "f #{ok}"
if ok
cb null
View a1.go
package main
import (
"fmt"
)
func f() (int, int) {
return 3, 4
}
@mlsteele
mlsteele / addrslice.go
Last active May 14, 2018
Don't take the address of an element of a slice
View addrslice.go
// https://play.golang.org/p/ZVV6drJRqva
package main
import (
"fmt"
)
type S struct {
i int64
}
@mlsteele
mlsteele / git-force-push-ask
Created Apr 27, 2018
Script to run 'git push origin currentbranch' but ask for confirmation first
View git-force-push-ask
# Add this to ~/.gitconfig
[alias]
# Force push this branch, but with a confirmation.
force = !~/bin/git-force-push-ask
@mlsteele
mlsteele / signalsnoop.go
Created Jan 29, 2018
Go intercept and print all signals
View signalsnoop.go
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 Sep 13, 2017
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/un.h
View 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 Sep 13, 2017
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/sys/un.h
View 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 Feb 11, 2017
1346 Puzzle Solution with Amb
View 1346.coffee
# 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.
You can’t perform that action at this time.