class User < Crecto::Model
schema "users" do
field :name, String
end
end
user = User.init_with(name: "hello") # doesn't fail
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
function add2(a: number, b: number) { | |
return a + b; | |
} | |
function add4(a: number, b: number, c: number, d: number) { | |
return a + b + c + d; | |
} | |
function concat(a: string, b: string) { | |
return (a + b).length; |
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
class Lens<RootObject extends object, ChangableObject> { | |
getter: (x: RootObject) => ChangableObject; | |
setter: (x: RootObject, newValue: ChangableObject) => RootObject; | |
static simple<RootObject extends object, T extends keyof RootObject>( | |
name: T | |
) { | |
return new Lens<RootObject, RootObject[T]>( | |
x => x[name], | |
(x, v) => ({ ...x, [name]: v }) |
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
record Ok(O), result : O | |
record Err(E), error : E | |
## hopefully it could have been | |
# alias Result(O, E) = Ok(O) | Error(E) | |
## but it can't | |
def mytest(i) | |
if i < 0 | |
Ok.new(i) |
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
let pi = 4.0 *. atan(1.0); | |
type t = | |
| Radians(float) | |
| Degrees(float); | |
let toRadians = d => | |
switch (d) { | |
| Radians(d) => Radians(d) | |
| Degrees(d) => Radians(d *. pi /. 180.) |
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
opaque type bcrypt$hashed = string; | |
declare module "bcrypt" { | |
declare module.exports: { | |
hash: (password: string, saltRounds: number) => Promise<bcrypt$hashed>, | |
compare: ( | |
password: string, | |
hashedPassword: bcrypt$hashed | |
) => Promise<boolean>, | |
}; |
I hereby claim:
- I am schniz on github.
- I am schniz (https://keybase.io/schniz) on keybase.
- I have a public key ASAoK6wufz1Xfrm7AFF4Sbb1_pj9uagkBzRY1crIXWYI3go
To claim this, I am signing this object:
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
#!/bin/bash | |
# | |
# Install `jq` by `brew install jq` | |
# Make sure to have ~/dotfiles/bitbar/.env with the following env vars: | |
# JIRA_USERNAME=... | |
# JIRA_PASSWORD=... | |
# JIRA_BASE_URL=https://something.atlassian.net | |
# |
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 python | |
def curry(fn): | |
arg_count = fn.func_code.co_argcount | |
def start(*initial_args): | |
args = [] | |
args.extend(initial_args) | |
def inner(*more_args): |
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 React from "react"; | |
export default class GetCurrentLocation extends React.Component { | |
state = {}; | |
watchId = null; | |
componentDidMount() { | |
const options = { | |
enableHighAccuracy: true, | |
timeout: 200, |