Skip to content

Instantly share code, notes, and snippets.

@xwu
xwu / gist:132743
Created June 19, 2009 17:29
Download and configure Trait-o-matic core
cd
wget http://github.com/xwu/trait-o-matic/tarball/master -O trait.tar.gz
rm -Rf xwu-trait-o-matic-*
tar -zxvf trait.tar.gz
sudo rm -Rf /usr/share/trait
sudo cp -R xwu-trait-o-matic-*/core /usr/share/trait
cd /usr/share/trait
sudo python setup.py build_ext --inplace
@xwu
xwu / trait_data.sh
Created June 19, 2009 17:32
Download necessary data for Trait-o-matic core
sudo mkdir /var/trait
sudo wget http://hgdownload.cse.ucsc.edu/goldenPath/hg18/bigZips/hg18.2bit -O /var/trait/hg18.2bit
cd
# dbSNP (only two tables)
wget ftp://ftp.ncbi.nih.gov:21/snp/organisms/human_9606/database/organism_data/OmimVarLocusIdSNP.bcp.gz
wget ftp://ftp.ncbi.nih.gov:21/snp/organisms/human_9606/database/organism_data/b129/b129_SNPChrPosOnRef_36_3.bcp.gz
gunzip OmimVarLocusIdSNP.bcp.gz
gunzip b129_SNPChrPosOnRef_36_3.bcp.gz
@xwu
xwu / trait_prerequisites.sh
Created June 19, 2009 17:08
Install Trait-o-matic prerequisites
sudo apt-get install wget
sudo apt-get install zip unzip
sudo apt-get install apache2
sudo apt-get install apache2-threaded-dev
cd /etc/apache2/mods-enabled
sudo ln -s /etc/apache2/mods-available/expires.load expires.load
sudo ln -s /etc/apache2/mods-available/deflate.load deflate.load
sudo ln -s /etc/apache2/mods-available/rewrite.load rewrite.load
@xwu
xwu / trait_core_db.sql
Created June 19, 2009 17:21
Create the necessary databases, database users, and database tables for Trait-o-matic core
CREATE DATABASE `ariel` DEFAULT CHARACTER SET ASCII COLLATE ascii_general_ci;
CREATE DATABASE `caliban` DEFAULT CHARACTER SET ASCII COLLATE ascii_general_ci;
CREATE DATABASE `dbsnp` DEFAULT CHARACTER SET ascii COLLATE ascii_general_ci;
CREATE USER 'reader'@'localhost' IDENTIFIED BY 'shakespeare';
GRANT SELECT ON *.* TO `reader`@'localhost';
CREATE USER 'reader'@'%' IDENTIFIED BY 'shakespeare';
GRANT SELECT ON *.* TO `reader`@'%';
CREATE USER 'updater'@'localhost' IDENTIFIED BY 'shakespeare';
@xwu
xwu / gist:132767
Created June 19, 2009 18:15
Load Trait-o-matic data into MySQL databases
USE caliban;
LOAD DATA LOCAL INFILE '~/morbidmap.txt' INTO TABLE `morbidmap` FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n';
LOAD DATA LOCAL INFILE '~/omim.tsv' INTO TABLE `omim` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n';
LOAD DATA LOCAL INFILE '~/refFlat.txt' INTO TABLE `refflat` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' IGNORE 1 LINES;
LOAD DATA LOCAL INFILE '~/snpedia.tsv' INTO TABLE `snpedia` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n';
USE dbsnp;
LOAD DATA LOCAL INFILE '~/OmimVarLocusIdSNP.bcp' INTO TABLE `OmimVarLocusIdSNP` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n';
LOAD DATA LOCAL INFILE '~/b129_SNPChrPosOnRef_36_3.bcp' INTO TABLE `b129_SNPChrPosOnRef_36_3` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n';
@xwu
xwu / gist:132749
Created June 19, 2009 17:37
Custom DocumentRoot Apache configuration for Trait-o-matic
<Directory /var/www/>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
# Use only MTime and Size (not INode) in Etags calculation
FileETag MTime Size
# GZIP text files (requires mod_deflate)
@xwu
xwu / gist:132788
Created June 19, 2009 18:51
Production and increased upload limit modifications to PHP settings for Trait-o-matic
display_errors = Off
log_errors = On
magic_quotes_gpc = Off
session.bug_compat_42 = 0
session.bug_compat_warn = 0
max_execution_time = 30
max_input_time = 600
memory_limit = 128M

Completing the Swift 3 range operator suite

Introduction

We propose to complete Swift's suite of range operators to introduce a fully open range (&lt;.&lt;) and the second complementary half-open range (&lt;..).

@xwu
xwu / numerics.md
Last active January 18, 2017 05:02
Numeric Protocols

Arithmetic

protocol Arithmetic : Equatable, ExpressibleByIntegerLiteral

An type that provides certain arithmetic operations (addition, subtraction, and multiplication).

Types that conform to Arithmetic satisfy the following conditions for any values a, b, and c (unless the result of an operation overflows the maximum size of the conforming type):

  • Addition (+) is commutative; that is, a + b == b + a
@xwu
xwu / user-experience-of-new-integer-protocols.md
Last active August 3, 2017 02:07
Notes on the user experience of new integer protocols

Notes on the user experience of new integer protocols

Xiaodi Wu
June 17, 2017

Introduction

The design, re-design, and implementation of [SE-0104][1], a proposal to revise integer protocols in Swift, is now largely complete in shipping previews of Swift 4. As an exercise, I have used the new APIs to develop a [set of additional numeric facilities][2]. Here are some insights gained from that experience--and from two unpublished exercises to implement a BigInt type (one from scratch, one wrapping GMP)--as well as suggestions for improvement.