Skip to content

Instantly share code, notes, and snippets.

View nimezhu's full-sized avatar

Zhu Xiaopeng nimezhu

View GitHub Profile
@nimezhu
nimezhu / iotest.go
Created October 23, 2016 03:35
Reading data from stdin or a file in Go
/*
If no filename given as argument, read from stdin. Allows use as piped tool.
mashbridge@hex iotest$ go build iotest.go
mashbridge@hex iotest$ ./iotest x.txt
file data: foo bar
mashbridge@hex iotest$ ./iotest < x.txt
stdin data: foo bar
@nimezhu
nimezhu / mat64_nmf.go
Last active July 21, 2016 18:32
mat64 NMF ( translated from go.matrix NMF https://gist.github.com/r9y9/9030922 )
package main
import (
"fmt"
. "github.com/gonum/matrix/mat64"
)
func NewElemDense(r int, c int, v float64) *Dense {
data := make([]float64, r*c)
for i := range data {
@nimezhu
nimezhu / README
Created March 11, 2016 17:51 — forked from adilapapaya/README
Export Table Data to CSV using Javascript
Example code for exporting data in a table to a csv file.
#!/usr/bin/env python
# Programmer : zhuxp
# Date:
# Last-modified: 01-29-2016, 16:48:48 EST
from __future__ import print_function
VERSION="0.1"
import os,sys,argparse
from bam2x.Annotation import BED6
from bam2x import TableIO,Tools
from bam2x import IO
#!/usr/bin/env python
# Programmer : zhuxp
# Date:
# Last-modified: 12-25-2015, 22:16:09 EST
from __future__ import print_function
VERSION="0.1"
import os,sys,argparse
from bam2x.Annotation import BED12
from bam2x import TableIO,Tools
from bam2x import IO
#!/usr/bin/env python
# Programmer : zhuxp
# Date:
# Last-modified: 12-11-2015, 10:41:26 EST
from __future__ import print_function
VERSION="0.1"
import os,sys,argparse
from bam2x.Annotation import BED12
from bam2x import TableIO,Tools
from bam2x import IO
#!/usr/bin/env python
# Programmer : zhuxp
# Date:
# Last-modified: 12-07-2015, 11:27:31 EST
from __future__ import print_function
VERSION="0.1"
import os,sys,argparse
from bam2x.Annotation import BED12
from bam2x import TableIO,Tools
from bam2x import IO
@nimezhu
nimezhu / geneset_api.js
Last active November 21, 2015 16:37
restapi server side example
var qs = require('querystring');
var sqlite3 = require('sqlite3').verbose();
var dbs = ["test.db","elisa.db","mouse.geneset.db"];
var db={};
dbs.forEach(function(d){
db[d] = new sqlite3.Database("data/"+d);
db[d].serialize(function() {
//db.run("CREATE TABLE IF NOT EXISTS geneset (key TEXT, value INTEGER)");
});
})
request = require("request")
var restful="http://127.0.0.1:8081"
function list(sp,callback) {
request(
{url:restful+"/list"+sp+"h"
,json:true},
function(err,res,body) {
callback(body)
}
@nimezhu
nimezhu / pub.css
Last active October 25, 2015 22:43
render pubmed search
h2 {
padding:4px;
color:#fff;
margin:0;
background-color:black;
font-size: 10pt; /* or whatever */
}
body {
width: 100%;
height: 100%;