git fetch <remote>
git checkout -b <branch> --track <remote>/<branch>
When installing Python 2 and Python 3 on a Windows computer. The environment variables determine which one to use.
So one of the python executables may be on the PATH. You can rename the python executable such as python27.exe or python33.exe.
Then you can execute them like python27
or python33
on the CLI.
However when Python launches it utilises certain environment variables to get its dependencies.
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
Build PHP with PHPBrew | |
WORK IN PROGRESS | |
http://devkardia.com/easyblog/ubuntu-12-04-multiple-php-versions-and-virtualmin-using-phpbrew.html | |
Use these php.ini files | |
- Make sure to use TCP sockets for everything. Unix Domain Sockets are BAAAAD! | |
- Set session save path to the temporary directory |
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
function sed-keyword-escape { | |
echo $1 | sed -e 's/[]\/$*.^|[]/\\&/g' | |
} | |
function sed-replace-escape { | |
echo $1 | sed -e 's/[\/&]/\\&/g' | |
} | |
function sed-easy { | |
sed -i "s/$(sed-keyword-escape $1)/$(sed-replace-escape $2)/g" $3 |
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 | |
// sorted array must be a 0 indexed | |
// left most index, right most index all inclusive | |
// finds all of the elements coming from the left to the right that is less or equal to the key | |
function bisect_right($sorted_array, $key, $left = null, $right = null){ | |
if(is_null($left)){ | |
reset($sorted_array); | |
$left = key($sorted_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
<?php | |
// O(n) time complexity with constant space complexity | |
function fibonacci_dynamic($n){ | |
if($n == 0){ | |
return 0; | |
}elseif($n == 1 OR $n == 2){ | |
return 1; | |
} |
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
let | |
fib = number: fib' number 1 1; | |
fib' = number: first: second: | |
if number == 0 | |
then first | |
else fib' (number - 1) second (first + second); | |
# the second becomes the new first, the (first + second) becomes the new second | |
in | |
fib 5 |
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
// factorial tail recursive (Elixir style) | |
// 4! means 1*2*3*4, we can ignore 1, which makes it 2*3*4 = 24 | |
def factorial(number) do | |
factorial(number, 1) | |
end | |
def factorial(number, product) do | |
factorial(number - 1, product * number) |
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 | |
// count inclusive from x to y keys (x and y keys are the keys for the prefix sum, not the keys of the original array) | |
function cumulative_slice($prefix, $x, $y){ | |
return $prefix[$y] - $prefix[$x]; | |
} | |
// here's a more flexible function: | |
// run with X, Y when using original array indexes | |
// run with X, null, Z when using cumulative array indexes |