Skip to content

Instantly share code, notes, and snippets.

@julianshen
julianshen / merge.go
Created October 23, 2012 16:52
[Go] Concurrent merge sort
package main
import "fmt"
func Merge(ldata []int, rdata []int) (result []int) {
result = make([]int, len(ldata) + len(rdata))
lidx, ridx := 0, 0
for i:=0;i<cap(result);i++ {
switch {
@julianshen
julianshen / a.go
Created October 23, 2012 11:04
[Go] fibonacci with closure
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() uint64 {
var x, y, z uint64 = 0, 1, 0
return func() uint64 {
z, x, y = x, y, x+y
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="fb-root"></div>
<fb:login-button width="200" max-rows="1"
scope="user_likes, friends_likes, user_groups, friends_groups, read_stream, read_friendlists, user_activities, offline_access, publish_stream">
@julianshen
julianshen / render-in-iframe.html
Created March 5, 2012 17:50
render-in-iframe
<fb:login-button render-in-iframe="true" width="200" max-rows="1"
scope="user_likes, friends_likes, user_groups, friends_groups, read_stream, read_friendlists, user_activities, offline_access, publish_stream">
</fb:login-button>
@julianshen
julianshen / fbloginwithshowface.html
Created March 5, 2012 17:48
fbloginwithshowface
<fb:login-button show-faces="true" width="200" max-rows="1"
scope="user_likes, friends_likes, user_groups, friends_groups, read_stream, read_friendlists, user_activities, offline_access, publish_stream">
</fb:login-button>
@julianshen
julianshen / fbloginwithshowface.html
Created March 5, 2012 17:48
fbloginwithshowface
<fb:login-button show-faces="false" width="200" max-rows="1"
scope="user_likes, friends_likes, user_groups, friends_groups, read_stream, read_friendlists, user_activities, offline_access, publish_stream">
</fb:login-button>
@julianshen
julianshen / login.html
Created March 5, 2012 17:45
login.html
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div id="fb-root"></div>
<fb:login-button width="200" max-rows="1"
scope="user_likes, friends_likes, user_groups, friends_groups, read_stream, read_friendlists, user_activities, offline_access, publish_stream">
</fb:login-button>
import com.thrift.gen.*;
import org.apache.thrift.TException;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TTransportException;
var thrift = require('thrift');
var Computer = require('./gen-nodejs/Computer.js'),
ttypes = require('./gen-nodejs/computer_types.js');
var server = thrift.createServer(Computer, {
add: function(a, b, callback) {
console.log("function called:", a+b);
callback(a+b);
},
namespace java com.thrift.gen
service Computer {
i64 add(1: i64 a, 2: i64 b),
}