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
var s = new Set(); | |
s.add(2); | |
// Set { 2} | |
s.add(45); | |
// Set { 2, 45} | |
s.add(45); | |
// Set { 2, 45} | |
s.add('hello world!'); | |
// Set { 2, 45, 'hello world!' } |
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
> selectionSort([33,2,52,106,73]); | |
> comparing 33 and 2 | |
> comparing 2 and 52 | |
> comparing 2 and 106 | |
> comparing 2 and 73 | |
> swapping the number 2 for the number 33 | |
> numbers currently looks like: 2,33,52,106,73 | |
> comparing 33 and 52 | |
> comparing 33 and 106 |
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
function selectionSort(numbers) { | |
var length = numbers.length; | |
// Traverse through all the elements in the number array. | |
for(var index = 0; index < length; index++) { | |
// Set the current item to be the smallest/minimum. | |
var smallestNumIndex = index; | |
// Find the minimum element in remaining unsorted array. | |
for(var nextNumIndex = index + 1; nextNumIndex < length; nextNumIndex++) { | |
console.log('comparing ' + numbers[smallestNumIndex] + ' and ' + numbers[nextNumIndex]) |
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
> var myArray = [9, 7, 4, 1, 2]; | |
> bubbleSort(myArray); | |
> comparing 7 and 9 | |
> SWAPPING 7 and 9 | |
> array is now (5) [7, 9, 4, 1, 2] | |
> comparing 4 and 9 | |
> SWAPPING 4 and 9 | |
> array is now (5) [7, 4, 9, 1, 2] | |
> comparing 1 and 9 |
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
function bubbleSort(array) { | |
var isSorted = false; | |
while (!isSorted) { | |
isSorted = true; | |
// Iterate until we get to the last element | |
for (var index = 1; index < array.length; index++) { | |
console.log("comparing " + array[index] + " and " + array[index - 1]); | |
// If the element to the left is bigger, then swap the element |
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
> var a = [4, -31, 0, 99, 83, 1]; | |
> insertionSort(a); | |
> currentUnsortedItem is currently 4 | |
> ** inserting 4 at index 0 | |
> array is now: 4,-31,0,99,83,1 | |
> currentUnsortedItem is currently -31 | |
> -31 < 4 is true | |
> ** inserting 4 at index 1 | |
> ** inserting -31 at index 0 |
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
function insertionSort(array) { | |
// Traverse through length of array, starting with the element at index 0. | |
for (var i = 0; i < array.length; i++) { | |
// Our current place in the unsorted portion of the array. | |
// currentUnsortedItem is the item we will be moving into the "sorted" subset of our array. | |
var currentUnsortedItem = array[i]; | |
console.log('currentUnsortedItem is currently ' + currentUnsortedItem); | |
// Iterate through sorted items. | |
// If the current unsorted item is smaller than the item to its left, |
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
# To install plotly: install.packages('plotly') | |
# To ensure you have plotly: library(plotly) | |
# Import your dataset. You can use this script to generate a CSV for an entire month's worth of data: | |
# https://gist.github.com/vaidehijoshi/5bb92c2a3656d8b72fc731bb0d2bf243 | |
# R Studio should recgonize your dataset automatically when you upload it, but if not, you can do something like this: | |
monthly_endpoint_percentages <- read.table('~/Code/scatter_plot_data.csv', sep=",", header=TRUE) | |
# If you want to graph the endpoints as compared to their app rpm's, use this command: |
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
sudo env ARCHFLAGS="-arch x86_64" gem install pg -v '0.17.1' |
NewerOlder