View php-tricks.php
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 | |
/** | |
* Array: Find previous element (method 1) | |
* @source http://stackoverflow.com/questions/4792673/php-get-previous-array-element-knowing-current-array-key | |
*/ | |
$array = array( | |
12 => array('a','b'), | |
34 => array('c','d'), | |
56 => array('e','f') |
View defaults.php
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 TestStuff { | |
private $defaults = array( | |
'color' => '#00ff00' | |
); | |
public function doIt() { | |
return $this->__request(array('color' => '#ff0000')); |
View gist:1292741
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
Replace master by a branch | |
http://stackoverflow.com/questions/2862590/how-to-replace-master-branch-in-git-entirely-from-another-branch | |
Pull branch from different repo | |
http://help.github.com/fork-a-repo/ |
View gist:1286862
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
# Remove | |
for c in $(git for-each-ref refs/tags/ --format='%(refname)'); do echo $c; git push origin :$c; echo; done | |
# Local | |
for c in $(git for-each-ref refs/tags/ --format='%(refname:short)'); do echo $c; git tag -d $c; echo; done |
View get_the_relative_time.php
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 | |
// This function will return "now", "3 seconds ago", "1 month ago" etc ... | |
// example: echo 'posted ' . get_the_relative_time(mktime(date("H"), date("i"), date("s"), date("m")-1, date("d"), date("Y"))); | |
function get_the_relative_time($time = null, $now = 20) { | |
if(is_null($time)) $time = date('U'); | |
$time_diff = date("U") - $time; // difference in seconds | |
$second = 1; |
View .bashrc
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
# found here http://ubuntuforums.org/showthread.php?t=1116012 | |
extract () { | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.bz2) tar xvjf $1 && cd $(basename "$1" .tar.bz2) ;; | |
*.tar.gz) tar xvzf $1 && cd $(basename "$1" .tar.gz) ;; | |
*.tar.xz) tar Jxvf $1 && cd $(basename "$1" .tar.xz) ;; | |
*.bz2) bunzip2 $1 && cd $(basename "$1" /bz2) ;; | |
*.rar) unrar x $1 && cd $(basename "$1" .rar) ;; |