Posts

php - Join tables from different databases using doctrine symfony2 -

i found can define different database connections doctrine in symfony2 so, want know if possible execute query join using tables different databases, have been trying without success far.

Django: Display DB data to only logged in users with multiple filters -

Image
i have db table below. url display db data is url(r'^editinvoice/(?p<pk>\d+)/$',views.edit_invoice,name='editinvoice'), template.html code redirects page is <a href="{% url "editinvoice" pk=invoices.id %}">{{ invoices.invoice_number }}</a></td> invoices.id foreign key of above db table. the link passes correct pk , details correctly displayed. if change id in url, can see information if not user related it. should done information should available logged in user if user if owner of it. for views method edit_invoice , use @login_required decorator. in method raise 403 error: from django.core.exceptions import permissiondenied def edit_invoice(request, pk): invoice = invoice.objects.get(pk=pk) if invoice.user != request.user: raise permissiondenied see django docs @login_required . also see django doc permissiondenied . edit: yea having "does not exist" makes more s...

to evaluate polynomial in Haskell -

i have function( eval ) evaluate polynomial. eval coeffs value = ....... coeffs list of coefficents. value x in math ex) calculate 3x^2 + 2x + 1 x=20 coeffs stored reverse order. when type coefficient above, stored [1,2,3] program working , last part wrong (the value of polynomial): here code getcoeff 0 ls = return ls getcoeff n ls = putstr "what x^" putstr (show(n-1)) putstr " coefficient: " v <- getline w <- getcoeff (n-1) ((read v :: float):ls) return w evalpoly = putstr "what degree of polynomial: " v <- getline l <- (getcoeff ((read v :: int)+1) []) putstr "what value want evaluate at: " x <- getline putstr "the value of polynomial is: " putstr (show (polyevaluate (l) (read x :: float))) putstr "\n" eval [] x = 0.0 eval (l) x = what degree of ...

twitter - Tweeting Images Programatically -

i have business requirement project i'm working on allow users print, email , share image on facebook , twitter. first 3 simple whereas i'm finding impossible find succinct example of how post tweet image using client side scripting. i've seen various solutions using twitter api , of them php based. surely can't difficult. any appreciated. this example uses twitterapi python library. from twitterapi import twitterapi tweet_text = 'some tweet text' image_path = './some_image.png' consumer_key = '' consumer_secret = '' access_token_key = '' access_token_secret = '' api = twitterapi(consumer_key,consumer_secret,access_token_key,access_token_secret) # step 1 - upload image file = open(image_path, 'rb') data = file.read() r = api.request('media/upload', none, {'media': data}) print('upload media success' if r.status_code == 200 else 'upload media failure') # step 2...

networking - Detect a captive portal on iOS -

so i'm able detect whether or not user has basic internet connection fine using apple's reachability class. however, when try detect whether or not connected wi-fi network utilizes captive portal, networkstatusreachableviawifi , makes sense. however, returned if user using wifi connection. i need able detect both no internet connection , captive portal situation, no internet. are there reliable api's can accomplish task? based off article, http://blog.erratasec.com/2010/09/apples-secret-wispr-request.html#.vxkmrjmriy5 , apple pings internal address when connect wifi check captive portal. i'd prefer avoid pinging outside networks, if must, know how ping same apple address , use response tell if user has captive portal up? edit: i've come across nsurlconnectiondelegate , method connection:willsendrequestforauthenticationchallenge: . think method may able need, can send basic request www.google.com , make myself delegate, , if method gets hit need do. think ...

java - Spring RestTemplate unable to get JSESSIONID cookie -

in spring boot/spring security application i'm trying login spring resttemplate. this code: final keystore keystore = keystore.getinstance("pkcs12"); keystore.load(new fileinputstream(new file("keystore.p12")), "changeit".tochararray()); final sslcontext sslcontext = new sslcontextbuilder().loadtrustmaterial(null, new trustselfsignedstrategy()).loadkeymaterial(keystore, "changeit".tochararray()).build(); final sslconnectionsocketfactory socketfactory = new sslconnectionsocketfactory(sslcontext, noophostnameverifier.instance); final httpclient httpclient = httpclientbuilder.create().setsslsocketfactory(socketfactory).setredirectstrategy(new laxredirectstrategy()).build(); final clienthttprequestfactory requestfactory = new httpcomponentsclienthttprequestfactory(httpclient); final resttemplate resttemplate = new resttemplate(requestfactory); final httpheaders headers = new httpheaders(); headers.add("cookie...

java - Looking for a way to replace a string from a pdf by retaining the formatting -

i have 2 static pdfs. second pdf having few place holders.at runtime replacing place holders strings application property file.finally append second pdf first pdf. formatting lost while doing it.please see code below, private void appendpdf() throws documentexception, ioexception { //source pdf pdfreader reader_glossary = new pdfreader(gloosary); pdfstamper stamper = new pdfstamper(reader_glossary, new fileoutputstream(dest)); //adding new page in end of src pdf stamper.insertpage(reader_glossary.getnumberofpages() + 1, reader_glossary .getpagesizewithrotation(1)); pdfcontentbyte srccbytes = stamper .getovercontent(reader_glossary.getnumberofpages()); pdfreader readerout = new pdfreader(src); pdfreadercontentparser parser = new pdfreadercontentparser(readerout); textextractionstrategy strategy = parser.processcontent(1, new locationtextextractionstrategy()); string data = new string(strategy.getresultantt...