- library for working with command line arguments
- A manipulable, pluggable, memoization framework for Clojure
- A Clojure interface to Sentry
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' | |
} | |
} |
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 |
def flatten(input, output=[]) | |
input.each do |e| | |
if e.is_a? Array | |
output += flatten(e) | |
else | |
output.push e | |
end | |
end | |
output | |
end |
# 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 |
#!/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 |
#!/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) |
+Esc
#!/usr/bin/env ruby | |
# You can try the running code at http://tpcg.io/FnffuR | |
# More explicit implementation. The algorithm you described: | |
# iterating over characters from both ends of string. | |
# Returning false as soon as first mismatch is found | |
def palindrome_by_manual_reversing?(word) | |
word_string = word.to_s | |
# Return early because a word is always a palindrome if |
require 'webrick' | |
require 'rack' | |
require 'rack/query_parser' | |
class CallbackServer | |
ENDPOINT = '/callbacks' | |
attr_reader :requests | |
def initialize |