Skip to content

Instantly share code, notes, and snippets.

View bmpvieira's full-sized avatar

Bruno Vieira bmpvieira

  • Lifebit
View GitHub Profile
@bmpvieira
bmpvieira / pca.R
Created April 10, 2012 20:05
Short PCA example with FactoMineR and ggplot2 in R
#Copyright (c) 2012 Bruno Vieira [http://bmpvieira.com]
#License: CC BY
#Short PCA example with FactoMineR and ggplot2 in R
library(FactoMineR)
library(ggplot2)
data = read.table("data.tsv", head=T, row.names=1)
pca = PCA(data[,2:ncol(data)], scale.unit=T, graph=F)
PC1 = pca$ind$coord[,1]
PC2 = pca$ind$coord[,2]
@bmpvieira
bmpvieira / lonlat2utm.R
Created August 16, 2012 23:46
Simple R script to convert Long/Lat to UTM format
#!/usr/bin/Rscript
#
#Copyright (c) 2012 Bruno Vieira [http://bmpvieira.com]
#License: MIT
#Description: Simple R script to convert Long/Lat to UTM format
require("PBSmapping") || install.packages("PBSmapping", dependencies=TRUE) && require("PBSmapping")
input <- commandArgs(TRUE)[1]
coord <- read.csv(input, header = TRUE)
attr(coord, "projection") <- "LL"
@bmpvieira
bmpvieira / youtubePlaylistParser.js
Created October 2, 2012 16:49
Simple Youtube playlist parser using JSONStream
/*
author: bmpvieira
license: WTFPL
description: Simple Youtube playlist parser using https://github.com/dominictarr/JSONStream
usage example: node youtubePlaylistParser.js PLt4dwg5cC5TSqHR44YK0UQ_8TSG8YtZtI | cclive -f best -c
*/
var request = require('request');
var JSONStream = require('JSONStream');
@bmpvieira
bmpvieira / getMycorLinks.coffee
Last active December 12, 2015 00:18
This script fetches all the sequences links from a MycorWeb Blast result.
@bmpvieira
bmpvieira / getMycorSequences.coffee
Last active December 12, 2015 00:18
This script fetches sequences from MycorWeb Blast result links.
# getMycorSequences.coffee
# This script fetches sequences from MycorWeb Blast result links.
#
# links file must be provided and can be obtained with getMycorLinks.coffee:
# https://gist.github.com/4683065
#
# Dependencies: casperjs
# Usage: casperjs getMycorSequences.coffee fileWithLinks
# Example: casperjs getMycorSequences.coffee sequencesLinks:0-4275.txt
# Author: Bruno Vieira (mail@bmpvieira.com)
@bmpvieira
bmpvieira / blastXMLtoJSON.coffee
Created February 13, 2013 09:25
Convert NCBI's Blast XML results to JSON
# blastXMLtoJSON.coffee | 2013 Bruno Vieira [mail@bmpvieira.com]
#
# This script converts NCBI's Blast XML results to JSON
#
# For small files, it parses everything into a object in memory and
# writes the result to the output file in the end.
# For big files, it will write each Blast “Iteration” object separately,
# one per line, to avoid memory limits.
#
# Usage: coffee blastXMLtoJSON.coffee blast_results.xml output.json
@bmpvieira
bmpvieira / watable-controller.coffee
Last active December 20, 2015 03:09
CoffeeScript and JavaScript examples of using WATable with Express.js and Jade, with button to download CSV.
app.get '/watable', (req, res, next) ->
res.render 'watable'
app.get '/data.json', (req, res, next) ->
UserModel.find {}, 'email firstname lastname', (err, users) ->
return next err if err
rows = []
for user in users
user = user.toObject()
@bmpvieira
bmpvieira / docker-osx-install.sh
Created January 26, 2014 20:05
Docker running natively in OSX connected to daemon running inside Vagrant
#!/bin/bash
# Docker running natively in OSX connected to daemon running inside Vagrant
#
# This allows to use Docker natively in an OSX terminal, connected to a docker
# daemon running inside a CoreOS VM in Vagrant. Shared folder enabled through NFS.
#
# I tried to use [dvm](https://github.com/fnichol/dvm) but got issues with
# networking (#4) and shared folder (#7), so I just switched to CoreOS and
# added the settings for it to work like dvm.
@bmpvieira
bmpvieira / index.js
Created March 19, 2014 12:24 — forked from max-mapper/index.js
requirebin sketch
var shell = require("gl-now")({clearColor: [0,0,0,0]})
var camera = require("game-shell-orbit-camera")(shell)
var createTileMap = require("gl-tile-map")
var ndarray = require("ndarray")
var terrain = require("isabella-texture-pack")
var createAOShader = require("ao-shader")
var glm = require("gl-matrix")
var createShader = require("gl-shader")
var createBuffer = require("gl-buffer")
var createVAO = require("gl-vao")
@bmpvieira
bmpvieira / dnadigest-datasearch.html
Last active August 29, 2015 13:58
Mockup of an ideal UI/UX for searching data sets. Developed during the DNAdigest Hackday in London (5 April 2014) by @bmpvieira, @yannaspot and @owenlancaster
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="IE=edge" http-equiv="X-UA-Compatible">
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>DNAdigest</title>
<!-- Bootstrap -->