Skip to content

Instantly share code, notes, and snippets.

View everson's full-sized avatar

Johnny Everson everson

View GitHub Profile
@everson
everson / keybase.md
Created March 29, 2017 18:42
keybase.md

Keybase proof

I hereby claim:

  • I am everson on github.
  • I am everson (https://keybase.io/everson) on keybase.
  • I have a public key ASAsYPxrdc6JJE63Cbr0LQG_8jNZ77yj68vhdOKTd_1n9go

To claim this, I am signing this object:

@everson
everson / hello.elm
Created August 19, 2015 04:24
First Elm Attempt
import Html exposing (text)
import Mouse exposing (position)
main = (map text position)
#!/bin/sh
exec scala "$0" "$@"
!#
/*
* Copyright (c) 2011-15 Miles Sabin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@everson
everson / 0_reuse_code.js
Last active August 29, 2015 14:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@everson
everson / inserts.scala
Created February 17, 2015 17:51
Monadic Either
type Id = Int
def insertA():Either[Exception, Id] = {println("running A"); Right(1)}
def insertB(a: Id):Either[Exception, Id] = {println("running B with " + a); Left(new Exception("Oops"))}
def insertC(b: Id):Either[Exception, Id] = {println("running C with " + b); Right(3)}
for {
a <- insertA().right
b <- insertB(a).right
c <- insertC(b).right
@everson
everson / CoolStuff.scala
Last active August 29, 2015 14:13
scalaz.Tag
import scalaz._
import Scalaz._
val isThisCool: Boolean @@ CoolStuff = Tag(true)
def requiresCoolStuff(in: Boolean @@ CoolStuff) = in
// type checks
requiresCoolStuff(isThisCool)
@everson
everson / BlackBox.scala
Last active August 29, 2015 14:11
Sample scala-js-fiddle usage.
object BlackBox {
def value = "Some content"
}
@everson
everson / Array.ts
Last active August 29, 2015 14:03
Option<T> type for typescript. Just experimenting.
interface Array<T> {
flatMap <U>( fn: (a:any) => Maybe<U>): Array<U>;
// currently limited because I cannot write Array<T extends Maybe<Z>> and have flatten return Array<Z>
flatten (): Array<any>;
}
// the runtime
Array.prototype.flatMap =
function <U>(fn: (a:any) => Maybe<U>):Array<U> {
var res:Array<U> = [];
@everson
everson / map.js
Created July 17, 2012 06:21
Adding map operation to javascript Array
// returns a new array where every object is the result of the passed function applied to corresponding element in the original array
Array.prototype.map = function(fn){
var nArr=[];
for(i=0; i<this.length; i++){
nArr[i] = fn(this[i])
};
return nArr
}
// to use it, define a function taking one argument and processing it:
@everson
everson / CardsSnippet.scala
Created June 17, 2012 02:37
Embed and render order in Lift
".playerDeckCard" #> cards.map ( card =>
".card [data-keyname]" #> card.keyname.is &
".card [data-cardname]" #> card.name.is &
...
)