Skip to content

Instantly share code, notes, and snippets.

View ShadowBelmolve's full-sized avatar

Renan Tomal Fernandes ShadowBelmolve

View GitHub Profile
@ShadowBelmolve
ShadowBelmolve / Main.hx
Last active January 2, 2016 10:19 — forked from anonymous/Main.hx
haxe-traits break with this. Seems that if you import an "interface A"(IEntity) that has a variable of type "class B"(EntityData) that has a function with return type "class C"(Entity) and "class C" implements the "interface A", then variables from "interface A" simply aren't copied to "class C" or something like this. The same if you import "Cl…
package;
//works
//import world.Entity;
//works
//import world.IEntity;
//import world.Entity;
//not work
@ShadowBelmolve
ShadowBelmolve / example.rb
Created November 4, 2012 17:55
A prototype of my next gem.
#app/filters/user.rb
FilterIt.create('user') do
requires :name, :class => String # stop the filter if no name is found on 'data'
if current_user.admin? # search in each context for one that respond to the method 'current_user' without an error
# optional will not raise an error if isn't found, if any validation fail it will be simply ignored.
optional :authorizantion_level, :class => Integer,:in => 0..10
end
if current_user.manager?
optional :org_ids, :class => Array do
unless (is_creating_user rescue false)
@ShadowBelmolve
ShadowBelmolve / main.rb
Created October 12, 2012 02:30
Inspect source of files
SCRIPT_LINES__ = {}
require './test'
puts SCRIPT_LINES__.keys
# [".../test.rb"]
puts SCRIPT_LINES__.first[1].join
# def foo
# puts "bar"
@ShadowBelmolve
ShadowBelmolve / auto-hash.rb
Created October 11, 2012 16:47
Autovivification hash
deep = Hash.new { |hash, key| hash[key] = Hash.new(&hash.default_proc) }
# {}
deep[:foo][:bar][:lol?][:win!] = 10
# 10
deep
# {:foo=>{:bar=>{:lol?=>{:win!=>10}}}}
Today I've updated my gems and got this error with ActiveRecord::Base#to_json
>> User.all.to_json
=> "[\"#<User:0x6a9eb00>\",\"#<User:0x6a9ea60>\",\"#<User:0x6a9e9c0>\",\"#<User:0x6a9e920>\"]" #this isn't what I want
I think the problems is json_pure :/ but I can't remove it from project(some gems depend on it)
>> User.all.to_json
=> "[\"#<User:0x6a9eb00>\",\"#<User:0x6a9ea60>\",\"#<User:0x6a9e9c0>\",\"#<User:0x6a9e920>\"]"
Account 5 | Sem data
Act 2078164 | 2010-08-26 18:26:37 UTC
Address 169 | Sem data
Area 12 | 2009-06-02 11:52:57 UTC
Article 0 | Sem data
Avl 354 | 2008-08-27 20:10:47 UTC
AvlMacro 0 | Sem data
AvlProfile 0 | Sem data
BackupHost 0 | Sem data
Booth 29 | 2008-12-19 16:26:31 UTC
@import <Foundation/CPObject.j>
@import "PageView.j"
@import "PhotoInspector.j"
@implementation AppController : CPObject
{
}
# IRBRC file by Iain Hecker, http://iain.nl
# put all this in your ~/.irbrc
require 'rubygems'
require 'yaml'
alias q exit
class Object
def local_methods
(methods - Object.instance_methods).sort
a=Nanite.request('/integra_out/command', 45805)
=> #<Nanite::Job:0x74b6d90 @intermediate_state={}, @targets=["nanite-integra3"], @request=#<Nanite::Request:0x74be860 @selector=:least_loaded, @size=nil, @from="mapper-9a828281d56e78c397d2f41ee0f4f28b", @target=nil, @type="/integra_out/command", @tags=[], @token="f7e9b788f368047be12ff7daaa4abc3b", @persistent=false, @reply_to="mapper-9a828281d56e78c397d2f41ee0f4f28b", @payload=45805>, @results={}, @completed=nil, @pending_keys=[], @token="f7e9b788f368047be12ff7daaa4abc3b", @intermediate_handler=nil>
>> [Thu, 24 Jun 2010 17:24:30 -0300] ERROR: RECV [result] Could not load "--- !ruby/object:Nanite::Result \nfrom: nanite-integra3\nresults: &id003 !ruby/object:MQ::Exchange \n key: \n mq: &id002 !ruby/object:MQ \n _send_mutex: !ruby/object:Mutex {}\n\n callbacks: \n channel: 1\n connection: &id001 !ruby/object: \n _channel_mutex: !ruby/object:Mutex {}\n\n buf: !ruby/object:AMQP::Buffer \n data: \"\"\n pos: 0\n callbacks: []\