Posts

java - dofilter not giving pdf as output on response -

i trying show pdf output on browser. here code in dofilter class of servlet. getting byte array renders pdf correctly on line --> byte[] pdfarray = pdfconverter.converttodoc(bytes); see pdf file saved in --> file somefile = new file("c:\\log\\java2.pdf"); it's not outputting on servletresponse, mixed characters show up. appreciated. please inside dofilter method. have pdfconverter take whole site byte array , convert pdf. import java.io.bytearrayoutputstream; import java.io.ioexception; import java.io.printwriter; import javax.servlet.filter; import javax.servlet.filterchain; import javax.servlet.filterconfig; import javax.servlet.servletexception; import javax.servlet.servletoutputstream; import javax.servlet.servletrequest; import javax.servlet.servletresponse; import javax.servlet.writelistener; import javax.servlet.http.httpservletresponse; import javax.servlet.http.httpservletresponsewrapper; import org.slf4j.logger; import org.slf4j.loggerfactory; ...

java - Iterating over a json array of arrays -

i have json array comes this [{"item":"value"},{"item":"value"},{"item":"value"},{"item":"value"}] i attempting loop on array , grab "item" code such below, value never grabbed, can confirm array have values somehow returns null arraylist<arraylist<object>> mainlist = new arraylist<arraylist<object>>(); string json = getjson(url, null); jsonobject jsonobject = null; try { jsonobject = new jsonobject(json); int counter = 0; jsonarray itemarray = new jsonarray(); itemarray.put(jsonobject); while(counter < itemarray.length()){ //create inner array arraylist<object> innerlist = new arraylist<object>(); //grab contents of post jsonobject item = itemarray.getjsonobject(counter); //place items inner array innerlist.add(co...

java - Zigzag conversion -

question : string "paypalishiring" written in zigzag pattern on given number of rows this: (you may want display pattern in fixed font better legibility) p h n p l s i g y r and read line line: "pahnaplsiigyir" i have written below code, appearantly works fine, might miss corner cases. me find corner cases question on answer? public static string zigzagconversion(string s , int rownum){ if (s == null){ throw new illegalargumentexception(); } if (rownum == 1){ return s; } stringbuilder str = new stringbuilder(); int step = 2 * rownum - 2 ; (int = 0 ; < rownum ; i++){ if( == 0 || == rownum -1){ (int j = ; j < s.length() ; j +=step){ str.append(s.charat(j)); } } else{ int step2 = 2* (rownum - - 1); int step3 = step - step2; int k = i; boolean fla...

javascript - Display multiple markers, variable and array problems -

i try display multiple markers on map. put multiples location in adata-attribute trough php file. try grab information in javascript one. if directly paste coordinates, markers appear. if reference data-attribute don't. (the difference on line beginning var locations .) this code works: function googlemapsinit(){ settimeout(function initialize() { var emplacements = $('#iframecarte').attr("data-emplacements"); // emplacements returns [[45.5314817,-73.1835154], [45.570004,-73.448701] ] var mapoptions = { zoom: 12, center: new google.maps.latlng(45.5580421, -73.7303025) }; var map = new google.maps.map(document.getelementbyid('map-canvas'), mapoptions); var locations = [[45.5314817,-73.1835154], [45.570004,-73.448701] ]; var marker, i; var markers = new array(); (i = 0; < locations.length; i++) { marker = new google.maps.marker({ position: new google.maps.latlng(locations[i][...

html - Font appears thinner in Firefox and Safari - fine in Chrome -

i'm trying font reasonably same across mac chrome, safari , firefox (will move on ie later). i've been playing with: -webkit-font-smoothing: subpixel-antialiased; the font looks same, safari , firefox looks @ least 1 weight thinner. i have tried: -webkit-font-smoothing: antialiased; and ff: -moz-osx-font-smoothing: grayscale also have on: text-rendering: optimizelegibility !important; this gets fonts pretty same it's not smooth subpixel antialiased. am missing property here? know not going 100% same across browsers think chrome , safari being both webkit browsers same. i'm using raleway google fonts if that's help. maybe font-weight light or lighter in code try changing font-weight normal font-weight:normal; or font-weight:400;

python - concatenate elements of list with PIPE Delimiter -

i require on below code. code following. execute sql query , output of sql query mix of strings,int , date. ie 10001,new york,corp,1,20151001 10002,new york,corp,1,20151001 etc. the expectation want concatenate each record of sql output , write file. 10001|new york|corp|1|20151001\n 10002|new york|corp|1|20151001\n below code. import cx_oracle import os result = cur.execute(qry) # -> execute sql query. le.extend(result) # output of le , le -> type list le = [(10001,u'new york','corp',1,20151001),(10002,u'new york','corp',1,20151001)] final_data = [] final_data.extend('|'.join(w) w in le) getting error above statement. typeerror: sequence item 1: expected string or unicode, int found i tried this final_data.extend('|'.join(str(w)) w in le) but not getting desired output, 10001|new york|corp|1|20151001\n highly appreciate if on this. thanks, bala final_data = ["|".join(map(unico...

jquery - Weird output with packery used to randomly position div -

i'm having trouble inserting div (ad banner) randomly within bunch of other divs. i found working example i'm using question: insert div in random location in list of divs however, template being inserted within 1 of items/children, rather it's outer container/target. here's html: <div class="template" style="display: none;"> <a class="item advertisement"> <div class="item-inner-wrapper"> <img alt="image" src="http://placehold.it/525x765"> </div> </a> </div> <div class="listings"> <a class="item card" href="#"> <div class="item-inner-wrapper"> <img alt="" src="http://placehold.it/525x765"> </div> </a> <a class="item card" href="#"> <div class="i...