Skip to content

Instantly share code, notes, and snippets.


Max Lielje mxlje

View GitHub Profile
mxlje /
Last active July 4, 2017 14:31
dgraph broken recursive sorting example/bug

dgraph recursive sorting bug

This gist is an extracted test case to show how sorting by timestamps in a recursive query in dgraph does not return the expected results.

dgraph version

Dgraph version   : v0.7.7
Commit SHA-1     : e065d29
mxlje / recursive.go
Created June 29, 2017 14:13
Golang html/template recursive rendering partial
View recursive.go
type Thing struct {
Text string
Things []Thing
func RootHandler(rw http.ResponseWriter, req *http.Request) {
tmpl, err := template.New("root").Parse(`
{{ define "message" }}
<li>{{ .Text }}
View promocodes.rb
([*('A'..'Z'),*('0'..'9')]-%w(0 1 I O)).sample(9).each_slice(3).map(&:join).join('-')
mxlje / heredoc.rb
Last active August 10, 2018 17:19
Ruby 2.3.0 heredocs with tilde (~)
View heredoc.rb
# When using heredocs in Ruby 2.3.0, use a tilde (~) instead of a minus (-)
# to remove leading whitespace while keeping indentation in the doc itself.
module I
module AM
OLD = <<-END
<title>Hello World</title>
mxlje /
Last active March 23, 2018 13:31
download dropbox images from Camera Uploads folder

Dropbox Camera Upload image downloader

Disclaimer: This script is very hacky and could be optimized in almost every regard. It got the job done for me a little while ago (I was very angry at Dropbox when I wrote it), and I thought I’d share it.

You have been warned.


Dropbox Keys

View colors.rb
class C
class << self
def green(s)
def orange(s)
mxlje / ping
Created November 5, 2015 09:26
View ping
Request timeout for icmp_seq 176
Request timeout for icmp_seq 177
Request timeout for icmp_seq 178
Request timeout for icmp_seq 179
Request timeout for icmp_seq 180
Request timeout for icmp_seq 181
Request timeout for icmp_seq 182
Request timeout for icmp_seq 183
Request timeout for icmp_seq 184
Request timeout for icmp_seq 185
mxlje / underscore.move.js
Last active August 26, 2015 17:53 — forked from kjantzer/underscore.move.js
Underscore.js Mixin: Move - takes array and moves item at index and moves to another index; great for use with jQuery.sortable()
View underscore.move.js
_.move - takes array and moves item at index and moves to another index; great for use with jQuery.sortable()
move: function (array, fromIndex, toIndex) {
array.splice(toIndex, 0, array.splice(fromIndex, 1)[0] );
return array;
View slugs.rb
slug = text.downcase.gsub(/(ä|Ä|ö|Ö|ü|Ü|ß| |\?|\!)/, {
'ä' => 'ae',
'Ä' => 'ae',
'ö' => 'oe',
'Ö' => 'oe',
'ü' => 'ue',
'Ü' => 'ue',
'ß' => 'ss',
' ' => '-',
'?' => '',
mxlje / arguments.js
Last active October 15, 2015 19:22
Code samples for “Understanding GraphQL Server”
View arguments.js
let arguments = { someId: "1234" }
graphql(schema, query, null, arguments)