Skip to content

Instantly share code, notes, and snippets.

View jonasalmeida's full-sized avatar

Jonas Almeida jonasalmeida

View GitHub Profile
@jonasalmeida
jonasalmeida / JSON Patients
Created May 14, 2014 19:11
ESTE module to display Patient entries as JSON
$('<li> <a href="javascript:myPatientsFun()">JSON_Patients</a></li>').appendTo($('.navbar-nav')[0]);
myPatientsFun = function() {
if($('#JSON_Patients').length>0){$('#JSON_Patients').remove()}
else{
var myPatients = Patients.find().fetch();
$('.row-fluid').prepend($('<div id="JSON_Patients"><a style="color:red" href="javascript:myPatientsFun()">Hide ('+myPatients.length+')</a></div>'));
$('#JSON_Patients').append($('<pre>'+JSON.stringify(myPatients,undefined,3)+'</pre>'));
}
}
@jonasalmeida
jonasalmeida / code.js
Created October 22, 2014 17:16
Bade's Array Challange
// https://gist.github.com/drobbins/64b0d90009333fc50d01
@jonasalmeida
jonasalmeida / TCGAimageURL.js
Last active August 29, 2015 14:08
retrieving URLs for TCGA tissue images from SPARQL endpoint
// SPARQL query composition at http://agalpha.mathbiol.org/repositories/tcga#query/r/TCGA-CM-4743-01A-01_URL
label='TCGA-CM-4743-01A-0' // example of a label
url = 'http://agalpha.mathbiol.org/download?file=query.json&accept=application%2Fsparql-results%2Bjson&path=%2Frepositories%2Ftcga%3Fquery%3Dselect%2520distinct%2520%253Fo%2520%253Fu%250Awhere%2520%257B%250A%2509%253Ft%2520a%2520%253Chttp%253A%252F%252Fpurl.org%252Ftcga%252Fcore%2523platform%253E.%250A%2520%2520%2509%253Ft%2520%253Chttp%253A%252F%252Fwww.w3.org%252F2000%252F01%252Frdf-schema%2523label%253E%2520%2522tissue_images%2522.%250A%2520%2520%2509%253Fo%2520%253Chttp%253A%252F%252Fpurl.org%252Ftcga%252Fcore%2523platform%253E%2520%253Ft.%250A%2520%2520%2509%253Fo%2520rdfs%253Alabel%2520%253FL.%250A%2520%2520%2509filter%2520REGEX(%253FL%252C%72'+label+'1%27)%250A%2520%2520%2520%2520%253Fo%2520tcga%253Aurl%2520%253Fu%250A%257D%26infer%3Dfalse'
$.getJSON(url,function(x){
y=x.results.bindings.map(function(xi){return xi.u.value});
console.log('
@jonasalmeida
jonasalmeida / residualSignDistribution.js
Last active August 29, 2015 14:09
Residua Distribution of signs
// One way to measure goodness of fit is to
// assess the even distribution of values arround
// the regression line. This is a non-parameric
// approach that is not sensitive to the magitude
// of the noise, only to its structure
RSD={
res2sign:function(r){ // counts same-sideness of residuals in array r
var rs = 0
for(var i=1;i<r.length;i++){rs+=((r[i]*r[i-1])>0)}
<h2>Mean Absolute Deviation = <span id="y"> ... </span></h2>
<p><textarea id="x"></textarea></p>
(separate values with commas)
x = [1,2,3]
var http = require('http')
var port = process.env.PORT || 1337;
http.createServer(function(req, res) {
res.writeHead(200, {
'Content-Type': 'text/plain',
'Access-Control-Allow-Origin': '*' // CORS
});
if(req.url.match('=')){
var pp=req.url.slice(2).split('=') // parameter array
var parm={}
Verifying my Blockstack ID is secured with the address 194cZZBfYZYtuRdnjVbNWnVNkUX6B8xJYL https://explorer.blockstack.org/address/194cZZBfYZYtuRdnjVbNWnVNkUX6B8xJYL