How to Rotate a Multi Page PDF in Ubuntu Linux

So you have a PDF file that might be one or more pages, but you want to rotate the pages? Use these simple steps from your Ubuntu Linux command line terminal:

  1. Run sudo apt-get install python-pypdf (you need this to modify PDFs with Python)
  2. Create a text document to contain this python code:
    #!/usr/bin/env python
    import sys
    from pyPdf import PdfFileWriter, PdfFileReader
    input = PdfFileReader(sys.stdin)
    output = PdfFileWriter()
    for i in range(0,input.getNumPages()):
        output.addPage(input.getPage(i).rotateClockwise(90))
        output.write(sys.stdout)

    You can change 90 to -90 to rotate the other direction (left instead of right).

  3. Save & Close the file as rotatepdf.py
  4. Run chmod 755 rotatepdf.py to make it executable
  5. Run ./rotatepdf.py < input.pdf > output.pdf

Input.pdf is your original PDF file that is not rotated. Output.pdf is the PDF after rotation is applied (do not use the same filename for both).

Install Google Wallet on a Verizon Galaxy Nexus with Android Jelly Bean 4.1

I have a Verizon Wireless (VZW) Galaxy Nexus and upgraded it to Jelly Bean 4.1 as soon as I got my hands on it. But I couldn’t get Google Wallet installed on it because Verizon is stupid. It’s hidden from the Google Play store if you’re on Verizon, and often loading APK copied onto the device didn’t work for me either. But this post did the trick for me!

Steps:

  • UPDATE 2 for Sept 14, 2012: Verizon has blocked Google Wallet again! But luckily there’s a simple solution for Verizon Galaxy Nexus ICS & Jelly Bean owners: Download and run this updated APK file (if the file is no longer available, Google search for “Wallet_1.5-R79-v5.apk” and you should find it somewhere). Follow steps below to install it.
  • >Download the APK file from this post< (you have to register on the forum to download it =(
  • UPDATE: If that APK does not work for you, try the one >in this post< (thanks Tory Silvers)
  • In Root Explorer (ES File Explorer works too if you enable Root browsing), copy the apk file you want to put in /system/app
  • Navigate to the /system/app directory
  • Tap the Mount R/W button on the top right (not applicable with ES File Explorer)
  • Tap Paste
  • Scroll down to the pasted apk, long press on it and select Permissions (you’ll see 9 check boxes when you do this)
  • Check the Read and Write buttons for User
  • Check only the Read box next to Group and Others, then tap OK (once you’re done, the read/write permissions under the app name should be the same as all the other apps listed (rw-r–r–))
  • Reboot the phone

How to Set Up Logitech M510 USB Mouse on Ubuntu 12.04

Logitech has a great selection of USB mice for all operating systems and they often work without installing any software. Sometimes to get the most out of it however, you can configure your xorg.conf file on Ubuntu 12.04 and some previous Ubuntus. After plugging in the Logitech M510 USB wireless laser mouse, make sure the batteries are in and it is turned on. Then put this code into your /etc/X11/xorg.conf file:


Section "InputDevice"
Identifier "Logitech Mouse"
Driver "evdev"
Option "Protocol" "evdev"
Option "Name" "Logitech USB Optical Mouse"
Option "Phys" "usb-*/input0"
Option "Device" "/dev/input/by-id/usb-Logitech_USB_Receiver-mouse"
Option "Buttons" "8"
Option "ZAxisMapping" "4 5"
Option "Resolution" "1200"
Option "CorePointer"
EndSection

Note: If your xorg.conf file already has a section labeled “InputDevice”, replace it with this one.

It is recommended that you copy your current xorg.conf file to another one using the “cp” command before using this code. After it is done, restart your computer (logout/login might also work).

Anonymous Member takes down thousands of websites in GoDaddy attack

Earlier today, DNS and other servers at GoDaddy became unresponsive, throwing thousands of websites hosted there (including Snooth.com, the internet’s largest interactive wine website and where I work) offline.

Anonymous “Security Leader” @AnonymousOwn3r claims to be behind the take-down, who also points out that it is not Anonymous acting as a whole, just one person.


UPDATE: GoDaddy claims down time was caused by their own incompetency, not a hacker. Who do you think is right? Either way, this puts GoDaddy in a bad light.


According to AnonymousOwn3r, he is taking GoDaddy down to “test how the cyber security is safe” and for other reasons that cannot be disclosed at this time — perhaps keeping secret some sort of security exploit or hole.

Late last year, the internet was in a fury after GoDaddy announced its support of the US government’s proposed SOPA to censor websites just like what communist China does.

How to mount a DVD ISO as a drive in Ubuntu Linux

No additional software required. First, create a directory in which to mount the ISO.

mkdir -p ~/media/iso

Then, to mount it:

sudo mount -o loop /home/path/to/my_fun_dvd.iso ~/media/iso
nautilus ~/media/iso

The last line is to open the mounted directory in a visual file browser called Nautilus.

If you end up doing this often, you can create a bash function. Put this at the end of your ~/.bashrc file:

function mountcd {
sudo mount -o loop $1 ~/media/iso
}

Save the file, reload it in bash using this command

. ~/.bashrc

That’s (period)(space)~/.bashrc — the period is a command in bash that reloads the script file without having to launch the terminal again.

Now you can do this in the terminal:

mountcd ~/Downloads/my_cool_dvd.iso

And your DVD ISO will be ready for viewing in the ~/media/iso directory (the tilde character means your home directory, /home/john). In Ubuntu 12, by opening the folder containing the DVD files, it will prompt you to open with VLC media player:

Execute a command for each file in a directory recursively on Linux

I recently wanted to make a change — actually a string replacement — in every file in the current directory and all directories beneath it, perhaps filtering by file extension. In this case, I wanted to change four spaces to a tab character in every .php source file. I created a small BASH shell script file to do this, though you could also just run the command directly at the command line:

find . -type f -name '*.php' -exec sed -i 's/    /\t/g' {} \;

Explanation:

  • find lists all files, one per line, in the current directory and all subdirectories recursively
  • . (period) means current directory
  • -type f only list files, not directories.
  • -name ‘*.php’ only if the name matches * (wildcard) with “.php” at the end
  • -exec execute the following command for each result that matched
  • sed -i ‘s/    /\t/g’ replace, or substitute, one string for another. I’m searching for four consecutive spaces and replacing with t, meaning tab character. the /g at the end means global, replace each instance wherever it may appear in the file on each line. -i means “edit file in place” so the modified file is saved back to itself.
  • {} this inputs the file for the sed command
  • \; I think this finishes the -exec parameter for find. Don’t forget the backslash

To change spaces to tabs or tabs to spaces, you can also look into the expand and unexpand commands.

Overall I highly recommend learning the sed command for quick and easy find & replace operations in text files.

More examples of the find command with -exec:

Delete all directories matching a name, such as CVS, under the current directory:

cd /path/to/myproject/directory/src
find . -type d -name 'CVS' -exec rm -rf {} \;

Linux – Disk Usage (du) Sorted by Size

Here’s a simple way to find how much disk space is taken up by each folder in a directory, and sort it by size. This works in pretty much any Linux distribution (Ubuntu, Fedora, CentOS, and more).

du --block-size=MiB --max-depth=1 | sort -n
  • du is the disk usage and will, by default, recursively traverse every directory of the current one, listing the size of the directory by bytes. Without options, it isn’t very helpful (press Ctrl C to stop the process safely)
  • –block-size=MiB will convert the bytes amount to megabytes (or Mebibytes), so instead of showing 9437184 (bytes) it will show 9 MiB
  • –max-depth=1 will only list size of directories in the current directory. 2 will traverse an additional level down, and so on.
  • | sort -n will transfer, or “pipe”,  the output of the du program to the sort utility which simple sorts lines sent to it. -n tells it to sort numerically.
  • If you want to sort in reverse order, simply change n to rn
Example output:
statik@Phenom:~/Pictures$ du --block-size=MiB --max-depth=1 | sort -n
1MiB ./icons
1MiB ./USTM
1MiB ./vector
1MiB ./Webcam
3MiB ./animated
3MiB ./wallpaper
8MiB ./UltraMiami
688MiB ./2010
1600MiB ./2011
2306MiB .

As you can see, when I run this command in my Pictures folder, I have 688 MB of pictures in 2010 and 1600 MB of pictures in 2011.

You can add a shortcut to the command (an “alias”) by adding this to your ~/.bashrc or ~/.bash_aliases file

alias duinfo='du --block-size=MiB --max-depth=1 | sort -n'

The next time you open a terminal you can simply type “duinfo” and it will execute the alias. Tab completion also works.

Additional Tip: the ls (directory listing) command also supports the –block-size=MiB statement. Use –block-size=KiB for kilobytes, GiB for gigabytes, and so on.

Related Article: http://www.earthinfo.org/linux-disk-usage-sorted-by-size-and-human-readable/

A Solution to the Software Patent Problem?

Patents in the USA were intended to protect inventors against people copying, reproducing, and selling their own creations. But with software, things have gone awry with companies like Apple and Microsoft patenting the stupidest things — hoping they will slip through the US patent office and be accepted. And now to defend oneself from being sued for patent infringement, huge companies are scooping up patents in billion dollar buys. Apple and Microsoft recently paid $4.5 billion for Nortel‘s patent pool, and Google bought Motorola Mobility for $12 billion which included their patent pool.

This is a tremendous amount of money spent which isn’t even for any tangible product, research, or manpower. In the long run this is going to cost consumers by raising product prices (Microsoft gets $5-10 for every HTC phone sold, even though there is absolutely no Microsoft product or technology in it).

I was thinking about the patent problem and how it could be changed to protect the individual or company inventions but prevent big businesses from bullying other companies and hurting the consumer. What if patents could not be transferred to another individual or company without being released into the public domain? In other words if you hold a patent for something that you invented, you would still be fully protected by that patent, but you could not sell or transfer that patent power to someone else. If you decided to sell your company or go out of business, the patents automatically get released in the public domain.

This solution would protect the inventor (person or company) that invented the “thing”, but prevent the fake companies that just buy up patents and sue everybody from existing.

See also:

SwiftKey X Keyboard for Android Review

SwiftKey X Icon

UPDATE! Today only, SwiftKey X is free on the Amazon Appstore! Normally a $3.99 purchase.

The fastest and most advanced keyboard for Android, SwiftKey, just got better with SwiftKey X. SwiftKey is an Android keyboard replacement, the first that introduced the idea of next-word prediction and analyzing your e-mail and SMS messages to detect your own word and grammar patterns.

But is it really the best keyboard for Android right now? I think so. Read on past the break to find out why.
Continue reading