Skip to content

Instantly share code, notes, and snippets.

Avatar

Jan Klimo janklimo

View GitHub Profile
@daolf
daolf / mrr.js
Last active Dec 28, 2020
MRR iOS widget
View mrr.js
// Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e
// Modified from @levelsio's https://gist.github.com/levelsio/a1ca0dd434b77ef26f6a7c403beff4d0
// By @daolf
// Prerequisite: install Scriptable @ https://apps.apple.com/us/app/scriptable/id1405459188
const API_TOKEN = "CHARTMOGUL_TOKEN"
const API_SECRET = "CHARTMOGUL_SECRET"
// Recreating a basic auth with Scriptable lib
View shopify-serverless-sync-sanity.js
const sanityClient = require('@sanity/client');
const crypto = require('crypto');
const {
SANITY_API_TOKEN,
SANITY_PROJECT_ID,
SANITY_DATASET,
SHOPIFY_SECRET
} = process.env;
@wvengen
wvengen / README.md
Last active Jul 8, 2022
Ruby memory analysis over time
View README.md

Finding a Ruby memory leak using a time analysis

When developing a program in Ruby, you may sometimes encounter a memory leak. For a while now, Ruby has a facility to gather information about what objects are laying around: ObjectSpace.

There are several approaches one can take to debug a leak. This discusses a time-based approach, where a full memory dump is generated every, say, 5 minutes, during a time that the memory leak is showing up. Afterwards, one can look at all the objects, and find out which ones are staying around, causing the

@teamon
teamon / prof.rb
Created Jun 5, 2013
Profile rails controller with ruby-prof
View prof.rb
# gem "ruby-prof"
around_filter :profiler
def profiler(&block)
data = RubyProf::Profile.profile(&block)
filepath = Rails.root.join("tmp", "profiler.html")
File.open(filepath, "w") do |f|
RubyProf::CallStackPrinter.new(data).print(f)
@camertron
camertron / measure.rb
Created Jun 15, 2012
Measure the memory taken by a Ruby object (by Robert Klemme)
View measure.rb
#!/bin/env ruby
# lazy hack from Robert Klemme
module Memory
# sizes are guessed, I was too lazy to look
# them up and then they are also platform
# dependent
REF_SIZE = 4 # ?
OBJ_OVERHEAD = 4 # ?
View capybara cheat sheet
=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')