This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Control.Monad | |
import Data.List | |
import Data.Char | |
checkio :: (String,String) -> String | |
checkio (text, ws) = zip [0..] text >>= trans | |
where | |
span = [(i,w) | w<-words $ map toLower ws, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spline <- function(points, df) { | |
smooth.spline(points[,1],points[,2],df=df) | |
} | |
general_sample <- function(weight, size) { | |
weight$y[which(weight$y<0)] <- 0 | |
r<-rmultinom(1,size,weight$y) | |
rr<-c() | |
while (any(r>0)) { | |
i<-which(r>0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var httpProxy = require('http-proxy'); | |
var qs = require('querystring'); | |
var url= require('url'); | |
var redis = require('redis'); | |
var cheerio = require('cheerio'); | |
var ua= require('./ua'); | |
var rc = redis.createClient(); | |
var port=8081; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
general_distribution <- function(points, step=1) { | |
N <- nrow(points) | |
L <- points[1,1] | |
R <- points[N,1] | |
U <- max(points[,2]) | |
D <- min(points[,2]) | |
sp <- smooth.spline(points[,1],points[,2]) | |
x <- seq(L,R,step) | |
predict(sp,x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var stats = { | |
hit: 0, miss: 0 | |
}; | |
exports.LRU = function(size,k_match) { | |
var tbl=[]; | |
if (!k_match) k_match=function(k1,k2) { | |
if (k1.length!=k2.length) | |
return false; | |
for (var i=0; i<k1.length; i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var stats = { | |
hit: 0, miss: 0 | |
}; | |
exports.LRU = function(size,k_match) { | |
var tbl=[]; | |
if (!k_match) k_match=function(k1,k2) { | |
if (k1.length!=k2.length) | |
return false; | |
for (var i=0; i<k1.length; i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsdom = require("jsdom"); | |
var $ = require("jquery"); | |
var request = require("request"); | |
var ua = require("./ua"); | |
var myConfig = { | |
UA: "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)", | |
minTitleCount: 3, | |
minAvgTitleLen: 10, | |
minArticleFillRate: 0.5, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function attach(obj,methods) { | |
var wrap = function(a,f) { | |
return function() { return f.apply(a,arguments); } | |
}; | |
for (var name in methods) { | |
if (obj[name]) throw "conflict:"+name; | |
obj[name] = wrap(obj,methods[name]); | |
} | |
return obj; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$line = <>; | |
chomp $line; | |
($N)=split(/\s+/,$line); | |
%b=(); | |
$b{54}=$b{45}='B'; | |
$b{44}=$b{55}='W'; | |
for ($i=0; $i<$N; $i++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var attachMethods = function(obj,methods) { | |
var wrap = function(a,f) { | |
return function() { return f.apply(a,arguments); } | |
}; | |
for (var name in methods) { | |
if (obj[name]) throw "conflict:"+name; | |
obj[name] = wrap(obj,methods[name]); | |
} | |
return obj; | |
} |