Skip to content

Instantly share code, notes, and snippets.

View marcusandre's full-sized avatar

Marcus André marcusandre

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() {
@marcusandre
marcusandre / defaults.vim
Created October 8, 2016 19:58
Vim 8.0 default vimrc
" The default vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2016 Sep 02
"
" This is loaded if no vimrc file was found.
" Except when Vim is run with "-u NONE" or "-C".
" Individual settings can be reverted with ":set option&".
" Other commands can be reverted as mentioned below.
/* 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 / ping.js
Created September 7, 2013 10:44
ping
// `ping` backend from client via websocket
// frontend code
// ping every 60 seconds or so
ping.send({
"user": userid,
"time": new Date.now()
});
@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 / ostype.sh
Last active January 31, 2019 18:19
Get operating system as string identifier from $OSTYPE
#!/bin/sh
#
# get os type
#
get_os() {
if [ -z $OSTYPE ]; then
OSTYPE=$(uname | tr '[:upper:]' '[:lower:]')
fi
@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;