Skip to content

Instantly share code, notes, and snippets.

@etaf
etaf / clc_elapsed_time.cpp
Created September 18, 2015 10:31
clc_elapsed_time.cpp
#include <iostream>
#include <chrono>
#include <thread>
int main()
{
//using namespace std::literals;
std::cout << "Hello waiter" << std::endl;
auto start = std::chrono::high_resolution_clock::now();
std::this_thread::sleep_for (std::chrono::seconds(1));
auto end = std::chrono::high_resolution_clock::now();
@etaf
etaf / gist:7635f163a51b902a4532
Created December 31, 2015 02:59
rename filename using regex
rename file:
2015-01-21-hello.md
2015-04-02-word.md
to:
hello.md
word.md
for f in 2015* ; do mv $f $(echo $f | sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-//') ; done
@etaf
etaf / dircolor
Created January 24, 2016 07:23
dircolor
# Dark 256 color solarized theme for the color GNU ls utility.
# Used and tested with dircolors (GNU coreutils) 8.5
#
# @author {@link http://sebastian.tramp.name Sebastian Tramp}
# @license http://sam.zoy.org/wtfpl/ Do What The Fuck You Want To Public License (WTFPL)
#
# More Information at
# https://github.com/seebi/dircolors-solarized
@etaf
etaf / gdbinit
Created January 24, 2016 07:24
gdbinit
#
# STL GDB evaluators/views/utilities - 1.03
#
# The new GDB commands:
# are entirely non instrumental
# do not depend on any "inline"(s) - e.g. size(), [], etc
# are extremely tolerant to debugger settings
#
# This file should be "included" in .gdbinit as following:
# source stl-views.gdb or just paste it into your .gdbinit file
@etaf
etaf / vimrclocal
Created January 24, 2016 07:40
vimrclocal
" set F5 for compile and run c/cpp/python
"map <C-F5> : call CompileRunC()<CR>
map <F5> : call CompileRunCpp()<CR>
"map <F5>: call DebugCpp()<CR>
"map <F6> : call RunPython()<CR>
map <F6> : call RunShell()<CR>
func! CompileRunC()
exec "w"
exec "!gcc -std=c++11 -g -lboost_program_options -lpthread -lboost_system -lboost_filesystem % -o %<"
@etaf
etaf / mtw_download.sh
Last active July 19, 2016 05:39
download the easy fm more to learn mp3 from start day to now
#!/bin/bash
#usage:
#download the easy fm more to learn mp3 from start day to now
trap ctrl_c INT
function ctrl_c(){
echo "\n catched interput signal, exiting..."
[ ! -e $current_process_file ] || rm $current_process_file
echo "bye!"
exit
}
spinner() {
local spin="\\|/-"
local i=0
tput civis
while kill -0 "$1" 2>/dev/null; do
i=$(( (i+1) %4 ))
printf "\b%s" "${spin:$i:1}"
sleep 0.07
done
tput cnorm
@etaf
etaf / auto_passwd.exp
Created January 19, 2017 13:56
auto_passwd
#!/usr/bin/expect
set timeout 20
set cmd [lrange $argv 1 end]
set password [lindex $argv 0]
eval spawn $cmd
expect "assword:"
send "$password\r";
@etaf
etaf / yum_download_only.sh
Last active August 5, 2017 08:53
yum download only
yum install yum-utils
# use --resolve to download dependencies.
yumdownloader --destdir ./rpms --resolve <package>
# on other machine
cd rpms
yum --disablerepo=* localinstall *.rpm -y
@etaf
etaf / build tmux
Created July 22, 2018 07:07
build tmux
```bash
brew install automake pkg-config libevent
git clone https://github.com/tmux/tmux.git
cd tmux
sh autogen.sh
./configure --prefix=$HOME/.local
make -j8 && make install
```