Posts

c++ - pack (type erase) a random number generator -

the c++11 std library has several random number generators (rng), each implementing concept uniformrandomnumbergenerator . these can used argument random distributions, see this documentation overview. the advantage of design choice of underlying rng engine de-coupled application. however, design requires definition (not merely declarations) of calls rng available (if rng type remain unspecified template parameter). thus, in struct complicated_random_distribution { /* data , auxiliary methods here */ // complicated; may call rng::operator() many times template<typename rng> some_type operator()(rng&gen) const; }; the member operator() cannot straightforwardly implemented in separate compilation unit (cu), must available in same header file (or 1 #include d it). for separate implementation, 1 ideally want way pack rng in same way std::function<> packs callable object. (simply using std::function , providing values rng::min() , rng::max() ...

android - TextView Ellipsize not working -

below textview defined in xml. <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="select language" android:singleline="true" android:maxlines="1" android:maxlength="30" android:ellipsize="end" android:padding="4dp" android:textappearance="?android:textappearancemedium" android:textcolor="@android:color/holo_blue_dark" android:id="@+id/selected_language" /> i want ellipsize text when text length greater 30 chars not working @ all.please check if missing anything.i tried answers posted similar question did not work. i have changed maxlength maxems in textview working use this. <textview android:layout_width="wrap_content" android:layout_he...

c# - How to do optimal write rule definition in NRules -

the code of nrules simplerule define following rule: public class preferredcustomerdiscountrule : rule { public override void define() { customer customer = null; ienumerable<order> orders = null; when() .match<customer>(() => customer, c => c.ispreferred) .collect<order>(() => orders, o => o.customer == customer, o => o.isopen, o => !o.isdiscounted); then() .do(ctx => applydiscount(orders, 10.0)) .do(ctx => logorders(orders)) .do(ctx => orders.tolist().foreach(ctx.update)); } ... } i wondering why conditions seperate pareameters in stead of using && operator i.e. following have same effect? public class preferredcustomerdiscountrule : rule { public override void define() { customer customer = null; ienumerable<order> orders = null; ...

javascript - Remove false values in object -

the problem i'm facing -removing values in onject has property false here object var myobj={105:true,183:false,108:true,106:false} i'm able values in array using following logic: object.keys(myobj) gives ["105","183","108","106"] need way remove values have property false , generate ["105",108"] .can me out ? i've created solution problem on jsbin: working demo please find below code: var myobj={105:true,183:false,108:true,106:false}; var myarray = []; function removefalseandtransformtoarray () { (var key in myobj) { if(myobj[key] === false) { delete myobj[key]; } else { myarray.push(key); } } } removefalseandtransformtoarray(); console.log("myobj: ", myobj); console.log("myarray: ", myarray); // result = ["105", "108"] please, let me know if have question.

javascript - backbone database search firing 4 times -

i have search functionality in backbone application queries database via api, reason fires 4 times (or atleast returns results 4 times). here code, collections app.collections.searchablecollection = backbone.collection.extend({},{ search: function(query, options) { var search = $.deferred(); options = options || {}; var collection = new this([], options); collection.url = _.result(collection, 'url'); var fetch = collection.fetch({ data: { q: query } }); fetch.done(_.bind(function(){ pops.events.trigger('search:done'); search.resolvewith(this, [collection]); }, this)); fetch.fail(function(){ pops.events.trigger('search:fail'); search.reject(); }); return search.promise(); } }); app.collections.projectsearch = app.collections.searchablecollection.extend({ ...

php - Issue with EXPORT to CSV FILE -

i want export write in input text : -i have created class called "excelfile", contain methods exporting data csv file. -i have issue, when try export file data, colone added automatically in csv file, colone contain code html of table -this code : excelfile.php <?php class excelfile { private $csv = null; function colonne($file) { $this->csv.=$file."\n"; return $this->csv; } function insertion($file){ $this->csv.=$file."\n"; return $this->csv; } function output($nomfichier){ header("content-type: application/vnd.ms-excel"); header("content-disposition: attachment; filename=$nomfichier.csv"); print $this->csv; exit; } } ?> index.php <?php include_once 'excelfile.php'; ?> <html> <form method='post' action="index.php"> <table> <tr...

Database integrity errors when deploying Python(2.7)/Django(1.5) app on Heroku -

these days i'm learning python(2.7)/django(1.5) via developing reddit clone. clone done , works in local environment (db = sqlite3). when try host same thing on heroku (db = postgres), things go awry. specifically, web app still loads, login , logout , comments part throwing errors (i'm using django-registrations-redux, django-comments , south). since app online, can go here see error trace: login: https://salty-ridge-5419.herokuapp.com/login/ comments: https://salty-ridge-5419.herokuapp.com/comments/post/ and files, including requirements.txt etc., can found here: https://github.com/mhb11/unconnectedredditapp it perplexes me thing continues work locally, not on heroku. i'm assuming may have fudged south migrations. however, i've been deleting heroku app , setting new ones day long. every time run syncdb command on new app, following error after setting super user credentials post django-auth system installation , table creation: databaseerror: rela...