Posts

A recipe for failure

 I've recently created an account at a freelance agency to get requests. Very nice. So far, the technologies potential clients have listed are outside my skill set, but something is bound to come my way. Recently, I got the weirdest request: "Build a website similar to this Youtube video in three months with the technology you choose." With the available information, I just deleted the email. This is not something I want to think about as it's a recipe for failure: The scope is ill-defined. The technology is undefined. The team is nonexistent. The pay is undefined. The time restraint is unrealistic. If you should accept a job like this, you would have to: Design and create the website (and the security). Design and create the database. Create a functional analysis. Code, debug and test the code. You expose yourself to all kinds of trouble. As the scope is ill-defined, you risk not getting paid. Also, the people who wrote the job description are not interested in IT. ...

Ubuntu - Auto-mount an encrypted drive

My new computer has a "small" SSD and a large HDD. Solid-State Drives are the popular choice for startup disks as they are blazing fast, while ordinary Hard-Disk Drives are excellent for long time storage. [As an aside, don't ignore your backup strategy. I've written (and published) my own open-source backup utility .] When I installed Ubuntu, I encrypted both drives, which is cool. However, when I started the computer for the first time, the HDD did not mount. Bummer. I managed to semi-auto-mount the HDD with the Disks Utility (encryption options -> Unlock at system startup) and with Nautilus, but I still had to manually navigate to the HDD (in Nautilus) before I could work. Not good. Recently, I solved this problem and I'm sharing the solution with you. It's not as hard as it seems. First, you need some code to mount the HDD. This code will not work. First, you need to create a mount point. Then you need to mount the HDD. Once you have the mount point cr...

Spaghetti code

Once upon a time, many years ago, a colleague came to me and asked me what I knew about a code-base I had never heard of. "Nothing", I replied. He told me it was urgent to get the code up and running again as it had broken down in February or March. It was July, I think. I called upon another colleague who didn't work at the department anymore and he told me that the code was stored at an old desktop PC which had a post-it note attached: "Do not delete". He also told me that the programmers, who had left the company already, were incredible professionals and that he was impressed by the job they had done. Long story short, we recovered the code from the PC and stored it in the cloud. Then, I had the "privilege" to look at the code. It was not pretty. If you know anything about Model-View-Controller, you know that it is a three tier philosophy meant to simplify code development. All security work is done by the Controller, all business logic is ...

Setting up a HTTPS server in Python (WSGI)

The situation Setting up a HTTP server in Python is quite easy. You overload the handlers.CGIHandler class, and Bob's your uncle... You have to overload the  run  function, and that's about it. def run( self , host= 'localhost' , port= 8000 ): # Initialize the server deamon # HTTP self ._httpd = simple_server.make_server(host, port, self . __call__ ) print ( "Serving on port {0}..." .format(port)) # Start the server self ._httpd.serve_forever() Nothing to it, right? So, you'd expect that setting up a HTTPS server would also be a piece of cake... but it isn't that straightforward. Luckily, for you, I have spent some time to make this easy as frig. The idea is to make a SSL socket, and to do that, you have to use the  wrap_socket  command... but where? Look at this line of code from the  run  function self ._httpd = simple_server.make_server(host, port, self . __call__ ) When you open the  simple_serv...

Optimizing date calculations

I wrote a naive little algorithm to calculate the end date of a scheduled event. There are the following restraints: Total number of hours Number of hours per day Workdays per week Skip holidays So, the pseudo-code looks like this : While there are hours     If it's a workday          diminish the hour counter by the amount of hours per day     Go to the next day This works, but it's slow. Let's do this moar better! New pseudo-code : Hours / Hours per day                   ===> Days Days / Workdays per week            ===> Weeks (7 - workdays per week) * Weeks ===> More Days  Add the number of days to the initial date to get the end date.  Calculate the number of holidays in the range ===> Days  While there are days     If it's a workday          diminish the day counter by one...

A simple way to show the 'cookie' warning

The European Union, apparently, has a cookie law . This "requires websites to get consent from visitors to store or retrieve" cookies. There are some tools out there that allow you to add this message, but it's really simple to do this yourself with a little bit of Javascript. The first thing to do is to add a <div> to your template's <body> < div id= "cookie_warning" > We use third party "cookies" for ... < input type= "button" value= "Accept" onclick= " javascript:cookies(true); " /> < input type= "button" value= "Deny" onclick= " javascript:cookies(false); " /> </ div >  Next, we add a new rule to our .css file #cookie_warning {display: none } We don't want to show this warning when people have Javascript deactivated. Let's stop our cookies from travelling. Encapsulate the cookie code in a function: functi...

How I 'hacked' the Google App Engine

A couple of days ago, I published my microdata generator tool * which still has to be integrated with schema.org . The people at schema.org were very positive, and asked me if it would run on Google App Engine . I thought that would not be too problematic. Little did I know. So, I jumped into the documentation and found the first surprise; Python2.7 instead of Python3.4. I had to downgrade my code. Not too traumatic. Change some libraries, change some lines of code. I had to redo the pickle file because that's incompatible. I downloaded the SDK and set up everything. First error: no 'app'. Let's see... app = webapp2 . WSGIApplication ([ ( '/' , MainPage ), ], debug = True ) Okay. I changed the MainPage into Controller.run_this , my tool's handler. Next error: run_this accepts three parameters, two given. Hmmm, I have to do something with the webapp2.RequestHandler . Not looking good. Didn't I read somewhere that Google App Engine was...

Bechamel / Velouté without clumps - my method

After years of preparing velouté for Dutch croquettes, I think I can explain how to prepare this sauce without getting lumps. The secret is quite simple: don't mix in the liquid with the heat on. Having said that, here's the method. Heat the liquid. Milk for bechamel. Fond for velouté. Prepare a roux. Melt butter and add flour. Normally, the proportion is 1:1, but I use 1:1,5. The flour is the thickening agent. So, more flour - more thick. For a small batch, use 100g butter, 150g flour.Cook the roux thoroughly on a medium high flame. The roux will change colour and you'll see it becoming clearer. It will also start smelling nutty. Kill the heat and add the hot liquid slowly (in increments) while stirring with a ladle or whisk. Some prefer the whisk, I prefer the ladle. After adding all the liquid, turn the heat back on. Keep stirring and finish the sauce. Clumps will only form if you have the heat on and you don't stir.

Linear Mortgage Calculation

Image
One of my clients asked me to do a Linear Mortgage Calculation. Not a big deal were it not that I could not find the mathematical formula for it. There are a number of online calculators, so 'they' know what's going on but 'they' don't want you to know*! So, what's the deal? With a linear mortgage, also called a straight line mortgage, you pay back the same amount of  capital each period and therefore the same 'relative' amount of interest. This Dutch graph explains it. 'Aflossing' is repayment. 'Rente' is interest. Source: De Hypotheker (Dutch) So, how do you calculate this? It's relatively easy. Loan (L) is 100.000€ Years (y) is 30 Interest (i) is 2% Periods (p) is y*12 (months per year) is 360 Repayment (r) = L/p = 100.000/360 = 277,78€/month The total amount of interest (t) = L*i*y =  100.000*0,02*30 = 60.000€ The first month, the interest you pay is t/p = 60.000/360 = 166.67€ Now we can solve the followi...

Configuring Apache2 for multisite (localhost)

Apache2 is one of the most popular webservers out there. If you develop websites, you want to have WAMP (Windows, Apache, MySQL & PHP), MAMP (Mac ...), LAMP (Linux ...) on your development machine. I have LAMP installed on a Virtual Machine I'm using for development. First things first; unless you're an expert, don't configure Apache2 to serve as a webserver. There are hosting services out there that have professionals doing these configurations, and they get attacked by hackers A friend asked me how to configure Apache2 for multisite development. I told him it was easy and then spend the whole morning figuring out how easy it is. It's not hard, just follow the following steps... in no particular order. I'm supposing you already have one site up and running. 1. Activate the Virtual Host module     You can skip this if you already have more than one site $ sudo a2enmod vhost_alias 2. Create a new configuration file from the default $ sudo cp /etc...

Charity

Christopher Hitchens said it best when he said that talking about the goodness of the church was distracting from the main question whether gods exist, or not. “it's a time wasting tactic” Yet, whenever the subject of taxing the church comes up, people use it as a counter-argument. Let's look at the “good” the church actually does. Parochial support for affiliated charities. Direct financial support to affiliated charities. Giving people hope * . * IMO the hope (of heaven) the church provides is annulled by the fear (of hell) the church instills first. As atheist say; The church provides an imaginary cure for an imaginary disease. I can't estimate the amount of money parochial support translate into. Suffice to say that the churches own buildings and these would be unoccupied or under-occupied without these Christian charities. Opening these buildings, apart from maintenance costs and electricity, is free and it's publicity. More on ...

What the fuck is Intelligent Design?

Update: Intelligent design is a creationist' scam as shown during the Dover trial. You can check-out the legal text here and the expert witness here Calling it as it is. Creationist leaders are scam artists (liars). They deliberately concocted the ID movement to get creationism taught in schools. If you are a Christian, according to your faith, lying is a "sin". Think about the lack of ethics of these people. End update - January 3rd, 2017 The original article below: I contend that nobody knows. According to IDelists I've come across with, other IDelists are wrong. It may be that I'm constructing a Strawman logical fallacy, but I think ID is deliberately constructing a logical fallacy of confusion. Here's what I understand. ID is against the scientific theory of evolution, because evolution doesn't explain abiogenesis. ID explains abiogenesis with an unnamed designer, either supernatural or … alien. ID does not accept evol...

Guts

I've had a long convo with -a person who wants to remain anonymous-, a former Young Earth Creationist (YEC) about evolution (and religion, and abiogenesis, and morality...). This convo is ongoing with the exact same result; -S- returning to her default position of denial (of evolution) and affirmation (of creation). The latest development is that -S- is now a believer of Intelligent Design (ID); her beliefs have evolved (changed over time). She's not a Christian any more. I'm not sure if she's gone from YEC to Old Earth Creationism. It seems nearly impossible to convince -S- that evolution is possible, probable and, in fact, a scientific fact. Still, one can only try :-) and try, and try, and try again. The thing is that -S- needs to look at evolution from a different angle because she has been bombarded with creationist' propaganda that she chooses to believe over the biologists' evidence. How can you convince someone who believes the ea...

Faith, no more

One of the recurring arguments theists use is 'We have faith'. This is a strange, seemingly unassailable position. The word 'faith' means 'to believe without evidence'. The point is that 'the absence of evidence is not evidence of absence'. This may sound convincing, to some, at first glance (and second, and third), but if examined closely, the argument fails utterly. First of all, if there is no evidence, why should one religion be chosen over any other religion? In other words, maybe a deity exists, but how can anybody claim its name is Yahweh, Jehovah , Allah or Vishnu (let alone, Zeus, Thor or Ra...). To have faith in the deity of someone’s parents, or of their own choosing, seems to be quite arbitrary. Secondly, and this is the main issue, there is evidence to the contrary. The 'holy' books (Torah, Bible, Koran or Bhagavad Gita) all contain creation stories that are in conflict with current scientific knowledg...

Fallacies 'R Us

Image
After debating with religious people on Twitter for a number of months (mostly Christians, some Muslims and a few... stray bullets), I thought to myself that all arguments for gods are based on flawed logic. A short convo confirmed that, indeed, my fellow atheists on Twitter believe the same. This is a short list with the most common logical fallacies I've encountered. This post will be updated to incorporate new fallacies when they present themselves. The Fallacy Fallacy Warning: Using flawed logic doesn't mean that your conclusion is necessarily wrong, it just means that you cannot base your conclusion on that logic. Let's think about an example to clarify this. Suppose you are going to visit your family, and they ask you at what time you'll arrive. You take into account the inevitable traffic jam and estimate an hour. Then, you step into your car and lo and behold, there is no traffic jam... but you get a flat tire. You arrive at the estimat...