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 / 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 &
...
)
@everson
everson / ShellSupport.scala
Created May 23, 2012 21:37
How to create DSL in Scala for command lines with minimum boilerplate
package lib
import sys.process.{Process, stringToProcess}
class Shell {
var elems = Vector[String]()
var cwd = "/tmp"
def >(str: String) = elems :+= str
def run() = elems.map( cmd => {
@everson
everson / ChatIn.scala
Created December 12, 2011 17:46
Multi-room Chat server / client with Lift
package myproject
package snippet
import net.liftweb._
import common.Logger
import http._
import js._
import JsCmds._
import JE._
@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)