Posts

c++ - Using Templates to resolve virtual methods -

this issue involves using templates resolve virtual members in dispatch pattern. note: not same virtual template method questions asked on stackoverflow . * edit 1: corrected syntax errors, added clarifications. given following: #include <string> #include <iostream> class field_interface { public: virtual std::string get_field_name(void) const = 0; }; class field_integer : public field_interface { public: std::string get_field_name(void) const { return "int";} }; class field_string : public field_interface { public: std::string get_field_name(void) const { return "varchar";} }; class field_double : public field_interface { public: std::string get_field_name(void) const { return "double";} }; class abstract_visitor { public: virtual void visit(const field_integer& fi) = 0; virtual void visit(const field_string& fi) = 0; virtual void visit(const field_double& fi) = 0; ...

/ operand not working as expected in python 3 -

Image
i'm reading book tkinter gui application development hotshot based on python 2, , have code: from tkinter import * rows = 5 un = 2 bp = 2 columns = un * bp root = tk() right_frame = frame(root) right_frame.pack() button = [[0 x in range(columns)] x in range(rows)] in range(rows): j in range(columns): active = false color = '#f3f3f3' if (j / bp) % 2 else '#9a72a9' button[i][j] = button(right_frame, bg=color, relief='flat', width=1) button[i][j].grid(row=i, column=j) root.mainloop() and have result: need this: . tkinter works when run tkinter , python 2 unexpected result when running in python 3 , tkinter, cause behaviour? the difference due how python 2.x , python 3.x handle division operator. lengthy description can found here: http://legacy.python.org/dev/peps/pep-0238/

python - Find Largest Element in 2 Ordered Lists which does not occur in one list -

hi i've searched here can't find answer problem. i'm using python , have 2 lists. both ordered. first list longer 1 (approx 10,000 elements) , never changes. second 1 shorter grows program runs same length. the lists might this: [1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 8, 8, 10, 11, 12, 13, 16, 18, 19, 20] [1, 1, 2, 2, 3, 4, 16, 18, 19, 20] in case, want return 13 because it's maximum element in list 1 not in list 2. now repeatedly list 1 needs remain unchanged. both lists contain duplicate values. my naive way of doing far slow: def removeitems(list2, list1): list1copy = list(list1) item in list2: if item in list1copy: list1copy.remove(item) return list1copy so create new list , remove items exist in shorter list , value want end value in list1copy. there must faster way of doing using dicts or something? so far none of answers have been given take advantage of fact lists ordered , want largest value l1 not i...

Generating Shake Rules from Actions -

i find of 'makefiles' in project , generate rules based them. however, looks (purposely) nothing can escape action. so, instead lifted 'makefile' scanner io operation before shake function. main = makefiles <- findmakefiles shake skakeoptions $ generate_rules makefiles is there better way? firstly, don't think there's wrong current approach. shake package uses similar approach built in ninja , makefile interpreters, see details makefile interpreter or the sake interpreter . long processing makefile sufficiently quick not matter (which is) writing interpreter custom build syntax using shake, works nicely. there couple of reasons avoid approach, example, if processing of makefile expensive, or if makefile has other dependencies. in situation can use combination of newcache parse makefile once, , addoracle rules can depend on subset of makefile require. however, approach tricker right, since forces layer of indirection, , have make assu...

java - Difference between "file:///" and "file://" -

i tried both , both did same. there difference (only interest)? i have webview loads local data , able hand on url that. example: webview.loadurl("file://storage/emulated/0/folder1/folder2/hello.html" going spec file://storage/emulated/0/folder1/folder2/hello.html invalid. storage here should represent host name. while using file uri scheme may choose ignore host represents path. described on wiki page, quote below. a file uri takes form of file://host/path where host qualified domain name of system on path accessible, , path hierarchical directory path of form directory/directory/.../name. if host omitted, taken "localhost", machine url being interpreted. note when omitting host, slash not omitted ("file:///foo.txt" valid, while "file://foo.txt" not, although interpreters manage handle latter). my guess webview.loadurl lenient , accepts file uris not conform spec. uri.fromfile() provides examp...

c# - Domain to ViewModel Design? -

i wondering best design following. have domain models like: public class car { public string name { get; set; } //other common properties removed brevity } in domain model have models fuel specific cars inherit car like: public class dieselcar : car { public bool runonbiodiesel { get; set; } //other diesel specific properties removed brevity } public class petrolcar : car { public int nosparkplugs { get; set; } //other petrol specific properties removed brevity } on view have common car view model. common properties used , depending on fuel type render partial view either diesel or petrol - again partial view takes complete carview model there common properties on each partial view well. however rather map multiple properties view model domain in controller , domain view model in view model builder wanting take adavantage of automapper this. however think mean having below in automapperbootstrapper (and i'm not sure work correctly??) mapper.c...

Get "Terminated due to Memory error" for ios 8 custom keyboard Extension -

i developing ios 8 custom keyboard extension. run charm start. but "receive memory warning" in xcode. custom keyboard extension terminate sometimes. but run custom keyboard in host app. there don't have problem. don't "receive memory warning" in xcode. don't terminate. anybody can me? if app have limit size extension use? terminated due memory error http://i62.tinypic.com/ra41lz.png apple mentions in app extension programming guide memory limits app extensions significantly lower limits imposed on foreground apps. additionally types of extensions may have lower limits others. apple not explicit these memory limits far can tell , it's unclear if dependent on device , how memory other apps consuming. ethan mentioned, keyboard extensions should aim less 30mb avoid crashing. it's important test extension when not running in xcode or using debug build configuration. seems memory limits debug builds higher.