Skip to content

Instantly share code, notes, and snippets.

View suewonjp's full-sized avatar

Suewon Bahng suewonjp

View GitHub Profile
@suewonjp
suewonjp / Open_iTerm2.txt
Last active July 28, 2016 13:45
[Mac OS X Tip] Open a new iTerm tab from the current folder in Finder
on run {input, parameters}
tell application "Finder"
set dir_path to quoted form of (POSIX path of (folder of the front window as alias))
end tell
CD_to(dir_path)
end run
on CD_to(theDir)
tell application "iTerm"
activate
@suewonjp
suewonjp / backup-functions.sh
Last active May 22, 2017 06:14
Bash Functions for Simple Directory Backup
checkBackupTarget() {
[ ! "$1" ] \
&& echo "Usage: $FUNCNAME [ directory-to-backup ]" \
&& echo "Note: the path should be relative" \
&& return 2
local tgtPath=$1
[ ! -d "$tgtPath" ] \
&& printf "$FUNCNAME : \"%s\" does NOT exist!!!\n" "$tgtPath" \
@suewonjp
suewonjp / mappings-for-windows-and-tabs.vim
Last active October 4, 2017 02:05
[vim tip] key mappings for conveniently traversing windows and tabs
" These mappings are based on the default key movement scheme of Vim (h, j, k, l)
" For example, when you want to move to the left tab, press Alt + h
" When you want to move to the window underneath, press Shift + Alt + j
" Paste the below code to your Vim settings file ( ~/.vimrc )
" Map Alt(Meta) key combinations
execute "set <M-l>=\el"
execute "set <M-h>=\eh"
execute "set <M-L>=\eL"
execute "set <M-H>=\eH"
@suewonjp
suewonjp / prefix_suffix.js
Created June 7, 2016 08:04
[JavaScript snippet] string prefix, suffix
function prefix(str, sep) {
// prefix("foo.bar.txt", ".") => foo
return str && str.substring(0, str.indexOf(sep));
}
function suffix(str, sep, excludeSep) {
// suffix("foo.bar.txt", ".") => .txt
// suffix("foo.bar.txt", ".", true) => txt
return str && str.substring(str.lastIndexOf(sep) + (excludeSep === true ? sep.length : 0));
}
@suewonjp
suewonjp / rmrf.sh
Last active June 7, 2016 08:32
[Bash tip] Safer 'rm -rf' command
#!/bin/sh
scriptName=${0##*/}
if [ $# = 0 ] ; then
echo "Wrapper script for the dangerous 'rm -rf'"
echo "Usage : $scriptName [folder to delete]"
exit 0
fi
@suewonjp
suewonjp / toggle-qf-win.vim
Created June 7, 2016 08:51
[vim tip] Toggle Quickfix Window
function! ToggleQuickfix()
let l:nr = winnr("$")
if l:nr == 1
copen
else
cclose
endif
endfunction
@suewonjp
suewonjp / Building Primefaces from source.md
Last active January 18, 2017 10:31
Building Primefaces from source

https://github.com/primefaces/primefaces/wiki/Building-From-Source

  1. git-clone the packages:

     git clone https://github.com/primefaces/maven-jsf-plugin.git
     git clone https://github.com/primefaces/primefaces.git
    
  2. Find out maven-jsf-plugin version before trying to build Primefaces

  • Especially when you want to build older snapshots of Primefaces, you need to build maven-jsf-plugin that matches them
@suewonjp
suewonjp / colorful-echo.sh
Last active January 6, 2017 11:29
Bash - Simple echo function to print colorful text
### Font colors
red=1 green=2 yellow=3 blue=4 magenta=5 cyan=6
### Font attributes
bold=1 underline=4 reverse=7
preecholor() {
printf '\e[%s;3%dm' "$1" "$2"
}
@suewonjp
suewonjp / check-version.sh
Last active January 7, 2017 09:28
compare two version notation strings in Bash
#!/bin/bash
versionAccepted() {
### $1 is the minimum required version, $2 is the version in question;
### If $1 < $2, return 0 (the input version is accepted)
### otherwise, return 1 (not accepted)
versions=( "$1" "$2" )
#printf "${versions[*]}\n"
for (( i=0; i<${#versions[@]}; ++i )); do
@suewonjp
suewonjp / Converting .bat to .exe using AutoIt.md
Created January 10, 2017 03:51
Converting .bat to .exe using AutoIt

There are many ways to convert Windows batch script files to .exe files;

Unfortunately, most of hit methods when searching with https://www.google.co.kr/?gws_rd=ssl#newwindow=1&q=bat+to+exe
may not work or may not satisfy your quality demand;

Many of these naive implementations may let most of antivirus apps consider your result .exe file as a malware;

I tested several tools but until now, AutoIt is the best tool to convert .bat to .exe

Workflow: