Best Practice: Convert 1 and 0 to true and false in Javascript

1 und 0 zu true und false in Javascript
Today there will be only a very short post. There are certainly many ways to convert 0 and 1 in Javascript to true and false.
The following way to reach the wanted result I’ve seen today. I think it is probably the shortest and most elegant way to go. In addition, it works not only for integer values, but also for the string representations of 0 to 1.
So this is the stuff I like to add to my personal “POP”-collection (pearls of programming)…
0 and 1 to true and false
To convert the integers 0 and 1 to boolean, it is sufficient to use the not-operator twice.

var thisIsFalse = !!0; //false
var thisIsTrue = !!1; //true

Why it works? Here is a short explanation. 1 is a valid value and thus true. When we write !1 now, then we create a false condition because 1 […]

Open SAP GUI from HTML out of your webbrowser

SAP aus Browser aufrufenSome time ago I got into a discussion about whether it is possible to open transactions in the SAP GUI out of the browser. The opinion of the colleagues was unanimous – start SAP GUI from browser is something not be done.
However I have maintained and created a small proof-of-concept. Because it works. Ok, it’s not pretty, but it works. And that’s how to call the SAP GUI from the browser.
sapshcut.exe and what you can do with it
The solution works (among other things) using the sapshcut.exe (short for SAP Shortcut). This .exe file allows to start the SAP GUI parameterized. The possible parameters ranging from user via logon language up to the executed transaction. A complete list of possible parameters can be obtained by calling the sapshcut.exe with the parameter -?. (See screenshots below.)
sapshcut.exe - help from cmd  

How to pixelate images using Javascript

Close Pixelate TutorialToday there is again a bit of Javascript code. The exact topic is about how you can pixelate images via Javascript. This has both advantages and drawbacks, which I would like to briefly point out once below.

Pixelation can be done dynamically (Manual effort in your graphics program falls away. Graphics must not be known beforehand.)
The computational power required is outsourced to the client side. In contrast to a server-side solutions (eg using PHP & Imagick), the computational load is distributed to the users. This helps to keep the server load low, if you have a lot of visitors.


The pixelation should be used rather as design or graphic effect, since the data is only sent not pixelated to the client. So if you really want to hide faces and picture information the pixelation still needs to be done before delivery to the […]

Javascript’s escape() in C# – a C# equivalent to the escape()-function

csharp_vs_javascriptThe .NET framework provides a large number of ways to encode HTML code and URLs. There exist, for example, Uri.EscapeDataString(), Uri.EscapeUriString(), System.Web.HttpUtility.UrlEncode(), System.Web.HttpUtility.UrlPathEncode(), System.Web.HttpUtility.HtmlEncode() or System.Web.HttpUtility.HtmlAttributeEncode().
However, if you are looking for equivalent functionality to Javascript’s escape(), so you will be disappointed by all of these aforementioned functions. None of these inherently with the .NET framework delivered functions is equivalent to the Javascript escape() function.  For better understanding, I made the following example:
The test text is in german, because the ‘ä’ is a nice character to show the problems. Translated to english it means: “Raffi’s annoying C# testcode”.

// Original source text
// Raffi’s ärgerlicher C# Teststring/Testcode.

// Javascript original (produced by escape())
// Raffi%27s%20%E4rgerlicher%20C%23%20Teststring/Testcode.

// Uri.EscapeDataString():
// Raffi’s%20%C3%A4rgerlicher%20C%23%20Teststring%2FTestcode.

// Uri.EscapeUriString():
// Raffi’s%20%C3%A4rgerlicher%20C#%20Teststring/Testcode.

// System.Web.HttpUtility.UrlEncode():
// Raffi%27s+%c3%a4rgerlicher+C%23+Teststring%2fTestcode.

// System.Web.HttpUtility.UrlPathEncode():
// Raffi’s%20%c3%a4rgerlicher%20C#%20Teststring/Testcode.

// System.Web.HttpUtility.HtmlEncode():
// Raffi's ärgerlicher C# Teststring/Testcode.

// System.Web.HttpUtility.HtmlAttributeEncode():
// Raffi's ärgerlicher C# Teststring/Testcode.

But I would not blog about it if I did not have a solution […]