Skip to content

Instantly share code, notes, and snippets.

View nechkin's full-sized avatar
🎯
Focusing

Sergey nechkin

🎯
Focusing
View GitHub Profile
#!/bin/bash
# Install:
# curl -O https://gist.github.com/nechkin/0ac33fad55f777c9994d#file-autossh-initd-elastic-tunnel-setup-sh
# chmod u+x autossh-initd-elastic-tunnel-setup.sh
# ./autossh-initd-elastic-tunnel-setup.sh
SSH_USER="EBdev"
SSH_SERVER="172.22.40.10"
SSH_PORT="22"
@nechkin
nechkin / bash_loop_files_basename
Created December 21, 2014 16:41
Bash loop over files extracting file basename from path
http://stackoverflow.com/questions/18845814/bash-extracting-file-basename-from-long-path
files=( /very/long/path/to/various/files/*.file )
for file in "${files[@]}"
do
filename="${file##*/}"
filenameWithoutExtension="${filename%.*}"
echo "$filenameWithoutExtension"
done
@nechkin
nechkin / gist:1b887d38370e76e1072d
Created August 26, 2014 03:31
Version of [binarySearch] optimized for comparable keys
// From dart algorithm package
/** Version of [binarySearch] optimized for comparable keys */
int _comparableBinarySearch(List<Comparable> list, Comparable key) {
int min = 0;
int max = list.length;
while (min < max) {
int mid = min + ((max - min) >> 1);
var element = list[mid];
int comp = element.compareTo(key);
if (comp == 0) return mid;