Posts

swift - How to initial correctly between two class -

Image
i want make sure in class home invoke class hud, , these 2 part code test okay when run in xcode, crash , show issue: "fatal error: use of unimplemented initializer 'init(size:)' class 'leftbehind.hud'" i hope told me how fixed it, thanks. import uikit import spritekit class hud: skscene { let positionx:cgfloat let positiony:cgfloat let sceneself: skscene let year = sklabelnode() let month = sklabelnode() let day = sklabelnode() let hour = sklabelnode() let minute = sklabelnode() init(positionx:cgfloat,positiony:cgfloat,scene:skscene) { self.positionx = positionx self.positiony = positiony self.sceneself = scene super.init() } required init?(coder adecoder: nscoder) { fatalerror("init(coder:) has not been implemented") } func hudshow() { year.fontnam...

algorithm - how to remove duplicate numbers from unsorted array -

i given following question in technical interview: how remove duplicates unsorted array? one option thinking of: create hash map frequency of each number in array go through array , o(1) lookup in hash map. if frequency > 0, remove number array. is there more efficient way? another option sort array o(nlog n) using quick sort or merge sort then iterate through array , remove duplicates why option 1 better option 2? i cannot use functions work array_unique. instead of removing object array if hash map says there duplicate, why don't build new array each item in hash map, , add array if there isn't duplicate? idea save step of having 2 arrays equal overhead @ start. php sucks @ garbage collection if start massive array, though unset value, might still hanging around in memory.

javascript - jQuery .post or .get pass dynamic parameters -

the common way send request server is $.get('link/to/send', { param1: "value1", param2: "value2" }, function(result) { // ... etc }); now if want send dynamic parameter names, can jquery support that? (i.e. need write generic code can specify parameter names @ runtime) this not jquery dependent, it's vanilla javascript. you should this: var objtosend = {}; objtosend["param1"] = "value1"; objtosend["param2"] = "value2"; $.get('link/to/send', objtosend, function(result) { // ... etc });

javascript - How to simulate drag and drop feature using protractor for e2e? -

hi html code drag used is: <div class="btn-event" dnd-type="'newevent'" dnd-draggable="event" dnd-effect-allowed="copy" dnd-copied=""> <div class="icon"> <i class='demo'></i> </div> <span class="label" title="object name"> {{o.name}} </span> </div> the code drop is: <div class="row slot-body" dnd-list="sequenceslot.events" dnd-allowed-types="['newevent']" dnd-drop="drop(event, index, item, external, type, dropped item)" dnd-dragover="drop.validate(event, index, type)"> are supposed search dragabble ? or css ? use draganddrop() action method, example: browser.actions().draganddrop( element(by.css("div[dnd-draggable]")), element(by.css("div[dnd-dragover]")) ).perform();

java - Stream closed when using htpp client -

when using httpclient response error on line out.write(entityutils.tostring(resentity)); // line 70 in java code why happens? closeablehttpclient httpclient = httpclients.custom().setuseragent("mozilla/5.0 (windows nt 6.3; rv:36.0) gecko/20100101 firefox/36.0").build(); httpresponse response = httpclient.execute(new httpget(searchlink.tostring())); httpentity resentity = response.getentity(); system.out.println(entityutils.tostring(resentity)); printwriter out = new printwriter(new file("searchresult.xml")); out.write(entityutils.tostring(resentity)); out.flush(); out.close(); httpclient.close(); the error is 2015/08/07 13:03:12,887 error [stderr] (thread-101) java.io.ioexception: stream closed 2015/08/07 13:03:12,887 error [stderr] (thread-101) @ java.util.zip.gzipinputstream.ensureopen(gzipinputstream.java:61) 2015/08/07 13:03:12,887 error [stderr] (thread-101) @ java.util.zip.gzipinputstream.read(gzip...

hibernate - Spring Data JPA repository query builder, many to many relationship -

i want construct find query in repository interface select elements mapped many many relationship. user.java: @entity @table(name = "user") public class user { @id @column(name = "id", columndefinition = "binary(16)") private uuid id; @column(name = "username") private string username; @column(name = "email") private string email; @column(name = "passwordhash") private string passwordhash; @manytomany(mappedby = "userstracking") private set<show> shows; ... show.java: @entity @table(name = "shows") public class show { @id @column(name = "id", columndefinition = "binary(16)") private uuid id; @column(name = "imdb_id", length = 9, nullable = false) private string imdbid; @column(name = "title", length = 100, nullable = false) private string title; @column(name = "...

android - Scrolldown Listview from top -

i having 1 imageview , below imageview , having 1 listview . want scroll down listview top , zoom imageview when listview scrolls down. can ? basically, want zoom imageview on top of listview when pulls listview top. try this, listview , scrollview pull zoom : https://github.com/frank-zhu/pullzoomview