Skip to content

Instantly share code, notes, and snippets.

@tcaddy
tcaddy / rename_for_car
Created April 10, 2015 01:52
Rename mp3 files for my Toyota radio to maintain song order. Copy this file to folder of mp3 files for an album and run it.
#!/usr/bin/env ruby
# coding: utf-8
require 'rubygems'
require "mp3info"
dir = File.expand_path(File.dirname(__FILE__))
Dir["#{dir}/*mp3"].each do |filename|
Mp3Info.open(filename) do |mp3|
disk_num = mp3.tag2["disc_number"]
CoffeeScript
ColdFusion
Cucumber
HTML-CSS-JS Prettify
Javascript Beautify
JSONLint
Package Control
PowerShell
Pretty JSON
RocketUniData
@tcaddy
tcaddy / hpu-sharepoint.css
Last active August 29, 2015 14:27
This is a place to hold some custom javascript and css code for HPU's implementation of the Ellucian Sharepoint Portal
/* Hide all like links on IT pages */
form[action^='/admin-services/it'] [id^='likesElement-'],
form[action^='/administrative-services/information-technology'] [id^='likesElement-'], {
display: none;
}
/* Hide all 'Email a link' links on IT pages */
form[action^='/admin-services/it'] li[id*='share'] a[title='Email a link'],
form[action^='/administrative-services/information-technology'] li[id*='share'] a[title='Email a link'] {
display: none;
}
@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');