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
<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]; |
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: lsauer.com | |
//Data is in the form | |
//[ ["JOEBRA","Doeduardo","9.9.1999","Midwaystreet 12","1160 Vienna", "Austria" ],...] | |
//if you need the name fully anonymized shuffle the name before substr or calculate a Soundex of it | |
for(i=0; i<x.autpolData.length; i++){ | |
tmp[i] = [].concat(x.autpolData[i][1].substr(0,4), x.autpolData[i][2].split('.')[2], x.autpolData[i].slice(3) ) | |
} | |
//["Doed", "1948", "Midwaystreet 12", "1160 Vienna", "Austria" | |
//the address is resolved to GPS lat/long -> see my scripts_n_snips folder | |
//often times JS is faster and more powerful than an editor with RegExp |
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: lo sauer 2011 - lsauer.com | |
//implementation of PHP's trim | |
//see http://php.net/manual/en/function.trim.php | |
//bug: doesn't work with ']' in the charlist | |
//@param: charlist <string> | |
String.prototype.phptrim = function(s) | |
{ | |
if(0==arguments.length) | |
return this.valueOf().trim(); |
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: lo sauer 2011 - lsauer.com | |
#demonstrating the difference in RegEx engines | |
Python: | |
import re | |
a="123 test 42 <!-- comment 345 commentEnd --> 678 test2 348" | |
filter(None, re.findall('(?:\<\!--.+\d+.+--\>)|(\d+)',a)) | |
#With RegEx lookbehinds; for demonstration only - not very practical (slow!) | |
re.findall('(\d+)(?!(?:[^<]+|<(?!!--))*-->)',a)) |
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 | |
//join() is by default: join(',') | |
[1,2,,3,,3,,,0,,,4,,4,,5,,6,,,,,8,,,-2].filter(String).join() | |
>>>"1,2,3,3,0,4,4,5,6,8,-2" | |
//same result for: filter(function(){return 1}); | |
[1,2,,3,,3,,,0,,,4,,4,,5,,6,,,,,8,,,-2].filter(function(){return 1}).join() | |
>>>"1,2,3,3,0,4,4,5,6,8,-2" | |
//to conveniently eliminate null-elements... |
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: lo sauer 2011, lsauer.com | |
//description: Forcing JSON array notation on array-like object (i.e. arguments, DOMCollection) | |
//application: e.g. JSON-RPC | |
//Take for instance this simple function, which returns a pure JS object notation | |
function x(){console.log(JSON.stringify(arguments))} | |
x(1,2,3,"sfdsf", [1,2,3], {1:2}) | |
>>>[{"0":1,"1":2,"2":3,"3":"sfdsf","4":[1,2,3],"5":{"1":2}}] | |
//There is no straightforward Array typecasting in JS; Array() will nest the object in an array |
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
//instructions are especially for mysql: | |
//lo sauer, 2011 | |
1. create the database: 'CREATE DATABASE `enzymes`;' | |
2. now either select the database with 'USE `enzymes`;' or put the same command at the beginning of your sql-file. | |
in the latter case run sqlimport which is a shortcut for the more powerful command LOAD DATA INFILE http://dev.mysql.com/doc/refman/5.1/en/load-data.html | |
' mysqlimport -u root -p --local enzymes enzymes.sql' | |
Or in mysql (e.g. mysql -u root -p) you can use the LOAD DATA INFILE Command |