Skip to content

Instantly share code, notes, and snippets.

View xaviervia's full-sized avatar

Fernando Via Canel xaviervia

View GitHub Profile
@xaviervia
xaviervia / .gitignore
Last active August 29, 2015 13:56
spacegit
node_modules/*
@xaviervia
xaviervia / simplification.md
Last active August 29, 2015 13:56
Pika: Simplification

Simplification

Delegation

Delegation can be accounted for by making the delegate references into caller references, and adding an indirection to the call of the delegated actualization so that the caller now matches the intended delegate.

For example

With delegate

<jstp bind="message/*@localhost:.post">
<p><strong>{{message.author}}</strong> <span>{{message.text}}</span></p>
</jstp>
<p>There are <jstp bind="humanity/total@statistics.com:.put"></jstp> humans on Earth, and counting</p>

You have a file named "greet.js" with the following code:

module.exports = function (name) {
  console.log("Hi " + name);
}

Then you run:

@xaviervia
xaviervia / built-in-ed.md
Last active August 29, 2015 14:03
Built-in asynchronous, event driven messaging to Descriptions. So cool

Just a quick example

action: {
  argument: ø
  print(argument)
  result: +(argument, argument)
}

action: {
@xaviervia
xaviervia / index.js
Last active August 29, 2015 14:04
Playing with mathjs Matrices
// sudo npm install -g washington
// npm install mathjs
// washington index
var math = require("mathjs")
math.type.Matrix.prototype.toString = function () {
var string = " ┌ "
for (var i = 0; i < this.size()[1]; i ++)
string += " "
string += "┐"
this.forEach((function (value, index) {
@xaviervia
xaviervia / self-memoizing.js
Created September 3, 2014 16:52
Self memoizing JavaScript function
// Naming an otherwise anonymous function creates the named reference inside the
// function's scope. We use `cache` as the internal name
var selfMemoizing = function cache(input) {
// Let's prepare a cache object called "memoize" if not available
cache.memoized = cache.memoized || {}
// Return the cached result if available
if (cache.memoized[input]) return cache.memoized[input]
var wildcardProperty = (function (match) {
return function (value) {
return {
value: value,
match: match
}
}
})(function (object) {
for (key in object) if (object[key] === this.value) return true
@xaviervia
xaviervia / generalizing-endpoints.md
Last active August 29, 2015 14:18
Generalizing Endpoints

Generalizing Endpoints

It is quite easy to describe an HTTP API:

GET /users/:id

An HTTP verb and a pattern of the path it’s all that is required. We call that conjunction an endpoint. Although the name is older than REST, and was in use for XML-RPC and SOAP web services, REST has clearly brought it to the mainstream.

@xaviervia
xaviervia / JSTP_URI.txt
Created July 5, 2015 17:26
JSTP URI "ABNF" (not proper, of course)
jstp:GET//localhost:80//google.com:8080/books,timestamp:<number>
jstp:GET
jstp:POST
jstp:PUT
jstp:PATCH
jstp:DELETE
jstp:BIND