سكربتات بالروبي
+ اسكربتات قمت بكتابتها بالروبي
1- L33t_Convertor
– سكربت يقوم بتحويل جملة تقوم بكتابتها باللغة الإنجليزية إلى لغة الأرقام والرموز والمسماه (L33t ).
#!/usr/bin/env ruby puts "\t\t\tTh1S C0dE WaS WrittEn By" puts "\t\t\t\tMutati0N" puts "\t\t\tU N33D 2 l3arN M0r3!!!\n\n" #l33T Convertor : Script Convert the English Language #to the l33t language . #You can Get More Information About leet on #(http://en.wikipedia.org/wiki/Leet) require "jcode" alphabet = ['4','8','[','|>','3','|=','6','/-/', '1','_/','|','<|', '|?','$','7','(_)','\/','vv','}{','`/','2'] puts "\t\tWellcome to the l33t Converter V1.0\n" print "* Enter the Statement U want to Convert:" l33t = gets.chomp.downcase l33t.each_char do |char| if char == "a" char = alphabet[0] elsif char== "b" char = alphabet[1] elsif char == "c" char = alphabet[2] elsif char == "d" char = alphabet[3] elsif char == "e" char = alphabet[4] elsif char== "f" char = alphabet[5] elsif char == "g" char = alphabet[6] elsif char == "h" char = alphabet[7] elsif char == "i" char = alphabet[8] elsif char== "j" char = alphabet[9] elsif char == "k" char = alphabet[10] elsif char == "l" char = alphabet[11] elsif char == "m" char = alphabet[12] elsif char== "n" char = alphabet[13] elsif char == "o" char = alphabet[14] elsif char == "p" char = alphabet[15] elsif char == "q" char = alphabet[16] elsif char== "r" char = alphabet[17] elsif char == "s" char = alphabet[18] elsif char == "t" char = alphabet[19] elsif char == "u" char = alphabet[20] elsif char == "v" char = alphabet[21] elsif char== "w" char = alphabet[22] elsif char == "x" char = alphabet[23] elsif char == "y" char = alphabet[24] elsif char == "z" char = alphabet[25] end print "#{char}" end puts "" ##EnD 0F My C0dE!!!
2- L33t_Convertor
– الإصدارة الثانية من محول الاسكربت، وفيه تم إستبدال الـ if/else بعبـارة case مع وضع الناتج في مجلد نصي في ملف اسمه L33t.txt في مجلد الـ Home.
#!/usr/bin/env ruby puts "\t\t\tTh1S C0dE WaS WrittEn By" puts "\t\t\t\tMutati0N" puts "\t\t\tU N33D 2 l3arN M0r3!!!\n\n" #l33T Convertor 1S Script thats Convert the English #Languages to the l33t languages (Numbers) . #MorE Informtion About l33t on #(http://en.wikipedia.org/wiki/Leet) puts "\t\t## Wellcome to the l33t Converter V1.5 ##\n" require 'jcode' $__output__= '' print "Please Enter the Phrase:" $l33t = gets.chomp.downcase alphabet = ['4','8','[','|>','3','|=','6','/-/', '1','_/','|', '<|','|?','$','7','(_)','\/','vv','}{','`/','2'] $l33t.each_char do |char| case char when "a": char = alphabet[0] when "b": char = alphabet[1] when "c": char = alphabet[2] when "d" : char = alphabet[3] when "e" : char = alphabet[4] when "f" : char = alphabet[5] when "g" : char = alphabet[6] when "h" : char = alphabet[7] when "i" : char = alphabet[8] when "j" : char = alphabet[9] when "k" : char = alphabet[10] when "l" : char = alphabet[11] when "m" : char = alphabet[12] when "n" : char = alphabet[13] when"o" : char = alphabet[14] when "p" : char = alphabet[15] when "q" : char = alphabet[16] when "r" : char = alphabet[17] when "s" : char = alphabet[18] when "t" : char = alphabet[19] when "u" : char = alphabet[20] when "v" : char = alphabet[21] when "w" : char = alphabet[22] when"x" : char = alphabet[23] when "y" : char = alphabet[24] when "z" : char = alphabet[25] end $__output__ << char end location = (ENV['HOME'] + '/L33t.txt' ) new_file = File.new(location , 'w+' ) new_file.puts $__output__ new_file.close ##EnD 0F My C0dE!!!
3- ls
– سكربت بسيط بيعمل عمل الأمر ls فهو يعرض لك المحتوى الموجود في ديريكتوري معين تقوم بتحديده ونوع كل ملف جواه .
* الاستخدام :
ruby ls-0.1.rb path_of_directory
* مثال :
ruby ls-0.1.rb /media/Magrabi
بحيث path_of_directory هو امتداد الديريكتوري الذى تريد إظهار المحتوى الموجود بداخله.
#!/usr/bin/env ruby # Written By Mutati0N def list_files(path= ARGV[0]) if File.directory?(path) Dir.foreach(path) do |results| next if results == ".." || results == "." puts "#{results} -> #{File.ftype("#{path}" + '/' + "#{results}")}" end end end list_files
Emptyfolders -4
– سكربت وظيفته البحث عن المجلدات الفارغه في قسم تقوم بتحديده، و يعمل على حذفها مع إظهار مكان المجلدات الفارغة التي تم مسحها، فكثير منا يترك مجلدات فارغة دون أن يحذفها، ويجد بعد ذلك صعوبه في البحث عنهم وحذفهم، وهذا الاسكربت يوفر الوقت ويعمل علي حذفهم .
* كيفية الإستخدام :
ruby Emptyfolders.rb path_of_directory
* مثال :
ruby Emptyfolders.rb /media/MagrabI
def delete_empty_folders(path= ARGV[0]) Dir.glob(File.join(path,"**","**")).each do |all_dirs| next if File.file?(all_dirs) next if !"#{Dir.entries(all_dirs)-["..","."]}".empty? puts File.expand_path(all_dirs) Dir.delete(all_dirs) end end begin delete_empty_folders rescue puts "-You forget somthing!!\n* Usage: ruby Emptyfolders.rb path_of_the_directory" end