Created
November 13, 2014 20:07
-
-
Save anonymous/ba0bf44ec84b313b0ed3 to your computer and use it in GitHub Desktop.
atom shortcuts clinic
This file contains 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
# Basic Core Atom Features | |
# Plugins to install: | |
# Monokai Theme | |
# Fancy New File | |
# Icons | |
# Gist it | |
# Emmet (quickly write html) | |
# Commands: | |
# cmd + , ==> will open Atom settings | |
# cmd + (number) ==> move to different tabs | |
# cmd + direction ==> move cursor quickly | |
# cmd + control + direction ==> move an entire line somewhere else | |
# cmd + l ==> highlight an entire line (keep clicking for more lines) | |
# cmd + / ==> comment things out quickly | |
# cmd + \ ==> toggle tree view | |
# alt/option + h ==> delete to beg of word | |
# alt + f ==> move to end of word | |
require 'pry' | |
require 'benchmark' | |
array = [] | |
1_000_000.times do | |
array << rand(1000) | |
end | |
def merge_sort(array) | |
return array if array.length <= 1 | |
half = array.size / 2 | |
left_array = array.take(half) | |
right_array = array.drop(half) | |
sorted_left = merge_sort(left_array) | |
sorted_right = merge_sort(right_array) | |
return merge_a(sorted_left, sorted_right) | |
end | |
def merge_a(left_array, right_array) | |
result = [] | |
until left_array.empty? || right_array.empty? | |
if left_array.first <= right_array.first | |
result << left_array.shift | |
else | |
result << right_array.shift | |
end | |
end | |
return result.concat(left_array).concat(right_array) | |
end | |
puts Benchmark.measure {puts merge_sort(array)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment