Posted: October 26th, 2011 | Author: rexchung | Filed under: Rambling | Tags: editor, ruby | No Comments »
Just started using the new slick editor Sublime2.
http://www.sublimetext.com/2
Here’s some key mappings my colleagues added.
https://gist.github.com/1314816
You would want to get this cucumber syntax highlight too.
https://github.com/sagework/cucumber-sublime2-bundle
Here’s link to documentation:
http://www.sublimetext.com/docs/2/
Enjoy
Posted: July 20th, 2011 | Author: rexchung | Filed under: Rambling | Tags: coffeescript, rails3.1 | No Comments »
module ApplicationHelper
def coffee_script(&block)
output = CoffeeScript.compile(capture(&block))
concat content_tag(:script, <<-JAVASCRIPT.html_safe, :type => 'text/javascript', :charset => 'utf-8')
//
#{output}
//]]>
JAVASCRIPT
end
end
Posted: July 19th, 2011 | Author: rexchung | Filed under: Rambling | Tags: gamification | No Comments »
starting a blog on gamification at
http://www.gamification101.com
Posted: July 18th, 2011 | Author: rexchung | Filed under: Rambling | Tags: facebook, heroku, omniauth | No Comments »
https://github.com/intridea/omniauth/wiki/Setting-up-SSL-certificate-locations-in-Linux
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, ‘YOUR_APP_ID’, ‘YOUR_SECRET_KEY’,
{:scope => ‘PERMISSION_1, PERMISSION_2, ETC’, :client_options => {:ssl => {:ca_file => ‘/usr/lib/ssl/certs/ca-certificates.crt’}}}
end
Posted: July 18th, 2011 | Author: rexchung | Filed under: Rambling | Tags: heroku, rails | No Comments »
in your gemfile.
gem ‘rails’, :git => ‘git://github.com/rails/rails.git’, :branch => ’3-1-stable’
gem ‘sprockets’, :git => ‘git://github.com/sstephenson/sprockets.git’
gem ‘therubyracer-heroku’, :group => :production
Posted: July 7th, 2011 | Author: rexchung | Filed under: Rambling | Tags: jquery, rspec, selenium | No Comments »
Note the ‘sleep 1′, didn’t work for me unless I add a wait in between filling in the autocomplete field and mimicking the select.
fill_in(“Client”, :with => @individual.code)
sleep 1
page.execute_script %Q{ $(‘.ui-menu-item a:contains(#{@individual.code})’).first().trigger(“mouseenter”).click(); }
click_on “Save”
Posted: June 27th, 2011 | Author: rexchung | Filed under: Rambling, Ruby, Ruby on Rails | No Comments »
This doesn’t seem to be that well documented.
When you want to do a conditional where clause on a joint table.
You could do this: Model.where().includes(:model_b).where(“model_b_table.attribute = ?”, ‘foo’)
Better way is: Model.where().includes(:model_b).where(:model_b => {:attribute => ‘foo’) )
The end…
Posted: June 21st, 2011 | Author: rexchung | Filed under: Ruby, Ruby on Rails | Tags: factory_girl | No Comments »
Factory_girl is different to fixtures. There’s no way to define 2 user belonging to the same school. Creating one instance of school, we call it as a singleton method. Here’s a drop in monkey patch that stores the instance in a class variable.
Posted: May 4th, 2011 | Author: rexchung | Filed under: Rambling | Tags: rails3 coffeescript | No Comments »
Since Rails 3.1 will have coffee-script as default. For those eager to try it can easily do so with ‘barista’ gem.
Simply head to: https://github.com/Sutto/barista
Textmate bundles:
https://github.com/yikulju/CoffeeScript-Syntax-Checker-Textmate-Bundle
https://github.com/jashkenas/coffee-script-tmbundle
Posted: January 21st, 2011 | Author: goodwill | Filed under: Ruby, Ruby on Rails | Tags: nokogiri, ruby, ruby on rails, xml | No Comments »
I am in a project where there is a huge XML file I need to use SAX parser and unfortunately, to further complicate this matter, we encountered this bug:
(Nokogiri::XML::SyntaxError) "xmlParseCharRef: invalid xmlChar value 25"
Turns out that is caused by  in the document.
So at first I did something pinpoint to this problem before I submit the string to push parser:
data.gsub('', ''')
As this kind of an apostrophe in the text.
Turns out, I got another one later:
(Nokogiri::XML::SyntaxError) "xmlParseCharRef: invalid xmlChar value 29"
With some more googling, I realize anything below character x20 is invalid, then I see a funny post:
Removing Invalid XML Character
Works, but not elegant, especially when you know there is something called regular expression in the world.
This is the easiest:
data.gsub(/&#x[0-1]?[0-9a-eA-E];/, ' ')
Of course for character like  when you want something actually a character replace that, you would definitely need to do your own replace first before you do this sweeping.