Posts

gsl - C++ strange behaviour with function call by value -

i have object class interface matrix struct found in gnu scientific library typedef double real_t; typedef unsigned short index_t; class matrix { gsl_matrix* m; public: matrix(index_t rows, index_t columns, real_t val); } matrix::matrix(index_t rows, index_t columns, real_t val) { m=gsl_matrix_alloc(rows,columns); gsl_matrix_set_all(m, val); return; } index_t matrix::rows(void) { return m->size1; } index_t matrix::columns(void) { return m->size2; } the problem if use function taking matrix object value one: void test_function(const matrix m){}; and use in program one int main() { matrix m(4,4,1); cout << m.rows() << '\t' << m.columns() << endl; test_function(m); cout << m.rows() << '\t' << m.columns() << endl; } i surprisingly obtain number of rows of matrix object m modified function test_function garbage value, if put keyword const before a...

c# - Get GridView Object from Sender -

i have multiple gridview on page, , pagable. need handle paging in onpageindexchanging event, i'd rather not write same code each gridview . so how can gridview object id sender? i'm trying following.... protected void pageindexchanging(object sender, gridviewpageeventargs e) { gridview gridview = (gridview)sender.id; gridview.pageindex = e.newpageindex; gridview.databind(); } this way call same event handler gridviews , not have write new handler each one? i'm not sure how id of gridview firing event :( any appreciated! it's simpler: gridview gridview = (gridview)sender; the sender argument control triggered event.

Is there any threshold where bitmap compression stops, considering feedback input? -

i compress image jpeg format using quality factor. again use newly compressed image , again compress using same quality factor. every time result different. is there threshold compression stop? or continue compress compressed image? (keeping same quality factor throughout) i recommend reading on lossy compression . specifically: the original contains amount of information; there lower limit size of file can carry information. intuitive example, people know compressed zip file smaller original file, repeatedly compressing file not reduce size nothing , in fact increase size. also, understanding, makes sense results not repeatable. if compression repeatable (aka deterministic), mean reversible, make lossless compression, jpeg not.

html - page size if element is hidden -

if element hidden effect page size while loading. for example image hidden.now when page loads time calculate size of image too? there can 50 hidden images. thanks. no, if hide css, still html request images server, if want page loads quick need comment out img tags on page, won't hide images, won't request images server too, resulting in faster page loading. you can use css sprites if you've tons of small icons on websites, if talking literal images can check out lazy load technique if want render images faster page loading

Jquery UI Dialog button gets executed without clicking -

i calling jquery ui dialog success function of ajax call. code dialog - $.ajax({ 'url': "../../controller/myclass.cfc", 'data':{ method: "generatequote", 'quoteitems':quoteitems, returnformat: "json" }, success: function(data){ $("#place_of_loading_image").hide(); newquoteid = data.tostring(); //new quote confirmation popup $( "#newquoteaddedalert" ).dialog({ autoopen: false, resize: 'auto', width: 'auto', modal: true, closeonescape: false, closetext: "close" , position: "center top", buttons: [{ text:"continue", click: function(){ ...

zend framework2 - How to pass error message from Controller Action to Form on form submit. -

while creating form, form validation easy. how can 1 validate submitted data , pass error message form. for example have form password change, need verify old password , check if new password , confirm password same, , in failure stage, show message on password edit form. you mean in view script ? <?php if ($form->getmessages()){ // alert ?> <div class="alert alert-error"> <button class="close" data-dismiss="alert" type="button">×</button> <strong><?php echo $this->translate("are awake ?"); ?></strong> <?php echo $this->translate("some data not filled out correctly."); ?> </div> <?php }?> after print errors $form->getmessages()

c# - SQL Simple Equation (2 columns as something) -

i'm new linq , having difficulties converting part of sql query linq... the part in query there subtract 1 column other , set new column name... how do in linq? the part of sql follows: - '[columna] - [columnb] actual' thanks in advance! in linq query can project result of query existing class (not 1 generated entity framework or linq sql) or anonymous type like: var query = t in yourlist select new { actual = t.columna - t.columnb };

java - Can client side code access or set http request attributes? -

i'm reasonably confident know answer this, struggling find concrete information out there. i'm aware client submits requests http server optionally supplying reqeust parameters. server has additional capability store information in request attributes via objects. question is, client have access attributes in http request object? have lot of poorly written code looks this: if (request.getattribute("name") != null) name = request.getattribute("name); else if (request.getparameter("name") != null) name = request.getparameter("name"); i'm guess because original developer didn't understand how client side http requests submitted data server. in case, i'm working on implementing additional valiadation , encoding of request data prevent xss vulnerabilities , wondered if possible client corrupt/hack/take advantage of request attributes (assuming aren't ever populated data sourced client)? no. attributes ...

c++ - Ambiguity when using boost::assign::list_of to construct a std::vector -

this code: std::vector<int>(boost::assign::list_of<int>(1)(2)(3)); gives error: main.cpp: in member function 'void <unnamed>::requesthandler::processrequest(foo&, bar, unsigned int, unsigned int*, const char*, boost::shared_ptr<baz::ioutput>&)': main.cpp:450: error: call of overloaded 'vector(boost::assign_detail::generic_list<int>&)' ambiguous /4.4.2/bits/stl_vector.h:241: note: candidates are: std::vector<_tp, _alloc>::vector(const std::vector<_tp, _alloc>&) [with _tp = int, _alloc = std::allocator<int>] /4.4.2/bits/stl_vector.h:227: note: std::vector<_tp, _alloc>::vector(size_t, const _tp&, const _alloc&) [with _tp = int, _alloc = std::allocator<int>] /4.4.2/bits/stl_vector.h:215: note: std::vector<_tp, _alloc>::vector(const _alloc&) [with _tp = int, _alloc = std::allocator<int>] when compiled gcc 4.4.2. how can revolve iss...

vba - How to count cell colours allocated through a macro in excel 2007? -

i have created spreadsheet in excel 2007 teachers monitor progress , attainment based upon various parameters. to create rules parameters have used set of macros working brilliantly , cells containing student scores change colour depending upon whether progressing at, below or above expected level (yellow, red , green- original know!!). i trying create 'drop-in' spreadsheet allow staff copy , paste master sheet (which contains of students in year group) , feedback on own class specifically. has worked until came thought easiest part- getting excel count number of different coloured cells in each column. know cannot done through formula unless have xcellcolor add-in (which don't) wrote simple countcolor script using vba. i can apply formula count coloured cell based upon existing cell colour cannot count coloured cells copied on master spreadsheet. keep getting answer '0' or '29' total number of cells in column! is way in master spreadsheet alloca...

c# - How to make EndInvoke generic? -

in code raise events using begininvoke , because each event has different eventargs , code full of duplicate functions, like: private void endasyncconnect(iasyncresult iar) { var ar = (system.runtime.remoting.messaging.asyncresult)iar; var invokedmethod = (eventhandler<infoargs>)ar.asyncdelegate; invokedmethod.endinvoke(iar); } private void endasyncreceived(iasyncresult iar) { var ar = (system.runtime.remoting.messaging.asyncresult)iar; var invokedmethod = (eventhandler<receivedargs>)ar.asyncdelegate; invokedmethod.endinvoke(iar); } is there way make endasync function generic events? if event delegate types eventhandler<t> , should work: void completioncallback<t>(iasyncresult iar) t : eventargs { var ar = (system.runtime.remoting.messaging.asyncresult)iar; var invokedmethod = (eventhandler<t>)ar.asyncdelegate; invokedmethod.endinvoke(iar); }

r - Segment annotation on log10 scale works differently for the end and the beginning of the segment? -

Image
i found rather confusing feature in ggplot while trying annotate segments on log10 scale. following code produces plot below: library(ggplot2) dat <- data.frame(x = x <- 1:1000, y = log(x)) ggplot(dat, aes(x = x, y = y)) + geom_line(size = 2) + scale_x_log10() + annotate("segment", x = 0, xend = log10(100), y = log(100), yend = log(100), linetype = 2) + annotate("segment", x = log10(100), xend = log10(100), y = 0, yend = log(100), linetype = 2) whereas after: ggplot(dat, aes(x = x, y = y)) + geom_line(size = 2) + scale_x_log10() + annotate("segment", x = 0, xend = log10(100), y = log(100), yend = log(100), linetype = 2) + annotate("segment", x = 100, xend = log10(100), y = 0, yend = log(100), linetype = 2) in other words, have log10 transform endpoint of segment on x-axis, not beginning. behaviour have logical explanation? understand aes() transformations ...but in case, transformations on x-axis should uniform (well, log1...

c# - how to user Rectangle -

i user rectangle display 2 colors in vs 2010 window phone, if rectangle can't, please tell how do. <rectangle height="20" width="400" stroke="white" fill="green" strokethickness="1"> maybe possible through gradient. otherwise suggest 2 rectangles, both have half of height/width (depending on want have colors)