This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'webrick' | |
class Servlet < WEBrick::HTTPServlet::FileHandler | |
PORT = 4200 | |
INDEX_FILE = 'index.html' | |
ROOT_PATH = File.expand_path(__dir__) # Folder of current file | |
def do_GET(request, response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class GraphGenerator | |
# Returns list of edges for n-vertex complete graph | |
# | |
# Example: | |
# GraphGenerator.generate(4) | |
# [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4] | |
def self.generate(count) | |
if count == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From http://meinit.nl/using-tar-and-ssh-to-efficiently-copy-files-preserving-permissions | |
ssh user@machine-where-precious-data-is "tar czpf - /some/important/data" | tar xzpf - -C /new/root/directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flatten(input, output=[]) | |
input.each do |e| | |
if e.is_a? Array | |
output += flatten(e) | |
else | |
output.push e | |
end | |
end | |
output | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def build_tree(root_id:) | |
root_row = db_find(id: root_id) | |
root_node = | |
{ | |
id: root_id, | |
text: root_row[:text] | |
} | |
add_children(root_node, db_find_children(parent_id: root_id)) | |
root_node | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thwait' | |
$LOAD_PATH << '/Users/madisnoemme/code/etventure/rbn-be-api' | |
threads = 10000.times.map { | |
print "." | |
Thread.new { | |
require_relative './rbn/service/xml/mapping' | |
require_relative './rbn/service/xml/mappings' | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Settings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker images | tail -n+2 | awk '{print $3}' | xargs -L1 docker rmi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
navigator.mozGetUserMedia({video: true, audio: false}, function(s) {window.zeVideoOnly = s}, function() {}); navigator.mozGetUserMedia({video: true, audio: true}, function(s) {window.zeVideo = s}, function() {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From http://stackoverflow.com/questions/6850276/how-to-convert-dataurl-to-file-object-in-javascript | |
function dataURItoBlob(dataURI) { | |
if(typeof dataURI !== 'string'){ | |
throw new Error('Invalid argument: dataURI must be a string'); | |
} | |
dataURI = dataURI.split(','); | |
var type = dataURI[0].split(':')[1].split(';')[0], | |
byteString = atob(dataURI[1]), | |
byteStringLength = byteString.length, | |
arrayBuffer = new ArrayBuffer(byteStringLength), |