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 / 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!" );
def f1 = {
println("f1")
true
}
def f2 = {
println("f2")
@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
}
@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 / 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="")))
})