You can't parse HTML with regex...
http://stackoverflow.com/questions/4683046/regular-expression-for-extracting-script-tags
...and if you do, someone will write some poem of poetic beauty quality:
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454
Friday, November 30, 2012
Thursday, November 29, 2012
Can your RDBMS do a convenient audit trail?
Can your RDBMS do this?
Output:
hstore can be used as a convenient mechanism for audit trail
http://www.sqlfiddle.com/#!1/d5729/1
create table person
(
person_id serial not null primary key,
lastname text not null,
firstname text not null,
nickname text null,
favorite_number int null
);
insert into person(lastname,firstname,nickname, favorite_number) values
('lennon','john winston','john',default),
('mccartney','james paul','paul',default),
('harrison','george',default,default),
('starr','richard','ringo', 10);
select skeys(hstore(p.*)) as field, svals(hstore(p.*)) as value from person p;
Output:
field | value -----------------+-------------- lastname | lennon nickname | john firstname | john winston person_id | 2 favorite_number | lastname | mccartney nickname | paul firstname | james paul person_id | 3 favorite_number | lastname | harrison nickname | firstname | george person_id | 4 favorite_number | lastname | starr nickname | ringo firstname | richard person_id | 5 favorite_number | 10 (20 rows)
hstore can be used as a convenient mechanism for audit trail
http://www.sqlfiddle.com/#!1/d5729/1
Saturday, November 24, 2012
Detect kissing and overlapping points in Highcharts
formatter: function() {
// console.log(this);
// Michael Buen is here
var search = this.series.chart.series[0].data;
var a = this.point;
var overlapCount = 0;
for(var i in search) {
var b = search[i];
var d = getDistance(a, b);
// choose an overlap threshold
var kiss = 5 * 2;
var halfOverlap = 5;
var fullOverlap = 2.5;
if (d <= kiss) {
++overlapCount;
}
}
return this.x +' cm, '+ this.y +' kg' + a.plotX + ' <br/><b>Overlaps:</b> ' + overlapCount;
}
function getDistance(point1,point2)
{
var xs = 0;
var ys = 0;
xs = point2.plotX - point1.plotX;
xs = xs * xs;
ys = point2.plotY - point1.plotY;
ys = ys * ys;
return Math.sqrt( xs + ys );
}
Live code: http://jsfiddle.net/HxTjK/
Subscribe to:
Comments (Atom)