Skip to content

Instantly share code, notes, and snippets.

View mikefarmer's full-sized avatar
🏠
Working from home

Michael Farmer mikefarmer

🏠
Working from home
View GitHub Profile
@mikefarmer
mikefarmer / debug_localization.rb
Last active December 15, 2015 15:59
localization debugging in Rails
# Allow some helpful debugging of localization issues.
# You can see translations in the UI by adding the following (or like it) to your CSS.
# .translation_missing { background-color: red; color: white !important; }
# .translation_fallback { background-color: green; color: white !important; }
#
# You will also need to have the following in your development group in your Gemfile:
# gem 'term-ansicolor'
#
# To turn this off, change this to false.
LOG_LOCALIZATION_ERRORS = true unless defined?(LOG_LOCALIZATION_ERRORS)
bad URI(is not URI?):
/usr/local/lib/ruby/1.9.2/uri/common.rb:156:in `split'
/usr/local/lib/ruby/1.9.2/uri/common.rb:174:in `parse'
/usr/local/lib/ruby/1.9.2/uri/common.rb:628:in `parse'
/mnt/data/scommerce/releases/6a15180025c6e1433a7355e4138f4cfe3ffdc379/config/environments/staging.rb:17:in `block in <top (required)>'
/data/scommerce/shared/vendor/bundle/ruby/1.9.2/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:24:in `class_eval'
/data/scommerce/shared/vendor/bundle/ruby/1.9.2/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:24:in `configure'
/mnt/data/scommerce/releases/6a15180025c6e1433a7355e4138f4cfe3ffdc379/config/environments/staging.rb:3:in `<top (required)>'
@mikefarmer
mikefarmer / hack.sh
Created April 8, 2012 01:53 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@mikefarmer
mikefarmer / _form.html.erb
Created June 3, 2011 17:36
Snippets for Bookshelves
<%= form_for @bookshelf do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<% @books.each do |book| %>
<%= check_box_tag "books[#{book.id}]", "1", @bookshelf.books.include?(book) %>
<%= book.name %>
@mikefarmer
mikefarmer / smtp-sink.rb
Created May 13, 2011 22:53 — forked from kennethkalmer/smtp-sink.rb
Simple SMTP sink for eventmachine
require 'rubygems'
require 'eventmachine'
class SmtpSink < EM::Protocols::SmtpServer
def receive_data_chunk( data )
buffer.concat data
end
def receive_message
puts
@mikefarmer
mikefarmer / KRL OAuth 1 Implementation
Created March 19, 2011 22:27
A pure krl implementation of OAuth 1.0
ruleset a18x46 {
meta {
name "OAuth"
description <<
Module for OAuth 1.0
>>
author "Michael Farmer"
logging on
configure using oauth_keys = {} and
javascript:(function(){if(document.getElementById("groove")){document.getElementById("groove").parentNode.removeChild(document.getElementById("groove"));}else{qry=document.getSelection();if(qry){url="http://pseudosodacore.appspot.com/groove/"+qry;ifrm=document.createElement("IFRAME");ifrm.setAttribute("id","groove");ifrm.setAttribute("src",url);ifrm.style.top="50%";ifrm.style.left="50%";ifrm.style.position="fixed";ifrm.style.border="0";ifrm.style.width="0";ifrm.style.height="0";document.body.appendChild(ifrm);}}})()