E-Mail Privacy Should Concern YOU! Read why.

But I’ve got nothing to hide!

If you send something like the location of your extra house key to a family member or telling your colleague or friend what bank account to transfer money to using an unencrypted email, it is the equivalent of writing it on a postcard (no envelope), letting it take its routes through hundreds of prying eyes and unfaithful servants. The information is out in the open and it can be read and even changed before it reaches you without you even knowing.

Even if you have nothing to hide, using email encryption helps protect the privacy of people you communicate with, and makes life difficult for bulk surveillance systems in use today. Remember the Snowden case?

It is a known fact that government authorities and other more scrupulous groups like the NSA, is watching all internet activities closely. The reason for this has been covered as an attempt to “fight terror” and is in a double-crossing way partially true. The thing is that it doesn’t just focus on “suspected” persons activities online, but yours and mine as well.

They use advanced computational linguistic algorithms to snap up words, combinations of words and other “susceptible” ways of expressing something, trying to find hidden contexts using the intrinsic meanings of words and phrases in different combinations crossed with under-developed theoretical linguistic syntax algorithms, leading to a “profile” that who knows what they get out of.
One thing is sure: They get the contents.

I don’t mind if the NSA reads my mail…

With something as easy to interpret as e-mail, you no longer have to be a security specialist or advanced cracker to read and change other peoples e-mail. Anyone can download pre-made “hacker” tool-kit from the internet and watch everything you do on the internet, unless you correctly configure WiFi routers and use secured pairing between your wireless keyboard and PC or other wireless devices.
Tools are readily available for a so called “script-kiddie” to park his car nearby and intercept EVERY LETTER you write on your keyboard. The signals from your wireless keyboard is easily eavesdropped.

Do you trust your ISP to read your personal information?

Even if we take away the factors mentioned up until now, anyone that works for your ISP (Internet Service Provider) with access to the servers can scroll through a long listing of un-encrypted text in email communication whenever they please. So the reasons NOT to encrypt your email communication is starting to disappear.

But I don’t know anything about this!?

Luckily for everybody, the Open Source community has been developing and using such tools for years.

Not only have they developed technologies for doing this, but they’ve also taken time to create graphical user interfaces for setting up the tools you need, no matter what operating system you are using.

These products won’t cost you anything other than a little time and dedication to make a change to your rights for privacy. Descriptions and documentation is also available and easy to understand, often delivered in a multitude of languages as well.

Here is something to get you going in no time:

Mac OS X Users: https://gpgtools.org/gpgsuite.html

Windows Users: http://www.gpg4win.org/index.html

Linux / BSD Users: You know what to do… 😉

If you choose to use products mentioned in this post or in any of its links, please consider donating a little money to the Free  Software Foundation, or even better, become a donating member!

Best of luck with claiming your right to privacy!



I’m going away for 4-6 months, but please stay subscribed because…

New stuff is coming up!

Keywords: Game Development, Python, C, C++ and (hold your breath) Lisp!

New ways of thinking about the good old OOP, including functional development in Haskell and Test Driven Development and re-factoring legacy code in C++.

More 3D stuff, like Allegorithmic Substances and Modo 701.

The Blender Game Engine (programmed via Python) gets a thorough examination.

A taste of my upcoming book, called “Becoming a Real Life Developer” vol. 1 “The Stuff you Need-to-Know”.
This is a planned three-volume book series covering multiple programming languages, paradigms and languages plus how life unfolds in the real world of software development with version control systems, code reviews, the art of problem-solving and thinking “outside the box”.
It will also be geared towards team building and how to fit in to an established team of developers.
The art of becoming a software developer is very much a psychological challenge with a constant need to stay on top of the latest technologies.
My goal is to make one realize that this business is not always a bed of roses, but an extremely satisfying way of making a living if you know the right way to walk forward and get promoted without pushing yourself off the edge…

Until next time:

The Mad Man (going on a spiritual ride)

Using LINQ and EntityFramework, Measuring and analyzing the LINQ effectiveness

Some Entity Framework Components

When you use something like the extensive “Entity Framework” or any other ORM (Object Relational Mapping) tool, the process of writing sophisticated database driven applications becomes a lot easier.
It eliminates most of the data access code used to be required to create object-based data applications, and contains tools that makes it possible to create object-oriented data applications from an existing database, by using .edmx files that describes the CLR (Common Language Run-time) objects and these can be “extracted” from any existing relational database that the Entity Framework has a driver for.

This enables developers to program directly against data types defined at the conceptual level, presented as regular object instances.

The responsibility to create clean queries and dispose the resources that’s being used, are just as important as it was in more “old fashioned” database connected applications that does all the SQL manually.

Many people assume that, as long as the application compiles and runs without complaining loudly, everything is probably done correctly, right?
This is .Net we’re talking about, so if something was wrong I would probably get a warning or something, right?

Sadly life is not that simple in this case.

The risk of introducing data-access “anti-patterns” in your code that may decrease the performance of your application and greatly slow down your organization’s database server is highly possible, and  actually quite likely to happen if you’re new to ORM and the Entity Framework in particular.

How Can You Measure the LINQ query’s Efficiency?

To reduce the chances of creating inefficient ORM based applications, we need some way to easily (or it won’t be used) analyze exactly what goes on in the EF brain when it executes our code.

This post focuses on a product called LINQ Insight by DevArt, that addresses this problem (and a lot of other LINQ related problems) and may be downloaded for free from the DevArt site:

Download LINQ Insight Standard

NB! The FULL functionality is free for 30 days, before it changes to the more restricted, but highly useful Free Edition.

Data access anti-patterns decreases performance greatly and must be avoided.

When you write applications using for example LINQ to Entities with the Entity Framework, what goes on behind the scenes is something like:

1) The Entity Framework “Mapped” Objects are created with a ObjectQuery() method, run against an existing ObjectContext instance.

The ObjectContext instance is a container for in-memory objects and metadata extracted from the relational database.
It manages the object identities and states, keeps a pointer to original and current values of the objects properties, and tracks changes made to each object in its cache store.

The ObjectContext provides the connection and metadata information that is required to compose and execute queries, and should therefore be set up in advance.

2) Entity Framework components like the ObjectQuery class are compiled behind the scenes, and generate “regular” SQL statements that does the “actual” query against the database.

The queried data is returned as entity objects, most often as anonymous class instances, and the application works with these objects instead of directly querying the SQL database.
This is an important point to understand.
Using LINQ in this way, to offload the database server is a fundamental aspect of ORM frameworks.

Constructing an ObjectQuery Instance

The ObjectQuery returns a collection of zero or more typed entities.  The ObjectQuery generic class implements the IQueryable generic interface, whose methods enable LINQ queries to be incrementally built. You can also let the compiler infer the type of entities by using the C# var keyword, which is something that simplifies specific query situations considerably.

Instances of the ObjectQuery generic class, which implements the generic IQueryable interface, serve as the data source for LINQ to Entities queries. In a query, you specify exactly the information that you want to retrieve from the data source. A query can also specify how that information should be sorted, grouped, and shaped before it is returned. In LINQ, a query is stored in a variable. This query variable takes no action and returns no data; it only stores the query information. After you create a query you must execute that query to retrieve any data.

// Call ctor with query for "persons" and the named ObjectContext
var personsQuery = new ObjectQuery("Persons", context);

3) You can get access to the entities via the reference and collection properties, and this in turn produces additional SQL queries to get the necessary data.

4) When your application finishes working out what entities are needed, the “mapping” process of EF is more or less done.

BUT: if there are any changes to the queried entities, the application will have to save them to database somehow.
It does this by transforming your LINQ, like SubmitChanges() to “regular” SQL statements, like SELECT, UPDATE etc.

All of this happens without you being able to “see” exactly what’s going on at a “lower” level. That’s kinda the idea, to abstract away the unnecessary details from the user, and let you think about designing the flow of the application, not the technicalities used to make things work.

Though all these actions are performed by Entity Framework run-time, and are transparent for the application that works with entities, they may be complex and affect application performance greatly. That’s why you probably need a good Entity Framework profiler to create efficient applications using Entity Framework for data access. Entity Framework profiler in LINQ Insight really profiles ORM events and allows you to see how much time LINQ statement or SubmitChanges call takes to execute as a whole even if it generated multiple SQL statements.

Example Application

Let’s show how to profile Entity Framework applications on a simple example. We have used the widely used NorthwindEF sample database for our example, and generated the model for it with EDM wizard using default settings. The application is a simple console application with the following code:

Some GNU Emacs hotkeys for ya!

I’ve collected some of the Emacs shortcuts / keyboard hotkeys I find myself using from time to time! 😉

Please visit:
GNU Emacs for Unix/Linux and precompiled Windows binaries
Aquamacs for OS X (I prefer this over http://emacsformacosx.com/ as it is better integrated)

To get a hold of this incredible “editor”. The reasons I write “editor” is because calling Emacs an editor is something of an understatement! It’s more like a little operating system or at least an intelligent Lisp world!

For you guys never bothered to learn Emacs: You don’t know what you’re missing out on!

Ok, here are the hotkeys (feel free to add some as a comment, and I’ll add them to the list!):

General commands:

c-x c-f = new buffer (file)
c-x c-c = quit
c-g = cancel input command
c-v next page
m-v previous page
c-l toggle cursor point up/down/center (pgUp/pgDown)

Navigation in text:

c-p = previous line
c-n = next line
c-b = backward
c-f = forward
m-f = move forward Word-by-word
c-a = beginning of the line
c-e = end of the line
m-a = beginning of the sentence
m-e = end of the sentence

m-< = beginning of the text
m-> = end of the text

Editing Text

Killing text:
(text goes to a safety buffer like in Cut)

m-backspace = kill word before cursor
m-d = kill word after cursor
m-k = kill words until end of sentence (.)
c-k = kill words until end of line
c-space = mark start of delete (move to end of text to delete)
c-w = delete text from mark until here
c-y = yank (paste) text from last kill buffer
m-y = cycle through the kill buffer entries

c-x u = undo
c-_ = undo too!

Search for text:
c-s = search forward in buffer from cursor
c-r = search backwards in buffer from cursor

for a non-interactive search press enter before search word.

Search and replace:
m-x replace-string + enter
<word to replace>
<word to replace with>

Managing buffers and windows

c-x c-b = display buffer list
c-x o = switch to buffer list, select with arrows and enter
c-x b = start typing the name of the buffer to choose (tab-complete)

c-x 1 = one buffer in window
c-x 2 = two buffers in window horizontal
c-x 3 = two buffers in window vertical

c-x 0 = close active buffer (file)

m-x recover-file = recover file after crash (open original file, not auto-backup)

c-u 90 c-x f = set margin width to 90 chars

c-u 0 c-l = move current line to top of buffer window
c-x o = move cursor to “other” buffer window
c-m-v = scroll through other window (keeping cursor in main window)

m-x make-frame = create an independent Emacs frame

esc esc esc = get out of recursive editing level mode

c-h f <function> = help on <function>
c-h k <command> = help on <command>
c-h a <keyword> = search for <keyword> in help
c-h i m Emacs = read Emacs manual using info

That is something to get you started!

Until next time, happy editing!


making the move, “from commercial 3d software to blender” part 3

Today I’ll go over my impressions of the User Interface (UI) of Blender.

The User Interface is what gives you the first impression of any software, and Blender has an interface that looks pretty sleek and modern. It uses a Cross platform OpenGL GUI library that looks the same on all supported platforms, which is a good thing!

The interface has three “rules”, saying that it should be:

  • Non Overlapping: The UI permits you to view all relevant options and tools at a glance without pushing or dragging windows around.
  • Non Blocking: Tools and interface options do not block the user from any other parts of Blender. Blender doesn’t pop up requesters that require the user to fill in data before things execute.
  • Non Modal: User input should remain as consistent and predictable as possible without changing commonly used methods (mouse, keyboard) on the fly.

So what does this mean in practice?

Well, Blender is and looks a bit different than anything else out there and therefore takes some getting used to, as with anything else in Blender.
But personally I’ve come to like it very much, because it allows for unhindered configurability. If you like to work in a full 3d view, without any distractions (this is the way I prefer to model), you can just hit Ctrl + UpArrow to toggle a full window/regular view (you need to have your mouse cursor over the window/pane to maximize).
This is a very nice feature when working with the Node Editor, to give you space to see your whole node system, or any other panel you like to isolate.

Like in Modo, the windows can be split into as many smaller windows as you like, each containing different content, or duplicating an existing one if that is what you want. I love this ability to create new window presets, and they can also be saved and restored in later sessions.

Some pictures are in place to demonstrate this:

Blender Interface 1

You can click and drag any divider to split the windows horizontally or vertically
Blender Interface 2

This way you can construct your own working presets, like this one I’ve made for texturing:

Blender Interface 3

So, as you can see, the interface is very customizable.

I don’t know what else to say about the window arrangement, but it is very easy to get exactly what you want for any given job.

No 3D application would be complete without a Quad View, and Blender supports this as well. Just hit Ctrl+Alt+Q (for quad, i guess).

Blender Interface 4

You can switch the 3D view to show wireframe, textured, shaded, as bounding boxes and with Cycles renderer enabled, you can also view the object As Rendered! Very nice indeed.

After working in Blender for a couple of days, the viewport/window shortcuts I find myself using most for navigation (in random order) is:

Ctrl + Alt + 0 (zero) = Align Active Camera to view
This way it is easy to set up a general view for render in the 3D viewport.

Shift + C = Center Cursor and view all
To get an overview of my scene

. = Zoom to selected
Would not survive without this

Ctrl + UpArrow = Maximize window under cursor
Very nice feature to get into the details

Numpad / = Isolate selected in view (local/global view)
Very practical for getting an undisturbed focus to a single object in the viewport

z = toggle solid/wireframe view

Home = Zoom to All
Get a view over your whole scene

1 – 10 = Select layer (shift to add more than one)

1-9 (num pad) = jump to different views (top,right,back etc) 5 to toggle persp/ortho

And off course the regular Rotate, Zoom and Pan is self explanatory.

Last time I covered the Selection tools briefly, and next up, I’ll cover some of the basic tools that I find myself using all the time and how I think they work compared to how other software implements similar solutions.

This has been a brief overview of the Viewport and navigational features of Blender.

I really like the way it is implemented, and I don’t miss anything from Maya or Modo when it comes to windows and navigation, though it does take some time to adjust to it! Within a few days it starts to feel more and more natural anyway…

Until Next Time:

Happy Blending 😉

Final Gather with Mental Ray (Maya)

My last post described the GI indirect lighting method that uses photons to create the secondary lighting.
Another way to achieve indirect lighting is with Final Gather, that in contrast to GI looks at the information in the regular direct light and based on that it sends out Final Gather Points. These points land where the regular light rays land and from there it sends out their own rays that collects information about their surroundings and adjusts accordingly to how the point is to be lit. In the end, all the points average their values to get an even distribution of light in the scene.
When you use FG in your renders, you can actually use geometry as lights in your scene with a bright surface shader, so that the FG points sends this out when hitting the geometry.
Final Gather gives very nice looking lights which are soft and delicate, but it isn’t really a “true” indirect light. It is kind of fake compared to real indirect light, and therefore it isn’t the most authentic looking light out there. But it is easy to set up and works very well in many situations. Besides it is faster to render than Global Illumination.

With Final Gather the default settings in Maya usually works ok as a starting point. If your render gets noisy you can increase the accuracy in the render settings. If you set this too high, your render times can drastically increase.
Point Density controls how many points getting sent out.
The default usually works well.

One common problem with FG is that you can get noisy areas in the tight shadows in your scene.
You can remedy this by increasing the accuracy and adjusting the Point Interpolation upwards. This makes the points blend better, but at the expense of loss in detail. You can get the details back with the use of Ambient Occlusion, that I’ll explain later.

The Scale sliders (primary diffuse and secondary diffuse) is used to tone down the intensity of the FG light effect. A darker shade gives less brightness. The secondary diffuse implies using the Secondary Diffuse Bounces.
The Secondary bounces works so that the points that land on a surface, spawns another ray that bounces from the original target and creating a new sample point on the next surface.
This increases calculation but gives more even distribution and more authentic lighting.

Keep on lighting!

Global Illumination in Mental Ray Part 1 (Maya 2012)

Direct light is the light we see in our scene without Global Illumination turned on. GI will trace the light and make it bounce between surfaces to give a more real-life light behavior.
The thing that makes GI work is the use of light photons that is emitted from the light source and travel through the scene, illuminating the surfaces by Gathering information about color and luminance on the surfaces they come in contact with. This information is picked up and then the photons bounce to the next surface repeating the work.

Choosing the light type to use is important, as it will affect the way photons work within it. Generally you can think that the photon emission will follow the light emission for each light type.

There are two types of photons in Mental Ray, the first being Global Illumination and the second is Caustics.

The photon intensity setting of the light refers to the light-energy used for the photons when they leave the light source. The default value in Maya is set to 8000, which is pretty intense and often leads to blown out renders when used with small scenes.
The Exponent setting determines how fast the photons will lose their energy as they travel through space.
High values give shorter life so they lose energy faster.

Keep in mind that all these settings are calculated on values that exists in the sizes of objects and the size of your scene in the Units setting in Maya.
So if you build a scene that is many units in size this would need totally different settings in Mental Ray than if your scene is only a few units in size.

When using GI in your lights it is easy to forget that you also need to consider the direct light property, so that the direct light intensity is adjusted up or down depending on
the light you are trying to mimic. These are independent settings and can drastically alter your overall lighting!

There are many settings to control in the Indirect Lighting tab of Mental Ray. I will continue to post tips and tricks on lighting and rendering with Mental Ray in the time to come.

Setting up Mental Ray Satellite with Windows slave and Mac OS X host

I don’t know why, but every time I have to set up Mental Ray between different platforms I always stumble some before everything works perfect. Today I configured my quad core Windows computer to do the chewing when rendering from my MacBook Pro laptop.

This is a super-simple setup, but somehow it wasn’t all click and go today either. First of all, I had the slave machine configured earlier, so when I tried to telnet into the port I googled about it would not connect from my Mac host.
So, I checked with the \Windows\System32\Drivers\etc\services file on the Windows machine and got the correct port number 7412 for satellite connections, then I created the maya.rayhosts file in the preferences folder on my mac containing one simple machine.

(File: /Users/chris/Library/Preferences/Autodesk/maya/2012-x64/prefs/maya.rayhosts):

After disabling the local network firewall on Windows, it sort of worked, but I got this annoying error message from Mental Ray after the render:

MSG  0.0  info : adding new host 1 (
MSG  0.0  error  011330: mi-ray/tcp: not a service (check /etc/services)
MSG  0.0  warn   012219: using fallback inet service 7003

Then I tried to add the correct port for satellite (a different port than the one used with MR Stand alone btw) to the /etc/services.
This did not help either.

But, when I also added the “fallback service”, inet 7003/tcp to /etc/services it managed to actually shut up!

# /etc/services
# Mental ray satellite
inet		7003/tcp

So, if anybody out there experience the same “error” message, you know what to do…
BTW, the error doesn’t stop the render from running, but I believe maybe a nanosecond or two will be wasted if the ports don’t match up and the system has to mage a different route… Who knows?

How to stop Maya from asking for network connection (OS X)

For some reason, Maya isn’t allowed to receive network connections without manually letting it by choosing “Allow” or “Deny” in the firewall pop up message. Even if it is listed as “Allow” in the firewall preferences, it asks again every time.

I’m not sure whats causing this behavior, but it sure is annoying. Finally I found a solution for it!

It has to do with “code signing” and something the developer has forgotten to do after changing the application, I don’t know.

I’m not as paranoid to think that someone has altered the code without my knowledge, so I trust the code from Autodesk and sign it myself to stop receiving this message. I’ll route you to the blog where I found the solution here:

Silvanote blog post

I’ve heard people have similar problems with other applications as well, like iTunes.

I take no responsibilities for this solution, it’s totally up to you!

Easy way to get Apache and MOD_WSGI working on OS X

I’ve fooled around with some Python Web-frameworks lately, and maybe someone would care to know that you don’t have to install MAMP or XXAMP or whatever they are called, because as you probably already know, OS X does have Apache 2 Server already installed, just waiting to be configured to your needs.
Off course, it is very easy and convenient in many cases to just push a button and have it all working, but I always like to have total control over the environment when I do stuff like this, so…
I don’t know if these packages support mod_wsgi anyway, so I’ll explain how to get things going the hard way! Similarly you could enable PHP, but that is a nother story.

This is about getting Python web hosting locally, so you can set up frameworks like Django, py2web and the likes.

I’m using OS X 10.7 (Lion), but I think this will work just as fine with older versions, but then you’ll get the module linked to an older release of Python by default.

Here is some information on mod_wsgi:

The aim of mod_wsgi is to implement a simple to use Apache module which can host any Python application which supports the Python WSGI interface. The module would be suitable for use in hosting high performance production web sites, as well as your average self managed personal sites running on web hosting services.
The mod_wsgi module is written in C code directly against the internal Apache and Python application programming interfaces. As such, for hosting WSGI applications in conjunction with Apache it has a lower memory overhead and performs better than existing WSGI adapters for mod_python or alternative FASTCGI/SCGI/CGI or proxy based solutions.

As mod_wsgi supports the WSGI interface specification, any Python web framework or application which is compatible with the WSGI interface specification should be able to be hosted on top of mod_wsgi.

Major Python web frameworks and toolkits which are known to work include CherryPy, Django, Pylons, TurboGears, Pyramid, web.py, Werkzeug, Web2Py and Zope. Major Python web applications which are known to work include MoinMoin, PyBlosxom and Trac.

How to set it up using the internal Apache web server on OS X:

Download the latest version of mod_wsgi from:

Unpack the sources, and do the usual:

sudo make install

(if you have an older version of OS X, and would like to link to a newer Python version you have installed, use the

–with-python=/path/to/your_python with ./configure command)

Then, you have to edit the Apache configuration to load the newly installed module:

sudo vi /private/etc/apache2/httpd.conf

After the list of default modules to load type in:

#Load mod_wsgi module:
LoadModule wsgi_module libexec/apache2/mod_wsgi.so
WSGIScriptAlias / /Library/WebServer/Documents/

Now you should be ready to serve Python content on the local Apache server that comes with OS X.

To try out your new configuration, create the following .py file, and save it to your document root folder /Library/WebServer/Documents/testpy.py:

def application(environ, start_response):
status = ‘200 OK’
output = ‘Hello World!’

response_headers = [(‘Content-type’, ‘text/plain’),
(‘Content-Length’, str(len(output)))]
start_response(status, response_headers)

return [output]

Start the web server via System Preferences -> Sharing -> Web Sharing
or via the
sudo /usr/sbin/apachectl start
Terminal command

Visit http://localhost/testpy.py
You should be greeted with the notorious “Hello World!” message, indicating that you now serve Python locally via Apache and mod_wsgi!