##Download a repository with submodules
git clone URL MAIN_REPO_DIR
git submodule init
git submodule update##Add a submodule
cd MAIN_REPO_DIR| sudo add-apt-repository ppa:yannubuntu/boot-repair | |
| sudo apt-get update | |
| sudo apt-get install -y boot-repair | |
| boot-repair |
| #!/usr/bin/env ruby | |
| # quotes.rb | |
| # Picks a random quote from quotes.txt and prints it to stdout. | |
| # Quotes should be separated by double newlines (single empty lines) in the file. | |
| # We need to define Array#sample if this version of Ruby is really old. | |
| unless Array.respond_to? 'sample' | |
| class Array | |
| def sample | |
| self[rand(length)] |
| # Set the sum to 0 initially and print its value | |
| p sum = 0 | |
| # Set i to 0 initially | |
| i = 1 | |
| # Start an infinite, iterative loop | |
| loop do | |
| # Add 1/i (as a float to keep this accurate) to sum and print its new value | |
| p sum += 1/i.to_f |
| /* | |
| * Try compiling this. It actually works. | |
| * Output: "Hello world" | |
| */ | |
| \u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0020\u0020\u0020 | |
| \u0063\u006c\u0061\u0073\u0073\u0020\u0055\u0067\u006c\u0079 | |
| \u007b\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0020\u0020 | |
| \u0020\u0020\u0020\u0020\u0073\u0074\u0061\u0074\u0069\u0063 | |
| \u0076\u006f\u0069\u0064\u0020\u006d\u0061\u0069\u006e\u0028 |
| class Array | |
| def in_order? | |
| (0..length-2).none? { |i| self[i] > self[i+1] } | |
| end | |
| def bogo_sort | |
| copy = self.dup | |
| copy.shuffle! until copy.in_order? | |
| copy |
##Download a repository with submodules
git clone URL MAIN_REPO_DIR
git submodule init
git submodule update##Add a submodule
cd MAIN_REPO_DIR| require 'benchmark' | |
| Benchmark.bm do |b| | |
| b.report "summation equation" do | |
| sum = 1_000_000*(1_000_000+1)/2.to_f | |
| end | |
| b.report "each loop" do | |
| sum = 0 |
| $ ed | |
| i | |
| Hello, world! | |
| . | |
| w hello.txt | |
| 14 | |
| q | |
| $ cat hello.txt | |
| Hello, world! |
| [a = 'hello'].each { |_| b = 'world' } | |
| puts a # hello | |
| puts b # world |
| # REPL: Read Evaluate Print Loop | |
| # See http://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop | |
| # The prompt for the REPL | |
| PROMPT = 'repl> ' | |
| # Keep reading, evaluating, and printing forever (or until the user exits) | |
| loop do | |
| # Display the prompt | |
| print PROMPT |