Skip to content

Instantly share code, notes, and snippets.

View haampie's full-sized avatar

Harmen Stoppels haampie

View GitHub Profile
@haampie
haampie / test
Created November 8, 2016 21:49
test
0.5258035496409385338996633621320518075577262895034576824436935036190909359484821735511244086357105703763089095001084909503562784106432631780885381833487161441115426324089735535648577478022198173062961599662707079574920200839277886235481421364962201726366096411855900154689889962293083318039904967542464945043705977339467548513433912472348985230682047335936507184327257718362160494751446144883847282407215005669970705901314196397855777633081493954608446354...
@haampie
haampie / json-base64.php
Created August 19, 2016 16:12
File contents and memory
<?php
$app->get('/', function () {
// Write some data to a temp file
$stream = fopen('php://temp', 'w+');
for ($i = 0; $i != 100000; $i++) {
fwrite($stream, str_repeat(strval($i), 100) . PHP_EOL);
}
@haampie
haampie / request.php
Last active August 18, 2016 23:21
Sync / Async event handlers
<?php
// In requests:
final class SomeSubscriber {
public function applyDomainEvent(DomainEvent $xyz) {
// Maybe fire another event to get some consistency.
}
}
@haampie
haampie / hydrate.php
Created July 25, 2016 21:28
Hydration methods
<?php
$iterations = 1000000;
class Example
{
private $a;
private $b;
private $c;
private $d;
var autocompletes = ['name', 'honorific-prefix', 'given-name',
'additional-name', 'family-name', 'honorific-suffix',
'nickname', 'username', 'new-password',
'current-password', 'organization-title', 'organization',
'street-address', 'address-line1', 'address-line2',
'address-line3', 'address-level4', 'address-level3',
'address-level2', 'address-level1', 'country',
'country-name', 'postal-code', 'cc-name', 'cc-given-name',
'cc-additional-name', 'cc-family-name', 'cc-exp',
'cc-exp-month', 'cc-exp-year', 'cc-csc', 'cc-type',
@haampie
haampie / index.html
Last active April 19, 2016 20:21
Examples
<form id="form" action="/" method="post">
<div class="inputarea">
<h1>Leave your email to obtain 5 free articles</h1>
<label for="email">Email</label>
<input type="email" name="email" id="email" placeholder="name@example.com" required autocomplete="email" class="input" />
<p><input type="submit" id="submit" class="button" value="Send!"></p>
</div>
</form>
@haampie
haampie / main.cc
Last active January 6, 2016 23:11
locks 'n stuff
#include <condition_variable>
#include <iomanip>
#include <iostream>
#include <thread>
using namespace std;
int someNumber = 0;
mutex numberMutex;
condition_variable cv;
proxy_cache_path /var/www/gravatar-cache levels=1:2 keys_zone=gravatar:8m inactive=24h use_temp_path=off max_size=1000m;
proxy_cache_key "$scheme$request_method$host$request_uri";
server {
listen 443 ssl http2;
server_name [hidden];
access_log off;
ssl_certificate [hidden];
ga(function(tracker) {
var linkerParam = tracker.get('linkerParam');
console.log(linkerParam);
// hier nu iets doen met linkerParam, want hier issie beschikbaar.
// kan zijn dat de DOM nog *niet* geladen is als je code in de header staat
document.addEventListener("DOMContentLoaded", function(event) {
var form = document.getElementById('some-form');
form.action= /*...*/;
});
@haampie
haampie / exc18.cpp
Created September 20, 2015 10:28
rereading stdin
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char * argv[])
{
string line;
bool foundStart = false;
size_t start = 0;