PHP: What is lsphp?

PHP needs to communicate with the WebServer (apache, nginx, litespeed or any other) in a format which both parties can understand. For example a common way of integrating apache with PHP is by using “mod-php” for apache. nginx usually is integrated using “php-fpm” which is a modern way of “cgi” interface (basically informations are shared … Read more

Why onbeforeunload event is not firing

The onbeforeunload event is not cancel-able, because of security reasons, but if an event handler function for the onbeforeunload event returns a string value, this text will be shown in a confirmation dialog box, where the user can confirm whether he wants to stay or leave the current page. Note that event listeners cannot be registered for the onbeforeunload event with the addEventListener and attachEvent methods (only … Read more

adb devices return error: protocol fault (no status)

I had the same issue and found the problem: Android Studio. Open the Android Studio menu Tools -> Android and uncheck Enable ADB integration. adb devices should work (you might need adb kill-server first). Then you can re-enable ADB integration in Studio.

What does the variable $this mean in PHP?

It’s a reference to the current object, it’s most commonly used in object oriented code. Reference: http://www.php.net/manual/en/language.oop5.basic.php Primer: http://www.phpro.org/tutorials/Object-Oriented-Programming-with-PHP.html Example: This stores the ‘Jack’ string as a property of the object created.

C# Encoding a text string with line breaks

Yes – it means you’re using \n as the line break instead of \r\n. Notepad only understands the latter. (Note that Environment.NewLine suggested by others is fine if you want the platform default – but if you’re serving from Mono and definitely want \r\n, you should specify it explicitly.)

Fastest way to put contents of Set to a single String with words separated by a whitespace?

With commons/lang you can do this using StringUtils.join: You can’t really beat that for brevity. Update: Re-reading this answer, I would prefer the other answer regarding Guava’s Joiner now. In fact, these days I don’t go near apache commons. Another Update: Java 8 introduced the method String.join() While this isn’t as flexible as the Guava version, it’s handy when … Read more

How to use bitmask?

Bit masking is “useful” to use when you want to store (and subsequently extract) different data within a single data value. An example application I’ve used before is imagine you were storing colour RGB values in a 16 bit value. So something that looks like this: You could then use bit masking to retrieve the … Read more

Create empty branch on GitHub

November 2021 Update: As of git version 2.27, you can now use git switch –orphan <new branch> to create an empty branch with no history. Unlike git checkout –orphan <new branch>, this branch won’t have any files from your current branch (save for those which git doesn’t track). This should be the preferred way to create empty branches with … Read more