Skip to content

Instantly share code, notes, and snippets.

@werdlerk
werdlerk / i18n.rb
Created September 30, 2014 13:40
Rails i18n key lookup tracing
# Where is Rails trying to look-up L10N / I18N Strings
# archived mirror http://cache.preserve.io/8vupog4s/index.html
# original of http://www.unixgods.org/~tilo/Rails/which_l10n_strings_is_rails_trying_to_lookup.html
#
# add newer versions to this array if the method definition didn't change, otherwise do an if-cascade
if ['0.5.0'].include?(I18n::VERSION)
module I18n
module Backend
module CarrierWave
module MiniMagick
def toaster_filter
manipulate! do |img|
img.modulate '150,80,100'
img.gamma 1.1
img.contrast
img.contrast
img.contrast
img.contrast

What's Flying Widgets?

Flying Widgets adds CSS3 transitions to your dashboard, allowing you to cycle through multiple widget sets on a single TV without page reloads, using stylish CSS3 transitions. You can even still re-order your widgets and save their locations!

Note that sinatra-cyclist is a potential alternative if the machine you use to display your dashboards is lacking in graphics horsepower.

Setup

To use, put this file in assets/javascripts/cycleDashboard.coffee. Then find this line in application.coffee:

@werdlerk
werdlerk / protein_translation.rb
Last active January 15, 2016 21:11
Launch School challenge: Protein Translation
class Translation
AMINO_ACIDS = {
'Methionine' => [:AUG],
'Phenylalanine' => [:UUU, :UUC],
'Leucine' => [:UUA, :UUG],
'Serine' => [:UCU, :UCC, :UCA, :UCG],
'Tyrosine' => [:UAU, :UAC],
'Cysteine' => [:UGU, :UGC],
'Tryptophan' => [:UGG],
@werdlerk
werdlerk / circular_buffer.rb
Last active January 22, 2016 20:30
Launch School challenge: Circular Buffer
class CircularBuffer
class BufferEmptyException < RuntimeError; end
class BufferFullException < RuntimeError; end
def initialize(size)
@size = size
@buffer = Array.new
end
def write(value)
@werdlerk
werdlerk / meetup.rb
Last active February 11, 2016 21:35
Launch School challenge: Meetup
class Meetup
def initialize(month, year)
@month, @year = month, year
end
def day(weekday, schedule)
@date = Date.new(@year, @month, 1)
wday = Date::DAYNAMES.index(weekday.to_s.capitalize)
case schedule
@werdlerk
werdlerk / Humax HMT format
Created May 31, 2017 19:58 — forked from GrahamCobb/Humax HMT format
Humax HDR Recorders file formats
Offset Size Content
------ ----- ---------------------------------- Header Block, Size 0x1004 (4100) bytes ---------------------------------------------
0x0000 2 byte 0x1701 Constant.
0x0000 126 byte All Nulls.Constant
------ ----- ---------------------------------- This next part is rewritten when playback completes/pauses
It seems to contain information about the recording
0x0080 string 254 byte max Recording file path e.g. "/media/sda1/My Video/" (not needed when creating hmt)
0x017F string 256 byte max Recording date-extended file name e.g. "The One Show_21010816_1817"
0x0280 4 byte 0x11223344 Recording start time (Epoch format)
0x0284 4 byte 0x11223344 Recording end time (Epoch format)
@werdlerk
werdlerk / application_controller.rb
Created April 9, 2018 13:28
Audited 3.0 gem : add extra user information to Audit
# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
# (...)
def save_admin_user_current_user
Thread.current[:audited_admin_user_id] = current_admin_user&.id
current_user
end

Uninstall brew package and dependencies

Remove package's dependencies (does not remove package):

brew deps [FORMULA] | xargs brew remove --ignore-dependencies

Remove package: