Sunday, April 6, 2025

VIM issues with powerline

What to do if you get this annoying issue -
vi requirements.txt Traceback (most recent call last): File "", line 4, in ModuleNotFoundError: No module named 'powerline' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 9, in ModuleNotFoundError: No module named 'powerline' An error occurred while importing powerline module. This could be caused by invalid sys.path setting, or by an incompatible Python version (powerline requires Python 2.6, 2.7 or 3.2 and later to work). Please consult the troubleshooting section in the documentation for possible solutions. Unable to import powerline, is it installed? Press ENTER or type command to continue
It means the your bash uses powerline and within your virtualenv your vim does not find the powerline python modules to exist. hence install powerline-status (yes 'powerline-status', as powerline is taken by some other project) That should resolve the issue

Friday, November 10, 2017

List directories via 'ls -d' - surprised me

List directories via 'ls -d' - surprised me

This was one of those feelings where I was left surprised with the humble linux command 'ls'

Here is what the man page says about ls -d -

-d, --directory

list directories themselves, not their contents
tried many times 'ls -d' all I got back was -
[sanjayu@dhcp-0-69:~]$
ls -dl
drwx--x---+ 110 sanjayu sanjayu 12288 Nov 10 19:39 .
[sanjayu@dhcp-0-69:~]$
ls -d
.
Now definitely there is something wrong, and I started searching the google. frankly not much came out as a help. I know we can do this via find ie find ./ -type d (using -maxdepth one can control recursive-ness). However, what intrigued me was man page and the contrary behaviour.

Finally found this - http://www.rapidtables.com/code/linux/ls.htm

ls -d */

Monday, March 6, 2017

Yum: search for a package through the disabled repos

Recently, I was searching for a package, it soon turned out that I need to archive this at least for myself. Here is it

Look for all the repos :

[stack@undercloud ~]$ yum repolist all
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* base: mirror.raystedman.net
* extras: mirror.pac-12.org
* updates: mirrors.sonic.net
515 packages excluded due to repository priority protections
repo id repo name status
!base/7/x86_64 CentOS-7 - Base 9,363
!centos-ceph-jewel/7/x86_64 CentOS-7 - Ceph Jewel 82
!delorean delorean-python-networking-bigswitch-2dd6c2693b8b203b9ac2148e9747609161514af9 520+236
!delorean-newton-testing/x86_64 dlrn-newton-testing 830+515
!extras/7/x86_64 CentOS-7 - Extras 264
!rdo-qemu-ev/x86_64 RDO CentOS-7 - QEMU EV 70
!updates/7/x86_64 CentOS-7 - Updates 856
repolist: 11,985

Find a package in disabled repolist

#!/bin/bashset -ex

for i in `yum repolist all | awk '{print $1}' | cut -d '/' -f 1 | sed 's/!//'`;
do
yum --disablerepo="*" --enablerepo="${i}" search $1done

Breaking up the script


  1. yum repolist all | awk '{print $1}' --> get the first columns and remove anything after '/'
  2. sed 's/!//' remove the annoying ! at the beginning
  3. search for the package use -
 yum --disablerepo="*" --enablerepo=$REPONAME search $PACKAGE_NAME


More here

Wednesday, March 1, 2017

Uploading to gist and sharing

Gist is a cool tool, here we are going to see how to use it from cli and use it as archiving or sharing utility.


Steps - 

[gist]
token: 
editor: 
  • Now you are set, use the following - 
gist create  - creates a new gist
gist edit    - edit the files in your gist
gist list    - prints a list of your gists
gist clone   - clones a gist
gist delete  - deletes a gist from github
gist files   - prints a list of the files in a gist
gist archive - downloads a gist and creates a tarball
gist content - prints the content of the gist to stdout
gist info    - prints detailed information about a gist
gist version - prints the current version

Tuesday, February 28, 2017

Skydive (real-time network topology and protocols analyzer) on Fedora

Skydive Installation on Fedora 25

Dependencies

  • Go >= 1.5
  • Elasticsearch >= 2.0
  • libpcap
  • libxml2
  • protoc >= 3.0

On Fedora, Install steps are -

  • Install GO
    • wget -c https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz
    • tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz
    • add the following in /etc/profile or ~/.profile
      export PATH=$PATH:/usr/local/go/bin
  • Install Elasticsearch
    • Elasticsearch requires JDK, hence we will install openjdk, as it works with it
      • sudo dnf install java-1.8.0-openjdk icedtea-web
    • Download RPM from https://www.elastic.co/downloads/elasticsearch
    • Install and start the services - 
    • sudo systemctl enable elasticsearch.service
      sudo systemctl start elasticsearch.service
  • Install libpcap, libxml2
    • dnf install gcc gcc-c++ glibc unzip libpcap libpcap-devel libxml2 libxml2-devel
  • Install protoc (via building from source)
    • wget -c https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip
    • unzip protoc-3.2.0-linux-x86_64.zip
    • cd protoc-3.2.0
    • ./configure 
    • make install
  • Build skydive
    • export GOPATH=`pwd1`
    • mkdir -p $GOPATH/src/github.com/skydive-project
    • git clone https://github.com/skydive-project/skydive.git $GOPATH/src/github.com/skydive-project/skydive
    • cd $GOPATH/src/github.com/skydive-project/skydive
    • make install

Running Skydive

  • Now that skydive installed, check via running - skydive allinone. If this works, we are ok, we can configure skydive to run with our tripleo setup
  • Create skydive.yml with the following content -
https://gist.github.com/adc0ded6c4d648cb9d1b531d51b90c1f
  • start the analyzer via - skydive agent --conf /etc/skydive.yml
  • start the agent  - skydive agent --conf /etc/skydive.yml
  • Fire up browser and watch the url http://hostname:8082/

Running some test scenarios

  • Download https://github.com/skydive-project/skydive/blob/master/scripts/simple.sh
  • run it, sudo bin/simple.sh start 172.16.99.1/24 172.16.100.1/24 to create two VM over a bridge br-int. Look at the flows in UI, enjoy!

Final Results

UI screenshot -

Tuesday, June 14, 2016

Youtube video to mp3 music for your music player

I listen to a lot of music over youtube, and I feel, thats an awful waste of bandwidth.

If I could just get the MP3 downloaded and listened over and over. Well this is possible! Let me tell you how?


youtube-dl -https://github.com/rg3/youtube-dl
This is a Python code which is a downloader of the video - 

sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dlsudo chmod a+rx /usr/local/bin/youtube-dlyoutube-dl https://www.youtube.com/watch?v=eKz6Jpg9op8

you can download a playlist as well in a folder and once the all are downloaded you can run this small shell script. Copy this in some file and run it

for i in *; do
f1=`sed 's/.\{4\}$//' <<< "$i"`;
echo ${f1}; f2="${f1}.mp3";
ffmpeg -i ${i} -q:a 0 -map a ${f2};
done

Monday, June 13, 2016

Docker based application on your laptop

You want to have apps running in docker container. why?

  1. Its convenient, to upgrade and twea k the app independent of changes to your own OS. 
  2. To have multiple images of upgrade apps, which you know are experimental and buggy.
  3. Ship-able, so things can be shared in a way which is exactly reproduce-able 
  4. Hype!

How to do it in the easiest of ways.

Git checkout - https://github.com/jfrazelle/dockerfiles
Someone has put a lot of hardwork and have made all the dockerfiles for most of the things you need - 
It is an exhaustive list.

Build it, hack it, resubmit it, use it!
I use the firefox, chrome, tor, slack containers. The sound is a bit buggy and doesnt work straight out of the box. Here are some blogs to get you started - Jassie Frazelle's Container on desktop, Setting the sound up.

Here is how I build and fired up chrome - 



#>cd ~/workspace
#>git clone https://github.com/jfrazelle/dockerfilescd
#>cd dockerfiles
#>docker build -t saneax/chrome-stable chrome/stable/
#>docker run -it --rm \
  --net host \ 
  --cpuset-cpus 0 \ 
  --memory 512mb \ 
  -v /tmp/.X11-unix:/tmp/.X11-unix:rw \ 
  -v /dev/snd:/dev/snd \ 
  --privileged \ 
  -v /dev/shm:/dev/shm \ 
  -v /etc/machine-id:/etc/machine-id \ 
  -v /var/lib/dbus:/var/lib/dbus \ 
  -v /run/user/`id -u`/pulse/native:/run/user/`id -u`/pulse/native \ 
  -v ~/.pulse:/home/$dockerUsername/.pulse \ 
  --name chrome saneax/chrome


Happy docking!

VIM issues with powerline

What to do if you get this annoying issue - vi requirements.txt ...