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 | |
PHP variable names can't start with a digit. As such non-associative array conversion can pose a problem. | |
Additionally stdClass does not implement ArrayAccess - as PHP's base class. | |
//note: this is not serialized php code | |
$var = stdClass Object | |
( | |
[0] => stdClass Object | |
( | |
['my'] => 1442, |
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
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
//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
// lo sauer, lsauer.com - JavaScript testing for binary String as part of my 'islib'-project | |
// description: For a parser I need to first make sure whether the character set of the input is a | |
// standard-printable ASCII-charset i.e. text | |
(is={}).Binary = function (o) { if( typeof o !== 'string') return false; return !(RegExp("^([\x20-\x7F]+)$").test(o)); } | |
is.Binary("Hello World!") | |
false | |
is.Binary("Hello World!\0x12") | |
true | |
is.Binary("Hello World! - Àéʱ") | |
true |
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 | |
//jquery toggle accepts functions and pools these; | |
//These functions ('actions') are then cycled through upon each event-based invocation | |
//Variants: | |
//.toggle( [duration] [, easing] [, callback] ) | |
//.toggle( [duration] [, callback] ) | |
//.toggle( showOrHide ) | |
//#imgtagtop is a simple image: <img src="..." id="imgtagtop"> |