Show Date and Time in Mac Menu Bar

Writing by on Monday, 27 of October , 2014 at 4:18 am

I’m not sure why this is not a default option, but if you want to show Date and Time in the Menu Bar on a Mac, then you you will need to set that in your System Preferences.

System Preferences –> Date & Time (Select Clock) –> Check Show date

Here’s a screenshot.

Leave a comment

Category: Apple,Tips and Tricks

SyslogNG – The Basics

Writing by on Wednesday, 22 of October , 2014 at 6:14 pm

You can find enough documentation online and edoceo is a good resource. But the basics of setting up Syslog-NG are as follows.

Setup and configure the Host Machine where you will receive the syslog messages.

# 1. Install syslog-ng
$ sudo apt-get install syslog-ng

# 2. Backup the config file syslog-ng.conf
$ sudo cp /etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf.orig

# 3. Edit the config file
$ sudo vi /etc/syslog-ng/syslog-ng.conf

# 4. Create a Source, a Destination and bind them together through Log
# Add these in the relevant sections
source s_net { udp(ip(“0.0.0.0”) port(514)); tcp(); };
destination d_somedest { file(“/var/log/somedest.log”); };
log { source ( s_net ); destination ( d_somedest ); };

# 5. Restart syslog-ng
$ sudo service syslog-ng restart

When you configure your Appliance to forward syslog to your Host, you will see the logs in “/var/log/somedest.log”.

Leave a comment

Category: Linux

Escape quote in alias

Writing by on Wednesday, 22 of October , 2014 at 5:25 pm

I wanted to create change the prompt to show the active git branch through an alias.
Changing PS1 as follows would do it as follows:

# Try this in bash to get the git prompt, but how do you alias this?
PS1='[\u@\h \W$(__git_ps1 ” (%s)”)]\$

However I needed to create an alias for it and turns out that if you wanted to escape a single quote you could do it using the following: ‘”‘”‘

# Note here that the entire aliased string needs to be escaped using a quote
alias ingit=’PS1='”‘”‘[\u@\h \W$(__git_ps1 ” (%s)”)]\$'”‘””

Now I can activate the git prompt that I need through an alias that contains a combination of single and double quotes.

Now !!! I wanted to change the IP Address of my DHCP vm in the /etc/hosts file. (Related sed Article)

# something that works
$ sed -i ” ‘s/^192.168.*vm/192.168.1.12 vm/’ /etc/hosts

# i would like to do something like this
$ setvmip 192.168.1.12

# so the escaped version is
alias setvmip=’function _setvmip(){ sudo sed -i “” ‘”‘”‘s/^192.168.*vm/'”‘”‘$@'”‘”‘ vm/'”‘”‘ /etc/hosts ; }; _setvmip’

Leave a comment

Category: Linux

Passing arguments to a script started through Ubuntu Upstart

Writing by on Thursday, 9 of October , 2014 at 5:54 pm

If you’re trying to use the –exec option and need to pass in arguments, then you would need to use — to let –exec know that these are arguments to the script that needs to be executed.

# No arguments passed to test.py
exec start-stop-daemon –start –exec python test.py

# Arguments (-i $PARAM) passed to test.py
exec start-stop-daemon –start –exec python test.py — -i $PARAM

Leave a comment

Category: Linux,Python

Find out modules installed by pip

Writing by on Wednesday, 1 of October , 2014 at 3:52 am

We have a bunch of Python (2.7) virtual environments and I needed a way to figure out a way to list modules installed by pip within the context of that venv and then grep for a particular one. I’m not a super Python expert at this time, but wrote up a small script to list this.

Here’s a python script:

# pip_installed_modules.py 
import pip

def main():
	modules = pip.get_installed_distributions()
	for m in modules:
		print m


if __name__ == "__main__":
    main()

Here’s my alias:

alias pipmodules=’python ~/bin/pip_installed_modules.py’

Now I can simply grep for specific modules or just see the installed modules.

Leave a comment

Category: Python

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.