Skip to content

Instantly share code, notes, and snippets.

View danmayer's full-sized avatar

Dan Mayer danmayer

View GitHub Profile
# frozen_string_literal: true
class SlowCall
def self.work
@work ||= Concurrent::Promises.future(name: "load #{self.class.name}") do
sleep 2
Time.now
end
end
end
@danmayer
danmayer / dog.rb
Created April 15, 2020 04:56
Jruby Coverage Differences
# frozen_string_literal: true
class Dog
def bark
'woof'
end
end
# NOTE: We monkey patch because the unknown_asset_fallback option
# doesn't seem to do what we expect, when compile scss see more below
#
# Rails.application.config.assets.unknown_asset_fallback = false
# ^^ The above works for image_tag("head_liner.svg") references, but fails for scss
#
# This patch ensures we also fail on scss
# patched against: sprockets (3.7.2), sprockets-rails (3.2.1), sass-rails (5.1.0)
# I suspect it is slightly different and perhaps the config works as expected in differnt versions
# of sprockets, sprockets-rails, sass-rails
@danmayer
danmayer / circle_runner.rb
Created September 10, 2019 04:15
Circle CI runner
require 'byebug'
require 'json'
require 'time'
#####
# A quick and dirty script to compare the success rate of branches on CircleCI.
#
# This script will run a project and banch X number of times and calculate it's success / failure rate.
# Inititally developed to track and fix a flaky test suite, it should be easily modifiable to help with
# any CircleCI project that includes flaky jobs.
@danmayer
danmayer / test_runner.rb
Created September 10, 2019 04:08
Ruby Test Runner
require 'byebug'
require 'json'
require 'time'
#####
# This script is a quick and dirty way to check the success rate of an individual test file.
#
# Purpose:
# run a test file many times and figure out how flaky it is, reporting the success rate and logging any errors
#
@danmayer
danmayer / test header overflow
Created August 15, 2019 22:11
Trigger Header Overflow on Cloudfront
curl 'https://www.stitchfix.com/' -v -H 'authority: www.stitchfix.com' -H 'cache-control: max-age=0' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36' -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3' -H 'sec-fetch-site: none' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-US,en;q=0.9' -H 'cookie: header_check=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
@danmayer
danmayer / RailsCookieDebugging.rb
Created August 14, 2019 18:56
Debugging Growing Cookies and Cookie Overflows
####
# This can be inserted in a before filter, or an endpoint causing cookie overflows
# this will log data for users who are approaching the max_cookie_size
# it will also for the most common cookie to overflow session, break down the size by key value pairs.
# This logs cookie and key names, but none of the data which may include PII, it just logs the byte sizes
#
# How to read:
# Cookie Debug (size: 3280) # overall cookies total size in bytes
# [COOKIE_NAME] size=IN_BYTES # these are sorted by smallest to largest byte size
# session: [KEY] size=IN_BYTES # for the session cookie, the key name with values in byte size sorted
@danmayer
danmayer / amsterdam.md
Last active March 30, 2019 19:57
Amsterdam

I have twice recently been asked what to do in Amsterdam with kids... Clearly need to blog this but for now.


I recall you are biking folks, so rent some bikes, you can get one with a variety of child attachments for the 4 year old. If after walking through the city that kind of biking doesn't look fun... Rent bikes and visit Vondelpark, regardless of bike riding Vondelpark is awesome to walk through.

I frequently stayed very close to Anne Frank's house while there as my old office was walking distance from that.

  • If you do a boat tour I highly recommend "Those damn boat guys" We have done that twice with Theo (who is now 2)
  • they are smaller boats/groups, and less stodgy very funny and factual kind of stand-up comedy like history
@danmayer
danmayer / tech_books.csv
Last active March 25, 2018 19:46
Tech Books
Book Theme Recommended By Notes
[Remote: Office Not Required](http://batman.com) Distributed Work Moyinoluwa Adeyemi A great book about how to function as a distributed team. Full review here: https://tech.offgrid-electric.com/book-review-remote-office-not-required-e75e19c68529
Radical Candor: Be a Kick-Ass Boss Without Losing Your Humanity Communication / Team Management Thor Muller From the time we learn to speak, we’re told that if you don’t have anything nice to say, don’t say anything at all. When you become a manager, it’s your job to say it--and your obligation.
Emotional Intelligence 2.0 Communication / Self Management Dian four, core EQ skills that enable you to achieve your fullest potential: 1) Self-Awareness 2) Self-Management 3) Social Awareness 4) Relationship Management
Creativity, Inc - Ed Catmull  Creative work / Collaboration Dan Mayer How to encourage deep thought and creativity in a working environment, told through the story of Pixar
@danmayer
danmayer / jira_tasks.rb
Created August 20, 2017 18:34
Simple Jira Release Process Automation
# These tasks should be called from your deploy process or countinious deployment server script, something like below
namespace :production do
desc 'production deployment'
task deploy: 'docker:build:push' do |t, args|
release_notes_and_tagging
end
end
###
# Update releases.txt file with deployed tickets