This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type AsyncCell<T> = { value: T; next: Promise<AsyncCell<T>> }; | |
type AsyncStreamOutput<T> = () => AsyncGenerator<unknown, T, unknown>; | |
type AsyncStreamInput<T> = (value: T) => unknown; | |
const mkPromiseAndInput = <T>(): [Promise<T>, AsyncStreamInput<T>] => { | |
// streamInput is assigned before return because of Promise implementation | |
let streamInput!: AsyncStreamInput<T>; | |
const promise = new Promise<T>((resolve) => { | |
streamInput = resolve as AsyncStreamInput<T>; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
const logo = [ | |
"xxx x x xxx ### ### ### x x x x x x", | |
"x x x x x # # # # x x x x x xx xx", | |
"x xxx xxx # # ### # x xx x x x x x", | |
"x x x x x # # # # x x x x x x x", | |
"xxx x x x x ### ### # x x x xxx x x", | |
]; | |
const colors = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sleep = (t) => new Promise(resolve => setTimeout(resolve, t)); | |
// must be function & cannot be strict mode | |
function withContext(context, next) { | |
return next(); | |
} | |
const getContext = () => withContext.arguments[0]; | |
const logContext = (label) => function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function parse($input) { | |
$formats = array( | |
'/^\d{1,2}\.\d{1,2}\.\d{4}$/' => 'd.m.Y', | |
'/^\d{8}$/' => 'dmY' | |
); | |
foreach($formats as $pattern => $format) { | |
if(preg_match($pattern, $input)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Network( | |
defaultPort, Connection(..), send, recv, close, | |
Listening(..), stopListening, serve, connect, | |
serve', connect' | |
)where | |
{-| | |
This module handles opening/accepting connections on/to an interface/ip, | |
to send/receive Data.Binary | |
|-} | |
import Control.Monad |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const split = [ | |
{ | |
directives: [], | |
kind: "OperationDefinition", | |
name: { | |
kind: "Name", value: "t_magic", | |
}, | |
operation: "query", | |
selectionSet: { | |
kind: "SelectionSet", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Control.Monad | |
import Control.Monad.State as St | |
import Data.Set (Set) | |
import qualified Data.Set as S | |
import GHC.Word (Word8) | |
import Prelude hiding (Left, Right, last) | |
data Segment = Edge | Plain deriving (Show, Eq) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Tree where | |
{- | |
This is code for a Haskell module named `Tree`. | |
You're currently reading a comment block in it. | |
Below this comment we define a data type called `Tree`. | |
It has two constructors, named `Leaf` and `Branch`. | |
The `Leaf` constructor takes one argument, which must be of type `Int`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
fileStack = [] | |
with open('./printMe') as f: | |
files = f.read().split('\n') | |
for file in files: | |
if file == '': | |
continue | |
fileStack.append(file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
intern=eDP1 | |
extern=$(xrandr|grep " connected"|sed "s/ .*//g"|grep -v eDP1) | |
case $1 in | |
above) | |
xrandr --output $intern --auto --output $extern --auto --above $intern | |
;; | |
below) | |
xrandr --output $intern --auto --output $extern --auto --below $intern | |
;; |
NewerOlder