Skip to content

Instantly share code, notes, and snippets.

View renaatdemuynck's full-sized avatar

Renaat De Muynck renaatdemuynck

  • Artevelde University of Applied Sciences
  • Ghent, Belgium
View GitHub Profile
fetch('http://localhost/my-script.js').then(response => {
var reader = response.body.getReader();
var result = new Uint8Array();
reader.read().then(function processText({ done, value }) {
if (done) {
let decoder = new TextDecoder('utf-8');
return decoder.decode(result);
}
@renaatdemuynck
renaatdemuynck / AdapterChain.php
Created September 24, 2015 16:10
Chainable authentication adapters in Zend Framework
<?php
namespace My\Authentication\Adapter;
use Zend\Authentication\Adapter\AbstractAdapter;
use Zend\Authentication\Adapter\Exception\InvalidArgumentException;
use Zend\Authentication\Adapter\ValidatableAdapterInterface;
use Zend\Authentication\Result;
class AdapterChain extends AbstractAdapter
{
CREATE FUNCTION `format_filesize`(filesize INTEGER) RETURNS varchar(20) CHARSET utf8
BEGIN
DECLARE log INT;
SET log = TRUNCATE(LOG(1024, filesize), 0);
RETURN CONCAT(ROUND(filesize / POW(1024, log), 2), ' ',
ELT(log + 1, 'Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB', 'BB'));
END
@renaatdemuynck
renaatdemuynck / README.md
Last active August 29, 2015 14:05 — forked from gmarik/README.md

About

minimal example of using [phantomjs] with [qunit]

$ phantomjs run-qunit.js file://`pwd`/test.html
'waitFor()' finished in 200ms.
Tests completed in 21 milliseconds.
5 tests of 5 passed, 0 failed.

Installation

@renaatdemuynck
renaatdemuynck / uniqueID.js
Last active May 13, 2019 13:34
Returns the unique identifier generated by the browser for the object
/**
* @file Returns the unique identifier generated by the browser for the object.
* The uniqueID property of the document works as an identifier generator in Internet Explorer.
* Each time when the value of this uniqueID property is retrieved, the browser generates
* a new unique identifier and returns it.
* HTML elements also support the uniqueID property. The first time when the value of any of these
* properties is retrieved, the browser generates a new identifier for the element.
* @author Renaat De Muynck <renaat.demuynck@gmail.com>
*/