wayland/weston

To remove topbar from the wayland/weston desktop, add following lines in its configuration.

[Shell]
panel-location=""
panel-position=none

config file can be found at

/etc/xdg/weston/weston.ini

Once changes are saved, restart it

systemctl restart weston

Most probably Wayland/Weston log file will be:

/var/log/weston.log

rename git branches

Let’s rename a git branch locally & remotely.

Let’s assume that you got git repository with multiple branches and you want to mark a branch as a master whereas existing master to something else.

  • Make note of the branch names and their respective remote
git branch -vv
  • Goto server repo and switch default branch
git symbolic-ref HEAD refs/heads/new-master
  • Goto local repo, checkout master
git checkout master
  • Rename it locally
git branch -mv master something
  • Remove remote branch
git push origin --delete master
  • Set new remote
git branch --unset-upstream
git push --set-upstream origin something
  • Goto server repo and switch default branch
git symbolic-ref HEAD refs/heads/something
  • Switch to branch which is going to be new master
git checkout new-master
  • Rename this branch
git branch -mv new-master master
  • Remove remote branch
git push origin --delete new-master
  • Set new remote
git branch --unset-upstream
git push --set-upstream origin master
  • Goto server repo and switch default branch to master
git symbolic-ref HEAD refs/heads/master

Tensorflow grappler

Tensorflow runtime got a module grappler which does optimizations once model is loaded into module. Tensorflow session parameter can be used to control this optimization applied by grappler.

// 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);
config->set_disable_model_pruning(true);
config->set_function_optimization(tensorflow::RewriterConfig::OFF);
config->set_arithmetic_optimization(tensorflow::RewriterConfig::OFF);
config->set_loop_optimization(tensorflow::RewriterConfig::OFF);
config->set_dependency_optimization(tensorflow::RewriterConfig::OFF);
config->set_constant_folding(tensorflow::RewriterConfig::OFF);
config->set_memory_optimization(tensorflow::RewriterConfig::NO_MEM_OPT);
config->set_shape_optimization(tensorflow::RewriterConfig::OFF);
config->set_remapping(tensorflow::RewriterConfig::OFF);
config->set_pin_to_host_optimization(tensorflow::RewriterConfig::OFF);
config->mutable_auto_parallel()->set_enable(false);
config->clear_optimizers();
// Create tensorflow session with customized options
std::unique_ptr<tensorflow::Session> tf_session(tensorflow::NewSession(session_opts));

Merge PDF files

Merge pdf files placed in a folder:

#!/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"
# Get all files and append to command
for file in "$FOLDER"/*.pdf; do CMD="$CMD $file"; done
echo "Folder: $1"
echo "File Count: $FILE_COUNT"
echo "Pdf: $NEW_NAME"
# echo "Cmd: $CMD"
echo ""
echo "Merge in progress…"
ret="$($CMD)"
echo "*** $NEW_NAME is ready."

view raw
Merge pdf files
hosted with ❤ by GitHub

Tensorflow: Visualize freezed model file (.pb) in Tensorboard

To visualize freezed Tensorflow model file use Tensorboard:
– Download import_pb_to_tensorboard.py (https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/tools/import_pb_to_tensorboard.py)
– Create a directory (/path/to/tmp/folder) where intermediate files will be created to visualize model in Tensorboard.
– Execute
– python import_pb_to_tensorboard.py –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"
– By default Tensorboard runs on 6006, so open http://localhost:6006 in your web-browser to see Tensorboard.
– JFI: To inspect model without loading in web browser:
– tensorboard –inspect –logdir="/path/to/tmp/folder"

Makefile: value assignment to variable

Makefile: Exploring different ways to set value of a variable
# Ref: https://www.gnu.org/software/make/manual/html_node/Setting.html#Setting
########
# 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
# != Value variable will be evaluated before assignment.
# override directive
########
# UnComment following line NOT_SET_VAR will have VAL_0
# otherwise VAL_1
# NOT_SET_VAR = VAL_0
# Only set value to VAL_1 if NOT_SET_VAR hasn't got any value
NOT_SET_VAR ?= VAL_1
########
########
# EXPAND_VAR_ASSIGNMENT should be set to ZERO
VAR_0 := 10
VAR_1 := $(VAR_0)
ifeq ($(VAR_1),10)
EXPAND_VAR_ASSIGNMENT := ZERO
else
EXPAND_VAR_ASSIGNMENT := ONE
endif
########
# Simple assignment
VAR_X = 100
VAR_Y = 200
VAR_Z = $(VAR_X),$(VAR_Y),300 # On usage of VAR_Z, it will be expanded
# and it will end up with 100,200,300
# UnComment following line, the VAR_Z will show 200,200,300
# VAR_X = 200
########
# Appending
VAR_APPEND := 1
VAR_APPEND += 2 # VAR_APPEND will have 1 2
########
# Override: If a var has been set with command argument then
# simple assignment will not change its value.
# make -f variables.mk VAR_OVERRIDE_0=300
override VAR_OVERRIDE_0 = 200
override VAR_OVERRIDE_1 := 200
override VAR_OVERRIDE_APPEND += 200
all:
@echo "NOT_SET_VAR is having $(NOT_SET_VAR)"
@echo "EXPAND_VAR_ASSIGNMENT is having $(EXPAND_VAR_ASSIGNMENT)"
@echo "VAR_Z is having $(VAR_Z)"
@echo "VAR_APPEND is having $(VAR_APPEND)"
@echo "VAR_OVERRIDE_0 is having $(VAR_OVERRIDE_0)"
@echo "VAR_OVERRIDE_1 is having $(VAR_OVERRIDE_1)"
@echo "VAR_OVERRIDE_APPEND is having $(VAR_OVERRIDE_APPEND)"

Setting env variables in makefile

Makefile: Setting up environment variables globally as well as from a phony target.

GLOBAL_VAR=GOLBAL_VAR_VALUE # This value will be set as it is global
export GLOBAL_VAR_EXPORT=GLOBAL_VAR_EXPORT_VALUE # This value will be set as it is global
# @$(foreach var, $(filter GB_ENV_%, $(.VARIABLES)), $(eval export $(subst GB_ENV_,,$(var))=$($(var))))
all:
# Following two vars remain unset as Makefile doesn't set var under phony target
@LOCAL_VAR=LOCAL_VAR_VALUE
@export LOCAL_VAR_EXPORT=LOCAL_VAR_EXPORT_VALUE
# Following two vars will be set using eval
@$(eval LOCAL_VAR_EVAL=LOCAL_VAR_EVAL_VALUE)
@$(eval export LOCAL_VAR_EXPORT_EVAL=LOCAL_VAR_EXPORT_EVAL_VALUE)
@echo "GLOBAL_VAR : $(GLOBAL_VAR)"
@echo "GLOBAL_VAR_EXPORT : $(GLOBAL_VAR_EXPORT)"
@echo "LOCAL_VAR : $(LOCAL_VAR)"
@echo "LOCAL_VAR_EXPORT : $(LOCAL_VAR_EXPORT)"
@echo "LOCAL_VAR_EVAL : $(LOCAL_VAR_EVAL)"
@echo "LOCAL_VAR_EXPORT_EVAL : $(LOCAL_VAR_EXPORT_EVAL)"