Short solution for short problems

AngularJS: Set ng-style text decoration

I was trying to set the text decoration from the controller to underlined or none, depending on some scope variable.

<row ng-style="{text-decoration: player1.turn}"><h2>{{player1.text}}</h2></row>

But first I got some errors: Error: [$parse:syntax] Syntax Error: Token '-' is unexpected, expecting [:] at column 6 of the expression [{text-decoration:

 Now I found why:

<row ng-style="{'text-decoration': player1.turn}"><h2>{{player1.text}}</h2></row>

I needed to put text-decoration between quotes. player.turn can hold none, underlined or any other decoration.

Classic ASP: Performance problems (Response.Buffer = false)

In my previous post, I proposed a way of trying to figger out where performance problems are.

Now I discovered a possible problem in our existing classic ASP website. On several places, the server tag:

<%Response.Buffer = false%>

Now what exactly happens when this is set on top of the page?

When the Response.Buffer is set to false, every Response.Write is sent immediately to the client. If response buffering is enabled, then these writes are grouped and sent to the client in one larger, more efficient transaction. From IIS 5 this is by default enabled on the server (they did that for a reason). 

In our case there are loops and sometimes these loops go over 100 rows. In the loop there are more then 50 Response.Write tags. So image when the Response.Buffer is set to false. It will result in 100 * 50 connections from server to client. that's 5000 connections. Now when the load on the server gets higher and 100 users are opening the same page on the same time, it's 500000 connections. This will blow up the server and breaks performance. 

5000 Response.WriteResponse.Buffer = falseResponse.Buffer = true
1 user5.000 connections1 connection
100 users500.000 connections100 connections

If your page is very large, and the processing very long you may want to periodically flush the response buffer to the client. This will ensure that the client steadily receives data and does not time out. If you are building large tables in a loop you may want to add Response.Flush every 100 rows or more.

It can also happen that the Buffer Limit is reached and the response is cancelled. By default the Response Limit is set to 4Mb. You could increase the to max 20Mb. But even better, you could improve the page itself by using Response.Flush every n rows or simply check if the page could be rewritten. You do not want to sent page over 10Mb to clients. 

Responsiveness can be achieved by other ways, like showing a loading message, Response.Flush it and hide it in the end of the response. Or flush loops over n number of rows.

When to use Response.Buffer = false? In my opinion a page with images, or some special cases like counters (if this cannot be achieved with javascript and the rest of the page is not writing more output). But be aware of the number of connections that are made from server to client.

Classic ASP: Analyse large classic asp applications

I have several techniques to analyse an old asp application. 

Off course reading the code, but some large pages can be totally unreadable. 

In my case all calls to the DB where performed through the same functions. So there I put a file logger. Now all SQL calls to the DB are logged in a file. Later I could analyse them and have some more idea what's going on.

Function LogToFile(stringToLog)
    dim fs,f stringToLog = FormatDateTime(Now()) & ": " & stringToLog set fs=Server.CreateObject("Scripting.FileSystemObject") set f=fs.OpenTextFile("c:\temp\classicASPLog.txt",8,true) f.WriteLine(stringToLog) f.Close set f=nothing set fs=nothing
End Function

Making a good pot of chimarrão

I have many friends in Brazil. Meeting them and drinking chimarrĂ£o together aways been great times. So now I even have my own stack of herbs here in the freezer (Directly from Brazil, the imported herbs in the shops in Belgium are really bad!)

The only hard part sometimes is to make the pot of chimarrĂ£o.

I found a very easy and good way, where the herbs keep fixed and you can enjoy all day! They call it the ant heap.

Here are the steps to follow:

1) Fill the pot with water to the top.

2) Insert the BOM (pipe) and lower the water level until a few cm above the head of the pipe.

3) Fill it with herbs until you get a small hill on top:

Do not push the herbs, just let it fall on int the pot.

4) Make a small hole with your finger in the other side as where the pipe goes in:

(Do not try to push on the herbs, just swipe the herbs on the sides to get a small hole there.)

5) Pour a little bit of water in the hole:

Really not too much, just a bit, to get the herbs sticky where we will make the hole go down to the bottom later.

6) Leave it for 2 minutes, then gently make the hole deeper with a spoon or fork end: