Skip to content

Instantly share code, notes, and snippets.

View dimiro1's full-sized avatar

Claudemiro A F Neto dimiro1

  • Berlin, Germany
View GitHub Profile
@dimiro1
dimiro1 / main.rb
Created May 25, 2015 23:56
Permutations Ruby
[2,3,5,6,7,9].permutation(3).map {|e| e.join.to_i % 5 == 0 }.count { |i| i == true }
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 ..."
# -*- coding: utf-8 -*-
class Stack < Array
end
class Calculator
def initialize
@stack = Stack.new
end
def eval(expr)
/***************************************************************************
* Pequena implementação da calculadora "dc" do GNU/Linux *
* Copyright (C) 2009 by Claudemiro Alves Feitosa Neto *
* dimiro1@gmail.com *
* *
* 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. *
* *
/***************************************************************************
* 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 *
* dimiro1@gmail.com *
* 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 *
#!/usr/bin/env ruby
class Person
def initialize(name)
@name = name
end
def name
@name
end
def hello
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)
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 },
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