Skip to content

Instantly share code, notes, and snippets.

payment_frequency:
control:
creator: window.FormHelper.createInput
type: 'hidden'
serializer: (val, $root) ->
freq = $root.find('[name=income_frequency]').find(':selected').val()
if freq == 'Weekly' then 'Bi-weekly' else freq
@laser
laser / haste-boot.txt
Created April 24, 2014 17:11
haste-boot
[foo]$ haste-boot
Downloading base libs from GitHub
Sending:
GET /haste-libs/haste-libs-0.2.99.tar.bz2 HTTP/1.1
Host: valderman.github.io
Creating new connection to valderman.github.io
Received:
HTTP/1.1 200 OK
@laser
laser / rpc_batch_error.js
Created April 21, 2014 22:36
RPC Batch Errors
// Errors from Batch Request (Barrister)
initApp(function(err, TodoManager, BatchTodoManager) {
TodoManager.readTodos(function(err, todos) {
for (var i = 0, len = todos.length; i < len; i++) {
BatchTodoManager.deleteTodo(todos[i]['id']);
}
BatchTodoManager.send(function(err, results) {
var result, i, len;
@laser
laser / batch_rpc.js
Last active August 29, 2015 14:00
Batching createTodo Calls on Client
// Initializing API Client (Barrister)
function initApp(callback) {
var client = Barrister.httpClient({
'endpoint': '/todos',
'interfaces': ['TodoManager']
});
client.loadContract(function() {
var batch, proxy;
@laser
laser / rpc_error.js
Created April 21, 2014 22:31
Receiving Error Code on Client
// Receiving Error Code on Client
var lastTodoId = 45;
$('#todos li').click(function(e) {
var $tgt = $(e.target), todoId = $tgt.prop('id');
TodoManager.deleteTodo(todoId, function(err) {
if (err.code === 1004) {
alert(err.message);
@laser
laser / todo_manager.js
Created April 21, 2014 22:31
TodoManager raising an error
// Changing TodoManager Implementation
server.addHandler('TodoManager', {
'readTodos': function(callback) {
callback(null, store.getAll());
},
'createTodo': function(props, callback) {
callback(null, store.save(props));
},
'updateTodo': function(id, props, callback) {
@laser
laser / documeting_error_code.idl
Created April 21, 2014 22:29
Barrister IDL w/error code
interface TodoManager {
// returns all Todos
readTodos() []Todo
// creates new Todo and returns it with an id
createTodo(todo TodoProperties) Todo
// updates Todo and returns it
updateTodo(todo Todo) Todo
@laser
laser / jquery_rpc_client.js
Created April 21, 2014 22:24
jquery RPC client
// Barrister Client Initialization
function initApp(callback) {
var client = Barrister.httpClient({
'endpoint': '/todos',
'interfaces': ['TodoManager']
});
client.loadContract(function() {
var proxy = client.proxy('TodoManager');
@laser
laser / server_rpc.js
Created April 21, 2014 22:22
Barrister RPC + Express
// Server: Barrister RPC + Express
var express = require('express')
, fs = require('fs')
, http = require('http')
, path = require('path')
, barrister = require('barrister')
, store = require("./store").store
, idl = JSON.parse(fs.readFileSync("./todo_manager.json").toString());
@laser
laser / todo_manager.idl
Created April 21, 2014 22:19
todo manager IDL
// todo_manager.idl
struct TodoProperties {
title string
completed bool
}
struct Todo extends TodoProperties {
id int [optional]
}