Saturday, November 15, 2014

Prepopulate a `user` field in a Django admin form

It took me a while to find the solution, which I am posting here:
class ArticleAdmin(admin.ModelAdmin):

    form = ArticleAdminForm

    def get_changeform_initial_data(self, request):
        initial = super().get_changeform_initial_data(request)
        initial['submitted_by'] = request.user
        return initial

Tuesday, November 11, 2014

Inside of a Blog: Implementing a ReDiS COUNT command in Lua

Inside of a Blog: Implementing a ReDiS COUNT command in Lua: I have recently been implementing a master/slave redis cache for our enterprise application and at certain points during the development/test phases, have found it useful to be able to query redis for the # of keys that have been inserted that match a certain regex...

In short:

eval "return #redis.pcall('keys', '*')" 0

Thursday, October 23, 2014

Stop Baloo in KDE

This will make an entry Indexing-Enabled=false in $HOME/.kde/share/config/baloofilerc :
$ kwriteconfig --file baloofilerc --group 'Basic Settings' --key 'Indexing-Enabled' false

Upgrading Kubuntu/Ubuntu from 14.04 to 14.10

Ensure that you have the upgrade tool installed:
$ sudo apt install update-manager-core
Reading package lists... Done
Building dependency tree       
Reading state information... Done
update-manager-core is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Run the upgrade tool. In my case it didn't work:
$ sudo do-release-upgrade
Checking for a new Ubuntu release
No new release found
Edit configuration to allow upgrades to non-LTS versions (change "lts" -> "normal"):
$ sudo nano /etc/update-manager/release-upgrades
Try again:
$ sudo do-release-upgrade
Checking for a new Ubuntu release
Get:1 Upgrade tool signature [198 B]
Get:2 Upgrade tool [1 147 kB]
Fetched 1 148 kB in 0s (0 B/s)
authenticate 'utopic.tar.gz' against 'utopic.tar.gz.gpg'
extracting 'utopic.tar.gz'
Don't forget to re-enable repositories which could have been disabled after the upgrade.

Monday, August 18, 2014

Exclude files and directories from Project View in IDEA

I have some files which are needed for the project, but they are service files which I have excluded from Git tracking  using .gitignore, but I also wanted them not to be shown in the file list. Here is how I did it.

1. Go to Settings -> File types -> Ignore files and folders.
2. Add *.iml;*.egg-info; to field "Ignore files and folders".

Tuesday, August 12, 2014

Learn Byobu in 10 minutes while listening to Mozart

From the Canyon Edge: Learn Byobu in 10 minutes while listening to Mozart: If you're interested in learning how to more effectively use your terminal as your  integrated devops environment , consider taking 10 minutes and watching this video while enjoying the finale of Mozart's Symphony No. 40, Allegro Assai (part of which is rumored to have inspired Beethoven's 5th).

Friday, June 27, 2014

Google I/O 2012 - Go Concurrency Patterns

Google I/O 2012 - Go Concurrency Patterns
Rob Pike

Concurrency is the key to designing high performance network services. Go's concurrency primitives (goroutines and channels) provide a simple and efficient means of expressing concurrent execution. In this talk we see how tricky concurrency problems can be solved gracefully with simple Go code.

For all I/O 2012 sessions, go to