This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'set' | |
| require 'forwardable' | |
| set = SortedSet.new([8,6,4,2,0,5,9,66,8]) | |
| p set # => #<SortedSet: {0, 2, 4, 5, 6, 8, 9, 66}> | |
| # How to implement the same 'SortedSet' functionality on your own | |
| class SortedList | |
| include Enumerable | |
| extend Forwardable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def bubble_sort(array) | |
| n = array.length | |
| loop do | |
| swapped = false | |
| (n-1).times do |i| | |
| # if the item that comes first in the array is bigger than that comes next | |
| # then resort it | |
| if array[i] > array[i+1] | |
| array[i], array[i+1] = array[i+1], array[i] | |
| swapped = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| first_names = ["Ahmad", "Ahmad", "Emad"] | |
| last_names = ["Hamdi", "Magdi", "Elsaid"] | |
| first_names.zip(last_names).inspect |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| puts 'Renaming files...' | |
| # a parameter to the program from command line. | |
| folder_path = ARGV[0] # /Users/a7madx7/Pictures/WallPapers | |
| Dir.glob(folder_path + "/*").sort.each_with_index do |f, i| | |
| # prepare a the brand new 'renamed' complete file path. | |
| new_name = File.dirname(f) + '/' + i.to_s + File.extname(f) | |
| # do the actual renaming of the file. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Ahmads-Mac-Pro:~ a7madx7$ rvm remove all | |
| Are you SURE you wish to 'remove' all rubies? | |
| (anything other than 'yes' will cancel) > yes | |
| ruby-2.2.0 - #removing src/ruby-2.2.0.. | |
| ruby-2.2.0 - #removing rubies/ruby-2.2.0.. | |
| Ahmads-Mac-Pro:~ a7madx7$ rvm pkg install libyaml | |
| Beware, 'rvm pkg ...' is deprecated, read about the new autolibs feature: 'rvm help autolibs'. | |
| Checking requirements for osx. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Ahmads-Mac-Pro:~ a7madx7$ cat /Users/a7madx7/.rvm/log/1421056561_ruby-2.2.0/install.log | |
| [2015-01-12 11:58:33] __rvm_make | |
| __rvm_make () | |
| { | |
| \make "$@" || return $? | |
| } | |
| current path: /Users/a7madx7/.rvm/src/ruby-2.2.0 | |
| PATH=/usr/local/opt/pkg-config/bin:/usr/local/Cellar/libtool/2.4.2/bin:/usr/local/opt/automake/bin:/usr/local/opt/autoconf/bin:/Users/a7madx7/.rbenv/shims:/Users/a7madx7/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/a7madx7/.rvm/bin | |
| command(2): __rvm_make install | |
| ++ make install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rvm install 2.2.0 | |
| Searching for binary rubies, this might take some time. | |
| No binary rubies available for: osx/10.10/x86_64/ruby-2.2.0. | |
| Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. | |
| Checking requirements for osx. | |
| Certificates in '/usr/local/etc/openssl/cert.pem' are already up to date. | |
| Requirements installation successful. | |
| Installing Ruby from source to: /Users/a7madx7/.rvm/rubies/ruby-2.2.0, this may take a while depending on your cpu(s)... | |
| ruby-2.2.0 - #downloading ruby-2.2.0, this may take a while depending on your connection... | |
| ruby-2.2.0 - #extracting ruby-2.2.0 to /Users/a7madx7/.rvm/src/ruby-2.2.0.... |
NewerOlder