Categories
OSX

Reduce the File Size of PDF Documents with Preview on OS X

The PDF file format is ubiquitous for good reason, mostly because it allows for perfect preservation of a documents formatting, text, and other elements. However, sometimes PDF can be quite bloated and a file that should be not more than 200KB can suddenly be 1.5MB for no obvious reason. Adobe’s Acrobat X has functions to reduce/optimise the size of a pdf. On OSX you can achieve the same with Preview.

For PDF files that have not been optimized yet, the Preview app in OS X can often reduce the file size considerably by passing it through an export filter.
export-pdf-to-compress-file-size
reduce-file-size-filter-for-pdf-preview

While it works great for text heavy files, it’s not a perfect solution for image-heavy slides. The “Reduce File Size” Quartz filter will indeed drastically shrink the file size of a pdf but the great savings in size come at a price. It will also make the slides look thoroughly awful. This is because the filter achieves its file size reduction by scaling all the images down by at least 50% and to no more than 512 pixels on a side, plus it uses aggressive JPEG compression. So not only will the images suffer from compression artifacts, they will also tend to get that lovely up-scaling blur.

Fortunatenly, anyone can create their own Quartz Filter with the ColorSync Utility shipped with OSX. The following zip file: PDF compression filters contains various files that reduce the file size while trying to minimise the amount of artifcats introduced in the images. It’s nowhere near as aggressive as the default Quartz-Filter.

The ColorSync Utility will by default save your own Quartz Filters in the following directory: /Users/YourName/Library/Filters/.

In order for the Filters to appear in the Save AS/Export menu the *.qfilter files need to be moved into the following directory

/Library/PDF Services/ Notice not in home folder (~/) but system-wide.

Afterwards the filters will appear in the dropdown menu of the export function:
Screenshot 2014-11-28 13.43.34

Categories
Linux

Limiting ssh user to SFTP using restricted shell

This is a follow up to the recent article about restricting ssh login to sftp. Back then I showed you how to restrict an ssh user who can login into a system by configuring openssh to prevent user logins of users associated with a specific group.

To do things differently I will show you an alternative and in my personal opinion easier way of restricting a ssh user to sftp. rSSH is a restricted shell that can be used with OpenSSH to only allow sftp and scp. It also includes support for rsync, rdist and cvs. This enables the creation of shell users without providing them full login access to the server except for transferring files.

First, make sure that the rssh package is installed (can be found in the usual repository). Since Debian is still my favourite distro I use aptitude. Use the equivalent on yours (yum, zypper etc.)

[bash]
# aptitude install rssh
The following NEW packages will be installed: rssh
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 65.8 kB of archives. After unpacking 185 kB will be used.
Get: 1 http://mirror.switch.ch/ftp/mirror/debian/ wheezy/main rssh amd64 2.3.3-6 [65.8 kB]
Fetched 65.8 kB in 0s (752 kB/s)
Preconfiguring packages …
Selecting previously unselected package rssh.
(Reading database … 137643 files and directories currently installed.)
Unpacking rssh (from …/rssh_2.3.3-6_amd64.deb) …
Processing triggers for man-db …
Setting up rssh (2.3.3-6) …
[/bash]

In order to restrict a user to SFTP the rssh shell needs to be configured as the login shell for the user. The following example adds a new user bubu to the system with the shell set to /usr/bin/rssh

[bash]
# useradd -m -d /home/bubu -s /usr/bin/rssh bubu
# passwd bubu
[/bash]

To change the shell of an existing shell use either usermod or the chsh command. Whichever you prefer.
[bash]
# usermod -s /usr/bin/rssh <old-user-name>
# usermod -s /usr/bin/rssh chris2

# chsh -s /usr/bin/rssh chris2
[/bash]

Afterwards, if you try logging in via ssh or sftp you will receive a similar response to this since by default rssh locks down the system completely leaving the user without any sort of access.

[bash]
$ sftp bubu@server.pretendco.com

$ ssh bubub@server.pretendco.com
[/bash]

Response:

[bash]
bubu@server.pretendco.com’s password: TYPE-THE-PASSWORD
Linux bubu@server.pretendco.com 3.13-0.bpo.1-amd64 #1 SMP Debian 3.13.10-1~bpo70+1 (2014-04-23) x86_64 GNU/Linux
Last login: Sun Nov 16 07:03:04 2014 from localhost
This account is restricted by rssh.
This user is locked out.
If you believe this is in error, please contact your system administrator.
Connection to server.pretendco.com closed.
[/bash]

The default action for rssh is to lock down any access. To adjust the default setting edit the rssh.conf file. Append or uncomment the following two lines: allowscp, allowsftp:

[bash]
# vi /etc/rssh.conf

# Leave these all commented out to make the default action for rssh to lock
# users out completely…

allowscp
allowsftp
#allowcvs
#allowrdist
#allowrsync
#allowsvnserve


[/bash]

The user should be able to login into the system now:

[bash]
$ sftp bubu@server.pretendco.com
Connecting to server.pretendco.com…
ubu@server.pretendco.com’s password:
sftp> pwd
Remote working directory: /home/bubu
sftp>
[/bash]

Categories
OSX

Bootable OS X 10.10 Yosemite USB installation drive

With the announcement of new iPads and iMacs and a refreshed Mac mini, Apple also released the final version of OSX 10.10 after multiple public betas. In case you are setting up multiple Macs or need an offline installer for older Macs that do not support “Internet Recovery” you can create an USB Installer. You will need the following:

  • A Mac with OSX Mavericks/Yosemite installed
  • 8GB or larger USB flash drive – preferably USB 3.0 if your Mac supports it
  • OSX 10.10 Installer from the AppStore in the Appllications folder.
  • Administative Access to your Mac (No restricted account)

Beware: All date on the USB key will be deleted (create a backup if necessary)

Using the Disk Utility format the Stick so it contains 1 HFS+ Partition and uses the GUID partitoning scheme (not the default MBR)

DiskUtility Partition Table

Leave the name “Untitled” as it is for now and format it using the Mac OSX Extended (Journaled) filesystem.

Open command line terminal and enter the following command

[bash]

sudo /Applications/Install\ OS\ X\ Yosemite.app/Contents/Resources/createinstallmedia –volume /Volumes/Untitled –applicationpath /Applications/Install\ OS\ X\ Yosemite.app –nointeraction

[/bash]

This command will erase the disk and copy over all necessary installation files. After a while the USB key will automatically be mounted and the volume will soon load the OSX installer. Additionally, a recovery partition has been created that may come in handy if the hard drive dives and not internet connection is available.

Categories
Android

Disabling factory installed Applications on an Android Phone without root

If you ever have used an Android phone I am pretty sure that you all experienced the following: Android Phones usually come with dozens of pre-installed applications. If you happen to receive your phone from a carrier it might even come with more carrier – centric applications which you might or might not like. The Android application managers offers the ability to disable most of these apps similar to how you uninstall applications acquired through the Google Play Store.

Disable Built - in Application
Disable Built – in Application

Short Remark: If the application came factory pre-installed and meanwhile has received updates through the Play Store the “Disable” button will probably be labelled with: “Uninstall Updates”

In contrast, the manufacturer may turn off the “Disable” functionality for certain system applications. As you can see on the next screenshot, the application cannot be disabled. The button is greyed out.

Application Management - Disabling Application not allowed
Application Management – Disabling Application not allowed

Fortunately, a way still exist to disable those apps without rooting your mobile phone using Android’s Debug Bridge.

  • Connect your device via USB and fire up a Terminal
  • Check that your device is connected using adb devices
  • Connect to a shell on your mobile phone using adb shell
  • pm list packages will show the package names of all installed applications on the phone (including built-in applications)

[bash]

shell@C6903:/ $ pm list packages
package:com.google.android.ears
package:com.sonyericsson.cameraextension.permission
package:ch.admin.meteoswiss
package:com.android.defcontainer
package:com.sonymobile.cameracommon
package:bbc.mobile.news.ww
package:com.audible.application
package:com.sonyericsson.orangetheme
package:com.android.phone
package:com.sonyericsson.initialbootsetup
package:com.mobisystems.fileman
package:com.sonyericsson.unsupportedheadsetnotifier
package:com.sonyericsson.providers.protectedmedia

[/bash]

To disable any app use the block command. Even those with Disable turned off can be disabled.
For example to disable Sony’s What’s New Application:

pm block com.sonymobile.advancedwidget.entrance

To turn off the small app widgets found in the recent app launcher execute the following commands:

[bash]
shell@C6903:/ $ pm block com.sony.smallapp.launcher
Package com.sony.smallapp.launcher new blocked state: true
shell@C6903:/ $ pm block com.sony.smallapp.app.widget
Package com.sony.smallapp.app.widget new blocked state: true
[/bash]

Reboot and you’re done.