Skip to content

Instantly share code, notes, and snippets.

View asterite's full-sized avatar

Ary Borenszweig asterite

  • NoRedInk
  • Buenos Aires, Argentina
View GitHub Profile
class Object
def self.size
base = Pointer(self).null
(base + 1).address - base.address
end
end
struct Foo
def initialize(@x, @y, @z)
end
class HtmlBuilder
def initialize
@str = StringBuilder.new
end
def build
self.yield
@str.to_s
end
class LinkedList(T)
include Enumerable
class Node(T)
property :next
property :data
def initialize(@data : T, @next = nil)
end
end
@asterite
asterite / ruby_calls.rb
Created January 10, 2014 14:32
Benchmark time lost in Ruby because of calls
$x = 0
def foo1
foo2
end
def foo2
foo3
end

Review Semestral 2013-H2

Nota al Ary del futuro

Poné el conejo y la tortuga

Colores

Colores

class Board
getter rows
getter moves
getter x
getter y
getter previous_board
getter hash
def initialize(@rows, @x, @y, @moves = 0, @previous_board = nil)
@length_y = @rows.length
@asterite
asterite / chinese_checkers.cr
Created September 15, 2013 15:17
Chinese checkers solver written in Crystal
Directions = [:up, :down, :left, :right]
class Board
getter :cells
def initialize
@cells = [
['x', 'x', ' ', 'o', ' ', 'x', 'x'],
['x', 'x', ' ', 'o', ' ', 'x', 'x'],
[' ', ' ', 'o', 'o', 'o', ' ', ' '],
@asterite
asterite / palindromes.cr
Last active December 19, 2015 18:09
Simple resolution in Crystal for the Google Code Jam discussed here: http://blog.clifreeder.com/blog/2013/04/21/ruby-is-too-slow-for-programming-competitions/
class Int64
def palindrome?
num = self
reverse = 0_i64
while num > 0
dig = num % 10
reverse = reverse * 10 + dig
num = num / 10
end
self == reverse

Review Semestral 2013-H1

Nota al Ary del futuro

Poné el conejo y la tortuga

Proyectos

Brium, CDC, CV Maker, Cepheid, De-Bee, Equilibria, Dist, Frutas, GeoChat, Nuntium, Support,

require "strscan"
class Command
end
class Name < Command
attr_reader :name
def initialize(name)
@name = name