External USB 3.0 SSD with Full Disk Encryption

ata encryption, aes256, ASM1053E, ubuntu, linux, external case, caddy, intel 535 series

Preface# External USB drives are everywhere these days, used as storage extension, data transport facility or backup drive. If you need a reliable, schock resistent and secure solution an external SSD might be the best choice instead of an old fashioned hard drive. Especially in case the drive got stolen, a SSD can protect your data […]

HowTo: Flashing NodeMCU Firmware to ESP8266

esptool.py, nodemcu, ubuntu, debian

NodeMCU Firmware# From time to time, you should take a look into the official NodeMCU Firmware repository. It is under heavy development and new modules and features are added constantly. Since version 0.9.6, there are no binary releases available, because the large amount of available module will not fit into the flash. Instead, you can […]

Firmware Update of IBM ServeRaid BR10i with Ubuntu

system x, x3550 m3, LSI SAS 1068E, ibm 7944

I have just got a used IBM x3550 M3 server as development machine and ran into some trouble when trying to add some SSDs: the throughput was pretty slow (~100MB/s). Generally the BR10i controller supports 3G SATA2 and therefore i expected a throughput of ~250MB. I’ve figured out, that this behaviour is caused by the firmware […]

Render Markdown/GFM Documents online using the GitHub v3 API

simple code snipped to convert markdown to html, public github api

Sometimes, you need to render parts of your Markdown documents – e.g. README.md or CHANGES.md – as html to embed it into your application, documentation or project website. There are a several markdown or especially GFM (GitHub Flavored Markdown) libraries are out there, but they require an additional setup and have to be maintained.

The simple Way#

Thanks to GitHub, there is a public API available which allows you to render your documents by the GitHub webservices.

PHP Client#

/**
 * Render Markdown content using the GitHub v3 Markdown API
 * @see https://developer.github.com/v3/markdown/
 * @source https://andidittrich.com/2016/05/render-markdown-gfm-documents-online-using-the-github-v3-api
 * @license: MIT
 * @return string(html)
 */
function renderGFM($text, $repositoryContext = null){

    // create the payload
    // @see https://developer.github.com/v3/markdown/
    $postdata = json_encode(
        array(
            'text' => $text,
            'mode' => ($repositoryContext != null ? 'gfm' : 'markdown'),
            'context' => $repositoryContext
        )
    );

    // prepare the HTTP 1.1 POST Request
    $opts = array('http' =>
        array(
            'method'  => 'POST',
            'protocol_version' => '1.1',
            'user_agent' => $repositoryContext,
            'header'  => array(
                'Content-type: application/x-www-form-urlencoded;charset=UTF-8',
                'Connection: close',
                'Accept: application/vnd.github.v3+json'
            ),
            'content' => $postdata
        )
    );

    // send request
    return file_get_contents('https://api.github.com/markdown', false, stream_context_create($opts));
}

Usage#

The optional $repositoryContext argument allows your to define the context which should be used for rendering to e.g. enable issue linking

// fetch the document (example)
$document = file_get_contents('https://raw.githubusercontent.com/AndiDittrich/WordPress.Enlighter/master/CHANGES.md');

// render html using the GitHub GFM API
$html = renderGFM($document, 'AndiDittrich/WordPress.Enlighter');

// show it!
echo $html;

 

 

Ubuntu 15.10 with Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card

mbmi to qmi modeswitch, magical ffc-auth sequence

A several days ago, i’ve replaced the Gobi 2000 WWAN Card with a newer version, a Dell 5570 Module. It’s a branded Sierra Wireless card, so i hoped it will work out of the box on Ubuntu 15.10 – but nothing. After some investigations if figured out, that the card is locked in “low-power” / […]

Ubuntu 15.10 – Disable Wake on LAN (WOL) permanently

ubuntu, systemd, Wily Werewolf, notebook, battery power drain

Preface# In some cases, Wake on LAN is enabled by default and you cannot disable it in your BIOS/UEFI because the setting is not available. On notebooks/ultrabooks, WOL can drain/discharge your battery even your device is powered-off! There are a several guides out there, which didn’t even work. The general mistake is, that the WOL […]