Skip to content

Instantly share code, notes, and snippets.

View danielvlopes's full-sized avatar

Daniel Lopes danielvlopes

View GitHub Profile
<?php
function include_my_javascripts() {
if (is_page('video')) {
wp_enqueue_script('video.js')
} else (if is_page('contato')) {
wp_enqueue_script('validation.js')
}
}
# Import your 'Today' list from Things into PomoDo;
require 'rubygems'
begin
require 'appscript'
rescue LoadError
puts "You need to install the rb-appscript gem"
exit
end
@danielvlopes
danielvlopes / gist:301158
Created February 11, 2010 02:56 — forked from dhh/gist:29752
config.action_controller.asset_host = Proc.new do |source, request|
non_ssl_host = "http://asset#{source.hash % 4}.backpackit.com"
ssl_host = "https://asset1.backpackit.com"
if request.ssl?
case
when source =~ /\.js$/
ssl_host
when request.headers["USER_AGENT"] =~ /(Safari)/
non_ssl_host
# = YERB
#
# Who needs HAML when you have YAML + ERB? :)
#
# See example.yaml below for an example. You can run this code
# by cloning this gist and then `ruby _yerb.rb example.yaml`.
#
# Notice that you need Ruby 1.9 so the hash order is preserved.
# Obviously, this is just for fun. Definitely slow as hell.
#
require 'database_cleaner'
DatabaseCleaner.strategy = :truncation
Spec::Runner.configure do |config|
config.use_transactional_fixtures = false
config.before(:each) do
DatabaseCleaner.start
end
We couldn’t find that file to show.
This is an example of using RVM's Project .rvmrc file
to have it automatically bootstrap your environment, including bundler.
This could be further expanded to do anything you require :)
The important thing to remember is that the purpose of these files is
to allow you to very easily have your 'project context' (aka 'environment')
loaded automatically for you when you enter the project in the shell (cd).
You can generate the .rvmrc file below by running:
require 'action_controller/test_process'
# Paperclip attachments in factories, made easy based on technicalpickles
Factory.class_eval do
def attach(name, path, content_type = nil)
if content_type
add_attribute name, ActionController::TestUploadedFile.new("#{RAILS_ROOT}/#{path}", content_type)
else
add_attribute name, ActionController::TestUploadedFile.new("#{RAILS_ROOT}/#{path}")
end
require 'action_controller/test_process'
# Paperclip attachments in factories, made easy based on technicalpickles
Factory.class_eval do
def attach(name, path, content_type = nil)
if content_type
add_attribute name, ActionController::TestUploadedFile.new("#{RAILS_ROOT}/#{path}", content_type)
else
add_attribute name, ActionController::TestUploadedFile.new("#{RAILS_ROOT}/#{path}")
end
$(".grid input:checked").each(function(e){
var isPending = $(this).parents("tr:first").hasClass("pending");
var value = currencyToFloat( tr.children(".value").html() );
if (isDebit(value)) {
adjustDebit(value);
} else if (isCredit(value)) {
adjustCredit(value);
}
});