Posts

ios - dispatch_after wont run code under it when executed in swift -

when use dispatch_after method produce delay never executes code after it. need return array skips on it. here matt's delay method: func delay(delay:double, closure:()->()) { dispatch_after( dispatch_time( dispatch_time_now, int64(delay * double(nsec_per_sec)) ), dispatch_get_main_queue(), closure) } here method error occurs: func rolldice() -> array<int> { var dicearray = [int]() let timertime:nstimeinterval = 0.3 delay(timertime) { //my code } return dicearray //never gets here } you don't seem understand delay is. code operate in order: func rolldice() -> array<int> { var dicearray = [int]() // 1 let timertime:nstimeinterval = 0.3 delay(timertime) { // 3 } return dicearray // 2 } so, rolldice return empty dicearray before code inside delay ever runs. whatever doing inside delay ineffective point of view; has, , can hav...

python - Combining linked lists iteratively -

i'm trying combine 2 linked lists iteratively, have right giving me reverse of result. there way combine lists in correct order without having reverse if after result list created? class link: empty = () def __init__(self, first, rest=empty): assert rest link.empty or isinstance(rest, link) self.first = first self.rest = rest def __add__(self, lst): """ >>>s = link(1, link(2)) >>>s + link(3,link(4)) link(1,link(2,link(3,link(4)))) """ result = link.empty while self not link.empty: result = link(self.first,result) self = self.rest while lst not link.empty: result = link(lst.first, result) lst = lst.rest return result conceptually, combine 2 linked lists, need find tail of first list, , connect head of second list, , return head of first list. major proble...

javascript - Why jQuery .val() work and js .value doesn't work -

i have problem jquery .val() method , native js .value. have function use in 2 different page, html code : <input type="hidden" name="checkentreelun" value=""/> <input type="hidden" name="checkentreemar" value=""/> <input type="hidden" name="checkentreemer" value=""/> <input type="hidden" name="checkentreejeu" value=""/> <input type="hidden" name="checkentreeven" value=""/> <input type="hidden" name="checkentreesam" value=""/> <input type="hidden" name="checkentreedim" value=""/> and other page same code, except there default value in inputs. , in js function, need value of each input. here have : for (i=0;i<days.length;i++){ var nameentree = "checkentree"+days[i]; var checkentreematin = $("inpu...

programatically add a function to a javascript file from another javascript -

i want add function/code java script file script. have below code in a.js /*some comments.. 4-5 lines*/ module.exports = { aaa: aaa, add: add }; var asd = 'test'; function aaa() { console.log('ddddd --- ' + asd); } function add(a, b) { var sum = + b; console.log(sum); } from js file need add below function a.js , update module.exports list function diff(c, d) { ///some code } i parsed contents of a.js , new function esprima parser , splice function added code. converted ast code recast , wrote file comments gone. how insert code without affecting other content of original file?

python - How do I split a string BEFORE a certain character? -

timeline = ''' 1961 - second child, john, born. 1963 - ordained presbyterian minister. makes on-camera debut host of series of 15-minute episodes children produced in toronto. program titled "mister rogers." 1964 - returns pittsburgh , turns 15-minute show half-hour "mister rogers' neighborhood." 1968 - "mister rogers' neighborhood" debuts on pbs , wins first of several emmy awards. rogers appointed chairman of forum on mass media , child development of white house conference on youth. 1969 - wins first of 2 george foster peabody awards television excellence. fred rogers readies opening pitch start pirates' season in 1988. (post-gazette archives) 1971 - forms production company, family communications inc. 1975 - ceases production on "mister rogers' neighborhood," continues air on pbs in reruns. 1978 - creates pbs series "old friends, new friends," focusing on older people. 1979 - production re...

asp.net mvc - jquery limit adding partial view -

i think simple, not know why code not work. i dynamically adding textboxes in view using partial view, want add restrictions number of rows added. below code not limit number of rows added. kindly help, in advance. @section scripts { @scripts.render("~/bundles/jquery") <script> $("#btnadd").on('click', function () { var counter = 0; if (counter > 5) { alert("limit exceeds"); return false; } else { $.ajax({ async: false, url: '/employee/add' }).success(function (partialview) { $('#add > tbody').append("<tr>" + partialview + "</tr>"); }); } counter++; }); function deleterow() { var par = $(this).parent().parent(); par.remove(); }; $("#add").on("click", ".btnremove...

binary - How to edit the file generated by file sink of Gnu Radio? -

i find file generated file sink block binary format, can not edit gedit under linux or else, how can edit file? i send dat file contains "hello world" , want recieve file contains "hello world" this asked often. here's link faq , excerpt: all files in pure binary format. bits. that’s it. floating point data stream saved 32 bits in file, 1 after other. complex signal has 32 bits real part , 32 bits imaginary part. reading complex number means reading in 32 bits, saving real part of complex data structure, , reading in next 32 bits imaginary part of data structure. , keep reading data. take @ octave , python files in gr-utils reading in data using octave , python’s scipy module. the exception format when using metadata file format. these files produced file meta sink: http://gnuradio.org/doc/doxygen/classgr_1_1blocks_1_1file__meta__sink.html block , read file meta source block. see manual page on metadata file format more informa...