Skip to content

Instantly share code, notes, and snippets.

View dnch's full-sized avatar

Dan Cheail dnch

  • melbourne, au
View GitHub Profile
@dnch
dnch / gist:302344
Created February 12, 2010 05:53
accessing raw paperclip data
def _paperclip_is_csv(field_name)
if attachment_for(field_name).dirty?
begin
FasterCSV.read(attachment_for(field_name).queued_for_write[:original].path)
rescue FasterCSV::MalformedCSVError => e
errors.add_to_base("Please ensure that the #{field_name.to_s.titleize} is a valid CSV file.")
end
end
end
@dnch
dnch / development.log
Created May 17, 2010 13:36
demonstration of SASS bug
[TheOrphanarium] dan:app_name$ tail -f log/development.log
*** In /Users/dan/Code/app_name/config/initializers/haml_and_sass.rb; Testing if we've loaded SASS...
Sass Not Loaded - Configuration likely to be clobbered
*** In /Users/dan/Code/app_name/config/initializers/haml_and_sass.rb; Checking Template Locations and Style options...
[["./public/stylesheets/sass", "./public/stylesheets"], ["/Users/dan/Code/app_name/app/stylesheets", "./public/stylesheets"]]
Sass::Plugin.options[:style] => compressed
grey='\e[0;90m'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$grey%}("
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$grey%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$grey%})"
function pat_prompt {
(( spare_width = ${COLUMNS} ))
prompt=" "
var CallbackObject = {
task_a_done = false,
task_b_done = false,
trigger = function(which_task) {
if(which_task == "A") { this.task_a_done = true; }
if(which_task == "B") { this.task_a_done = true; }
if(this.task_a_done && this.task_b_done) {
trigger_task_c();
}
require 'net/imap'
imap = Net::IMAP.new("imap.gmail.com", { :ssl => true })
imap.login("username", "password")
imap.status("INBOX", ["UNSEEN"])
imap.select("INBOX")
imap.search(["UNSEEN"]) # => message ids
t = imap.fetch(message_id, "RFC822").first.attr["RFC822") # => whole message in RFC822
Mail.new(t)
= form_for @enquiry || Enquiry.new, :remote => true, :builder => Paragon::Builder, :html => { :class => "paragon" } do |f|
%fieldset.horizontal
= f.text_field :name
= f.text_field :company_name
= f.text_field :email_address
= f.text_field :contact_number
= f.text_area :message
ActionView::Helpers::AssetTagHelper.register_javascript_expansion :jquery => case Rails.env
when "production" then ["http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js", "application", "etc"]
when "development" then %w(jquery jquery-ui jquery-typewatch rails application)
end
ZSH_THEME_GIT_PROMPT_PREFIX=""
ZSH_THEME_GIT_PROMPT_SUFFIX=""
ZSH_THEME_GIT_PROMPT_CLEAN=" %F{46}±"
ZSH_THEME_GIT_PROMPT_DIRTY=" %F{196}±"
function codeape_prompt {
# set up the biggest possible middle padding we'd need
(( spare_width = ${COLUMNS} ))
prompt=" "
Feature: Starting the Applcation
In order to avoid reprimands from my boss
As a disobedient little hacker, desperate to flagrantly break IT policy
I want to use Twitter in a stealthy manner
Because ImageMagick likes to remove tarballs, we're downloading their
stable release from their SVN repo instead. But they only serve the
repo over HTTPS, and have an untrusted certificate, so we auto-accept
this certificate for you.
If this bothers you, open a ticket with ImageMagick to fix their cert.