Skip to content

Instantly share code, notes, and snippets.

View ChristophP's full-sized avatar

ChristophP

View GitHub Profile
@ChristophP
ChristophP / .vimrc
Last active October 12, 2021 10:04
My .vimrc file
set nocompatible " Disable vi-compatibility
set nomodeline " good practice to disable because of security issues
set t_Co=256
" Disable safe write
set backupcopy=yes
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = "\<space>"
import Data.List.Split
import Text.Read
main :: IO ()
main = do
contents <- readFile "/home/deedo/Desktop/times.txt"
let line = getSecondLine $ splitOn "\n" contents
putStrLn $ prepareOutput $ calcDay <$> line
calcDay :: String -> Int
@ChristophP
ChristophP / SimpleJson.hs
Last active January 1, 2019 19:07
Haskell JSON
module SimpleJson
( JValue(..)
, put
) where
import Data.List (intercalate)
-- union type
data JValue
= JString String
@ChristophP
ChristophP / ElmParser.elm
Last active January 30, 2019 22:41
Trying to parse Elm's internal data stucture
module Main exposing (main)
import Char
import Html exposing (Html)
import Json.Encode as JE
import Parser exposing (..)
import Set
main : Html Never
@ChristophP
ChristophP / Highlight.elm
Last active March 10, 2019 13:33
Elm snippet to highlight text for when searching
module Highlight exposing (highlight, interweave)
type Html msg
= Mark (List (Html msg))
| Text String
mark _ children =
Mark children
@ChristophP
ChristophP / OccuranceCount.hs
Last active April 16, 2019 19:36
count occurance of words in a sentence
module OccuranceCount where
import Data.Foldable (foldl')
countWord :: String -> String -> Int
countWord needle =
foldl' (\acc word -> if word == needle then acc + 1 else acc) 0 . words
@ChristophP
ChristophP / git-bisect-example.sh
Last active May 5, 2019 19:21
git bisect example
# MANUAL RUN
git checkout <KNOWN_BAD_COMMIT>
git bisect start
git bisect bad
git bisect good <KNOWN_GOOD_COMMIT>
# cycle till done
git bisect log # to check what you've done so far
<test if good or bad>
git bisect bad|good
@ChristophP
ChristophP / new-pet-stack.sh
Last active February 5, 2022 07:32
Quickly scaffold a new app using the parcel bundler, Elm and TailwindCSS
#!/usr/bin/env sh
set -eu
# checking input
[ -z ${1:-} ] && echo "Missing directory name. Call this script with a directory name you want to create." && exit 1;
DIR=$1
[ -d $DIR ] && echo "Directory ${DIR} already exists. I need a fresh directory." && exit 1;
# scaffolding of dirs and files
@ChristophP
ChristophP / assume-role.sh
Created May 15, 2020 14:55
little shell script which can be sourced to act on behalf of an IAM role in AWS.
#!/usr/bin/env sh
# this script will modify your environment
# so that you can work in the context of an assumed role in AWS
set -u
if [ -z ${ASSUME_ROLE_ARN+x} ]
then
echo "NO ASSUME_ROLE_ARN variable configured in Environment.";
@ChristophP
ChristophP / stream-to-node-stdin.sh
Last active July 16, 2020 15:00
Streaming to an application in shell using output grouping
{ while :; do echo test; sleep 5; done } | node -e 'process.stdin.on("data", () => process.stdout.write("Peter"))'