Skip to content

Instantly share code, notes, and snippets.

@tcaddy
tcaddy / gist:1369131
Created November 16, 2011 02:59
Google+ private photo album getter
// visit a the pictures uploaded from cell phone page
// instant upload images are here: https://plus.google.com/u/0/photos/fromphone
// open javascript console...
// add jQuery to page
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1; g.src="//ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"; s.parentNode.insertBefore(g,s)}(document,"script"));
// create an array of objects, where the `url` property is the full size original uploaded image
var a=[];jQuery.each(jQuery("img.B-J-pc-ja[src$='.jpg'],img.B-J-pc-ja[src$='.JPG']"), function(i,item){var h={src:jQuery(this).attr('src')};h.proto=h.src.split('://')[0];h.host=h.src.split('://')[1].split('/')[0];h.pieces=h.src.split('://')[1].split('/');var url=[];for(var i=1;i<h.pieces.length;i++){if(i==(h.pieces.length-2)){url.push('s0-d');}else{url.push(h.pieces[i]);}};h.url=h.proto+'://'+h.host+'/'+url.join('/');a.push(h); });a;
@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
@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 / 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: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 / 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: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 / 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 */
.gecko .gform_body input[type='text'] {
height: inherit;
padding: 5px;
}
@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}"