Skip to content

Instantly share code, notes, and snippets.

View zipizap's full-sized avatar

zipizap

View GitHub Profile
java -Dhttp.proxyHost=YourProxyIpOrUrl.com -Dhttp.proxyPort=8080 -Dhttps.proxyHost=YourProxyIpOrUrl.com -Dhttps.proxyPort=8080 -Xmx800m -jar minecraft.jar
LOCAL_LISTENING_PORT=12345
REMOTE_USER="zipizap"
REMOTE_SERVER="my.server.com"
ssh -N -D $SOCKS_LISTENING_PORT $REMOTE_USER@$REMOTE_SERVER sleep 60
source $BYOBU_PREFIX/share/byobu/keybindings/common
source $BYOBU_PREFIX/share/byobu/keybindings/f-keys.screen.disable
escape "^Aa"
register x "^A"
bindkey "^A"
# The text
#
$ echo 'the lazy dog jumped the impossible river'
the lazy dog jumped the impossible river
# The text dumped in hexadecimal
#
$ echo 'the lazy dog jumped the impossible river' | od -ct x1
0000000 t h e l a z y d o g j u m
74 68 65 20 6c 61 7a 79 20 64 6f 67 20 6a 75 6d
#######################################
## Add these lines into ~/.tmux.conf
#######################################
# set correct term
set -g default-terminal "screen-256color"
# and add an alias into ~/.bashrc
# alias 'tmux'='TERM=xterm-256color tmux'
# see http://unix.stackexchange.com/questions/1045/getting-256-colors-to-work-in-tmux
$env | grep VAR
# nothing
$ VAR1="my_v1" VAR2="my_v2" bash -c 'env | grep VAR'
VAR1=my_v1
VAR2=my_v2
# the command after VAR1 and VAR2 has those vars defined in its environment
# but the vars only exist in the environment of that command, and not in the
# "outside" environment, as can be seen:
zipizap@lnxp:/tmp/depth0$ tree --charset ascii
.
|-- A_depth1
| `-- A_depth2
| `-- A_depth3
|-- B_depth1
| `-- B_depth2
| `-- B_depth3
`-- C_depth1
`-- C_depth2
zipizap@lnxp:/tmp$ ./a.sh
Handler for CTRL-C is defined - press CTRL-C or wait 5 seconds to continue
^C------- handler_CtrlC -------
>> Control-C was pressed. Exiting
zipizap@lnxp:/tmp$
zipizap@lnxp:/tmp$
zipizap@lnxp:/tmp$
zipizap@lnxp:/tmp$
zipizap@lnxp:/tmp$
zipizap@lnxp:/tmp$ ./a.sh
#!/bin/bash
# capture SIGINT (emitted when CTRL-C)
function handler__CtrlC {
echo "------- handler_CtrlC -------"
echo ">> Control-C was pressed. Exiting"
exit 1
}
trap handler__CtrlC SIGINT
echo "Handler for CTRL-C is defined - press CTRL-C or wait 5 seconds to continue"
@zipizap
zipizap / gist:6935276
Created October 11, 2013 14:10
Bash ternary-like comparisons
# condition && command-if-true || command-if-false
#
# CAUTION: condition && ... || ... works, but
# condition || ... && ... does NOT work!
#
$ [[ "your" == "condition" ]] && echo "executed if true" || echo "executed if false"
executed if false
$ [[ "your" == "your" ]] && echo "executed if true" || echo "executed if false"
executed if true