GraalVM, Truffle, SubstrateVM and Sulong

I’ve been reading a lot about Graal recently, and with a bunch of related projets, I needed to remind myself what are the differences and uses for each. Here’s a brief recap and intro to those projects. Most of the research and work is from Oracle and the JKU (Johannes Kepler University Linz). GraalVM GraalVM’s motto is “Run Programs Faster Anywhere”, also known as “One VM to rule them all”.
Read more...

Record on motion detection with Xiaomi Dafang

Couple months ago, I read this article about hacking the Xiaomi Dafang camera to expand its capabilities. It’s a cheap $30 camera with neat features, such as MicroSD support, a rotating gimbal, microphone, infrared vision, among others. Thought it would be a fun project to try it out. The goal was to check if I could use this to record motion detection at night, without going to a third party service.
Read more...

How to read the RubyGems specs file

Had an issue with gems not being downloaded from JFrog’s Artifactory. Basically it looked as if gem install could not be found on the Artifactory repo, yet manually browsing the repo, the gem was properly uploaded. Reading the specs file that is downloaded during gem install highlighted the issue, which is deploying a same gem version didn’t properly show up in the specs file. # the ;1 is to prevent the possible long list of gems to display afterwards irb(main) list = Marshal.
Read more...

Understanding the JVM memory

Stumbled upon a very nice explanation of the JVM memory, including garbage collector, tuning and related errors (watch here, in french). Here are some notes. Garbage Collector The classic garbage collector (included into the standard HotSpot JVM) will clean the Young Gen in minor GCs, and the entire heap (including both Young and Tenured gen) during a full GC, which occurs less frequently than the former. Read https://stackoverflow.com/a/2129294 for some additional information:
Read more...

Capture The Flag

There’s a Capture The Flag security challenge going on, organized by Stripe, the payment company. Capture The Flag security challenge are a series of technical weaknesses that participants need to find in order to find flags and capture them for points. It can range from finding a password through a SQL injection, to getting permissions to a server box. I highly recommend anyone that is interested in broadening their development skills in joining those challenges.
Read more...

Understanding PHP multi_curl_exec loops

In the PHP curl_multi_exec manual, a strange 3 loops are given as an example: do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); while ($active && $mrc == CURLM_OK) { if (curl_multi_select($mh) != -1) { do { $mrc = curl_multi_exec($mh, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); } } I was wondering why we needed so many while loops as opposed to a simple one such as: do { curl_multi_exec($master,$running); } while($running > 0); What I have found is mostly due to prevent making unnecessary calls to curl_multi_exec.
Read more...

Capistrano deploy tag, using wrong revision

You have your code under SVN, and trying to deploy via Capistrano. You capify your root folder, you cap deploy:setup, everything works. How do you deploy a specific tag? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 set :application, "
Read more...

PHP flush, sleep, and browsers…

If anything else doesn’t work, try this sample code:

 1 2 3 4 5 6 7 8 910111213141516
<?php
@apache_setenv('no-gzip', 1);
@ini_set('zlib.output_compression', 0);
@ini_set('implicit_flush', 1);
for ($i = 0; $i &lt; ob_get_level(); $i++) { ob_end_flush(); }
ob_implicit_flush(1);

// All you need is 256 spaces first
echo str_repeat(" ", 256); ob_flush();
for($i=0;$i&lt;10;$i++)
{
   echo $i,' ';
   ob_flush();
   sleep(1);
}

PHP strip_tags, while keeping the inner text

function strip_only($str, $tags) {
    if(!is_array($tags)) {
        $tags = (strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags));
        if(end($tags) == '') array_pop($tags);
    }
    foreach($tags as $tag) $str = preg_replace('#</?'.$tag.'[^>]*>#is', '', $str);
    return $str;
}

$str = '<p style="text-align:center">Paragraph</p><strong>Bold</strong><br/><span style="color:red">Red</span><h1>Header</h1>';

echo strip_only($str, array('p', 'h1'));
echo strip_only($str, '<p><h1>');

Credit: Steven (php.net)