Skip to content

Instantly share code, notes, and snippets.

View mkreyman's full-sized avatar
🏃‍♂️
Building cool stuff, serving customers, and enjoying every moment of it...

Mark Kreyman mkreyman

🏃‍♂️
Building cool stuff, serving customers, and enjoying every moment of it...
View GitHub Profile
@mkreyman
mkreyman / DynamoDbWriter.js
Created July 17, 2019 19:53 — forked from mike-hogan/DynamoDbWriter.js
Nodejs DynamoDB writer with exponential back off
"use strict";
var fs = require('fs');
var path = require('path');
var AWS = require('aws-sdk');
var util = require('util');
var stream = require('readable-stream');
var _ = require('lodash');
@mkreyman
mkreyman / donate-bitcoin.html
Created July 9, 2018 01:22 — forked from joar/donate-bitcoin.html
Quick and dirty bitcoin donation button, as seen on https://gobblin.se
<style>
.donate-button {
text-align: center;
}
.donate-button .bitcoin-address {
font-size: 1.5em;
}
</style>
<div class="donate-button">
@mkreyman
mkreyman / ruby_benchmark_examples.rb
Created August 15, 2017 16:41 — forked from SabretWoW/ruby_benchmark_examples.rb
Three examples showing three of the main methods of Ruby's Benchmark class that's used to profile your code. Benchmark.measure at the most basic, Benchmark.benchmark allows you to run trials of different code blocks, and Benchmark.bmbm that helps you establish a baseline for your tests.
# http://www.ruby-doc.org/stdlib-2.0/libdoc/benchmark/rdoc/Benchmark.html
require 'benchmark'
# http://www.ruby-doc.org/stdlib-2.0.0/libdoc/bigdecimal/rdoc/BigMath.html
require 'bigdecimal/math'
# Set the number of iterations to run. The underscore here is used as a substitute for normal comma so Ruby interprets the number correctly.
iterations = 10
puts "\nCalculating pi #{iterations} times.\n\n"
@mkreyman
mkreyman / rspec_model_testing_template.rb
Created August 15, 2017 16:40 — forked from SabretWoW/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems:
@mkreyman
mkreyman / Gemfile
Last active July 18, 2017 20:54 — forked from hopsoft/Gemfile
ruby-prof: Add profiling to your rake tasks.
group :development do
gem "ruby-prof"
end
@mkreyman
mkreyman / enigma_machine.rb
Created March 9, 2016 21:11 — forked from albertstill/enigma_machine.rb
Understand how the Enigma machine works with 30 lines of Ruby
Plugboard = Hash[*('A'..'Z').to_a.sample(20)]
Plugboard.merge!(Plugboard.invert)
Plugboard.default_proc = proc { |_, key| key }
def build_a_rotor
Hash[('A'..'Z').zip(('A'..'Z').to_a.shuffle)]
end
ROTOR_1, ROTOR_2, ROTOR_3 = build_a_rotor, build_a_rotor, build_a_rotor
@mkreyman
mkreyman / .irbrc
Created April 20, 2014 02:25 — forked from adamcrown/.irbrc
require 'rubygems' unless defined? Gem # rubygems is only needed in 1.8
def unbundled_require(gem)
loaded = false
if defined?(::Bundler)
Gem.path.each do |gems_path|
gem_path = Dir.glob("#{gems_path}/gems/#{gem}*").last
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')