Posts

ios - How can I access Collection View from delegate & datasource class? -

i have view controller contains collection view. collection view's delegate , datasource 1 custom class , can't access collection view class. class includes uicollectionviewflowlayout, uicollectionviewdelegateflowlayout, uicollectionviewdatasource. i tried accessing collection view typing self.collectionview didn't work, saying: "fatal error: unexpectedly found nil while unwrapping optional value (lldb)". tried setting static let variable points view controller containing collection view didn't work. delegates , datasources dataprovider, not more. extracting them own classes idea (object oriented design). these classes shouldn't implement more api of protocol , maybe private helper functions them. each protocol function provide access collection view giving reference first parameter. e.g. func numberofsections(in: uicollectionview)

web services - Oracle Database URL_HTTP Issue -

i'm trying invoke web service send encoded (base64 encoding) file name. shorter file name works fine, when file name increases after encoding pl/sql fails invoke web service , turns out bad request 400 error. based on our observation far have seen upto 65 chars worked once sent ~ 89 chars failed. *code snippet req := utl_http.begin_request(url, 'put',' http/1.1'); utl_http.set_body_charset('utf-8'); utl_http.set_header(req, 'username', username); utl_http.set_header(req, 'password', password); utl_http.set_header(req, 'content-type', 'application/octet-stream'); utl_http.set_header(req, 'content-length', '32767'); utl_http.set_header(req, 'accept-encoding', 'gzip'); utl_http.set_header(req, 'transfer-encoding', 'chunked'); filename := utl_raw.cast_to_varchar2 (utl_encode.base64_encode (utl_raw.cast_to_raw (ffile.file_name))); //encoding file name before...

java - Javafx Choicebox - how to check if selected/activated -

i trying make simple app using javafx. i want make choicebox, , when choicebox activated - meaning if value selected - want code progress. this working: if ( choicebox.getselectionmodel().isempty()){ } why opposite not work? : if (! choicebox.getselectionmodel().isempty()){ } edit: have 2 layouts. 1 represents choicebox , 1 represents set of checkboxes. want accomplish checkboxes should appear when choicebox activated / value selected. if (! choicebox.getselectionmodel().isempty()){ secondlayout.setvisible(true); } try this: choicebox<string> cb = new choicebox(....); secondlayout.visibleproperty().bind(bindings.createbooleanbinding(() -> cb.getvalue() != null, cb.valueproperty())); as alternative can do: secondlayout.visibleproperty().bind(bindings.isnotnull(cb.valueproperty()));

database - MySQL mutual condition query with single table -

i receiving user_id 1 , 2 post. want hospital id sharing both user 4. user_hopitals table id | user_id | hospital_id 1 | 1 | 4 2 | 2 | 4 3 | 1 | 5 4 | 2 | 9 hospitals table id | name 4 | abc hospital 5 | xyz hospital 9 | def hospital i want data hospital_id | hospital_name 4 | abc hospital you can use self join , e.g.: select h.id. h.name user_hospitals uh1 join user_hospitals uh2 on uh1.hospital_id = uh2.hospital_id join hospitals h on uh1.hospital_id = h.id uh1.user_id = 1 , uh2.user_id = 2;

ASP.NET Core Dependency Injection inside Startup.Configure -

i using cookie middleware authenticate user. have been following this official tutorial . inside startup class, excerpt configure method looks this: public void configure(iapplicationbuilder app, ihostingenvironment env, iloggerfactory loggerfactory) { // ... // cookie-based authentication app.usecookieauthentication(new cookieauthenticationoptions() { authenticationscheme = cookieauthenticationdefaults.authenticationscheme, automaticauthenticate = true, automaticchallenge = true, events = new customcookieauthenticationevents(app), }); // ... } the customcookieauthenticationevents class defined follows: public class customcookieauthenticationevents : cookieauthenticationevents { private iapplicationbuilder _app; private imyservice _myservice = null; private imyservice myservice { { if(_myservice != null) { return _myservice; } else { return _myservice = (imyservice) _app.applica...

Passing arguments into the revealing Module pattern in Javascript -

how can pass arguments function when implementing revealing module pattern in javascript. have module this var globalmodule = (function() { function consolelog(texttooutput) { console.log(texttooutput); } return { consolelog: consolelog() }; })(); later on, when run globalmodule.consolelog("dummy text"); , undefined output. do function inside return object var globalmodule = (function() { return { consolelog: function(texttooutput) { console.log(texttooutput); } } })(); globalmodule.consolelog("dummy text"); simply same output achieved . object => function call .no need return object var globalmodule ={ consolelog: function(texttooutput) { console.log(texttooutput); } } globalmodule.consolelog("dummy text");

mysql - Which index to add here? -

this query ends in slow query log because join without index. index add , where? simple query takes anywhere 500ms 1,2s. guess should complete within 100ms. select users.*, user_roles.apirequests, user_roles.downloadrequests, now() users inner join user_roles on user_roles.id = users.role users.rsstoken = '775e155c780ed5af9119f797f814c714' limit 1; see query , show create tables: https://kopy.io/icz1z for query: select u.*, ur.apirequests, ur.downloadrequests, now() users u inner join user_roles ur on ur.id = u.role u.rsstoken = '775e155c780ed5af9119f797f814c714'; the best indexes users(rsstoken, role) , user_roles(id) . have second index, because id declared primary key. you can include apirequests , downloadrequests in index on user_roles : user_roles(id, apirequests, downloadrequests) . might small optimization -- counsel against because id primary key , row size small.