Posts

javascript - Accessing a previously fullfilled promise result in a promises chain -

this question has answer here: how access previous promise results in .then() chain? 15 answers what correct pattern, when coding promises, access data coming long before in chain of promises? for example: do_a.then(do_b).then(do_c).then(do_d).then(do_e_withthedatacomingfrom_a_and_c_onlywhen_d_issuccesfullycompleted) my current solution: passing along single json structure through chain, , let each step populate it. opinion that? i don't think there's 1 "correct" pattern this. solution sounds neat, however, it's bit tightly coupled. may work great situation, see few problems general pattern: participating steps need agree on structure of collector object. every step needs participate in @ least forwarding of object, can tedious if chain long , need previous data occurs sporadically. inflexible insertion of steps not written (c...

tabbar - xcode title bar / collection view -

probably easy solution this, not sure how. i'm using colelction view tab bar. i'm unable drag navigation bar on view objects pannel, , selecting navigation bar properties pannel works, doesn't display in simulator mode. any thoughts? many thanks, again. well, 1 way achieve you're looking embed view controller or collection view controller contains collection within navigation controller (editor->embed in>navigation controller). then instead of linking controller collection directly tab bar, link navigation controller contains it.

What's the best way to generate random strings of a specific length in Python? -

for project, need method of creating thousands of random strings while keeping collisions low. i'm looking them 12 characters long , uppercase only. suggestions? code: from random import choice string import ascii_uppercase print(''.join(choice(ascii_uppercase) in range(12))) output: 5 examples: qpupzvvhunsn efjaczebyqeb qbqjjeeoytzy eojusueajeek qwrwliwdtdbd edit: if need digits, use digits constant instead of ascii_uppercase 1 string module. 3 examples: 229945986931 867348810313 618228923380

java - Progress bar on console using Log4J or LogBack -

i have console application prints output using log4j. useful can implement switch optionally show debug messages, though hidden default. this application has long running actions progress bar appropriate. what best way implement using either log4j or logback ? to write progress bar or sort of updating text console, end output \r (carriage return) instead of \n (new line) next line overwrites it. question goes more detail. f-ansi library enables generate nice-looking console output including overwriting previous line. but if set on using logging framework, not not possible, it's not want. chrism suggests, right way log progress log new line every percent done far. way, can see both program doing , how far along in context. what sounds want separate logging program's actual output (this idea, disregarding progress bar issue). use logging framework log information program's execution; things or debugging interested in. actual program's out...

c# - Remove duplicates with conditions using ASP.NET Regex -

i searching remove duplicates in document using regex or similar; remove following: first line <important text /><important text />other random words i need remove duplicates of <some text/> , keep else remain is. text may or may not on multiple lines. it need work off of several different words use < > tags. edit: i not know words be. nested inside < > tags , not be. need remove duplicates repeat 1 after each other like: <text/><text/><words/><words/><words/> and output should be: <text/><words/> this regex search duplicate tags, (<.+?\/>)(?=\1) , , here regex 101 prove it .

c# 4.0 - Why don't ODataQueryOptions work for both sides of a 1..* relationship? -

i have 2 tables joined link table , exposed through odata / entity framework: users usergroup using ~/api/users, following [user] api controller action returns results: public ienumerable<user> get(odataqueryoptions<user> options) { var unitofwork = new atms.repository.unitofwork(_dbcontext); var users = options.applyto(unitofwork.repository<user>().queryable .include(u => u.usergroups) .orderby(order => order.username)) .cast<user>().tolist(); unitofwork.save(); // includes dispose() return users; } i am, however, unable apply odataqueryoptions following [usergroup] api controller action: public ienumerable<usergroup> get(odataqueryoptions<user> options) { var unitofwork = new atms.repository.unitofwork(_dbcontext); ...

c++ - SSE and AVX intrinsics mixture -

in addition sse-copy, avx-copy , std::copy performance . suppose need vectorize loop in following manner: 1) vectorize first loop-batch (which multiple 8) via avx. 2) split loop's remainder 2 batches. vectorize batch multiple of 4 via sse. 3) process residual batch of entire loop via serial routine. let's consider example of copying arrays: #include <immintrin.h> template<int length, int unroll_bound_avx = length & (~7), int unroll_tail_avx = length - unroll_bound_avx, int unroll_bound_sse = unroll_tail_avx & (~3), int unroll_tail_last = unroll_tail_avx - unroll_bound_sse> void simd_copy(float *src, float *dest) { auto src_ = src; auto dest_ = dest; //vectorize first part of loop via avx for(; src_!=src+unroll_bound_avx; src_+=8, dest_+=8) { __m256 buffer = _mm256_load_ps(src_); _mm256_store_ps(dest_, buffer); } //vectorize remainder part of loop via sse for(; sr...