Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View slaskis's full-sized avatar
🤓

Robert Sköld slaskis

🤓
View GitHub Profile
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "JSON API Schema",
"description": "This is a schema for responses in the JSON API format. For more, see http://jsonapi.org",
"oneOf": [
{
"$ref": "#/definitions/success"
},
{
"$ref": "#/definitions/failure"
var Emitter = require('emitter');
var slice = [].slice;
module.exports = QueueEmitter;
function QueueEmitter(){
if( !(this instanceof QueueEmitter) ){
return new QueueEmitter();
}
this.queued = {};
@slaskis
slaskis / AVector.hx
Created February 15, 2014 15:38
A quick test with abstract types in haxe. This is really cool
abstract AVector(Array<Float>) {
public var x(get, never):Float;
public var y(get, never):Float;
public var z(get, never):Float;
public var length(get, never):Float;
public var lengthSq(get, never):Float;
public inline function new(x:Float, y:Float, z:Float=0.) this = [x, y, z];
@:op(A+B) public static inline function add(a : AVector, b : AVector) : AVector {
return new AVector(a.x+b.x,a.y+b.y,a.z+b.z);
@slaskis
slaskis / dc1.html
Last active December 11, 2015 04:39
Data Channel Examples
<!DOCTYPE html>
<html>
<head>
<title>Data Channel Demo 1</title>
<style>
button {
font: 18px sans-serif;
padding: 8px;
}
textarea {
(function() {
var
// Configuration:
hostname = window.CHANNEL_HOST || window.location.hostname || 'localhost',
websocketServer = "ws://"+hostname+":8000/",
// For browser compatibility:
PeerConnection = window.PeerConnection
|| window.RTCPeerConnection
package main
import (
"fmt"
"net/http"
"code.google.com/p/go.net/websocket"
"strings"
"time"
)
@slaskis
slaskis / test.redis-multi.js
Created September 19, 2012 18:36
A test for node_redis that shows some inconsistencies.
var redis = require('redis')
, client = redis.createClient()
, assert = require('assert');
// redis.debug_mode = true;
client.on("error", function (err) {
console.log("Error " + err);
});
@slaskis
slaskis / test-inheritence.js
Created February 8, 2012 09:17
Inherit some sweet sweet locals plz
var express = require('express');
function middleware(req,res,next){
// do real funky stuff here...
// add access to funky stuff in routes
req.funky = function(){return 'funky stuff'}
// add access to funky stuff in views
res.locals.funky = function(){return 'funky stuff'}
diff --git a/lib/parser.js b/lib/parser.js
index ca6fe8d..9673efe 100644
--- a/lib/parser.js
+++ b/lib/parser.js
@@ -387,7 +387,7 @@ Parser.prototype = {
if (!this.filename)
throw new Error('the "filename" option is required to extend templates');
- var path = name = this.expect('extends').val.trim()
+ var path = this.expect('extends').val.trim()
function (doc){
var object = {'resource':'Post'};
var match = function(){
for( var k in object )
if( object[k] !== doc[k] )
return false;
return true;
};
if( doc.resource === 'Post' && match() ){
emit(doc._id, doc);