Understanding x86 bootloader assembly

I am working my way through this tutorial: Writing a Bootloader Part 1.

And I don’t understand assembly at all, so I here are some notes to make sense of it all.

First here are two references that I hope will be useful:

This is the code of the example:

bits 16 ; tell NASM this is 16 bit code
org 0x7c00 ; tell NASM to start outputting stuff at offset 0x7c00
boot:
    mov si,hello ; point si register to hello label memory location
    mov ah,0x0e ; 0x0e means 'Write Character in TTY mode'
.loop:
    lodsb
    or al,al ; is al == 0 ?
    jz halt  ; if (al == 0) jump to halt label
    int 0x10 ; runs BIOS interrupt 0x10 - Video Services
    jmp .loop
halt:
    cli ; clear interrupt flag
    hlt ; halt execution
hello: db "Hello world!",0

times 510 - ($-$$) db 0 ; pad remaining 510 bytes with zeroes
dw 0xaa55 ; magic bootloader magic - marks this 512 byte sector bootable!

So the first instruction bits 16 makes sense.

But org 0x7c00 already gets me struggling. It means that this is where the “code” starts.

However, if I change the number it only changes a number in the output, it does not “move” the code, as I would have expected.

So I looked up the description for the org directive in the nasm docs

The bin format provides an additional directive to the list given in chapter 7: ORG. The function of the ORG directive is to specify the origin address which NASM will assume the program begins at when it is loaded into memory.

Unlike the ORG directive provided by MASM-compatible assemblers, which allows you to jump around in the object file and overwrite code you have already generated, NASM’s ORG does exactly what the directive says: origin. Its sole function is to specify one offset which is added to all internal address references within the section

To be honest I did not understand any of the explanation, so I just assume it is magic and must be in there for this thing to work.

Next is boot: it is a label as I understand, that is, it is not written to the output, but it can be referenced from other places in the code. boot: is not referenced anywhere, but there is a “local label” called .loop: below it, that is used. And local labels must be placed under a label.

mov si,hello means that the address of the “Hello World” string is put into register si, the 16 bit general purpose source register

mov ah,0x0e loads a value into the 8 high-bit accumulator register.

What this does is explained in the linked wikipedia page: BIOS interrupt call

mov ah, 0x0e    ; function number = 0Eh : Display Character
mov al, '!'     ; AL = code of character to display
int 0x10        ; call INT 10h, BIOS video service

ah is the high accumulator which contains the function and al is the low accumulator which gets the character to print. So this works like

  1. set method to invoke
  2. pass parameter
  3. perform that function call

What lodsb does is easy to google:

The LODSB loads the byte addressed by DS:[SI] into register AL. SI is then incremented (if DF=0) or decremented (if DF=1) by 1.

The last byte in a string is the zero byte, so the next part of the code

or al,al ; is al == 0 ?
jz halt  ; if (al == 0) jump to halt label

is easy to understand, it checks for zero and jumps to halt.

Then the int 0x10 instructions performs the operation

And the last part pads they binary file with zeros and adds the magic number

I have also run the resulting binary through an x86 disassembler:

0:  be 10 7c b4 0e          mov    esi,0xeb47c10
5:  ac                      lods   al,BYTE PTR ds:[esi]
6:  08 c0                   or     al,al
8:  74 04                   je     0xe
a:  cd 10                   int    0x10
c:  eb f7                   jmp    0x5
e:  fa                      cli
f:  f4                      hlt

And it appears that the 0x7c00 from the org instruction is added to the address of the “Hello World” string. So I guess it is the offset that points to the beginning of the 512 byte that this bootloader operates in. Which would only make sens

Using Jenkins Matrix Builds with Agent Docker

There is one simple tutorial that I was looking for on the web, and I could not find it.

So I wrote it myself.

Jenkins has matrix builds, and Jenkins has agent Docker for builds inside a docker image.

Combined, these features make it easy to test a project with multiple versions of PHP for example.

So here is the simple example I came up with: Put this in your Jenkinsfile and you are done.

pipeline {
  agent none
  stages {
    stage('BuildAndTest') {
      matrix {
        agent {
            docker { image "${DOCKER_IMAGE}" }
        }
        axes {
          axis {
            name 'DOCKER_IMAGE'
            values 'php:5.3', 'php:5.6'
          }
        }
        stages {
          stage('Build') {
            steps {
              echo "Do Build for ${DOCKER_IMAGE}"
              sh 'php --version'
            }
          }
        }
      }
    }
  }
}

Let me know if it helps you: I am on twitter: @oracle2020

The Memory Palace Method

I am writing about a memory palace that I once built. There are different ways to build memory palaces.

A saw a method recently that used a single picture from a single scene, and did the walk through without moving.

The memory palace that I built most successfully was for learning for a certification to work as a security guard in Germany. For this you have to learn the legal requirements that are the base of the job. The interesting part here is that as a security guard, you are nothing like a police men or women. You only have the exact same basic rights that any ordinary person has. So your room for legal maneuvering is very tight, and you need to know exactly what you are allowed to do.

To learn for the examination, I constructed a path that took me through the neighborhood that I was living in at that time. I took places that were each about 200 meters apart, and gave each location a name, and added a marker to a custom google map. I am right now actually trying to use the Open Source software Marble for this type of work, but I found that it’s bookmark handling is quite rudimentary. Not what I would expect from a popular Open Source Tool. Maybe I need to jump in, and create my own extension. However, at each I of the spots I marked I visualized an animal as vividly as possible, to give the location even more memorability.

After placing names and markers in a map, I transferred the ordered list of locations (with their names) to a table document, with several columns.And next to location and animal, I added one of the facts that I needed to remember. The thing about remembering contents for certifications is, that often it is quite a lot harder, to remember a list of more than 5 or 6 items, than it is to remember a list of 3 things. But these would be the exact types of question being asked in a multiple choice test.

There would be a question like „when you stop a person who stole some merchandise in a supermarket, which law are you acting upon.“ and „how long are you allowed to keep the person.“ And the answer would give you 4 or so, slightly similar sounding names of laws. And of course you are expected to pick the exact right one.So for multiple choice questionnaires in this type of setting, it is not enough to be able to apply to knowledge intuitively, or to talk yourself out of it if you get asked face to face. You need to be able to remember exactly what was asked, even if it does not make much sense in a practical setting.

So that is why a memory palace is a good tool here, because if you would mentally go through your list of laws, you would be able to easily distinguish, if the law was the one at the bus-stop, or if it was the one on the bridge.

A Protocol for testing Self Driving Car Algorithms

If was tasked with testing Self Driving Car Algorithms in the “Real World”, I would go about it in the following simple way:

I’d equip a test-car with all the sensors required for the algorithm to test, and in addition I would add sensors to record the steering wheel position and the positions of the gas and break pedals. I would not add any servos to control and actually “do” the driving the algorithm would suggest.

Instead I’d put two test drivers into the car, one at the steering wheel, doing the driving like a human driver would do. And in the passenger seat, I’d put an “instructor” that would get a screen, that cannot be viewed from the driver position. On that screen the following data would be displayed: The Steering wheel position the algorithm would suggest, and the difference to the current steering wheel position. And the same difference for the speed the algorithm would suggest, and the difference to the current speed.

The “Instructor” in the passenger seat would then get the task of conveying the desired direction and speed that the algorithm suggests to the driver verbally. In the beginning this might be awkward, inefficient and error prone, but over time, as the driver and the instructor adjust to their roles, they will become more and more in tune, like a duo of musicians improvising together. As a pair they would do the task of conveying the information the computer provides to the physical machine, the car.

Then of course all the data from these test drives would be collected, together with the actual driving data collected from the sensors in the steering wheel, pedals, velocity meter, etc.

This data could then be used to evaluate the efficiency and practicality of the algorithms. The goal would then be to optimize in a way that difference between the suggested direction and velocity is minimal in regards to the measured values.

This approach would provide several benefits. First of all the “human” part of this interaction is a model that has been already proved to work well, as this is usually the constellation in a rally car. There is a “Driver” and a “Navigator”.

Additionally, this approach can be used without any legal requirements to testing on actual roads. The driver is actually driving and focusing on traffic, and is not distracted by a screen or anything.

But above all, this approach provides the fast iterations necessary to improve an algorithm incrementally, or quickly test a new idea. Because as the human safety drivers are fully in control and actively focusing on the driving there is no risk if an algorithm proves to have bugs, as this case will simply show up in the data as a greater deviation.

There is no need to have an emergency stop button, and there is no risk of the car suddenly stopping abruptly, or accelerating rapidly, if the algorithm runs in a completely wrong direction.

Thinking about the problem at hand, this was the first and most obvious solution to quickly get to a stage to experiment, without putting anyone at risk and without slowing down the experimenting.

A Shaving Routine without the Fluff

Many words have been written about a manly shaving routine, here are mine.

There are the usual guides on the internet, that are about some fictitious manly archetype, that ramble on about some specific manly products, about scents, and using a single razor, or some classic shaving apparatus. Or that try to guide you towards unnecessarily expensive products in order to drive the writers affiliate commissions up.

You will find none of the above here.

My routine is a simple no frills shaving routine, that includes some necessary products that are in no way expensive or unattainable. They will serve their purpose, and they will serve you a long time.

First of all, why shave at all? It is 2019 for gods sake, nobody cares if you are shaved or not, we live in times where everything goes. So shaving is not part of my daily routine. I do it only, when I feel the time has come again, and I happen to have some “me-time” available. So shaving is for me to celebrate myself, to have some for taking care for myself, and for my body. So I usually not only shave, but I take a bath or a shover before or after, however I see fit. Taking a bath or a shower is not only a physical cleansing for me, it is also a mental cleansing, I do it to draw a barrier maybe between a stressful day of work or travel, to mark the transition into a more tranquil phase of my day, where I relax and feel good, and have a good time.

So my shaving ritual usually starts with me undressing. I do not undress in the bathroom, but rather somewhere else in my momentary living quarters. Undressed then, I take a look around, maybe bring order in some things, taking an inventory of my surroundings.

Then I go for the bathroom, where I usually keep all my shaving equipment and get to work.

As I said, I do not shave every day, so usually I have a bit of a stubble. When I am in a hurry, I just shave anyways, but when I do feel I have the time to take care slowly, I have an electric long-hair cutter. And here is the first piece of advice: I got the cheapest possible version available, from some random supermarket, probably 10+ years ago. It cost me 20 € and basically served me all my adult life long. It used to be rechargeable, but probably the batteries are so worn down by now, it does not charge anymore, I have to keep it plugged in all the time, while using. Well, big deal, it does not matter, I need light and a mirror anyways to shave, and an electric outlet is near by. By now it is also totally clogged up by hair residue, that sometimes it does not even move. Well, I shake it a bit, and gently knock it on the sink, gets it going every time.

So, after I used this cutter to get the stubble into manageable length, and after trimming my beard, I get out the big guns. Well, not so much. I use shaving cream form a tube. And this is an important detail, nothing sucks more than shaving cream from some compressed canister. First of all, canisters with a compressed air or some gas, are an unnecessary waste, the gas involved used to poison the atmosphere, (not so much anymore these days, but hey, Karma!) and they are bulky and a waste of space.

Usually I get a brand of shaving cream in a tube called “Palmolive Rasiercreme Classic“. The reason why I chose this brand is simple, it is the only brand that is available in a tube. Everything else comes in a container, so its out. Here in Germany, it is basically available at every streetcorner, and usually cheaper than on amazon, so don’t waste your money ordering stuff on the internet. I usually buy two tubes, when I see them, so when one runs out, I already have a spare. Although it never runs out. I only use a tiny itsi-bitsi bump of shaving cream, and I shave so seldom, this stuff basically lasts for ages.

To apply it, I use a basic shaving brush. Don’t bother going for expensive materials and brands, I got mine from a random supermarket a few years ago, and I still use it, even though it is already starting to crack and might fall apart anytime soon, … well it hasn’t happened yet, so I stick with it.

Other than that you need something like a plate or cup to stir the shaving cream with your brush. Don’t go all rocket science here, and scout out specialty shops, get a saucer or cup from the kitchen and use that. I have plastic bowl, that I got with another brand of shaving creme some years ago, and this is serving me well here. At one point in time there was a brand of shaving soap that was sold in a plastic bowl as a solid piece of soup, you just had to stick your brush on. Well, I prefer the tube these days, but the bowl still comes in handy to beat the bush so to say.

Also, applying shaving creme, and stirring the foam. I keep it simple and suggest to not overthink it, I don’t waste time stirring to perfect consistency, I just do a few stroke with the brush until its evenly spread and then I start to apply it.

Next up is the razor, and here again, keep it simple, use an effective tool, nothing fancy, but also don’t go all neanderthal on yourself here, hear me? When I was a bit younger and more pretentious I felt like I had to use an elegant tool from a more civilized age (The single blade classic Saftey Razor patented from Gilette in 1901/1904). But these days I simple go for the Wilkinson Sword Quadro, a simple yet effective design, and not expensive at all. Any other brand would probably serve this purpose as well.

And here is also they only luxury that I indulge into, when it comes to my shaving routine. I used to wear out a razor blade until it was barely cutting at all anymore, but these days, I prefer a sharp edge. So I decided to set up the regular order plan on amazon, to ship me a new XXL Pack of Wilkinson Quadro Blades every six months. This means I never run out of blades, and I can generously appoint myself a fresh blade whenever I feel like I want one. As I said, I don’t shave very often, so a new shipment every six months is plenty of blades for me.

And basically then I am done, I do not use any aftershave or other product after the blade, I simple splash water into my face, and wipe it of with a towel, preferable not a white on.

I do not use an Aftershave or any other “smelling” body product, like deodorant or such, because, the whole idea that the human body has any smell that needs to be painted over, is a myth perpetuated by the advertising industry, to make you feel ashamed and insecure, and waste money on their “cure”. Well not for me, for sure, don’t buy into that bullshit.

How to setup a minimal Laptop as a Focused Writing Tool.

These days I had a chance to catch up with my siblings and found myself in an interesting discussion with my brother, about a simple setup for mobile authoring of documents.

And as I pondered that question during my trip back home, I came up with some ideas about how to build the type of machine we talked about. Namely something small resembling a laptop, but with a dumbed down feature set, to avoid the distractions of the Internet, Email and various other features of a modern laptop.

I thought about building a customized laptop, based around an ARM board, eventually with a custom designed mechanical keyboard, and a custom Linux based OS, with limited applications, eventually even a built in power adapter, to reduce the number of items to carry on a trip.

But as I was working from my train seat, I noticed that in some way, I already have quite a good machine for writing from on the go.

Because ideally, the device that we conceived would be simple that it could be used like a single purpose appliance. Instantly on, without the boot process of a laptop.

But as I am writing this from a MacBook, I remembered how hassle free the standby mode is, compared to all the Windows and Linux laptops, that I would use as well.

And I already do use a kind of “distraction free” writing environment customized to me needs. For me that is a VIM with the “Goyo” plugin, running inside a tmux console, in the terminal app.

Goya, provides a simple centered writing space similar to what other “distraction free” editors would provide. I use the tmux feature to hide the status bar, and I usually run the terminal in full screen. For me that is quite sufficient, as I have tmux usually always running, for opening new terminals, doing programming, connecting to servers etc. And as a Vim enthusiast and heavy user, I am quite comfortable with the cumbersome keyboard shortcuts.

Just getting the instant standby operation as smooth as on the Mac when creating a custom device and motherboard, would probably be an intense experience of yak shaving, I thought about the option to just use a Mac based laptop for the ideal basic writing machine.

It would require the discipline of only using the machine for writing and sending email, but some discipline is required for writing as well. And getting something like a used small MacBookAir, to set it all up, would probably not be even that expensive.

And even for software options for my brother, a few came to my mind. There exists an app called “Typora” for the Mac, which provides a very streamlined and distraction free option for producing “Markdown” documents, without the hassle of actually needing to write markup, as it is a WYSIWYG Markdown Editor. It has a distraction free fullscreen mode, and is as basic and minimal as it gets.

Other than that, the Machine could probably be dumbed down to the essentials, WiFi could be disabled, and with a cleaned up Dock, it could distraction free as well. Considering that Typora would be kept in Fullscreen anyways, and the Machine would wake up to the empty page or last document of the editor.

And even for the requirement of sending the occasional email without getting sidetracked by an obnoxious display of the inbox I think I saw a solution in the experimental “Plain Email” that kind of provides a distraction free Email Composer.

I am not quite sure if “Plain Email” is ready for actual use, but given the constraints I would be curious to try it, and see if we can get such a machine to work as to our intentions.

4 Easy Steps to Learning how to draw

TLDR:

  • Learn to handle your Tool of Choice
  • Seeing and Drawing Relations and Proportions
  • Learn what to Leave out
  • Compose a Scene

Currently I am practicing to draw with a pen on paper, more specifically I am working on the technique of five minute sketches to be able to draw street scenes that I observe quickly into a sketchbook, striving not necessarily for absolute realism, but for something that is recognizable and interesting.

As a tool, I am mostly using a gel pen, which is easy to handle, does not need as much pressure as a regular pen, and can mostly bring one single level of darkness and thickness to the paper.

In some way a gel pen for drawing is a very “digital” tool, it knows exactly two states: Black or not black. Unlike a pencil, it is not possible to draw shades of gray by pressing harder or gentler onto the paper.

In a way, it removes one complexity for me, as I no longer need to decide if I want to have a stroke light or dark, the decision is reduced to “stroke” or “no stroke”.

Because there are already many complexities involved.

Taking the drawing process apart, there are several different skills involved, that fortunately can be practiced individually.

The first step is simple learning to handle your tool. If you have practiced very little drawing, or come from a background where most of your drawing needs are about drawing boxes and connecting them, you will likely find it quite hard to get the pen to draw on paper what you had imagined in your head.

I used to work around that problem, usually by drawing a line, looking at it, and drawing another line, that seemed closer to what I imagined and then repeat that process, until the stroke was approaching what I had in mind. Of course this led to messy results, where I would start with a light stroke, and pressing increasingly harder, as I approached my ideal line.

First, learn to be able to place a single stroke at exactly the place you imagined it at the first place.

And for this you can do little practices. Like filling a part of the paper with something like parallel lines. In the beginning, if you do it quickly, sometimes your lines might cross each other by accident, some lines might start further left or right than the others, the distance between the lines might vary, they might be wobbly rather than straight, and so on and so forth.

That is one area to practice.

Another one that I like to do is to draw simple circles, small ones and bigger ones, and here I try to get them really into circle shapes, and especially try to match the beginning with the end of the circle, without leaving a gap or overdrawing. Ideally you would be unable to distinguish the beginning and end from any other part of the circle. A gel pen can be quite unforgiving in this area. If you press too hard while putting the pen on the paper, or when taking it away, you might leave an ugly speck.

The goal with all those exercises is to practice the handling of the tool, to train the muscle memory to observe your intentions and to be able to start a line where you intend to start it, and end it where you intend to end it, and to be able to keep the stroke going where you want it to go instead of diverting from the path. And with closing to circle to hit a spot and connect two lines where you want them to connect.

It is a basic skill upon which you can base your further study.

And fortunately it is an easy practice, that does not require to much thought or concentration. You can doodle during meetings, on the train, while eating, etc. etc.

It is a bit like being a warrior or sword fighter. You need to become familiar with your tool of choice, you need to keep it on you all the time, handle it all the time, have it lie next to you when you sleep, in case you wake up in bed and need jot down a few ideas. It needs to become a new body part for you.

If you are on a train that is wobbling and shaking see it as an additional handicap or challenge to overcame and keep your straight line.

No matter what tool you chose, if you go for the gel-pen, as I did, or if you prefer the pencil, the next skill you need to master is shading, that is getting different gray levels out your tools.

In the case of gel-pen, that does not allow greater or smaller pressure for controlling the shade, you need to resort to other tricks, like drawing lines in varying distance to make it look like different shades from the distance, or making crosses, etc.

There are many ways to practice different ways of drawing patterns and shading, I usually try to shade close to a line, without over spilling on the other side of the line.

After having honed some basic skill to be able to handle the pen and draw, the next, learn to see relations and proportions and be able to bring them to the paper. When sketching faces it is quite vital to get the proportions right, and when I started out with sketching, it might happen quite often that I started with drawing an ear and then the head, and suddenly I would have a tiny head with a giant ear on my paper.

The most basic proportion to start with, when sketching faces is usually the eye ear line that can be imagined across the head, and quite surprisingly it is about in the middle of the head.

As I sometimes find it quite hard to estimate proportions when looking at the real scene as a beginner, I found it a bit easier to start with photos which are already in the 2d space, and start practicing estimating proportions from there.

You could also take your fingers to measure a proportion with a pinch grip or a small ruler.

There is also the way to draw a grid over a photo, and transfer the image using a grip. Also a great exercise, although I would put this exercise more into the “handling the pen” category, rather than into the “estimating proportions”, because for me it feels quite unnatural to try to mentally overlay a grid over a real scene. While it comes easier to me to see proportions in the relationship between objects and features in the scene.

So one thing is to see proportions and another thing is to be able to put them ob paper. So this I guess needs practice, but I guess one starting point could be to try to draw two or more lines on a paper, one twice as long as the other and one three times as long as the other, etc. Or to place objects in a specific distance of each other.

The next exercise would be to learn what to draw, and what to leave out. Here I found it quite interesting to look at comics, or graphic novels, and try to imitate how faces and characters are often draw with few and simple strokes in a comic.

When sketching from photos or real life, in the beginning it is often quite hard to distinguish what details are defining for the overall appearance of an objects, and what details can be left out or are even distracting.

Comics help to see that, and as a practice, I like to draw over photos from magazines, like the free ones, you get on trains or in the mail.

What to leave out is especially important when drawing with a tool like a gel pen, where you cannot get very small and light strokes, and where a too small detail would look out of place.

Often, it is not even necessary to draw a thin line, it might be enough to draw the beginning and the end of an edge, and the imagination of the observer will fill in the rest.

The next step in the skill ladder is the ability to compose a scene. To decide what to draw from the higher level view. While the part before was about what to draw in terms of details, the next thing is to learn what to draw in terms of the overall scene.

And to be able to see that, I find it quite useful, to get into the habit if taking a good photograph every now and then. Apart from looking at scenic sketches and good photography of course. Taking good photographs of people and scenes comes down to two basic factors, and that is the framing and the composition of foreground and background. And for the framing it comes down to a similar thing as before, the question of what to leave out. Learning to let go, and be bold in keeping objects and details out of the frame.

When I was much younger, I often imagined photography to be about capturing everything of am interesting scene, rather than creating a good picture, independent of what the whole scene was about. So I when taking a photo of friends, I would try to capture all of said friends from head to toe, and keep everything in the frame, rather then selecting or curating the contents of the picture. Later I learned that capturing just a face and a bit of the torso of a person, while the person was engaged in something interesting would produce a much more satisfying picture.

In addition to the focus on something specific, like a face, it would also be important where to place that detail in the frame. According to the golden rule you would place the focus point not in the middle of the frame, but rather divide the frame into thirds and put the focus point into one of the dividers of the thirds.

Selecting a focus point would also mean making a decision of what should be in the foreground.

And that would make the second factor to take into account, selecting a background for your focus point. As a naive photographer, I would always be so interested in the object I was about to picture that I did not pay much attention to the surroundings of said object. So today I usually also take that into account. If I find that background of my object of interest is boring, I usually move around it in a circle, trying to find a more satisfying composition, while keeping the focus the same.

And usually I would also try to emphasize the focus, be trying to keep the sharpness of the picture there. A simple trick to do that with a zoom lens, is to zoom in as much as possible, as this will usually make the field of focus more shallow, so you would find it more easy to give a slight blur to the background.

Learning to frame a picture and select a composition is probably not of so much use to a beginner, who will be happy to get a sketch of a face, but it will make it easier when moving on to creating whole scenes, because extracting to interesting parts of a scene means less work sketching out the details and everything.

And it also shows that sometimes a detail is much more interesting than trying to cram everything into a picture. And dividing background from foreground and putting things in a blur also highlights where in a picture less detail might be necessary.

Living more comfortable by going through discomfort

Lately I made in interesting Observation on myself. And that is, I would take an action that felt uncomfortable to create a situation for me, that is actually more pleasent. Not sure if that makes sense, but I will go through my experiences.

Today I took a trip by train to visit my siblings. It was going to be quite a long journey, so I was about to stop at a supermarket to get some food that I could have for dinner which i would have on the train.

So there was a normal german Supermarket, that would have carried everything that I would usually buy for a small meal on the train. And that would probably be a sandwich and a softdrink.

That was the comfortable option, it was a big brand name supermarket, I shopped there already plenty of times, I would know what I was about to buy, and I would be on Auto-Pilot going through the motions, and buy at a big name brand.

However, around the corner, just a two minute walk away, I knew that there is also a Turkish supermarket, locally run probably, that I would usually hesitate to frequent, as the products sold there would be totally different than anything that I would expect from a supermarket. So, I would not know what to buy, and where to find it. It would be a more uncomfortable choice.

Never the less, I believe it took me a minute or two to ponder that question, I went for the uncomfortable option, and entered the Turkish supermarket.

In the end I bought some healthy salad from the salad selection, and some sweets from a to me unknown brand.

I am not sure if in this case I got something better tasting than I would have gotten at the other supermarket, but for sure what I saw was more interesting, as this supermarket had quite a large selection of salads, and even a real butchers shop inside the market, while the big brand name supermarket these days, only carries prepackaged meat.

What I did however, is that I primed myself to make the more interesting if uncomfortable choice, when faced with two options. And it took me some effort, there was a slight tingling in me to go for the easier option, that I had to overcome.

But the story did not stop there. I did buy the salad, but walking into the train station, I noticed that I did not bring any eating tool to consume said salad. I needed to get a fork or spoon, or anything. So simple walked into one of the bakeries that are at the train station, and took a plastic fork, that was provided there. And usually I would feel quite uncomfortable to get a fork from a place without buying there, but given that I was already primed to do uncomfortable things I took the fork. Would have been even more uncomfortable having to eat the salad without a fork. Basically a small transgression of my existing social code.

On I went to the train, and looking at my ticket, I noticed that I had a reserved seat on the train. I did not remember that, because I booked the ticket some time in advance. So I went to my seat, and in this type of train, there are different types of seat arrangements, it is either two seats next to each other behind another row of seats, similar like sitting in an airplane. Alternatively there are two seats that face another row of two seats and in between there is a small table. These tables are usually more spacious and comfortable, as in the seat rows, you usually only get a flimsy fold down table, like in an airplane. So I noticed I had reserved the wrong seat. But as luck comes, just the next row as a “good” row. So even though the train appeared to fill up quickly, and these “good” seats were marked “reserved”, I took my chances to sit there. Sometimes People do not show up, even though a seat is marked reserved.

To spare you the suspense, in the end, the seat I choose stayed free, and now I am sitting in the comfortable space, rather than in the cramped position I had reserved. And here is where it seems to get uncomfortable for many people. Everybody who has a reserved seat usually is quite happy to get there, especially if the train seems to become full. For me, I had all the options, a reserved seat, should I need one, but the chance for a better one, should it stay free. What I had to endure though was the possibility of two uncomfortable conversations. The first one would have been when the person on whose seat I sat would have shown up. And the second one when I would have to ask the person sitting on my reserved seat to get up. Luckily, that scenario never happened, so in the end I got the better deal, without any real risk at all.

But it does not stop there, quite often you can get a better deal, just by suggesting an alternative to the established procedure.

Recently I had to go on a company business trip, which I usually try to avoid as business trips are often quite a hassle, and feel not very comfortable to me.

However, this time I decided to make some small changes to the usual business trip arrangements, all without any consequences, but with immense increase in comfort for me.

The default magic rule for company travel seems to be the following, that is what you get when you ask the responsible person in the company to arrange for the travel. A trip by plane, a taxi from to airport to a regular business hotel in the vicinity of the customer location. Taxi trips to and from the customer and the hotel if necessary and that is it.

To me that sounds usually like a complete horror-trip. Usually customer companies are in the very far outskirts of the city center, where land is cheap, and entertainment, as well as public transport is sparse.

That means that when the work of the day is done, you get into your taxi to the hotel and that is it. If you want to do any activities after that, you either have to pay for a taxi on your own dime, or take the bus, which in that area usually means a 30 minutes walk from the hotel to next bus station. And the same way back, after a few drinks. Good luck, finding yourself in a sleepy small town, with your phone battery empty trying to navigate to your hotel, when the last bus from town dropped you off at different bus stop.

And usually these types of hotels for business travelers are the most boring places ever, all other customers come in to sleep, or watch TV, exhausted from their day at work. Everything is usually nice, clean and orderly, but the audience is usually not anything close to what you’d call a party crowd.

Having found myself in this rather unpleasant situation several times again and again, I decided to take matters into my own hands and adjust the situation in a slight manner.

I gave precise instructions to the travel agent making the arrangements, and I was curious how it would play out. Again, no risk at all on my side, the worst that could have happened is that the company denied my wishes, citing some “travel policy”.

So I choose a specific Hostel right in the city center, that accordingly to the internet reviews, photos and location looked, like an interesting place to stay. And for the most part the diametral opposite of what I would expect from a standard business hotel. I even asked them to book a single bed in the dorm. But here the company took it on them to actually book me a single room in my preferred hostel. I did not complain.

Of course the hostel was quite a trip away from the customer, so I would not have taken a taxi for the trip. Again, taking taxis is not my preferred way of taking a car, I like to drive myself, so I asked the agent to book a rental car instead. My wish was fulfilled, again, I did not expect it, but it would not hurt to ask, and see, it payed off.

I do not even own a car myself, living in the city with every imaginable type of public transport is in walkable distance. However, I am signed up to every available “car-sharing” company that is available, (basically a rental car that can be booked by the minute with a mobile app, spread around the city) And that is usually what I use instead of a taxi. As I said, I prefer to drive myself, and I do it quite often.

Conveniently enough, the hostel even offered an option to book a parking space in the city center, an option which I requested and got approved. Not getting a parking space near my hostel could have spoiled the deal, but even that I could get covered.

The next inconvenience that I usually endured was air travel. I am not a big fan of air travel, especially if it is short distances. In this case it was something like a one hour flight. That sounds quite easy, but this is only the time, the plane is in the air. Add to that one hour of getting to the airport, one hour of waiting at the airport, while enduring the hassle of security checks, one hour of flight, another hour fiddling around at the destination airport waiting for luggage, searching the taxi strip, and then another hour plus minus for the trip from the airport to whatever the final destination is. All together that is about five hours, the same time, it takes for the train.

Except that it is quick for me to get to the main station, I get in my seat, the train has power outlets and WiFi, and I can get a solid 5 hours of work done, without interruptions. Finally. No waiting, no back and forth, no security checks, no getting on the plane, off the plane, waiting for luggage, etc. etc.

So I asked to get a ticket for a specific train at a specific time, that was the most comfortable to me, and got it approved, and booked. Great success.

In the end the business trip went as well as I expected, I could even visit a friend, on my trip from the customer to my hostel, I had a nice drink with a colleague in the local pub after work, and could easily walk over to my hostel after a few drinks.

And I got all that just by making the very slight uncomfortable choice of not going with the accepted standard of plane+taxi+hotel, and instead suggested my own most preferred options. And all of those choices were not in any way more expensive, than the default. They were just adjusted to my personal preferences.

Non existing risk for me, but great win.

HOWTO run a flask app under apache

In an effort to switch my php based web sites to python, here are the steps required to make a python based web app available under an apache server, using wsgi.

under /var/www/hello:

hello <-- folder with flask app hello/venv <-- virtualenv with all dependencies installed hello.wsgi <-- file with following contents:

#!/usr/bin/python
activate_this = '/var/www/hello/hello/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/hello/")

from hello import app as application
application.secret_key = 'GENERATED_SECRET_CHANGE_AND_DO_NOT_SHOW_TO_ANYONE'

Howto generate a secret (from flask documentation):

python -c 'import os; print(os.urandom(16))'

And then in the apache site configuration the following will make the app active:

WSGIDaemonProcess flaskapp user=www-data group=www-data threads=5 home=/var/www/hello/hello
WSGIScriptAlias /hello /var/www/hello/hello.wsgi


WSGIProcessGroup flaskapp
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Order deny,allow
Allow from all

Alias /hello/static /var/www/hello/hello/static

Order allow,deny
Allow from all

And that should make the site available under the path /hello