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 Post | |
extend Enumerable | |
def self.files | |
Dir["posts/*.markdown"].sort_by { |file| File.stat(file).ctime }.reverse | |
end | |
def self.each | |
files.each do |entry| | |
File.open(entry) { |file| yield Post.new(file.read) } |
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
- (id)initWithStyle:(id)style | |
{ | |
... | |
} | |
or | |
- (id)initWithStyle:(id)style { | |
... | |
} |
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
source ~/.vim/vimrc | |
set wrap nowrap | |
if has("gui_running") | |
set columns=180 | |
colorscheme railscasts2 | |
if has("gui_mac") || has("gui_macvim") | |
set guifont=Menlo:h12 |
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
set :rails_env, "production" | |
set :passenger_port, 9292 | |
set :passenger_cmd, "#{bundle_cmd} exec passenger" | |
namespace :deploy do | |
task :start, :roles => :app, :except => { :no_release => true } do | |
run "cd #{current_path} && #{passenger_cmd} start -e #{rails_env} -p #{passenger_port} -d" | |
end | |
task :stop, :roles => :app, :except => { :no_release => true } do |
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
#!/bin/sh | |
# runcocoa.sh - Run any Cocoa code from the command line | |
# | |
# Michael Tyson, A Tasty Pixel <[email protected]> | |
# | |
ccflags=""; | |
includes=""; | |
usegdb=; | |
ios=; | |
while [ "${1:0:1}" = "-" ]; do |
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
ISPLAY=:2.0 | |
NAME=Xvfb | |
INSTALL_DIR=/usr/bin | |
DAEMON=$INSTALL_DIR/$NAME | |
DAEMON_ARGS="-ac -screen scrn 1024x768x24 $DISPLAY" | |
PIDFILE=/var/run/$NAME.pid | |
DAEMON_USER=root | |
DAEMON_GROUP=$DAEMON_USER |
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
# encoding: UTF-8 | |
module ApplicationHelper | |
def sharing_on_social_networks(subject) | |
social_networks = {} | |
social_networks[:twitter] = "http://twitter.com/share?text=Estou vendo #{truncate(subject, :length => 60)} na página da Soulfitness. Veja também em&url=http://www.soulfitness.com.br" | |
String.new.html_safe.tap do |output| | |
social_networks.each_pair do |key, value| | |
output << link_to(image_tag(key.to_s + ".png", :width => 21, :height => 21), value, :class => key, :target => "_blank") | |
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
abstract public class Cliente { | |
protected double saldo; | |
public Cliente(float saldo){ | |
this.saldo = saldo; | |
} | |
public void depositar(float valor){ | |
this.saldo = this.saldo + valor; | |
} |
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
# encoding: UTF-8 | |
require "open-uri" | |
class Video < ActiveRecord::Base | |
class YoutubeVideoValidator < ActiveModel::Validator | |
def validate(record) | |
unless record.youtube_code.include? 'youtube.com/watch?v=' | |
record.errors[:base] << "URL não é um endereço válido de um vídeo do youtube" | |
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
scope :page, lambda { |number| | |
per_page = 2 | |
limit(per_page).offset(per_page * ([number.to_i, 1].max - 1)) | |
} do | |
def per(number) | |
limit(number).offset(offset_value / limit_value * number) | |
end | |
def num_pages | |
(except(:offset, :limit).count.to_f / limit_value).ceil |