Skip to content

Instantly share code, notes, and snippets.

[{
count: 71,
heap_allocated_pages: 1939,
heap_sorted_length: 1939,
heap_allocatable_pages: 0,
heap_available_slots: 790308,
heap_live_slots: 672632,
heap_free_slots: 117676,
heap_final_slots: 0,
heap_marked_slots: 636366,
@mcgaffin
mcgaffin / bub_pill_as_pure_component.jsx
Created October 11, 2019 14:37
BubPill as PureComponent, BubPill as functional component with hooks
import classNames from "classnames";
import "stylesheets/shared/components/bub_pill";
export class BubPill extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
hovered: false,
@mcgaffin
mcgaffin / compare_plans.rb
Created May 21, 2019 15:16
Comparing Individual users in a planner spec
def compare_individual_users(good, test)
keys = good.first.last.keys.sort
good.each do |user_key, good_user|
test_user = test[user_key]
puts "---> #{user_key}"
keys.each do |key|
if (good_user[key] != test_user[key])
puts key
puts good_user[key]

Keybase proof

I hereby claim:

  • I am mcgaffin on github.
  • I am mcgaffin (https://keybase.io/mcgaffin) on keybase.
  • I have a public key ASB5Ub6PTYX0X7BzUTpLPXdmFjX8JRhdq3Vuc8PI7pWNzQo

To claim this, I am signing this object:

@mcgaffin
mcgaffin / console_tips.md
Last active March 6, 2019 19:58
Console/Canary Tips

chrome console

colorize your logs

normal log message

console.log('normal log message')

image

log message with color

@mcgaffin
mcgaffin / 0_reuse_code.js
Created September 30, 2016 18:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
require "spec_helper"
describe "editors' recommendations", js: true do
context "visit the editor's recommendations page" do
it "visits the page and takes a screenshot" do
visit "/editors"
page.save_screenshot("editors.png", full: true)
end
end
end
@mcgaffin
mcgaffin / convert_cloudinary_urls.sh
Last active August 8, 2016 13:26
Convert Cloudinary URLs to named transformations using sed
#!/bin/sh
#
# sed script to convert dynamic transformations on Cloudinary to named transformations
#
# The tricky part was getting the backreference syntax correct.
sed -E \
's/bookbub\/image\/upload\/.+h_([0-9]{3}).+\/v[0-9]*/kobubob\/image\/upload\/t_ci_email_201608_dynamic_\1/' \
previews/default_deals_mobile_improvements/secondary_data/promotions.json
@mcgaffin
mcgaffin / jq.md
Last active August 4, 2016 16:22
Querying json with jq

Install jq

$ brew install jq

Simple Querying

With json that looks like this:

[
  [
@mcgaffin
mcgaffin / days_of_month.sql
Last active June 15, 2016 13:28
Find number of days in any month modded by some day-of-month
postgresql
----
select 31 % (SELECT
DATE_PART(
'days',
DATE_TRUNC('month', now() :: DATE) + '1 MONTH' :: INTERVAL - '1 DAY' :: INTERVAL
)
)::integer
redshift