Saturday, 15 September 2012

colors - pdfbox table header colouring not working properly -



colors - pdfbox table header colouring not working properly -

i usind pdfbox , trying colour header of table; had done table drawing correctly using tutorial ' http://fahdshariff.blogspot.in/2010/10/creating-tables-with-pdfbox.html'

the code follows

//draw rows float nexty = y ; (int = 0; <= rows; i++) { contentstream.drawline(margin, nexty, margin+tablewidth, nexty); nexty-= rowheight; } //draw columns float nextx = margin; (int = 0; <= cols; i++) { contentstream.drawline(nextx, y, nextx, y-tableheight); nextx += (colwidths != null) ? colwidths[i] : colwidth; }

i got code colouring follows:

contentstream.setnonstrokingcolor( color.red ); contentstream.fillrect( 10, 10, 100, 100 );

i tried set not working needed. need colour table header only. how can acheive that. please help me guys!!

table colors pdfbox

php - Is it efficient to change cookies and save them into database per request? -



php - Is it efficient to change cookies and save them into database per request? -

i utilize dynamically changing cookies in order maintain user logged in. illustrate, after successful login, login command function saves user session info rememberme table , creates cookies info. info kept in server user_id, key , expiration_date. if user having valid cookie (namely user_id, key , expire time within cookies match info stored in rememberme table) tries access user-only accesible page, server creates new cookie different key, , default-period expiration time , updates info within rememberme table. cycle goes on way. so, user valid cookie maintains logged in , extends session expiration time every request page. question is, how much efficient implement such session management style. create burden server , database?

fyi, utilize php/mysql in amazon ec2 micro windows server development.

why not utilize php sessions? designed tasks this.

http://php.net/manual/en/book.session.php

php mysql session cookies

android - Sending an email using javamail without user interaction - java.net.ConnectException -



android - Sending an email using javamail without user interaction - java.net.ConnectException -

hello attempting create android application sends emails without need user interaction (the user informed of emails beingness sent). using javamail: http://code.google.com/p/javamail-android/downloads/list , next example: http://www.jondev.net/articles/sending_emails_without_user_intervention_%28no_intents%29_in_android getting next errors:

10-07 09:23:10.373: e/mailapp(9173): not send email 10-07 09:23:10.373: e/mailapp(9173): javax.mail.messagingexception: not connect smtp host: localhost, port: 25; 10-07 09:23:10.373: e/mailapp(9173): nested exception is: 10-07 09:23:10.373: e/mailapp(9173): java.net.connectexception: failed connect localhost/127.0.0.1 (port 25): connect failed: econnrefused (connection refused) 10-07 09:23:10.373: e/mailapp(9173): @ com.sun.mail.smtp.smtptransport.openserver(smtptransport.java:1391) 10-07 09:23:10.373: e/mailapp(9173): @ com.sun.mail.smtp.smtptransport.protocolconnect(smtptransport.java:412)

code sending email:

thread emailsendthread = new thread(new runnable() { @override public void run() { while (true) { seek { thread.sleep(100); } grab (interruptedexception e1) { // todo auto-generated grab block e1.printstacktrace(); } if (sendemail == true) { seek { mailsender m = new mailsender("firstname.surname@gmail.com", "password"); string[] toarr = {"example@email.com"}; m.setto(toarr); m.setfrom("firstname.surname@gmail.com"); m.setsubject("this email sent using mail service javamail wrapper android device."); m.setbody("email body."); seek { m.send(); if(m.send()) { toast.maketext(mainactivity.this, "email sent successfully.", toast.length_long).show(); } else { toast.maketext(mainactivity.this, "email not sent.", toast.length_long).show(); } } catch(exception e) { //toast.maketext(mailapp.this, "there problem sending email.", toast.length_long).show(); log.e("mailapp", "could not send email", e); } } grab (exception e) { log.e("email", "error", e); } seek { thread.sleep(100); } grab (interruptedexception e) { // todo auto-generated grab block e.printstacktrace(); } sendemail = false; } } } });

i have substituted email username , password illustration ones in code. send email execute sendemail = true;

you can send mails using smtp server. if smtp server not @ device running application, need provide address of smtp can send email. expected application not send email if smtp details not correct.

android email gmail javamail javax.mail

javascript - 'unsafe-eval' on chrome extension -



javascript - 'unsafe-eval' on chrome extension -

i trying run following:

chrome.tabs.oncreated.addlistener(function (tab){ if (tab.url.indexof(".salesforce.com/") != -1 || tab.url.indexof(".force.com/") != -1) { chrome.tabs.executescript(tab.id, { "file": "loadscript.js" }, function () { console.log("script executed .. "); }); } else { var wrongtab = chrome.i18n.getmessage("wrongtab"); console.log(wrongtab); alert(wrongtab); } });

which should (in theory), on page load run loadscript.js file.... loadscript.js file follows, should append file running page, not background page @ moment:

/* create scriipt element in head of html , set /soap/ajax/31.0/connection.js in src */ var connectjsurl = "/connection.js"; function loadscript(url, callback) { var head = document.getelementsbytagname("head")[0]; var script = document.createelement("script"); script.src = url; var done = false; script.onload = script.onreadystatechange = function() { if (!done && (!this.readystate || this.readystate == "loaded" || this.readystate == "complete")) { done = true; callback(); script.onload = script.onreadystatechange = null; head.removechild(script); } }; head.appendchild(script); } loadscript(connectjsurl, function() { console.log("script confirmed...") }); /* check see if file have been appended correctly , works correctly */ var jsfile = "chrome-extension://" + window.location.host + connectjsurl; var req = (window.xmlhttprequest) ? new xmlhttprequest() : new activexobject("microsoft.xmlhttp"); if (req == null) { console.log("error: xmlhttprequest failed initiate."); }; req.onload = function() { seek { eval(req.responsetext); } grab (e) { console.log("there error in script file."); } }; seek { req.open("get", jsfile, true); req.send(null); } grab (e) { console.log("error retrieving info httpreq. browsers take cross-domain request http."); };

i still newbie chrome extensions , .js excuse me if have made stupid error :)

all getting following: refused evaluate string javascript because 'unsafe-eval' not allowed source of script in next content security policy directive: "script-src 'self' chrome-extension-resource:".

to prevent cross site scripting google has blocked eval function.

to solve add together code manifest.json

"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"`,

please comment if need farther explanation

javascript google-chrome-extension

graph databases - How to realize a nested tree in Neo4j? -



graph databases - How to realize a nested tree in Neo4j? -

i getting started neo4j , graph databases , wondering if nested hierarchical trees utilize case neo4j. mutual illustration nested set of comments. example:

- article - comment 1 on article - comment 2 on comment 1 - comment 3 on comment 1 - comment 4 on comment 3 - comment 5 on article

as understand it, article , comments each nodes. , each comment have parent-child relationship. getting direct comments on article (1 , 5) easy. how retrieving whole set?

please excuse utilize of layman terms. figured improve way trying utilize appropriate words while confusing everyone.

well, because trees graphs using graph database store tree seems exclusively appropriate me. perform best depend on info access patterns, trees specialization of graphs.

yes, in case "elements in tree" nodes, , "nesting" relationships. here's how might mock example:

create (root:article {label: "article"}), (c1:comment {label: "comment 1"}), (c1a:comment {label: "comment 2 on comment 1"}), (c1b:comment {label: "comment 3 on comment 1"}), (c1b1:comment {label: "comment 4 on comment 3"}), (c2:comment {label: "comment 5 on article"}), (root)<-[:reply]-(c1), (c1)<-[:reply]-(c1a), (c1)<-[:reply]-(c1b), (c1b)<-[:reply]-(c1b1), (root)<-[:reply]-(c2);

this creates bunch of nodes , relationships, mimicking construction provided. here i've chosen utilize :reply connect things.

now, "getting everything" means traversing of :reply relationships created:

match p=(a:article {label: "article"})<-[:reply*1..]-(otherthing) nodes(p) nodes homecoming nodes[length(nodes)-2] inresponseto, nodes[length(nodes)-1] commentorreply;

what query traverse number of :reply links (starting root "article"). looks @ nodes in path, , returns lastly item (commentorreply) , in response (the sec lastly item).

the result looks this:

+-------------------------------------------------------------------------------------+ | inresponseto | commentorreply | +-------------------------------------------------------------------------------------+ | node[18]{label:"article"} | node[19]{label:"comment 1"} | | node[19]{label:"comment 1"} | node[20]{label:"comment 2 on comment 1"} | | node[19]{label:"comment 1"} | node[21]{label:"comment 3 on comment 1"} | | node[21]{label:"comment 3 on comment 1"} | node[22]{label:"comment 4 on comment 3"} | | node[18]{label:"article"} | node[23]{label:"comment 5 on article"} | +-------------------------------------------------------------------------------------+

so that's how traverse entire tree.

edit - it's worth, "variable length path matching", in query above bit: <-[:reply*1..]- me 1 of top 3 selling points graph database. it's exactly graph dbs create easy, of other alternatives relational create tortuously painful exercise. if need sort of thing (like here, assembling entire tree) claim argues graph db because you're using in area of fundamental strength.

neo4j graph-databases

javascript - AngularJs filter:$viewValue is not handling html escaping -



javascript - AngularJs filter:$viewValue is not handling html escaping -

if type in box, you'll see:

alabama missing text in bracket alaska fine arizona displays fine 1 time selected shows &lt; , &gt;

any thought on how prevent filter sanitizing or (best) utilize proper encoding , decoding of html characters?

http://jsfiddle.net/zjpwe/64/

<div class="container"> <div ng-controller="mainctrl" class="row-fluid"> <form class="row-fluid"> <div class="container-fluid"> <input type="text" ng-model="selected" typeahead="state state in states | filter:$viewvalue" /> </div> </form> </div> </div>

...

angular.module('myapp', ['ui.bootstrap']) .controller("mainctrl", function ($scope) { $scope.selected = ''; $scope.states = ['alabama <where this>', 'alaska [this ok]', 'arizona &lt;select me&gt;']; });

one not-so-beautiful way solve issue apply filters sanitize array elements, , unsanitize them when selected.

http://jsfiddle.net/pwu0r81m/

$scope.$watch('selected', function() { $scope.selected = $scope.selected.replace(new regexp('&lt;', 'g'), '<').replace(new regexp('&gt;', 'g'), '>'); }); angular.module('myapp') .filter('sanitizer', function(){ homecoming function (items) { var filtered = []; angular.foreach(items, function(item){ filtered.push(item.replace(new regexp('<', 'g'), '&lt;').replace(new regexp(">", 'g'), "&gt;")); }); homecoming filtered; } });

javascript angularjs

php - Script does not work, shows no errors -



php - Script does not work, shows no errors -

i made little script 'cache' copies of websites, , far can tell appears coded fine, when run in browser, not work , shows no errors.

my code:

<?php //display errors please error_reporting(e_all); ini_set('display_errors', 1); //get random string $length = 5; $string = ""; $characters = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789"; //thanks code stackoverflow while ($length > 0) { $string .= $characters[mt_rand(0,strlen($characters)-1)]; $length -= 1; } $random = $string //get url request if(isset($_get['link'])) { $link = $_get['link']; $data = file_get_contents("http://$link"); //send info html file file_put_contents("/cache/$random.html","$data"); echo "cached successfully.<br>link: http://example.com/cache/$random.html"; } ?>

there syntax error in code posted,

$random = $string

should be

$random = $string;

its thought check php files errors after edit them. 1 way (if on linux/unix system) run php command

php -l filename.php

you utilize online compiler (what did code)

http://writecodeonline.com/php/

php