Posts

javascript - using populate to display username instead of id -

i'm running expressjs mongoosejs made connection between collections customerid below: . . /** * customer schema */ var customerschema = new schema({ id : number, name: string, joined: { type: date, default: date.now }, city: string }); mongoose.model('customer', customerschema); . . /** * order schema */ var orderschema = new schema({ id : number, products: [schema.types.mixed], total: number, comments: string, customerid: {type: number, ref: 'customer'} }); mongoose.model('order', orderschema); . . exports.customerorders = function (req, res) { return order.find({customerid: req.params.customerid}, function (err, orders) { order.populate(orders, {path: 'customerid', model: 'order'}, function (err, orders) { if (!err) { return res.json(orders); } else { return res.send(err); } }); }); }; the above code generate following error: { m...

c++ - Multiple instances of class using single instance of another class -

i have class (class a) there exist many instances of @ run time. class uses class (class r) handles resource allocation. due fact second class (class r) doing resource allocation instances of class there must single copy of it. so looks this: class p (parent) class a[64], childs of class p each of these requires access single instance of class r i'm wondering best solution of this. let parent (class p) instantiate class r , pass instance each class a. problem : class p doesn't care class r , has no use it. seems daft have manage it. global variable, perhaps hidden in namespace problem : can use it, , should restricted class a. static variable inside class a, instances of class have access same instance of class r. problem : static class variables evil or i've not thought of? let class r contain instance itself, ie. singleton pattern. then can do: class { r *resource; public: a() { resource = r::getinstance(); } } and on use 'resource...

debugging - lldb set maximum watchpoint count -

i facing little problem lldb, whenever want watch expression, error: error: watchpoint creation failed (addr=0x61f2e70, size=4). error: number of supported hardware watchpoints (0) has been reached and when watchpoint list -b it tells me number of supported hardware watchpoints: 0 no watchpoints set. is there command in lldb set maximum count of possible watchpoints / supported watchpoints? thanks the platform you're debugging not support hardware breakpoints, or if does, support not configured version of lldb you're using.

scalatest - SBT console encoding for test results -

i have sbt + scalatest project. tests log in console this: [info] - should *** failed *** [info] java.lang.exception: ╧ЁштхЄ! that's not useful of cause.. exception text in cyrillic have set cp866 charset on console stream display correctly. i've tried console.setout(new printstream(system.out, true, "cp866")) but sbt ignores it. seems sbt constructs it's own stream logging various messages, can't find , how alter it.. there way add custom logger, it's overkill. i've found solution. can create custom logmanager val customlogmanager = logmanager.defaultmanager(consoleout.printstreamout(new java.io.printstream(system.out, true, "cp866"))) and set in project settings: logmanager := customlogmanager though, i'm not sure if best solution. 1 flaw have provide logmanager setting every project. inheriting build settings doesn't work reason.

php - Populate html markup with data from the database -

i'm trying translate between php , asp.net. in php can connect database, run query, , print out results in html tags shown below: $query="select * comments;"; $result=$mysqli->query($query); while($row=$result->fetch_object()) { echo "<div class=\"comment\">"; echo "<h1>".$row->title."</h1>"; echo "<p>".$row->comment."</p>"; echo "</div>"; } ?> in asp.net c#, how this? i'm aware have use sqlconnection() , sqlcommand() , possibly sqldatareader(). how make asp.net have php doing above? , place code? in page load method? or in middle of html? i have looked using grid views , table views pull data database, don't allow me make page how want. want data database populate html template mark up, not predefined grid or table structure. thanks i guess of in sql-server well. see below .... test data decla...

php - codeigniter validation not working in bootsrap modal window -

i trying validation class working in codeigniter within bootstrap modal window. function in controller contains codes not being seen form-open function. this modal form: <div class="modal fade" id="login" tabindex="-1" aria-labelledby="modallabel" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button> <h4 class="modal-title" id="mymodallabel">login</h4> </div> <div class="modal-body"> <?php echo validation_errors();?> <?php echo form_open('site/login_validation');?> <form> <div class="input-group"> <span class=...

javascript - Get current slide number when using bookblock.js? -

im working on online book children, , im using bookblock.js flip animations. im using popcorn.js provide audio when im on current slide , highlight words when audio playing. problem (and maybe stupid question - im kinda new in javascript world) dont know how current slide can autoplay appropriate audio file. managed attach audio file on each slide , play when clicking custom play button , pause when clicking custom pause button, want autoplay appropriate audio file when clicking on next button user don't have press play every time on new slide. this main div have 2 more divs (bb-custom-side) in 1 (the right) have image, , in left bb-custom-side have 2 buttons (play/pause working should), have image (background) , text. <div class="bb-item" id="check3"> <div class="bb-custom-side"> <a class="play" id="play1" onclick="this.firstchild.play()"><audio clas...