Skip to content

Instantly share code, notes, and snippets.

struct Solution
res::Union{Int64, Nothing}
end
function ex_div(a, b)::Solution
if b == 0
Solution(nothing)
else
Solution(Int64(a / b))
end
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
p#title {
font-size: 50px;
}
@mrkaspa
mrkaspa / functor.fs
Created May 10, 2018 19:53
Functors in fsharp
type SumFunctor<'T> = {
sumFn : 'T -> 'T -> 'T
diffFn : 'T -> 'T -> 'T
}
let createSumFunctor monoidOp negMonoidOp =
{
sumFn = monoidOp
diffFn = negMonoidOp
}
# set your user tokens as environment variables, such as ~/.secrets
# See the README for examples.
[color]
ui = true
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
package main
import (
"fmt"
"reflect"
)
type any = interface{}
func main() {
@mrkaspa
mrkaspa / def.json
Last active December 8, 2018 03:42
vscode config
{
// Place your settings in this file to overwrite the default settings
"editor.acceptSuggestionOnCommitCharacter": false,
"editor.fontSize": 20,
"editor.fontFamily": "Fira Code",
"editor.codeLens": false,
"editor.fontLigatures": true,
"workbench.editor.enablePreview": false,
"files.autoSave": "onFocusChange",
"window.restoreWindows": "all",
@mrkaspa
mrkaspa / youreason.sh
Created September 25, 2017 00:43
Parse ocaml files to reasonml
for f in *.ml; do x=$(basename "$f" ".ml"); refmt "$f" > "$x.re"; rm "$f"; done
@mrkaspa
mrkaspa / comp.fs
Created September 24, 2017 14:55
Fable interfacing with react components
type [<Pojo>] Props =
{ source: string } //other properties here
[<Import("default", "react-markdown")>]
type private ReactMarkdown (props) = inherit Component<Props, obj> (props)
//create using
let view _ _ =
let props = { source = "# This is a header\n\nAnd this is a paragraph" }
com<ReactMarkdown, _, _> props [] //props is Props
@mrkaspa
mrkaspa / modules.cr
Created September 13, 2017 16:20
Crystal module playing
module Ord(A)
abstract def cmp(a : A, b : A)
end
class IntOrd
include Ord(Int32)
def cmp(a, b)
a > b
end
@mrkaspa
mrkaspa / keybindings.json
Last active September 21, 2017 03:14
vscode
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "cmd+1",
"command": "type",
"args": {
"text": "|>"
},
"when": "editorTextFocus"
},