Module: Roebe::CustomMethods

Defined in:
lib/roebe/custom_methods/constants.rb,
lib/roebe/custom_methods/custom_methods.rb

Overview

Roebe::CustomMethods

Constant Summary collapse

EINE_MINUTE =
#

EINE_MINUTE

#
60
EINE_STUNDE =
#

EINE_STUNDE

#
60 * 60
HASH =
#

HASH

#
{
  'b' => 2, 'a' => 1, 'c' => 3, 'e'   => 5,
  'd' => 4, 'j' => 7, 'i' => 7, 'FgH' => 6 
}
ARRAY =
#

Define a few global variables next:

#
[
  '1','2','3','4','5','6','7','8','9','0',
  'a','b','c','d','e', 'abc','cat','dog',
  'a','a','b',nil,nil
]
ALPHABET =
#

ALPHABET

#
('a'..'z').to_a
STRING =
#

STRING

#
'random line:'
HOME_DIRECTORY_OF_USER_X =
#

HOME_DIRECTORY_OF_USER_X

#
'/home/x/'
PI =
#

alias e puts Temporarily disabled the above … have to figure out if it is really good to have as alias here … December 2009.

#
Math::PI

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.autosourceObject

#

Roebe::CustomMethods.autosource

This is a hackish method - it will simply add an alias to the main rc files I use on my home system.

#

1527
1528
1529
1530
1531
1532
1533
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1527

def self.autosource
  into = Dir.home.to_s+'/.bashrc'
  puts 'Storing into `'+into+'`.'
  append_what_into(
    ". /AUTOGENERATED/aliases_rc\n", into
  )
end

.create_lua_pc_fileObject

#

Roebe::CustomMethods.create_lua_pc_file

#

4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4787

def self.create_lua_pc_file
  into = '/usr/lib/pkgconfig/lua.pc'
  what = '

V=5.4
R=5.4.3

prefix=/usr
INSTALL_BIN=${prefix}/bin
INSTALL_INC=${prefix}/include
INSTALL_LIB=${prefix}/lib
INSTALL_MAN=${prefix}/man/man1
INSTALL_LMOD=${prefix}/share/lua/${V}
INSTALL_CMOD=${prefix}/lib/lua/${V}
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: Lua
Description: An Extensible Extension Language
Version: ${R}
Requires: 
Libs: -L${libdir} -llua -lm
Cflags: -I${includedir}'
  ::Roebe.write_what_into(what, into)
  puts 'Stored at `'+::Roebe.sfile(into)+'`.'
end

.e(i = '') ⇒ Object

#

Roebe::CustomMethods.e

#

68
69
70
# File 'lib/roebe/custom_methods/custom_methods.rb', line 68

def self.e(i = '')
  puts i
end

.enable_roebe_promptObject

#

Roebe::CustomMethods.enable_roebe_prompt

#

481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
# File 'lib/roebe/custom_methods/custom_methods.rb', line 481

def self.enable_roebe_prompt
  # ======================================================================= #
  # === ROEBE_PROMPT
  #
  # Define the ROEBE_PROMPT here. You can invoke it by doing something
  # like:
  #
  #   irb --prompt roebe-prompt
  #
  # ======================================================================= #
  IRB.conf[:PROMPT][:ROEBE_PROMPT] = {
    PROMPT_I: "\n",  # A newline is, oddly enough, required here.
    PROMPT_N: ".. ", # Or: "",
    PROMPT_S: '"',   # Or nil
    PROMPT_C: '',
    RETURN:   "=> %s\n"
  }
  IRB.conf[:PROMPT_MODE] = :ROEBE_PROMPT
end

.feedback_which_ruby_version_is_in_useObject

#

Roebe::CustomMethods.feedback_which_ruby_version_is_in_use

Feedback which ruby-version is in use:

#

201
202
203
204
205
206
207
# File 'lib/roebe/custom_methods/custom_methods.rb', line 201

def self.feedback_which_ruby_version_is_in_use
  e "#{Colours.rev}"+
    "#{Colours.mediumpurple('Ruby Version in use: ')}"+
    "\e[1;32m"+
     RUBY_VERSION.to_s+"\e[0;37m "+
     "#{Colours.lightblue('Welcome to ruby!')}"
end

.ocra_build(on_this_file = 'examples/control_gallery.rb', name_of_the_output_exe = 'control_gallery.exe') ⇒ Object

#

Roebe::CustomMethods.ocra_build (ocra tag, orca tag)

This is ad-hoc code for windows.

Invocation example:

rinvoke Roebe.ocra_build
#

1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1625

def self.ocra_build(
    on_this_file           = 'examples/control_gallery.rb',
    name_of_the_output_exe = 'control_gallery.exe'
  )
  if on_this_file.is_a? Array
    on_this_file = on_this_file.first
  end
  case on_this_file
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default,
       nil
    on_this_file = 'examples/control_gallery.rb'
  end
  case name_of_the_output_exe
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    name_of_the_output_exe = 'control_gallery.exe'
  end
  if name_of_the_output_exe.frozen?
    name_of_the_output_exe = name_of_the_output_exe.dup
  end
  unless name_of_the_output_exe.end_with? '.exe'
    name_of_the_output_exe << '.exe'
  end
  ::Roebe.esystem 'ocra '+on_this_file+' '\
                  '--dll ruby_builtin_dlls/libssp-0.dll '\
                  '--dll ruby_builtin_dlls/libgmp-10.dll '\
                  '--dll ruby_builtin_dlls/libffi-7.dll '\
                  '--gem-all=fiddle '\
                  '--output '+name_of_the_output_exe
end

.require_my_custom_addonsObject

#

Roebe::CustomMethods.require_my_custom_addons (require tag, requires tag)

This will load all gems and files that I consider useful, whenever I work with irb. Keep in mind that this can slow down IRB immensely, so only load these components up when it is necessary.

#

79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/roebe/custom_methods/custom_methods.rb', line 79

def self.require_my_custom_addons
  # ======================================================================= #
  # === array_require_these_files
  # ======================================================================= #
  array_require_these_files = %w(
    roebe/core/string.rb
    roebe/classes/passwords.rb
    roebe/classes/enable_autologin.rb
    optparse
    open-uri
    csv
    net/ftp
    find
    json
    open
    esystem
    opn
    beautiful_url
    colours
    directory_paradise
    save_file
    ascii_paradise
    dictionaries
    percentage
    environment_information
    rbt
    rcfiles
    beautiful_url
    bioroebe
    cyberweb
    mountpoints
    multimedia_paradise
  ) # studium
  e
  Thread.new {
  array_require_these_files.each_with_index {|file, index| index += 1 # Do failsafe requires.
    begin
      # e Colours.rev+index.to_s.rjust(4)+') Next requiring '+Colours.steelblue(file)
      require file
      case file
      when 'multimedia_paradise'
        # e 'Also setting M to an alias of MultimediaParadise.'
        # M = MultimediaParadise
        # ^^^ Hmm.
      end
    rescue LoadError => error
      e '=' * 80
      e error if file == 'openssl'
      e 'We will feedback the error that we have received when loading '+
        Colours.sfancy(error)
      e Colours.simp(error)
      e '=' * 80
      case ENV['IS_ROEBE'].to_s
      when '1'
        puts '(from custom_methods.rb): The project `'+file+'` is not available.'
      end
    end
  }
  }
  e
end

.ruby_feature(id = ARGV.first) ⇒ Object

#

ruby_feature

#

787
788
789
790
791
# File 'lib/roebe/custom_methods/custom_methods.rb', line 787

def ruby_feature(id = ARGV.first)
  _ = 'https://bugs.ruby-lang.org/issues/'+id.to_s
  e 'Now opening '+sfancy(_)
  Open.in_browser(_)
end

.show_the_irb_historyObject

#

Roebe::CustomMethods.show_the_irb_history

Show the history of IRB so far.

#

464
465
466
467
468
469
# File 'lib/roebe/custom_methods/custom_methods.rb', line 464

def self.show_the_irb_history
  if Object.const_defined? :Readline
    history_array = Readline::HISTORY.to_a
    print history_array.join("\n")
  end
end

Instance Method Details

#aa?(optional_sequence = nil) ⇒ Boolean

#

aa?

My trainer for amino acids. (aminosäuren) rinvoke aa?

#

Returns:

  • (Boolean)

2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2709

def aa?(optional_sequence = nil)
  optional_sequence = ARGV.first.dup if ARGV.first
  puts; puts '-' * 80
  x = Bioroebe.new(optional_sequence)
  if optional_sequence.nil?
    x.cra(20, 5) unless optional_sequence
  else # else user passed in a sequence
    x.translate
  end
  x.aa?
  e '-' * 80
  puts;puts;puts
  e x.translate
end

#abbObject

#

abb

#

2359
2360
2361
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2359

def abb
  require 'abbrev'
end

#abc(inp = 1) ⇒ Object

#

abc

#

4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4307

def abc(inp = 1)
  { 
    :a => 1,  :b => 2,  :c => 3,  :d => 4,  :e => 5,  :f => 6,  :g => 7,  
    :h => 8,  :i => 9,  :j => 10, :k => 11, :l => 12, :m => 13, :n => 14, 
    :o => 15, :p => 16, :q => 17, :r => 18, :s => 19, :t => 20, :u => 21, 
    :v => 22, :w => 23, :x => 24, :y => 25, :z => 26
   } 
  alp2 = %w{ a b c d e f g h i j k l m n o p q r s t u v w x y z } 
  alp2.insert(0,nil)
  e
  e alp2[inp]
end

#add_ascii_suffixObject

#

add_ascii_suffix

#

840
841
842
843
844
845
846
# File 'lib/roebe/custom_methods/custom_methods.rb', line 840

def add_ascii_suffix
  Dir['*'].each {|file|
    new_filename = file+'.ascii'
    e 'Now modifying '+file+' to '+new_filename+'.'
    mv(file, new_filename)
  }
end

#add_comment(i = 76) ⇒ Object

#

add_comment

#

513
514
515
# File 'lib/roebe/custom_methods/custom_methods.rb', line 513

def add_comment(i = 76)
  Roebe.add_comment(i)
end

#add_current_symlink_to_every_entry_under_programsObject

#

add_current_symlink_to_every_entry_under_programs

rinvoke add_current_symlink_to_every_entry_under_programs

#

2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2298

def add_current_symlink_to_every_entry_under_programs
  all_dirs = Dir['/Programs/*']
  all_dirs.each {|entry|
    e  entry
    cd entry
    File.delete('Current') if File.symlink? 'Current'
    numbered_dir = Dir['*'].select {|inner_entry|
      File.directory?(inner_entry)
    }.first
    e 'Now working on '+numbered_dir+'.'
    to_current(numbered_dir)
  }
end
#

Enable magnet links in transmission.

#

2125
2126
2127
2128
2129
2130
2131
2132
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2125

def add_magnet_links
  _ = 'gconftool-2 -t string -s /desktop/gnome/url-handlers/magnet/command "transmission %s"'
  esystem _
  _ = 'gconftool-2 -s /desktop/gnome/url-handlers/magnet/needs_terminal false -t bool'
  esystem _
  _ = 'gconftool-2 -t bool -s /desktop/gnome/url-handlers/magnet/enabled true'
  esystem _
end

#add_to_playlist(i = ARGV) ⇒ Object

#

add_to_playlist

#

4598
4599
4600
4601
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4598

def add_to_playlist(i = ARGV)
  require 'multimedia_paradise'
  MultimediaParadise::Playlist.add_this_song(i)
end

#all_dirs(i = '*') ⇒ Object

#

all_dirs

Get all directories of the input-argument.

#

644
645
646
# File 'lib/roebe/custom_methods/custom_methods.rb', line 644

def all_dirs(i = '*')
  Dir[i].find_all { |f| ! File.directory?(f) }
end

#all_files(padding = ' ') ⇒ Object

#

all_files

#

2212
2213
2214
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2212

def all_files(padding = '  ')
  Dir['*'].select {|file| File.file? entry }.each { |file| puts padding+file }
end

#alphabet_to_number(your_string) ⇒ Object

#

alphabet_to_number

alfabet tag alphabet tag alfa tag alpha tag (alfabet code) pass a string. This string will be converted to alphabet.

This way you can find out the total sum of all used alphabet chars.

Usage Examples:

atn("abc")      # ==>  6
atn("jkj---k")  # ==> 43
atn("lightppd") # ==> 92
atn("Crossbone".downcase) # ==> 110
atn("apache")
atn("pandora")  # ==> 69
alphabet_to_number("apache")
#

3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3516

def alphabet_to_number(your_string)
  # The following way is what apeiros showed me.
  #   your_string.chars.inject(1000) { |s,char| s+char.first }
  sum = 0
  your_string.each_char { |tmp| # zb a
    alphabet_char_position = 0
    if ALPHABET.include? tmp
      alphabet_char_position = ALPHABET.index(tmp) + 1 
      # Only if the tmp char is in the alphabet, we add it up
      # puts "char war #{tmp}, sein value is #{alphabet_char_position}"
      sum += alphabet_char_position 
    end
    # e "sum is nun #{sum}"
  }
  return sum
end

#append_help(i = 'normalize') ⇒ Object

#

append_help

#

5054
5055
5056
5057
5058
# File 'lib/roebe/custom_methods/custom_methods.rb', line 5054

def append_help(
    i = 'normalize'
  )
  esystem "#{i} --help"
end

#asciiObject

#

ascii

#

367
368
369
# File 'lib/roebe/custom_methods/custom_methods.rb', line 367

def ascii
  require 'ascii_paradise'
end

#ascii_alphabetObject

#

ascii_alphabet

Following method displays each ascii value of a string.

#

3575
3576
3577
3578
3579
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3575

def ascii_alphabet
  ALPHABET.chars.each { |char|
    e char.first # returns ascii value, such as ?a
  }
end

#ask_a_question_based_on_this_pwdstud_entry(this_position = 1) ⇒ Object

#

ask_a_question_based_on_this_pwdstud_entry

The argument to this method should be the number to the pwdstud entry such as 1 for pwdstud1, or 2 for pwdstud2 etc..

#

4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4064

def ask_a_question_based_on_this_pwdstud_entry(
    this_position = 1
  )
  require 'studium'
  this_position -= 1 # We start to count at 1, hence we must subtract 1 to deal with ruby Arrays.
  regex = Studium.regex_for_pwd_stud # Obtain the regex for Studium here.
  file  = Studium.file_cd_aliases
  _ = File.read(file)
  exam_type = File.basename(
    _.scan(regex).sort[this_position]
  ).gsub(/; pwd/,'').strip
  # ======================================================================= #
  # Next get rid of numbered-input.
  # ======================================================================= #
  if exam_type =~ /^\d+-?\d*(.+)/
    exam_type = $1.to_s.dup.downcase.delete('_')
  end
  Studium.ask_exam_question(exam_type) # Delegate to class AskExamQuestion next.
end

#autostartObject Also known as: kde_autostart

#

autostart

Enable autostarting some apps for KDE. rinvoke autostart

#

1457
1458
1459
1460
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1457

def autostart
  require 'autostart'
  Autostart.new(:kde) # bl $RUBY_TOOLS/autostart.rb
end

#avg(i = ARGV, display_result = true) ⇒ Object Also known as: average, mean

#

avg

Returns the average of numbers.

Example:

avg [5, 6, 7, 8]
avg 5,10,15,30   # => 15.0
avg [5,10,15,30]  # => 15.0
average '2556 + 5320 + 3595 + 2806'
avg '5.42 5.53 5.49'
avg %w( 1 2 3 4 5 6 7 )
#

3326
3327
3328
3329
3330
3331
3332
3333
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3326

def avg(
    i = ARGV, display_result = true
  )
  require 'x/MATH/average.rb' # bl $RUBY_SRC/MATH/average.rb
  _ = Average.new(i)
  _.report if display_result
  return _.result
end

#avinfo(file = '') ⇒ Object

#

avinfo

multimedia stuff, avinfo

#

3761
3762
3763
3764
3765
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3761

def avinfo(file = '')
  e ' === AVINFORMATION === '
  e system("avinfo #{file}")
  e ' === END  === '
end

#backup_kdeObject

#

backup_kde

rinvoke backup_kde

#

2672
2673
2674
2675
2676
2677
2678
2679
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2672

def backup_kde
  kde_base_dir = '/root/.kde/share/apps/'
  e 'We will now backup some KDE settings.'
  copy_file kde_base_dir+'konqueror/konqueror.rc',
    '/home/x/data/PC/OS/LINUX/KDE/'
  copy_file kde_base_dir+'konsole/konsoleui.rc',
    '/home/x/DATA/PC/OS/LINUX/KDE/'
end

#bashObject

#

bash

#

4300
4301
4302
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4300

def bash
  system("bash -c '. ~/.bashrc;ll'")
end

#batch_create_filesObject

#

batch_create_files

This simply creates several files in one go.

rin batch_create_files
#

2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2912

def batch_create_files
  startname = 'wall'
  range = (11..35).to_a
  append_this = '.c'
  range.each { |x|
    filename = startname+x.to_s+append_this 
    puts filename
    create_file(filename)
  }
end

#benchmark_prototypeObject

#

benchmark_prototype

Show what code we can use for a benchmark prototype.

#

4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4204

def benchmark_prototype
  lpad = '' # This can be set to e. g. '  ' to allow initial padding.
  e lpad+"require 'benchmark'"
  e lpad+'N_TIMES = 250_000'
  e
  e lpad+'Benchmark.bm { |x|'
  e lpad+"  x.report('Testing: Dir.entries(Dir.pwd)') {"
  e lpad+'    N_TIMES.times { Dir.entries(Dir.pwd) }'
  e lpad+'  }'
  e lpad+"  x.report(\"Testing: Dir['*']            \") {"
  e lpad+"    N_TIMES.times { Dir['*'] }"
  e lpad+'  }'
  e lpad+'}'
end

#binary(i) ⇒ Object

#

binary

This is binary upload of ftp_upload.

#

3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3281

def binary(i)
  require 'ftp_paradise'
  if i.is_a? Array
    i.each {|entry| binary(entry) }
  else
    _ = FtpParadise::Connection.new('SHEVY', :dont_run_yet)
    _.be_verbose
    _.set_mode :binary, :be_verbose
    _.set_data('SHEVY')
    _.('SHEVY')
    _.upload(file) if File.exist? file
  end
end

#bit?Boolean

#

bit?

#

Returns:

  • (Boolean)

4233
4234
4235
4236
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4233

def bit?
  cmd = 'grep -q "^flags.*\blm\b" /proc/cpuinfo && echo "x86_64" || echo "not x86_64"'
  system cmd
end

#boku?Boolean

#

boku?

#

Returns:

  • (Boolean)

5023
5024
5025
5026
5027
# File 'lib/roebe/custom_methods/custom_methods.rb', line 5023

def boku?
  e BeautifulUrl[:boku]
  e BeautifulUrl[:bokumail]
  Passwords.password_for :boku
end

#border?Boolean

#

border?

Feedback the available CSS Borders.

#

Returns:

  • (Boolean)

738
739
740
# File 'lib/roebe/custom_methods/custom_methods.rb', line 738

def border?
  e 'dotted dashed solid double groove ridge inset outset'
end

#build_all_my_local_gemsObject

#

build_all_my_local_gems

#

803
804
805
# File 'lib/roebe/custom_methods/custom_methods.rb', line 803

def build_all_my_local_gems
  ::Roebe.build_all_my_local_gems
end

#bundle_exam_resultsObject Also known as: bundle_exams

#

bundle_exam_results

See the module-method for the documentation to this method here.

#

853
854
855
# File 'lib/roebe/custom_methods/custom_methods.rb', line 853

def bundle_exam_results
  ::Roebe.bundle_exam_results
end

#calculate_sum_for_excel(start_number = 4, up_to = 128, array = %w( I J K )) ⇒ Object

#

calculate_sum_for_excel

#

1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1728

def calculate_sum_for_excel(
    start_number =   4, # We start at this number here.
    up_to        = 128, # And we end at this number here.
    array        = %w( I J K ) # Which rows to use will be designated in this array.
  ) # excel
  e
  array.each {|index_character|
    print '=SUM(' # For now, we only use =SUM in excel.
    start_number.step(up_to,2) {|i|
      print index_character+i.to_s+';'
    }
    print ')'
    e; e
  }
  e
end

#cat(i = ARGV) ⇒ Object

#

cat

#

867
868
869
# File 'lib/roebe/custom_methods/custom_methods.rb', line 867

def cat(i = ARGV)
  ::Roebe.cat(i)
end

#cccObject

#

ccc

#

2806
2807
2808
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2806

def ccc
  esystem 'clear'
end

#chance(base_chance = 25) ⇒ Object

#

chance

Base chance is measured towards 100. A value of 25 as input argument means that in every 1/4 calls, true is returned.

Commandline invocation:

rinvoke chance
#

3693
3694
3695
3696
3697
3698
3699
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3693

def chance(
    base_chance = 25
  )
  # The input variable is tested against the following variable.
  this_turn_chance = rand(100)+1 # From 1 to 100.
  e this_turn_chance <= base_chance ? true : false
end

#change_all_entries_for_todayObject

#

change_all_entries_for_today

#

4195
4196
4197
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4195

def change_all_entries_for_today
  Dir['*'].each {|file| FileUtils.touch(file) }
end

#chdir(i = '/Depot/Temp') ⇒ Object Also known as: cd

#

chdir (chdir tag)

This method must be able to work with $VARIABLES, because on windows the typical ENV may not be available as-is.

#

719
720
721
722
723
724
725
726
727
728
729
730
731
# File 'lib/roebe/custom_methods/custom_methods.rb', line 719

def chdir(
    i = '/Depot/Temp'
  )
  i.strip!
  if i.include? '$'
    i = ConvertGlobalEnv[i]
  end
  if File.directory? i
    Dir.chdir(i)
  else
    e "#{i} is not a directory."
  end
end

#chmod?(i = ARGV, output_result = true) ⇒ Boolean

#

chmod?

#

Returns:

  • (Boolean)

4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4361

def chmod?(
    i             = ARGV,
    output_result = true
  )
  if i.is_a? Array
    i.each {|entry| chmod?(entry, output_result) }
  else
    permissions = File.stat(i).mode.to_s(8)[-3,3].to_s
    if output_result
      puts permissions
    else
      return permissions
    end
  end
end

#chunker(f_in, out_pref, chunksize = (1_073_741_824 / 1024.0)) ⇒ Object

#

chunker

Splits at 1 MB by default.

#

2857
2858
2859
2860
2861
2862
2863
2864
2865
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2857

def chunker(f_in, out_pref, chunksize = (1_073_741_824 / 1024.0))
  out_pref = f_in.dup if out_pref.nil?
  File.open(f_in,'r') { |fh_in|
    _ = "#{out_pref}_#{"%05d"%(( fh_in.pos / chunksize )+1)}.txt"
    File.open(_,'w') { |fh_out|
      fh_out << fh_in.read(chunksize)
    } until fh_in.eof?
  }
end

#closeObject Also known as: clo

#

close

#

4293
4294
4295
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4293

def close
  system('close')
end

#clrObject Also known as: clear

#

clr

Clear your system

#

677
678
679
# File 'lib/roebe/custom_methods/custom_methods.rb', line 677

def clr
  system('clear')
end

#colour_to_hex(i = ARGV) ⇒ Object

#

colour_to_hex

#

4166
4167
4168
4169
4170
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4166

def colour_to_hex(i = ARGV)
  require 'colours/rgb_to_hex/rgb_to_hex.rb'
  i = i.first if i.is_a? Array
  e Colours::RgbToHex[i.to_s]
end

#colourized_method(input = '', colour = 'green', make_newline = true, print_result = true) ⇒ Object Also known as: cme, cm

#

colourized_method (cme tag colme tag)

This method prints colourized strings. Note that you do not have to use “print” with this method - default is to print to STDOUT.

  • If string_logging is true, we will return a string, which is stored

in the global variable $LOGGING.

x = cme "test", 'def', true, false
#

3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3848

def colourized_method(
    input        = '',
    colour       = 'green',
    make_newline = true,
    print_result = true
  )
  result = ''.dup # our result string
  colour = 'green' if colour.to_s.downcase == 'def'

  result << pick_color(colour) unless colour.nil?
  result << input.to_s
  # result << Colour.clear unless colour.nil?
  result << "\n" if make_newline
  if print_result
    print result
  else
    return result
  end
end

#compile(this_program = 'php5') ⇒ Object Also known as: comp, ry

#

compile

Compile the given program.

#

705
706
707
# File 'lib/roebe/custom_methods/custom_methods.rb', line 705

def compile(this_program = 'php5')
  RBT::Compile.new(this_program)
end

#compile_as_appdir(i = Dir.pwd) ⇒ Object Also known as: compile_into_appdir

#

compile_as_appdir (appconf, appdir)

This method allows you to quickly compile into an Appdir-Like structure.

#

1090
1091
1092
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1090

def compile_as_appdir(i = Dir.pwd)
  self.compile_as_appdir(i)
end

#compile_into_xfce_prefixObject

#

compile_into_xfce_prefix

Use this method if you want to compile into a special XFCE Prefix.

#

980
981
982
983
# File 'lib/roebe/custom_methods/custom_methods.rb', line 980

def compile_into_xfce_prefix
  _ = './configure --prefix='+ENV['XFCE_PREFIX']
  esystem _
end

#compile_these(these = ARGV) ⇒ Object

#

compile_these

compile_these imlib2loaders libnet cups

#

1060
1061
1062
1063
1064
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1060

def compile_these(these = ARGV)
  _ = '"'+ARGV.join(',')+'"'
  require 'bt' # bl $BT/chained_compiling*
  _ = ChainedCompiling.new(_, nil, :compile)
end

#completion(dataset = nil) ⇒ Object

#

completion

Generate the english-completion.

rinvoke completion

#

1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1393

def completion(
    dataset = nil
  )
  require 'dictionaries'
  require 'generate_shell_completion'
  if dataset.nil?
    require 'yaml'
    dataset = YAML.load_file(Dictionaries.file_english).keys
    generate_where = '/home/x/DATA/PC/OS/LINUX/SHELL/SCRIPTS/english_completion.sh'
  end
  _ = GenerateShellCompletion.new(false)
  _.add_data(dataset)
  _.set_file(generate_where)
  _.set_name_of_function('english')
  _.add_alias 'askeng'
  _.generate
  e "Stored into `#{generate_where}`."
  generate_rf_completions
end

#configure_magicObject Also known as: configuremagic

#

configure_magic

#

4040
4041
4042
4043
4044
4045
4046
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4040

def configure_magic
  _ = './configure --prefix=/Programs/Xfce/4.12'
  e _
  system _
  system 'make'
  system 'make install'
end

#copy_cookbook_files_into_ruby_cookbooks_directoryObject

#

copy_cookbook_files_into_ruby_cookbooks_directory

This method will always work anyway, without requiring to cd to the target directory.

#

3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3780

def copy_cookbook_files_into_ruby_cookbooks_directory
  target_dir = RUBY_SRC_DIR+'rbt/lib/rbt/yaml/individual_cookbooks/'
  cd target_dir
  FileUtils.rm_rf(target_dir)
  FileUtils.mkdir(target_dir)
  Dir["#{target}*.yml"].each {|file|
    copy_file(file, target_dir)
  }
  # ======================================================================= #
  # Next, install the new cookbooks if we are on roebe:
  # ======================================================================= #
  if is_on_roebe?
    cd RUBY_SRC_DIR+'rbt/'
    r2
  end
end

#copy_file(file, where_to = Dir.pwd) ⇒ Object Also known as: copy

#

copy_file (copy tag)

Copies a file.

#

3111
3112
3113
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3111

def copy_file(file, where_to = Dir.pwd)
  self.copy_file(file, where_to)
end

#cpp_header?Boolean

#

cpp_header?

#

Returns:

  • (Boolean)

1051
1052
1053
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1051

def cpp_header?
  ::Roebe.cpp_header?
end

#cprubyObject

#

cpruby

#

3884
3885
3886
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3884

def cpruby
  ::Roebe.cpruby
end

#cpu?Boolean Also known as: cpu

#

cpu?

Spits out CPU info. Taps into modules.

struct.members => array, Returns an array of strings

representing the names of the instance variables.
#

Returns:

  • (Boolean)

3916
3917
3918
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3916

def cpu?
  SysInfo.get_system_info
end

#create_benchmark_fileObject

#

create_benchmark_file

#

5138
5139
5140
5141
# File 'lib/roebe/custom_methods/custom_methods.rb', line 5138

def create_benchmark_file
  require 'roebe/classes/create_benchmark_file.rb'
  Roebe::CreateBenchmarkFile.new
end

#create_databaseObject

#

create_database

insert into programs values(“a”,“b”,“c”); rvoke create_database

#

2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2245

def create_database
  require 'yaml'
  require 'rbt/constants/registered_cookbook_entries.rb'
  _ = RBT.file_registered_cookbook_entries
  sys_string = 'create table programs ('+N.dup
  sys_string << '    id integer primary key autoincrement,'+N
  entries = YAML.load_file(_)
  size = entries.size
  entries.each_with_index { |entry, index|
    sys_string << '    '+entry.to_s+' varchar(255)'
    sys_string << ',' unless index == (size-1)
    sys_string << N
  }
  sys_string << ')'
  e sys_string 
end

#create_directoriesObject

#

create_directories

#

3216
3217
3218
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3216

def create_directories
  self.create_directories
end

#create_directory(i) ⇒ Object Also known as: mkdir

#

create_directory

This method can be used to create a directory, using Ruby.

#

3209
3210
3211
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3209

def create_directory(i)
  FileUtils.mkdir(i) unless File.directory? i # Unless it already exists.
end

#create_file(i = '') ⇒ Object Also known as: touch

#

create_file

Create a file in the current directory. The first argument to this method is the filename.

#

2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2816

def create_file(i = '') # <- Filename
  if i.is_a? Array
    i.each {|entry| create_file(entry) }
  else
    if File.exist? i
      e 'Can not create file '+i+' as it already exists.'
    else
      FileUtils.touch(i)
    end
  end
end

#create_image_collectionObject

#

create_image_collection

This method will find all images under $IMG and create a html file with all the links to it.

Commandline invocation:

rinvoke create_image_collection
#

2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2636

def create_image_collection
  _ = Dir[ENV['IMG'].to_s+'/*/**']
  _.reject! {|entry| File.directory?(entry) }
  _.reject! {|file| ! is_image_file?(file)  }
  # next we will create a new html page
  my_file = '/Depot/IMAGES.html'
  create_file my_file
  append '<html><body><table>', my_file
  _.each { |image|
    append '<tr><td><b>'+image+'</b></td><td>'+'<img src="'+image+'"></td></tr>'+"\n",my_file
  }
  append '</table></body></html>', my_file
  e 'Look at '+my_file 
end

#create_individual_file(array) ⇒ Object

#

create_individual_file

This throwaway method I use to create stubs.

#

4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4501

def create_individual_file(array)
  array.each { |file|
    file = file.dup
    file << '.yml'
    if File.exist? file
      e 'Can not create `'+file+'` as this exists already.'
    else
      e 'Creating file `'+file+'` now.'
      create_file(file)
    end
  }
end

#create_lua_pc_fileObject

#

create_lua_pc_file

#

4818
4819
4820
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4818

def create_lua_pc_file
  ::Roebe::CustomMethods.create_lua_pc_file
end

#create_njoy_pageObject

#

create_njoy_page

This will generate a page with images.

#

4587
4588
4589
4590
4591
4592
4593
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4587

def create_njoy_page
  require 'diamond_shell/standalone_classes/webpage_for_images.rb'
  cd '/Depot/j'
  _ = WebpageForImages.new :do_not_run_yet
  _.use_this_dir = HOME_DIRECTORY_OF_USER_X+'DATA/IMG/NJOY/'
  _.run
end

#create_rpm_dirsObject

#

create_rpm_dirs

#

3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3670

def create_rpm_dirs # rinvoke create_rpm_dirs
  esystem 'mkdir -p ~/RPB_BUILDS/src/rpm/RPMS/noarch'
  esystem 'mkdir -p ~/RPB_BUILDS/src/rpm/RPMS/i586'
  esystem 'mkdir -p ~/RPB_BUILDS/src/rpm/RPMS/i686'
  esystem 'mkdir -p ~/RPB_BUILDS/src/rpm/RPMS/i486'
  esystem 'mkdir -p ~/RPB_BUILDS/src/rpm/RPMS/i386'
  esystem 'mkdir -p ~/RPB_BUILDS/src/rpm/RPMS/athlon'
  esystem 'mkdir -p ~/RPB_BUILDS/src/rpm/BUILD'
  esystem 'mkdir -p ~/RPB_BUILDS/src/rpm/SRPMS'
  esystem 'mkdir -p ~/RPB_BUILDS/src/rpm/SOURCES'
  esystem 'mkdir -p ~/RPB_BUILDS/src/rpm/SPECS'
  esystem 'mkdir -p ~/RPB_BUILDS/src/tmp'
end

#create_these_files_and_open_them(also_open_these_files = false) ⇒ Object

#

create_these_files_and_open_them

#

2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2014

def create_these_files_and_open_them(
    also_open_these_files = false
  )
  base_name = 'chopper_'
  file_ending = '.ascii'
  1.upto(30).each {|number|
    number = number.to_s.rjust(2,'0')
    _ = base_name+number+file_ending
    e _
    touch _
    open_in_editor(_) if also_open_these_files
  }
end

#cropdetect(i = ARGV.first) ⇒ Object

#

cropdetect

If you want to view the video, change -vo from null to xv rinvoke cropdetect

#

4225
4226
4227
4228
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4225

def cropdetect(i = ARGV.first)
  _ = "mplayer -ao null -vo null -vf cropdetect=24:2 #{i}"
  esystem _
end

#css_comments?Boolean Also known as: css_hints

#

css_comments?

How to do comments in .css files?

#

Returns:

  • (Boolean)

360
361
362
# File 'lib/roebe/custom_methods/custom_methods.rb', line 360

def css_comments?
  e '/* This is a CSS comment. */'
end

#csv(i = 'trees91.csv') ⇒ Object

#

csv

Simplified way to read in a .csv file.

#

3950
3951
3952
3953
3954
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3950

def csv(i = 'trees91.csv')
  csv = CSV.read(i, headers: true) # your data"
  csv.each {|entry| p entry }
  return csv
end

#custom_promptObject Also known as: my_prompt, myprompt

#

custom_prompt

#

505
506
507
# File 'lib/roebe/custom_methods/custom_methods.rb', line 505

def custom_prompt
  Roebe::CustomMethods.enable_roebe_prompt
end

#cyberwebObject Also known as: cyber, web_object

#

cyberweb

#

436
437
438
# File 'lib/roebe/custom_methods/custom_methods.rb', line 436

def cyberweb
  require 'cyberweb'
end

#dateObject

#

date

Displays date.

#

3925
3926
3927
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3925

def date
  system 'date'
end

#defaultObject

#

default

#

4606
4607
4608
4609
4610
4611
4612
4613
4614
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4606

def default
  51.upto(150).each {|index|
    file_name = 'sailing_boat_'+index.to_s+'.ascii'
    FileUtils.touch(file_name)
    _ = "#{MAIN_EDITOR_TO_USE} #{file_name}"
    Esystem.esystem _
    sleep 0.25
  }
end

#delete_all_directories_from_this_directoryObject

#

delete_all_directories_from_this_directory

This will delete all directories from the current working directory.

Use with caution!

Commandline invocation:

rinvoke delete_all_directories_from_this_directory
#

2104
2105
2106
2107
2108
2109
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2104

def delete_all_directories_from_this_directory
  all_dirs = Dir['*'].select {|entry| File.directory? entry }.reject {|entry|
    entry.strip.squeeze('/') == '/' # Don't want to delete the root directory.
  }
  remove_directory(all_dirs)
end

#delete_all_empty_directories_from_this_directoryObject

#

delete_all_empty_directories_from_this_directory

This will delete all directories from this directory.

#

779
780
781
782
# File 'lib/roebe/custom_methods/custom_methods.rb', line 779

def delete_all_empty_directories_from_this_directory
  all_dirs = Dir['*'].select {|entry| File.directory? entry }
  remove_directory(all_dirs, :only_delete_if_it_is_empty)
end

#delete_file(i) ⇒ Object Also known as: remove_file, del

#

delete_file

#

3057
3058
3059
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3057

def delete_file(i)
  File.delete(i) if File.exist? i
end

#diaObject

#

dia

#

3018
3019
3020
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3018

def dia
  require 'diamond_shell'
end

#dir(which_files = 'tar.bz2') ⇒ Object Also known as: glob

#

dir

With this method you can get a listing of all files, ie all pov files. Try it:

x = dir 'pov'
#

3876
3877
3878
3879
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3876

def dir(which_files = 'tar.bz2')
  e 'Error! must supply default file type.' if which_files.nil?
  Dir["*.#{which_files}"].each { |x| printf("%s\n", x) }
end

#dirs?Boolean

#

dirs?

Yield back all directories from the current directory.

#

Returns:

  • (Boolean)

990
991
992
# File 'lib/roebe/custom_methods/custom_methods.rb', line 990

def dirs?
  Dir['*'].select {|entry| File.directory? entry }
end

#disable_inputObject

#

disable_input

This disables input.

#

3745
3746
3747
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3745

def disable_input
  system 'stty -echo -icanon'
end

#display_batteryObject

#

display_battery

#

575
576
577
578
# File 'lib/roebe/custom_methods/custom_methods.rb', line 575

def display_battery
  require 'x/tools/battery.rb'
  Battery.new
end

#display_help_for_wurzel_ziehenObject

#

display_help_for_wurzel_ziehen

#

4735
4736
4737
4738
4739
4740
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4735

def display_help_for_wurzel_ziehen
  e 'Die dritte Wurzel ziehen geht so:'
  efancy '  Math.sqrt3 WERT'
  e 'Normale Wurzel ziehen geht so:'
  efancy '  Math.sqrt WERT'
end

#divide(*args) ⇒ Object

#

divide

Takes one or more objects (which should respond to the '/' method) and returns the result of applying the '/' method successively to each object

#

1864
1865
1866
1867
1868
1869
1870
1871
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1864

def divide(*args)
  args   = *args
  divide = args.shift
  args.each { |elem|
    divide = divide/elem
  }
  divide
end

#do_pid(create_this_directory = '/Depot/dir_created_as_some_user/') ⇒ Object

#

do_pid

Used to replace stuff.

#

3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3621

def do_pid(
    create_this_directory = '/Depot/dir_created_as_some_user/'
  )
  user_id = 99
  Dir.mkdir '/Depot/dir_created_as_root'
  Process.as_uid(user_id) {
    e 'Creating the directory '+create_this_directory+' next.'
    Dir.mkdir create_this_directory
    %x{ whoami }
  }
end

#dolphinObject

#

dolphin

Play the Simpson halloween that refers to dolphin.

#

1266
1267
1268
1269
1270
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1266

def dolphin
  require 'multimedia_paradise'
  _ = '/Depot/Video/Cartoons/Simpsons-12/Simpsons_12x01_Tree_House_of_Horror_XI.avi'
  system "mpv -vo x11 #{_}"
end

#dosbox_config(i = ARGV) ⇒ Object

#

dosbox_config

rinvoke dosbox_config

#

3272
3273
3274
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3272

def dosbox_config(i = ARGV)
  self.dosbox_config(i)
end

#download(this_url = ARGV.first) ⇒ Object

#

download

Use this to download a webpage.

rdownload blog.fefe.de/

#

4575
4576
4577
4578
4579
4580
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4575

def download(this_url = ARGV.first)
  require 'cyberweb'
  _ = Cyberweb.download_webpage(this_url)
  e _.string
  e "\nThe target was "+_.url
end

#download_favicon(this_url = 'https://www.ruppweb.org/Xray/101index.html') ⇒ Object

#

download_favicon

Use this method if you wish to download a favicon.

#

1666
1667
1668
1669
1670
1671
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1666

def download_favicon(
    this_url = 'https://www.ruppweb.org/Xray/101index.html'
  )
  require 'cyberweb'
  Cyberweb.download_favicon(this_url)
end

#druby(i = '9000') ⇒ Object

#

druby

rinvoke druby

#

2511
2512
2513
2514
2515
2516
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2511

def druby(i = '9000')
  DRb.start_service
  where = 'druby://localhost:'+i.to_s
  obj = DRbObject.new(nil, where)
  e "Sum is: #{obj.add(1,2,3)}"
end

#dump_all_my_gemsObject

#

dump_all_my_gems

This method will build all my gems and then copy them into a new location.

#

4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4140

def dump_all_my_gems
  require 'fileutils'
  require 'roebe/constants/array_install_these_gem_projects.rb'
  target_base_dir = '/Depot/Temp/my_gems/'
  remove_directory(target_base_dir) if File.directory? target_base_dir
  mkdir(target_base_dir)
  base_dir = RUBY_SRC_DIR
  Roebe.array_install_these_gem_projects.each {|this_gem|
    e base_dir+this_gem
    cd base_dir+this_gem
    make_gem
    this_gem = Dir['*.gem']
    unless this_gem.empty?
      this_gem = this_gem.first
      e 'Now moving `'+sfancy(this_gem)+'` to `'+sdir(target_base_dir)+'`.'
      FileUtils.mv( this_gem, target_base_dir )
    end
  }
  cliner {
    e 'Finished putting all into '+sdir(target_base_dir)+'!'
  }
end

#e(i = '') ⇒ Object

#

e

#

61
62
63
# File 'lib/roebe/custom_methods/custom_methods.rb', line 61

def e(i = '')
  puts i
end

#ejectObject Also known as: eje

#

eject

#

4286
4287
4288
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4286

def eject
  system('eject')
end

#enable_auto_loginObject

#

enable_auto_login

This method enables autologin.

rinvoke 
#

4651
4652
4653
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4651

def 
  EnableAutologin.new
end

#enable_autoindentObject

#

enable_autoindent

Enable autoindent in IRB.

#

3232
3233
3234
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3232

def enable_autoindent
  IRB.conf[:AUTO_INDENT] = true
end

#enable_inputObject

#

enable_input

#

3752
3753
3754
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3752

def enable_input
  system 'stty echo icanon'
end

#enable_my_firefox_profileObject

#

enable_my_firefox_profile

rinvoke enable_my_firefox_profile

#

2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2686

def enable_my_firefox_profile
  _  = ENV['FF'].to_s+'/'
  __ = ENV['MY_FF_DIR'] # pwdlinyam; bl roeber*
  __ = '/home/debug/.mozilla/firefox/w2rv0q83.default/'
  puts 'Enabling my firefox profile next to '+__ # cd $MY_FF_DIR
  FileUtils.cp _+'userChrome.css', __+'/chrome/'
  FileUtils.cp _+'hperm', __+'/hostperm.1'
  FileUtils.cp _+'user.js', __+'/'
  FileUtils.cp _+'userContent.css', __+'/chrome/'
  FileUtils.cp _+'barmid.png', __+'/chrome/'
  FileUtils.cp _+'bar.png', __+'/chrome/'
  # Next, enable java
  target = '/root/.mozilla/plugins/libjavaplugin_oji.so'
  target = '/home/debug/.mozilla/plugins/libjavaplugin_oji.so'
  system 'ln -s /Programs/Java/1.5.0/plugin/i386/ns7-gcc29/libjavaplugin_oji.so '+target
end

#enable_nano_configObject Also known as: generate_nano_config

#

enable_nano_config

rinvoke enable_nano_config

#

1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1467

def enable_nano_config
  require 'save_file'
  require 'convert_global_env'
  target_file = ConvertGlobalEnv['$HOME']+'/.nanorc'
  opn; e 'Appending info to '+sfile(target_file)
  File.delete(target_file) if File.exist? target_file
  nano_dir = '/home/x/data/PC/EDITORS/NANO/'
  files_to_copy = Dir["#{nano_dir}*.txt"]
  files_to_copy.each {|file|
    content = File.read(file)
    ::Roebe.append_what_into(content, target_file)
  }
  opn; e "Finished storing into #{sfile(target_file)}."
end

#envObject

#

env

read in environmental sections into the global var $env

#

2955
2956
2957
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2955

def env
  $env = `env`.split("\n").to_a.sort
end

#esystem(i) ⇒ Object

#

esystem

#

226
227
228
229
# File 'lib/roebe/custom_methods/custom_methods.rb', line 226

def esystem(i)
  e i
  system i
end

#extract(i) ⇒ Object Also known as: ext

#

extract

Usage example:

extract 'Packages-List-Printing.squashfs'
#

634
635
636
637
# File 'lib/roebe/custom_methods/custom_methods.rb', line 634

def extract(i)
  require 'extracter'
  Extracter[i]
end

#extract_url(url_string = ARGV.first) ⇒ Object

#

extract_url

rinvoke extract_url 'lalala homepage.mac.com/jamesrburgess/Stuff/ l'

#

2460
2461
2462
2463
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2460

def extract_url(url_string = ARGV.first)
  require 'uri'
  e URI::extract(url_string)
end

#extract_what_to(what, to = Dir.pwd) ⇒ Object

#

extract_what_to

Use this to extract something.

#

3832
3833
3834
3835
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3832

def extract_what_to(what, to = Dir.pwd)
  require 'extracter'
  Extracter.extract_what_to(what, to)
end

#fancy_irbObject Also known as: fancyirb, firb

#

fancy_irb

#

187
188
189
190
191
192
193
# File 'lib/roebe/custom_methods/custom_methods.rb', line 187

def fancy_irb
  require 'fancy_irb'
  FancyIrb.start
  # FancyIrb.start(
  #   {rocket_prompt: "\n# => "}
  # )
end

#featuresObject Also known as: fe

#

features

#

2002
2003
2004
2005
2006
2007
2008
2009
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2002

def features
  $LOADED_FEATURES.sort!
  e
  e
  $LOADED_FEATURES.each {|entry| e entry }
  e
  e
end

#feedback_base_classObject

#

feedback_base_dir

This will feedback the code we may use to

#

2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2063

def feedback_base_class
  _ = ENV['RUBY_SRC'].to_s+'/'
  path = Dir.pwd.gsub(/#{_}/,'')
  path.gsub!(/lib\//,'') if path.include? 'lib/'
  result = ''.dup
  result << "require '#{path}/base/base.rb'"
  result << '; < ::'+path.capitalize.to_s+'::Base'
  set_xorg_buffer(result)
  e result
end

#feedback_base_dirObject Also known as: base_project?

#

feedback_base_dir

#

997
998
999
# File 'lib/roebe/custom_methods/custom_methods.rb', line 997

def feedback_base_dir
  ::Roebe.feedback_base_dir
end

#feedback_help_about_raiseObject

#

feedback_help_about_raise

#

905
906
907
# File 'lib/roebe/custom_methods/custom_methods.rb', line 905

def feedback_help_about_raise
  e "raise ArgumentError, 'Argument is not numeric' unless x.is_a? Numeric"
end

#feedback_ruby_keywordsObject

#

feedback_ruby_keywords

#

4825
4826
4827
4828
4829
4830
4831
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4825

def feedback_ruby_keywords
  result = ''.dup
  self.ruby_keywords?.each {|keyword| result << keyword+', ' }
  result.strip!
  result.chop!
  e result
end

#fetch_gimpObject Also known as: update_gimp

#

fetch_gimp

Use this to fetch gimp from the latest git sources.

#

4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4838

def fetch_gimp
  require 'esystem'
  require 'totarxz'
  the_date = Time.now.strftime '%d.%m.%Y'
  base_dir = HOME_DIRECTORY_OF_USER_X+'SRC/gimp/'
  cd(base_dir)
  e 'We are now in the directory `'+sdir(base_dir)+'`.'
  _ = 'git clone git://git.gnome.org/gimp'
  esystem _
  e 'Next renaming the dir `'+sdir(the_date)+'`.'
  the_dir = 'gimp-'+the_date
  rename 'gimp', the_dir
  old_dir = Dir.pwd
  cd the_dir
  remove('.gitignore')
  remove('.git/')
  cd old_dir
  ToTarXz[the_dir]
end

#fetch_page(which_page = 'http://www.google.at') ⇒ Object Also known as: fet, www_open, open_www

#

fetch

This is a simple web_fetcher.

Commandline invocation example:

rinvoke fetch derstandard.at

Example in ruby code:

result = www_open 'http://www.ebi.ac.uk/ena/data/view/M80805&display=fasta'
x = www_open 'http://www.zamg.ac.at/cms/de/wetter/wetterwerte-analysen/wien'
#

1687
1688
1689
1690
1691
1692
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1687

def fetch_page(which_page = 'http://www.google.at')
  e 'heureka ...' if which_page[0,'http://'.size] == 'http://'
  result = open(which_page).read # .read(1024) # If we need to limit it.
  e result
  return result
end

#fib(input = 10) ⇒ Object

#

fib

rinvoke fib

#

2088
2089
2090
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2088

def fib(input = 10)
  input.times { |i| print StdMath.fib(i).to_s+' ' }; puts
end

#fibonacci(i = ARGV.first) ⇒ Object

#

fibonacci

rinvoke fibonacci 10

#

5065
5066
5067
# File 'lib/roebe/custom_methods/custom_methods.rb', line 5065

def fibonacci(i = ARGV.first)
  Roebe.fibonacci(i)
end

#file_ending(i = ARGV.first) ⇒ Object

#

file_ending

#

4727
4728
4729
4730
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4727

def file_ending(i = ARGV.first)
  cmd = 'find . -type f -name \*.'+i
  esystem cmd
end

#fill_up_with_this_token(amount = 10, my_token = ' ') ⇒ Object

#

fill_up_with_this_token

#

2727
2728
2729
2730
2731
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2727

def fill_up_with_this_token(amount = 10, my_token = ' ')
  tmp = ''
  0.upto(amount) { |h| tmp << my_token }
  return tmp
end

#filter_ansi(i) ⇒ Object Also known as: fansi

#

filter_ansi

fansi “ä”

#

3050
3051
3052
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3050

def filter_ansi(i)
  i.gsub(/\e[^a-z]+[a-z]/, '')
end

#find_duplicatesObject

#

find_duplicates

I use this to find duplicates in the code.

How to find duplicated when clauses here:

#

4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4179

def find_duplicates
  input_file = ENV['RUBY_SRC'].to_s+'/beautiful_url/lib/beautiful_url/toplevel_methods/beautiful_menu.rb'
  x = File.readlines(input_file)
  y = x.join("\n").grep(/^ +when/).join(' ').gsub(/when/,'').gsub(/','/,' ')
  z = y.split(' ').join(' ').gsub(/,/,' ').squeeze(' ').split(' ').join(' ')
  # gsub(/'/,' ')
  pp z
  hash = Hash.new(0)
  z.scan(/\w+\??/) { |word| hash[word] += 1 }
  e 'Results are:'
  pp hash.select {|key, value| pp key if value.to_i > 1}
end

#find_object(the_object_id) ⇒ Object

#

find_object

find_object -607869178 y = find_object -608122768

#

1851
1852
1853
1854
1855
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1851

def find_object(the_object_id)
  # ObjectSpace.each_object {|o| break o if o.object_id == the_object_id}
  # ObjectSpace.each_object {|o| return o if o.object_id == the_object_id}
  ObjectSpace._id2ref the_object_id
end

#find_primesObject Also known as: primes?

#

find_primes

Find prime numbers via this method.

Commandline invocation:

rinvoke find_primes
#

3072
3073
3074
3075
3076
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3072

def find_primes
  for index in 2..35000 do
    puts index unless (2..index-1).find { |j| index % j == 0 }
  end
end

#find_rdoc_docu(i = ARGV.first, format_type = '--format=markdown') ⇒ Object

#

find_rdoc_docu

rinvoke find_rdoc_docu

#

4757
4758
4759
4760
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4757

def find_rdoc_docu(i = ARGV.first, format_type = '--format=markdown')
  require 'show_rdoc_docu'
  ShowRdocDocu.new(i, format_type)
end

#fix_filenamesObject

#

fix_filenames

Generic method to fix filenames in the current directory. Should be adapted to the specific use case that you currently have.

#

1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1510

def fix_filenames
  old_files = Dir['*']
  old_files.each {|file|
    if file.include? 'WIEN' # Downcase to Wien.
      new_filename = file.gsub(/WIEN/,'Wien')
      e "Renaming #{sfile(file)} to #{sfile(new_filename)}."
      mv(file, new_filename)
    end
  }
end

#fix_pidginObject Also known as: fix_icq

#

fix_pidgin

Fix the crappy pidgin config.

#

4426
4427
4428
4429
4430
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4426

def fix_pidgin
  target = File.expand_path('~/.gtkrc-2.0')
  e "Copying gtkrc to #{target} next (this will fix the Pidgin keybindings)"
  copy_file ENV['LINUX'].to_s+'/GTK/gtkrc', target
end

#fsize(file = '/Depot/Temp/Multiaterm.desktop') ⇒ Object

#

fsize

#

1787
1788
1789
1790
1791
1792
1793
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1787

def fsize(file = '/Depot/Temp/Multiaterm.desktop')
  x = File.stat(file).size?
  y = x/1000
  z = y/1000
  a = z.to_f/1000
  e y.to_s+' KB, '+z.to_s+' MB, '+a.to_s+'GB'
end

#fstat(file = '/index.php') ⇒ Object

#

fstat

#

3736
3737
3738
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3736

def fstat(file = '/index.php')
  e File.lstat(file)
end

#geas_itObject

#

geas_it

#

3298
3299
3300
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3298

def geas_it # rinvoke geas_it
  Roebe.geas_it
end

#geas_it2Object

#

geas_it2

#

1976
1977
1978
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1976

def geas_it2
  Roebe.geas_it2
end

#gem_installObject

#

gem_install

#

3223
3224
3225
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3223

def gem_install
  ::Roebe.gem_install
end

#gem_install_scriptObject

#

gem_install_script

require 'x/STD/array_install_these_gem_projects.rb'
rinvoke gem_install_script
#

1986
1987
1988
1989
1990
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1986

def gem_install_script
  ARRAY_INSTALL_THESE_GEM_PROJECTS.each {|name|
    e '  wget '+name
  }
end

#gemi(i) ⇒ Object

#

gemi

Install a gem as user.

#

4053
4054
4055
4056
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4053

def gemi(i)
  _ = 'gem install --user-install '+i.to_s
  esystem _
end

#generate_cookbooks_completionsObject

#

generate_cookbooks_completions

rinvoke generate_cookbooks_completions

This will be stored at:

bl /Depot/Temp/rbt_completion.sh
#

2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2475

def generate_cookbooks_completions
  require 'rbt'
  require 'generate_shell_completion'
  array  = RBT.programs?
  array << RBT.cookbook_aliases?.keys
  array.flatten!
  store_here = '/Depot/Temp/rbt_completion.sh'
  _ = GenerateShellCompletion::GenerateShellCompletion.new(ARGV, :dont_run_yet)
  _.set_name_of_the_shell_function 'completion_for_ry'
  _.set_aliases 'rf'
  _.set_dataset(array)
  _.store_here store_here
  _.use_files_in_directory_as_well
  e 'We will store at `'+Colours.sfile(store_here)+'`.'
  _.remove_old_file
  # ======================================================================= #  
  # Which aliases to use here.
  # ======================================================================= #
  use_these_aliases = %w(
    ry url urla wis co cookbook sload
    tags coptions? coptions blfs
    ecompile
  )
  _.set_aliases use_these_aliases
  _.run
  target = '/home/x/data/PC/OS/LINUX/SHELL/SCRIPTS/'+File.basename(store_here)
  e "We will store at #{Colours.sfile(target)}."
  _.store_here target
  _.run
end

#generate_html_table_for_individuelles_curriculumObject

#

generate_html_table_for_individuelles_curriculum

#

1097
1098
1099
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1097

def generate_html_table_for_individuelles_curriculum
  ::Roebe.generate_html_table_for_individuelles_curriculum
end

#generate_lighttpd_configurationObject

#

generate_lighttpd_configuration

#

4012
4013
4014
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4012

def generate_lighttpd_configuration
  Roebe.generate_lighttpd_configuration
end

#generate_opal_filesObject

#

generate_opal_files

rinvoke generate_opal_files

#

1441
1442
1443
1444
1445
1446
1447
1448
1449
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1441

def generate_opal_files
  require 'opal'
  where = 'app.js'
  e 'Now creating '+sfile(where)
  ::Roebe.write_what_into(Opal.compile("puts 'wow'"),  where)
  where = 'opal.js'
  e 'Now creating '+sfile(where)
  ::Roebe.write_what_into(Opal::Builder.build('opal'), where)
end

#generate_random_chars(how_many = 25) ⇒ Object

#

generate_random_chars

This method will simply generates a few random characters.

#

1830
1831
1832
1833
1834
1835
1836
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1830

def generate_random_chars(
    how_many = 25
  )
  array = []
  how_many.times {|x| array << ALPHABET.sample }
  return array
end

#generate_random_numbers(n_times = 10, range = (0..100).to_a) ⇒ Object

#

generate_random_numbers

This will generate random numbers. It returns an array.

pp generate_random_numbers(10, (1..2001).to_a)

rinvoke generate_random_numbers
#

3642
3643
3644
3645
3646
3647
3648
3649
3650
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3642

def generate_random_numbers(
    n_times = 10,
    range   = (0..100).to_a
  )
  array = []
  array_of_available_numbers = range
  n_times.times { array << array_of_available_numbers.sample }
  return array 
end

#generate_random_string(len = 1_000, shall_we_output_the_result = true) ⇒ Object Also known as: random_string, gsr

#

generate_random_string

Since Jun 2011, we use only alphabetical characters. gsr 100, true gsr 20, true gsr(20, true).downcase

#

4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4464

def generate_random_string(len = 1_000, shall_we_output_the_result = true)
  result = (0...len).map {
    rand(36).to_s(36)
  }.map {|x| (rand < 0.5) ? x:x.upcase }.join
  result = (0...len).map {
    $alphabet.sample
  }.map {|x| (rand < 0.5) ? x:x.upcase }.join
  e result if shall_we_output_the_result
  result
end

#generate_rf_completionsObject

#

generate_rf_completions

gcompletions

#

1800
1801
1802
1803
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1800

def generate_rf_completions
  require 'roebe/browser/firefox.rb'
  ::Roebe.firefox.generate_tab_completions
end

#get_random_imageObject

#

get_random_image

rinvoke get_random_image

#

4451
4452
4453
4454
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4451

def get_random_image
  require 'x/STD/std_includes.rb'
  _ = get_file_listing(ENV['IMG'].to_s+'/RPG').sample
end

#getchObject

#

getch

#

4639
4640
4641
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4639

def getch
  STDIN.getch
end

#girlsObject

#

girls

#

4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4261

def girls
  %w(
    girl1
    girl2 
    girl3
    girl4
    girl6
  ).map(&:to_sym).each {|entry|
    rf entry
  } unless RUBY_VERSION < '2.0'
end

#git_coloursObject

#

git_colours

#

817
818
819
# File 'lib/roebe/custom_methods/custom_methods.rb', line 817

def git_colours
  ::Roebe.git_colours
end

#google_search(search_term = 'ruby') ⇒ Object

#
#

4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4380

def google_search(search_term = 'ruby')
  begin;require 'google';require 'cgi';rescue;end
  key = File.read(File.join(ENV['HOME'], '.google_key')).chomp
  google = Google::Search.new(key)
  result = google.search( search_term )
  result.resultElements.each_with_index { |block_result, index|
    printf "\nResult #%d:\n", index
    puts 'url war: '+block_result.send('url')
    puts 'title war: '+block_result.send('title')
    #result.each do |key|
    #  printf("%s = %s\n", key, result.send(key))
    #end
  }
end

#gtkObject Also known as: gtk2

#

gtk

#

3004
3005
3006
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3004

def gtk
  require 'gtk2'
end

#gtk_runner?Boolean

#

gtk_runner?

We need the start-position and the end-position.

rinvoke gtk_runner?

#

Returns:

  • (Boolean)

3029
3030
3031
3032
3033
3034
3035
3036
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3029

def gtk_runner? # bl $RSRC/gtk_runner/lib/gtk_runner/gtk_runner.rb
  _ = RUBY_SRC_DIR+'gtk_paradise/lib/gtk_paradise/run.rb'
  start_line = 567 - 1 # We deduct 1 because Arrays start at 0.
  end_line   = 587
  e File.readlines(_)[
    start_line..end_line
  ].map {|entry| entry.gsub(/# /,'' ).delete('#') }.join().to_s
end

#has_readline?Boolean

#

has_readline?

Use this method to determine whether your ruby version has readline support or whether it has not.

#

Returns:

  • (Boolean)

1702
1703
1704
1705
1706
1707
1708
1709
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1702

def has_readline?
  begin; require 'readline'; rescue LoadError; end
  if Object.const_defined? :Readline
    e 'Yes, your ruby has readline support.'
  else
    e 'No, your ruby does not have readline support.'
  end
end

#heredocs?Boolean

#

heredocs? (eof tag)

This makes an EOF.

#

Returns:

  • (Boolean)

585
586
587
# File 'lib/roebe/custom_methods/custom_methods.rb', line 585

def heredocs?
  ::Roebe.heredocs?
end

#htmlentities(i) ⇒ Object

#

htmlentities

As the PHP's htmlentities version.

The input to this method should be a String.

Use this as in the following example:

htmlentities('a > x && y < 0') # => "a &gt; x &amp;&amp; y &lt; 0"
#

3611
3612
3613
3614
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3611

def htmlentities(i)
  require 'cyberweb/toplevel_methods/escape_html.rb'
  Cyberweb.htmlentities(i)
end

#images_to_html(from_this_directory = return_pwd) ⇒ Object Also known as: imagestohtml

#

images_to_html

#

5146
5147
5148
5149
5150
5151
# File 'lib/roebe/custom_methods/custom_methods.rb', line 5146

def images_to_html(
    from_this_directory = return_pwd
  )
  require 'cyberweb'
  Cyberweb::ImagesToHtml.new(from_this_directory)
end

#increase_volume(i) ⇒ Object

#

increase_volume

#

796
797
798
# File 'lib/roebe/custom_methods/custom_methods.rb', line 796

def increase_volume(i)
  ::Roebe.increase_volume(i)
end

#install_acrobat_readerObject

#

install_acrobat_reader

rinvoke install_acrobat_reader

#

686
687
688
689
690
691
# File 'lib/roebe/custom_methods/custom_methods.rb', line 686

def install_acrobat_reader
  name = 'AdobeReader-9.4.2.bin'
  copy_file '/home/x/src/PDF/'+name,'/Depot/j'
  cd '/Depot/j'
  system './'+name
end

#install_and_update_rcfilesObject

#

install_and_update_rcfiles

#

1416
1417
1418
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1416

def install_and_update_rcfiles 
  ::Roebe.install_and_update_rcfiles
end

#install_bcm4318Object Also known as: install_bcm

#

install_bcm4318

This is for the wlan on my laptop. rinvoke install_bcm4318

#

2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2565

def install_bcm4318
  e 'Now installing WLAN Driver for the laptop:' 
  append 'blacklist bcm43xx', '/etc/modprobe.d/blacklist'
  esystem 'ndiswrapper -i '+ENV['SRC']+'/WLAN/DRIVERS/bcmwl5a.inf'
  esystem 'modprobe bcm43xx'
  esystem 'iwlist wlan0 scan'
  esystem 'ndiswrapper -m'
  esystem 'ifup wlan0'
  esystem 'iwlist scanning'
  esystem 'dhclient wlan0' 
end

#install_docbook_componentsObject

#

install_docbook_components

This will install the docbook components, including smgl.

rinvoke install_docbook_components

#

1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1108

def install_docbook_components
  require 'rbt'
  require 'esystem'
  # ======================================================================= #
  # First, we get rid of some already installed things.
  # ======================================================================= #
  remove '/etc/xml/'  if File.directory? '/etc/xml/'
  remove '/etc/sgml/' if File.directory? '/etc/sgml/'
  remove '/usr/share/xml/'  if File.directory? '/usr/share/xml/'
  remove '/usr/share/sgml/' if File.directory? '/usr/share/sgml/'
  e 'We will install SGML first:'
  to   = '/Depot/Temp/'
  what = RBT::Cookbooks::SanitizeCookbook.new(:sgmlcommon)
  name = what.name_and_version?
  Extracter.extract_what_to(what.path?, to)
  FileUtils.mkdir('/etc/xml')
  cd to+name
  esystem 'patch -Np1 -i *.patch'
  esystem 'autoreconf -f -i'
  e
  esystem './configure --prefix=/usr --sysconfdir=/etc'
  e
  esystem 'make'
  e
  # Now, as the root user:
  esystem 'make install'
  e
  e 'We will now add to '+sfile('/etc/sgml/sgml-ent.cat')
  e
  esystem 'install-catalog --add /etc/sgml/sgml-ent.cat 
  /usr/share/sgml/sgml-iso-entities-8879.1986/catalog'.delete("\n").strip
  e
  esystem 'install-catalog --add /etc/sgml/sgml-docbook.cat
  /etc/sgml/sgml-ent.cat'.delete("\n").strip
  e
  # ======================================================================= #
  # And now we will install docbook-xsl
  # ======================================================================= #
  what = RBT::Cookbooks::SanitizeCookbook.new(:docbookxsl)
  name = what.name_and_version?
  Extracter.extract_what_to(what.path?, to)
  cd to+name
  e
  esystem "install -v -m755 -d /usr/share/xml/docbook/xsl-stylesheets-1.78.1"
  e
  esystem "cp -v -R VERSION common eclipse epub extensions fo highlighting
  html htmlhelp images javahelp lib manpages params profiling roundtrip
  slides template tests tools webhelp website xhtml xhtml-1_1
  /usr/share/xml/docbook/xsl-stylesheets-1.78.1"
  e
  esystem "ln -s VERSION /usr/share/xml/docbook/xsl-stylesheets-1.78.1/VERSION.xsl"
  e
  esystem "install -v -m644 -D README 
  /usr/share/doc/docbook-xsl-1.78.1/README.txt".delete("\n").strip
  e
  esystem "install -v -m644    RELEASE-NOTES* NEWS* 
  /usr/share/doc/docbook-xsl-1.78.1".delete("\n").strip
  e
  unless File.exist? '/etc/xml/catalog'
    esystem 'xmlcatalog --noout --create /etc/xml/catalog'
    e
  end
  esystem 'xmlcatalog --noout --add "rewriteSystem" 
  "http://docbook.sourceforge.net/release/xsl/1.78.1"
  "/usr/share/xml/docbook/xsl-stylesheets-1.78.1"
  /etc/xml/catalog'.delete("\n").strip
  e
  esystem 'xmlcatalog --noout --add "rewriteURI" 
  "http://docbook.sourceforge.net/release/xsl/1.78.1" 
  "/usr/share/xml/docbook/xsl-stylesheets-1.78.1" 
  /etc/xml/catalog'.delete("\n").strip
  e
  esystem 'xmlcatalog --noout --add "rewriteSystem"
  "http://docbook.sourceforge.net/release/xsl/current"
  "/usr/share/xml/docbook/xsl-stylesheets-1.78.1"
  /etc/xml/catalog'.delete("\n").strip
  e
  esystem 'xmlcatalog --noout --add "rewriteURI"
  "http://docbook.sourceforge.net/release/xsl/current"
  "/usr/share/xml/docbook/xsl-stylesheets-1.78.1"
  /etc/xml/catalog'.delete("\n").strip
  e
  # ======================================================================= #
  # Next we could install xml-dtd-4.2/
  # ======================================================================= #
  esystem 'xmlcatalog --noout --add "rewriteSystem"
  "http://docbook.sourceforge.net/release/xsl/4.2"
  "/usr/share/xml/docbook/xsl-stylesheets-4.2"
  /etc/xml/catalog'.delete("\n").strip.tr('  ',' ')
  esystem 'xmlcatalog --noout --add "rewriteURI" 
  "http://docbook.sourceforge.net/release/xsl/4.2"
  "/usr/share/xml/docbook/xsl-stylesheets-4.2"
  /etc/xml/catalog'.delete("\n").strip.tr('  ',' ')
  # ======================================================================= #
  # Ok, sgml is now installed. We will install docbook-4.5 next:
  # ======================================================================= #
  what = RBT::Cookbooks::SanitizeCookbook.new(:docbook)
  name = what.name_and_version?
  Extracter.extract_what_to(what.path?, to)
  cd to+name
  e
  esystem "sed -i -e '/ISO 8879/d' -e '/gml/d' docbook.cat"
  e
  esystem "install -v -d /usr/share/sgml/docbook/sgml-dtd-4.5"
  e
  esystem "chown -R 0:0 ."
  e
  esystem "install -v docbook.cat /usr/share/sgml/docbook/sgml-dtd-4.5/catalog"
  e
  esystem "cp -v -af *.dtd *.mod *.dcl /usr/share/sgml/docbook/sgml-dtd-4.5"
  e
  esystem "install-catalog --add /etc/sgml/sgml-docbook-dtd-4.5.cat
    /usr/share/sgml/docbook/sgml-dtd-4.5/catalog".delete("\n").strip
  e
  esystem "install-catalog --add /etc/sgml/sgml-docbook-dtd-4.5.cat
    /etc/sgml/sgml-docbook.cat".delete("\n").strip
  e
  # ======================================================================= #
  # Now we install docbook-4.2:
  # ======================================================================= #
  what = HOME_DIRECTORY_OF_USER_X+'src/docbook/docbook-4.5.tar.xz'
  name = File.basename(what).gsub(/\.tar\.xz$/, '')
  Extracter.extract_what_to(what, to)
  cd to+name
  e
  esystem "sed -i -e '/ISO 8879/d' -e '/gml/d' docbook.cat"
  e
  esystem "install -v -d /usr/share/sgml/docbook/sgml-dtd-4.2"
  e
  esystem "chown -R 0:0 ."
  e
  esystem "install -v docbook.cat /usr/share/sgml/docbook/sgml-dtd-4.2/catalog"
  e
  esystem "cp -v -af *.dtd *.mod *.dcl /usr/share/sgml/docbook/sgml-dtd-4.2"
  e
  esystem "install-catalog --add /etc/sgml/sgml-docbook-dtd-4.2.cat
    /usr/share/sgml/docbook/sgml-dtd-4.5/catalog".delete("\n").strip
  e
  esystem "install-catalog --add /etc/sgml/sgml-docbook-dtd-4.2.cat
    /etc/sgml/sgml-docbook.cat".delete("\n").strip
  e
end

#install_geany_addonsObject

#

install_geany_addons

Use this method to install geany addons.

#

5115
5116
5117
5118
5119
# File 'lib/roebe/custom_methods/custom_methods.rb', line 5115

def install_geany_addons
  e 'Installing geany addons (geany-plugins) next.'
  require 'rbt'
  RBT::Compile.new('geany-plugins')
end

#install_in_ruby_gem_manner(optional_copy_the_gem_to_this_location = nil) ⇒ Object

#

install_in_ruby_gem_manner

#

1995
1996
1997
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1995

def install_in_ruby_gem_manner(optional_copy_the_gem_to_this_location = nil)
  ::Roebe.install_in_ruby_gem_manner(optional_copy_the_gem_to_this_location)
end

#install_in_ruby_setup_mannerObject Also known as: r2

#

install_in_ruby_setup_manner

This is similar to the r2 alias.

#

4686
4687
4688
4689
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4686

def install_in_ruby_setup_manner
  require 'roebe/classes/update.rb'
  ::Roebe.install_in_ruby_setup_manner
end

#install_javaObject Also known as: installjava

#

install_java

rinvoke installjava

#

2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2790

def install_java
  require 'rbt'
  require 'fileutils'
  _ = RCreateProgram.new 'java-1.5.0.09'
  _.create_directories
  java_package = 'jdk-1.5.0.09'
  java_package << '.bin'
  _ = ENV['J']
  FileUtils.cp '/home/x/SRC/java/'+java_package, _
  cd _
  system 'sh '+java_package
end

#install_lamppObject

#

install_lampp

#

2542
2543
2544
2545
2546
2547
2548
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2542

def install_lampp
  require 'extracter'
  extract_to = '/opt/'
  what = ENV['SRC']+'/LAMPP/lampp.tar.xz'
  e 'Now trying to extract '+what+':'
  Extracter.new(what, extract_to, true)
end

#install_my_gemsObject

#

install_my_gems

This method will install all my local gems.

#

1810
1811
1812
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1810

def install_my_gems
  ::Roebe.install_my_gems
end

#install_openofficeObject Also known as: openoffice, install_libreoffice, ioffice

#

install_openoffice (openoffice tag, ooffice tag, roffice)

This method will install libreoffice, by making use of class Roebe::InstallLibreoffice for this job.

rinvoke openoffice

#

4938
4939
4940
4941
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4938

def install_openoffice
  require 'roebe/classes/install_libreoffice/install_libreoffice.rb'
  InstallLibreoffice.new
end

#install_operaObject

#

install_opera

Install opera here.

#

2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2774

def install_opera
  what = ENV['SRC']+'/OPERA/opera-11.51-1087.i386.linux.tar.bz2'
  cp what, ENV['MY_TEMP']
  cd ENV['MY_TEMP']
  extract File.basename(what)
  cd File.basename(what)
  puts 'In Directory '+return_pwd
  RBT.create_program
  cpr '.', ENV['MY_PROGRAMS']+'/Opera/Current/'
end

#install_postgresqlObject

#

install_postgresql

rinvoke install_postgresql

#

3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3974

def install_postgresql
  e 'We will initialize a database cluster next.'
  # esystem 'adduser postgre'
  user_id = '51' # This will be the userid of the postgres user.
  esystem 'install -v -dm700 /srv/pgsql/data'
  esystem 'install -v -dm755 /run/postgresql'
  esystem 'groupadd -g '+user_id+' postgres'
  esystem 'useradd -c "PostgreSQL Server" -g postgres -d /srv/pgsql/data -u '+user_id+' postgres'
  esystem 'chown -Rv postgres:postgres /srv/pgsql /run/postgresql'
  esystem "su - postgres -c '/usr/bin/initdb -D /srv/pgsql/data'"
  # Next start the database-cluster.
  esystem "su - postgres -c '/usr/bin/postmaster -D /srv/pgsql/data > /srv/pgsql/data/logfile 2>&1 &'"
  # Next, create a database and verify the installation:
  esystem "su - postgres -c '/usr/bin/createdb test'"
  command = <<-EOF
echo "create table t1 ( name varchar(20), state_province varchar(20) );" \
  | (su - postgres -c '/usr/bin/psql test ') &&
echo "insert into t1 values ('Billy', 'NewYork');" \
  | (su - postgres -c '/usr/bin/psql test ') &&
echo "insert into t1 values ('Evanidus', 'Quebec');" \
  | (su - postgres -c '/usr/bin/psql test ') &&
echo "insert into t1 values ('Jesse', 'Ontario');" \
  | (su - postgres -c '/usr/bin/psql test ') &&
echo "select * from t1;" | (su - postgres -c '/usr/bin/psql test')
EOF
  esystem command
end

#install_roebe_addonsObject

#

install_roebe_addons

#

860
861
862
# File 'lib/roebe/custom_methods/custom_methods.rb', line 860

def install_roebe_addons
  ::Roebe.install_roebe_addons
end

#install_ssl_certificatesObject

#

install_ssl_certificates

This will install SSL certificates.

The whole procedure is described here:

http://www.linuxfromscratch.org/blfs/view/svn/postlfs/cacerts.html
#

3814
3815
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3814

def install_ssl_certificates
end

#install_this_deb_file(deb_file) ⇒ Object

#

install_this_deb_file

This method will install a debian .deb file.

#

4400
4401
4402
4403
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4400

def install_this_deb_file(deb_file)
  require 'roebe/classes/install_debian_file.rb'
  ::Roebe::InstallDebianFile.new(deb_file)
end

#install_usb_tvObject

#

install_usb_tv

#

1299
1300
1301
1302
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1299

def install_usb_tv  
  e 'Now installing USB TV Stick from Pinnacle:' 
  esystem 'modprobe em28xx-dvb'
end

#install_wg111tObject Also known as: wlan

#

install_wg111t

rinvoke wlan

#

2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2738

def install_wg111t
  require 'x/STD/std_includes.rb'
  src_dir = ENV['SRC']
  what = src_dir+'/WINDOWS/DRIVERS/WLAN/WG111T.tar.bz2'
  extract_to = '/Depot/j'
  extract_what_to(what, extract_to)
  cd extract_to
  cd 'WG111T'
  esystem 'ndiswrapper -i '+extract_to+'/WG111T/athfmwdl.inf'
  esystem 'ndiswrapper -i '+extract_to+'/WG111T/netwg11t.inf'
  esystem 'depmod -a'
  esystem 'ndiswrapper -l'
  esystem 'modprobe ndiswrapper'
  esystem 'ndiswrapper -m'
  esystem 'dhcpcd -n wlan0'
end

#install_xfceObject

#

install_xfce

Use this method to install XFCE.

#

1578
1579
1580
1581
1582
1583
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1578

def install_xfce
  require 'rbt/cookbooks/sanitize_cookbook_dataset/sanitize_cookbook_dataset.rb'
  dataset = RBT::Cookbooks::SanitizeCookbook.new('xfce')
  location = extract_what_to(dataset.full_path?, '/Depot/Temp/')
  return location
end

#install_youtube_dlObject

#

install_youtube_dl

This method will install youtube-dl in a proper directory.

#

5043
5044
5045
5046
5047
5048
5049
# File 'lib/roebe/custom_methods/custom_methods.rb', line 5043

def install_youtube_dl
  require 'rbt'
  target = '/home/Programs/Youtubedl/1.0.0/'
  RBT.create_appdir_skeleton('youtubedl-1.0.0')
  cp_r HOME_DIRECTORY_OF_USER_X+'src/youtubedl/youtube-dl', target+'bin/'
  RBT.symlink_program(target)
end

#invoke_capitalize(name = ARGV.first) ⇒ Object

#

rinvoke invoke_capitalize

#

4628
4629
4630
4631
4632
4633
4634
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4628

def invoke_capitalize(name = ARGV.first) # capitalize
  if File.directory? name
    rename(name, name.capitalize)
  else
    e 'Did not find `'+name+'`-'
  end
end

#ip?(this_www_address = 'www.ruby-lang.org') ⇒ Boolean

#

ip?

#

Returns:

  • (Boolean)

2227
2228
2229
2230
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2227

def ip?(this_www_address = 'www.ruby-lang.org')
  a = IPSocket.getaddress this_www_address
  e "The address of #{this_www_address} was #{a}"
end

#is_image_file?(i) ⇒ Boolean

#

is_image_file?

#

Returns:

  • (Boolean)

2580
2581
2582
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2580

def is_image_file?(i)
  %w( jpg png gif ).any? {|f| i.downcase.include?(f) }
end

#is_on_roebe?Boolean

#

is_on_roebe?

#

Returns:

  • (Boolean)

3770
3771
3772
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3770

def is_on_roebe?
  ENV['IS_ROEBE'].to_s == '1'
end

#iso_encoding(i) ⇒ Object

#

iso_encoding

#

1317
1318
1319
1320
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1317

def iso_encoding(i)
  require 'roebe/encoding/encoding.rb'
  Roebe.ensure_main_encoding(i)
end

#javascriptcomment?Boolean

#

javascriptcomment?

#

Returns:

  • (Boolean)

1841
1842
1843
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1841

def javascriptcomment?
  e '/* */'
end

#json(i = nil) ⇒ Object

#

json

#

264
265
266
267
268
269
270
271
272
273
# File 'lib/roebe/custom_methods/custom_methods.rb', line 264

def json(
    i = nil
  )
  if i
    i = File.read(i) if File.exist? i
    return JSON.parse(i)
  else # no argument give, hence just require 'json' now.
    require 'json'
  end
end

#json_to_hash(from_this_file) ⇒ Object

#

json_to_hash

This method will convert the json data stored in a local file into a Hash for use in ruby.

As argument you have to pass in the path to a local file.

#

1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1280

def json_to_hash(
    from_this_file
  )
  require 'json'
  if from_this_file.is_a? Array
    from_this_file = from_this_file.first
  end
  if File.exist? from_this_file
    file = File.read(from_this_file)
    hash = JSON.parse(file)
    return hash # And return our Hash here.
  else
    no_file_exists_at(from_this_file)
  end
end

#keywords?Boolean

#

keywords?

#

Returns:

  • (Boolean)

1966
1967
1968
1969
1970
1971
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1966

def keywords?
  require 'irb/ruby-token'
  return RubyToken::TokenDefinitions.select { |definition|
    definition[1] == RubyToken::TkId
  }.map { |definition| definition[2] }.compact.sort
end

#kill_la_filesObject

#

kill_la_files

rinvoke kill_la_files This will remove all la files.

#

2929
2930
2931
2932
2933
2934
2935
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2929

def kill_la_files
  Dir['*/**/*.la'].each { |file|
    _ = return_pwd+'/'+file # absolute position.
    puts 'Removing this .la file next: '+_
    remove_file(_)
  }
end

#less(*args) ⇒ Object

#

less

Takes one or more objects (which should respond to the '-' method) and returns the result of applying the '-' method successively to each object

#

4334
4335
4336
4337
4338
4339
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4334

def less(*args)
  args=*args
  less = args.shift
  args.each { |elem| less -= elem }
  less
end

#liner(n_times = 80) ⇒ Object Also known as: cliner

#

liner

#

4019
4020
4021
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4019

def liner(n_times = 80)
  Cliner[n_times]
end

#link?(i = ARGV) ⇒ Boolean

#
#

Returns:

  • (Boolean)

219
220
221
# File 'lib/roebe/custom_methods/custom_methods.rb', line 219

def link?(i = ARGV)
  Roebe.link?(i)
end

#llObject Also known as: ls, l, showdir

#

ll (ll tag, ls tag, l tag)

#

5072
5073
5074
5075
5076
5077
# File 'lib/roebe/custom_methods/custom_methods.rb', line 5072

def ll
  unless Object.const_defined? :DirectoryParadise
    require 'directory_paradise'
  end
  DirectoryParadise::Report.new; '' # The '' is for IRB.
end

#load_path?Boolean

#

load_path?

Give us back the load path that Ruby uses.

#

Returns:

  • (Boolean)

2555
2556
2557
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2555

def load_path?
  e $LOAD_PATH
end

#load_wirbleObject

#

load_wirble

Enable wirble colour support for IRB next.

#

5165
5166
5167
5168
5169
5170
5171
# File 'lib/roebe/custom_methods/custom_methods.rb', line 5165

def load_wirble
  begin
    require 'wirble'
    Wirble.init
    Wirble.colorize
  rescue LoadError; end
end

#main_test(i = ARGV) ⇒ Object Also known as: test2

#

test2

This is a test-method.

You can use it like so:

test2 htop --appdir
#

2144
2145
2146
2147
2148
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2144

def main_test(i = ARGV)
  require 'rbt/cookbooks/class.rb'
  object = RBT::Cookbooks::SanitizeCookbookDataset.new(i)
  e object.prefix?
end

#make_cookbooks_gemObject

#

make_cookbooks_gem

This method will publish a proper cookbooks gem, with all yaml file entries. Afterwards, it will remove that directory.

To trigger this, do:

make_cookbooks_gem
#

2662
2663
2664
2665
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2662

def make_cookbooks_gem # rinvoke make_cookbooks_gem
  require 'rbt/tools/make_cookbooks_gem.rb'
  MakeCookbooksGem.new # bl $RUBY_TOOLS/make_cookbooks_gem.rb
end

#make_gemObject

#

make_gem

#

3536
3537
3538
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3536

def make_gem
  ::Roebe.make_gem
end

#make_pdfObject

#

make_pdf

Use this to test the generation of .pdf files. rinvoke make_pdf

#

4520
4521
4522
4523
4524
4525
4526
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4520

def make_pdf
  require 'pdf'
  pdf = PDF.new :default
  pdf.cell(50, 30, 'Testing.')
  _ = '/yo.pdf'
  pdf.create_then_open(_)
end

#manualObject

#

manual

#

651
652
653
# File 'lib/roebe/custom_methods/custom_methods.rb', line 651

def manual
  Roebe::Shell.create_manual
end

#marriedObject

#

married

#

2847
2848
2849
2850
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2847

def married
  require 'multimedia_paradise'
  MultimediaParadise.video_player(:married_with_children)
end

#married_with_childrenObject

#

married_with_children

#

520
521
522
# File 'lib/roebe/custom_methods/custom_methods.rb', line 520

def married_with_children
  ::Roebe.play_random_married_with_children_video
end

#mbr?Boolean

#

mbr?

rinvoke mbr?

#

Returns:

  • (Boolean)

3586
3587
3588
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3586

def mbr?
  pp File.open('/dev/sda') {|f| f.read(512) } # Using pp here is the right thing to do.
end

#mechanizeObject

#

mechanize

#

2997
2998
2999
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2997

def mechanize
  require 'mechanize'
end

#meduni?Boolean

#

meduni?

#

Returns:

  • (Boolean)

912
913
914
915
916
917
# File 'lib/roebe/custom_methods/custom_methods.rb', line 912

def meduni?
  e(_ = BeautifulUrl[:meduni])
  set_xorg_buffer(_)
  e BeautifulUrl[:meduni_mail]
  Passwords.password_for :meduni, :do_not_modify_the_xorg_buffer # bl $RUBY_TOOLS/passwords.rb
end

#mem?(i) ⇒ Boolean

#

mem?

#

Returns:

  • (Boolean)

3041
3042
3043
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3041

def mem?(i)
  ObjectSpace.memsize_of(i)
end

#merge_via_prawnObject

#

merge_via_prawn

Here we test how merging works through prawn. Unfortunately it does not work.

#

1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1598

def merge_via_prawn # rinvoke merge_via_prawn
  require 'prawn'
  pdf_file_paths = %w( one.pdf two.pdf three.pdf )
  store_new_pdf_here = 'result.pdf'
  Prawn::Document.generate(store_new_pdf_here, {page_size: 'A4', skip_page_creation: true}) { |pdf|
    pdf_file_paths.each { |pdf_file|
      if File.exists? pdf_file
        pdf_temp_nb_pages = Prawn::Document.new(template: pdf_file).page_count
        (1..pdf_temp_nb_pages).each { |i|
          pdf.start_new_page(template: pdf_file, template_page: i)
        }
      end
    }
  }
  e 'We should have stored into '+store_new_pdf_here+'.'
end

#methods?(from_this_module = Roebe) ⇒ Boolean

#

methods?

To use this in simpleirb, do:

require 'x/STD/custom_methods.rb'; methods?
#

Returns:

  • (Boolean)

1079
1080
1081
1082
1083
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1079

def methods?(from_this_module = Roebe)
  all_class_methods    = from_this_module.methods(false).sort
  all_instance_methods = from_this_module.instance_methods(false).sort
  return all_class_methods + all_instance_methods
end

#mini_fix_libtool_filesObject

#

mini_fix_libtool_files

This will fix libtool .la files in the current directory.

#

3822
3823
3824
3825
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3822

def mini_fix_libtool_files
  require 'rbt'
  RBT.fix_libtool_files
end

#miscObject

#

misc (misc tag)

Throwaway testing method.

#

1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1015

def misc
  # ======================================================================= #
  # batchrename
  # ======================================================================= #
  start_position   = 51
  down_to_position = 19
  start_position.downto(down_to_position).each {|counter|
    filename_in  = 'tears_of_ice_'+counter.to_s+'.ascii'
    filename_out = 'tears_of_ice_'+(counter+1).to_s+'.ascii'
    _ = 'mv '+filename_in+' '+filename_out
    e _
    system _
  }
  # tears_of_ice_45.ascii
end

#moleculargewicht(i) ⇒ Object

#

moleculargewicht

#

2219
2220
2221
2222
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2219

def moleculargewicht(i)
  require 'chemistry_paradise'
  e i+': '+ChemistryParadise.berechne_atomgewicht(i).to_s
end

#monthObject

#

month

Show the current month.

#

2902
2903
2904
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2902

def month
  StdConstants::CURRENT_MONTH
end

#mp3_to_ogg(i = ARGV) ⇒ Object

#

mp3_to_ogg

#

3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3543

def mp3_to_ogg(i = ARGV)
  unless Object.const_defined? :MultimediaParadise
    require 'multimedia_paradise'
  end
  if i.is_a? Array
    i.each {|entry| mp3_to_ogg(entry) }
  else
    MultimediaParadise::MultimediaConversions.mp3_to_ogg(i)
  end
end

#multi_ascii_splitter(char_limit, *args) ⇒ Object Also known as: mas

#

multi_ascii_splitter

#

1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1365

def multi_ascii_splitter(
    char_limit, *args
  )
  e " Arg leng is #{args.length} " if MY_DEBUG == 1
  ary_entries = args.length
  n           = 1
  char_count  = 0
  loop { 
    break if n == ary_entries
    if n % 2 == 1
      print args[n] if n % 2 == 0
      args[n].times { print args[n-1] }
      char_count += args[n]
    end
    n += 1
    puts if char_count == char_limit+1
  }
  e char_count if MY_DEBUG == 1
end

#mv(old_file, new_file, be_verbose = false) ⇒ Object Also known as: move_file

#

mv

#

3305
3306
3307
3308
3309
3310
3311
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3305

def mv(
    old_file,
    new_file,
    be_verbose = false
  )
  ::Roebe.mv(old_file, new_file, be_verbose)
end

#my_sym(target_location = ENV['SYSBIN']) ⇒ Object

#

my_sym

With this method we symlink ALL FILES in this_dir() to the (argument)location which defaults to /System/Executable It must be symlinked including the full absolute dir

Example:

my_sym "/System/Headers/SDL"
my_sym "/usr/lib/pkgconfig"
#

4126
4127
4128
4129
4130
4131
4132
4133
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4126

def my_sym(target_location = ENV['SYSBIN'])
  e 'Starting to Symlink'
  Dir.foreach( Dir.pwd ) { |tmp_var|
    next if tmp_var.start_with? '.'
    e 'Symlinking '+Dir.pwd+'/'+tmp_var+' to '+target_location+'/'+tmp_var
    File.symlink(Dir.pwd+"/"+tmp_var,target_location+'/'+tmp_var)
  }
end

#n_words(from_this_file = ARGV) ⇒ Object

#

n_words

n_words BLAAS

#

4747
4748
4749
4750
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4747

def n_words(from_this_file = ARGV)
  from_this_file = from_this_file.first if from_this_file.is_a? Array
  e File.read(from_this_file).scan(/\w+/).count.to_s+' words.'
end

#nano_addonsObject

#

nano_addons

#

810
811
812
# File 'lib/roebe/custom_methods/custom_methods.rb', line 810

def nano_addons
  ::Roebe.nano_addons
end

#ndirs?(i = Dir.pwd, output_result = true) ⇒ Boolean

#

ndirs?

This method will report how many directories are in this dir.

#

Returns:

  • (Boolean)

4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4660

def ndirs?(i = Dir.pwd, output_result = true)
  all_entries = get_all_files
  _ = all_entries.reject {|x| ! File.directory?(x)}
  _ = _.size
  if output_result
    e _
  else
    return _
  end
end

#newstud10Object

#

newstud10

#

3416
3417
3418
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3416

def newstud10
  ::Roebe.newstud10
end

#newstud11Object

#

newstud11

#

3423
3424
3425
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3423

def newstud11
  ::Roebe.newstud11
end

#newstud12Object

#

newstud12

#

3430
3431
3432
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3430

def newstud12
  ::Roebe.newstud12
end

#newstud13Object

#

newstud13

#

3437
3438
3439
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3437

def newstud13
  ::Roebe.newstud13
end

#newstud14Object

#

newstud14

#

3444
3445
3446
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3444

def newstud14
  ::Roebe.newstud14
end

#newstud15Object

#

newstud15

#

3451
3452
3453
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3451

def newstud15
  ::Roebe.newstud15
end

#newstud16Object

#

newstud16

#

3458
3459
3460
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3458

def newstud16
  ::Roebe.newstud16
end

#newstud17Object

#

newstud17

#

3465
3466
3467
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3465

def newstud17
  ::Roebe.newstud17
end

#newstud18Object

#

newstud18

#

3472
3473
3474
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3472

def newstud18
  ::Roebe.newstud18
end

#newstud19Object

#

newstud19

#

3479
3480
3481
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3479

def newstud19
  ::Roebe.newstud19
end

#newstud2Object

#

newstud2

#

3363
3364
3365
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3363

def newstud2
  ::Roebe.newstud2
end

#newstud20Object

#

newstud20

#

3486
3487
3488
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3486

def newstud20
  ::Roebe.newstud20
end

#newstud3Object

#

newstud3

This makes the tertiary newstud setting.

#

3356
3357
3358
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3356

def newstud3
  ::Roebe.newstud3
end

#newstud4Object

#

newstud4

This makes the quaternary newstud setting.

#

3372
3373
3374
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3372

def newstud4
  ::Roebe.newstud4
end

#newstud5Object

#

newstud5

This makes the fifth newstud setting.

#

3381
3382
3383
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3381

def newstud5
  ::Roebe.newstud5
end

#newstud6Object

#

newstud6

#

3388
3389
3390
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3388

def newstud6
  ::Roebe.newstud6
end

#newstud7Object

#

newstud7

#

3395
3396
3397
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3395

def newstud7
  ::Roebe.newstud7
end

#newstud8Object

#

newstud8

#

3402
3403
3404
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3402

def newstud8
  ::Roebe.newstud8
end

#newstud9Object

#

newstud9

#

3409
3410
3411
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3409

def newstud9
  ::Roebe.newstud9
end

#no_audio(file = ARGV.first) ⇒ Object

#

no_audio

#

3704
3705
3706
3707
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3704

def no_audio(file = ARGV.first)
  require 'multimedia_paradise/audio/remove_audio.rb'
  MultimediaParadise.remove_audio(file)
end

#non_asciiObject

#

non_ascii

This method will remove the .ascii suffix from files.

#

833
834
835
# File 'lib/roebe/custom_methods/custom_methods.rb', line 833

def non_ascii
  ::Roebe.non_ascii
end

#objects?Boolean

#

objects?

This method will retrieve all objects in ObjectSpace.

#

Returns:

  • (Boolean)

3186
3187
3188
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3186

def objects?
  ObjectSpace.each_object(Class) { |c| printf("%s\n", c.to_s) }
end

#odd_or_even(i) ⇒ Object

#

odd_or_even

Invocation examples:

odd_or_even 555
odd_or_even 42
#

1821
1822
1823
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1821

def odd_or_even(i)
  i.odd? ? 'odd':'even'
end

#opal(i) ⇒ Object

#

opal

#

386
387
388
389
# File 'lib/roebe/custom_methods/custom_methods.rb', line 386

def opal(i)
  require_opal
  Opal.compile(i)
end

#open?Boolean Also known as: ports?

#

open?

Returns all open ports on your system

#

Returns:

  • (Boolean)

4979
4980
4981
4982
4983
4984
4985
4986
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4979

def open?
  require 'x/std/std_modules.rb'
  require 'socket'
  StdModules::Ports.open?.each { |open_port|
    s = Socket.getnameinfo(['AF_INET',open_port, 'localhost'])
    e "Port #{open_port} (#{s[1]}) ist offen."
  }
end

#open_in_browser(i = ARGV) ⇒ Object

#

open_in_browser

#

561
562
563
# File 'lib/roebe/custom_methods/custom_methods.rb', line 561

def open_in_browser(i = ARGV)
  ::Roebe.open_in_browser(i)
end

#open_in_editor(i = ARGV) ⇒ Object

#

open_in_editor (open tag)

Open a file in the editor with this method.

#

446
447
448
449
450
# File 'lib/roebe/custom_methods/custom_methods.rb', line 446

def open_in_editor(
    i = ARGV
  )
  Roebe.open_in_editor(i)
end

#opnnObject

#

opnn

#

568
569
570
# File 'lib/roebe/custom_methods/custom_methods.rb', line 568

def opnn
  ::Roebe.opnn
end

#optionparser?Boolean

#

optionparser?

#

Returns:

  • (Boolean)

1485
1486
1487
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1485

def optionparser?
  cat RUBY_SRC_DIR+'test/minimal_optparse_example.rb'
end

#output_array_from_beautiful_menuObject

#

rinvoke output_array_from_beautiful_menu

#

1933
1934
1935
1936
1937
1938
1939
1940
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1933

def output_array_from_beautiful_menu
  require 'case_parser'
  require 'roebe/requires/failsafe_require_of_beautiful_url.rb'
  array = CaseParser[RUBY_SRC_DIR+'beautiful_url/lib/beautiful_url/menu/beautiful_menu.rb'].flatten
  array.each {|entry|
    e "#{entry} -> #{BeautifulUrl.fetch_value(entry).to_s}"
  }
end

#pathnameObject

#

pathname

#

2758
2759
2760
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2758

def pathname
  require 'pathname'
end

#pexit(*args) ⇒ Object

#

pexit

To output stuff.

#

3893
3894
3895
3896
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3893

def pexit(*args)
  args.each {|entry| e entry }
  exit
end

#pidObject

#

pid

#

2765
2766
2767
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2765

def pid
  require 'pidify'
end

#ping(i) ⇒ Object

#

ping

#

2352
2353
2354
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2352

def ping(i)
  system i
end

#play(i) ⇒ Object

#

play

#

967
968
969
970
971
972
973
# File 'lib/roebe/custom_methods/custom_methods.rb', line 967

def play(i)
  if i.is_a? Array
    i.each {|entry| play(entry) }
  else
    esystem 'mplayer '+i
  end
end

#play_columbo_filesObject Also known as: columbo

#

play_columbo_files

Play all columbo files.

#

2054
2055
2056
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2054

def play_columbo_files
  Roebe.play_columbo_files
end

#play_midi(i = HOME_DIRECTORY_OF_USER_X+'DATA/AUDIO/MIDI/al_adagi.mid') ⇒ Object

#

play_midi

Play a .mid file through this method.

#

3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3714

def play_midi(
    i = HOME_DIRECTORY_OF_USER_X+'DATA/AUDIO/MIDI/al_adagi.mid'
  )
  if File.exist?(i)
    require 'midilib'
    require 'midilib/io/seqreader'
    seq = MIDI::Sequence.new()
    # Read the contents of a MIDI file into the sequence.
    File.open(i, 'rb') { |file|
      seq.read(file) { |track, num_tracks, track_number|
        # Print something when each track is read.
        e "read track #{track_number} of #{num_tracks}"
      }
    }
  else
    e 'File '+i+' does not exist.'
  end
end

#play_random_simpsons_movieObject Also known as: simpson_movie

#

play_random_simpsons_movie

#

1034
1035
1036
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1034

def play_random_simpsons_movie
  ::Roebe.play_random_simpsons_movie
end

#populate_the_main_ENV_variable_with_data_from_custom_yaml_fileObject

#

populate_the_main_ENV_variable_with_data_from_custom_yaml_file

#

5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
# File 'lib/roebe/custom_methods/custom_methods.rb', line 5092

def populate_the_main_ENV_variable_with_data_from_custom_yaml_file
  array_work_on_these_yaml_files = []
  array_work_on_these_yaml_files <<
    '/home/x/programming/ruby/src/rcfiles/lib/rcfiles/yaml/system_settings.yml'
  array_work_on_these_yaml_files <<
    '/home/x/data/personal/yaml/roeberia_settings.yml'
  array_work_on_these_yaml_files.each {|this_yaml_file|
    if File.exist? this_yaml_file
      dataset = YAML.load_file(this_yaml_file)
      dataset.each_pair {|key, value|
        key = key.to_s
        value = value.to_s
        ENV[key] = value unless ENV.has_key? key
      }
    end
  }
end

#port_strObject

#

port_str

This can, on Linux, determine the port_str.

#

3595
3596
3597
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3595

def port_str
  `ls /dev`.split("\n").grep(/usb|ACM/i).map{|d| "/dev/#{d}"}
end

#ppexit(*args) ⇒ Object

#

ppexit

prettyprint argument, then exit. Useful for debugging.

#

3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3250

def ppexit(*args)
  args.each { |arg|
    puts ' ---------------------------------------- '
    puts # __FILE__
    puts ' In ppexit() of '+$PROGRAM_NAME+','
    puts __LINE__.to_s+' the class of our arg (START)'
    pp arg
    puts 'was '+arg.class.to_s
    puts; puts;puts '---' * 80
    puts;puts ' :: These were our real arg:'
    pp arg
    puts;puts '---' * 80; puts
    puts ' ---------------------------------------- '
  }
  exit # now exiting.
end

#prepare_gccObject

#

prepare_gcc

This will install the MPFR etc… packages.

#

747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
# File 'lib/roebe/custom_methods/custom_methods.rb', line 747

def prepare_gcc # pgcc
  begin
    require 'rbt'
  rescue LoadError; end
  gcc = RBT::Cookbooks::SanitizeCookbooks.new('gcc4')
  dataset = gcc.data?
  e 'Now preparing GCC things.'
  e '  '+dataset['program_path']
  dataset = RBT::Cookbooks::SanitizeCookbooks.new('mpfr').data?
  e '(1) First, we tackle MPFR:'
  e '  '+dataset['program_path']
  # We extract this to the current working directory
  extract_what_to(dataset['program_path'], Dir.pwd)
  symlink dataset['program_name'], dataset['short_name']
  dataset = RBT::Cookbooks::SanitizeCookbooks.new('gmp').data?
  e '(2) First, we tackle GMP:'
  e '  '+dataset['program_path']
  extract_what_to(dataset['program_path'], Dir.pwd)
  symlink dataset['program_name'], dataset['short_name']
  dataset = RBT::Cookbooks::SanitizeCookbooks.new('mpc').data?
  e '(2) First, we tackle MPC:'
  e '  '+dataset['program_path']
  extract_what_to(dataset['program_path'], Dir.pwd)
  symlink dataset['program_name'], dataset['short_name']
  e 'Finished!'
end

#privObject

#

priv

output what ruby can do

#

668
669
670
# File 'lib/roebe/custom_methods/custom_methods.rb', line 668

def priv
  e Object.private_instance_methods.sort
end

#process_killObject

#

kill

Unfinished snippets:

PID killin bot
#

2893
2894
2895
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2893

def process_kill
  get_pid { |pid| Process.kill(SIGTERM, @pid) if pid }
end

#pty_spawnObject

#

pty_spawn

#

5084
5085
5086
5087
# File 'lib/roebe/custom_methods/custom_methods.rb', line 5084

def pty_spawn
  require 'pty'
  return PTY.spawn
end

#purge_invalid_yaml_directories_from_programs_hierarchyObject

#

purge_invalid_yaml_directories_from_programs_hierarchy

#

3800
3801
3802
3803
3804
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3800

def purge_invalid_yaml_directories_from_programs_hierarchy
  results = Dir['/Programs/**/**'].select {|entry| entry.end_with? '/yaml' }
  results.select! {|entry| entry.count('/') == 3 }
  remove_directory(results)
end

#putssystem(i) ⇒ Object

#

putssystem

#

4491
4492
4493
4494
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4491

def putssystem(i)
  e i
  system i
end

#pwdObject

#

pwd

#

4005
4006
4007
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4005

def pwd
  e Dir.pwd
end

#python_has_bz2?Boolean

#

python_has_bz2?

#

Returns:

  • (Boolean)

278
279
280
# File 'lib/roebe/custom_methods/custom_methods.rb', line 278

def python_has_bz2?
  esystem '/usr/bin/python -c "import bz2; print(bz2.__doc__)"'
end

#qObject Also known as: rda, qu, qi, i

#

q (q tag. quit tag. Roebe::q)

#

177
178
179
# File 'lib/roebe/custom_methods/custom_methods.rb', line 177

def q
  exit
end

#question1Object

#

question1

#

2962
2963
2964
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2962

def question1
  ask_a_question_based_on_this_pwdstud_entry 1
end

#question2Object

#

question2

#

2969
2970
2971
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2969

def question2
  ask_a_question_based_on_this_pwdstud_entry 2
end

#question3Object

#

question3

#

2976
2977
2978
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2976

def question3
  ask_a_question_based_on_this_pwdstud_entry 3
end

#question4Object

#

question4

#

2983
2984
2985
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2983

def question4
  ask_a_question_based_on_this_pwdstud_entry 4
end

#question5Object

#

question5

#

2990
2991
2992
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2990

def question5
  ask_a_question_based_on_this_pwdstud_entry 5
end

#rack_handlers?Boolean

#

rack_handlers?

#

Returns:

  • (Boolean)

4904
4905
4906
4907
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4904

def rack_handlers?
  require 'rack'
  return Rack::Handler.constants
end

#rails?Boolean

#

rails?

#

Returns:

  • (Boolean)

4033
4034
4035
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4033

def rails?
  e 'http://127.0.0.1:3000/'
end

#random_numberObject

#

random_number

#

2235
2236
2237
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2235

def random_number
  e rand(35)+1
end

#range(up_to_this_number = 10, start_number = 1) ⇒ Object

#

range

range(10,1000,6) <- von 10 bis 1000 gehe in 6-er schritten vor.

#

3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3139

def range(
    up_to_this_number = 10,
    start_number      =  1
  )
  array = []
  start_number.upto(up_to_this_number) {|number|
    array << number
  }
  array
end

#raw_dirObject

#

raw_dir

Usage example from within irb:

x = raw_dir; x.keys?; filesize = x.filesize?
#

379
380
381
# File 'lib/roebe/custom_methods/custom_methods.rb', line 379

def raw_dir
  return DirectoryParadise::Content.new
end

#rbtObject

#

rbt

#

415
416
417
# File 'lib/roebe/custom_methods/custom_methods.rb', line 415

def rbt
  require 'rbt'
end

#rcfiles(i = ARGV) ⇒ Object

#

rcfiles

#

241
242
243
244
245
246
247
248
# File 'lib/roebe/custom_methods/custom_methods.rb', line 241

def rcfiles(i = ARGV)
  require 'rcfiles'
  Rcfiles.parse_commandline(i)
  if Rcfiles.is_on_roebe?
    require 'rcfiles/aggregate_all_rcfiles/aggregate_all_rcfiles.rb'
    Rcfiles::AggregateAllRcfiles.new
  end
end

#read_line(of_this_file = ARGV.first, line_number = ARGV[1]) ⇒ Object

#

read_line

rinvoke read_line zip.rb 2

#

2427
2428
2429
2430
2431
2432
2433
2434
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2427

def read_line(
    of_this_file = ARGV.first,
    line_number  = ARGV[1]
  )
  line_number = 1 if line_number.nil?
  array = File.readlines(of_this_file)
  e array[line_number.to_i - 1, 1]
end

#readable_int(num) ⇒ Object

#

readable_int

This one does the following: take a int, and outputs it in easy readable format.

Try it like so:

puts readable_int(555666252) # => 555_666_252

Alternatively use this oneliner:

def readable_int(num); num.to_s.reverse.gsub(/(\d\d\d)\b/,'_\1').reverse; end
#

2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2615

def readable_int(num)
  cnt = 0
  return_value = ''
  num.to_s.each_char { |tmp|
    return_value << tmp
    cnt += 1
    return_value << '_' if cnt % 3 == 0
  }
  return_value.chop! if return_value.end_with? '_'
  return return_value
end

#register_irc?Boolean

#

register_irc?

#

Returns:

  • (Boolean)

1041
1042
1043
1044
1045
1046
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1041

def register_irc?
  require 'xorg_buffer'
  _ = '/msg nickserv identify 1aaaaaa'
  e _
  set_xorg_buffer(_.chomp)
end

#register_sigintObject

#

register_sigint

#

3102
3103
3104
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3102

def register_sigint
  self.register_sigint
end

#registered_pipe_actions?Boolean

#

registered_pipe_actions?

#

Returns:

  • (Boolean)

617
618
619
620
621
622
623
624
# File 'lib/roebe/custom_methods/custom_methods.rb', line 617

def registered_pipe_actions?
  require 'pipe_handler'
  require 'colours_e/autoinclude'
  PipeHandler.allowed_actions.each_with_index {|entry, index|
    index += 1
    e royalblue(index.to_s.rjust(3)+') ')+yellowgreen(entry)
  }
end

#reject_blanks(input = ARGF.read) ⇒ Object

#

reject_blanks

This method will reject blank entries.

#

2589
2590
2591
2592
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2589

def reject_blanks(input = ARGF.read)
  array = input.split("\n").reject {|entry| entry.to_s.empty? }
  pp array
end

#remote_file_listing(url = 'http://curl.haxx.se/download/') ⇒ Object

#

remote_file_listing

This method allows you to list which files are found at a remote site.

#

4560
4561
4562
4563
4564
4565
4566
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4560

def remote_file_listing(
    url = 'http://curl.haxx.se/download/'
  )
  require 'ftp_paradise'
  _ = FtpParadise.connect to: url
  pp _.return_entries  
end

#remove(i) ⇒ Object

#

remove

#

2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2335

def remove(i)
  if i.is_a? Array
    i.each {|entry| remove(entry) }
  else
    if File.exist? i
      # =================================================================== #
      # We will never remove the / directory, from within the Roebe
      # project.
      # =================================================================== #
      FileUtils.rm_rf(i) unless i.squeeze('/') == '/'
    end
  end
end
#

rinvoke remove_all_symlinks

#

2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2317

def remove_all_symlinks
  entries = Dir['*'].select {|entry|
    ! File.exist?(entry)
  }
  entries.each {|entry|
    e "Now working on entry `#{sfile(entry)}`."
    if File.ftype(entry) == 'link'
      unless File.exist? entry
        e 'Now removing entry `'+sfile(entry)+'`.'
        File.delete entry
      end
    end
  }
end

#remove_directory(i, delete_only_empty_directories = false) ⇒ Object

#

remove_directory

This method can be used to delete directories.

#

529
530
531
532
533
534
# File 'lib/roebe/custom_methods/custom_methods.rb', line 529

def remove_directory(
    i,
    delete_only_empty_directories = false
  ) # Delegate into .remove_directory()
  ::Roebe.remove_directory(i, delete_only_empty_directories)
end

#remove_numbers(input = 'test123') ⇒ Object

#

remove_numbers

#

1431
1432
1433
1434
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1431

def remove_numbers(input = 'test123')
  input.gsub!(/\d/,'')
  e input
end

#remove_old_gemObject

#

remove_old_gem

#

4926
4927
4928
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4926

def remove_old_gem
  ::Roebe.remove_old_gem
end

#rename(old, new) ⇒ Object

#

rename (rename tag)

#

3941
3942
3943
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3941

def rename(old, new)
  FileUtils.mv(old, new)
end

#rename_allObject

#

rename_all

To use it, do:

rinvoke rename_all
#

4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4962

def rename_all
  require 'fileutils'
  entries = Dir['*']
  entries.each {|entry|
    if entry.include? "\b"
      new_name = entry.gsub(/\b/,'ü')
      e 'Now renaming `'+entry+'` to `'+new_name+'`.'
      FileUtils.mv(entry, new_name)
    end
  }
end

#rename_ascii_filesObject

#

rename_ascii_files

This will batch-rename some .ascii files.

#

1006
1007
1008
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1006

def rename_ascii_files
  ::Roebe.rename_ascii_files
end

#rep(how_many_times) ⇒ Object

#

rep

rep(3) {|t| puts 'gekeg' } rep(3) {|t| puts }

#

4279
4280
4281
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4279

def rep(how_many_times)
  how_many_times.times {|t| yield t }
end

#replace_double_underscoresObject

#

replace_double_underscores

This method will replace __ underscores with _.

#

255
256
257
258
259
# File 'lib/roebe/custom_methods/custom_methods.rb', line 255

def replace_double_underscores
  require 'roebe/classes/replace_space_with_underscore/replace_space_with_underscore.rb'
  array = ['__','_']
  Roebe::ReplaceSpaceWithUnderscore.new(array)
end

#report_pwdObject

#

report_pwd

#

944
945
946
# File 'lib/roebe/custom_methods/custom_methods.rb', line 944

def report_pwd
  e ::Colours.steelblue(return_pwd)
end

#require_opalObject Also known as: ropal

#

require_opal

#

394
395
396
# File 'lib/roebe/custom_methods/custom_methods.rb', line 394

def require_opal
  require 'opal'
end

#reset_irbObject

#

reset_irb

#

302
303
304
# File 'lib/roebe/custom_methods/custom_methods.rb', line 302

def reset_irb
  exec($0)
end

#resize_images_for_my_mom(resize_n_percent = '15') ⇒ Object

#

resize_images_for_my_mom

This should be similar to:

convert terminal.gif  -resize 64x64  resize_terminal.gif
#

3342
3343
3344
3345
3346
3347
3348
3349
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3342

def resize_images_for_my_mom(resize_n_percent = '15')
  all_images = Dir['*']
  all_images.each {|image|
    _ = 'convert '+image+' -resize '+
         resize_n_percent.to_s+'% '+'resized_'+File.basename(image) 
    esystem _
  }
end

#restore?Boolean

#

restore?

#

Returns:

  • (Boolean)

5013
5014
5015
5016
5017
5018
# File 'lib/roebe/custom_methods/custom_methods.rb', line 5013

def restore?
  e '# Store the state of the terminal'
  e 'stty_save = `stty -g`.chomp'
  e 'rescue Interrupt'
  e "system('stty', stty_save) # Restore"
end

#restore_kdeObject

#

restore_kde

rinvoke restore_kde

#

2116
2117
2118
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2116

def restore_kde
  Roebe::RestoreKde.new
end

#restore_stdout?Boolean

#

restore_stdout?

#

Returns:

  • (Boolean)

1945
1946
1947
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1945

def restore_stdout?
  e '$stdout = STDOUT'
end

#ret_ftype(file = '') ⇒ Object

#

ret_ftype

Returns the file type.

#

4254
4255
4256
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4254

def ret_ftype(file = '')
  file[-3, 3]
end

#return_pwdObject

#

return_pwd

#

937
938
939
# File 'lib/roebe/custom_methods/custom_methods.rb', line 937

def return_pwd
  ("#{Dir.pwd}/").squeeze('/')
end

#rf(i) ⇒ Object

#

rf

#

2521
2522
2523
2524
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2521

def rf(i)
  require 'roebe/browser/firefox.rb'
  Roebe.firefox(i)
end

#rfeedback(i = ARGV) ⇒ Object

#

rfeedback

rfeedback gtk2 htop geany

#

4243
4244
4245
4246
4247
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4243

def rfeedback(i = ARGV)
  require 'rbt'
  _ = RBT::NewInstaller.new
  _.feedback_urls(i)
end

#rm(i) ⇒ Object

#

rm (rm tag)

Remove a file via FileUtils.

#

5002
5003
5004
5005
5006
5007
5008
# File 'lib/roebe/custom_methods/custom_methods.rb', line 5002

def rm(i)
  if File.file? i
    remove_file(i)
  else
    FileUtils.rm(i)
  end
end

#rmax(string = ARGV.first) ⇒ Object

#

rmax

rinvoke max

#

2451
2452
2453
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2451

def rmax(string = ARGV.first)
  e string.split("\n").max
end

#round(i, round_to_n_places = 3) ⇒ Object

#

round

#

1423
1424
1425
1426
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1423

def round(i, round_to_n_places = 3)
  i = i.to_f unless i.is_a? Float
  return i.round(round_to_n_places)
end

#rsongObject

#

rsong

Returns a random song.

#

3934
3935
3936
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3934

def rsong
  get_file_listing(ENV['MY_SONGS'].to_s, true).sample
end

#rsplitObject

#

rsplit

rinvoke rsplit rsplit 'slalal:a:asasasf:'

#

2442
2443
2444
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2442

def rsplit
  STDIN.read.split(':').each { |_| e _ }
end

#ruby_download(i = ARGV) ⇒ Object

#

ruby_download

#

4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4408

def ruby_download(i = ARGV)
  if i.is_a? Array
    i.each {|entry| ruby_download(entry) }
  else # Do the download here.
    store_here = File.basename(i)
    e 'Now storing into the file '+store_here
    # save_file( open(i, 'rb').read, store_here)
    open(store_here, 'wb') { |file|
      file << open(i).read
    }
  end
end

#ruby_headerObject

#

ruby_header

This can also be invoked via:

Roebe.ruby_header
#

3121
3122
3123
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3121

def ruby_header
  self.ruby_header
end

#ruby_mainObject

#

ruby_main

rinvoke ruby_main

#

3130
3131
3132
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3130

def ruby_main
  self.ruby_main
end

#rubycalc(i = ARGV) ⇒ Object

#

rubycalc

#

234
235
236
# File 'lib/roebe/custom_methods/custom_methods.rb', line 234

def rubycalc(i = ARGV)
  ::Roebe.rubycalc(i)
end

#rubycolObject Also known as: rubycolours

#

rubycol

#

4897
4898
4899
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4897

def rubycol
  Colours.test
end

#run_cfdgObject

#

run_cfdg

rinvoke run_cfdg

#

552
553
554
555
556
# File 'lib/roebe/custom_methods/custom_methods.rb', line 552

def run_cfdg
  require 'image_paradise'
  @confree_generator = ImageParadise::ConfreeGenerator.new
  @confree_generator.run_batchmode
end

#sanitize_uptime(inp, language_used = 'german') ⇒ Object

#

sanitize_uptime

We sanitize our uptime. We can lateron generalize this…

#

1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1750

def sanitize_uptime(inp, language_used = 'german')
  inp = inp.to_f

  wie_viele_stunden = ( inp.to_f/EINE_STUNDE.to_f ).to_i
  inp -= EINE_STUNDE * wie_viele_stunden
  wie_viele_minuten = ( inp.to_f/EINE_MINUTE.to_f ).to_i

  case language_used.downcase
  when 'german'
    hours   = 'Stunden'
    minutes = 'Minuten'
  when 'english'
    hours   = 'Hours'
    minutes = 'Minutes'
  else
    hours   = 'unknown unique_90290'
    minutes = 'unknown unique_90290'
  end
  return "#{wie_viele_stunden} #{hours} und #{wie_viele_minuten} #{minutes}"
end

#save_yaml(i) ⇒ Object

#

save_yaml

save_yaml 1..100

#

327
328
329
330
331
# File 'lib/roebe/custom_methods/custom_methods.rb', line 327

def save_yaml(i)
  save_into_this_file = 'test.yml'
  puts 'Now storing data into '+save_into_this_file
  File.open(save_into_this_file, 'w+') {|f| YAML.dump(i, f)}
end

#say(i = ARGV) ⇒ Object

#

say

Simply a say alias.

Commandline invocation:

rinvoke say ok
#

2945
2946
2947
2948
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2945

def say(i = ARGV)
  i = i.join(' ') if i.is_a? Array
  puts 'You speak: "'+i+'"'
end

#sdlObject

#

sdl

#

401
402
403
# File 'lib/roebe/custom_methods/custom_methods.rb', line 401

def sdl
  require 'sdl'
end

#setup_gitObject Also known as: enable_git

#

setup_git

enable_git

#

3961
3962
3963
3964
3965
3966
3967
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3961

def setup_git
  system 'git config --global user.name "Robert A. Heiler"'
  system 'git config --global user.email [email protected]'
  system 'git config --global color.ui auto'
  system 'git config --global core.autocrlf false'
  system 'git config --global core.filemode false'
end

#sfancy(i) ⇒ Object

#

sfancy

#

1588
1589
1590
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1588

def sfancy(i)
  Colours.sfancy(i)
end

#show_all_256_coloursObject

#

show_all_256_colours

Show the 256 colours, from the Colours gem.

#

3495
3496
3497
# File 'lib/roebe/custom_methods/custom_methods.rb', line 3495

def show_all_256_colours
  Roebe.show_all_256_colours
end

#show_fc_listObject

#

show_fc_list

#

658
659
660
661
# File 'lib/roebe/custom_methods/custom_methods.rb', line 658

def show_fc_list
  _ = 'fc-list : file'
  esystem _
end

#show_iso_encoding(i = nil) ⇒ Object Also known as: show_encoding

#

show_encoding

This will show the ISO encoding.

#

1309
1310
1311
1312
# File 'lib/roebe/custom_methods/custom_methods.rb', line 1309

def show_iso_encoding(i = nil)
  e "'#{i.inspect} is #{i.encoding.name}" if i
  e '# Encoding: ISO-8859-1'
end

#show_regex(input_data, regEx) ⇒ Object

#

show_regex

Show regex stuff

#

2393
2394
2395
2396
2397
2398
2399
2400
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2393

def show_regex(input_data, regEx) 
  e "Regex war #{regEx}",'yelb'
  if input_data =~ regEx
    "#{$PREMATCH} MATCH=> #{$MATCH} <=MATCH #{$POSTMATCH}" 
  else
    'no match'
  end 
end

#show_registered_binariesObject

#

show_registered_binaries

#

2044
2045
2046
2047
# File 'lib/roebe/custom_methods/custom_methods.rb', line 2044

def show_registered_binaries
  require 'rbt'
  RBT.show_registered_binaries
end

#show_rubylibdirObject

#

show_rubylibdir

#

4026
4027
4028
# File 'lib/roebe/custom_methods/custom_methods.rb', line 4026

def show_rubylibdir
  e RbConfig::CONFIG['rubylibdir']
end

#show_the_irb_historyObject Also known as: history

#

show_the_irb_history

#

474
475
476
# File 'lib/roebe/custom_methods/custom_methods.rb', line 474

def show_the_irb_history
  ::Roebe::CustomMethods.show_the_irb_history
end

#show_yaml_syntaxObject

#

show_yaml_syntax

rinvoke show_yaml_syntax

#

338
339
340
341
342
# File 'lib/roebe/custom_methods/custom_methods.rb', line 338

def show_yaml_syntax
  e 'begin'
  e "  YAML::ENGINE.yamler = 'syck' if RUBY_VERSION >= '1.9'".strip
  e 'rescue NameError; end'
end

#silence_warnings