Skip to content

Instantly share code, notes, and snippets.

View marcusandre's full-sized avatar

Marcus André marcusandre

  • Germany
  • 05:59 (UTC +01:00)
View GitHub Profile
@marcusandre
marcusandre / Readme.md
Created March 29, 2024 00:07
Implementing TCP in Rust

TBD

@marcusandre
marcusandre / sequential-map.ts
Last active October 19, 2022 14:31
Sequential version of Map in continuation passing style
type MapHandler<T> = (item: T, index: number, callback: (result: T) => void) => void;
type MapDoneHandler<T> = (results: T[]) => void;
function map<T>(array: T[], handler: MapHandler<T>, done: MapDoneHandler<T>) {
let index = 0;
let results: T[] = [];
step()
function step() {
/* Reset */
*:where(:not(iframe, canvas, img, svg, video):not(svg *, symbol *)) {
all: unset;
display: revert;
}
*,
*::before,
*::after {
const dayjs = require('dayjs')
let start = dayjs().startOf('day')
const end = start.add(1, 'day')
const results = {}
while (start.isBefore(end)) {
const fmt = start.format('HH:mm')
const qs = fmt
.replace(':', '')
@marcusandre
marcusandre / Dockerfile
Last active March 18, 2019 15:50
run your Lumen development efforts with docker.
FROM php:7.3-apache
ENV APACHE_DOCUMENT_ROOT /var/www/html/public
RUN docker-php-ext-install pdo pdo_mysql
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
RUN a2enmod rewrite
@marcusandre
marcusandre / header.js
Created February 14, 2019 11:55
simple sticky scrolling header
/* global $ */
import throttle from 'raf-throttle'
export default class Header {
constructor (el) {
this.el = el
this.hiddenClass = 'hidden'
}
stick () {
@marcusandre
marcusandre / style.css
Created January 10, 2019 07:29
Solve word break of long titles and headlines
h1,
h2,
h3,
h4,
h5,
h6,
.word-wrap,
.word-break {
overflow-wrap: break-word;
word-wrap: break-word;
@marcusandre
marcusandre / iban-regex.md
Last active December 11, 2018 09:23
IBAN regular expressions

IBAN regular expression

The following regular expression will match:

  • AB12 1234 1234 1234 1234
  • AB12 1234 1234 1234 1234 1
  • AB12 1234 1234 1234 1234 12

but also:

@marcusandre
marcusandre / sw.js
Last active November 19, 2018 09:12
Simple Service Worker to respond with cached request
(function () {
'use strict'
self.addEventListener('fetch', event => {
let request = event.request
if (request.method !== 'GET') {
return
}
event.respondWith(
caches.match(request)
.then(response => {
@marcusandre
marcusandre / mysql.service
Last active October 16, 2018 04:42
get mysql config file hierarchy on the system
/usr/sbin/mysqld --verbose --help | grep -A 1 "Default options"