Skip to content

Instantly share code, notes, and snippets.

@xiaojay
xiaojay / initr.js
Last active May 19, 2019 09:11
use node.js to call "grin wallet init -r"
var cp = require('child_process')
i = cp.spawn('grin-wallet', ['init', '-r'])
i.stdout.on('data', function(data){
let output = data.toString()
console.log(output)
})

Keybase proof

I hereby claim:

  • I am xiaojay on github.
  • I am xiaojay (https://keybase.io/xiaojay) on keybase.
  • I have a public key ASB6wuNIfzLe67wrYJVec3tMCmrsX6124z4ui7P24xSGoQo

To claim this, I am signing this object:

@xiaojay
xiaojay / withdraw.js
Created August 30, 2018 01:57
从fibos转eos到eos主网代码
var FIBOS = require("fibos.js");
var config = {
chainId: "6aa7bd33b6b45192465afa3553dedb531acaaff8928cf64b70bd4c5e49b7ec6a",
priKey: "你的fibos账号私钥",
httpEndpoint: "http://sl-rpc.fibos.io:8870",
verbose: false,
}
var fibos_client = FIBOS({
chainId: config.chainId,
keyProvider: config.priKey,
@xiaojay
xiaojay / how-to-use-web3-with-react-native.md
Created April 23, 2018 14:53
This file describes how to set up the Ethereum JS API web3.js with the boilerplate Create React Native App

How to set up web3.js with CRNA

This is a simple guide to get you started with using the Ethereum Javascript API (web3.js) with the Create React Native App project. This is not an in-depth guide.

  1. Make sure you have Node version 6 or later installed, if not, get it on the Node website

    node --version

  2. Install Create React Native App

@xiaojay
xiaojay / how-to-use-web3-with-react-native.md
Created April 23, 2018 14:53
This file describes how to set up the Ethereum JS API web3.js with the boilerplate Create React Native App

How to set up web3.js with CRNA

This is a simple guide to get you started with using the Ethereum Javascript API (web3.js) with the Create React Native App project. This is not an in-depth guide.

  1. Make sure you have Node version 6 or later installed, if not, get it on the Node website

    node --version

  2. Install Create React Native App

@xiaojay
xiaojay / how-to-use-web3-with-react-native.md
Created April 23, 2018 14:53
This file describes how to set up the Ethereum JS API web3.js with the boilerplate Create React Native App

How to set up web3.js with CRNA

This is a simple guide to get you started with using the Ethereum Javascript API (web3.js) with the Create React Native App project. This is not an in-depth guide.

  1. Make sure you have Node version 6 or later installed, if not, get it on the Node website

    node --version

  2. Install Create React Native App

@xiaojay
xiaojay / Add dbSNP IDs to a VCF file
Created September 15, 2016 06:47 — forked from obenshaindw/Add dbSNP IDs to a VCF file
Add dbSNP IDs to a VCF file that doesn't have them.
#GATK Method <- Slower and keeps original ID plut dbSNP rsID
# R=Reference FASTA
# V=VCF file to add IDs to
# --dbsnp = dbsnp VCF -- download from NCBI FTP
java -jar GenomeAnalysisTK.jar -R /reference/Homo_sapiens_assembly19.fasta -T VariantAnnotator -V vcf_to_add_id_to.vcf --dbsnp /reference/dbsnp_137.b37.vcf.gz --out /data/Broad.chr1.annotated.vcf
#bcftools Method <- Faster, replaces existing ID with dbSNP rsID
/usr/bin/htslib/bcftools/bcftools annotate -a /reference/dbsnp_137.b37.vcf.gz -c ID vcf_to_add_id_to.vcf
@xiaojay
xiaojay / 1000.py
Created July 12, 2016 14:49
stats in chinese from 1000 genome
#coding=utf-8
import sys,json,re
import vcf
vcf_reader = vcf.Reader(open(sys.argv[1]))
ch = json.load(open('chb.json')) + json.load(open('chs.json'))
pattern = r'^([0,1])[\|\/]([0,1])$'
for record in vcf_reader:
if record.var_type == 'snp' and len(record.ALT) == 1:
@xiaojay
xiaojay / snp.sql
Created July 9, 2016 09:43
bigquery on 1000 genomes
SELECT
reference_name,
names,
start,
END,
reference_bases,
alt,
sample_id,
genotype from(
SELECT
@xiaojay
xiaojay / fm.py
Created March 25, 2016 01:48
check 23andme data
#coding=utf-8
import os,sys,argparse,zipfile
def parse_23andme_file(fn):
data = {}
suffix = fn.split('.')[-1].lower()
if suffix == 'zip':
z = zipfile.ZipFile(fn, 'r')
content = z.read(z.namelist()[0])
else: