Skip to content

Instantly share code, notes, and snippets.

View technicalpickles's full-sized avatar

Josh Nichols technicalpickles

View GitHub Profile
<%@ taglib prefix="stripes" uri="http://stripes.sourceforge.net/stripes.tld"%>
<%@ page import="edu.mit.broad.cbip.web.CbipJspConstants" %>
<%@page import="edu.mit.broad.cbip.web.compound.management.CreateMotherTubesFromMasterTubesActionBean"%>
<stripes:layout-render name="<%= CbipJspConstants.BASIC_LAYOUT_JSP %>">
<stripes:layout-component name="title">
</stripes:layout-component>
<stripes:layout-component name="contents">
<stripes:form beanclass="<%= CreateMotherTubesFromMasterTubesActionBean.class %>" >
unless logged_in?
unless params[:captcha] && Digest::SHA1.hexdigest(params[:captcha].upcase.chomp)[0..5] == params[:captcha_guide]
@item.errors.add("Word")
render :action => 'new'
return
end
end
def exact_distance_of_time_in_words(from_time, to_time = 0, include_seconds = false)
from_time = from_time.to_time if from_time.respond_to?(:to_time)
to_time = to_time.to_time if to_time.respond_to?(:to_time)
distance_in_seconds = ((to_time - from_time).abs).round
distance_in_minutes = (distance_in_seconds / 60).round
distance_in_hours = (distance_in_minutes / 60).round
@technicalpickles
technicalpickles / create_svn_authorsfile.sh
Created August 24, 2008 18:44
Script for generating a svn.authorsfile from subversion history
#!/usr/bin/env bash
authors=$(svn log -q | grep -e '^r' | awk 'BEGIN { FS = "|" } ; { print $2 }' | sort | uniq)
for author in ${authors}; do
echo "${author} = NAME <USER@DOMAIN>";
done
module AttachmentFuMacros
def should_have_attachment()
klass = model_class
should "define AttachmentFu class methods" do
# breakpoint
class_modules = (class << klass; included_modules; end)
assert class_modules.include?(Technoweenie::AttachmentFu::ClassMethods),
"#{klass} doesn't define AttachmentFu class methods"
@technicalpickles
technicalpickles / attachment_fu_shoulda_macros.rb
Created September 3, 2008 21:50
Shoulda macros for attacfhment_fu. Place in test/shoulda_macros
module AttachmentFuMacros
def should_have_attachment(options = {})
klass = model_class
should_have_db_columns :size, :content_type, :filename
if options[:content_type] == :image
should_have_db_columns :height, :width
end
should "define AttachmentFu class methods" do
module Clearance
module Model
def included(base)
base.class_eval do
attr_accessible :email, :password, :password_confirmation
attr_accessor :password, :password_confirmation
validates_presence_of :email
module Clearance
module UnitTest
def self.included(base)
base.class_eval do
should_require_attributes :email, :password
should_require_unique_attributes :email
should "require password validation on create" do
user = User.new(:password => "blah", :password_confirmation => "boogidy")
Josh:
My name is <snip> and I am a Tech Recruiter in NYC. I came across your blog on Google and laughed out loud when I saw the following –
* "If you were to record him playing hacky sack, and then edit out the hacky sack, he would have some sick dance moves."
Hahahahahaha. Sorry Josh, but I am going to make that part of my repertoire and totally not give you credit!
<snip>
Sr. Account Manager
(rdb:1) @time = Time.utc(2000, "jan", 1, 20, 15, 1)
Sat Jan 01 20:15:01 UTC 2000
(rdb:1) @note.created_at = @time
Sat Jan 01 20:15:01 UTC 2000
(rdb:1) p @time
Sat Jan 01 20:15:01 UTC 2000
(rdb:1) p @note.created_at
Sat, 01 Jan 2000 15:15:01 EST -05:00