Posts

java - How to get return type of constructor lambda -

i wondering if possible return type of supplier assigned constructor. e.g. supplier<foo> sfoo = foo::new; how "foo.class" supplier? have been using typetools solve problem other things. this works, example: supplier<foo> sfoo = () -> new foo(); class<?> fooclasss = net.jodah.typetools.typeresolver.resolverawarguments(supplier.class, sfoo.getclass())[0]; // fooclass == foo.class but if assign supplier like: supplier<foo> sfoo = foo::new , return type cannot resolved... any thoughts? don't have use typetools btw... seems parsing method references not supported typetools. there's open issue similar problem. in general such feature quite fragile runtime lambda representation not specified , implementation dependent. may break 1 day. if need class suggest passing actual class<?> argument.

python - Issue in generating all permutations of columns in a dataframe in Ipython -

i working in ipython , trying generate permutations of columns present in dataframe . issue have 15 columns in dataframe , code doesn't reach end , keeps on executing. here current code: df = pd.read_csv(filename, sep = ';', error_bad_lines=false) def all_perms(str): if len(str) <=1: yield str else: perm in all_perms(str[1:]): in range(len(str)): #nb str[0:1] works in both string , list contexts yield perm[:i] + str[0:1] + perm[i:] allperms_list = [] p in all_perms(df.columns[:len(df.columns)]): allperms_list.append(p) i followed this example . have 16 core , 32gb memory system , have been running code last 1.5 hours still executing , doesn't reaching end. there fundamental issue in code have? how can make run faster without affecting final result? read itertools.permutations option. how can modify current code include itertools.permutations , achieve same result?

yii2 - Yii 2 FileValidator -

i'm new yii 2 , reading documentation , experimenting. using activeform , trying file upload, keep getting error "please upload file" though appears file has been uploaded when step through code. model code public function upload() { if ($this->validate()) { $destination = yii::getalias('@app/uploads'); $this->brochure->saveas($destination . '/' . $this->product_id . '.' . $this->brochure->extension); return true; } else { return false; } } controller code public function actionupdate($id) { $model = $this->findmodel($id); if (yii::$app->request->ispost) { $model->load(yii::$app->request->post()); $upload = uploadedfile::getinstance($model, 'brochure'); if ($upload !== null) { $model->brochure = $upload; $result = $model->upload(); } // if model...

Efficiently get largest 3 integers in C++ Linked List (unsorted) -

i heard there std functions give largest n integers of array, how linked list? i think solution have few loops iterate on linked list, seems if there simpler solution in c++ libraries. thanks. i if can't use data structure: typedef std::list<int> intlist; instlist list = <your_values>; int top[3]; (size_t = 0; < 3; i++) top[i] = std::numeric_limits<int>::min(); intlist::iterator it, end; (it = list.begin(), end = list.end(); != end; ++it) { const int& value = *it; if (value > top[2]) { top[0] = top[1]; top[1] = top[2]; top[2] = value; } else if (value > top[1]) { top[0] = top[1]; top[1] = value; } else if (value > top[0]) { top[0] = value; } }

c++ - Why can't I call a class's non-default constructor in another file? -

this question has answer here: “undefined reference to” in g++ cpp 2 answers i new c++. have started writing class called row, , trying call non-default constructor create row object in separate main.cpp file, keep getting error not understand. can explain me i've done wrong? here 3 files: row.h #ifndef row_h #define row_h #include<vector> #include<iostream> class row { std::vector<int> row; public: // constructor row(std::vector<int> row); }; #endif row.cpp #include<vector> #include<iostream> #include "row.h" // constructor row::row(std::vector<int> row_arg) { row = row_arg; } main.cpp #include<vector> #include<iostream> #include "row.h" using namespace std; int main() { vector<int> v = {1, 2, 3, 4}; row row(v); return 0; } the error re...

multisite - How to use an IP address for a multi-site in Drupal 8? -

this url seems claim it's not possible. workarounds on site doesn't work, , information dated. question is... why work in drupal 8, when put in sites.php file: $sites = array( // url ==> path 'test.localhost' => 'default', 'test2.localhost' => 'somepath', ); but not this: $sites = array( // url ==> path 'test.localhost' => 'default', '127.0.0.1' => 'somepath', ); and how make work? it known bug dont go way. have setup additional virtual host , setup drupal there. can partially link site , modify configuration - filesystem related opration not drupal nor apache/nginx operation.

java - How to apply operator precedence for calculator? Library? Is ANTLR the right library to use? -

i'm trying make calculator app applies operator precedence. however, haven't been able find clear references on how apply in java. understand have use recursive descent parser (unless there's method or better way this). if so, better me code parser myself? or should utilize library. while browsing forums, came upon answer suggested using antlr find seems language grammar rather applying operator precedence in expressions. if it's better me code recursive descent parser myself, please link me references on how so? if should use library, please link me 1 examples how apply operator precedence? i'm not sure how apply antlr operator precedence , haven't seen clear references in docs either on how apply leaves me doubts whether or not right library use. thanks! i don't see why mixing antlr operator precedence. antlr parser (and lexer) generator. use bison/flex same result. now, precedence if given grammar (there might error, i've se...