Posts

Index out of range in multidimensional array in Swift -

this question has answer here: swift 3 2d array of int 2 answers var tri = [[int]](); tri[0][0] = 321; this code causes error: fatal error: index out of range what's wrong? you're accessing first element of first subarray of array. array doesn't contain subarrays, crashes.

javascript - Two clicks - different actions (same div) -

hope help! have divs (using bootstrap) like: <div class="container"> <div class="row" id="r2"> <div class="col-lg-8"> <div class="block-in-div"></div> </div> <div class="col-lg-4"> <div class="col-lg-12"> <div class="block-in-div"></div> </div> <div class="row"> <div class="col-lg-12"> <div class="col-lg-4"> <div class="row"> <div class="col-lg-12"> <div class="block-in-div"></div> </div> </div> <div class="row"> ...

RxJS proper way to merge 3 arrays into one, as an Observable -

hi have 3 subjects ( observables ) const arr1$ = new behaviorsubject([]) const arr2$ = new behaviorsubject([]) const arr3$ = new behaviorsubject([]) let's these subjects contain data arr1 = ['1','2'], arr2 = ['3','7'], arr3 = ['4'] i want create observable (mergedobservable) combines latest these 3 observables, merges them 1 array, result 1 array this: ['1','2','3','7','4'] so can achieve this.mergedobservable.subscribe( mergedarray => { console.log(mergedarray) }) // ['1','2','3','7','4'] i struggling how make 'mergedobservable'. have tried combinelatest(arr1$,arr2$,arr3$) , still need 'chain' more functionality merge 3. thanks! combinelatest takes optional project function can used modify combined value. you can specify project function uses array.prototype.reduce flatten arrays single array: ...

javascript - Parsing JSON objects in an array using jQuery -

i'm trying print out value of "title" each object, delay before next title replaces current one. json: {"articles":[ "author":"author1", "title":"title1", "description":"description1" }, { "author":"author2", "title":"title2", "description":"description2" } ] } and code $(function getnews(){ $.getjson( "https://newsapi.org/v1/articles?source=google-news&sortby=top&apikey=",function out(json){ shownews(json) }); function shownews(json){ arr =[]; $.each(json.articles, function(index, value) { arr.push(value.title); }); for(k =0; k< arr.length; k++){ console.log(arr[k]); } settimeout(function(){getnews()},4000);}}); what i'm getting for-loop running once, , printing values of array @ same time. appreciated. let array = [ { ...

ios - Firebase permissions: Sign up with username and password -

i'd have users sign unique username , password (rather email + password). have working i: sign up check if provided username exists if not, use firauth.auth()?.createuserwithemail , store username in db email, e.g. users qzqfzwxpdmfc0xmyiq5idar1bzr2 credentials email: "myemail@gmail.com" username: "myusername" rjasdfasfasdad3dadaewdsdkdq3dk credentials email: "another@gmail.com" username: ""another sign in query db user associated username , use email address , use firauth.auth()?.signin(withemail: withemail log in while approach work, i'm wondering how work firebase permissions? in order email address associated username, i'm going have let all users access email address / username data, e.g. { "rules": { ".read": true, ".write": "auth != null" } } does mean 'hacker' email addresses of users have registered app? if so, ther...

android - Read different inputs from InputStream JAVA -

i'm writing code send encrypted file client server first client send encrypted message digest of file server , send name of file , @ end send bytes of encrypted file, in server side read these variables 1 variable digest , and when server trying decrypt digest throws illegal block size exception question here how can server read , save them in different variables ?? client // set mode encrypt aescipher.init(cipher.encrypt_mode, key); dataoutputstream toserver = new dataoutputstream(socket.getoutputstream()); // digest of file messagedigest md = messagedigest.getinstance("md5"); byte[] hash = md.digest(bytes); // encrypt digest , write file byte [] encryptedhash = aescipher.dofinal(hash); toserver.write(encryptedhash); // write file name server toserver.writeutf(filename); //encrypt file byte[] encrypt...

c# - asp-for="Property" and @Model.Property values are not the same for the same object -

i have cshtml file has section of similar below code below: <div id="entries" class="records-table"> @if (model.entries != null) { foreach (var entry in model.entries) { @html.partia("../partials/_partialentry", entry) } } </div> and in _partialentry file have code similar below: <input asp-for="somemodelvalue" /> <div class="@(model.somemodelvalue == "special":"hidden":string.empty)">...</div> the issue having given entry somemodelvalue properties between asp-for="somemodelvalue" , @model.somemodelvalue not same. @model.somemodelvalue returns somemodelvalue of previous entry. try , provide example below. lets me model.entries had values below: [{somemodelvalue = "special", ....}, {somemodelvalue = "someothervalue", ....} {somemodelvalue = "special", ....}, {...