Skip to content

Instantly share code, notes, and snippets.

@tcaddy
tcaddy / config
Last active December 11, 2015 17:29
Desktop notifications and Last.fm scrobbing with Pianobar (CLI Pandora music player). Inspired by https://gist.github.com/3056329
# User
user = YOUR_EMAIL_ADDRESS_FOR_PANDORA_ACCOUNT
password = YOUR_PASSWORD_FOR_PANDORA_ACCOUNT
# Misc
event_command = /YOUR_PATH_TO_HOME_FOLDER/.config/pianobar/pianobar-lastfm.rb
audio_quality = high
rpc_host = tuner.pandora.com
tls_fingerprint = 2D0AFDAFA16F4B5C0A43F3CB1D4752F9535507C0
@tcaddy
tcaddy / rspec.rake
Last active December 10, 2015 00:08
Place this file in the `lib/tasks` folder of your Rails project. Run `rake -T` to see available rake tasks. This will dynamically create a single rake task for each single `*_spec.rb` file. It will also create additional rake tasks that run all `*_spec.rb` files in a given sub-directory.
require 'rspec/core/rake_task'
orm_setting = Rails.configuration.generators.options[:rails][:orm]
spec_prereq = if(orm_setting == :active_record)
Rails.configuration.active_record[:schema_format] == :sql ? "db:test:clone_structure" : "db:test:prepare"
else
:noop
end
namespace :spec do
[:requests, :models, :controllers, :views, :helpers, :mailers, :lib, :routing].each do |sub|
dn = "#{File.expand_path(::Rails.root.to_s)}/spec/#{sub}"
.gecko .gform_body input[type='text'] {
height: inherit;
padding: 5px;
}
@tcaddy
tcaddy / bootstrap-progress-auto.css
Created May 21, 2012 19:40
Use CSS to auto expand-retract progress bar infinitely
/* this animation is for progress bars that are not active */
.progress.auto-progress > .bar {
-webkit-animation: progress-bar-auto 2s linear infinite;
-moz-animation: progress-bar-auto 2s linear infinite;
-ms-animation: progress-bar-auto 2s linear infinite;
-o-animation: progress-bar-auto 2s linear infinite;
animation: progress-bar-auto 2s linear infinite;
}
/* this animation is for progress bars that are active */
@tcaddy
tcaddy / gist:1893758
Created February 23, 2012 17:01
RoR error_messages_for in jQuery Mobile
// run this after pageload/DOM ready
// this will modify HTML generated by Ruby on Rails :error_messages_for helper method
function jqmify_error_messages_for() {
var sel = $("div.errorExplanation");
if (sel.length>0) {
sel.parent().addClass("ui-body").addClass("ui-body-e");
sel.attr('data-role','collapsible')
.attr('data-theme','e')
.collapsible()
.trigger('expand');
@tcaddy
tcaddy / gist:1879026
Created February 21, 2012 21:20
Use jQuery Mobile $.mobile.showPageLoadingMsg() for other messages/notifications
var default_msg = $.mobile.loadingMessage; // set this outside function scope so we can access it later
// you must provide a msg argument. The delay and theme arguments are optional.
function show_hide_message = function(msg,delay,theme) {
if (typeof(delay)==='undefined') {
var delay = 3500; // in milliseconds
}
if (typeof(theme)==='undefined') {
var theme = 'a'; // default theme; setting this to 'e' is nice for error messages
}
@tcaddy
tcaddy / gist:1878894
Created February 21, 2012 20:59
override jQuery Mobile fieldcontain padding and bottom border for portrait mode
@media all and (max-width: 450px){
.ui-field-contain, .ui-mobile fieldset.ui-field-contain {
border-width: 0 !important;
padding: 0 !important;
margin: 1em 0 !important;
}
}
@tcaddy
tcaddy / your_style.css
Created February 21, 2012 16:01
jQuery Mobile - show labels nested within hidden label classes
.ui-hide-label .ui-show-label label {
/* show a label nested within a hide label */
position: relative !important;
left: auto !important;
clip: auto !important;
}
@tcaddy
tcaddy / gist:1688976
Created January 27, 2012 14:16
Convert Datatel export files to UTF-8 using Ruby
=begin
I am using Ruby to parse exported data generated from Datatel. I ran into a strange problem with conflicting character sets.
Datatel's internal character set is: ISO_8859-1
Datatel will set the metadata in the export text file to be: US-ASCII
And I want Ruby to use this charset: UTF-8
=end
@tcaddy
tcaddy / gist:1377322
Created November 18, 2011 18:38
assert_template in Rails3 mailer test
class SomeMailerTest < ActionMailer::TestCase
# include this so that assert_template is defined
include ActionController::TemplateAssertions
end
class SomeMailerTest < ActionMailer::TestCase
test "the mailer" do
email = SomeMailer.the_mailer.deliver
assert_template :partial=>'_the_mailer_partial'
end