Posts

javascript - onclick is not working with document.getElementsByClassName -

i have accordion menu using product descriptions in cms trying develop javascript/css/html speed data entry having same class name encapsulate sections , subsections. saw on website , thought cool, cannot work. e.g sections this: <button class="accordion_f">section 1 title</button> <div class="panel"> <button class="accordion_f">section 1 subsection title</button> <div class="panel"> section 1 contents</div> <button class="accordion_f">section 2 title</button> <div class="panel"> <button class="accordion_f">section 2 subsection title</button> <div class="panel"> section 2 contents</div> , on... section 1 section 1 contents section 1 contents section 2 section 2 contents section 2 contents , on this way can cut , paste content without worrying specific div id names. css <style> button.acc...

php - How to find difference between two time? -

this question has answer here: difference between 2 dates in seconds [duplicate] 1 answer i have 2 variable value date type assigned it. want find difference of 2 variable values. $d1='2016-08-24 12:22:13'; $d2='2016-08-24 12:22:30'; difference of d2-d1 17 seconds. how find in php? // instantiate datetime $datetimefirst = new datetime('2016-08-24 12:20:00'); $datetimesecond = new datetime('2016-08-24 12:34:00'); //calculate difference $difference = $datetimefirst->diff($datetimesecond); //format output echo $difference->format('%y-%m-%d %h:%i:%s'); reference

c - How to fill bitfields with 0xff -

is there way initialize unsigned field in bitfield 0xfff...(according its' size ofcourse) ? if use -1 warning assigning signed unsigned variable. one solution manually create init values in enum , use them: enum init_bit { // etc i_3 = 7u, // use longer names because global space i_4 = 15u, i_5 = 31u, // etc }; you write once , becomes easy: x x = {/*other fields*/, i_4, /*other fields*/}; another solution found init 0 , decrement. defined because dealing unsigned type. if need initialize can create function this: x get_x() { x x; x.a = 0; --x.a; return x; } with optimizations enable compiler direct initialize: get_x: movl $15, %eax ret you can use function initialization: x x = get_x(); of course has disadvantage need init other fields of x in get_x . where x defined as: struct x { unsigned : 4; }; typedef struct x x; it seems tricky initialize bit fields without warnings (gcc 6.1): x x = {-...

list - How to enable/disable item in selecManyCheckbox based on flag -

i need in disabling , enabling item selectmanycheckbox component in jsf page. first of all, selectmanycheckbox component showing 3 chechboxes (loan - health - transfer). list populated bean has code: private list<hrcertificate> hrcertificateslist = new arraylist<hrcertificate>(); //getter , setter private string loanflag=""; @postconstruct public void init() { this.hrcertificateslist.add(new hrcertificate(("loan"), "lc")); this.hrcertificateslist.add(new hrcertificate(("health"), "hi")); this.hrcertificateslist.add(new hrcertificate(("trasnfer"), "te")); } in same bean, running sql statement return either yes or no , value adding loanflag variable.so if flag="y", need enable loan checkbox user can select else need disable selectmanycheckbox . issue facing difficulties in applying logic disable , enable item selectmanycheckbox where in above code listing , enabling ...

Run python in C++ -

i have application written in c++ , testing system (also in c++). testing system pretty complicated , hard change (i want make small changes). class looks this: class derived : public base { public: void somefunc(const anotherclass& file) { } }; there several functions inside. testing system creates derived class instance , uses it's methods stuff. now want able write solution in python. need two-way integration. idea write python function, executed every time when somefunc called. , don't want lose variables' values in python 1 launch of function another. , want able use methods defined in base class instance python. how can achieve these things? i chose boost.python these purposes. now, understand, how use c++ function, or simple class in python after work. don't understand how launch python function c++. the second question - boost.python choice? need fast and, @ same time, easy use. thank help. i recommend using cython sort of thing...

r - How to append date to the filename for logging -

i'm triggering r script via scheduler. r script causes errors (maybe due input problmens). after each run, r-out file history log. log super helpful in checking if went planed unfortunately gets overwritten every day. question is: how can different r-out file each day (e.g. date it) best regards , thank you, phil to generate filename includes current date, take output of sys.date() , use paste0 to compose name of file including date. maybe this: filename <- paste0("r-out_", sys.date(), ".log") #> filename #[1] "r-out_2016-08-24.log" the format of date can changed format() if desired (thanks @konrad reminding this). instance, use format(sys.date(), "%d-%m-%y") obtain day-month-year form typically used, e.g., in europe: filename <- paste0("r-out_", format(sys.date(), "%d-%m-%y"), ".log") we can use sink() to redirect console (standard) output of script file. in case script edi...

MongoDB C# How to delete nested record -

i have following structure { "_id" : "68f77d83-7141-4867-a355-16eda3ebe470", "roles" : [ { "id" : "0001010260", "roleids" : [ "customer", "admin" ] } ] } now try delete 1 roleid "customer" or "admin". have 2 filters combine and. filterdefinition<roleentry> subfilter = builders<roleentry>.filter.eq(p => p.sub, _sub); filterdefinition<roleentry> idfilter = builders<roleentry>.filter.elemmatch(p => p.roles, r => r.id == _role.id); i can delete whole roleids element with. don't know how 1 level deeper. tried updatedefinition<roleentry> updatedefinition = builders<roleentry>.update.unset("roles.$.roleids"); updateresult result = await _roleentryconnector.roleentrycollection.updateoneasync(andfilter, updatedefinition, null...