Skip to content

Instantly share code, notes, and snippets.

View liuweiathust's full-sized avatar

liuweiathust liuweiathust

View GitHub Profile
library(readxl)
library(dplyr)
ARDS_COMPARE <- read_excel("D:/Desktop/ARDS_COMPARE.xlsx")
colnames(ARDS_COMPARE) <- c("compare", "number", "gene", "snp", "minor_allele_1", "major_allele_1", "minor_allele_2", "major_allele_2")
d <- ARDS_COMPARE %>% select(minor_allele_1, major_allele_1, minor_allele_2, major_allele_2)
d$minor_allele_1 = as.integer(d$minor_allele_1)
d$major_allele_1 = as.integer(d$major_allele_1)
d$minor_allele_2 = as.integer(d$minor_allele_2)
@liuweiathust
liuweiathust / 0_reuse_code.js
Created January 9, 2017 08:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
println("hello world!")
#!/bin/bash
usage ()
{
echo Parallel sort
echo usage: psort file1 file2
echo Sorts text file file1 and stores the output in file2
}
# test if we have two arguments on the command line
import MySQLdb
class DummyDict(object):
def __init__(self, database="test", user="liuwei", password="123456"):
self.database = MySQLdb.connect("localhost", user, password, database)
self.db = self.database.cursor()
self.db.execute("DROP TABLE IF EXISTS test")
self.db.execute("CREATE TABLE test (name VARCHAR(255) PRIMARY KEY, content VARCHAR(255))")
self.database.commit()
def __getitem__(self, key):
self.db.execute("SELECT content FROM test WHERE name = %s", (key, ))
import sqlite3
class DummyDict(object):
def __init__(self, database="database.db"):
self.database = sqlite3.connect(database)
self.db = self.database.cursor()
self.db.execute("DROP TABLE IF EXISTS test")
self.db.execute("CREATE TABLE test (name VARCHAR(255) PRIMARY KEY, content VARCHAR(255))")
def __getitem__(self, key):
self.db.execute("SELECT content FROM test WHERE name = ?", (key, ))
return self.db.fetchone()[0]
@liuweiathust
liuweiathust / plugins.sbt
Created March 7, 2013 16:51
lift project project/plugins.sbt
libraryDependencies <+= sbtVersion(v => v match {
case "0.11.0" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.0-0.2.8"
case "0.11.1" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.1-0.2.10"
case "0.11.2" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.2-0.2.11"
case "0.11.3" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.3-0.2.11.1"
case x if (x.startsWith("0.12")) => "com.github.siasia" %% "xsbt-web-plugin" % "0.12.0-0.2.11.1"
})
@liuweiathust
liuweiathust / build.sbt
Created March 7, 2013 16:50
lift project build.sbt
name := "lift-demo"
scalaVersion := "2.9.2"
seq(webSettings :_*)
// enable jrebel
scanDirectories in Compile := Nil
resolvers += "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"
@liuweiathust
liuweiathust / gist:1516675
Created December 24, 2011 07:20
read each line's second field, and sort by frequency, return top 10 frequency records
ARGF.readlines.inject(Hash.new(0)){ |h,l| h[l.chomp.split[1]] += 1;h}.sort.last(10)