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
/** | |
L. Sauer,2011 | |
license: public domain | |
http://xhr2.blogspot.com/2011/09/php-arraymerge-by-value-or-array-merge.html | |
*/ | |
function array_merge_values_explode(){ | |
$args = func_get_args(); | |
$elem = array(); | |
$delim = strlen(end($args))<=2 ? array_pop($args) : ','; |
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
//L.Sauer 2011; Public Domain | |
//renders code even without SyntaxHighlighter present | |
//see http://xhr2.blogspot.com/2011/09/alexgorbatchevcom-down-changing.html | |
//dp is the typical SyntaxHighlighter object; | |
//use the class 'shFallback' for styling the fallback <pre>-tag | |
if(typeof dp === 'undefined' ){ | |
(function(){ | |
var els = document.getElementsByTagName('script'); | |
var elClass = null; //or e.g. class 'shFallback' | |
for(var i in els) { |
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
( a >= 0 && ~a >= 0 ) | |
First statement ensures that the variable is positive, the second ensures that no sign-bit is flipped. |
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
function j2timer(e){ | |
window.tdiff || (window.tdiff = []); | |
window.tdlog || (window.tdlog = []); | |
window.fnred || (window.fnred = function(a,b){return a-b;}); | |
//toogle statement | |
if( (tdiff.length+1) % 2){ | |
tdiff.push( Date.now()); | |
return; | |
} |
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
The following code will do just what you would expect (a css rule for the element's id is applied). | |
<input id="searchCmpnd" onClick="this._originalWidth = this.style.width; this.style.width='50%';" onBlur="this.style.width = this._originalWidth;" /> | |
However when the onClick is changed to onKeyUp, onKeyPress, onKeyDown it will expand but not retract. This is because the element is not marked focused, or because the event order got messed up (in Chrome >12). | |
Include this.focus(); | |
<input id="searchCmpnd" onClick="this._originalWidth = this.style.width; this.focus(); this.style.width='50%';" onBlur="this.style.width = this._originalWidth;" /> |
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
#INSERT INTO `core_url_rewrite` (`store_id`, `category_id`, `product_id`, `id_path`, `request_path`, `target_path`, `is_system`) | |
SELECT 1 AS `store_id`, | |
`sub`.`category_id`, | |
`sub`.`entity_id` AS `product_id`, | |
CONCAT('product', '/', `entity_id`, '/', `category_id`) AS `id_path`, | |
`value` AS `request_path`, | |
CONCAT('catalog/product/view/id/', `entity_id`, '/category/', `category_id`) AS `target_path`, | |
1 AS `is_system` | |
FROM | |
(SELECT |
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
#L sauer 2011, public domain | |
def main(): | |
import urllib2 | |
furl = urllib2.Request('http://www.mypacm.us.gov/bin/www_bget?one=two') | |
furl.add_header('Referer', 'http://www.mypacm.us.gov/') | |
furl.add_header('User-agent', 'Mozilla/5.0 AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.35 Safari/535.1') | |
furl.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') | |
furl.add_header('Accept-Encoding', 'gzip,deflate,sdch') | |
furl.add_header('Accept-Language', 'en-US,en;q=0.8') | |
#furl.add_header('Origin', 'http://www.mypacm.us.gov/bin/') |
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
//l.sauer 2011, public domain | |
//returns a hash table with the word as index and frequency as value; good for svg / canvas -plotting or other experiments | |
//[:punct:] Punctuation symbols . , " ' ? ! ; : # $ % & ( ) * + - / < > = @ [ ] \ ^ _ { } | ~ | |
var wordcnt = function(id){ | |
var hist = {}, words = document.getElementById(id).innerText.split(/[\s*\.*\,\;\+?\#\|:\-\/\\\[\]\(\)\{\}$%&0-9*]/) | |
for( i in words) | |
if(words[i].length >1 ) | |
hist[words[i]] ? hist[words[i]]+=1 : hist[words[i]]=1; | |
return hist; | |
}; |
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
<style type="text/css"> | |
.socialBoxV, .socialBoxH { { | |
float: right; | |
margin: 15px 20px 0 0; | |
padding: 7px 7px 7px 14px; | |
background-color: #FCF6C4; | |
border-radius: 5px; | |
-o-transition: all 0.7s linear; | |
-moz-transition: all 0.7s linear; |
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
//author: unknown/ extended by Lo Sauer (2000); Codebase yr2000 | |
//descr: Color and grey palette in PHP with Javascript interaction | |
<script language="JavaScript"> | |
var coRed=127;coGreen=127;coBlue=255; // Original color | |
var Hex=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"); | |
function rgb2hex(cRed,cGreen,cBlue){ | |
cColor=Hex[Math.floor(cRed/16)]+Hex[cRed%16]+Hex[Math.floor(cGreen/16)]+Hex[cGreen%16]+Hex[Math.floor(cBlue/16)]+Hex[cBlue%16]; |
OlderNewer