Friday, May 13, 2016

Ubuntu - Moving Launcher to the bottom of the screen

Finally the default Unity Desktop’s left launcher panel can be moved to the bottom of screen in Ubuntu 16.04 LTS Xenial Xerus.
To move the launcher to the bottom of the screen,
gsettings set com.canonical.Unity.Launcher launcher-position Bottom
To revert back, run:
gsettings set com.canonical.Unity.Launcher launcher-position Left

Thursday, June 25, 2015

Change Chrome default to system print dialog on a mac

This the the magic command! To revert, just use false instead of true.

defaults write com.google.Chrome DisablePrintPreview -bool true

Tuesday, April 7, 2015

Adding empty folders to git

Create a .gitignore file in a directory and add the following 4 lines in it.

# Ignore everything in this directory
*
# Except this file
!.gitignore

Monday, February 2, 2015

Python logging module basics

The Python logging module organizes loggers in a hierarchy. All loggers are descendants of the root logger. Each logger passes log messages on to its parent. So in effect, you have two ways of configuring logging.

1. Setup the configuration at a particular logger level.

2. Setup the configuration at the root level. If a particular logger doesn't have a configuration, the default(root) level configuration will be used.


To configure the root level logger, use the following snippet in your main entry script.


import logging
LOG_LEVEL = logging.DEBUG
logger = logging.getLogger() # Gets the root logger
logger.setLevel(LOG_LEVEL)
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(LOG_LEVEL)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
handler.setFormatter(formatter)
logger.addHandler(handler)


Then in all other modules, you can add two simple lines to create a module level logger. As the module level logger doesn't have any configuration, it will use the root level logger configuration.
import logging
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())

You can configure the root logger by using the logging.basicConfig() function.

logging.getLogger(name)

Return a logger with the specified name or, if no name is specified, return a logger which is the root logger of the hierarchy. If specified, the name is typically a dot-separated hierarchical name like “a”, “a.b” or “a.b.c.d”. Choice of these names is entirely up to the developer who is using logging.

Friday, December 12, 2014

Upgrading all install packages with pip

See upgrades available
The following commands will show all the packages which have an upgrade available.

$ pip list --outdated
argparse (Current: 1.2.1 Latest: 1.2.2)
astroid (Current: 1.2.1 Latest: 1.3.2)
ipython (Current: 2.3.0 Latest: 2.3.1)

$pip freeze | cut -d = -f 1 | xargs -n 1 pip search | grep -B2 'LATEST:'
(standard input)-4-argparse                  - Python command-line parsing library
(standard input)-5-  INSTALLED: 1.2.1
(standard input):6:  LATEST:    1.2.2
--
(standard input)-42-astroid                   - An abstract syntax tree for Python with inference support.
(standard input)-43-  INSTALLED: 1.2.1
(standard input):44:  LATEST:    1.3.2
--
(standard input)-48-ipython                   - IPython: Productive Interactive Computing
(standard input)-49-  INSTALLED: 2.3.0
(standard input):50:  LATEST:    2.3.1

Upgrade all packages
Use this command to install all the installed packages using pip.

pip install -U `pip list --outdated | awk '!/Could not|ignored/ { print $1}'`

Install python-ldap on macos

When install python-ldap on macos, you may get an error about sasl.h. To resolve this error, use the following commands,

$ xcrun --show-sdk-path 
$ sudo ln -s /usr/include /usr/include
$ pip install python-ldap

More details on the issue can be found here.

Monday, November 24, 2014

Setting wordpress permissions

chgrp www-data /var/lib/wordpress/wp-config.php
chmod 660 /var/lib/wordpress/wp-config.php
chgrp www-data /var/lib/wordpress/.htaccess
chmod 664 /var/lib/wordpress/.htaccess
find /var/lib/wordpress/wp-content -exec chgrp www-data {} \;
find /var/lib/wordpress/wp-content -type d -exec chmod 775 {} \;
find /var/lib/wordpress/wp-content -type f -exec chmod 664 {} \;

Friday, August 15, 2014

Install Samsung ML 2010 driver on OSX Mavericks

The ML-2010 problem has been fixed for me Installing the usbtb usb backend for CUPS.

The procedure I followed:

Download and install from the gutenprint page http://sourceforge.net/projects/gimp-print/files/ the two packages gutenprint-5.2.9.dmg and usbtb-1.0.17.uni.dmg. Actually the gutenprint driver doesn’t support the ML-2010 but without it the usb backend didn’t work for me.

Install the official Samsung ML-2010 driver.

Reset the printing system - http://support.apple.com/kb/HT1341

Add a new printer (+), wait 20-30 seconds and the Samsung ML-2010, Type USB Printer (usbtb) appears in the printers list, next to the usual Samsung ML2010, Type USB.

Select the new one and manually choose the Samsung ML-2010 official driver for it.

My old Samsung printer is working very well now, much quicker than before.

It seems the printer Intermittence was due to some issue on the usb layer communication, from the Samsung Driver and the CUPS server.

Thursday, June 26, 2014

Problems with touchpad on Logitech K400 keyboard

To disable the tap to click,

Hold down the blue function key and the left trackpad key simultaneously.

No software is required for this an it works independent of the operating system.

Friday, May 30, 2014

Virtualbox error - Kernel driver not installed (rc=-1908) Make sure the kernel module has been loaded successfully.

Virtualbox stops working after MacOS upgrade with the following error message,

Kernel driver not installed (rc=-1908)

Make sure the kernel module has been loaded successfully.

The following command will fix the issue.

# sudo /Library/Application\ Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh restart
/Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart => /Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxBalloonCtrl => /Applications/VirtualBox.app/Contents/MacOS/VBoxBalloonCtrl-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxDD2GC.gc => /Applications/VirtualBox.app/Contents/MacOS/VBoxDD2GC.gc-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxDDGC.gc => /Applications/VirtualBox.app/Contents/MacOS/VBoxDDGC.gc-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxExtPackHelperApp => /Applications/VirtualBox.app/Contents/MacOS/VBoxExtPackHelperApp-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxHeadless => /Applications/VirtualBox.app/Contents/MacOS/VBoxHeadless-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxManage => /Applications/VirtualBox.app/Contents/MacOS/VBoxManage-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxNetAdpCtl => /Applications/VirtualBox.app/Contents/MacOS/VBoxNetAdpCtl-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxNetDHCP => /Applications/VirtualBox.app/Contents/MacOS/VBoxNetDHCP-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxNetNAT => /Applications/VirtualBox.app/Contents/MacOS/VBoxNetNAT-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxSVC => /Applications/VirtualBox.app/Contents/MacOS/VBoxSVC-amd64
/Applications/VirtualBox.app/Contents/MacOS/VBoxXPCOMIPCD => /Applications/VirtualBox.app/Contents/MacOS/VBoxXPCOMIPCD-amd64
/Applications/VirtualBox.app/Contents/MacOS/VMMGC.gc => /Applications/VirtualBox.app/Contents/MacOS/VMMGC.gc-amd64
/Applications/VirtualBox.app/Contents/MacOS/VirtualBox => /Applications/VirtualBox.app/Contents/MacOS/VirtualBox-amd64
/Applications/VirtualBox.app/Contents/MacOS/VirtualBoxVM => /Applications/VirtualBox.app/Contents/MacOS/VirtualBoxVM-amd64
/Applications/VirtualBox.app/Contents/MacOS/vboxwebsrv => /Applications/VirtualBox.app/Contents/MacOS/vboxwebsrv-amd64
Loading VBoxDrv.kext
Loading VBoxUSB.kext
Loading VBoxNetFlt.kext

Loading VBoxNetAdp.kext

Tuesday, May 20, 2014

Get a list of all packages installed on Ubuntu

The following command will provide a list of all packages installed on Ubuntu.

dpkg --get-selections

Get a list of crontabs for all users on a system

The following command will print a list of crontabs for all users of the system.

for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done

Friday, May 16, 2014

Find largest files in a directory and display in human readable form

find . -type f -exec du -a --human-readable {} + | sort --human-numeric-sort -r | head

Sunday, March 30, 2014

Print the attributes of an object in Python

This can be done easily using,

print object.__dict__

You can also write a function as below.

def dump_an_object(obj):
    for attr in dir(obj):

        print "obj.%s = %s" % (attr, getattr(obj, attr))

Monday, March 24, 2014

Getting rid of unicode pain in Python

Python programming has its quirks and one of them revolves around Unicode. This article provides a very useful explanation of the issues and ways to go around it.

http://nedbatchelder.com/text/unipain.html


Monday, March 3, 2014

REST API Guide

Here is a good guide to the REST API's.

http://rest.elkstein.org


Thursday, January 23, 2014

Uninstall McAfee Agent on a Mac



To uninstall McAfee Agent on a Mac,

1. Log on as an administrator or with root account permissions.
2. Open the Terminal window and type,

sudo /Library/McAfee/cma/uninstall.sh

Type the logged on administrator or root account password and press ENTER to uninstall the Agent.

NOTE: During the removal, you will see the following messages: stopping McAfee agent and McAfee agent stopped.

Restart your computer when the uninstall is complete.

Uninstall McAfee Endpoint Protection for Mac 2.1.0

1. Open a Terminal window. Type the following command, then press return.

sudo /usr/local/McAfee/uninstall EPM

The uninstallation command is case sensitive.

Type the administrator password when prompted. When self-protection feature is enabled in EndPoint Protection for Mac 2.1.0 uninstalling the software using the command line prompts you to type the password provided by the ePolicy Orchestrator administrator.

When the software is uninstalled, the following message appears:

McAfee Endpoint Protection for Mac 2.1.0 has been uninstalled successfully.

When you uninstall the software, the McAfee Agent is not uninstalled from the system. This is
because that it might be used by other products. Refer to the product guide of your McAfee Agent
version for more information.

Wednesday, December 11, 2013

Installing ntfs-3g on Mavericks

http://crosstown.coolestguidesontheplanet.com/os-x/56-how-to-write-to-a-ntfs-drive-from-os-x-mavericks

Friday, November 15, 2013

Interface builder for bootstrap CSS

Here it is... A tool to build bootstrap websites quickly.

http://www.layoutit.com/