Skip to content

Instantly share code, notes, and snippets.

@sqs
sqs / gist:4151179
Created November 26, 2012 22:47
Sample Avro JS codegen'd file
if (typeof require !== "undefined" && typeof Avro === "undefined") {
var Avro = require("../lib/validator.js").Avro;
}
/**
* autograph.model.gen.PersonId (AUTOGENERATED)
*/
if (typeof autograph === "undefined") {
var autograph = {};
}
import collection.JavaConversions._
import java.net.URI
import java.net.ConnectException
import java.util.concurrent.TimeUnit
import com.couchbase.client.protocol.views.ViewRow
import com.couchbase.client.CouchbaseClient
import com.couchbase.client.protocol.views.Query
import java.util.concurrent.TimeUnit
import com.couchbase.client.protocol.views.ComplexKey
import com.couchbase.client.protocol.views.Stale
@sqs
sqs / repro.sh
Last active August 29, 2015 14:01
Docker btrfs "no space left on device" when "processing triggers for libc-bin" in Ubuntu 14.04 host & container
# When running Docker (0.8-0.11.1) on an Ubuntu 14.04 or Amazon Linux host,
# using btrfs, the btrfs partition fills up when building a container with
# docker-in-docker.
#
# STEPS TO REPRODUCE:
# 1. Launch a new EC2 instance with Ubuntu 14.04, 64-bit, m3.large.
# 2. Log in with `ssh -i /path/to/key.pem ubuntu@ec2-hostname`.
# 3. Copy this script to the EC2 instance and run it.
# 4. Wait ~3 minutes, and you'll see the error at the bottom.
#
@sqs
sqs / golang-present-speaker-notes.diff
Created June 13, 2014 13:10
Patch to add speaker notes to the Go present tool (lines beginning with ">"; in the web UI, toggle display with 'n'). Works on all slides but the title slide. Breaks if you have more than one contiguous run of lines starting with "> " in a single slide (due to CSS). I'll submit a real patch upstream soon (unless someone else volunteers).
diff -r 5b025577f8ab cmd/present/static/slides.js
--- a/cmd/present/static/slides.js Fri Jun 13 12:42:11 2014 +1000
+++ b/cmd/present/static/slides.js Fri Jun 13 06:09:06 2014 -0700
@@ -10,6 +10,8 @@
var curSlide;
+var showNotes;
+
/* ---------------------------------------------------------------------- */
@sqs
sqs / gist:ce913ce35599d3377c11
Created June 24, 2014 16:07
sourcegraph/go-vcs libgit2 cgo crash - in cgo-crash branch
$ go test -test.run=Concurrency
*** Error in `/tmp/go-build871593397/github.com/sourcegraph/go-vcs/vcs/_test/vcs.test': double free or corruption (top): 0x0000000001549d60 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x80996)[0x7faa96ef7996]
/usr/local/lib/libgit2.so.0(+0x77acc)[0x7faa974d3acc]
/usr/local/lib/libgit2.so.0(+0x77b24)[0x7faa974d3b24]
/usr/local/lib/libgit2.so.0(+0x77cdd)[0x7faa974d3cdd]
/usr/local/lib/libgit2.so.0(+0x9bea5)[0x7faa974f7ea5]
/usr/local/lib/libgit2.so.0(+0x6c1aa)[0x7faa974c81aa]
/usr/local/lib/libgit2.so.0(+0x6c381)[0x7faa974c8381]
@sqs
sqs / queue.go
Created August 11, 2014 22:15
simple postgresql queue in go
package db
import (
"strings"
"time"
"github.com/sqs/modl"
)
// SimpleQueue is a PostgreSQL-backed queue with atomic enqueue and dequeue, no
[
{
“Name”: “twitter-text-dart”,
“Type”: “DartPackage”, // same as defined in the Srclibtoolchain
“Files”: [
“lib/foo.dart”, “lib/bar.dart” // all files related to the Dart package (used as make prereqs in Makefile generated by srclib underlying backend)
],
“Ops”: { // just use this - null means use the registered toolchain for graphing/depresolving DartPackage source units
“graph”: null,
“depresolve: null
@sqs
sqs / sourcegraph_pullrequest_authors_url.js
Created December 9, 2014 12:36
sourcegraph_pullrequest_authors_url.js
// requires the 'btoa' function, which browsers provide. just run this
// in your browser's JS console to try it out. if using node.js, use
// https://github.com/node-browser-compat/btoa/blob/master/index.js.
var tmpl = "https://sourcegraph.com/api/repos/{BASE_REPO}/.deltas/{BASE_BRANCH}==={BASE_RESOLVED_COMMIT_ID}..{BASE64_URL_ENCODED_HEAD_REPO}:{HEAD_BRANCH}==={HEAD_RESOLVED_COMMIT_ID}/.affected-authors";
var vars = {
BASE_REPO: "github.com/JodaOrg/joda-money",
BASE_BRANCH: "master",
BASE_RESOLVED_COMMIT_ID: "1c7920a861a5c55c2fa9bc892b24f4873b593746",
HEAD_REPO: "github.com/ffbit/joda-money",
@sqs
sqs / ToSourcegraph.js
Created May 4, 2017 20:43
Jump to Sourcegraph bookmarklet
javascript:(function(){ if (window.location.hostname !== "github.com" && window.location.hostname !== "sourcegraph.com") { alert("This bookmarklet may only be used on GitHub.com or Sourcegraph.com, not " + window.location.hostname + "."); return; } var pats = [ ["^/([^/]+)/([^/]+)/tree/([^/]+)$", "/github.com/$1/$2@$3", "^/github\.com/([^/]+)/([^/@]+)@([^/]+)$", "/$1/$2/tree/$3"], ["^/([^/]+)/([^/]+)/tree/([^/]+)/(.+)$", "/github.com/$1/$2@$3/-/tree/$4", "^/github\.com/([^/]+)/([^/@]+)@([^/]+)/-/tree/(.+)$", "/$1/$2/tree/$3/$4"], ["^/([^/]+)/([^/]+)/blob/([^/]+)/(.+)$", "/github.com/$1/$2@$3/-/blob/$4", "", ""], ["^/([^/]+)/([^/]+)$", "/github.com/$1/$2", "^/github\.com/([^/]+)/([^/]+)$", "/$1/$2"], ["^/([^/]+)$", "/$1", "^/([^/]+)$", "/$1"], ]; var pathname = window.location.pathname; if (window.location.hostname === 'sourcegraph.com') { if (pathname.indexOf('/sourcegraph.com/') === 0) { pathname = pathname.replace('/sourcegraph.com/', '/github.com/'); } else if (pathname.indexOf('/sourcegraph/') === 0) { pa
@sqs
sqs / file.ts
Created May 24, 2017 11:32
resolves to equal uri typescript vscode.ts
/**
* Returns true iff url == uri-resolve(url, candidate) per
* https://tools.ietf.org/html/rfc3986#section-5.2.2. For example, if currentURL is
* http://example.com/foo and newURL is /foo, then it returns true.
*/
export function resolvesToEqual(url: URI | string, candidate: URI | string): boolean {
if (typeof url === 'string') { url = URI.parse(url); }
if (typeof candidate === 'string') { candidate = URI.parse(candidate); }
const change: {