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
def yield_and_ensure | |
yield | |
ensure | |
'ensure' | |
end | |
def yield_and_return_ensure | |
yield | |
ensure | |
return 'ensure' |
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
class Foo | |
def self.method_added(method_name) | |
super | |
create_wrapper_for(method_name) | |
end | |
def self.create_wrapper_for(method) | |
wrap_module.class_eval <<-RUBY | |
def #{method}(*) | |
p '#{method} called!' |
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
create or replace type id_list as table of number | |
/ | |
create table test_nested( | |
id number primary key, | |
ids id_list | |
) | |
nested table ids store as nested_ids | |
/ | |
insert into test_nested(id, ids) | |
values (1, id_list(1, 2, 3)) |
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
declare | |
cursor c_t is | |
select * | |
from dual; | |
procedure remember_about_cursor | |
as | |
begin | |
if c_t%isopen then | |
close c_t; |
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
FUNCTION FETCH_NEXT_SERVICE | |
RETURN BOOLEAN | |
AS | |
num_Rows NUMBER; | |
BEGIN | |
rc_ServiceRow := NULL; | |
rc_OverlappingRow := NULL; | |
OPEN c_NextService; |
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
SELECT sn.username, m.sid, m.type, | |
DECODE(m.lmode, 0, 'None', | |
1, 'Null', | |
2, 'Row Share', | |
3, 'Row Excl.', | |
4, 'Share', | |
5, 'S/Row Excl.', | |
6, 'Exclusive', | |
lmode, ltrim(to_char(lmode,'990'))) lmode, | |
DECODE(m.request,0, 'None', |
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
2.2.2 :001 > fiber = Fiber.new {} | |
=> #<Fiber:0x007fc04b891f58> | |
2.2.2 :002 > Thread.new {fiber.resume}.join | |
FiberError: fiber called across threads | |
from (irb):2:in `resume' | |
from (irb):2:in `block in irb_binding' |
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
module TestCV | |
def value=(val) | |
@@value = val | |
end | |
def value | |
@@value | |
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
define_method :create do |field, &block| | |
define_method "#{field}=" do |arg| | |
instance_variable_set(:"@#{field}", arg) | |
end | |
define_method "#{field}" do | |
puts instance_exec(&block) | |
instance_variable_get(:"@#{field}") | |
end | |
end | |
A = Class.new do |
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
module CommandPlugins | |
module ActiveRecordTimestamps | |
def insert(tuples) | |
now = Time.zone.now | |
tuples_with_timestamps = tuples.map do |tuple| | |
tuple.merge(created_at: now, updated_at: now) | |
end | |
super(tuples_with_timestamps) | |
end |