Posts

C++ & Qt: Don't pick a random number for x minutes -

let's have 10 numbers 1 10 , rand() picks number 3. number displayed on screen, but won't shown 15 minutes after picked . how can that? i know srand should used better random results, that's not want achieve. want specific number shown once, after not appear until 15 minutes gone. i've read sleep, haven't figured out how works , if fits problem. one straightforward way: keep record of numbers they're picked , time they're picked. so each time want display number: check record , remove entries older 15 minutes. pick number between 1 , 10. check record see if picked number has been used in last fifteen minutes. if go step one. since picked number hasn't been used in last 15 minutes, display number. add new entry record picked number , current time. note obviously, if pick 9 numbers in less 15 minutes, , tenth number picked within 15 minutes, result not random @ all. point being kind of constraint results less random more numbers ...

r - missing S3 method but higher level-function works -

i'm trying pin down problem grobwidth applied gtable objects (see gtable:::widthdetails.gtable ); issue arises when size specified sum of units ( unit.arithmetic object), library(grid) u = unit(1,"npc") + unit(2,"mm") grid:::absolute.units(u) #error in usemethod("absolute.units") : # no applicable method 'absolute.units' applied object of class #"c('unit.arithmetic', 'unit')" remarkably, absolute.size works, though calls grid:::absolute.units , grid::absolute.size(u) #[1] 1null+2mm how possible? ok, browsing grid source code , found out method is defined, grid:::absolute.units.unit.arithmetic(u) but it's not exported. absolute.size() knows it, because it's in package namespace, calling outside (e.g. gtable) fails.

c++ - Why does this virtual method return true? -

while taking tutorial on polymorphism in c++, code seems acting strangely on call non-overriden virtual method. here classes: // classes.cpp namespace classes { class c { public: virtual bool has_eyesight() { return false; } } c; class see : public c { public: bool has_eyesight() override { return true; } } si; } and here main method: // file.cpp #include <iostream> #include "classes.cpp" using std::cout; using std::endl; using classes::c; using classes::see; int main() { see& si = classes::si; cout << si.has_eyesight() << endl; c& c = si; cout << c.has_eyesight() << endl; c = classes::c; cout << c.has_eyesight() << endl; } this code print 1 1 1 (true true true) when run; shouldn't c.has_eyesight() return false if references c , not see? (forgive me if sounds naive, start...

jquery - Image and label not aligning correct -

Image
i trying align text of label starts @ same indent text in first line when text spills on next line due insufficent screen space. created example demonstrate problem im having. alignment should this http://jsfiddle.net/74k8kptc/2/ <body> <div class="container"> <div class="toggle_head"> <img src="pfeil_rechts_blau.png" alt="expand" class="expand"> <img src="pfeil_links_blau.png" alt="collapse" class="collapse"> <label class="question">some long text doesnt align when page forces text on new line on making smaller</label> </div> <div class="toggle_body"> <hr> lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. @ vero eos et accusa...

ruby - How to draw shape and use as button in Shoes? -

Image
i writing calendar gui in ruby using shoes . going of it's features, until got part wanted style boxes had created. using basic shoes::shapes @ first placeholder, after reading through documentation decided going undoable. tried border solution, didn't seem work well. here basic example of trying achieve. the boxes must function both clickable (so button), , element who's contents can changed. what, if any, best way achieve in shoes? have ditch shoes , pursue other gui framework instead? i found answer. reason, didn't see (or didn't register) when viewed page. answer can found here

mysql - Merging 2 tables with different field name -

select * 'batcha' table 'batcha' +--------+--------+--------+ |fruits | color | class | +--------+--------+--------+ | | | | |apple | red | x | |apple | yellow | x | |guava | green | o | +--------+--------+--------+ select * 'batchb' table 'batchb' +--------+--------+--------+ |fruitsb | size | type | +--------+--------+--------+ | | | | | apple | large | | | guava | medium | b | | guava | small | c | +--------+--------+--------+ is possible query join or union using these results? result +--------+--------+--------+--------+--------+--------+ |fruits | color | class |animals | size | type | +--------+--------+--------+--------+--------+--------+ | | | | | | | | apple | red | x | | | | | apple | yellow | ...

javascript - css only appends to the first panel -

i have wrote jquery change button colour red when 1 clicks on it. work first panel not working rest of panels. in first set of button works not everything. jquery part. function durationonclick(element){ var buttonid = element.id; var buttonname = element.name; var buttonids = ["1hour", "30min", "1day" , "1week", "1month"]; var charttype = $('#charttype').val(); var idvalue = $('#idvalue').val(); //after user click option here changing option black red. $(buttonids).each(function(i, e) { $('#'+e+'[name='+buttonname+']').css("color", ""); }); $('#'+buttonid+'[name='+buttonname+']').css("color", "blue"); ` the html code : <div class="row"> <div class="col-md-6"> <div class="panel panel-default"> ...