Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/osascript
-- Launche multiple SSH session
-- completely rewritten but inspired by github:xgdlm/iterm2-cssh
on run argv
set serverList to argv
-- Print help if no servers are given
@paulogaspar7
paulogaspar7 / createObject.js
Created October 29, 2012 00:51 — forked from mxriverlynn/createObject.js
An Object.create wrapper / shim for MarionetteJS
// Helpers
// -------
// For slicing `arguments` in functions
var slice = Array.prototype.slice;
// Borrow the Backbone `extend` method so we can use it as needed
Marionette.extend = Backbone.Model.extend;
// A wrapper / shim for `Object.create`. Uses native `Object.create`
@paulogaspar7
paulogaspar7 / tabs.js
Created October 24, 2012 23:30 — forked from malihu/tabs.js
Fully commented code for the tabs.js script
(function($){
$.fn.Tabs=function(speed){ /* tabs transition speed parameter */
return this.each(function(){
/* define/cache variables */
var tabs=$(this),
tabsLabels=tabs.children("ul"),
tabLabel=tabsLabels.find("a"),
tabsContent=tabs.children("div"),
tabLink,
tabsLoader=tabsContent.children(".ajax-loader"); /* define ajax loader element */
@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));
}
@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/
@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 / 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 / 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;

#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 / 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;