Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am fcarriedo on github.
  • I am fcarriedo (https://keybase.io/fcarriedo) on keybase.
  • I have a public key ASBklMjeK0rC1A1be5sKj_7_METS6OdNPip_Ry9qQF79hQo

To claim this, I am signing this object:

[[112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101], [216, 215, 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201], [313, 312, 311, 310, 309, 308, 307, 306, 305, 304, 303, 302, 301], [415, 414, 413, 412, 411, 410, 409, 408, 407, 406, 405, 404, 403, 402, 401], [513, 512, 511, 510, 509, 508, 507, 506, 505, 504, 503, 502, 501], [612, 611, 610, 609, 608, 607, 606, 605, 604, 603, 602, 601], [709, 708, 707, 706, 705, 704, 703, 702, 701]]}

@fcarriedo
fcarriedo / data-tmpl.html
Last active December 18, 2015 09:29
HTML5 Server sent events demo implementation
<div class="msg">
<h3>Msg</h3>
<p>This is the message: </p>
<p><i>{{.}}</i></p>
</div>
@fcarriedo
fcarriedo / build-lib.xml
Created September 15, 2012 17:46
Basic ant files for web and lib projects
<?xml version="1.0" encoding="UTF-8"?>
<!--
Created: March 23 2010
Comments:
A very basic ant file for lib projects.
-->
<project name="Estation Prototype" basedir="." default="jar">
@fcarriedo
fcarriedo / NCube conn protocol spec.md
Created August 23, 2012 21:46
Technovision/ZoomSystems comms spec.

NCube's and ZoomShop communication specification

In a 20 thousand feet view, two persistent communication channels* will be maintained, one for commands generally coming from the ZoomShop (client) to the NCube (server) for dispensing, inventory requests, etc. in an RPC style and another one for events (in fire-and-forget style) which flow is to be started from the NCube (server) to the ZoomShop (client).

Having persistent connections benefits both parties as both can immediately detect when a connection was broken and take the appropriate measures.

On a related note, but not relevant to this document, both commands and events messages (see NCube Protocol Format > Messages) are to be serialized as XML documents.

*Note: Within this document, the term stream, socket connection and channel are treated as synonyms.

@fcarriedo
fcarriedo / throttle-debounce.js
Last active October 5, 2015 21:57
Throttle function
/**
* Returns a functions that ensures that only one call
* executes every given milliseconds.
*/
function throttle(funct, time) {
var active = false;
return function() {
if(!active) {
active = true;
funct.apply(this, arguments);
@fcarriedo
fcarriedo / DB.java
Created May 17, 2012 03:15
InMemory - minimal DB
import java.util.List;
import java.util.ArrayList;
/**
* Temporal DB class.
*
* @author Francisco.Carriedo
* May 16, 2012
*/
public class DB {
@fcarriedo
fcarriedo / ZipUtil.java
Created February 13, 2012 08:47
Java Zip util with option to exclude containing folder
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class ZipUtil {
private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
@fcarriedo
fcarriedo / DemoServer.java
Created September 6, 2011 21:20
Minimal jdk1.6 java http server. Sun's Internal.
import com.sun.net.httpserver.*;
import java.net.*;
import java.io.*;
import java.util.*;
public class DemoServer {
public static void main(String[] args) throws Exception {
final int port = 8000;
HttpServer server = HttpServer.create( new InetSocketAddress("localhost", port), 10);
server.createContext("/stats", new MyHandler());
@fcarriedo
fcarriedo / Demo.scala
Created November 8, 2010 03:43
basic scala hello world..!
object HelloWorld {
def main(args: Array[String]) {
println("Hello world")
}
}