Skip to content

Instantly share code, notes, and snippets.

View benjaminjkraft's full-sized avatar
🔓
<svg onload=alert(1)>in your computer</svg>

Ben Kraft benjaminjkraft

🔓
<svg onload=alert(1)>in your computer</svg>
View GitHub Profile
@benjaminjkraft
benjaminjkraft / keybase.md
Created September 18, 2020 04:08
keybase.md

Keybase proof

I hereby claim:

  • I am benjaminjkraft on github.
  • I am benkraft (https://keybase.io/benkraft) on keybase.
  • I have a public key ASDj9ZVsxA4_K56AzNEwtOxnbVGdIAQkaFzIabrOeUICDgo

To claim this, I am signing this object:

@benjaminjkraft
benjaminjkraft / datastore_v3.pb.go
Created May 26, 2020 17:45
first-gen compatible key encoding
// Package gaepb is copied from cloud.google.com/go/datastore/internal/gaepb,
// which copied a subset of google.golang.org/appengine/internal/datastore.
// It includes the Reference, Path, and Path_Element protos.
//
// They are copied there, and here, to provide compatibility to decode keys
// generated by the google.golang.org/appengine/datastore package. Copying the
// minimal amount of protos to support key decoding means we don't need to add
// a dependency on the appengine/datastore package.
//
// Other than the above comment, code generated by protoc-gen-go. DO NOT EDIT.

Khan Go Contest

We have a s3cr3t repository (ok, you can probably find it, but don't peek) that we will announce right before the contest start. It's some of the exercises that were literally and liberally stolen from literally and liberally stolen from the Exercism.io Go track.

Fork this repo, solve the exercises, and submit a pull request TO THIS REPO, NOT EXERCISM/GO for judging with the description containing your personal Tally. No more commits after the time limit, but you can fuss with your Pull Request more.

Please notify the judges in Slack the #go-contest channel which one, if any of your fully 100% passing solutions, should be considered for Special Awards:

  • Greased Lightning Performance Award - for exercises with benchmarks showing that you made yours go so dang fast
  • Elegant Étude Award - for exceptional cleverness, radical simplicity, and amazing aesthetics to your solutions.
@benjaminjkraft
benjaminjkraft / info locals
Last active August 6, 2019 03:44
vim crash
(gdb) info locals
hash = 7972575859106013492
hi = 0x555555ba9660
wc = <optimized out>
buf = "f̷̢̩̰̬͕͇͍́̀ō̶̯̌̋͛̕͜r̷̔̓͗̌̂͂̀͑̀c̷̓̄͒̆̃̈̒̔̾e̷̎̂͆͛̔̓̅͊͌s"
p = 0x7fffffffbf10 "f̷̢̩̰̬͕͇͍́̀ō̶̯̌̋͛̕͜r̷̔̓͗̌̂͂̀͑̀c̷̓̄͒̆̃̈̒̔̾", <incomplete sequence \314>...
@benjaminjkraft
benjaminjkraft / iterfuncs.py
Last active July 29, 2019 16:16
hot garbage with iterator-functions
def caller(cb):
while True:
try:
yield cb()
except StopIteration:
break
sentinel = object()
@benjaminjkraft
benjaminjkraft / setup_with_stdlib.go
Last active July 24, 2019 21:21
Go testing POCs
package sandbox
import (
"testing"
"github.com/stretchr/testify/assert"
)
// WithSetup would be a standard util. It accepts a setup func (which returns
// a teardown func to undo its work) and the test itself.
@benjaminjkraft
benjaminjkraft / slackimate.py
Last active February 23, 2016 23:32
slackimate.py
#!/usr/bin/env python
#
# Script to generate animated slack messages
#
# Credit for the idea goes to @mroth.
#
# Usage: ./slackimate.py '#channel-name' 'frame-1' 'frame-2' 'frame-3' ...
# (ctrl-C to end)
# If `--delete` is an argument, the message will be deleted on exit.
#
import pickle
from django.utils.functional import SimpleLazyObject
class FooBase(object):
def __reduce__(self):
self.__dict__['_version'] = 1
return super(FooBase, self).__reduce__()
```
with open('/usr/share/dict/words') as f:
words=set([x.strip() for x in f])
words = words - set('in' + x for x in words)
inwords = set(x for x in words if x.startswith('in') and not x.endswith("s") and not x.endswith("ed"))
```
in
inadvertence
inadvertent
inadvertently