Skip to content

Instantly share code, notes, and snippets.

View danmayer's full-sized avatar

Dan Mayer danmayer

View GitHub Profile
@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
# 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 / 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
@danmayer
danmayer / wumpus.java
Created March 11, 2012 01:38
Wumpus world, old java code I found on one of my blogs
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class Room {
@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 / 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