Skip to content

Instantly share code, notes, and snippets.

@paulogaspar7
paulogaspar7 / pubsub-demo.js
Created February 25, 2012 18:11 — forked from cowboy/pubsub-demo.js
Two approaches: "Traditional" vs Pub/Sub (via rmurphey)
// Note that this uses my Pub/Sub implementation, which is slightly different than
// phiggins' in that jQuery custom events are used, and as such the first event handler
// argument passed is the event object.
//
// jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery
// https://gist.github.com/661855
// The "traditional" way.
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {
@paulogaspar7
paulogaspar7 / rhino_dust.java
Created March 4, 2012 00:44 — forked from vybs/rhino_dust.java
Sample code to rendering dust template using Rhino
package com.linkedin.dust.renderer;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Writer;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.JavaScriptException;
@paulogaspar7
paulogaspar7 / rhino_dust.java
Created March 4, 2012 02:28 — forked from vybs/rhino_dust.java
Sample code to rendering dust template using Rhino
package com.linkedin.dust.renderer;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.Writer;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.JavaScriptException;

#MVVM For JavaScript Developers

MVVM (Model View ViewModel) is an architectural pattern based on MVC and MVP, which attempts to more clearly separate the development of user-interfaces (UI) from that of the business logic and behaviour in an application. To this end, many implementations of this pattern make use of declarative data bindings to allow a separation of work on Views from other layers.

This facilitates UI and development work occurring almost simultaneously within the same codebase. UI developers write bindings to the ViewModel within their document markup (HTML), where the Model and ViewModel are maintained by developers working on the logic for the application.

##History

@paulogaspar7
paulogaspar7 / MethodParamNamesScaner.java
Created June 5, 2012 17:15 — forked from wendal/MethodParamNamesScaner.java
获得方法形参名称列表(Java)
package org.nutz.lang.util;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
@paulogaspar7
paulogaspar7 / latency.txt
Created June 15, 2012 12:17 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
@paulogaspar7
paulogaspar7 / Bootstrap homeshick
Created June 16, 2012 17:45 — forked from andsens/bootstrap_homeshick.sh
Script that can set up an entire user account with homeshick automatically
#!/bin/bash -ex
# Paste this into ssh
# curl -sL https://gist.github.com/gists/2913223/download | tar -xzO | /bin/bash -ex
# When forking, you can get the URL from the download button.
pushd $HOME
apt-get update
apt-get install sudo
@paulogaspar7
paulogaspar7 / www.rb
Created August 30, 2012 14:40 — forked from pda/www.rb
www: Serve the current directory via HTTP.
#!/usr/bin/env ruby
# Serve the current directory via HTTP.
# Like Python's SimpleHTTPServer, but with no-cache headers.
# Default port 8000, specify alternate port as first parameter:
# www 3000
# sudo www 80 # (probably a bad idea)
# Inspired by http://chrismdp.github.com/2011/12/cache-busting-ruby-http-server/
@AtmosphereHandlerService(path="/chat",
interceptors = {AtmosphereResourceLifecycleInterceptor.class, BroadcastOnPostAtmosphereInterceptor.class})
public class ChatAtmosphereHandler extends OnMessage<Data> {
private final ObjectMapper mapper = new ObjectMapper();
@Override
public void onMessage(AtmosphereResponse response, Data message) throws IOException {
response.getWriter().write(mapper.writeValueAsString(data));
}