Skip to content

Instantly share code, notes, and snippets.

View pauca's full-sized avatar

Pau Carrió pauca

  • Barcelona, Spain
View GitHub Profile
@pauca
pauca / R_chem_snippets.R
Created October 13, 2015 09:21
R_chem_snippets
# CAS -> smiles with CACTUS server
sapply(cas, function(id){
require(RCurl)
return(getURL(paste("http://cactus.nci.nih.gov/chemical/structure/",id,"/smiles",sep="")))
})
@pauca
pauca / gz.scala
Last active April 30, 2022 06:14
scala read / write from compressed gz
import java.io._
import java.util.zip._
import scala.io.Source
var in = new GZIPInputStream(new FileInputStream("test.gz"))
// write setup in different objects to close later properly (important for big files )
var fos = new FileOutputStream("test2.gz")
var gzos = new GZIPOutputStream( fos )
var w = new PrintWriter(gzos)
@pauca
pauca / elapsedTime.scala
Last active January 22, 2019 11:57
measure and show elapsed time
// from https://biercoff.com/easily-measuring-code-execution-time-in-scala/
def time[R](block: => R): R = {
val t0 = System.nanoTime()
val result = block // call-by-name
val t1 = System.nanoTime()
println("Elapsed time: " + (t1 - t0) + "ns")
result
}
def f1 = {
println("f1")
true
}
def f2 = {
println("f2")
@pauca
pauca / examplePasteAndShow.html
Created January 18, 2017 10:19
Example of jQuery of Paste on textarea and do an action
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Paste&Go</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" ></script>
<script>
$( document ).ready(function() {
console.log( "ready!" );
@pauca
pauca / RqcScript.R
Last active January 19, 2017 11:22
Rqc - memory error reproduce
library(Rqc)
fs <- "corrupted.fastq"
qa <- rqcQA(fs,sample=F)
sessionInfo()
@pauca
pauca / replaceSymLinks.sh
Last active April 11, 2017 13:12
replace symbolik links in current directory by originals, and remove them
@pauca
pauca / StoreRocksDB.scala
Last active January 24, 2022 17:11
Template for testing: RocksDB with Scala
import java.io.File
import org.rocksdb._
import org.rocksdb.util.SizeUnit
import scala.collection.JavaConversions._
// build.sbt
// name := "RocksDB"
// version := "0.1"
// scalaVersion := "2.12.0"
// libraryDependencies += "org.rocksdb" % "rocksdbjni" % "5.0.1"
@pauca
pauca / AkkaStreamTemplate.scala
Created June 9, 2017 15:34
Basic Akka Stream Template: read, transform, write
/*
build.sbt
name := "AkkaStreamTemplate"
version := "0.1-SNAPSHOT"
scalaVersion := "2.12.2"
libraryDependencies ++= {
Seq(
@pauca
pauca / binaryDistances.R
Last active June 19, 2017 12:28
binary distances R ( tanimoto)
# http://www.sequentix.de/gelquest/help/distance_measures.htm
bdist <- function( x, y , method ){
a <- sum( x == 1 & y == 1)
b <- sum( x == 1 & y == 0)
c <- sum( x == 0 & y == 1)
d <- sum( x == 0 & y == 0)
switch(method,
tanimoto = (a+d)/(a+2*(b+c)+d),