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 scala.io.StdIn | |
// Result[+T] is a Monoid with bind as the join fn | |
sealed trait Result[+T] { | |
// makes this a Functor | |
def map[U](f: T => U): Result[U] | |
// bind hence a Monad | |
def flatMap[U](f: T => Result[U]): Result[U] | |
} |
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 json | |
import sqlite3 | |
import sys | |
from bcoding import bencode, bdecode | |
def read(): | |
return dict(bdecode(sys.stdin.buffer)) |
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 scala.io.StdIn | |
// Result[+T] is a Monoid with flatMap as the join fn | |
enum Result[+T] { | |
case Success(value: T) | |
case Failure(exception: Throwable) | |
// bind hence a Monad | |
def flatMap[U](f: T => Result[U]) = | |
this match { |
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
(require '[clojure.java.io :as io] | |
'[clojure.string :as s]) | |
(defn line->cmd | |
[line] | |
^String | |
(some->> (s/index-of line \;) | |
inc | |
(subs line))) |
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/env bash | |
set -eo pipefail | |
changed=$(git status --porcelain) | |
is_github_repo=$(git config --get remote.origin.url; echo $?) | |
declare -A github_users | |
github_users=( | |
["rd"]="Rahul De <[email protected]>" |
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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"strconv" | |
) | |
type Result interface { |
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
; JSON Schema | |
; { | |
; "definitions": { | |
; "fact": { | |
; "type": "object", | |
; "properties": { | |
; "question": { "type": "string" }, | |
; "guess": { "type": "string" }, | |
; "no": { "$ref": "#/definitions/fact" }, | |
; "wrongGuess": { "$ref": "#/definitions/fact" } |
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 java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
import java.util.function.Function; | |
interface Result<T> { | |
<R> Result<R> then(Function<T, Result<R>> nextFn); | |
} | |
record Success<T>(T value) implements Result<T> { | |
@Override |
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/env bb | |
(require '[babashka.process :as p] | |
'[clojure.string :as str]) | |
(def authors | |
{"rd" {:name "Rahul De" | |
:email "[email protected]"}}) | |
(defn exec |
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
(require '[babashka.deps :as deps]) | |
(deps/add-deps '{:deps {org.babashka/http-client {:mvn/version "0.0.2"}}}) | |
(require '[babashka.http-client :as http] | |
'[cheshire.core :as json]) | |
(import '[java.net URL]) | |
(defn get-projects |