Skip to content

Instantly share code, notes, and snippets.

@yaronuliel
yaronuliel / phpversion.sh
Last active Jun 4, 2018
HomeBrew PHP Version select script
View phpversion.sh
# Add this function to your ~/.bash_profile file
# To show current linked version, run: `phpversion`
# To link another version, run: `phpversion VERSION` (e.g. `phpversion 7.2`)
phpversion() {
# Get currently installed HomeBrew php version (ignoring system php)
local current_php_version=$(/usr/local/bin/php -r "echo PHP_VERSION;" 2>/dev/null | awk -F'.' '{print "php@" $1 "." $2}')
# If no argument passed - Present the current version
if [ -z "$1" ]; then
@yaronuliel
yaronuliel / git-ch
Last active Jan 16, 2018
Git checkout by partial branch name or from list - `git ch`
View git-ch
#!/usr/bin/env bash
get_branches="git branch | sort -u"
if [[ $# -eq 0 ]] ; then
eval "$get_branches | nl -ba"
exit;
fi
branch_num=$1
@yaronuliel
yaronuliel / sshhosts.sh
Last active Feb 6, 2019
Connect to preconfigure ssh hosts (set in ~/.ssh/config) via simple list with numbers or by regex of the host name
View sshhosts.sh
#!/usr/bin/env bash
get_hosts="cat ~/.ssh/config | grep Host\\\\s | awk '{ print \$2 }' | sort -u"
if [[ $# -eq 0 ]] ; then
eval "$get_hosts | nl -ba"
exit;
fi
host_num=$1
View whatismyip.sh
#!/usr/bin/env bash
curl -s ip-api.com/json | python -m json.tool
View git-update-author.sh
#!/bin/sh
echo "Enter Old Email address: "
read OLD_EMAIL
echo "Enter new Email Address: "
read CORRECT_EMAIL
echo "Enter new user name (First name + Last Name): "
read CORRECT_NAME
env_filter="
View git2ftp.sh
#!/usr/bin/env bash
#set temp dir (from second arguments). defaults to __toupload
dest=${2:-__toupload}
dest=${dest%/}/
to="HEAD"
# get start revision from first argument (default to -1)
from=${1:-1}
View utf8bom
#!/usr/bin/env bash
if [ $# -ne 2 ] && [ $# -ne 1 ]; then
echo "use: $0 source <destination>"
exit
fi
if [ ! -f $1 ]; then
printf "\e[31m$1\e[0m does not seem to be a file"
View shrink.js
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
function error(message) {
console.error(message);
process.exit();
}
@yaronuliel
yaronuliel / svn2ftp.sh
Last active Jun 28, 2016
This is a script for extracting the files that was changed in the most recent svn commit into a separate directory for upload to server (using FTP/SSH/whatever)
View svn2ftp.sh
#!/usr/bin/env bash
#set temp dir (from second arguments). defaults to __toupload
dest=${2:-__toupload}
dest=${dest%/}/
to=$(svn info --show-item revision)
# get start revision from first argument (default to -1)
from=${1:--1}