Skip to content

Instantly share code, notes, and snippets.

@vendethiel
vendethiel / scheme.sjs
Last active January 2, 2016 01:29 — forked from disnet/scheme.sjs
scheme.sjs (forked from https://gist.github.com/disnet/3854258)
macro sexp {
rule {()} => {
;
}
rule {($p)} => {
$p
}
rule {($x $y)} => {
$x($y);
}
@vendethiel
vendethiel / do.sjs
Last active January 2, 2016 01:29 — forked from puffnfresh/do.sjs
do.sjs fixed for new sweet.js
macro $do {
rule { { $y:expr } } => {
$y
}
rule { { $x:ident <- $y:expr $rest ... } } => {
λ['>=']($y, function($x) {
return $do { $rest ... }
});
}
}
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)
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
(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})
class @MediaItemsAPI
constructor: (options = {}) ->
console.log this.options
# this.options = _.extend this.options, options
if not this.key? and not this.options.key?
Meteor.Erros.throw "No API key has been set. Please set and API key and try again."
@key = options.key
@services = options.services
@extensions = options.extensions
@vendethiel
vendethiel / es6-map.js
Last active July 10, 2024 15:12 — forked from heath/es6-map.js
Map in different languages
[1,2,3].map((n)=> n*2)
@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()
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.', !->