Skip to content

Instantly share code, notes, and snippets.

View wottpal's full-sized avatar

Dennis Zoma wottpal

View GitHub Profile
@wottpal
wottpal / date-formats.ts
Created April 18, 2019 15:10
Custom DateFormats & DateAdapter for Angular Material MatDatepicker using Day.js
import { Platform } from '@angular/cdk/platform';
import { NativeDateAdapter } from '@angular/material';
import * as dayjs from 'dayjs';
import 'dayjs/locale/de';
import * as customParseFormat from 'dayjs/plugin/customParseFormat';
import * as localizedFormat from 'dayjs/plugin/localizedFormat';
/**
* Custom Date-Formats and Adapter (using https://github.com/iamkun/dayjs)
@wottpal
wottpal / form.service.ts
Last active April 21, 2021 14:55
Angular Service to synchronize FormGroup(s) with LocalStorage (get & set)
import { Injectable } from '@angular/core';
import { FormGroup, FormControl } from '@angular/forms';
import * as dayjs from 'dayjs'
@Injectable({
providedIn: 'root'
})
export class FormService {
@wottpal
wottpal / counter.component.ts
Last active March 25, 2020 17:36
Simple Angular Counter/Countdown Component with dayjs & rxjs
/**
*
* Example Usage:
*
* # Counter
* const now = dayjs()
* <app-counter [autostart]="true" [mode]="forwards" [startTime]="now"></app-counter>
*
* # Countdown
* const later = dayjs().add(1, 'minute')
@wottpal
wottpal / post-receive
Last active July 22, 2019 09:39
Kirby Git Deploy Hook
#!/bin/bash
# IMPORTANT REQUIREMENTS
# * Make sure the git-user is allowed to perform operations on behalf of
# www-data (without password) by adding this line to `/etc/sudoers`:
# `git ALL=(www-data) NOPASSWD: /usr/bin/git, /bin/mkdir`
# * Make sure `var/www` is owned by www-data:www-data by executing
# `sudo chown -R www-data:www-data /var/www`
# * Add www-data to the git-group by executing `sudo usermod -a -G git www-data`
# * Make sure this file is executable by executing
#! -*- coding: utf-8 -*-
import sys
import time
import numpy as np
import gensim
import matplotlib.pyplot as plt
from matplotlib import font_manager, rc
from sklearn.manifold import TSNE
from sklearn.cluster import MiniBatchKMeans
@wottpal
wottpal / kirby-nginx
Last active November 15, 2018 19:20
#######################
#######################
# KIRBY-CONFIGURATION #
# block content
location ~ ^/content/(.*).(txt|md|mdown)$
{
rewrite ^/content/(.*).(txt|md|mdown)$ /error redirect;
}
def VGG_16_BN(input_shape):
model = models.Sequential()
model.add(Convolution2D(64, (3,3), input_shape=input_shape, activation='relu', padding='same', use_bias=False))
model.add(BatchNormalization())
model.add(Convolution2D(64, (3,3), activation='relu', padding='same', use_bias=False))
model.add(BatchNormalization())
model.add(MaxPooling2D((2,2), strides=(2,2)))
model.add(Convolution2D(128, (3,3), activation='relu', padding='same', use_bias=False))
model.add(BatchNormalization())

Simple Contact-Form in Kirby 3

As a starting point I've used the latest Starterkit (Beta 4) combined with the core from the latest Nightly Build (18-08-06).

First, set email-properties in your config. I would recommend using a mail-service like Mailgun (via SMTP) because setting everything up on your own server is cumbersome, error-prone, and unsecure. But of course, it's up to you.

site/config/config.php:

<?php
@wottpal
wottpal / debug.js
Last active April 19, 2018 10:22
A convenience wrapper around the Console API which adds several functionalities.
/**
* A convenience wrapper around the Console API which adds:
* - Logging has to be globally enabled first (in a dev-environment)
* - Even when disabled logged messages are cached and can be displayed later
* - Prefix messages with a custom〈 Label 〉
*
* TODO Maybe add verbose-flag to really be able to log everything if needed
**/
@wottpal
wottpal / exp-027.js
Last active February 10, 2018 09:30
* numberOfPoints defines amount of points * respects frameWidth * returns array of triangles in the format [ [[x1, y1],[x2, y2],[x3, y3]], ... ]
function triangulateCanvas() {
let points = [], triangles = []
for (let i = 0; i < numberOfPoints; i++) {
const randomX = random(frameWidth, WIDTH-frameWidth)
const randomY = random(frameWidth, HEIGHT-frameWidth)
points.push([
constrain(randomX, frameWidth, WIDTH-frameWidth),
constrain(randomY, frameWidth, HEIGHT-frameWidth)