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
Efectivamente prototype es inicializado en las functions pero no en los objects: | |
> {}.prototype | |
undefined | |
> function(){}.prototype | |
{} | |
Sin embargo, Object se refiere al constructor: | |
> {}.constructor == Object |
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
source :rubygems | |
gem 'sinatra' | |
gem 'json' | |
gem 'omniauth' | |
gem 'omniauth-oauth2' | |
gem 'omniauth-github' | |
# gem 'omniauth-att', :path => File.expand_path("./../../omniauth-att", __FILE__) | |
gem 'thin' |
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
%token IDENT CONST VAR PROCEDURE COMPARISON expression NUMBER | |
%token CALL BEGIN END IF THEN WHILE DO ODD | |
%% | |
program | |
: block "." | |
; | |
block | |
: const var procedure statement |
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
defmodule MyList do | |
def sum([]), do: 0 | |
def sum([ head | tail ]), do: head + sum(tail) | |
end | |
IO.puts MyList.sum [1, 2, 3, 4] |
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
require 'data_mapper' | |
DataMapper::Logger.new($stdout, :debug) | |
DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/example.db") | |
class Post | |
include DataMapper::Resource | |
property :id, Serial | |
property :text, Text |
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
require 'delegate' | |
class Set2 < DelegateClass(Array) | |
attr_accessor :sep | |
attr_reader :a | |
protected :a | |
def initialize(*a) | |
@sep = ', ' | |
@a = a.uniq.sort |
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
require "rails" | |
module I | |
def f | |
puts "#{self.class}: doing f()" | |
end | |
def g | |
puts "#{self.class}: doing g()" | |
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
require 'sinatra' | |
require 'sinatra/contrib' | |
require 'sinatra/reloader' if development? | |
get '/' do | |
<<-"EOS" | |
cookies: #{cookies}<br/> | |
<a href="/set">Set the cookie 'something' to 'foobar'</a><br/> | |
<a href="/merge">cookies.merge! 'foo' => 'bar', 'bar' => 'baz'</a> | |
EOS |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<style> | |
.example { | |
border-style: dashed; | |
border-width: 2px; | |
border-color: blue; |
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
=begin | |
Hola profesor, | |
Me ha surgido una duda con una pregunta: supongamos que la clase B hereda de A un método tutu que usa la constante C definida en A. Si en la clase B se define C, ¿qué definición de C usará tutu, la de A o la de B? | |
Un saludo. | |
=end | |
class A | |
C = 4 | |
def tutu | |
puts C |