Saturday, November 26, 2016

Rotate a PDF under Linux with pdftk

sudo apt-get install pdftk

To rotate page 1 by 90 degrees clockwise:
pdftk in.pdf cat 1east output out.pdf 

To rotate all pages clockwise:
pdftk in.pdf cat 1-endeast output out.pdf 

From the "man" page
The page rotation setting can cause pdftk to rotate pages and documents. Each option sets the page rotation as follows (in degrees): north: 0, east: 90, south: 180, west: 270, left: -90, right: +90, down: +180. left, right, and down make relative adjustments to a page's rotation.

Adding a Swap Partition After System Installation

Updating partitions.
We need to edit /etc/fstab and add the new swap partition.

sudo nano /etc/fstab

We need to add a line that looks like

UUID=735b3be3-779c-4d21-a944-b033225f3ab4 none   swap    sw      0       0

The UUID can be got using the command

sudo blkid /dev/sdaX

---------///
We can format this partition with:

sudo mkswap /dev/sdX
replacing the X with your partition number. Mount this partition as swap with

sudo swapon -U UUID

If you want to use your swap for hibernating then you need to update the UUID in
/etc/initramfs-tools/conf.d/resume
with this content RESUME=UUID=xxx.
Don't forget to
sudo update-initramfs -u

-----///

Sunday, October 16, 2016

Embedding a PDF in Blogger

The following HTML code is to embed a PDF in Blogger (Blogspot). We only need to change the "srcid" value (the 0B6bwihHnzzPHbHdsQUpFYVQ3Mm8 part for the new corresponding PDF value)


The code can be downloaded from here.
Or copied from here:

<iframe height="480px" src="https://docs.google.com/viewer?srcid=0B6bwihHnzzPHbHdsQUpFYVQ3Mm8&amp;pid=explorer&amp;efh=false&amp;a=v&amp;chrome=false&amp;embedded=true" width="720px"></iframe>

Saturday, October 01, 2016

Mounting the Android Phone in Ubuntu 16.04

I was getting the following pop up message 'Unable to mount Android Device' every time that I plugged my Android smartphone in my Linux Ubuntu 16.04 machine.

I found the solution taking as a reference the following thread.

First I used the following command:

lsusb

That gives me:
Bus 001 Device 004: ID 04e8:6860 Samsung Electronics Co., Ltd Galaxy (MTP)

Then I included this info:
# Samsung LTD Galaxy
ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", SYMLINK+="libmtp-%k", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

in the following file:
sudo vim /lib/udev/rules.d/69-libmtp.rules

And the following line:
ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0666"

In the following file:

sudo vim /lib/udev/rules.d/61-persistent-storage-android.rules

And that's all. After a reboot my Linux PC can mount without problems my Android phone.

-----///

Wednesday, June 29, 2016

Updating the Youtube-DL (Now YT-DLP)

One way to solve error: "externally-managed-environment" is to create a virtual environment folder in your root path. By creating and using a virtual environment, you bypass the system Python entirely, allowing you to install and manage packages freely without impacting the system-wide Python installation.

sudo apt install python3-pip
sudo apt install python3.13-venv

python3 -m venv ~/py_envs
source ~/py_envs/bin/activate

python3 -m pip install yt-dlp
python3 -m pip install --upgrade yt-dlp

Before executing the 2nd command above, you can try executing first the 3rd command to see if the prompt returns a newer version suggestion than python3.13-venv  

yt-dlp is a better option with more functionalities. It's a fork from the youtube-dl 

Note: After you leave the virtual environment, if you need to use yt-dlp again, you have to first execute the 3rd and 4th commands above to set the virtual environment. 

Since this is installed in a virtual environment, you won't get notices of new versions available, so you have to run the 6th command above to check if there's an update ready to be installed. 
Sometimes the yt-dlp command may return an error when trying to download a video, in most cases that's fixed installing the new version. 

Thre's a lot of information and help in the manual:

man yt-dlp 

If you want to check first all the available formats of a YouTube video you need the URL of it along with the flag "-F" after the yt-dlp command:

yt-dlp -F https://www.youtube.com/watch?v=wh-07BzfgYY

And you will have an output like the following:
There will be a list of all the formats with IDs, formats, resolutions, video and audio codecs used, file sizes, extensions, FPS, if video or audio only, etc.

The command to download the format of your preference, by example if ID 18 do the following now using the lower case flag "-f" : 

yt-dlp -f 18 https://www.youtube.com/watch?v=wh-07BzfgYY

That format with ID 18 includes video and audio. But you can choose to merge video only plus audio only formats, in this case you need to have installed FFMPEG for the merge, if not installed yet proceed with:

sudo apt install ffmpeg

Then you can download and merge, by example ID 396 (video only) plus ID 139 (audio only) with the following command:

yt-dlp -f 396+139 https://www.youtube.com/watch?v=wh-07BzfgYY

Note: It's possible to download videos not only from YouTube.

-----------------------
The following produce an error and now it has been deprecated. It's better to use a virtual environment as shown here above:

sudo apt install python3-pip

sudo pip3 install --upgrade youtube-dl

-----------
The following is also deprecated:

sudo apt install python-pip

sudo pip install youtube-dl

If you want to upgrade youtube-dl

sudo pip install --upgrade youtube-dl

or, if necessary

sudo pip install --upgrade pip


The following method of installation is even older and deprecated, it's here just as a reference:

sudo apt-get install python-setuptools

sudo easy_install pip

Friday, February 12, 2016

Segmentation fault (core dumped)

If after a segmentation fault you are not getting the core dumped file, you might need to edit the limits.conf (this is in Ubuntu 14.04)

sudo vim /etc/security/limits.conf

and add a line like:
username      soft    core            50000

The previous line is for a core dumped file up to 50000 KB for that user. The user would have to relogin for the changes to take effect. A "small" core dump file is around 10 MB.

-----///