Skip to content

Instantly share code, notes, and snippets.


Sathya Sekaran sfsekaran

View GitHub Profile
sfsekaran / css_colour_validator.rb
Created March 26, 2012 19:22 — forked from attilagyorffy/css_colour_validator.rb
CSS colour validation in Rails 3
View css_colour_validator.rb
# Put this file under Rails.root /lib
class CssColourValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return false unless value
record.errors[attribute] << (options[:message] || 'is not a valid CSS colour') unless ::HexadecimalColourValidator.matches?(value) or ::WebSafeColourValidator.matches?(value)
sfsekaran /
Created February 10, 2012 23:07
Hack for Flash's security policy for cross-domain JSON
package lib
* AS3 Wrapper for jsonp
* Hack around flash's cross-domain security policy for
* loading json on remote servers. ONLY works when flash is in a browser.
* example:
* JSONP.get("",
* "{screen_name:'puppybits', count:'1'}",
sfsekaran / .vimrc.vim
Created April 6, 2011 21:27 — forked from samg/.vimrc.vim
Execute focused specs from vim; Detects bundler.
View .vimrc.vim
" Execute open rspec buffer
" Thanks to Ian Smith-Heisters
function! RunSpec(args)
if exists("b:rails_root")
if filereadable(b:rails_root . "/Gemfile")
let spec = "bundle exec rspec"
elseif filereadable(b:rails_root . "/script/spec")
let spec = b:rails_root . "/script/spec"
let spec = "rspec"