Posts

java - How to invoke a method by a string in singleton -

i have singleton class, string method's name, , want invoke method class. class foo { private static foo instance; private string name; private foo() { } public static getinstance() { if(instance == null) instance = new foo(); return instance; } public foo setname(string name) { this.name = name; return this; } private void bar() { system.out.println("a"); } public void execute() { // invoke "name" method here } } foo.getinstance().setname("bar").execute(); how can this? use foo.getclass().getmethod(name, null).invoke(this, null) . you'll need change second parameter getmethod if have several methods same name different signatures, , invoke if method accepts parameters.

C++ in Xcode pausing -

this first post. new programming, , c++ thought might try , make program allows user submits block of text (max 500 characters), allows them enter 4 letter word , program return amount of times picks word in text. using x-code , keeps making green breakpoint , pausing program @ 'for' loop function. code shown below: #include <iostream> #include <string> #include <math.h> #define space ' '(char) using namespace std; //submit text (maximum 500 characters) , store in variable string text; string textquery(string msgtext) { { cout << msgtext << endl; getline(cin, text); } while (text.size() > 500); return text; } //query word search , store variable string word; string wordquery(string msgword) { cout << msgword << endl; cin >> word; return word; } //using loop, run through text identify word int counter = 0; bool debugcheck = false; int searchword() { (int = 0; < text.size(); i++) { char ch_1 = text.at(...

php - mysqli_num_rows() boolean error -

while running code, shows error mysqli_num_rows() expects parameter 1 mysqli_result, boolean please me find solution: if(!empty($email_id) && !empty($password)){ $query="select 'email_id' 'user_details' 'email_id'='$email_id' , 'password'= '$password'"; $con=mysqli_connect("localhost", "root", "","idukki"); $query_run = mysqli_query($con,$query); $query_num_rows = mysqli_num_rows($query_run); if($query_num_rows == 0) { echo'invalid email , password combination'; } else if($query_num_rows == 1) { $user_id = mysqli_result($query_run,0,'email_id'); } } when type of error regarding mysql first thing should print out sql , test in phpmyadmin, if passes in phpmyadmin have error in script, if not bad sql

javascript - Chrome.storage.sync.get not storing value in local variable -

function getbugval() { var bugval = ""; chrome.storage.sync.get('bugid', function (obj) { console.log(obj.bugid); bugval = obj.bugid; console.log(bugval + "<- val inside sync"); }); console.log(bugval + "<- val outside sync"); return bugval; } if call getbugval() return value keeps indicating empty string instead of actual value chrome.storage.sync.get. bugval not saving string value. console.log(bugval + "<- val inside sync"); yields correct value within inner function call. thoughts? yep. that's how async code works. you'll have use callbacks. work. function workwithbugval(val) { // stuff } function getbugval(callback) { var bugval = ""; chrome.storage.sync.get('bugid', function (obj) { console.log(obj.bugid); bugval = obj.bugid; callback(bugval); }); } getbugval(workwithbugval);

sqlite error near '''' syntax error data input -

i using sqlite3 , trying put data database. create table club( cl_id int primary key not null, naam text not null, adres varchar(200) not null, dtm_opricht text not null ); create table stadion( sta_id int primary key not null, cl_id int references club(cl_id), naam text not null, adres varchar(200) not null, capaciteit int not null, dtm_bouw text not null ); create table technischdirecteur( td_id int primary key not null, cl_id int references club(cl_id), naam text not null, adres varchar(200) not null, salaris real not null, nationaliteit text not null, geslacht text not null, dtm_geboorte text not null ); everything going fine pu...

android - Capture image from web page using regex -

i writing simple program capture image resources web page. image items in html looks like: case1:<img src="http://www.aaa.com/bbb.jpg" alt="title bbb" width="350" height="385"/> or case2:<img alt="title ccc" src="http://www.ddd.com/bbb.jpg" width="123" height="456"/> i know how handle either case separately, take first 1 example: string capture = "<img(?:.*)src=\"http://(.*)\\.jpg\"(?:.*)alt=\"(.*?)\"(?:.*)/>"; defaulthttpclient client = new defaulthttpclient(); basichttpcontext context = new basichttpcontext(); scanner scanner = new scanner(client .execute(new httpget(uri), context) .getentity().getcontent()); pattern pattern = pattern.compile(capture); while (scanner.findwithinhorizon(pattern, 0) != null) { matchresult r = scanner.match(); string imageurl = "http://" +...

asp.net mvc 5 - How to remember the login in MVC5 when an external provider is used -

in our mvc5-application owin, use additional local accounts external logins (google). when user logs in local account, can activate option remember him, has not log-in every time newly. when logs in google-account, every time must click newly on external login-button google. is there built-in option activate “remember me”-option external logins? or there secure way add feature? you need set ispersistent true accomplish when sign in user identity (you want add kind of remember me checkbox external flow well) authenticationmanager.signin(new authenticationproperties { ispersistent = <rememberme> }, <useridentity>);