Skip to content

Instantly share code, notes, and snippets.

View tiegz's full-sized avatar
👋
Working from home

Tieg Zaharia tiegz

👋
Working from home
View GitHub Profile
@tiegz
tiegz / .gitconfig
Last active August 29, 2015 14:01 — forked from ktheory/.gitconfig
# Inspired by https://github.com/gabebw/dotfiles/blob/master/gitconfig.erb
[user]
name = Tieg Zaharia
email = XXX
[core]
excludesfile = ~/.gitignore
[apply]
whitespace = nowarn
[diff]
color = auto
@tiegz
tiegz / record_timestamps_and_callbacks_regression_example.rb
Last active August 29, 2015 13:57
Example for Rails 4 Timestamp/Callback order regression.
class Thing < ActiveRecord::Base
before_update :skip_record_timestamps
def skip_record_timestamps
self.record_timestamps = false
return true
end
after_update :reset_record_timestamps
def reset_record_timestamps
self.record_timestamps = true
@tiegz
tiegz / .gitignore
Last active August 29, 2015 13:57
Microgem for shoulda-matchers' assign_to helper (which was removed in 2+).
Gemfile.lock
@tiegz
tiegz / mailgun_batch_smtp.rb
Last active July 18, 2018 15:43
Getting Mailgun SMTP Batch emails to work in ActionMailer.
class FoobarMailer < BaseMailer
# The method you'll actually call to generate the batched email
def batched_foobar
# Recipient Variables
recipients = {"[email protected]" => {"name" => "You Youington"}}
mail(to: "[email protected]") do |format|
# Mailgun requires you to base64 your Recipient Variables JSON
format.custom('application/json', content_transfer_encoding: "base64") do
render text: Base64.encode64(recipients.to_json)
@tiegz
tiegz / jammit_to_asset_pipeline_check.rb
Last active December 21, 2015 00:39
Cross-checking the output of bundled files in Jammit vs Asset pipeline.
# Jammit bundle for 'application.js' expanded into paths
Jammit::Packager.new.instance_variable_get(:@packages)[:js][:application][:urls]
# Asset Pipeline bundle for 'application.js' expanded into paths
Rails.application.assets.find_asset('application.js').to_a.map(&:pathname).map(&:to_s)
@tiegz
tiegz / Preferences.sublime-settings
Last active December 16, 2015 22:20
Sublime preferences
{
"tab_size": 2,
"translate_tabs_to_spaces": true,
"word_wrap": false
}
@tiegz
tiegz / generate_letterboxd_csv_from_vudu.js
Last active October 13, 2020 00:50
Import VUDU rental history into a CSV format readable by Letterboxd.
// Run this in the browser bar: var el = document.createElement("script"); el.src=URL; document.body.appendChild(el);
//
// 1. Login to http://my.vudu.com
// 2. Open the Inspector (cmd-ctrl-I on OSX), and un this script (if popups are blocked, temporarily unblock popups from Vudu in your browser)
// 3. Grab the downloaded CSV file (probably with a random name), and load at http://letterboxd.com/import
//
// How it works: this script is inserted into the Vudu page via a bookmarklet, grabs your session key, and
// makes a call to Vudu's api. Then it parses the response and creates a CSV, which it then opens in a page as a data-uri.
//
// Copyright 2013-2020. Code released under the MIT license.
@tiegz
tiegz / raspbpi-gpio.rb
Last active December 12, 2015 02:58
Simple controls in Ruby for controlling the GPIO pins on RaspbPi (reference: http://elinux.org/images/2/2a/GPIOs.png)
def with_pin(pin)
begin
puts "Connecting..."
export(pin)
direction(pin, "out")
yield(pin)
ensure
puts "Disconnecting..."
unexport(pin)
end
@tiegz
tiegz / ruby_fun_liner.sh
Created November 19, 2012 16:56
Fun ruby one-liner
ruby -e 'c=`tput cols`.to_i;p=->(o){x=0;d=c/4;while(x<1)do puts("█"*(d*Math.sin(x+o)+d));x+=0.1;end};i=0;loop{p.(i);sleep 0.05;i+=0.1}'
@tiegz
tiegz / README.markdown
Created August 3, 2012 18:15
DTrace probes for ruby 1.9.3-HEAD

What?

This is a starting point to get something similar to memprof running in ruby 1.9. So far it adds DTrace probes to ruby 1.9.3, which we output and parse at some point later.

This will generate 2 types of probes so far:

  • RUBY_OBJ_NEW(): capture the file, line and type of a newly allocated object.
  • RUBY_CALL(): capture the function name of every function called. 😱

Partly inspired by this blog post: http://tenderlovemaking.com/2011/06/29/i-want-dtrace-probes-in-ruby.html