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
# Usage: | |
# | |
# image1 = ChunkyPNG::Image.from_file('vase.png') | |
# image1.colorfy!(:color => "ff0000") | |
# image1.save 'changed_red.png' | |
# | |
# image2 = ChunkyPNG::Image.from_file('vase.png') | |
# image2.colorfy!(:color => "ff0000", :solid => true) | |
# image2.save 'only_red.png' | |
# |
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
# atm its so for my class | |
class ApplicationController < ActionController::Base | |
extend ActiveSupport::Concern | |
protect_from_forgery | |
#enable_authorization | |
respond_to :html, :xml, :json | |
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
# example | |
class A | |
def a | |
puts "a" | |
end | |
def b | |
puts "b" | |
end | |
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
# what should I do, that a() would run in context of class A, not give "block in <main>': undefined method `a' for main:Object (NoMethodError)" | |
class A | |
def a | |
puts "a" | |
end | |
end | |
class B |
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
def digest array | |
Digest::MD5.hexdigest array.to_s | |
end | |
def write file, array | |
File.open(file, 'w') { |f| f.write array.sort.to_json } | |
end | |
def read file |
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
# Timeline is a Line that has beginning and the end, it contains many Frames with beginning and end. | |
module Timeline | |
# Range has the beginning, end and length. | |
class Range | |
attr_accessor :from, :length | |
attr_reader :to | |
def initialize from, length |
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 LuhnNumber | |
attr_accessor :full_number | |
def initialize(full_number) | |
self.full_number = full_number | |
end | |
def full_number=(full_number) | |
@full_number = full_number.gsub(/[^0-9]/, '').to_s |
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 Class | |
def instance_advices(include_super=true) | |
throw :never_thrown | |
end | |
end | |
class Test1 | |
end | |
class Test3 < Test1 |
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 Tableless | |
extend ActiveModel::Naming | |
extend ActiveModel::Translation | |
include ActiveModel::Validations | |
include ActiveModel::Conversion | |
include ActiveModel::MassAssignmentSecurity | |
def initialize(params={}) | |
if params | |
sanitized_params = sanitize_for_mass_assignment(params) |
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
public class Answer { | |
public static void main (String[] argum) { | |
Answer answer = new Answer(); | |
} | |
class Linked { | |
public int value; | |
public Linked parent; |
OlderNewer