Skip to content

Instantly share code, notes, and snippets.

Created November 13, 2014 20:07
Show Gist options
  • Save anonymous/ba0bf44ec84b313b0ed3 to your computer and use it in GitHub Desktop.
Save anonymous/ba0bf44ec84b313b0ed3 to your computer and use it in GitHub Desktop.
atom shortcuts clinic
# 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