Skip to content

Instantly share code, notes, and snippets.

Avatar
🌩️

Max Lielje mxlje

🌩️
View GitHub Profile
@mxlje
mxlje / README.md
Last active Jul 4, 2017
dgraph broken recursive sorting example/bug
View README.md

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 Jun 29, 2017
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(`
<html>
{{ 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
mxlje / heredoc.rb
Last active Aug 10, 2018
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
module INDENTED
OLD = <<-END
<head>
<title>Hello World</title>
</head>
@mxlje
mxlje / 0_dropbox-image-download.md
Last active Mar 23, 2018
download dropbox images from Camera Uploads folder
View 0_dropbox-image-download.md

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

View colors.rb
class C
class << self
def green(s)
"\e[36m#{s}\e[0m"
end
def orange(s)
"\e[33m#{s}\e[0m"
end
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
mxlje / underscore.move.js
Last active Aug 26, 2015 — 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()
*/
_.mixin({
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
mxlje / arguments.js
Last active Oct 15, 2015
Code samples for “Understanding GraphQL Server” https://keywordbrain.com/blog/understanding-graphql-server/
View arguments.js
let arguments = { someId: "1234" }
graphql(schema, query, null, arguments)