This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
csv,tsv to SQL conversion recipe | |
1.remove the first row split(by either tab or ,) and store in an array (field-header row) | |
e.g. ('Compound_id', 'Compound_common_name', 'Compound_synonyms', 'Molecular_weight', | |
'Chemical_formula', 'Smiles', 'Links', 'EC', 'Reaction_equation', 'Pathway'), | |
2.replace (in this order): | |
' -> \n | |
tab/, -> ', ' | |
\n -> '),\n(NULL, ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//author:lo sauer,2011 - lsauer.com - PHP - ZEND like URI Builder Class for RESTful services | |
//license: MIT license | |
//description: url builder class; allows object oriented setting of parameters etc, without relying on a big frameworks like ZEND | |
//purpose: emulating ZEND-like url-setting as shown for instance here: http://www.ibm.com/developerworks/web/library/x-phpwikipedia/?ca=drs- | |
//to show preformatted text | |
header("Content-Type: text"); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
// by lo sauer, 2011 - lsauer.com | |
// two div's or more are set such that the first is set to a fixed width, and the rest should be percent e.g. space filling | |
// container: <div id="container" style="width:700px;"> [div1] [div2] [divn...]</div> | |
// leftmost div: <div style="float:left; width:80px;>content</div> | |
// rightmost div: <div style="float:left; margin-right:80px; width:100%;>content</div> | |
// correct width a counter-margin, according to the total fixed-width; 80px in the example above | |
// below is an example, which you can see here: http://pastehtml.com/view/bb1d7ub83.html | |
// also note that in CSS, 'summarized' padding and margin settings start at the top, and proceed counter clockwise: top, right, bottom, left | |
// e.g. padding:0px 2px 2px 0px; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// lo sauer,2011 - dual license: your driver's license or public domain | |
// descr: quick hack for compiling BioCyc, *Cyc superpathways into JSON data | |
// milage may vary... try it for instance on: http://biocyc.org/ARA/NEW-IMAGE?object=Super-Pathways | |
// NOTE: heed this project: https://github.com/lsauer/json2sql (TBA soon) -> allows reorganization of higher order data structures into relational SQL tables | |
(function(self){ | |
var _set = [], | |
_el = self.getElementsByClassName('ecoparagraph')[3].getElementsByTagName('a'); | |
for(var i in _el){ | |
var n = _el[i]; | |
if(!n.getAttribute) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//lo sauer, 2011; lsauer.com | |
/** | |
* I saw this thread: http://stackoverflow.com/questions/840781/easiest-way-to-find-duplicate-values-in-a-javascript-array | |
* The solutions above lacked the elegance that can be done a with map-reduce-like operations | |
* Since this implementation works with native functions, the speed is in most circumstances faster | |
* than any solution using scripted-logic | |
* Additionally, I needed to quickly filter duplicate url-entries for: http://lsauer.github.com/chrome-session-restore/ | |
*/ | |
//copy and paste: without error handling | |
Array.prototype.unique = function(){return this.sort().filter( function(v,i,o){if(i>=0 && v!==o[i-1]) return v;});} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Dual licensed: BSD or Your Driver's License | |
1.<INSERT YOUR DRIVER'S LICENSE + MUGSHOT HERE> | |
2.<BSD LICENSE> | |
Copyright (c) 2011 lo sauer. | |
All rights reserved. | |
Redistribution and use in source and binary forms are permitted | |
provided that the above copyright notice and this paragraph are |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// International Chemical Identifier Regex, by lo sauer - lsauer.com | |
// Morphine InchI: | |
var x="InChI=1S/C17H19NO3/c1-18-7-6-17-10-3-5-13(20)16(17)21-15-12(19)4-2-9(14(15)17)8-11(10)18/h2-5,10-11,13,16,19-20H,6-8H2,1H3/t10-,11+,13-,16-,17-/m0/s1" | |
// applying an organic character-subset | |
// we could check for the length property, but in case of 0 matches 'null' is returned -> hence !!.. \ generally equal to Boolean(..) | |
!!x.trim().match(/^((InChI=)?[^J][0-9BCOHNSOPrIFla+\-\(\)\\\/,pqbtmsih]{6,})$/ig) | |
>true | |
//generic: | |
x.trim().match(/^((InChI=)?[^J][0-9a-z+\-\(\)\\\/,]+)$/ig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//lo sauer, 2011; lsauer.com - licensed under the "WTF's a licence?"-license | |
// parseInt() can show curious behavior; If a string is passed, without a second parameter | |
// (which takes the proper base of the number), parseInt may return unexpected numbers. | |
// For example parseInt('010') returns 8, not 10. Set the base to get the correct decimal result. | |
parseInt('0000010'); // returns 8! (FF>3, Chrome,...) | |
>8 | |
parseInt('0000010', 10); // returns 10, because the base is set to decimal | |
>10 | |
+'0000010' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//lo sauer, 2011; "what's a license?"-license | |
//String / Number padding in JavaScript | |
// performance seems to be equivalent, i.e. slice is an alias for substr http://jsperf.com/padding6000 | |
// ===Method 1===: | |
var str = "test"; | |
// padding length = pad.length | |
var pad = '0000000000000000'; | |
pad.length | |
> 16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// by jonas john, posted by lo sauer / lsauer.com; PUBLIC DOMAIN | |
// description: common http headers: | |
// Use this header instruction to fix 404 headers | |
// produced by url rewriting... | |
header('HTTP/1.1 200 OK'); | |
// Page was not found: | |
header('HTTP/1.1 404 Not Found'); | |
// Access forbidden: |