NoSQL Data Modeling Techniques

Highly Scalable Blog

NoSQL databases are often compared by various non-functional criteria, such as scalability, performance, and consistency. This aspect of NoSQL is well-studied both in practice and theory because specific non-functional properties are often the main justification for NoSQL usage and fundamental results on distributed systems like the CAP theorem apply well to NoSQL systems.  At the same time, NoSQL data modeling is not so well studied and lacks the systematic theory found in relational databases. In this article I provide a short comparison of NoSQL system families from the data modeling point of view and digest several common modeling techniques.

I would like to thank Daniel Kirkdorffer who reviewed the article and cleaned up the grammar.

To  explore data modeling techniques, we have to start with a more or less systematic view of NoSQL data models that preferably reveals trends and interconnections. The following figure depicts imaginary “evolution” of the major NoSQL…

View original post 3,646 more words

Advertisements

Open Navigation Drawer with a Handle

This type of functionality is not supported on DrawerLayout from support libraries. There are some third party libraries with all kind of additional functionality. They are huge and usually we don’t need all components included.

The implementation is very easy. After looking at source code of DrawerLayout class, we can see that there is onTouchEvent method predefined. So we have to delegate touch events from our “handle” widget to DrawerLayout.

 drag.setOnTouchListener(new View.OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {

       if(event.getAction() == MotionEvent.ACTION_DOWN){
          MotionEvent copy = MotionEvent.obtainNoHistory(event);
          copy.setEdgeFlags(ViewDragHelper.EDGE_ALL);
          copy.setLocation(0, event.getY());

          drawerLayout.onTouchEvent(copy);
       }
       return false;
   }
});

Object drag could be any type of View as long as we can listen to touch events. If touch action equals ACTION_DOWN than we delegate event handling to DrawerLayout object with motion event position X set to 0. All next updates will bi automatically propagated to DrawerLayout instance.

Terminating python script and releasing resources

Python script can be used as a background running service in order to provide some functionality. This service is often stopped on very aggressive way with process termination. Therefore some resources may not be released or child threads stopped.Below are two options how to handle script termination.

1.  Catching KeyboardInterrupt and SystemExit errors:

 try:
     running_service()
 except (KeyboardInterrupt, SystemExit):
     print("Termination occurred")
     handle_termination()
     sys.exit()

http://stackoverflow.com/questions/2564137/python-how-to-terminate-a-thread-when-main-program-ends

2.  Register on system signals:

Described in this post:  How To Catch “Kill” Events with Python

How To Catch “Kill” Events with Python

daniel's devel blog

Currently I’m working on a small MRCPv2 client written in Python, which is part of a bigger project at my laboratory. The client is started remotely by a program which controls and monitors several applications in the whole network and is stopped by it again.

In the Linux world catching “kill events” would be a simple task, to shut down another program a process just has to send a SIGTERM signal which can be caught be Python easily using the signal module which comes with every Python installation. However, on Windows things are a little bit harder, because the operating system never produces SIGTERM (and SIGILL) events according to the signal.h documentation from MSDN. That’s why it took me some time to figure out how to catch “kill” events under Windows with Python.

First of all, there are two different ways to close a program in Windows using the .NET…

View original post 87 more words

Raspberry PI: Volume control

Set the volume of sound output jack or USB sound card on Raspberry PI with Raspbian distro.

This action will be perfomed with amixer utility.

First list all audio capable devices:

$ amixer

Sample output:

Simple mixer control 'Speaker',0
 Capabilities: pvolume pswitch pswitch-joined penum
 Playback channels: Front Left - Front Right
 Limits: Playback 0 - 151
 Mono:
 Front Left: Playback 151 [100%] [0.06dB] [on]
 Front Right: Playback 151 [100%] [0.06dB] [on]
Simple mixer control 'Mic',0
 Capabilities: pvolume pvolume-joined cvolume cvolume-joined pswitch pswitch-joined cswitch cswitch-joined penum
 Playback channels: Mono
 Capture channels: Mono
 Limits: Playback 0 - 127 Capture 0 - 16
 Mono: Playback 0 [0%] [0.00dB] [off] Capture 0 [0%] [0.00dB] [on]
Simple mixer control 'Auto Gain Control',0
 Capabilities: pswitch pswitch-joined penum
 Playback channels: Mono
 Mono: Playback [on]

In my case I have three diferent control options. Try to find the right one. I am using external USB dongle with stereo output, so I will use “Speaker,0” device to control.

Execute command to set volume of selected control to 100% (or use prefered value):

$ amixer sset Speaker,0 100%

So simple is that. 🙂

SQLite documentation page exception

Try this url: http://www.sqlite.org/search?q=AND+OR.
Should be exception in sql. 🙂

Error: SQL logic error or missing database

SQL logic error or missing database
    while executing
"db one { SELECT count(*) FROM page WHERE page MATCH $::A(q) }"
    (procedure "searchresults" line 37)
    invoked from within
"searchresults"
    ("uplevel" body line 1)
    invoked from within
"uplevel { set doc "[searchform] [searchresults] [footer]" }"
    invoked from within
"time [list uplevel $script]"
    (procedure "ttime" line 2)
    invoked from within
"ttime { set doc "[searchform] [searchresults] [footer]" }"
    invoked from within
"db transaction {
    set t [ttime { set doc "[searchform] [searchresults] [footer]" }]
  }"
    (procedure "main" line 6)
    invoked from within
"main"

Setting up Objective-C on Ubuntu

This tutorial will explain how to set up environment for successful building Objective-C applications on Ubuntu for total beginners (without Apple machine) :).

It’s based on this step by step wizard: Getting started with Objective C on Ubuntu.

We can’t use default Cocoa implementation from iOS, instead we have another implementation suitable for Linux: GNUstep.

Needed steps:

  1. Install headers for gcc:
    sudo apt-get -y install build-essential
  2. Install GNUStep:
    sudo apt-get install gobjc gnustep gnustep-make gnustep-common
  3. Add next line to .bashrc
    #GNUSTEP Environment vars
    . /usr/share/GNUstep/Makefiles/GNUstep.sh

And you are good to go. How to create make file and Hello World follow this link: Getting started with Objective C on Ubuntu.

Some useful links:

Open source all the way.

%d bloggers like this: