Skip to content

Instantly share code, notes, and snippets.

View boukeversteegh's full-sized avatar

Bouke Versteegh boukeversteegh

View GitHub Profile
/* TRIANGLE */
.triangle {
width: 0;
height: 0;
border-width: 10px;
border-style: solid;
border-color: transparent;
font-size: 0;
}
@boukeversteegh
boukeversteegh / haar.py
Last active October 23, 2017 16:19
Haar Filter, Reversible Discrete Wavelet Transform
import math
import sys
'''
python haar.py
python haar.py 1 5 3 1
'''
def wrap(value, ubound):
sites:
apidoc:
scheme: http
host: apidoctest.elephone.vb
api:
scheme: http
host: api.elephone.vb
nginx_sites:
<<<<<<< HEAD
@boukeversteegh
boukeversteegh / move_file_sessions_to_database.php
Created October 7, 2015 16:36
Migration to switch from file sessions to database sessions
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Session\FileSessionHandler;
use Illuminate\Session\DatabaseSessionHandler;
use Symfony\Component\Finder\Finder;
/**
* @author Bouke Versteegh
*/
Constanten gebruiken voor ENUM waardes
<?php
class Ticket {
/**
* @ORM\Column(type="string", nullable=false, options={"default":"available"}, columnDefinition="enum('available','assigned','blocked','cancelled')")
*/
public $status = 'available';
}
$ticket = new Ticket();
@boukeversteegh
boukeversteegh / BaseModel.php
Last active April 21, 2017 13:45
Sorting Laravel model by relationship count (see comments for usage)
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* Class BaseModel
@boukeversteegh
boukeversteegh / sortArrays.js
Last active February 15, 2023 09:21
Sorting multiple arrays in Javascript
/**
* Sorts all arrays together with the first. Pass either a list of arrays, or a map. Any key is accepted.
* Array|Object arrays [sortableArray, ...otherArrays]; {sortableArray: [], secondaryArray: [], ...}
* Function comparator(?,?) -> int optional compareFunction, compatible with Array.sort(compareFunction)
*/
function sortArrays(arrays, comparator = (a, b) => (a < b) ? -1 : (a > b) ? 1 : 0) {
let arrayKeys = Object.keys(arrays);
let sortableArray = Object.values(arrays)[0];
let indexes = Object.keys(sortableArray);
let sortedIndexes = indexes.sort((a, b) => comparator(sortableArray[a], sortableArray[b]));
@boukeversteegh
boukeversteegh / main.dart
Last active September 23, 2020 17:57
Luck or hard work?
// run this script in your browser on:
//
// https://dartpad.dev/000ff368df58b18627652d5c6dc2cfc3
import 'dart:math';
// number of participants:
const n_participants = 18300;
// that will receive a skill between:
@boukeversteegh
boukeversteegh / enum_template.dart
Last active July 1, 2024 10:05
Dart class as enum template
void main() {
print(Number.one);
print(Number.two);
print(Number.three);
print(Number.fromInt(1));
print(Number.fromInt(2));
print(Number.fromInt(3));
print(Number.fromString('1'));
@boukeversteegh
boukeversteegh / readfiletest.dart
Last active September 23, 2020 17:52
Dart reading files (sync/async) performance test
import 'dart:io';
import 'dart:math';
import 'dart:typed_data';
const KB = 1024;
const MB = 1024 * KB;
const GB = 1024 * MB;
const sizes = {'B': 1, 'KB': KB, 'MB': MB, 'GB': GB};
const blockSize = 16 * MB;