Close

Configure IPython5 to have IPython3’s readline, tab-completion, (lack-of) syntax highlighting, etc? (self.IPython)

Start by creating a default iPython profile. From your shell, type:

$ ipython profile create

That should give output similar to this:

[ProfileCreate] Generating default config file: u'/home/mmphego/.ipython/profile_default/ipython_config.py'
[ProfileCreate] Generating default config file: u'/home/mmphego/.ipython/profile_default/ipython_kernel_config.py'

Open the newly created file with your favorite text editor, in the above example shown as:

vim /home/mmphego/.ipython/profile_default/ipython_config.py

Add the following lines at the bottom:

c.TerminalInteractiveShell.display_completions = 'readlinelike'

Save the file.

Previous

Screenshot_2017-12-18_17-12-15

New

Screenshot_2017-12-18_17-13-11

Advertisements

Best way to find direct download links of any media

Disclaimer
Notice: This post does not endorse piracy. It’s purpose is merely educational.

We all know that everyone love convinience, by that I mean having to watch your favorite movie, series or let alone listen to your favorite tunes. But getting hold of those contents in this day of age has became cumbersome. I mere Google search of a movie you been dying to watch leads one to spam websites or even worse very disturbing pop-ups like literally – Give it a try. Torrents has always been a NONO for me, reasons are pretty much obvious.

The tricks I am going to list here, with this trick you do not need to access hundrends of websites in search of your favorite media content, and it will not consume hours and hours of your misrable life searching the interweb for your daily dosage of dophamine.

  1. Open your favorite browser and open Google
  2. Now type the name of the movie/series you wish want to download and then paste the following code after the movie name.
    • Method 1: "Name of Movie" -inurl:(htm|html|php|pls|txt) intitle:index.of “last modified” (mp4|wma|aac|avi|mkv)
    • Method 2: intitle:index.of? mkv|mp4|avi "Name of the movie"
  3. Google will display you the search result, click on either first or second results and you will get the download link of the movie.

I hope you found this article helpful, please note I do not endorse piracy this is merely for educational purposes.

How to mount remote SSHFS via SSH Tunneling!

sshfs is very handy for mounting remote directories on your local filesystem. Recently I needed to mount the / directory off a remote server so I can remotely work from home without complicating everything by ssh’ng then vim my code – Painful exercise.

All that is needed is to copy the code below to a file and chmod +x it.

#!/bin/bash
if [ -z "$*" ];
    then echo -e "Usage: $0 USERNAME HOST REMOTEHOST REMOTEPORT MOUNTPOINT \\n
    USERNAME: Default to local username
    HOST: Hostname or IP of server to connect to.
    REMOTEHOST: Host to tunnel via
    REMOTEPORT: Host port to tunnel via (Default: 2222)
    MOUNTPOINT: Local mounting point"
    exit 1;
fi

export PATH="${HOME}/bin:$PATH"
USERNAME=$1
HOST=$2
REMOTEHOST=$3
REMOTEPORT=$4
MOUNTPOINT=$5

# Assumptions: ssh keys have been generated and successfully copied over to remotehost, vice versa
# if necessary, openssh-client, openssh-server and sshfs packages installed
# The first we need to pre-establish a forwarded port over SSH.
ssh -v -f -N -L 1233:"${HOST}":22 -p "${REMOTEPORT}" "${REMOTEHOST}"
sshfs -p 1233 "${USERNAME}"@localhost:/ "${MOUNTPOINT}" -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3

Automagically execute a bash function/cmd upon entering a directory.

After growing tired of sourcing Petalinux/Yocto-project settings, I decided to compile a script/code that resides under my ~/.bashrc , the only thing the code/script does it automagically source my settings upon entering the directory else it will just list the contents of that directory.

source $HOME/.opt/Xilinx/Vivado/2017.2/settings64.sh
export YOCTODIR=$HOME/Documents/Xilinx/EmbeddedLinux/Yocto/poky
export PETADIR=$HOME/Documents/Xilinx/EmbeddedLinux/Petalinux
function cd {
    # The 'builtin' keyword allows you to redefine a Bash builtin without
    # creating a recursion. Quoting the parameter makes it work in case there are spaces in
    # directory names.
    builtin cd "$@"
    if [ "$PWD" == "$YOCTODIR" ] ;
        then
            bash $YOCTODIR/.source_yocto
    elif [ "$PWD" == "$PETADIR" ] ;
        then
            bash $PETADIR/.source_petalinux
    else
        ls -lhF;
    fi
}

The content of source_petalinux listed above.

$ cat $PETADIR/.source_petalinux
#!/bin/bash
. ~/.opt/petalinux/settings.sh

as well as .source_yocto

$ cat $YOCTODIR/.source_yocto

#!/bin/bash
. $HOME/Documents/Xilinx/EmbeddedLinux/Yocto/poky/oe-init-build-env

Xilinx PetaLinux 2017.2 installation on Ubuntu 16.04.3

Firstly, we will to the Xilinx Downloads page to obtain the installer. Select version 2017.2 on the left sidebar. Choose “PetaLinux 2017.2 Installer”. It is a single-file executable that is 7.54GB large.

Note: you have to be a registered user to download it.

Installation

Firstly we need enable i386 architecture (if running Ubuntu x64):

sudo dpkg --add-architecture i386

Before you proceed, make sure all the prerequisites are satisfied:

sudo apt install chrpath socat texinfo gcc-multilib libsdl1.2-dev xinetd tofrodos iproute \
gawk gcc git-core make net-tools ncurses-dev libncurses5-dev zlib1g-dev flex bison lib32z1 \
lib32ncurses5 lib32stdc++6 libselinux1 xvfb autoconf libtool libbz2-1.0 xinetd tftpd tftp \
lib32stdc++6 libgtk2.0-0:i386 libfontconfig1:i386 libx11-6:i386 libxext6:i386 libxrender1:i386 libsm6:i386 libssl-dev \
libqtgui4:i386

for a successful installation, we need to configure tftp

sudo nano /etc/xinetd.d/tftp

service tftp
{
protocol = udp
port = 69
socket_type = dgram
wait = yes
user = nobody
server = /usr/sbin/in.tftpd
server_args = /tftpboot
disable = no
}

Create a directory /tftpboot(this should match whatever you gave in server_args.)

sudo mkdir /tftpboot
sudo chmod -R 777 /tftpboot
sudo chown -R nobody /tftpboot

Restart tftp service

sudo /etc/init.d/xinetd stop
sudo /etc/init.d/xinetd start

/bin/sh to bash

sudo dpkg-reconfigure dash
# --> Select Yes

Now install PetaLinux into the directory/opt/petaLinux. The installer is a shell script that runs in the terminal.

chmod a+x petalinux-v2017.2-final-installer.run
export PETADIR=$HOME/.opt/petalinux
sudo mkdir -p $PETADIR
sudo chown $USER:$USER -R $PETADIR
./petalinux-v2017.2-final-installer.run $PETADIR

Press ‘ENTER' to see the licenses, q to quit reading the licenses, and y + ENTER to accept the licenses. The installation should last for about 15-30 mins.

Every time you want to use PetaLinux tools, remember to source the “settings” script to have the right environment variables:

source $HOME/.opt/petalinux/settings.sh

Creating your first project [Board Support Package]

The following is a super simple walk-through of how to use PetaLinux tools.

  1. To create a PetaLinux project with a specific BSP, In my case Zedboard

Once you have the BSP of your choosing downloaded (and extracted if it was a zip file), go to your terminal and change directory to where you would like to create your new PetaLinux project directory and enter the following command.
In my case it would be:

$ cd $HOME/Documents/Xilinx/EmbeddedLinux/Petalinux/Projects
Then run the petalinux-create command on terminal:

$ petalinux-create -t project -s avnet-digilent-zedboard-v2017.2-final.bsp

Rebuilding the reference design system

In order to rebuild the system run petalinux-build

$ petalinux-build -v

This step usually takes 15-30min depending on the performance of your system, the step generated a device tree ‘DTB’ file, the FSBL(First Stage Bootloader), U-Boot, Linux Kernel and the root file-system images

After the build is complete you can test it in a simulated environment.

Pre-built Petalinux image test with QEMU

Petalinux provide QEMU support to enable testing the image-built in a simulated environment.

$ petalinux-boot --qemu --prebuilt 3
# The --qemu option test petalinux-boot to boot in QEMU instead of real hardware,
# and --prebuilt 3 boots the pre-built <span 				data-mce-type="bookmark" 				id="mce_SELREST_start" 				data-mce-style="overflow:hidden;line-height:0" 				style="overflow:hidden;line-height:0" 			></span>linux kernel

Docker: Remove all images and containers

Problem:

You use Docker, but working with it created lots of images and containers. You want to remove all of them to save disk space.

Solution:

Warning: This will destroy all your images and containers. It will not be possible to restore them!

Run those commands in a shell:
# Delete all containers
sudo docker rm $(docker ps -a -q)
# Delete all images
sudo docker rmi $(docker images -q)

This solution has be proposed by GitHub user @crosbymichael in this issue

Create a global git commit hook

Recently found out about these git hooks and they work flawlessly but my only worry was that I had to copy all my hooks over every repo such that I could use them, which was a pain sometimes.

Then started reading about this so called global git hooks, and found a fix.

Usually the default template library is found at /usr/share/git-core/templates and we are going to use that directory for all our hooks.

1. Enable git templates:

git config --global init.templatedir '/usr/share/git-core/templates/'

This tells git to copy everything in /usr/share/git-core/templates/ to your per-project .git/ directory when you run git init

2. Write your hooks in /usr/share/git-core/templates/hooks.

For example, here’s an update hook (located in /usr/share/git-core/templates/hooks/update):

#!/bin/sh
# Prevent pushing changes to master branch
if [ $USER != "mmphego" ];
then
  if [ "$1" == refs/heads/master ];
  then
    echo "Manual pushing to this repo is restricted"
    exit 1
  fi
fi

4. Make sure the hook is executable.

chmod a+x /usr/share/git-core/templates/hooks/update

5. Re-initialize git in each existing repo you’d like to use this in:

git init

NOTE if you already have a hook defined in your local git repo, this will not overwrite it.

Back to top