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 human_size(size, si = false) | |
return '0' if size == 0 | |
base = si ? 1000 : 1024 | |
bytes = %w(B KB MB GB TB PB EB ZB YB) | |
cnt = Math.log(size, base).floor | |
size = size / (base * 1.0) ** cnt | |
fmt = size < 10 ? '%.1f %s' : '%i %s' | |
sprintf(fmt, size, bytes[cnt]) |
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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'ffi' | |
module Uname | |
extend FFI::Library | |
ffi_lib FFI::CURRENT_PROCESS |
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
a = {'one' => 1 } | |
puts "a.class = #{a.class}" | |
case a.class | |
when Hash | |
puts 'Hash' | |
else | |
puts 'not Hash' | |
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
a = {'one' => 1 } | |
puts "a.class = #{a.class}" | |
case a | |
when Hash | |
puts 'Hash' | |
else | |
puts 'not Hash' | |
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
require 'rubygems' | |
require 'redis_session' | |
session = Session::SessionClient.new(:prefix => 'add_test') # init the session | |
session.save('name', { 'name' => 'session'}) # Saving a content. Pure ruby content | |
restored = session.restore('name') # return to me a pure ruby content | |
puts restored.inspect | |
session.remove('name') # delete the key |
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 name="Button" | |
c:symbol-prefix="button" | |
c:type="GtkButton" | |
parent="Bin" | |
glib:type-name="GtkButton" | |
glib:get-type="gtk_button_get_type" | |
glib:type-struct="ButtonClass"> | |
<implements name="Atk.ImplementorIface"/> | |
<implements name="Actionable"/> | |
<implements name="Activatable"/> |
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
type | |
PGtkButton = ^TGtkButton; | |
TGtkButton = object(TGtkBin) | |
priv3: PGtkButtonPrivate; | |
function new: PGtkButton; cdecl; inline; static; | |
function get_label: Pgchar; cdecl; inline; | |
procedure set_label(label_: Pgchar); cdecl; inline; | |
property label_: Pgchar read get_label write set_label; | |
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
type | |
PGtkButton = ^TGtkButton; | |
TGtkButton = record | |
bin : TGtkBin; | |
event_window : PGdkWindow; | |
label_text : Pgchar; | |
activate_timeout : guint; | |
flag0 : word; | |
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
#!/usr/bin/env ruby | |
# | |
require 'rubygems' | |
require 'fileutils' | |
dirs = { 'bgracontrols' => { 'scm' => 'git', 'dir' => 'bgracontrols', 'levels' => 1}, | |
'ccr' => { 'scm' => 'svn', 'dir' => 'ccr', 'levels' => 1}, | |
'dcpcrypt' => { 'scm' => 'git', 'dir' => 'dcpcrypt', 'levels' => 1}, | |
'fortres' => { 'scm' => 'svn', 'dir' => 'fortes4lazarus', 'levels' => 1}, |
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
recursivemv() { | |
for d in *; do | |
if [ -d $d ]; then | |
(cd $d; recursivemv); | |
else | |
mv "$d" ${d:0:-2} | |
fi | |
done | |
} |