Monday, October 26, 2015

Bash alias to copy the current IP to clipboard

This alias uses the one defined in the previous post to copy it to the clipboard.
We grabbed the IP with this alias in your .profile file in your home directory

alias cip="ifconfig | grep 'inet ' | grep -v 127.0.0.1 | awk '{print \$2}'"

Now define another one called cipb below it with this code

alias cipb="cip | tr -d '\n' | pbcopy"

So now you should have this in your .profile file
alias cip="ifconfig | grep 'inet ' | grep -v 127.0.0.1 | awk '{print \$2}'"
alias cipb="cip | tr -d '\n' | pbcopy"

This uses the pbcopy function to copy the value of your cip alias into the clipboard.
The tr -d '\n' removes the line ending from it. This allows me to use it when pasting it into a command on the terminal.
There is also cbpaste to paste whats in the clipboard. We can do a lot with these two commands, fun to play around with them.

You can find me on twitter @LZAntal

Friday, October 9, 2015

Properly install PIL or Pillow on Ubuntu

After installing PIL or Pillow on ubuntu server you notice that it doesnt have support for png, jpg, and freetype fonts.
It's because it's missing the lib files that it compiles against. Run these to get full support for those types.
sudo apt-get install libjpeg-dev
sudo apt-get install libpng-dev
After they installed you have to make sure they are linked/installed properly into /usr/lib. It never did for me so I run these commands.
sudo ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib
sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.so /usr/lib
sudo ln -s /usr/lib/x86_64-linux-gnu/libz.so /usr/lib
With that out of the way you are ready now to install PIL or Pillow and have full png, jpg and freetype support. To do that run this command.
sudo pip install Pillow

You can find me on twitter @LZAntal