Posts

GET request using ajax v java -

i'm writing simple web application completes 1 request custom headers. when tried making request using ajax, gave me cross domain error so: no 'access-control-allow-origin' header present on requested resource. origin 'http://localhost:8080' therefore not allowed access. when make same request in java using custom headers, works fine. public static string executeget() { string response = ""; try { url url = new url("http://...."); httpurlconnection con = (httpurlconnection) url.openconnection(); con.setrequestmethod("get"); //set custom headers con.setrequestproperty("header1", "2.0"); con.setrequestproperty("header2", "sellingv2"); con.connect(); inputstreamreader reader = new inputstreamreader(con.getinputstream()); scanner scanner = new scanner(reader); while (scanner.hasnext()) { ...

c# - Does SqlBulkCopy Enlist in Ambient Transaction? -

i can't seem find definitive answer on this. have sqlbulkcopy operation wrapped in transactionscope number of other operations. i aware of overloads in sqlbulkcopy constructor allow passing sqltransaction object. assuming not passing transaction in constructor, command automatically participate in ambient transaction created transactionscope? i've done testing, , appears sqlbulkcopy does, in fact, honor ambient transaction, @ least in .net 4.5. to test, did sqlbulkcopy operation while debugging, , verified rows made database (via nolock/dirty read query). threw exception on next line of code, , allowed transactionscope roll back. verified rows no longer in database.

c# - Check if image is on pdf using iTextsharp -

i working on trying make little console application can tell difference between blank page, , page 1 image on , no text. blank page i'm using itextsharp's simpletextextractionstrategy() , works great blank pages. problem pages image on them considered blank method well. there way know if pdf has image on similar way checking text on pages?

javascript - Add attribute to an object -

Image
how can change attribute of tag in html code given object? currently, if do: console.log(gallery.curritem); i get: so did: console.log(gallery.curritem.html); and html in console (not object, believe it's texy): <video width="500" height="250" controls><source src="" type=""></video> but i'm not sure how edit video tag adding attribute muted="muted" . i tried: console.log($(gallery.curritem.html).find('video')); but returned object again. :/ i assume using photoswipe. gallery.curritem.html not string actual html element. can directly edit attributes of it: gallery.curritem.html.setattribute("muted", "muted"); to make sure it's actual element, if in question, this: if(gallery.curritem.html.tagname) { gallery.curritem.html.setattribute("muted", "muted"); } else { // append dom or wrap jquery , set attributes ...

java - LibGDX Tiled Map Collision Detection with Property and Layers -

i building simple top down rpg game libgdx haven't found precise pointers on how detect collision on tiled map. i have character class looks this public class son{ spritebatch batch; texture texture; sprite sprite; private tiledmaptilelayer collisionlayer; public son(float x, float y, tiledmaptilelayer collisionlayer){ this.collisionlayer = collisionlayer; batch = new spritebatch(); texture = new texture(gdx.files.internal("characters/xter1.png")); sprite = new sprite(texture); sprite.setx(x); sprite.sety(y); } public void render(){ processkeys(); batch.begin(); sprite.draw(batch); batch.end(); } private void processkeys(){ if(gdx.input.istouched()){ //gdx.app.exit(); gdx.app.log("x touched", gdx.input.getx() + ""); gdx.app.log("y touched", gdx.input.gety() + "...

kafka log deletion and load balancing across consumers -

say consumer time intensive processing. in order scale consumer side processing, spawn multiple consumers , consumer messages kafka topic in round robin fashion. based on documentation, seems if create multiple consumers , add them in 1 consumer group, 1 consumer messages. if add consumers different consumer groups, each consumer same message. so, in order achieve above objective, solution partition topic ? seems odd design choice, because consumer scalability bleeding topic , producer design. ideally, if topic not partitioning, there should no need partition it. puts un-necessary logic on producer , causes other consumer types consume these partitions may make sense 1 type of consumer. plus limits usecase, consumer type may want ordering on messages, splitting topic partitions may not possible. second if choose "cleanup.policy" compact, mean kafka log keep increasing maintain latest value each key? if not, how can log deletion , compaction? update: seems have 2 opti...

Eloquent Javascript, listToArray. Why does my for loop return rest [object] when input array has more than 3 elements -

i'm working through eloquent javascript chapter 4. exercise asks write function arraytolist builds data structure previous 1 when given [1, 2, 3] argument using code below can necessary output - when number of elements in array 3 or less. function createnode (value, rest) { return { value: value, rest: rest } }; function arraytolist(arr) { var index = arr.length; firstnode = createnode(index,null); listbuild = firstnode; (i =(index-1); >0; i--) { listbuild = createnode(i,listbuild) } question arraytolist([1,2,3]) produces desired result of "{ value: 1, rest: { value: 2, rest: { value: 3, rest: null } } }" arraytolist([1,2,3,4]) produces output of "{ value: 1, rest: { value: 2, rest: { value: 3, rest: [object] } } }" why function generate rest property of [object] in case? thanks! your function seems work fine, suspect output issue, not problem code. if you're using node.js test code, you've run g...