Skip to content

Instantly share code, notes, and snippets.

View jerguslejko's full-sized avatar
🍊
Busy enjoying life.

Jerguš Lejko jerguslejko

🍊
Busy enjoying life.
View GitHub Profile
const puppeteer = require('puppeteer');
const askQuestions = require('ask-questions');
const { format, addDays } = require('date-fns');
(async () => {
const answers = await questionnaire({
invoiceNo: ['Invoice number', format(new Date(), 'YYYYMM001')],
createdAt: ['Created at', format(new Date(), 'DD/MM/YYYY')],
dueAt: ['Due at', format(addDays(new Date(), 14), 'DD/MM/YYYY')],
hours: ['Hours'],
@jerguslejko
jerguslejko / stack.ts
Created October 14, 2019 21:38
Type-safe stack in Typescript
type Z = { __Z: true }
type S<k extends Nat> = { __S: k }
type Nat = Z | S<any>;
type Incr<k extends Nat> = S<k>
type Decr<k extends Nat> = k extends Z ? void : k extends S<infer j> ? j : void
const zero: Z = { __Z: true }
function incr<k extends Nat>(x: k): Incr<k> {
USERNAME=""
PASSWORD=""
if [[ -z $1 ]]; then
echo "[error] spongebob text" && exit
fi
request() {
text=$1
length=$(echo $text | wc -c)
set -g base-index 1
set-window-option -g mode-keys vi
bind r new-session \;\
run-shell "tmux list-sessions | grep -v attached | awk -F: '{print $1}' | xargs -n 1 tmux kill-session -t" \;\
run-shell 'USER=root make kill-qemu > /dev/null || true' \;\
run-shell 'USER=root make kill-gdb > /dev/null || true' \;\
run-shell 'USER=root make kill-console > /dev/null || true' \;\
if-shell 'tmux select-window -t gdb' 'kill-window -t gdb' '' \;\

"Safe PHP" research

PHP type checker which uses native and phpDocumentor (extended) types. When types are present, the code is still valid PHP.

Usage

$ safe-php script.php
import Text.Yoda
import Prelude hiding (Num)
main :: IO ()
main = return ()
class Pretty a where
pretty :: a -> String
check :: (Eq a, Pretty a) => Parser a -> String -> Bool