Skip to content

Instantly share code, notes, and snippets.

Sathya Sekaran sfsekaran

View GitHub Profile
@sfsekaran
sfsekaran / pull-request-checklist.txt
Last active Aug 24, 2018
A Pull Request Checklist. Don't forget the basics!
View pull-request-checklist.txt
Pull Request Checklist
- [ ] Does not require additional reviewers: specialized expertise
- [ ] Check for logic errors
- [ ] Check for missing, broken, wrong tests
- [ ] Check if looked for missing indexes
- [ ] Check for database transactional consistency issues
- [ ] Check all log levels are correct
- [ ] Check level of log detail
- [ ] Check code organization
@sfsekaran
sfsekaran / conftest.py
Last active Aug 17, 2017
Per-Test Database Cleaner (Flask-SQLAlchemy + PyTest)
View conftest.py
@pytest.fixture(autouse=True)
def database_cleaner():
db.session.begin()
yield
db.session.rollback()
@sfsekaran
sfsekaran / css_colour_validator.rb
Created Mar 26, 2012 — 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)
end
end
@sfsekaran
sfsekaran / JSONP.as
Created Feb 10, 2012
Hack for Flash's security policy for cross-domain JSON
View JSONP.as
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("http://api.twitter.com/statuses/user_timeline.json",
* "{screen_name:'puppybits', count:'1'}",
@sfsekaran
sfsekaran / definite_article_helper.rb
Created Jul 29, 2011
Cucumber Definite Article Helper
View definite_article_helper.rb
module DefiniteArticleHelper
def the
@the ||= DefiniteArticle.new
end
def push_context
@the_contexts ||= []
@the_contexts.push(the.clone)
@the = nil
end
View gist:1114648
Scenario: User sees merchandise in the same order as the admin entered it
Given there is an artist
And the artist has a merchandise product
And the product has the following attributes:
| name |
| L |
| XL |
When I am on the product's page
Then I should see the attributes in the following order:
| name |
@sfsekaran
sfsekaran / .vimrc.vim
Created Apr 6, 2011 — 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"
else
let spec = "rspec"
View gist:590067
#default label => keyword sets
@campaign_keywords_label = Hash.new
@campaign.campaign_keywords_labels.each do |kcl|
@campaign_keywords_label[kcl.label_id] = kcl.keyword.value
end
You can’t perform that action at this time.