Data Versioning

Data Versioning, Temporal Data, Transaction Time Validity. Different names for maintaining snapshots of data that are consistent across multiple tables at any point in time. Just like Time Machine, but for data. 

This is a description of how it can be implemented with MySQL. 

The basic technique with the use of views is described and illustrated here (under ”The better plan”), we’ve just improved it a bit.

First of all a data table to store information about people. Every time a record is updated, a new record is created. 

The table will hold all historic versions of each people record, including the most current one.

CREATE TABLE people_data (

id_version BIGINT UNSIGNED,

Firstname VARCHAR(255),

Lastname VARCHAR(255),

moddate TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,

KEY id_version(id_version)

);

Then we have a table to keep track of versions and hold some meta data about each version. This table is common for all data tables that we want to enable versioning for. This is a variant of the Audit table on http://www.codeproject.com/KB/architecture/LisRecordVersioning.aspx but we use timestamp_start and timestamp_end instead of IsActive, to be able to get the historic state across all data tables of any point in time (this is picked up from http://www.paragon-cs.com/mag/issue7.pdf ).

CREATE TABLE version (

id BIGINT UNSIGNED auto_increment,

guid VARCHAR(20),

changedby_start VARCHAR(100),

changedby_end VARCHAR(100),

dt_start DATETIME,

dt_end DATETIME DEFAULT ’3000-01-01 00:00:00’,

PRIMARY KEY (id),

KEY guid(guid),

KEY dt_start (dt_start),

KEY dt_end (dt_end));

Läs mer

Adding to SVN without import

Add project files to svn without using import to be able to use ignore.

Since there is no svn meta info about the files yet before the files have been imported there is no way to use ignore to skip for example a huge media folder when using import. Hen and egg situation.

Instead we use svn add in a special way. Maybe you do like this all the time but it took me some head scratching to figure out.

In the example below we have a live webroot that will be ”svn enabled”. Don’t forget to block .svn directories in the web server when checking out a working copy to a live web folder!

1. Create an empty folder ”webroot” in the project repository, typically /trunk/webroot. Let it be empty.

2. Go to a level above the webroot folder on the live server, so webroot is listed when doing ls.

3. Check out the empty webroot folder over the live webroot

svn checkout svn://user@svnserver/Projekt/trunk/webroot webroot

Now the webroot is ”svn enabled” and a valid working copy on the live server, but no files are added yet since we checked out an empty folder from the repository.

Existing files in the live web root are untouched.

4. Get into webroot

cd webroot

5. Add the desired svn ignore (don’t forget the dot at the end, it says ”current directory”)

svn propset svn:ignore media .

Verify with

svn propget svn:ignore

It should list ”media”.

6. Add all live files form the web root.

svn add *

 

Here’s the catch: The problem is that this will also add all files in ignored directory since the asterisk overrides the ignore (explicit adding overrides ignore and the asterisk expands to a series of explicit adds). Verify with svn status to see that also media has A as in added, and it will be a heavy commit if the media directory is large.

7. Fix this by reverting the add of the directory we wanted to ignore.

svn revert –recursive media

Verify this with

svn status –no-ignore

Media is now listed with an I as in ignore. Great!

8. Commit the live web files from the webroot

svn commit -m ”Initial import from live server”

Read more here

http://episteme.arstechnica.com/eve/forums/a/tpc/f/6330927813/m/427002825931

Ett gott råd till hitta.se

Ni hade sluppit en massa gnäll i debatten om ni maskerade alla ansikten och registreringsnummer på Gatubild. Det tillför inget att ha med identifierbara människor och fordon på bilderna, ni hade istället tjänat en massa god karma genom att värna om människors integritet på detta enkla sätt. I synnerhet när man ser hur korkat fyrkantiga Eniro är när det gäller att ta retuschera bort människor – det krävs i princip att man har skyddad identitet för att de ska gå med på det. 

Lock your Mac

Sometimes it’s nice to be able to lock the Mac screen instantly. 

This terminal command sends you directly to the login screen with a nice visual effect. No worries, you are still logged in, but to regain access to your Mac you have to enter your password again. 

/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession -suspend

Use your favourite keyboard shortcut utility to define this script as a hotkey. I use iKey and have set ctrl-option-command-backspace to lock the screen. 

The command uses Fast User Switching to present the login screen.

This works even if you haven’t enabled Fast User Switching, and it should work at least from Mac OS X 10.4 and up.