This file contains hidden or 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
| macro $do { | |
| rule { { $y:expr } } => { | |
| $y | |
| } | |
| rule { { $x:ident <- $y:expr $rest ... } } => { | |
| λ['>=']($y, function($x) { | |
| return $do { $rest ... } | |
| }); | |
| } | |
| } |
This file contains hidden or 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
| package org.photon.login | |
| import com.twitter.util.Future | |
| import org.photon.common.Async | |
| import java.sql.{PreparedStatement, Timestamp, ResultSet} | |
| import org.joda.time.Instant | |
| trait RepositoryComponentImpl[T, RepoT] { | |
| implicit def timestamp2instant(t: java.sql.Timestamp) = new Instant(t.getTime) | |
| implicit def instant2timestamp(i: org.joda.time.Instant) = new Timestamp(i.getMillis) |
This file contains hidden or 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
| type Transaction = mutable.Builder[Any, _] | |
| def transaction[R](fn: Transaction => R): Future[NetworkSession] = { | |
| val builder = List.newBuilder[Any] | |
| fn(builder) | |
| @tailrec | |
| def rec(fut: Future[NetworkSession], buf: List[Any]): Future[NetworkSession] = buf match { | |
| case head :: tail => rec(fut flatMap {_.write(head)}, tail) | |
| case Nil => fut |
This file contains hidden or 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
| (use '[clojure.core.match :only [match]]) | |
| (defn evaluate [env [sym x y]] | |
| (match [sym] | |
| ['Number] x | |
| ['Add] (+ (evaluate env x) (evaluate env y)) | |
| ['Multiply] (* (evaluate env x) (evaluate env y)) | |
| ['Variable] (env x))) | |
| (def environment {"a" 3, "b" 4, "c" 5}) |
This file contains hidden or 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
| [1,2,3].map((n)=> n*2) |
This file contains hidden or 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
| @Demo.module "Entities", (Entities, App, Backbone, Marionette, $, _) -> | |
| App.reqres.setHandler "users:entities", -> | |
| promise = $.Deferred() | |
| App.request("socket:get:users").then | |
| (value) -> promise.resolve(value) | |
| promise.promise() |
This file contains hidden or 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
| require 'shelljs/global' | |
| require! <[gaze charm]> | |
| charm = charm! | |
| charm.pipe process.stdout | |
| task 'build' 'Compile *.moon files to lib/*.lua' !-> | |
| charm.write (exec 'moonc -t lib *.moon' {+silent}).output | |
| task 'test' 'Run unit tests with busted.', !-> |
This file contains hidden or 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 AjaxDateUpdater | |
| constructor: (@id, @url) -> | |
| $(@id).hover @hover_in, @hover_out | |
| @old = "" | |
| @has_focus = false | |
| hover_in: (ev) => | |
| return if @has_focus | |
| $el = $ ev.target |
This file contains hidden or 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
| /** | |
| * Conway's Game of Life, in LiveScript | |
| * ==================================== | |
| * | |
| * Conway's Game of Life is a cellular automaton, published by John H Conway | |
| * in 1970, fulfilling the design principles but greatly simplifying the | |
| * research of von Neumann, into a hypothetical machine that could build | |
| * copies of itself. It is a zero-player game, meaning there is no input, and | |
| * the game will progress on its own with a 'seed', or configuration, to | |
| * begin with. |