Skip to content

Instantly share code, notes, and snippets.

View whitered's full-sized avatar

Dmitry Zhelnin whitered

View GitHub Profile
@whitered
whitered / gist:974196
Created May 16, 2011 10:16
RBP ignore
def update
@membership = Membership.find(params[:id]) # this line sits in before_filter
raise ActiveRecord::RecordNotFound unless @membership.group_owner == current_user # ignore_rbp
is_admin = params[:membership] && params[:membership][:is_admin]
@membership.update_attribute(:is_admin, is_admin) unless is_admin.nil?
redirect_to @membership.group
end
# RBP advices to use scope access on the second line of the method, but it's impossible in my model,
# so I've added the comment that makes RBP ignore that error
@whitered
whitered / .vimrc
Created February 21, 2011 14:54
My vimrc for Ruby on Rails development
call pathogen#runtime_append_all_bundles()
" language messages en
set encoding=utf-8
if has('win32')
set guifont=Monaco:h10:cRUSSIAN
else
set guifont=Monaco\ 11
end
" base for vimrc file taken from http://biodegradablegeek.com/2007/12/using-vim-as-a-complete-ruby-on-rails-ide/
@whitered
whitered / lucky commit
Created August 6, 2010 13:03
Lucky commit git post-commit hook. Checks your last commit SHA number if it is lucky one (the sum of first 20 digits equals to the sum of last 20 ones).
#!/bin/sh
left_sum=$((`git log -1 --format=format:%H | cut -c -20 | sed -e 's/[a-f0-9]/\+0x&/g'`))
right_sum=$((`git log -1 --format=format:%H | cut -c 21- | sed -e 's/[a-f0-9]/\+0x&/g'`))
if [ $left_sum = $right_sum ]; then
echo '****************************************'
echo '* Congratulations! Lucky commit!!! *'
echo '****************************************'
fi
<?xml version="1.0" encoding="utf-8"?>
<project default="fixcrlf" basedir=".">
<target name="fixcrlf" description="Fix CRLF">
<fixcrlf srcdir="${basedir}" includes="**/*.as **/*.xml **/*.properties **/*.pbk" eol="lf" eof="remove" encoding="utf8"/>
</target>
</project>
@whitered
whitered / AS3 Performance test template
Created January 29, 2010 11:07
simple performance test template
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
[SWF(width="800",height="600",frameRate="120",backgroundColor="#ffffff")]
public class PerformanceTest extends Sprite
{
private static const LIMIT:int = 10000;