Skip to content

Instantly share code, notes, and snippets.

View tstelzer's full-sized avatar

Timm Stelzer tstelzer

View GitHub Profile
@tstelzer
tstelzer / gulpfile.babel.js
Last active July 30, 2016 13:32
Gulp setup for wordpress development
import gulp from 'gulp';
// utility
import rename from 'gulp-rename';
import debug from 'gulp-debug';
import changed from 'gulp-changed';
import gutil from 'gulp-util';
import del from 'del';
import sequence from 'gulp-sequence';
// html
import pug from 'gulp-pug';
@tstelzer
tstelzer / Contract Killer 3.md
Created August 1, 2016 23:55 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@tstelzer
tstelzer / ToggleRNU()
Created September 10, 2016 21:29
vim / use relative numbers depending on context
fun! ToggleRNU()
if &ft =~ 'help' || &ft =~ 'ctrlp'
return
endif
setlocal relativenumber
endfun
augroup ToggleRNU
au!
au WinEnter * call ToggleRNU()
au InsertEnter * setlocal nornu
@tstelzer
tstelzer / mode.vim
Created March 10, 2017 15:34
minimal modeline
function! ModeColor(mode)
let s:modes = {
\ 'n': '%#Normal#',
\ 'v': '%#Visual#',
\ 'V': '%#Visual#',
\ '': '%#Visual#',
\ }
if !has_key(s:modes, a:mode)
return '%#User3#' " default
else
// call with `gulp less --env=production`
// or `gulp less --env=somethingElse`
// mostly from https://github.com/gulpjs/gulp/blob/master/docs/recipes/pass-arguments-from-cli.md
var args = require('minimist');
var gulp = require('gulp')
var rename = require('gulp-rename')
var less = require('gulp-less')
var util = require('gulp-util');
@tstelzer
tstelzer / todos-actions.ts
Last active October 27, 2017 11:54
How I type my reducers.
// Regular old action constant literal.
export const ADD = 'todos/ADD'
// Action type.
export type ADD = Action<'todos/ADD', {readonly todo: Todo}>
export type AllActions =
| ADD
@tstelzer
tstelzer / implementation-example.js
Last active January 27, 2018 15:45
simple-functional-validation.js
const isEven = n => (n % 2 === 0)
const gte = min => n => n >= min
const isNil = x => x === undefined || x === null
const validatorA = {
pred: isEven,
message: n => `"${n}" should be an even number.`,
accessor: obj => obj.num1,
}
@tstelzer
tstelzer / validation.ts
Last active January 26, 2019 17:32
an attempt at applicative validation
import {array} from 'fp-ts/lib/Array';
import {getArrayMonoid} from 'fp-ts/lib/Monoid';
import {
failure as _failure,
Failure as _Failure,
getApplicative,
isSuccess as _isSuccess,
success as _success,
Success as _Success,
Validation as _Validation,
@tstelzer
tstelzer / index.html
Created September 14, 2019 18:24
intro-web-programming
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="description">
<meta name="author" content="Timm Stelzer">
<link rel="stylesheet" href="./styles.css">
@tstelzer
tstelzer / main-with-naive-impl.rs
Created April 16, 2020 16:34
Rust Closures Cache
struct Cacher<T>
where
T: Fn(u32) -> u32,
{
calculation: T,
value: HashMap<u32, u32>,
}
impl<T> Cacher<T>