Skip to content

Instantly share code, notes, and snippets.

Keith Rarick kr

Block or report user

Report or block kr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kr
kr / wait-example
Last active Oct 31, 2017
cond wait with context
View wait-example
// this is the example from https://godoc.org/sync#Cond.Wait,
// modified to use the cancelable wait described below.
c.L.Lock()
for !condition() && ctx.Err() == nil {
wait(ctx, c)
}
... make use of condition or ctx ...
c.L.Unlock()
@kr
kr / style.css
Last active Aug 29, 2015
remove syntax colors in github diffs
View style.css
@-moz-document domain("github.com") {
.pl-c1, .pl-mdh, .pl-mm, .pl-mp, .pl-mr, .pl-s1 .pl-v, .pl-s3, .pl-sc, .pl-sv, .pl-e, .pl-en, .pl-k, .pl-s, .pl-st, .pl-mo, .pl-v, .pl-pds, .pl-s1, .pl-s1 .pl-pse .pl-s2, .pl-sr, .pl-sr .pl-cce, .pl-sr .pl-sra, .pl-sr .pl-sre, .pl-src {
color: inherit ! important;
}
}
@kr
kr / Readme
Last active Jan 31, 2018
Run godoc at all times
View Readme
This launchd plist file will run godoc all the time on port 6060.
To have launchd start godoc at login, put godoc.plist in ~/Library/LaunchAgents:
curl -L https://gist.github.com/kr/3de40737f0e2c50b3b3a/raw/godoc.plist |
sed s:YOUR_GODOC_HERE:`which godoc`: |
sed s:YOUR_GOPATH_HERE:${GOPATH:-$HOME/go}: \
>~/Library/LaunchAgents/godoc.plist
Then to load godoc right away:
launchctl load ~/Library/LaunchAgents/godoc.plist
View gist:cec682c1a5f51b1f74ab
https://github.com/kr/bubble
Goals:
- use CPS as an intermediate representation
- use the callcc operator to implement a task scheduler
- use tasks in js to provide blocking I/O functions
- profit
Currently, the compiler barely exists. You can define functions
and provide arguments, and add integers and write if statements.
View gist:4d1cc7596cd305d0b91e
ume:bubble kr$ cat hello.b
func main() {
println("hello, world")
}
ume:bubble kr$ bubble -d hello.b
&ast.Program{
Files: {
&ast.File{
Funcs: {
&ast.FuncDecl{
@kr
kr / Readme.md
Created Sep 11, 2014
scripts to migrate godep-using projects automatically
View Readme.md

How it works:

Assumes you have a list of repos in a file called repos. Run ./all.sh to fork all the repos and generate patches. Probably a bunch of them will break. Take the output of that command and pull out the ones that worked (lines ending in "ok") and put those repos in another file called topr. Run ./allpr.sh and it'll send pull requests for the ones in that file. Then look at the log in do.log and try to figure out why the broken ones failed, and maybe fix it and rerun just those ones.

@kr
kr / gist:4c2ac22977b11d5aebb9
Last active Aug 29, 2015
how to get results from github search
View gist:4c2ac22977b11d5aebb9
function hasMore() {
return $('.next_page.disabled').length == 0;
}
function nextResults() {
$('.next_page').click();
}
function currentRepos() {
const q = '.code-list-item .title a:first-child';
@kr
kr / keybase.md
Created Mar 7, 2014
Keybase Identity
View keybase.md

Keybase proof

I hereby claim:

  • I am kr on github.
  • I am kr (https://keybase.io/kr) on keybase.
  • I have a public key whose fingerprint is B9C8 28EB 3CFA A3E7 426F 5E21 B2BC 2CE3 F5C3 7A58

To claim this, I am signing this object:

View main.go
package main
import (
"log"
"net/http"
"net/http/httputil"
"os"
)
func main() {
@kr
kr / jsonenv
Created Aug 6, 2013
convert a json dictionary into environment variables
View jsonenv
#!/usr/bin/env python
# jsonenv reads a json object as input and produces
# escaped shell commands for setting environment vars
import json
import pipes
import sys
for k, v in json.load(sys.stdin).items():
You can’t perform that action at this time.