Skip to content

Instantly share code, notes, and snippets.

View mxlje's full-sized avatar
🌩️

Max Lielje mxlje

🌩️
View GitHub Profile
@mxlje
mxlje / README.md
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
mxlje / recursive.go
Created June 29, 2017 14:13
Golang html/template recursive rendering partial
type Thing struct {
Text string
Things []Thing
}
func RootHandler(rw http.ResponseWriter, req *http.Request) {
tmpl, err := template.New("root").Parse(`
<html>
{{ define "message" }}
<li>{{ .Text }}
([*('A'..'Z'),*('0'..'9')]-%w(0 1 I O)).sample(9).each_slice(3).map(&:join).join('-')
@mxlje
mxlje / heredoc.rb
Last active August 10, 2018 17:19
Ruby 2.3.0 heredocs with tilde (~)
# 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
module INDENTED
OLD = <<-END
<head>
<title>Hello World</title>
</head>
@mxlje
mxlje / 0_dropbox-image-download.md
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.

Setup

Dropbox Keys

class C
class << self
def green(s)
"\e[36m#{s}\e[0m"
end
def orange(s)
"\e[33m#{s}\e[0m"
end
@mxlje
mxlje / ping
Created November 5, 2015 09:26
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
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()
/*
_.move - takes array and moves item at index and moves to another index; great for use with jQuery.sortable()
*/
_.mixin({
move: function (array, fromIndex, toIndex) {
array.splice(toIndex, 0, array.splice(fromIndex, 1)[0] );
return array;
}
slug = text.downcase.gsub(/(ä|Ä|ö|Ö|ü|Ü|ß| |\?|\!)/, {
'ä' => 'ae',
'Ä' => 'ae',
'ö' => 'oe',
'Ö' => 'oe',
'ü' => 'ue',
'Ü' => 'ue',
'ß' => 'ss',
' ' => '-',
'?' => '',
@mxlje
mxlje / arguments.js
Last active October 15, 2015 19:22
Code samples for “Understanding GraphQL Server” https://keywordbrain.com/blog/understanding-graphql-server/
let arguments = { someId: "1234" }
graphql(schema, query, null, arguments)