This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#========================================================================== | |
# Git aliases | |
#========================================================================== | |
alias g='git' | |
alias gb='git branch' | |
alias gba='git branch -a' | |
alias gstat='git status' | |
alias gc='git commit -v' | |
alias gca='git commit -v -a' | |
alias gd='git diff | mate' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⨀_⨀ | |
⨂_⨂ | |
(/◔ ◡ ◔)/ | |
°ﺑ° | |
(¬_¬) | |
(´・ω・`) | |
(ʘ_ʘ) | |
(ʘ‿ʘ) | |
(๏̯͡๏ ) | |
(◕_◕) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# | |
# This is a python script. You need a Python interpreter to run it. | |
# For example, ActiveState Python, which exists for windows. | |
# | |
# This script strips the penultimate record from a Mobipocket file. | |
# This is useful because the current KindleGen add a compressed copy | |
# of the source files used in this record, making the ebook produced | |
# about twice as big as it needs to be. | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias utc_timestamp='date -u "+%Y%m%d%H%M%S"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before_update :update_ranking | |
def self.calculate_ranking(score, created_at) | |
order = Math.log10(([score.abs,1].max)) | |
if score > 0 | |
sign = 1 | |
elsif score < 0 | |
sign = -1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module GoogleAnalyticsHelper | |
def google_analytics_for(account, domain) | |
unless account.blank? | |
<<-ANALYTICS | |
<script type="text/javascript"> | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', '#{account}']); | |
_gaq.push(['_setDomainName', '#{domain}']); | |
_gaq.push(['_trackPageview']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def destroy_data | |
puts "== Data: Destroying all data ".ljust(79, "=") | |
sql = ActiveRecord::Base.connection() | |
sql.execute "SET autocommit=0" | |
sql.begin_db_transaction | |
if sql.adapter_name == "MySQL" | |
sql.execute("/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */") | |
sql.execute("/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tip(msg); puts; puts msg; puts "-"*100; end | |
# | |
# 30 Ruby 1.9 Tips, Tricks & Features: | |
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/ | |
# | |
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
tip "Ruby 1.9 supports named captures in regular expressions!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DashboardController < ApplicationController | |
before_filter :require_user | |
def index | |
@feed_items = FeedItem.followed_by(current_user.id). | |
includes(:post).paginate(:page => params[:page]) | |
@page_title = "#{APP_CONFIG['site_name']} | Dashboard" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://news.ycombinator.com/item?id=1571894 | |
# A quick tips when creating block DSLs in Ruby: | |
def search(&blk) | |
if blk.arity == 1 | |
blk.call(self) | |
else | |
self.instance_eval(&blk) | |
end | |
end |