Posts

html - How to open UIWebView from another UIWebView? -

Image
i have web view @ bottom of 1 of view controllers contains links. want when user clicks on 1 of links in web view opens web view takes screen with content of page user has clicked on. or maybe when user clicks on 1 of links in web view, user taken safari display content of link. know how this? cheers. above screen shot of web view links user can click on.. try this: -(bool)webview:(uiwebview *)webview shouldstartloadwithrequest:(nsurlrequest *)request navigationtype:(uiwebviewnavigationtype)navigationtype; { nsurl *requesturl =[ request url ]; if ( ( [ [ requesturl scheme ] isequaltostring: @"http" ] || [ [ requesturl scheme ] isequaltostring: @"https" ] || [ [ requesturl scheme ] isequaltostring: @"mailto" ]) && ( navigationtype == uiwebviewnavigationtypelinkclicked ) ) { return ![ [ uiapplication sharedapplication ] openurl: requesturl] ; } return yes; }

apache - Why should we keep index.php in the public folder instead of in the root? -

Image
i still don't quite understand why must keep index.php in public directory instead of in root directory. root/of/project public/ index.php .htacess (html, image, css, etc) then, write following in our virtual host file: documentroot /path/to/myapp/app/public <directory "/path/to/myapp/app/public"> # other setting here </directory> the .htaccess file redirects non-existing urls index.php: rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [qsa,l] i notice frameworks so, such symfony , zend, this tutorial. actual benefits having trouble of modifying virtual host file? why shouldn't have below instead without modifying virtual host file? security risk or something? root/of/project index.php .htacess public/ (html, image, css, etc) if keeping index.php , modifying virtual host file better, how can modify virtual host file i...

java - Does Glassfish server consist of a webserver also? -

according defintions have read web server can serve http requests (e.g apache). a web container can serve servlets , jsps etc. since tomcat can both serve http requests , serve servlets , jsps considered both web server , web container. application servers jboss, glassfish fledged java ee servers include other containers apart web container. now in order application server glassfish work on own, needs web server(an http server) built it. therefore should contain webserver work on won, , if doesn't contain webserver built it, there should way plug existing web servers apache application server. what actual implementation? include webserver or should plug webservers these java ee application servers? yes, includes full web tier. java servlet spec covers of this.

java - My CSS stopped working -

i have problem css file haven't been able solve while. i'm relatively new in java web technologies , have no clue could've caused that. i'm trying write mvc based application servlets work controllers, jsp's views , database model. homecontroller supposed retrieve names of categories database , forward view (home.jsp). works fine, can display categories in view since i've implemented homecontroller css file have stopped working. ended working controller , awfull view. have no idea problem is. here's significant files: web.xml: <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="webapp_id" version="3.0"> <context-param> <param-name>databaseurl</param...

JDBC SQL Server Exception: java.lang.NumberFormatException -

i using minecraft jdbc logging plugin (logblock), automatically parses inputs server name, login, password, , port valid jdbc command. have set server , user using microsoft sql server express 2014 , tested login using this method , told me succeded. can assume error in parsing of inputs. find way not have change source code of plugin, instead edit inputs trick plugin parsing correctly. here's code give plugin: mysql: host: bob\sqlexpress database: minecraft password: testest12/345 user: skrublord9000 port: 3306 bob computer name, sqlexpress server name. can't think it's backwards slash that's causing problem. here's output of jdbc plugin: [logblock] connecting skrublord9000@jdbc:mysql://bob\sqlexpr ess:3306/minecraft?useunicode=true&characterencoding=utf-8... [logblock] error while fetching connection: com.mysql.jdbc.exceptions.jdbc4.mysqlnontransientconnectionexception: cannot loa d connection cl...

using HTML div and CSS -

so, html code <head lang="en"> <meta charset="utf-8"> <title>test</title> <link rel="stylesheet" href="style.css" type="text/css"> </head> <body> <div> <div class="header"> <input name="1" value="1" disabled /> </div> </div> and css-file: .header { background-color: yellow; color: green } the problem have, css code isn't changing html, made quick test , put css code in html file , worked. i know that, if use "id" insead of "class" works, task not change html file my problem don't want css code in html file, possible? edit: tried online worked, seems problem of webstorm since set in html file: <link rel="stylesheet" href="style.css" type="text/css"> your style.css file must in same folder html file. also, ;...

android - BluetoothAdapter variable not being found? -

Image
hello working on android ble project , running problem can't check if bluetoothadapter variable null? why that. should straight forward? did forget import something?

java - How can i add classes to classpath with gradle? -

i had spring mvc project xml configurations base, , change java code ones. problem is, have applicationcontexttest there specifics configurations test. when run gradle test fail error: /home/karim/workspace/spring-project/src/test/java/org/my-com/my-project/services/phoneservicetest.java:13: error: package config not exist import config.applicationcontexttest; ^ /home/karim/workspace/spring-project/src/test/java/org/my-com/my-project/services/phoneservicetest.java: error: cannot find symbol @contextconfiguration(classes=applicationcontexttest.class) ^ i think understand error means, there no config package in classpath right? the applicationcontexttest class @ src/test/resources/config . how can fix this? the resources folder for... resources (images, properties files, etc.). source files go in src/test/java .

c# - Width of control based on width of window -

i'm trying figure out, how write responsive ui in xaml. i have 2 controls on window. minwidth of each control id 400. if width of windows >800, width of each control should 50%, if change widht of window <800, each control should have 100% of window. it's pretty simple set html/css, , right i'm trying in wpf without progress. can me that? i tried handle wrappanel, not work. wraps properly, not change width of control. i have 2 ideas doing this: using binding converter, , bind width/height of each item container width/height. creating custom panel, de desired layout. only few ideas, hope helps.

ios - Cannot invoke 'init' with argument of type 'NSNumber' (Swift) -

i trying use 'weights' array fill graph below fetch request. getting error "cannot invoke 'init' argument of type 'nsnumber' , have no idea why. 'weights' array should array of uint16. var weights : [int16] = [] func weightfetchrequest() -> nsfetchrequest { let appdelegate = uiapplication.sharedapplication().delegate appdelegate let managedcontext = appdelegate.managedobjectcontext! let fetchrequest = nsfetchrequest(entityname: "assessment") fetchrequest.sortdescriptors = [nssortdescriptor(key: "nsdateofassessment", ascending: true)] var error: nserror? let fetchedresults = managedcontext.executefetchrequest(fetchrequest, error: &error) [assessment]? if let assessments = fetchedresults { let weightss = assessments.map { assessment in assessment.weight } weights = weightss println(w...

php - Symfony is changing where it's looking for assets depending on url -

Image
symfony looks looking assets in relative location based on url path navigate to. assets load , applied correctly when navigate "first-level" path such example.com/mpre , example.com/test , example.com/foo , of assets 404 when navigate "second-level" url such example.com/mpre/test , example.com/test/foo , example.com/foo/bar . why this? there way framework in 1 spot assets regardless of url? i have 2 urls example.com/mpre example.com/mpre/test my assets (css, js) load fine on first url, example.com/mpre , of them 404 when navigate second url, example.com/mpre/test when go inspector on each page see path assets, see following: example.com/bundles/app/css/023f7f6_style.css_4.css //example.com/mpre 200 ok response example.com/mpre/bundles/app/css/c8b625f_style.css_3.css //example.com/mpre/test 404 not found response in config.yml have following line assetic: assetic: write_to: %kernel.root_dir%/../web/bundles/app/ additional inf...

What should a C# object initializer for a Dictionary<string, string[]> look like? -

i trying declare dictionary values string arrays. how can this? i tried following code (which not work): dictionary<string, string[]> newdic = new dictionary<string,string[]> { {"key_0", {"value_0.0", "value_0.1"}}, {"key_1", {"value_1.0", "value_1.1", "value_1.2"}}, } you need specify values arrays like: using implicitly typed array {"key_0", new[] {"value_0.0", "value_0.1"}}, or explicitly specifying type {"key_0", new string[] {"value_0.0", "value_0.1"}}, so class like: public static class newclass { private static dictionary<string, string[]> newdic = new dictionary<string, string[]> { {"key_0", new[] {"value_0.0", "value_0.1"}}, {"key_1", new string[] {"value_1.0", "value_1.1", "value_1.2"}}, };...

r - Can I lag daily data by months with lag ( )? -

i have daily data on several years several currencies. lag variables in data set 1 month (i.e. june 15 july 15, not 30 days). na's fine not possible. i have gotten far writing this: ddply(data, .(currency), function(x){ #first column date, 2nd currency, rest data. y=x[,-(3)] #this data want lagged y$date=as.date(y$date) %m+% months(1) #this increases dates 1 month x$date=as.date(x$date) #what data dont want lagged x[, (1:3)] below z=merge(x[,(1:3)], y, by=c("date", "currency")) #merge date, #lagged stuff merges non-lagged stuff 1 month later original obs date return(z) }) i can include data if necessary, given have works dont want spend time on it. i want check cant use lubridate %m+% months(1) syntax within lag function. have tried lag function package "statar" uses along_by syntax haven't been able figure out. thanks!

c# - WCF Service - Message / Object size related -

Image
i have wcf service (s1) client , wcf service(s2) server. s1 consume s2 on net.tcp. s2 has 1 operation, return complex object of it's contents string. average size of object between 7-8 mb. recently had add more string contents actual object graph. cause s2 return following error the socket connection aborted. caused error processing message or receive timeout being exceeded remote host, or underlying network resource issue. local socket timeout '00:05:00'. system.net.sockets.socketexception (0x80004005): existing connection forcibly closed remote host @ system.net.sockets.socket.receive(byte[] buffer, int32 offset, int32 size, socketflags socketflags) @ system.servicemodel.channels.socketconnection.readcore(byte[] buffer, int32 offset, int32 size, timespan timeout, boolean closing) however, works expected when remove of string contents object graph. after doing bit of homework,i managed land on conclusion that, has size of returned obje...

Best C++ macro for creating a new scope -

i have macro #define scope_guard(guard, name, ...) \ for(bool __once = true; __once; /* nothing */) \ for(guard name (__va_args__); __once; __once = false) using this: scope_guard(std::unique_lock, lock, (some_mutex)) do_some(); or scope_guard(std::unique_ptr<char>, buff, (new char[buffer_size])) { *buff.get() = 0; getsomedescription(buff.get(), buffer_size); log(buff.get); } are there similar(better) implementation of macro, optimized multiple compilers correctly. p.s. macro should one, without macro boost_scope_exit_end (can redefine if (...) ) . edit simple scoupe in using codestyle huge. { std::unique_lock lock (some_mutex); do_some(); } but want using this scope_guard(std::unique_lock, lock, (some_mutex)) do_some(); you can awful lot c++ templates , lambda expressions. might worthwhile explore using them. example, instead of using scope_guard macro, this: template <typename g, typename f, typename... a> inl...

What is the equivalent of Python's list[:x] in C++? -

in python, if have list l , want first x elements of it, call l[:x]. in c++, use vectors instead, don't know of easy way invoke first x elements of vector. there several ways: 1) create vector v consisting of first x elements as: std::vector<t> v { begin(l), begin(l) + x }; 2) pass first x elements function, pair of iterators: f(begin(l), begin(l) + x); where f accepts 2 iterators arguments — explore standard algorithms <algorithm> , of them work on pair of iterators. depending on use case, use of them.

How to consume a Chunked HTTP Stream with Apache Camel? -

i have issue consuming chunked http rsvp stream using camel. the stream here , can find more information @ end of this page i have created simple route such: from("http4://stream.meetup.com/2/rsvps").log(org.apache.camel.logginglevel.info, "meetupelasticsearch.log", "json rsvp ${body}") but nothing happens no message consumed. tried adding camel timer before because not sure can use http4 component directly in from result same. can me please? you cannot use http4 component in from() directive. however, there several ways call url , retrieve result: one create timer , call http4 component to() this: from("quartz2://httppoll/mytimer?trigger.repeatcount=0") .to("http4://stream.meetup.com/2/rsvps") .log("body is: ${body}") .to(mockdestination); another way use content enricher pattern if want example aggegates results 1 stucture. note well, if url dynamic must use recipientlist()...

java - Handling exception in Service layer -

could please advice how overcome problem described below: there application (it involves using hibernate , spring frameworks) 3 layers: dao, service , controller. want avoid saving duplicate entities in db. made using constraints @ db-level , in annotation in bean ( @table(name = "artist", uniqueconstraints = {@uniqueconstraint(columnnames = "artist_name")}) ). logic supposes if try add duplicate entity exception thrown. try process exception in service layer fails succeed. mean when explicitly notice exception thrown application can't proceed work because of exceptions. more clear cite code below: dao-layer @override public void saveentity(client client) { session session = sessionfactory.getcurrentsession(); session.save(client); } service-layer @transactional @override public boolean saveentity(artist entity) { boolean completedstate = false; try { //method dao-layer artistdao.saveentity(entity); } catch (cons...

java - Library function to do bean comparison using Functions? -

since java 8 has made easier ever refer method directly (function/lambda), traditional reflection-based bean comparators (e.g. common-lang's equalsbuilder ) can implemented cleanly without reflection. wondering available in well-known library already? just clear, after function similar signature: static <t> boolean equals(t a, t b, function<t, ?>... proprefs); alternatively, non-confusion way of implementing using streams? given example class like class person { long id; string name, surname; int age; public long getid() { return id; } public string getname() { return name; } public string getsurname() { return surname; } public int getage() { return age; } } of course, can in compact form like @override public boolean equals(object obj) { if(obj==this) return true; if(!(obj instanceof person)) return false; person p=(person)obj; return stream.<functi...

ios - Making a single copy of a singleton -

a design question: i have singleton (in objective-c doesn't matter) the singleton class (object) data structure many classes access, , single (hence - singleton) now want add ability undo - saving snapshot of state of object - can go it. what need break singleton-ness of object (need 1 copy of it). not allow me share conveniently between classes. ideas? "the singleton class (object) data structure many classes access, , single" i think easier make singleton object have collection of data structure. create copies of data structure instead of copies of singleton.