Skip to content

Instantly share code, notes, and snippets.

tarranjones / array_change_key_type.php
Created December 12, 2016 23:16
array key casting
View array_change_key_type.php
function array_change_key_type(array $array, $type = T_STRING_CAST )
if($token === T_STRING_CAST) {
$obj = new stdClass();
foreach($array as $key => $value){
$obj->{$key} = $value;
return (array) $obj;
tarranjones / 0_reuse_code.js
Created December 12, 2016 11:11
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View scrape
#!/usr/bin/env zsh
mkdir -m 0700 -p $datadir
git -C $datadir init
exec >>$logfile
echo "# $date"
curl -fsSL | \
tarranjones / AbstractSingleton.php
Last active December 4, 2016 21:03
Singleton Classes
View AbstractSingleton.php
abstract class AbstractSingleton implements SingletonInterface
final public static function getInstance()
static $instance;
return $instance = $instance ?: new \static();
final private function __construct() {}
View install-wp-cli
curl -O
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp
tarranjones / install-composer-bash
Last active November 22, 2016 11:32
cross platform Install for composer -requires bash, curl, git and php
View install-composer-bash
# for name in {bash,curl,git,php} ; do which $name ; done
mkdir -p /usr/local/bin
curl -sS | sudo php -- --install-dir=/usr/local/bin --filename=composer
tarranjones / .bash_function_append
Last active November 22, 2016 10:38
Appends lines of text to a specified file but only if the line doesn't already exist
View .bash_function_append
function append(){
for i in "$@"; do
if ! [[ "$filename" = "$i" ]]; then
grep -q -F "$i" $filename || echo "$i" >> $filename
tarranjones / .bash_alias_osx
Created November 15, 2016 12:20
hidden files - refreshFinder, showFiles, hideFiles, toggleFiles
View .bash_alias_osx
alias refreshFinder='echo "Refreshing Finder . ."; killall Finder /System/Library/CoreServices/'
alias showFiles='echo "Showing All Files . ."; defaults write AppleShowAllFiles YES; refreshFinder;'
alias hideFiles='echo "Hiding Files . ."; defaults write AppleShowAllFiles NO; refreshFinder;'
alias toggleFiles='yn=$(defaults read AppleShowAllFiles); if [ $yn = "YES" ]; then hideFiles; else showFiles; fi'
tarranjones / tkheader.php
Created November 10, 2016 11:07
response header for DNT (tracking-status-values)
View tkheader.php
* @info
function getRequestTrackingStatusValue(){
return "N";
View gist:0478dc6fb9fc882c6f84bece44ed6f4a
sudo add-apt-repository $repo --yes --update
sudo apt remove $old
sudo apt install $new
sudo apt autoremove