Skip to content

Instantly share code, notes, and snippets.

View kirkconnell's full-sized avatar

Carlos Kirkconnell kirkconnell

  • Google
  • Mountain View, CA
View GitHub Profile
# Helps you migrate from attachment_fu
# put it in your /lib dir and include it your xxxx_uploader.rb
module UploaderFu
def partition_dir
("%08d" % model.id).scan(/\d{4}/).join("/")
end
def model_dir
"#{model.class.to_s.underscore}/#{mounted_as}/"
@kirkconnell
kirkconnell / Japanese style
Created December 6, 2011 22:25 — forked from endolith/Has weird right-to-left characters.txt
Unicode smileys emoticons
⨀_⨀
⨂_⨂
(/◔ ◡ ◔)/
°ﺑ°
(¬_¬)
(´・ω・`)
(ʘ_ʘ)
(ʘ‿ʘ)
(๏̯͡๏ )
(◕_◕)
namespace :locations do
desc 'Update the population field of all city locations with the help of a csv file'
task :populate_cities, :pop_file, :no_match_file, :needs => :environment do | t , args |
raise "Please send a valid CSV File, example: rake locations:populate_cities[pathCVSFile,noMatchFilePath*]" if args[:pop_file].nil?
csv_file = args[:pop_file]
unmatch_file = args[:no_match_file] || "no_match_location.csv"
namespace :pinow do
desc 'Update the population field of all city locations with the help of a csv file'
task :populate_cities => :environment do
require 'fastercsv'
#constants
CODE = 0
NAME = 5
STATE_NAME = 6
#return an array of arrays for the act event logger track changes in content_ui fields
# [ profile content real name, "displayed field name: displayed field value"]
def content_x_log_array
content_ui_log_instructions = (1..20).map {|n| ["content_#{n}", lambda{|value| "#{get_display_name(n)} : #{value}" }}
end
def get_display_name(n)
if template_group.present? && ci = template_group.content_uis.find{|ci| c.generic_field_number == n}
ci.field_name.titleize.gsub(/\s+/, '').underscore.to_sym
end
@kirkconnell
kirkconnell / conten_ui_log.rb
Created April 29, 2011 23:55
Get content_ui for log
#return an array of arrays for the act event logger track changes in content_ui fields
# [ profile content real name, "displayed field name: displayed field value"]
def content_x_log_array
content_ui_log_instructions = (1..20).map {|n| ["content_#{n}", lambda{|value| "#{get_display_name(n)} : #{value}" }}
end
def get_display_name(n)
if template_group.present? && ci = template_group.content_uis.find_by_generic_field_number(n)
ci.field_name.titleize.gsub(/\s+/, '').underscore.to_sym
end