Skip to content

Instantly share code, notes, and snippets.

View scalone's full-sized avatar

Thiago Scalone scalone

  • CloudWalk
  • São Paulo / SP
View GitHub Profile
@scalone
scalone / ruby_class_varible.rb
Created November 5, 2010 18:51
ruby class varible
@@ha = 'ha'
class A
class << self
@ha = 'boo'
end
def self.ha
@ha
end
end
@@ha = 'ha'
class A
@ha = 'boom'
class << self
attr_accessor :ha
end
def self.my_method
"k" + self.ha
end
@@ha = "a"
# definimos a variável de classe @@ha
class A
@@ha = "b"
# definimos novamente a variável de classe @@ha, agora com outro valor e dentro do escopo de uma nova classe.
end
# ao verificar o valor da variável de classe fora do escopo da classe A vimos que é o mesmo valor que setamos dentro do escopo da classe A.
@@ha
# => "b"
class A
@@ha = 'a'
def self.ha
@@ha
end
end
class B < A
@@ha = 'b'
end
@scalone
scalone / gist:1726879
Created February 3, 2012 01:11
Lua local variables
do
local cnt = 1
function inc ()
cnt = cnt + 1
return cnt
end
cnt = 5 -- Value will be changed after creating the function
end
print(inc()) --> Output 6
@scalone
scalone / gist:1727097
Created February 3, 2012 01:37 — forked from vinibaggio/gist:1727086
blocos malucos
p bloco = -> {
vai_danada = 1
def m
puts "AAAAAAA"
vai_danada += 1
end
vai_danada = 5
}.()
def onCreate(bundle)
super
@handler = Handler.new;
@i = 0
@thread = Thread.new do
@i += 1
puts "#{@i}"
@handler.postDelayed(self, 1000)
#or @handler.postDelayed(@thread, 1000)
unsigned char * SReader_ReadCard(int *size)
{
int cmdbuf[] = { 0x1b, 0x41, 0x00, 0x00, 0x2f, 0x75 };
// clear buffer;
int tmpsize = 0;
unsigned char *tmpbuf = get_DataBuffer(&tmpsize);
if (tmpbuf)
free(tmpbuf);
@scalone
scalone / test.rb
Created July 25, 2013 21:51
Test case and Test helper sample to abstract test interface in mtest(MRuby) and test/unit(MRI)
class TestHelper
if Object.const_defined?(:MTest)
def self.case
engine::TestCase
end
def self.engine
MTest::Unit
end
Generating /Users/thiagoscalone/projects/plano_be/walk/mobile/ruboto_sample/using_bundler/libs/bundle.jar
Fetching git@github.com:planobe/posxml_parse.git
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using posxml_parse (0.0.2) from git@github.com:planobe/posxml_parse.git (at master)
posxml_parse at /Users/thiagoscalone/projects/plano_be/walk/mobile/ruboto_sample/using_bundler/bin/bundle/bundler/gems/posxml_parse-f1f1fa96de14 did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
"cloudwalk.io" is not a URI