Skip to content

Instantly share code, notes, and snippets.

View robertknight's full-sized avatar

Robert Knight robertknight

View GitHub Profile
@robertknight
robertknight / pipe.ts
Created November 1, 2015 12:30
Cancelable callbacks for promises
/**
* A Pipe is a proxy for a function which supports cancelation.
* When a pipe is called, it will pass its arguments to the underlying
* function, unless it is canceled in which case it will become a no-op.
*
* Pipes are useful as a way to cancel promise callbacks by wrapping
* the fulfilment or rejection handler.
*
* eg.
* aPipe = pipe(arg => doSomethingWithArg(arg));
@robertknight
robertknight / wombat_options.ts
Created November 27, 2015 13:37
Wombat options interface
/** Options to specify which DOM operations
* are intercepted and overridden in order to rewrite
* URLs when dynamic content and location changes
* are made to the page.
*/
interface WombatOptions {
embedded?: boolean;
/**
* If true, disable rewriting of elements
@robertknight
robertknight / show-merge-status.rb
Created January 2, 2013 18:43
Script to print out the merge status of local branches with respect to an 'upstream' branch (by default, 'master'). For each local branch, it prints out the number and one-line summaries of commits that have not been merged. Run with the -m argument to print out just the merge status of each branch. The script looks at the diff introduced by com…
#!/usr/bin/env ruby
require 'optparse.rb'
upstream_branch = "master"
branch_names = []
show_merge_status = false
OptionParser.new do |parser|
parser.banner = <<END
{"elements":[{"type":".Title","label":"Bigtable: A Distributed Storage System for Structured Data\\n\\n","positions":[{"type":".PdfPosition","offsets":[0,1,2,3,4,5,6,7,8,10,12,13,14,15,16,17,18,19,20,21,22,24,25,26,27,28,29,30,32,33,34,35,36,37,39,40,41,43,44,45,46,47,48,49,50,51,52,54,55,56,57],"boundingBox":{"minx":122.52,"miny":124.44,"maxx":489.19406,"maxy":667.56},"pageId":1}]},{"type":".Section","children":[{"type":".Section","children":[],"label":"4 Building Blocks\\n\\n","positions":[{"type":".PdfPosition","offsets":[10693,10695,10696,10697,10698,10699,10700,10701,10702,10704,10705,10706,10707,10708,10709],"boundingBox":{"minx":314.9994,"miny":268.80017,"maxx":413.578,"maxy":523.1998},"pageId":3}]},{"type":".Section","children":[],"label":"5 Implementation\\n\\n","positions":[{"type":".PdfPosition","offsets":[14056,14058,14059,14060,14061,14062,14063,14064,14065,14066,14067,14068,14069,14070,14071],"boundingBox":{"minx":71.99955,"miny":129.23993,"maxx":171.41548,"maxy":662.7601},"pageId":4}]},{"type":
@robertknight
robertknight / webkit-75984-workaround.html
Created April 23, 2013 16:44
Workaround for https://bugs.webkit.org/show_bug.cgi?id=75984 - adds a wrapper around QtObject.method.connect() which registers the method in an array and disconnects the method when the document is unloaded.
<html>
<body>
<script>
// wrappers around QtObject.methodName.connect()
// workaround for https://bugs.webkit.org/show_bug.cgi?id=75984
window.qtSignals = [];
// connect a Qt signal to a JS function and register it for disconnection
// when the document is unloaded
function connectQtSignal(signal, func) {
@robertknight
robertknight / gist:5508364
Created May 3, 2013 10:19
Table actions menu
diff --git a/src/webContent/notes/summary.html b/src/webContent/notes/summary.html
index 63a23cb..a519377 100644
--- a/src/webContent/notes/summary.html
+++ b/src/webContent/notes/summary.html
@@ -30,7 +30,7 @@
<div class="table-data" id="{{elementId}}-table-data">{{{table}}}</div>
<div class="table-actions">
<a class="table-copy-link" id="{{elementId}}-copy-link" href="#copy-table"
- title="Copy table data">Copy</a>
+ title="Copy table data">Options</a>
<html><head><title>Apache Tomcat/7.0.26 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error () that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>org.springframework.web.util.NestedServletException: Request processi
@robertknight
robertknight / labels.json
Created June 21, 2013 14:50
Label schema file
[
{
"label": "abstract",
"color": "#dddddd"
},
{
"label": "address-other",
"color": "#dddddd"
},
{
@robertknight
robertknight / date-formatting.js
Last active December 21, 2015 12:02
Date formatting benchmark
var Benchmark = require('benchmark');
var moment = require('moment');
var formatOpts = {
year: 'numeric',
month: 'short',
day: '2-digit',
weekday: 'long',
hour: '2-digit',
minute: '2-digit',
@robertknight
robertknight / list.cpp
Created October 13, 2013 13:56
Trivial Qt app which displays a sorted list of items
#include <QtCore/QStringListModel>
#include <QtWidgets/QApplication>
#include <QtWidgets/QListView>
#include <algorithm>
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QListView view;