Skip to content

Instantly share code, notes, and snippets.

Avatar

Harmen Stoppels haampie

View GitHub Profile
@haampie
haampie / exc18.cpp
Created Sep 20, 2015
rereading stdin
View exc18.cpp
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char * argv[])
{
string line;
bool foundStart = false;
size_t start = 0;
View example.js
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= /*...*/;
});
View gist:995631
function LoadDashBoard()
{
$("#actdiv").hide('fast');
var loadUrl = "ajax/load_agents.php";
var ajax_load_bar = "<div align='center'><img src='images/loadingAnimation.gif' alt='loading...' /></div>";
$("#actdiv").html(ajax_load_bar).load(loadUrl,function() {
$(".agent-tab").click(function(){
alert('cliek');
});
});
@haampie
haampie / rug-to-csv.js
Created Sep 10, 2011
RUG kalender naar Google Calendar dmv CSV
View rug-to-csv.js
NodeList.prototype.forEach = Array.prototype.forEach;
HTMLCollection.prototype.forEach = Array.prototype.forEach;
Date.prototype.getSimpleDateString = function(){
return this.getDate() + '-' + (this.getMonth()+1) + '-' + this.getFullYear();
};
function Vakkenlijst(){
this.lijst = [];
View gist:778e907956d253478cf7
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];
@haampie
haampie / main.cc
Last active Jan 6, 2016
locks 'n stuff
View main.cc
#include <condition_variable>
#include <iomanip>
#include <iostream>
#include <thread>
using namespace std;
int someNumber = 0;
mutex numberMutex;
condition_variable cv;
View index.html
<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 / hydrate.php
Created Jul 25, 2016
Hydration methods
View hydrate.php
<?php
$iterations = 1000000;
class Example
{
private $a;
private $b;
private $c;
private $d;
@haampie
haampie / request.php
Last active Aug 18, 2016
Sync / Async event handlers
View request.php
<?php
// In requests:
final class SomeSubscriber {
public function applyDomainEvent(DomainEvent $xyz) {
// Maybe fire another event to get some consistency.
}
}
@haampie
haampie / json-base64.php
Created Aug 19, 2016
File contents and memory
View json-base64.php
<?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);
}