Skip to content

Instantly share code, notes, and snippets.

View cassiomarques's full-sized avatar
💭
I have no idea what I'm doing

Cássio Marques cassiomarques

💭
I have no idea what I'm doing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am cassiomarques on github.
  • I am cassiomarques (https://keybase.io/cassiomarques) on keybase.
  • I have a public key ASAWM1-qEX5vR9A08DeSGXFDCjhsl8ZTN3fW6uYWoGMTMgo

To claim this, I am signing this object:

[1] pry(main)> show-source Random.rand
From: random.c (C Method):
Owner: #<Class:Random>
Visibility: public
Number of lines: 5
static VALUE
random_s_rand(int argc, VALUE *argv, VALUE obj)
{
irb(main):021:0> Kernel.send :private, :class
=> Kernel
irb(main):022:0> foo.class
/Users/cassiommc/.rbenv/versions/2.2.2/lib/ruby/2.2.0/irb.rb:498:in `block (2 levels) in eval_input': private method `class' called for #<NoMethodError:0x007fa8f51abaa8> (NoMethodError)
irb(main):014:0> foo = "I am foo"
=> "I am foo"
irb(main):015:0> foo.is_a? String
=> true
irb(main):016:0> module Kernel
irb(main):017:1> private :is_a?
irb(main):018:1> end
=> Kernel
irb(main):019:0> foo.is_a? String
NoMethodError: private method `is_a?' called for "I am foo":String
@cassiomarques
cassiomarques / gist:2819167
Created May 28, 2012 13:25
Display your routes right at Rails Console, instead of waiting for rake to load your app
# This is part of my .pryrc.
# I put this at the section where I load Rails stuff, so I can use Pry instead of IRB
# for my Rails Console sessions
# Once this is loaded, just run the display_routes method from the console to see the same output that rake routes displays.
# I think it's better because I always leave a Rails console session running :)
require 'rails/application/route_inspector'
/**
* Recebe um objeto e o nome de uma propridade. Verifica se a propriedade existe no objeto.
* Se não existir, para cada propriedade do objeto que também seja um objeto, chama a si
* mesma recursivamente verificando se a propriedade pode ser encontrada.
* Caso a propriedade não seja encontrada, retorna false.
*/
function objectHasProperty(object, property) {
if (property in object) {
return true;
} else {
# For example, in a migration
#
# create_check_with_enumeration :foobars, :column => :category, :with => FoobarsCategory
#
# will create a check constraint in the table "foobars", so the column "category" will only accept one
# of the values declared in the FoobarsCategory enumeration
#
module ActiveRecord
module ConnectionAdapters
class PostgreSQLAdapter < AbstractAdapter
class A
def self.create_sub_class(name)
c= Class.new(self)
const_set name, c
end
end
A.create_sub_class "B"
A::B # ok!
var n = 3;
console.log(n.toFixed(5)); // 3.00000
//ou
console.log(Number(1.23).toFixed(5)); // 1.23000
value1 = 10;
var value2 = 0;
if(value2 == '') {
console.log("Não deveria ter sido executado!");
}
var funA = function() {
value1 = value1 * 2;
}