Skip to content

Instantly share code, notes, and snippets.

View Yoric's full-sized avatar

David Teller Yoric

View GitHub Profile
@Yoric
Yoric / gist:985817
Created May 22, 2011 19:57
Hello, web in Opa
server = one_page_server("Hello", -> <>Hello, web!</>)
@Yoric
Yoric / gist:985820
Created May 22, 2011 19:58
Hello, web in Opa (second version)
server = Server.simple_dispatch(_ ->
html("Hello", <>Hello, web!</>)
)
@Yoric
Yoric / wiki.js
Created May 26, 2011 13:50
wiki.opajs
/**
* {1 Database and database interaction}
*/
/**
* Contents of the wiki.
*
* Pages which do not exist have content "This page is empty".
* Note: By definition, pages stored in the database are always well-formed.
*/
@Yoric
Yoric / chat.js
Created May 26, 2011 13:51
chat.opajs
/**
* {1 Network infrastructure}
*/
/**
* The type of messages sent by a client to the chatroom
*/
type message = {author: string /**Arbitrary, untrusted, name*/
,text: string} /**Content entered by the user*/
@Yoric
Yoric / storage.js
Created May 26, 2011 13:51
storage.opajs
/**
* Add a path called [/storage] to the schema of our graph database.
*
* This path is is a dictionary indexed by [string]s of values
* of type [option(string)], i.e. values that may either be
* a string or omitted. To find out whether the value is present,
* one should use pattern-matching - case [{some: ...}] if the
* value is present, [{none}] if the value is omitted.
*
* Note: db is a keyword.
@Yoric
Yoric / wiki.opapy
Created May 26, 2011 14:37
wiki.opapy
##
# {1 Database and database interaction}
#
##
# Contents of the wiki.
#
# Pages which do not exist have content "This page is empty".
# Note: By definition, pages stored in the database are always well-formed.
#
@Yoric
Yoric / chat.boo
Created May 26, 2011 14:38
chat.opapy
/**
*{1 Network infrastructure}
*/
/**
*The type of messages sent by a client to the chatroom
*/
type message:
author as string //Arbitrary, untrusted, name
text as string //Content entered by the user
@Yoric
Yoric / storage.py
Created May 26, 2011 14:38
storage.opapy
/**
* Add a path called [/storage] to the schema of our graph database.
*
* This path is is a dictionary indexed by [string]s of values
* of type [option(string)], i.e. values that may either be
* a string or omitted. To find out whether the value is present,
* one should use pattern-matching - case [{some = ...}] if the
* value is present, [{none}] if the value is omitted.
*
* Note: db is a keyword.
@Yoric
Yoric / hello_web.js
Created May 27, 2011 10:37
Hello, web in Opa (revised syntax)
/**
* The function defining our user interface.
*/
start() {
<>Hello, web!</>; //HTML-like content. As the last value of the function, this is the result.
}
/**
* Create and start a server delivering user interface [start]
@Yoric
Yoric / hello_web2.js
Created May 27, 2011 10:52
Hello, web in Opa (revised syntax, one-liner)
start_server(one_page_server("Hello", -> <>Hello, web!</>));