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
/** | |
* Does the "Math.ceil" but goes to a given ending, such as "9.99" or "8.88". | |
* | |
* Example: Math.ceilEnding( 37.46, 9.99 ) returns 39.99 | |
* | |
* @param float number | |
* @param float ending | |
* @return float | |
*/ | |
Math.ceilEnding = function( number, ending ) { |
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
-- -------------------------------------------------------------------------------- | |
-- Does the CEIL function but goes to a given ending, such as "9.99" or "8.88". | |
-- | |
-- Example: SELECT ceilEnding( 37.46, 9.99 ) returns 39.99 | |
-- | |
-- @param decimal num | |
-- @param decimal ending | |
-- @return decimal | |
-- -------------------------------------------------------------------------------- | |
DELIMITER $$ |
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
[alias] | |
brr = branch -r | |
br = branch | |
ci = commit -m | |
cia = commit -a -m | |
amend = commit --amend -C HEAD | |
co = checkout | |
cob = checkout -b | |
st = status -sb | |
me = merge --no-ff |
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
<?php | |
class BST { | |
protected $root; | |
/** | |
* Abstracts away root selection. | |
* | |
* @param $data | |
* @return BSTNode | |
* @throws Exception |
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
<?php | |
// O(n^2) | |
function insertionSort( array $array ) { | |
$length = count($array); | |
for ( $i = 1; $i < $length; $i++ ) { | |
$j = $i; | |
while ( $j > 0 && $array[$j] < $array[$j-1] ) { | |
$temp = $array[$j]; | |
$array[$j] = $array[$j-1]; | |
$array[$j-1] = $temp; |
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
<?php | |
// O(n^2) | |
function selectionSort( array $array ) { | |
$length = count($array); | |
for ( $i = 0; $i < $length; $i++) { | |
$min = $i; | |
for( $j = $i + 1; $j < $length; $j++ ) { | |
if ( $array[$min] > $array[$j] ) |
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
<?php | |
function bubbleSort(array $array) { | |
if ( empty( $array ) ) | |
return $array; | |
$length = count($array); | |
for ( $i = 0; $i < $length - 1; $i++ ) { | |
$swapped = false; |
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
<?php | |
function mergeSort(array $array) { | |
$length = count( $array ); | |
// An array with one value is sorted | |
if ( $length < 2 ) | |
return $array; | |
// Split array in half | |
$left = $right = []; |
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
class LinkedList { | |
public $head; | |
public function add($data) { | |
$new_node = new Node($data); | |
if ( is_null( $this->head ) ) { | |
$this->head = $new_node; | |
} else | |
{ |
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
class Stack { | |
protected $top; | |
public function push($data) { | |
$node = new Node($data); | |
$node->next = $this->top; | |
$this->top = $node; | |
} |
OlderNewer