This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script is interested to take | |
# - a flag | |
# - an option which takes a parameter | |
arg_list=$(getopt -o bp: --long boolean,param: -- "$@") | |
eval set -- "$arg_list" | |
while [ $# -gt 0 ] ; do | |
case "$1" in | |
-b | --boolean) | |
echo "Parameter @ flag" | |
shift |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pre-built package (# Ubuntu 18.04.3 LTS) | |
sudo apt update | |
sudo apt install cppcheck | |
# Build from code | |
wget https://github.com/danmar/cppcheck/archive/2.1.tar.gz | |
tar zxvf 2.1.tar.gz | |
cd cppcheck-2.1 | |
mkdir build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Desktop Entry] | |
Type=Application | |
Name=EclipseC++ | |
GenericName=Eclipse | |
Comment=Eclipse for development | |
Exec=/path/to/eclipse | |
Icon=/path/to/icon.xpm | |
Terminal=false | |
MimeType=text/plain; | |
Categories=Development;IDE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A simple function which takes | |
# no parameters and returns nothing | |
function fun1() { | |
echo "A simple function" | |
} | |
# A function which takes parameters | |
# and return nothing | |
function fun2() { | |
echo "Fun:: Number of parameters: ${#@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A simple example of how dup2 can be used | |
const char* msg = "Text written by standard file descriptor\n"; | |
int fd = open("dup2_test.txt", O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); | |
write(fd, msg, strlen(msg)); | |
/* Map stdout to our file */ | |
dup2(fd, STDOUT_FILENO); | |
printf("Text written by dup @ stdout file descriptor\n"); | |
close(fd); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ubuntu 18.04.3 LTS | |
# Installation | |
sudo apt-get update | |
sudo apt-get install -y build-essential cmake git zlib1g-dev libncurses5-dev llvm-6.0-dev libclang-6.0-dev libclang-6.0-dev clang-6.0 | |
git clone https://github.com/include-what-you-use/include-what-you-use.git iwyu.git | |
cd iwyu.git | |
git checkout clang_6.0 | |
mkdir -p build | |
cd build | |
cmake -DIWYU_LLVM_ROOT_PATH=/usr/lib/llvm-6.0 .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To see top commands | |
history | awk '{print $2}' | sort | uniq -c | sort -rn | head | |
# To remove a commands from history | |
# Replace YOUR_COMMAND with the initials of the command you want to remove from bash history | |
sed -i '/^YOUR_COMMAND/d' ~/.bash_history |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Setup FTP server | |
# Instructions are tested on: Ubuntu 18.04.3 LTS | |
apt install -y atftpd | |
sudo gedit /etc/default/atftpd | |
# - set USE_INETD=FALSE | |
# - Optional: To change directory to host FTP contents, change /srv/tftp in OPTIONS line | |
# - Optional: To have maximum log: change --verbose=7 and append --logfile /var/log/atftpd.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Tensorflow session | |
tensorflow::SessionOptions session_opts; | |
tensorflow::OptimizerOptions* options = session_opts.config.mutable_graph_options()->mutable_optimizer_options(); | |
// Disable optimizations | |
options->set_opt_level(tensorflow::OptimizerOptions::L0); | |
// Grappler related optimizations | |
auto config = session_opts.config.mutable_graph_options()->mutable_rewrite_options(); | |
config->set_layout_optimizer(tensorflow::RewriterConfig::OFF); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script merge all pds found in a folder | |
# Where $1 is folder name | |
FOLDER="$1" | |
FILE_COUNT="$(ls $FOLDER/*.pdf | wc -l)" | |
NEW_NAME="merged-pdfs-$FILE_COUNT-$(cat /dev/urandom | tr -dc '0-9a-zA-Z' | fold -w 16 | head -n 1).pdf" | |
CMD="gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=$NEW_NAME" |
NewerOlder