Skip to content

Instantly share code, notes, and snippets.

@fxsjy
fxsjy / bpnn_digit.py
Created June 14, 2012 06:38
bpnn solve kindergarten problem
# Back-Propagation Neural Networks
#
# Written in Python. See http://www.python.org/
# Modified by JSun to solve the problem here: http://www.weibo.com/1497035431/ynPEvC78V
# Neil Schemenauer <nas@arctrix.com>
import math
import random
import string
@fxsjy
fxsjy / gist:2934746
Created June 15, 2012 05:02
bpnn solve kindergarten problem(numpy)
#!/usr/bin/env python
# Problem: http://www.weibo.com/2090476735/ynJtWvN1K
# junyi sun (weibo.com/treapdb)
from numpy import *
def Q(L):
H = [0]*11
H[0] = 1 #bias item
for x in L:
H[x+1]+=1
@fxsjy
fxsjy / gist:2928683
Created June 14, 2012 07:22
bpnn solve kindergarten problem
# Back-Propagation Neural Networks
# another way: solve it as a Regression Problem
# Written in Python. See http://www.python.org/
# Modified by JSun to solve the problem here: http://www.weibo.com/1497035431/ynPEvC78V
# Neil Schemenauer <nas@arctrix.com>
import math
import random
import string
@fxsjy
fxsjy / gist:3009412
Created June 28, 2012 06:03
http bomber
var http=require('http')
url =require("url")
var cluster = require('cluster');
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < 20; i++) {
cluster.fork();
}
@fxsjy
fxsjy / gist:3158805
Created July 22, 2012 07:45
python random read disk
import random
import time
size=100000000
t1 = time.time()
f=open('x.db','wb')
f.write('x'*size)
f.close()
print 'write:', time.time()-t1
f=open('x.db','rb')
t2=time.time()
@fxsjy
fxsjy / gist:3293029
Created August 8, 2012 07:13
QBuffer: A little buffer tool for Node.JS
var QBuffer = exports.QBuffer= function(){
this.list = []
this.length = 0
}
QBuffer.prototype.append=function(chunk){
this.list.push(chunk)
this.length += chunk.length
}
@fxsjy
fxsjy / gist:3377100
Created August 17, 2012 08:47
Memcached Server Written in Go, only 70 lines of code
package main
import (
"net"
"log"
"fmt"
"bufio"
"strings"
"strconv"
"io"
@fxsjy
fxsjy / gist:3550052
Created August 31, 2012 08:00
Bakup Weibo to Disk
package main
import (
"net/http"
"net/url"
"log"
"io/ioutil"
"regexp"
"fmt"
//"net/http/httputil"
@fxsjy
fxsjy / gist:3550053
Created August 31, 2012 08:00
Bakup Weibo to Disk
package main
import (
"net/http"
"net/url"
"log"
"io/ioutil"
"regexp"
"fmt"
//"net/http/httputil"
@fxsjy
fxsjy / find_nth_int.py
Created September 12, 2012 06:40 — forked from yongsun/find_nth_int.py
find nth integer in distributed env
#!/usr/bin/python
import numpy.random as random
from bisect import bisect_left, bisect_right
class SlaveNode:
def __init__ (self, data):
self.data = sorted(data)
def get_range (self):