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
formatJSON[json_] := formatRawJSON@rulesToAssociations[json] | |
rulesToAssociations[rules_] := | |
Replace[rules, r : {__Rule} :> Association[r], {0, Infinity}] | |
basicTypeQ[_String | True | False | Null | (_?NumericQ)] = True; | |
basicTypeQ[_] = False; | |
formatRawJSON[json_] := |
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
dpyNullary[ex_] := | |
Grid[{{ex, ""}}, | |
Frame -> {All,False}, | |
Alignment -> Left, | |
Background -> {{LightOrange,{LightYellow}}}]; | |
dpyMultiary[key_, vals_] := | |
With[{c = Length @ vals}, | |
Module[{ | |
spans = Table["", {c}], |
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 | |
# Parts stolen with no regret from Homebrew's OpenSSL formula. | |
require 'fileutils' | |
require 'openssl' | |
require 'digest/md5' | |
require 'digest/sha1' | |
CERT_FILE = ENV.fetch('SSL_CERT_FILE', '/usr/local/etc/openssl/cert.pem') |
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
# https://github.com/jeremyevans/sequel/issues/830 | |
require 'sequel' | |
require 'logger' | |
DB = Sequel.sqlite | |
logger = Logger.new($stdout) | |
DB.loggers << logger |
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
class Symbol | |
def | other | |
-> arg { other.to_proc[arg.send(self)] } | |
end | |
def call(*args) | |
-> arg { arg.send(self, *args) } | |
end | |
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
module Vulcan | |
module DataInterface | |
module RawLoader | |
def max_id | |
max(:id) || 0 | |
end | |
# Rows are selected in chunks specified by page_size | |
# and inserted in slices by slice_size |
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 | |
# encoding: utf-8 | |
CHARS = %w{ } | |
def encode(string) | |
string.chars.map{|c|"#{CHARS[c[0]/16]}#{CHARS[c[0]%16]}"}.join | |
end | |
program = <<-EOF |
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 'rubygems' | |
require 'sequel' | |
DB = Sequel.sqlite | |
DB.create_table :users do | |
Integer :id | |
String :name |
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
module Sequel | |
class Dataset | |
def to_csv(file_name, mode, opts = {}) | |
n = naked | |
cols = n.columns | |
FasterCSV.open(file_name, mode, opts) do |csv| | |
csv << cols | |
n.each{|r| csv << cols.map{|c| r[c]}} | |
end | |
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
if ARGV[0] | |
gem 'sequel', '= 3.34.1' | |
else | |
gem 'sequel', '= 3.33.0' | |
end |
NewerOlder