Skip to content

Instantly share code, notes, and snippets.


asad akbar aakbar5

View GitHub Profile
View cppcheck - installation
# Pre-built package (# Ubuntu 18.04.3 LTS)
sudo apt update
sudo apt install cppcheck
# Build from code
tar zxvf 2.1.tar.gz
cd cppcheck-2.1
mkdir build
# 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: ${#@}"
View dup2_usage.c
// 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");
View include-what-you-need - installation
# 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 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 ..
aakbar5 / Ubuntu: Bash history management
Created Oct 31, 2019
Ubuntu: Bash history management
View Ubuntu: Bash history management
# 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
aakbar5 / Ubuntu: Setup FTP server
Created Oct 24, 2019
Ubuntu: Setup FTP server
View Ubuntu: Setup FTP server
# Setup FTP server
# Instructions are tested on: Ubuntu 18.04.3 LTS
apt install -y atftpd
sudo gedit /etc/default/atftpd
# - 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
aakbar5 / Tensorflow: configure grappler
Created Aug 17, 2019
Tensorflow: configure grappler
View Tensorflow: configure grappler
// Tensorflow session
tensorflow::SessionOptions session_opts;
tensorflow::OptimizerOptions* options = session_opts.config.mutable_graph_options()->mutable_optimizer_options();
// Disable optimizations
// Grappler related optimizations
auto config = session_opts.config.mutable_graph_options()->mutable_rewrite_options();
View Merge pdf files
# This script merge all pds found in a folder
# Where $1 is folder name
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"
aakbar5 / Tensorflow: Tensoboard
Created Mar 11, 2019
Tensorflow: Visualize freezed model file (.pb) in Tensorboard
View Tensorflow: Tensoboard
To visualize freezed Tensorflow model file use Tensorboard:
- Download (
- Create a directory (/path/to/tmp/folder) where intermediate files will be created to visualize model in Tensorboard.
- Execute
- python --model_dir="/path/to/folder/tensorflow_model_frozen.pb" --log_dir="/path/to/tmp/folder"
NOTE: Wrapped values to param # model_dir and param # log_dir in "". Otherwise it might not work.
- tensorboard --logdir="/path/to/tmp/folder"
aakbar5 / makefile: variable assignment
Last active Mar 11, 2019
Makefile: Exploring different ways to set value of a variable
View makefile: variable assignment
# Ref:
# Setting variables:
# ?= Set variable if it is empty
# := Expand value variable before assignment,
# NOTE: (1) The behaviour of ::= is same as :=
# (2) Expansion of value variable will be only once at the of value assignment.
# = Simple variable assignment, value will evaluated/expanded on its usage
# += Append value to variable