Skip to content

Instantly share code, notes, and snippets.

@codeitlikemiley
Last active May 21, 2019 11:44
Show Gist options
  • Select an option

  • Save codeitlikemiley/62b94abdeb5bfb068ff56bbbbc36a311 to your computer and use it in GitHub Desktop.

Select an option

Save codeitlikemiley/62b94abdeb5bfb068ff56bbbbc36a311 to your computer and use it in GitHub Desktop.
scripts i3
#!/bin/sh
# CREATE NEW EMULATOR DEVICE
echo "Set A Name For Your Android Device"
read -r device
if [ -f "$device" ] ; then
echo "Opps! You Need to Name Your Device"
return;
fi
avdmanager list | grep id:
echo "Choose A Device ID from Above List"
read -r id
if [ -f "$id" ] ; then
echo "Opps You didnt specify An ID"
return;
fi
avdmanager create avd -d "$id" -n "$device" -k "system-images;android-25;google_apis;x86"
#!/bin/sh
sudo netstat -tulpn | grep :"$1"
#!/bin/sh
mysql -u root -p -e "CREATE DATABASE $1;"
#!/bin/sh
echo "$1" | base64 -d | xclip -sel clip
#!/bin/sh
/usr/bin/git --git-dir="$HOME/dotfiles/" --work-tree="$HOME" "$@"
#!/bin/sh
mysql -u root -p -e "DROP DATABASE $1;"
#!/bin/sh
mysqldump -u root -p "$1" > "$2"
#!/bin/sh
find . -type f -iname '*'"$*"'*' -ls;
#!/bin/sh
OPTIND=1
mycase=""
usage="fstr: find string in files.
Usage: fstr [-i] \"pattern\" [\"filename pattern\"] "
while getopts :it opt; do
case "$opt" in
i) mycase="-i " ;;
*)
echo "$usage"
return
;;
esac
done
shift $((OPTIND - 1))
if [ "$#" -lt 1 ]; then
echo "$usage"
return
fi
find . -type f -name "${2:-*}" -print0 |
xargs -0 egrep --color=always -sn ${case} "$1" 2>&- | less
#!/bin/sh
_get_repo() {
echo "$1" | sed -e "s/.git$//" -e "s/.*github.com[:/]\(.*\)/\1/"
}
_build_url() {
# shellcheck disable=SC2039
local upstream origin branch repo pr_url target
upstream="$(git config --get remote.upstream.url)"
origin="$(git config --get remote.origin.url)"
branch="$(git symbolic-ref --short HEAD)"
repo="$(_get_repo "$origin")"
pr_url="https://github.com/$repo/pull/new"
target="$1"
test -z "$target" && target=$(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)" | cut -d '/' -f 2)
test -z "$target" && target="master"
if [ -z "$upstream" ]; then
echo "$pr_url/$target...$branch"
else
# shellcheck disable=SC2039
local origin_name upstream_name
origin_name="$(echo "$repo" | cut -f1 -d'/')"
upstream_name="$(_get_repo "$upstream" | cut -f1 -d'/')"
echo "$pr_url/$upstream_name:$target...$origin_name:$branch"
fi
}
# shellcheck disable=SC2039
url="$(_build_url "$*")"
if [ "$(uname -s)" = "Darwin" ]; then
open "$url" 2> /dev/null
else
xdg-open "$url" > /dev/null 2> /dev/null
fi
# use git open-pr
# since we add an alias to git
# git config --global alias.pr open-pr
#!/bin/sh
mysql --user="root" --database="$1" -p < "$2"
#!/bin/sh
tar cvzf "${1%%/}.tar.gz" "${1%%/}/";
#!/bin/sh
zip -rq "${1%%/}.zip" "$1";
#!/bin/sh
mkdir -p "$1"
cd "$1" || exit
#!/usr/bin/bash
# Use an Encrypted Password File To Instantly Login MYSQL
# check if file exist
# if not use the default
# also check if the user is specified
# then we need to declare what our gpg file to be decrypted
password=$(eval echo '$(gpg --decrypt ~/mysqlpass.gpg 2>/dev/null)')
logcmd="mysql -uroot -p$password"
eval "$logcmd"
# create a temp file then we input password
# we encrypt it usingg our default encryption
# output
# recepiemt
# the tmp file name
# to edit we decrypt then create a temporary file
# we edit then we encrypt back
#!/bin/sh
# uses rofi ssh to generate config
# read this https://stackoverflow.com/questions/3225862/multiple-github-accounts-ssh-config#17158985
cwd=$(pwd)
sshdir=~/.ssh
echo "Set A Comment to your ssh key"
read -r comment
if [ -f "$comment" ] ; then
echo "Opps You didnt specify A Comment"
return;
fi
echo "Set An id to your ssh key"
read -r name
if [ -f "$name" ] ; then
echo "Opps You didnt specify An ID"
return;
fi
cd $sshdir && ssh-keygen -t rsa -b 4096 -C "${comment}" -f "id_$name" && cd "$cwd" || exit
#!/bin/sh
curl -F c=@- https://ptpb.pw
#!/bin/sh
if [ $# -eq 0 ]; then
php artisan route:list
else
php artisan route:list | grep "$1"
fi
#!/bin/sh
# Make your directories and files access rights sane.
chmod -R u=rwX,g=rX,o= "$@";
#!/bin/sh
if [ -f vendor/bin/phpunit ]; then
vendor/bin/phpunit "$@"
else
phpunit "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment