This file contains 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 CalendarHelper | |
def calendar(date = Date.today,options={}, &block) | |
Calendar.new(self, date,options, block).table | |
end | |
class Calendar < Struct.new(:view, :date,:options, :callback) | |
HEADER = %w[SUN MON TUES WED THU FRI SAT] | |
START_DAY = :sunday | |
delegate :content_tag, to: :view |
This file contains 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
function git.branch { | |
br=`git branch | grep "*"` | |
echo ${br/* /} | |
} | |
function git.pull { | |
branch=`git.branch` | |
op=`git pull origin $branch` | |
} | |
function git.push { |
This file contains 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
# Path to your oh-my-zsh configuration. | |
ZSH=$HOME/.oh-my-zsh | |
# Set name of the theme to load. | |
# Look in ~/.oh-my-zsh/themes/ | |
# Optionally, if you set this to "random", it'll load a random theme each | |
# time that oh-my-zsh is loaded. | |
ZSH_THEME="itg" | |
# Example aliases |
This file contains 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
f you installed postresql on your server then just host: localhost to database.yml, I usually throw it in around where it says pool: 5. Otherwise if it's not localhost definitely tell that app where to find its database. | |
development: | |
adapter: postgresql | |
encoding: unicode | |
database: kickrstack_development | |
host: localhost | |
pool: 5 | |
username: kickrstack | |
password: secret |
This file contains 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
result = client.execute(:api_method => api_method, :parameters => { | |
'ids' => "ga:7174565581", | |
'start-date' => Date.new(1970,1,1).to_s, | |
'end-date' => Date.today.to_s, | |
'dimensions' => 'ga:pagePath', | |
'metrics' => 'ga:pageviews', | |
'filters' => 'ga:pagePath==/url/to/user' | |
}) | |
This file contains 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
Add these lines into ~/.gitconfig file. | |
--------------------------------------------------------------------- | |
[alias] | |
st = status | |
ft = fetch | |
ci = commit | |
cm = commit -m | |
br = branch |
This file contains 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
/* | |
Add following in /home/usernam/.config/sublime-text-3/Packages/User/RubyTest.sublime-settings | |
If file not present then create one | |
in case you get errors like this | |
ruby:1: Invalid char `\x7F' in expression | |
ruby:1: Invalid char `\x01' in expression | |
ruby:1: Invalid char `\x01' in expression | |
ruby:1: Invalid char `\x01' in expression | |
ruby:1:in `<main>': uninitialized constant ELF (NameError) |
This file contains 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 ApplicationController < ActionController::Base | |
... | |
#Problem: | |
#In rails 3.0.1+ it is no longer possible to do this anymore; | |
# rescue_from ActionController::RoutingError, :with => :render_not_found | |
# | |
#The ActionController::RoutingError thrown is not caught by rescue_from. | |
#The alternative is to to set a catch-all route to catch all unmatched routes and send them to a method which renders an error | |
#As in http://techoctave.com/c7/posts/36-rails-3-0-rescue-from-routing-error-solution |
This file contains 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
process :get_geometry | |
def geometry | |
@geometry | |
end | |
def get_geometry | |
if (@file) | |
img = ::Magick::Image::read(@file.file).first | |
@geometry = [ img.columns, img.rows ] | |
end |
This file contains 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
# spec/factories/my_files.rb | |
FactoryGirl.define do | |
factory :my_file do | |
photo Rack::Test::UploadedFile.new(File.open(File.join(Rails.root, '/spec/fixtures/myfiles/myfile.jpg'))) | |
end | |
end |
OlderNewer