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 get_major_middle_min *numbers | |
(0..numbers.count-2).each |i| {numbers[i] > numbers[i+1] ? p i : } ... | |
# TODO | |
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
#Valida soluciones de sudoku con la forma | |
validSolution([[5, 3, 4, 6, 7, 8, 9, 1, 2], | |
[6, 7, 2, 1, 9, 5, 3, 4, 8], | |
[1, 9, 8, 3, 4, 2, 5, 6, 7], | |
[8, 5, 9, 7, 6, 1, 4, 2, 3], | |
[4, 2, 6, 8, 5, 3, 7, 9, 1], | |
[7, 1, 3, 9, 2, 4, 8, 5, 6], | |
[9, 6, 1, 5, 3, 7, 2, 8, 4], | |
[2, 8, 7, 4, 1, 9, 6, 3, 5], |
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 MovieReviewsApp | |
attr_accessor :tweet | |
@tweet = Hash.new() | |
def self.call(*args) | |
args.map{|a| JSON.parse(a).map{|i| append(i['title'], i)}} | |
return build_tweet(@tweet) | |
end | |
def self.append(title, hash) |
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
codigo = " p 'hello world' " | |
pp Ripper.lex(codigo) # Paso 1, Tokenizacion | |
# [[[1, 0], :on_sp, " "], | |
# [[1, 1], :on_ident, "p"], | |
# [[1, 2], :on_sp, " "], | |
# [[1, 3], :on_tstring_beg, "'"], | |
# [[1, 4], :on_tstring_content, "hello world"], | |
# [[1, 15], :on_tstring_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
namespace :deploy do | |
task :start do ; end | |
task :stop do ; end | |
task :symlink_shared do | |
run "ln -nfs #{shared_path}/shared/public/ #{release_path}/public/"" | |
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
class Preference | |
# Not allow dynamic attributes | |
not_allow_dinamic_attributes | |
has_rest_method create: '/checkout/preferences' | |
has_rest_method read: '/checkout/preferences/:id' | |
has_rest_method update: '/checkout/preferences/:id' | |
# Setting the relations between objects |
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
# The Java Driven Developer | |
class Person | |
@name = "" | |
def get_name | |
return @name | |
end | |
def set_name | |
return @name |
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
Fastest is for_caching#test |
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
Ripper.tokenize("a += 1") | |
# => ["a", " ", "+=", " ", "1"] | |
pp Ripper.sexp "a += 1" | |
#[:program, | |
# [[:opassign, | |
# [:var_field, [:@ident, "a", [1, 0]]], | |
# [:@op, "+=", [1, 2]], | |
# [:@int, "1", [1, 5]]]]] |
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
ar = Array.new | |
(0..1000000).map{|i| ar[i] = i} # Fill the Array | |
ar[rand(1000000)]=ar[rand(1000000)] # Randomise the repetition | |
beginning_time = Time.now | |
repeated = ar.each_with_index.map{|v, i| ar[(ar[i]).abs] < 0 ? ((puts "#{ar[i].abs}"); break;) : ((ar[(ar[i]).abs]= - ar[(ar[i]).abs]))} | |
end_time = Time.now | |
puts "Time elapsed #{(end_time - beginning_time)*1000} milliseconds" |