Skip to content

Instantly share code, notes, and snippets.

@meagar
meagar / close_zoom.js
Last active August 29, 2023 10:33
User Script: Close zoom tabs upon completion
// ==UserScript==
// @name Close Zoom Tabs
// @namespace Violentmonkey Scripts
// @match https://*.zoom.us/j/*
// @grant none
// @version 1.0
// @author Matthew Eagar <meagar@hey.com>
// @description Close the tabs Zoom spawns
// @homepage https://gist.github.com/meagar/9c902cf83d464c0572ea8dd37a7faa00
// ==/UserScript==
@meagar
meagar / rebase.md
Created April 30, 2014 16:01
Ultimate rebase-onto-master guide

Rebase "web-123-my-branch" onto master:

if you're the only person who is working on a branch...

$ git checkout web-123-my-branch # make sure you're on the right branch
$ git fetch # update remote refs
$ git rebase origin/master # perform the rebase onto the current state of master
  # for each conflict, edit file, resolve conflicts, git add -u <file>, git rebase --continue
$ git push -f origin web-123-my-branch # overwrite remote branch with newly rebase branch
@meagar
meagar / benchmark.rb
Created December 1, 2020 15:00
Monotonic time for benchmarking
# Source: https://blog.dnsimple.com/2018/03/elapsed-time-with-ruby-the-right-way/
starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
# time consuming operation
ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
elapsed = ending - starting
elapsed # => 9.183449000120163 seconds
@meagar
meagar / jsoffline.md
Last active August 14, 2018 09:28
Taking JavaScript Offline

Note: this presentation was written for Gistdeck. Add the bookmarklet, come back to this gist, click the bookmarklet, then use the arrow keys to navigate.

Note2: See https://github.com/meagar/taking-javascript-offline for code examples; any time a string like 2-basic-caching appears, that's a branch which supports that slide

Taking JavaScript Offline

Who am I?

@meagar

SIDES = %w(R L B F U D)
TURNS = ["", "2", "'"] # one turn, two turns, one counter-turn
N = 20
last = ""
moves = N.times.map do
side = (SIDES - [last]).sample
turn = TURNS.sample
last = side
[side, turn].join
SIDES = %w(R L B F U D)
TURNS = ["", "2", "'"] # one turn, two turns, one counter-turn
moves = 20.times.inject([]) { |memo, _| memo + [(SIDES - [memo.last]).sample] }
p moves.zip(TURNS.cycle).map(&:join) # ["F", "L2", "U'", "B", "L2", "R'", "D", "U2", "B'", "D", "F2", "U'", "L", "B2", "U'", "D", "R2", "L'", "D", "F2"]
# benchmark for http://stackoverflow.com/q/44097717/229044
require 'set'
require 'benchmark'
def make_data(size = 25_000)
t = Time.now
size.downto(0).map do |i|
{
'timestamp-value' => (t - i * 60).to_s[0..15],
# This is pure data, it's the definition of a category
class Category
has_many :clues
# name: string
end
# This is pure data, it's the definition of a category, it's not tied to any user or game
class Clue
MyModule.configure do |config| 
#stuff inside 
end 
@meagar
meagar / gist:8027073
Created December 18, 2013 18:14
Simple rake progress bar
# Use:
#
# # Pass an emuerable to #new
#
# users = User.active
# RakeProgrssBar.new(users) do |user|
# user.do_something_amazing
# end
#
#