Skip to content

Instantly share code, notes, and snippets.

View charlespeach's full-sized avatar

Charles Peach charlespeach

View GitHub Profile
@charlespeach
charlespeach / string_concat_benchmark.rb
Created September 1, 2020 11:02
Benchmarking string concat from array of hashes
require 'benchmark/ips'
Benchmark.ips do |b|
b.config(time: 39, warmup: 2)
count = 100
ary = Array.new(count, { text: 'text' })
b.report("map") do
ary.map { |hash| hash[:text] }.join
@charlespeach
charlespeach / Gemfile
Created June 25, 2020 23:27 — forked from dhh/Gemfile
HEY's Gemfile
ruby '2.7.1'
gem 'rails', github: 'rails/rails'
gem 'tzinfo-data', '>= 1.2016.7' # Don't rely on OSX/Linux timezone data
# Action Text
gem 'actiontext', github: 'basecamp/actiontext', ref: 'okra'
gem 'okra', github: 'basecamp/okra'
# Drivers
@charlespeach
charlespeach / book-recommendations.md
Last active March 4, 2020 22:01
Book Recommendations

BOOK SPLOT

  • Thank You For Arguing - Jay Heinrichs
  • Sapiens - Yuval Noah Harari
  • Out of the Forest - Gregory P Smith (heavy read, not for the faint of heart)
  • People's History of the United States - Howard Zinn
  • How to Invent Everything - Ryan North
  • Thing Explainer - Randall Munroe
  • Mother Tongue - Bill Bryson
  • The Timeless Way of Building & A Pattern Language & The Nature of Order - Christopher Alexander
@charlespeach
charlespeach / reject-trace.md
Last active January 30, 2020 22:50
Rejecting TRACE with middleware in a rails app

lib/reject_trace.rb

module Rack

  class RejectTrace
    def initialize(app)
      @app = app
    end
def find_in(collection:, query:)
result = collection.dig(*query[:object_path])
case result
when Array then
return result[query[:position]]
else
return result
end
end
@charlespeach
charlespeach / sqs.rb
Created May 31, 2017 03:03
Global variable using ruby singleton pattern
class SQSToken
class << self
def get_token
puts @@sqs_token ||= magic_method_which_gets_the_token_the_first_time
end
# Replace this method with a call to what ever magic
# code that gets a new token only if required
def magic_method_which_gets_the_token_the_first_time
puts 'ive run!'
@charlespeach
charlespeach / hack-mini.md
Last active May 26, 2017 18:06
Hack-mini part list

Parts list for the Hack-Mini

The following parts are what I used for mine. If you want to build your own, please message me and I can help with the hackintosh setup!

  • 1x ASRock Deskmini 110 (Case/Mobo/DC Powerbrick combo!)
  • 1x Intel Skylake Core i3 (You could swap this out for any Skylake processor, just be mindful the board that comes in the Deskmini has a intel H110 chipset and does not support overclocking)
  • 2x Kingston ValueRAM SO-DIMM DDR4 PC17000/2133MHz CL15 8GB (You could increase this to 2x 16GB as the system supports 32GB)
  • Lastly: What ever storage you want. There is a m.2 slot for a PCI-e x4 SSD (think intel 600p, samsung 950/960 PRO, cannot be sata) and also 2x SATA 3 headers for 2.5mm SATA SSD's. Pick your poison!

If you want wifi/bluetooth, I suggest buying this: [Broadcom WIFI Wireless AC BCM94352Z](https://www.aliexpress.com/item/NEW-Broadcom-Or