Skip to content

Instantly share code, notes, and snippets.

View pigoz's full-sized avatar
:octocat:

Stefano Pigozzi pigoz

:octocat:
View GitHub Profile
module Kernel
def meta
class << self; self; end
end
end
class Module
public :attr_accessor, :attr_reader, :attr_writer
end
@pigoz
pigoz / rsi.rb
Created October 28, 2010 19:29
Siebel Scripting from Ruby using COM Data Control
require 'win32ole'
theApp = WIN32OLE.new('SiebelDataControl.SiebelDataControl.1')
cs = %{host="siebel://10.0.0.1:2321/Sieb78/EAIObjMgr_ita" Lang = "ITA"}
theApp.Login(cs, "uid", "password")
bo = theApp.GetBusObject("Order Entry Orders")
bc = bo.GetBusComp("Order Entry - Line Items")
def otool
puts self
%x[otool -L #{self}].each_line.grep(/\t(.*)/) do
$1.gsub(/(\(.*?\))/,'').strip
end
end
@pigoz
pigoz / ruby_sql_to_csv.rb
Created May 31, 2011 13:04
Ruby SQL to CSV exporter
require "rubygems"
begin
require 'sequel'
rescue LoadError
puts "Please run gem install sequel"
exit!
end
DB = Sequel.connect(:adapter => 'mysql2',
:host => '127.0.0.1',
@pigoz
pigoz / the_foo.rb
Created July 27, 2011 20:45
method extensions through modules instead of alias_method_chain
class TheFoo
module Base
def initialize
@foo = "foo"
end
def foo
@foo = "baz"
end
@pigoz
pigoz / slug.rb
Created August 26, 2011 16:06
very simple url slug with Rails
module ApplicationHelper
def slugged(field, path_method, record)
[self.send(path_method, record), record.send(field).parameterize].join("/")
end
end
# then in your view
<%= link_to post.title, slugged(:title, :post_path, post) %>
@pigoz
pigoz / gist:1217612
Created September 14, 2011 19:59
PidLock
class PidLock
def initialize(name, &block)
@name = name
if can_execute?
set_running
block.call
else
puts "the pidfile #{pidfile} is locked by process #{current_pid}"
end
end
@pigoz
pigoz / override methods through eigenclass.rb
Created October 12, 2011 13:23
override methods through eigenclass
class Greeter
def greet
"hello"
end
end
module ItalianGreeter
def greet
"ciao"
end
@pigoz
pigoz / gist:1792131
Created February 10, 2012 19:43
llvm - gcc
# GCC-4.2
pigoz@NAVI ~/dev/mplayerosx-builds ±master⚡ » mplayer2 -benchmark -vo null -nosound /Users/pigoz/Yarr\ Downloads/\[Coalgirls\]_Kampfer_OP_\(1280x720_Blu-Ray_FLAC\)_\[8668AB91\].mkv
BENCHMARKs: VC: 12.182s VO: 5.356s A: 0.000s Sys: 0.572s = 18.110s
BENCHMARK%: VC: 67.2649% VO: 29.5761% A: 0.0000% Sys: 3.1590% = 100.0000%
# LLVM
pigoz@NAVI ~/dev/mplayerosx-builds ±llvm⚡ » mplayer2 -benchmark -vo null -nosound /Users/pigoz/Yarr\ Downloads/\[Coalgirls\]_Kampfer_OP_\(1280x720_Blu-Ray_FLAC\)_\[8668AB91\].mkv
BENCHMARKs: VC: 20.472s VO: 6.064s A: 0.000s Sys: 0.605s = 27.141s
@pigoz
pigoz / zzz_backtrace
Created February 24, 2012 08:26
LibAV crash, OSX + 10bit h264: put_hv4_10_mmxext.v_loop
VO: [gl] 1920x1080 => 1920x1080 Planar 420P 10-bit little-endian
Reading symbols for shared libraries . done
A: 31.3 V: 31.2 A-V: 0.014 ct: 0.000 0/ 0 14% 2% 0.8% 36 0
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x00000001052f5ffc
[Switching to process 33890 thread 0x6107]
0x000000010079a1df in put_hv4_10_mmxext.v_loop ()
(gdb) bt
#0 0x000000010079a1df in put_hv4_10_mmxext.v_loop ()
#1 0x000000010079ac22 in stub_put_h264_qpel4_mc21_10_mmxext.body ()