Skip to content

Instantly share code, notes, and snippets.

View flash-gordon's full-sized avatar
🔪
Working on sharp tools

Nikita Shilnikov flash-gordon

🔪
Working on sharp tools
View GitHub Profile
@flash-gordon
flash-gordon / oracle_locks.sql
Last active August 29, 2015 14:04
ora_locks
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',
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'
module TestCV
def value=(val)
@@value = val
end
def value
@@value
end
end
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
class Array
def complect(n)
each_slice((length.to_f / n).ceil).map {|a| a.inject(:+)}
end
end
# Nginx+Unicorn best-practices congifuration guide.
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies.
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module
#
# Deployment structure
#
# SERVER:
# /etc/init.d/nginx (1. nginx)
# /home/app/public_html/app_production/current (Capistrano directory)
#
@flash-gordon
flash-gordon / deterministic_test.sql
Created October 26, 2012 21:22
deterministic test
create or replace
function get_ref_name(
num_n_ref_id si_ref.n_ref_id%type,
num_n_lang_id si_ref.n_lang_id%type := sys_context('MAIN', 'N_LANG_ID')
)
return si_ref.vc_name%type
is
vch_vc_name si_ref.vc_name%type;
begin
select nvl(l.vc_name, r.vc_name)
@flash-gordon
flash-gordon / hupo.rb
Created November 15, 2012 23:28
clients_stuff/hupo.rb
module ClientsStuff
class Hupo < ::Rails::Engine
delegate :application, to: :Rails
initializer 'clients_stuff.hupo.append_assets' do
append_paths('assets')
end
initializer 'clients_stuff.hupo.append_widgets_paths', before: 'hupo_widget.load_all_widgets' do
append_paths('widgets')
@flash-gordon
flash-gordon / concat_strings.sql
Created January 12, 2013 11:51
wm_concat/listagg alt (10gR2) no benchmarks
create or replace function concat_strings (
c_list sys_refcursor)
return varchar2
as
vch_result varchar2(4000);
vch_string varchar2(4000);
begin
loop
fetch c_list into vch_string;
exit when c_list%notfound;
@flash-gordon
flash-gordon / object.rb
Created January 26, 2013 09:20
Little object extension that provide method calling tracking
class Object
# class MyObject
# end
#
# obj = MyObject.new
# obj.ring_it! # Start tracking
# # Logs will appear in rails log (tweak as you wish)
# # Do not use in production! Only for debug
def ring_it!
return if @__ringed__