Skip to content

Instantly share code, notes, and snippets.

View jkthorne's full-sized avatar
💭
caffeinated

Jack jkthorne

💭
caffeinated
View GitHub Profile
@jkthorne
jkthorne / benchmark.cr
Last active July 16, 2021 17:57
benchmark array v static array
require "benchmark"
std_array_sm = Array(Int32).new(8) { rand(0..1000) }
std_array_md = Array(Int32).new(16) { rand(0..1000) }
std_array_lg = Array(Int32).new(32) { rand(0..1000) }
std_array_xlg = Array(Int32).new(64) { rand(0..1000) }
std_array_xxlg = Array(Int32).new(128) { rand(0..1000) }
static_array_sm = StaticArray(Int32, 8).new { rand(0..1000) }
static_array_md = StaticArray(Int32, 16).new { rand(0..1000) }
static_array_lg = StaticArray(Int32, 32).new { rand(0..1000) }
@jkthorne
jkthorne / xml bug
Created February 21, 2021 18:15
xmll bug
require "xml"
xml = XML.parse <<-XML
<?xml version="1.0" encoding="UTF-8"?>
<transaction>
<id>fj6df5n1</id>
<status>submitted_for_settlement</status>
<type>sale</type>
<currency-iso-code>USD</currency-iso-code>
<amount>9363.36</amount>
require "benchmark"
module Enumerable
def j8r_join(separator, io)
first = true
each do |elem|
io << separator unless first
yield elem, io
first = false
end
@jkthorne
jkthorne / 00-README.md
Created March 8, 2019 06:39 — forked from rf-/00-README.md
Crystal ctags generator

To compile with Homebrew-installed LLVM:

PATH=/usr/local/opt/llvm/bin:$PATH crystal build crystal-tags.cr
@jkthorne
jkthorne / crystal-tags.cr
Created March 8, 2019 06:39 — forked from datanoise/crystal-tags.cr
ctags for crystal language
require "compiler/crystal/**"
require "option_parser"
include Crystal
class ToCtagsVisitor < Visitor
@filename : String
@lines : Array(String)
@io : IO
@opts : Generator
Error in ./main.cr:51: instantiating 'Polish::CLI:Class#run()'
Polish::CLI.run
^~~
in ./main.cr:14: instantiating 'Polish::CLI#run()'
new.run
^~~
iex(1)> alias BuzzwordBingo.User
nil
iex(2)> alias BuzzwordBingo.User.Repo
nil
iex(3)> Repo.all(User)
** (UndefinedFunctionError) undefined function: BuzzwordBingo.User.Repo.all/1 (module BuzzwordBingo.User.Repo is not available)
BuzzwordBingo.User.Repo.all(BuzzwordBingo.User)
iex(3)>
Run options: --seed 6850
# Running:
.....................................................E.............................................................................................E.............................................................................................................................................................
Finished in 127.196609s, 2.3979 runs/s, 5.8885 assertions/s.
1) Error:
SalesforceUserCreationWorker::#perform#test_0010_gracefully handles multiple queued jobs for the same user:
@jkthorne
jkthorne / gist:1888630f4788ad33edc4
Created May 15, 2014 18:09
this is madness this is filters
[:ensure_proper_protocol, :verify_authenticity_token, :assign_current_user_to_models, :handle_user_settings, :clean_temp_files, "_callback_around_277", :validate_selected_object, :do_not_allow_rjs_to_be_requested_via_script_tag, :clear_timeslice_service_state, :sanitize_request_format, :check_for_xhr_html, :verify_supported_browser, :login_required, :prevent_sidejacking, :prevent_framing, :load_account, :verify_authed_correctly, :verify_permissions, :verify_restricted_partnerships, :load_shard, :adjust_format_for_iphone, :load_time_zone, :log_request, :set_end_user_filter, :record_format, :require_email_validation_for_logged_in_users, :setup_shard_cache_and_metric_scope, "_callback_before_34850", "_callback_before_34854(self)", "_callback_before_34858(self)", "_callback_before_34862(self)", "_callback_before_34866(self)", "_callback_before_34870(self)", "_callback_before_34874(self)", "_callback_before_34878(self)", "_callback_before_34882(self)", "_callback_before_34886(self)", "_callback_before_34890(self)"
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;