Skip to content

Instantly share code, notes, and snippets.

@christianwish
christianwish / Zahlenbereiche.tex
Created February 19, 2020 12:26
Zahlenbereiche - Latex
$$\mathbb{N} = \{ 1,2, \dots\}$$
$$\mathbb{Z} = \{ \dots -2, -1, 0, 1,2, \dots\}$$
$$\mathbb{Q} = \{ x | x = \frac{m}{n} | m,n\in \mathbb{N}, n \neq 0\}$$
@christianwish
christianwish / useIsMounted.ts
Last active September 28, 2019 07:14
REact custom hook "useIsMounted"
import * as React from 'react';
export const useIsMounted = (): boolean => {
const [isMounted, setIsMounted] = React.useState(false);
React.useEffect(() => setIsMounted(true), []);
return isMounted;
};
const [a, b, c] = [await aPromise, await bPromise, await cPromise];
enum DocStatus {
OPEN = "OPEN",
WON = "WON",
DRAFT = "DRAFT",
OVERDUE = "OVERDUE",
CANCELED = "CANCELED",
};
interface Doc {
readonly id: string,
@christianwish
christianwish / usage.js
Last active April 18, 2019 14:28
Experimental React Custom Hook to prevent "can't perform a React state update on an unmounted component"
import React, { useEffect, useState } from 'react';
import { usePromiseEffect } from './usePromiseEffect';
const ToggleMount = () => {
const [fetched, setFetched] = useState(false);
const callbacks = {
resolve: (res) => {
setFetched(true);
},
@christianwish
christianwish / git-alias.sh
Last active March 7, 2019 21:18
Git Aliases
# append changes to last commit
git config --global alias.append 'commit --amend --no-edit'
# print current branch name
git config --global alias.current 'rev-parse --abbrev-ref HEAD'
# fetch develop and merge in current branch
git config --global alias.goodmorning '!git fetch origin ${1-develop} && git merge origin/${1-develop}'
# delete all local branches but nor [BranchName] (default is develop)
git config --global alias.current 'rev-parse --abbrev-ref HEAD'
# get current branch name
rev-parse --abbrev-ref HEAD
git branch | grep \* | cut -d ' ' -f2
const compose = (...fns) => x => fns.reduce((v, f) => f(v), x);
const all = xs => xs.reduce((acc, x) => ((!x) ? x : acc), true);
const any = xs => xs.reduce((acc, x) => (x || acc), false);
const not = x => !xs;
@christianwish
christianwish / xml.hs
Last active May 18, 2019 07:50
xml haskell
import System.Environment
import Data.List
type AttrName = String
type AttrVal = String
newtype TagName = TagName String deriving (Show)
data Attr = Attr AttrName AttrVal
listToStr :: (Show a) => [a] -> String
module Main where
import System.Environment
grey = "\x1b[2m"
noColor = "\x1b[0m"
replLine 0 = (grey ++ "> Hi!" ++ noColor)
replLine _ = (grey ++ ">" ++ noColor)