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'
...

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 https://developers.google.com/io/

Make a set in Go

The Golang docs say:
A set can be implemented as a map with value type bool. Set the map entry to true to put the value in the set, and then test it by simple indexing.
Here is such a set implementation:
package main

import (
    "log"
    "runtime"
)

func main() {
    const SIZE = 10000000
    set := make(map[int]bool, SIZE)
    for i := 0; i < SIZE; i++ {
        set[i] = true
    }
    memStats := runtime.MemStats{}
    runtime.ReadMemStats(&memStats)
    println("Used", memStats.Alloc, "bytes")

    // test the set
    for i := 0; i < SIZE; i++ {
        _, ok := set[i]
        if !ok {
            log.Panic("The set does not contain the expected value!")
        }
    }
    for i := SIZE; i < SIZE*2; i++ {
        _, ok := set[i]
        if ok {
            log.Panic("The set contains an unexpected value!")
        }
    }
}
The memory usage is:
$ go run sets.go
Used 195924120 bytes
It turns out you can make the values to consuming 0 bytes of memory if they will not of type bool, but struct{}:
package main

import (
    "log"
    "runtime"
)

func main() {
    const SIZE = 10000000
    set := make(map[int]struct{}, SIZE)
    for i := 0; i < SIZE; i++ {
        set[i] = struct{}{}
    }
    memStats := runtime.MemStats{}
    runtime.ReadMemStats(&memStats)
    println("Used", memStats.Alloc, "bytes")

    // test the set
    for i := 0; i < SIZE; i++ {
        _, ok := set[i]
        if !ok {
            log.Panic("The set does not contain the expected value!")
        }
    }
    for i := SIZE; i < SIZE*2; i++ {
        _, ok := set[i]
        if ok {
            log.Panic("The set contains an unexpected value!")
        }
    }
}
And you can see that the memory usage with a map of 10,000,000 integers dropped:
$ go run sets.go
Used 177338200 bytes
The difference is 18,585,920 bytes.

Monday, May 5, 2014

Cache me if you can: memcached, caching patterns and best practices

PyCon US 2014, Guillaume Ardaud

Memcached is a popular, blazing fast in-RAM key/object store mainly used in web applications (although it can be used in virtually any software). You will walk out of this talk with a solid understanding of memcached and what it does under the hood, and become familiar with several patterns and best practices for making the most of it in your own Python applications.