Skip to content

Instantly share code, notes, and snippets.

View devth's full-sized avatar
Hacking on @yetibot

Trevor Hartman devth

Hacking on @yetibot
View GitHub Profile
document.location = $('.gallery-holder ul li:nth-child( ' + (parseInt( $('#controls .current')[0].id.replace(/[^0-9]/g, '')) + 1) + ') a').attr('href');
# Select distinct category names that are being used on associated NewsArticle
# model and sort by name.
NewsArticle.all(:joins => :category, :order => 'categories.name',
:select => "DISTINCT(categories.name)")
RewriteEngine on
RewriteCond $1 !^(images|cms|themes|favicon\.ico|robots\.txt|index\.php) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]
// TRENT RICHARDSON
// http://trentrichardson.com/2009/01/08/getting-a-list-of-checkbox-values-with-jquery/
jQuery.fn.getCheckboxVal = function(){
var vals = [];
var i = 0;
this.each(function(){
vals[i++] = jQuery(this).val();
});
return vals;
// http://jsfiddle.net/uhNQX/
var NS = (function(){
var something = "hi";
return {
alert_something : function(){
alert( something );
}
}
}());
require 'active_support/inflector'
puts "so_very_nifty".titleize # => "So Very Nifty"
# ActiveSupport::CoreExtensions::String::Inflections documentation:
# http://rails.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Inflections.html
require 'nokogiri'
# retrive unique values of category in an XML document
# doc is an Nokogiri::XML::Document
# (http://nokogiri.org/Nokogiri/XML/Document.html)
@doc.css('category').to_a.map { |c| c.content }.uniq
# css('category') # get all <category> nodes
# to_a # convert to an array
def articles_list
articles = @items.select { |i| i.path.match(/reading_room\/.+/) unless i.path.nil? }
articles_by_category = {}
# organize by category
articles.each do |article|
articles_by_category[article[:category]] ||= []
articles_by_category[article[:category]].push article
end
$("input.dollars, input.number, input.percentage").blur(function(){
// VALIDATE
var input = $(this);
if (input.val() == "") input.val("0");
if (input.attr("data-min") != undefined && input.attr("data-max") != undefined){
var min = parseInt(input.attr("data-min"));
var max = parseInt(input.attr("data-max"));
var val = parseInt(input.val());
@devth
devth / fade_animation.cs
Created October 18, 2010 17:00
Fade animation in C# / WPF
DoubleAnimation animation = new DoubleAnimation();
animation.To = 0;
//animation.From = 1;
animation.Duration = TimeSpan.FromMilliseconds(ANIMATION_SPEED);
animation.EasingFunction = new QuadraticEase();
Storyboard sb = new Storyboard();
sb.Children.Add(animation);
c.Opacity = 1;