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
// Assume you sorting an array | |
// [5,1,2,3] => [1,2,3,5] | |
// [2,3,5,5,2,0] => [0,2,2,3,5,5] | |
function _swap(array, index1, index2) { | |
var temp = array[index1]; | |
array[index1] = array[index2]; | |
array[index2] = temp; | |
} | |
function _buildHeap(array) { |
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
// Assume you are sorting floating point values. | |
// [0.33, 0.22, 0.4, 0.1, 0.0] => [0.0, 0.1, 0.22, 0.33, 0.4] | |
function _hash(value) { | |
return Math.floor(value / 0.1); // create buckets with sized 0.1 | |
} | |
function _createBucket(array) { | |
var buckets = {}; // A hash that has keys that represent a range of values. | |
for (var i = 0; i < array.length; i++) { |
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
// Sort an array of integers. | |
// [1,4,1,9,5,10] => [1,1,4,5,9,10] | |
function _insert(array, position, value) { | |
var i = position - 1; // Check the previous value | |
// Walk backwards in the array and shifts the values of the array | |
// when the previous value is larger than the value we want to insert | |
while ((i >= 0) && (array[i] > value)) { | |
array[i + 1] = array[i]; | |
i--; |
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
// Assume you sorting an array within the range of 0-9 | |
// [5,1,2,3] => [1,2,3,5] | |
// [2,3,5,5,2,0] => [0,2,2,3,5,5] | |
function countingSort(array) { | |
// We can assume a range of values or we can determine the range ourselves. | |
// [0, k) where k is the max value of the range. | |
// k must be less than or equal to N | |
// Each value in the range is a represented a key in a bucket | |
var bucket = [], // We use the array's index as the key for the bucket | |
index = 0; |
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
map = {}; | |
_ref = form.serializeArray(); | |
_ref1 = this.model.parameters; | |
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | |
o = _ref[_i]; | |
if ((o.value != null) && jQuery.trim(o.value).length > 0) { | |
if (_ref1[_i].allowMultiple) { | |
map[o.name] = o.value.split(","); |
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
# Add this to the end of your development.rb and add | |
# | |
# gem 'pry' | |
# | |
# to your Gemfile and run bundle to install. | |
silence_warnings do | |
begin | |
require 'pry' | |
IRB = Pry |
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
/** | |
* What this does: | |
* converts current.docx to "current pdf" | |
* Adds a timestamp on the footer of each page of "current pdf" | |
* Appends the "current pdf" to comprehensive pdf | |
* Zip the "current pdf" to archive.zip | |
* Deletes the "current pdf" | |
* | |
* Usage example: java ELabnotes archive.zip comprehensive.pdf current.docx | |
* |