Skip to content

Instantly share code, notes, and snippets.

View jacegu's full-sized avatar
🦖
Juggling shipping and parenting

Javier Acero jacegu

🦖
Juggling shipping and parenting
View GitHub Profile
@jacegu
jacegu / modules1.rb
Created January 18, 2011 18:13
A little example about modules and namespaces
module AModule
class String
def i_like_open_classes
puts "#{self} hasn't been monkey patched"
end
end
end
string = String.new
begin
@jacegu
jacegu / mixins1.rb
Created January 22, 2011 20:17
A little example to illustrate how mixins work in Ruby
module ModuleExample
def self.hello_world
puts 'This is a static hello world from a module'
end
def hello_world
puts 'This is a non static hello world from a module'
end
end
@jacegu
jacegu / mixins2.rb
Created January 22, 2011 20:58
A little example of mixing in Comparable module
class ComputerBrand
include Comparable
attr_reader :name
def initialize(name)
@name = name
end
def <=>(other)
@jacegu
jacegu / access_control_examples.rb
Created February 13, 2011 19:55
A little example for access control declaration in Ruby
class AccessControlExamples
def public_method_by_default
end
protected
def first_protected_method
end
def second_protected_method
end
@jacegu
jacegu / more_access_control_examples.rb
Created February 13, 2011 19:58
More examples about access control in Ruby. This one wont work.
class MoreAccessControlExamples
def public_by_default
end
protected def protected_method
end
public def this_is_public_too
end
@jacegu
jacegu / even_more_access_control_examples.rb
Created February 13, 2011 20:01
An example of declaring visibility of existing methods in Ruby.
class EvenMoreAccessControlExamples
def public_by_default
end
def protected_method
end
def this_is_public_too
end
@jacegu
jacegu / .vimrc
Created March 9, 2011 20:06
Disable arrows in Vim
"Disable arrows
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
imap <up> <nop>
imap <down> <nop>
imap <left> <nop>
imap <right> <nop>
@jacegu
jacegu / post_example.post
Created March 22, 2011 20:53
A example showing the file format of the blog posts
Post explaining how the blog file format works.
#title:
The post file format
#description:
Showing the file format that the blog posts have in my blog engine
#date:
2011-03-22 22:00
@jacegu
jacegu / rss.xml.haml
Created April 26, 2011 21:08
The HAML code of the blog RSS feed
!!! XML
%rss(version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:atom="http://www.w3.org/2005/Atom")
%channel
%title Javier Acero's blog
%link #{url('blog/rss')}
%atom:link(href="#{url('blog/rss')}"
rel="self"
@jacegu
jacegu / coffee_learning1.coffee
Created October 29, 2011 17:42
Some weird stuff with contexts for a CoffeScript&Javascript beginner
set_name = (name) -> @name = name
set_name 'Juan'
console.log name #Juan
console.log @name #undefined
#How context works here is pretty weird...
#Looks like set_name is not evaluated on "this" context
#This seems quite true if we do: