Skip to content

Instantly share code, notes, and snippets.

#!/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"
@yaronuliel
yaronuliel / svn2ftp.sh
Last active June 28, 2016 14:40
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)
#!/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}
#!/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}
#!/usr/bin/env bash
curl -s ip-api.com/json | python -m json.tool
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
function error(message) {
console.error(message);
process.exit();
}
@yaronuliel
yaronuliel / git-ch
Last active January 16, 2018 12:41
Git checkout by partial branch name or from list - `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 / phpversion.sh
Last active June 4, 2018 16:02
HomeBrew PHP Version select script
# 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
#!/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="
@yaronuliel
yaronuliel / auto-nvm-use.sh
Created August 23, 2022 16:50
Automatically switch node version using `nvm` use `.nvmrc` file exists in the context
function find-up {
x=`pwd`
result=""
while [ -z "$result" ] && [ "$x" != "/" ] ; do
result=$(find "$x" -maxdepth 1 -name $1)
x=`dirname "$x"`
done
echo $result
}
@yaronuliel
yaronuliel / sshhosts.sh
Last active August 24, 2022 09:24
Connect to preconfigure ssh hosts (set in ~/.ssh/config) via simple list with numbers or by regex of the host name
#!/usr/bin/env bash
cd ~/.ssh
function get_includes {
includes=$(cat $1 | awk '{$1=$1};1' | grep -i "^include\s" | perl -pe 's#^include\s+##i')
for config in $includes; do
echo $config
get_includes $config
done