Skip to content

Instantly share code, notes, and snippets.

View GeneralD's full-sized avatar
💭
Alcohol makes better code 🥃

YUMENOSUKE GeneralD

💭
Alcohol makes better code 🥃
View GitHub Profile
#!/usr/bin/env zsh
(){
local plistfile="$HOME/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist"
local i=0
while [[ $i != "false" ]]; do
[[ `/usr/libexec/PlistBuddy -c "Print :LSHandlers:$i" $plistfile 2>/dev/null` ]] || break
ext=`/usr/libexec/PlistBuddy -c "Print :LSHandlers:$i:LSHandlerContentTag" $plistfile 2>/dev/null`
@GeneralD
GeneralD / parent-directory.zsh
Last active August 26, 2018 14:18
[parent-directory.zsh] #Shell #Ruby
# cd to parent directory of the file (even if it is symbolic link)
function pd() {
local dir=`realpath ${1:-.}`
cd $dir(:A:h)
}
# alias -g ...=../../, ....=../../../, .....=../../../../, ......
`ruby -e "(2..20).each{|i| puts 'alias -g .'+'.'*i+'='+'../'*i}"`
true
# zmv
autoload -Uz zmv
alias zmv='noglob zmv -W'
# Java use IPv4 for jenkins
alias jenkins='env _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true" jenkins'
constructor(private iab: InAppBrowser) {}
openUrl(url: string, externalBrowser: boolean = false) {
const target = externalBrowser ? '_system' : '_blank';
this.iab.create(url, target, TopicDetailPage.options);
}
# usage sample: echo Let\'s ${RED}color${CLEAR} text!
CLEAR='\033[0m'
BLACK='\033[0;30m'
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
# Mac Applications in 'Applications' directories -> runnable from the terminal
() {
local app dir
for dir in $@; do
for app in $dir/*.app(N); do; alias ${app:t:r:gs/ //}="open -a ${app:gs/ /\\ /}"; done
for app in $dir/*/*.app(N); do; alias ${app:t:r:gs/ //}="open -a ${app:gs/ /\\ /}"; done
done
} /Applications ~/Applications
# Open the directory with Finder (Open current directory without argument)
#!/usr/bin/env sh
## This script uses several commands. They can be install with...
## $ gem install notify-my-android
## $ gem install prowl
## $ brew install terminal-notifier
NMA_KEY=${NMA_KEY:-"YOUR_KEY"}
PROWL_KEY=${PROWL_KEY:-"YOUR_KEY"}
#!/usr/bin/env bash
# Parameters
NBINS=20
INTERVAL=1
PROCESSES=("Google Chrome")
# Set process
if [ $# -gt 0 ];then
PROCESSES=("$@")
#!/usr/bin/env zsh
if [[ $# -lt 2 ]]; then
echo "Usage: ${0##*/} [repo's url] [directory you want to clone]"
exit
fi
local dir=${1##*/}
mkdir $dir
local tmpdir=`pwd`