Skip to content

Instantly share code, notes, and snippets.

@mrkaspa
mrkaspa / build.bash
Created October 10, 2016 15:49
Golang build for different platforms
#!/usr/bin/env bash
set -ex
# This script builds archiver for most common platforms.
export CGO_ENABLED=0
cd cmd/archiver
GOOS=linux GOARCH=386 go build -o ../../builds/archiver_linux_386
GOOS=linux GOARCH=amd64 go build -o ../../builds/archiver_linux_amd64
struct Solution
res::Union{Int64, Nothing}
end
function ex_div(a, b)::Solution
if b == 0
Solution(nothing)
else
Solution(Int64(a / b))
end
@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",
<!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
}
@mrkaspa
mrkaspa / ycombinator.js
Created May 27, 2015 20:48
Y Combinator JS and Recursive Calls
var trampoline = function (f) {
while (f && f instanceof Function) {
f = f.apply(f.context, f.args);
}
return f;
}
var thunk = function (fn) {
return function () {
var args = Array.prototype.slice.apply(arguments);
# 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 / 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