Writing by shivdev on Tuesday, 11 of November , 2014 at 9:20 pm
If you’re having trouble selecting entries one at a time (because there’s no Select All option available) then here’s a quick workaround to selectively clear your Google Chrome History.
- In the Chrome Address Bar type chrome://history
- To Filter and Delete Selective history, enter search criteria and hit Search History
- There’s no Select All Option but here’s a workaround …
- Select the first entry from where you want deletion to begin
- Scroll down to the end or desired entry and Shift Click that item
- Scroll up top and hit Remove Selected Items
That should be quicker than individually selecting the entries.
Category: Tips and Tricks
Writing by shivdev on Saturday, 8 of November , 2014 at 10:05 pm
I was running into several errors while accessing a dictionary persisted in MongoDB as JSON (with Unicode) until I found this post on stackoverflow.com.
TypeError: string indices must be integers, not unicode
So basically the way to workaround the problem is as follows:
import json, ast
# You would assume this would work ...
somekey_val = dict[SOME_KEY]
# but due to frustrations with unicode in python handle it
try:
somekey_val = ast.literal_eval(dict[SOME_KEY])
except Exception, e:
print 'unicode conversion not needed for some_key'
# do regular processing from here on
process( somekey_val )
Category: Python
Writing by shivdev on Monday, 3 of November , 2014 at 6:18 pm
This post from stackoverflow.com explains it.
Basically, you will need to use the default=json_util.default argument as defined in the PyMongo Docs
So, while converting a date object in a dictionary to JSON
from bson import json_util
import json
json_str = json.dumps(anObject, default=json_util.default)
print json_str
And while reading back the JSON string into a dictionary
from bson import json_util
import json
json.loads(json_str, object_hook=json_util.object_hook)
Category: Python
Writing by shivdev 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.

Category: Apple,Tips and Tricks
Writing by shivdev 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”.
Category: Linux
Writing by shivdev 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’
Category: Linux