Skip to content

Instantly share code, notes, and snippets.

View bernEsp's full-sized avatar

Bernardo Espinoza bernEsp

View GitHub Profile
Que es code smell?
son todos los síntomas que podemos encontrar en el código fuente de un sistema que indican que muy probablemente existan problemas más profundos de calidad de código, de diseño o de ambos
Metodos largos, clases largas o duplicar codigo son algunos code smell
Long Method?
def parse(arg, argv, &error)
if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
return nil, block, nil # +1
end
http://yuml.me/diagram/scruffy/class/# Cool UML Diagram, [Cat]^-[Animal], [Bird]^-[Animal], [Bird]++->[SoldierAnimal], [Animal] ++->1[movement], [movement]++->1[MovementType], [MovementType]++->1[Motile], [MovementType]++->1[Sessility], [Motile]++->1[chemotaxis], [Motile]++->1[thermotaxis], [Motile]++->1[phototaxis], [Motile]++->1[magnetotaxis], [Motile]++->1[galvanotaxis], [Motile]++->1[gravitaxis], [Motile]++->1[durotaxis], [Motile]++->1[haptotaxis], [Motile]++->1[biopolymers], [gravitaxis]++->[Type], [Type]++->1[Air], [Type]++->1[Terrestrial], [Type]++->1[water].
@bernEsp
bernEsp / dabblet.css
Created March 28, 2012 17:25
CSS3 No-image Chupa-Chupsy candy
/**
* CSS3 No-image Chupa-Chupsy candy
* by @girlie_mac
* http://girliemac.com/blog/2012/03/24/making-chupa-chups-using-css3-pseudo-elements/
*
* Please, do not compare this with the real one.
* I feel pretty terrible making the awesome design by Salvador Dalí into some crap.
* But my point of this demo is that you can create the floral shape with CSS, using border-radius:50% and pseudo-element(s)
*/
html {
@bernEsp
bernEsp / dabblet.css
Created March 28, 2012 17:31
landing mockup
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
.texture-layer {
background: url("texture-chunk-layer.png") repeat scroll 0 0 transparent;
@bernEsp
bernEsp / dabblet.css
Created March 29, 2012 03:16
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
.texture-layer {
background: url("texture-chunk-layer.png") repeat scroll 0 0 transparent;
@bernEsp
bernEsp / default_avatar.txt
Created August 9, 2012 18:25
Citivox default avatar
/9j/4QBqRXhpZgAATU0AKgAAAAgAAgExAAIAAAAGAAAAJodpAAQAAAABAAAALAAAAABTa2l0Y2gA
BJAAAAcAAAAEMDIxMKABAAMAAAABAAEAAaACAAQAAAABAAAAKKADAAQAAAABAAAAKAAAAAD/4AAQ
SkZJRgABAQAAAQABAAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdCIFhZWiAH
zgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAAAA9tYAAQAAAADTLUhQ
ICAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABFjcHJ0AAAB
UAAAADNkZXNjAAABhAAAAGx3dHB0AAAB8AAAABRia3B0AAACBAAAABRyWFlaAAACGAAAABRnWFla
AAACLAAAABRiWFlaAAACQAAAABRkbW5kAAACVAAAAHBkbWRkAAACxAAAAIh2dWVkAAADTAAAAIZ2
aWV3AAAD1AAAACRsdW1pAAAD+AAAABRtZWFzAAAEDAAAACR0ZWNoAAAEMAAAAAxyVFJDAAAEPAAA
CAxnVFJDAAAEPAAACAxiVFJDAAAEPAAACAx0ZXh0AAAAAENvcHlyaWdodCAoYykgMTk5OCBIZXds
ZXR0LVBhY2thcmQgQ29tcGFueQAAZGVzYwAAAAAAAAASc1JHQiBJRUM2MTk2Ni0yLjEAAAAAAAAA
@bernEsp
bernEsp / linkedlist vs array benchmark
Last active December 18, 2015 18:59
Adding value to the top of array and to the top of linked list benchmarking
Node = Struct.new(:value, :next)
list = Node.new("first", nil)
#create linked list
def linked_list(value, next_node)
Node.new(value, next_node)
end
def unlinked_list(node_value, list)
@bernEsp
bernEsp / Maximum continuous subarray
Created June 22, 2013 22:37
In computer science, the maximum subarray problem is the task of finding the contiguous subarray within a one-dimensional array of numbers (containing at least one positive number) which has the largest sum. For example, for the sequence of values −2, 1, −3, 4, −1, 2, 1, −5, 4; the contiguous subarray with the largest sum is 4, −1, 2, 1, with su…
#max sub array sum return sum and sub array kadane's algorithm
def max_subarray(collection)
temp_sum = 0
max_sum = 0
check_sum = 0
begin_point = 0
end_point = collection.length - 1
max_subarray = []
collection.each_with_index do |element, index|
numbers = 100000.times.map { Random.rand(2000) }
t = Time.now
yield
ruby_sort = numbers.sort
p "it tooks #{t-Time.now}s"
#[5, -3, 3, 20, -50, 1, -1, 2]
def bubblesort( collection )
t = Time.now
@bernEsp
bernEsp / Design patterns
Created June 25, 2013 08:43
Separate out things changed from those that stay same. Use template pattern. created and abstract class with hooks methods and with methods to be override *required methods. Delegate, delegate, delegate. Use strategy pattern. Delete functionality and refactor using the power of Ruby Proc to dinamically pass code to objects.
class Animal #abstract class template pattern base on separete out the things changed from those that stay same
def initialize(&kind)
@kind = kind
end
#template patter
def live
eat
make_poop