Skip to content

Instantly share code, notes, and snippets.

View jdecuirm's full-sized avatar

Jorge Decuir jdecuirm

  • Mexico
View GitHub Profile
@jdecuirm
jdecuirm / card.py
Created December 9, 2015 03:54
Importing and inheritance problems
class Card:
""" Attributes and methods for the Card class """
suits = ["Clubs", "Diamonds", "Hearts", "Spades"]
ranks = ["narf", "Ace", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "Jack", "Queen", "King"]
def __init__(self, suit = 0, rank = 0):
self.suit = suit
self.rank = rank
@jdecuirm
jdecuirm / finding_father.js
Created September 24, 2015 01:45
Not fully understanding closures and recursive functions in this problem
var ANCESTRY_FILE = "[\n " + [
'{"name": "Carolus Haverbeke", "sex": "m", "born": 1832, "died": 1905, "father": "Carel Haverbeke", "mother": "Maria van Brussel"}',
'{"name": "Emma de Milliano", "sex": "f", "born": 1876, "died": 1956, "father": "Petrus de Milliano", "mother": "Sophia van Damme"}',
'{"name": "Maria de Rycke", "sex": "f", "born": 1683, "died": 1724, "father": "Frederik de Rycke", "mother": "Laurentia van Vlaenderen"}',
'{"name": "Jan van Brussel", "sex": "m", "born": 1714, "died": 1748, "father": "Jacobus van Brussel", "mother": "Joanna van Rooten"}',
'{"name": "Philibert Haverbeke", "sex": "m", "born": 1907, "died": 1997, "father": "Emile Haverbeke", "mother": "Emma de Milliano"}',
'{"name": "Jan Frans van Brussel", "sex": "m", "born": 1761, "died": 1833, "father": "Jacobus Bernardus van Brussel", "mother":null}',
'{"name": "Pauwels van Haverbeke", "sex": "m", "born": 1535, "died": 1582, "father": "N. van Haverbeke", "mother":null}',
@jdecuirm
jdecuirm / parser.rb
Created February 20, 2015 03:32
Unit test with custom class objects
def parse_sentence(word_list)
puts "First state of the array"
p word_list
subj = parse_subject(word_list)
puts "First shift getting the subject, if no subject, player goes default"
p word_list
verb = parse_verb(word_list)
puts "Second shift getting the verb."
p word_list
obj = parse_object(word_list)
@jdecuirm
jdecuirm / parser.rb
Created February 18, 2015 05:00
Not getting the logic.
require_relative 'sentence.rb'
#Check the type of the word and returns it.
def peek(word_list)
if word_list
word = word_list[0]
word[0]
else
nil
require 'rake/testtask'
Rake::TestTask.new do |task|
task.libs << "tests"
task.test_files = FileList['tests/test*.rb']
task.verbose = true
task.warning = true
end
Loaded suite /home/jdecuirm/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/rake/rake_test_loader
Started
.F
===============================================================================
Failure:
test_errors(TestName)
/home/jdecuirm/Documents/Ruby_Development/RTHW/projects/ex48/tests/test_lexicon.rb:37:in `test_errors'
34: end
35:
36: def test_errors()
Started
F
===============================================================================
Failure:
test_directions(TestName)
/home/jdecuirm/Documents/Ruby_Development/RTHW/projects/ex48/tests/test_lexicon.rb:7:in `test_directions'
4: class TestName < Test::Unit::TestCase
5:
6: def test_directions()
=> 7: assert_equal(Lexicon.scan('north'),[['direction','north']])
@jdecuirm
jdecuirm / Rakefile
Created February 11, 2015 03:58
Comparing Words
require 'rake/testtask'
Rake::TestTask.new do |task|
task.libs << "tests"
task.test_files = FileList['tests/test*.rb']
task.verbose = true
task.warning = true
end
require './map.rb'
require './engine.rb'
require './scene.rb'
require './hero.rb'
puts "Hello, welcome to Medieval Kingdom!, first we have to create your character."
puts "Please tell me your name: "
print "> "
hero_name = $stdin.gets.chomp
hero = Hero.new(hero_name)
require './scene.rb'
class CentralCorridor < Scene
def enter()
puts "The Gothons of Planet Percal #25 have invaded your ship and destroyed"
puts "your entire crew. You are the last surviving member and your last"
puts "mission is to get the neutron destruct bomb from the Weapons Armory,"
puts "put it in the bridge, and blow the ship up after getting into an "
puts "escape pod."