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 cut_string(text, length, ending) | |
text[0...length].strip + ending | |
end | |
# forma de uso | |
texto = "meu texto Γ© muito comprido, por isso eu preciso de um metodo que minimize ele" | |
cut_string(texto, 10, "...") # "meu texto ..." |
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
# -*- coding: utf-8 -*- | |
class Stack < Array | |
end | |
class Calculator | |
def initialize | |
@stack = Stack.new | |
end | |
def eval(expr) |
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
/*************************************************************************** | |
* Pequena implementaΓ§Γ£o da calculadora "dc" do GNU/Linux * | |
* Copyright (C) 2009 by Claudemiro Alves Feitosa Neto * | |
* [email protected] * | |
* * | |
* This program is free software: you can redistribute it and/or modify * | |
* it under the terms of the GNU General Public License as published by * | |
* the Free Software Foundation, either version 3 of the License, or * | |
* (at your option) any later version. * | |
* * |
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
/*************************************************************************** | |
* Pequena implementaΓ§Γ£o da calculadora "dc" do GNU/Linux * | |
* NΓ£o Γ© uma implementaΓ§Γ£o para calculos de alta precisΓ£o * | |
* Copyright (C) 2009 by Claudemiro Alves Feitosa Neto * | |
* [email protected] * | |
* Modified: <2009-05-21 20:58:52 BRT> * | |
* * | |
* This program is free software: you can redistribute it and/or modify * | |
* it under the terms of the GNU General Public License as published by * | |
* the Free Software Foundation, either version 3 of the License, or * |
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/env ruby |
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 Person | |
def initialize(name) | |
@name = name | |
end | |
def name | |
@name | |
end | |
def hello |
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 Paperclip | |
class Watermark < Processor | |
class InstanceNotGiven < ArgumentError; end | |
def initialize(file, options = {},attachment = nil) | |
super | |
puts attachment.to_yaml | |
@file = file | |
@current_format = File.extname(@file.path) |
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 Photo < ActiveRecord::Base | |
belongs_to :album | |
named_scope :covers, :conditions => {:cover => true} | |
has_attached_file :image, | |
:storage => :s3, | |
:s3_credentials => "#{RAILS_ROOT}/config/amazon_s3.yml", | |
:path => ":attachment/:id/:style/:basename.:extension", | |
:styles => { | |
:original => {:geometry => "500x375>", :processors => [:thumbnail, :watermark], :quality => :better }, |
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 ErbEngine < Haml::Engine | |
def push_script(text, preserve_script, in_tag = false, preserve_tag = false, | |
escape_html = false, nuke_inner_whitespace = false) | |
push_text "<%= #{text.strip} %>" | |
end | |
def push_silent(text, can_suppress = false) | |
push_text "<% #{text.strip} %>" | |
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
<?php | |
// Based on http://codeigniter.com/forums/viewthread/57902/#284919 | |
/** | |
* Yield | |
* | |
* Adds layout support :: Similar to RoR <%= yield => | |
* | |
* Just output the variable $yield in your layout file which should | |
* be located in application/views/layouts/ |
OlderNewer