Posts

Showing posts from August, 2014

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)

android - ListView crashing the my application why? -

my app crashed when try scroll down in listview i've tried trace error couldn't find , activity works fine when try scroll down app getting crashed , please guys tell me error or mess in code ? i had removed scroll down effect , removed lv.setonscrolllistener(new onscrolllistener() but still same problem listview xml <?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background_scroller" > <listview android:id="@+id/ringtonelistview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/scro

python - How to merge and split numpy array along the axis? -

i have data in following form shape of array (10,4,4,3) first want create array shape (merging, or flattening) (10,48) such data (4,4,3) converted 1 row. secondly want go original shape of data(splitting) such each element again placed @ same location. thanks b = a.reshape(10,48) = b.reshape(10,4,4,3)

Render text on canvas using WebGL -

i want render text on canvas using webgl, api of webgl should used? note: "text" can either plain text or html snippet css style most demos i've seen text of sort (like fps counter) create html element text want , position on canvas. approach text want show "in" canvas (ie: menus). the exception if want text actual part of 3d scene (like, say, text on billboard), in case methodologies wouldn't different rendering text in standard opengl. can find robust example here: http://dmedia.dprogramming.com/?n=tutorials.textrendering1 there's a webgl tutorial text here .

php - Prevent Propel from inserting empty strings -

how can prevent propel orm inserting empty strings when column not set? create table user ( uid integer primary key auto_increment, email varchar(255) not null unique, -- no default value ... ) engine innodb ... ; propel allows $user = new user(); $user->save(); . have tried setting sql_mode doesn't help. the correct way validator in schema , check using validate() method in code. here's example: <database ...> <table ...> <!-- "required" attribute here sets db property --> <column name="email" type="varchar" required="true" /> ... <!-- adds unique index in db (but nothing in php code!) --> <unique> <unique-column name="email" /> </unique> ... <validator column="email"> <!-- validator rule makes $obj->validate() method fail on null --> <rule name="required&quo

dependencies - CMake: Depending on another project -

i quite new cmake , want achieve "common" task it. until now, used eclipse cdt auto generated makefiles. suppose have 2 projects , b. builds static library , b needs library. of course, when building b, want ensure static library built up-to-date. thus, building of project b should trigger building of if changes made in sources of a. default behaviour of eclipse when inserting dependency of b. so, easiest way achieve cmake? have read tutorials , similar questions, none gave me satisfying answer. for example, there http://www.cmake.org/wiki/cmake/tutorials/exporting_and_importing_targets tutorial solution. however, seems quite complex such easy task. have "install" targets of a, not want install anything, want b depend on a. next, heard externalproject_add don't know how handle either. if you're building them same cmakelists file, specifying linkage using target name enough: add_library(librarya ${a_sources} target_link_libraries(librarya

Can I declare method to return Class object with restriction to subclasses of given type in Java? -

suppose declare abstract method, return class object (like dog.class, cat.class), this: abstract public class getproducedanimaltype(); can force clients extending api return class objects represents classes, wchich subclassess of animal.class ? like: abstract public class<representing subclass of animal> getproducedanimaltype(); so client extending class cannot write: public class getproducedanimaltype() { // integer not extends animal!, shoud not compile! return integer.class; } but can: public class getproducedanimaltype() { return fish.class; // fish extends animal } you can change return type class class<? extends animal> . following code allow return cat.class , dog.class , won't allow return integer.class : abstract public class<? extends animal> getproducedanimaltype(); the client can write following code , compile fine: public class<? extends animal> getproducedanimaltype() { return fish.class; // fis

jquery - Bulk status update on dropdown list change -

i have drop down list bulk status upload echo chtml::dropdownlist('updatestatus', 'updatestatus', lookup::items('nodestatus'), array( 'prompt' => '', 'ajax'=>array( 'type'=>'post', 'url' => ccontroller::createurl('node/bulkstatus'), 'data'=> array('updatestatus' => 'js:this.value', 'autoid' => 'js:$("input[name=autoid]:checked").map(function () {return this.value;}).get().join(",")'), 'success'=>'reloadgrid', 'update'=>'#msg', //selector update ), )

c# - Page redirects to subdomain folder -

i have code redirects user when sign out: if (isrequestedpage("login") && authorization.isauthenticated()) { response.redirect("calendarview.aspx"); } else if (libkezberprojectmanager.data.context.needsfirstuse() && !isrequestedpage("firstuse")) { response.redirect("firstuse.aspx"); } else if (!authorization.isauthenticated() && !isrequestedpage("login") && !libkezberprojectmanager.data.context.needsfirstuse()) { string filename = this.page.request.url.tostring(); filename = filename.remove(0, filename.lastindexof("/") + 1); response.redirect("login.aspx?redirect=" + filename); } } public bool isrequestedpage(string pagename) { return request.rawurl.contains(pagename

grammar - ANTLR 3, what does LT!* mean? -

i looking @ code javascript grammar written in antlr 3, http://www.antlr3.org/grammar/1206736738015/javascript.g in many instances found program : lt!* sourceelements lt!* eof! ; what lt!* mean ? edit: from http://ftp.camk.edu.pl/camk/chris/antlrman/antlrman.pdf i found lt stands lookahead token n th ahead token, n part in above ? no, lt not mean lookahead token in context. token defined @ end of grammar: lt : '\n' // line feed. | '\r' // carriage return. | '\u2028' // line separator. | '\u2029' // paragraph separator. ; the * means parser tries match 0 or more of these tokens, , ! indicates generated ast should not include these lt tokens.

ElasticSearch faceted search for a multilingual field -

i have elasticsearch dsl query below, query = { "query": {"query_string": {"query": "%s" % q}}, "facets": {"destination": { "terms": {"field": "destination"}}}} where destination indexed multilingual field below, destination': {u'fr': u'portland', u'en': u'portland'} so facets result comes empty because of multingual issue. ideas? query = { "query": {"query_string": {"query": "%s" % q}}, "facets": {"destination": { "terms": {"field": "destination.en"}}}} worked me

css3 - Using box model to contain items within its parent div -

Image
using following html , css3 rules, i'm trying make sure following criteria adhered to: i have of criteria working except item 1 children exceeding parent's width. question: how keep children within parent? li items cannot exceed parent width i.e. 400px img, label, , currency content must centred vertically within span currency should not wrap , should displayed in full currency should displayed close possible label span. the label text should clamped @ 2 lines ellipsis displayed exceeds 2 lines. note: needs work in chrome , safari webkit-based browsers. it should like: however, looks @ moment: any ideas? ********************* js fiddle example ************************ <ul> <li> <span class="img"></span> <span class="label">acclaim</span> <span class="currency">(usd 50)</span> </li> <li> <span class="i

How to implement inheritance in node.js modules? -

i in process of writing nodejs app. based on expressjs. confused on doing inheritance in nodejs modules. trying create model base class, let's my_model.js. module.exports = function my_model(){ my_model.fromid = function(){ //do query here } } now want use methods in my_model in other model class. let's user_model.js how inherit my_model in user_model? in base_model: function basemodel() { /* ... */ } basemodel.prototype.fromid = function () { /* ... */ }; module.exports = basemodel; in user_model: var basemodel = require('relative/or/absolute/path/to/base_model'); function usermodel() { usermodel.super_.apply(this, arguments); } usermodel.super_ = basemodel; usermodel.prototype = object.create(basemodel.prototype, { constructor: { value: usermodel, enumerable: false } }); usermodel.prototype.yourfunction = function () { /* ... */ }; module.exports = usermodel; instead of using object.create() direct

javascript - how to display result in other text box with condition in jquery -

Image
i have field as shown in figure, if enter less 20 in result field nor/ab value should automaticaly changes "low" if entered more 110, should display high else normal. tried jquery , did not successed...let see form. <div style=" width:900px; height:auto; float:left; text-align:center;"> <div style=" height:auto; width:140px; float:left">{title}</div> <div style=" height:30px; width:140px; float:left"><input type="text" height="30px" width="140" name="rep_result_{txt}" /></div> <div style=" height:30px; width:140px; float:left">{unit}</div> <div style=" height:30px; width:140px; float:left">{first_val}&nbsp;-&nbsp;{last_val}</div> <div style=" height:30px; width:140px; float:left"><input type="text" height="30px" width="140" name="remark_{txt}" >

c# - How to Create Custom "type" attribute for textboxfor in Asp.net MVC? -

i working in mvc. have stuck badly in situation. know, @html.textboxfor have property named type detects type of input textbox can take. for ex: type = "email" takes email input , if validation fails shows error message "please enter valid email address". type = "number" takes number input , shows validation message if text use. i want textbox take mobile/phone numbers(with country codes , without country codes well. e.g. +9177777777777). so can create own custom "type" attribute can accomplish above task , can generates own validation message if validation fails ? the attribute type talking attribute of <input /> html element. per html5 specifications there several valid values attribute can take. see them here: http://www.w3schools.com/html/html5_form_input_types.asp so, cannot add sort of "custom" value imply automatic validation browser. want, think, able validate input against specific

php - How to check if a received email is legit? -

i'm developing system gets emails pipe, verify if email address email sent in client database, , write database. the problem don't want have security issues, , if sends email php system, log too. so, how can check if email sent mail server? thinking in getting ip of mail server of domain , verify in email headers if sent these server. so, if got email test@hotmail.com, ping mail.hotmail.com , check if email came these ip address. anyway, if got custom domain yourdomain.com, running in shared cpanel server, other people in these server send emails php , ip verify passed. so, thinking in checking if email sent php or mail server, don't know how this. what suggestion? i thinking in checking if email sent php or mail server you not able find out difference between these 2 normally. , email sent php can same email mail server , case email sent php is also email mail server. you can try write detection on own (your own filter) based on monitoring , fin

WPF Propertygrid with custom sorting -

i'm looking propertygrid wpf project allows me customize ordering properties / categories listed. right i'm using extended wpf toolkit s (community edition) propertygrid custompropertydescriptor s. researches showed, it's not possible have custom sorting propertygrid. is there (preferably free) solution? ordering of properties in extended wpf toolkit can achieved decorating property propertyorderattribute attribute. if don't want pollute poco's decorating them attributes @ design time, or order dynamic in way, it's possible add attribute @ run time creating type converter , overriding getproperties method. example, if wish maintain index order of generic ilist type: using xceed.wpf.toolkit.propertygrid.attributes; using system.componentmodel; public class myexpandableilistconverter<t> : expandableobjectconverter { public override propertydescriptorcollection getproperties(itypedescriptorcontext context, object value, attribute[] at

vb.net - Dual check box selection vb / winform -

i after little bit of help: i have datagridview control add couple of columns (as check boxes) in order select multiple rows. when select first checkbox column want second selected automatically, can de-selected if required. , if first checkbox deselected, 2nd auto deselected too. i have working following code: private sub dgvbikeavailability_cellcontentclick(sender system.object, e system.windows.forms.datagridviewcelleventargs) handles dgvbikeavailability.cellcontentclick debug.print("row index = " + e.rowindex.tostring + ". column index = " + e.columnindex.tostring + ". column name = ") 'debug.print() 'when bike selected, helmet automatically selected, can deselected if customer requires if e.columnindex = 0 dgvbikeavailability.rows(e.rowindex).cells(0).value = not dgvbikeavailability.rows(e.rowindex).cells(0).value dgvbikeavailability.rows(e.rowindex).cells(1).value = dgvbikeavailability.rows(e.rowin

dao - Neo4j project structure -

i looking build relatively complex neo4j application, intend split in 2 separete projects, namely frontend , backend. frontend html5 , not relevant question, backend have rest interface jersey, it's structure behind rest interface have questions about. atm, how envisioned : restimpl <-data-> service <-dto-> repository <-node-> dao <--> neo4j singleton the general flow restimpl receives json , converts simple java objects strings, int, ... passed on service creates dto them. dto passed on repository performs dao calls needed write such dto database (one dto may require several nodes , relations created). dao thinking of creating both core api , cypher implementation, has basic graph functions creating node, creating relation, deleting node, ... methods useful repositories basically. neo4j singleton contain graphdatabaseservice instance , configuration stuff. this relatively complex structure want project modular. makes easy dependency injection.

php - Facebook CurlException 3 No URL set -

i getting facebookapiexception object ( [result:protected] => array ( [error_code] => 3 [error] => array ( [message] => no url set! [type] => curlexception ) ) [message:protected] => no url set! [string:private] => [code:protected] => 3 [file:protected] => /home5/theteci0/public_html/team/fb6/base_facebook.php [line:protected] => 979 [trace:private] => array ( [0] => array ( [file] => /home5/theteci0/public_html/team/fb6/base_facebook.php [line] => 911 [function] => makerequest [class] => basefacebook [type] => -> [args] => array ( [0] => https://graph.facebook.com/172535322883581_253291878141258 [1] => array

Why isn't my jQuery tooltip acting like a jQuery tooltip? -

i'm working on presenting yet periodic table, , running issues jquery ui tooltips. page ends, without javascript errors, at: <script src="/js/vendor/jquery-1.8.2.min.js"></script> <script src="/js/jquery-ui-1.10.2/ui/jquery-ui.js"></script> <script src="/js/jquery-ui-1.10.2/ui/jquery.ui.tooltip.js"></script> <script> jquery(document).tooltip(); </script> earlier giving no javascript errors default styled (chrome yellow on black, small font size) tooltip, unlike tooltip in jquery ui demo @ http://jqueryui.com/tooltip/ (both td , td > span). displays screen contents second or so, , blanks out display. what wrong http://jonathanscorner.com/periodic/content.html , how can fix displays page , displays jquery ui's default tooltip version of tooltip? top left corner has title. i created fiddle, markup of page. please note fiddle add html, head , body tag... , seems work fine: fid

c++ - Cannot find sin(double), sin(double&), cos(double), cos(double&) -

this simple question puzzling me. i'm getting following error(s) 1 source file not other: 4 src/source2.cpp:1466: error: no matching function call ‘cos(double&)’ 5 src/source2.cpp:1466: error: no matching function call ‘sin(double)’ 6 src/source2.cpp:1467: error: no matching function call ‘sin(double&)’ 7 src/source2.cpp:1467: error: no matching function call ‘sin(double)’ 8 src/source2.cpp:1468: error: no matching function call ‘cos(double)’ 9 src/source2.cpp:1479: error: no matching function call ‘cos(double&)’ 10 src/source2.cpp:1479: error: no matching function call ‘sin(double)’ 11 src/source2.cpp:1480: error: no matching function call ‘sin(double&)’ 12 src/source2.cpp:1480: error: no matching function call ‘sin(double)’ 13 src/source2.cpp:1481: error: no matching function call ‘cos(double)’ which weird since have header1.hpp/source1.cpp working, header2.hpp/source2.cpp not working. difference between them source2 using "doubles" , sou

mysql - Require letter in [A-Z] set -

i'm trying match number plates in database using regex can set them type, don't have use regex in future queries. i've got 2 expressions match dateless / irish plates. need separate irish plates dateless plates. irish plates must include letter or z, dateless plates cannot include or z. these 2 expressions match both dateless , irish. regexp '^[a-z]{1,3}[0-9]{1,4}$' regexp '^[0-9]{1,4}[a-z]{1,3}$' the problem have excluding i-z, can [a-hj-y], result in crossovers. how can modify expressions above require , z, , set of expressions exclude , z. many thanks irish plates either: ^([iz][a-z]{0,2}|[a-z]([iz][a-z]?|[a-z][iz]))[0-9]{1,4}$ ^[0-9]{1,4}([iz][a-z]{0,2}|[a-z]([iz][a-z]?|[a-z][iz]))$ if you're prepared tolerate 5 letters, these can simplified to: ^[a-z]{0,2}[iz][a-z]{0,2}[0-9]{1,4}$ ^[0-9]{1,4}[a-z]{0,2}[iz][a-z]{0,2}$ dateless plates either: ^[a-hj-y]{1,3}[0-9]{1,4}$ ^[0-9]{1,4}[a-hj-y]{1,3}$

asp.net mvc 4 - SimpleMembershipProvider roles not accessible -

i have mvc4 application uses simplemembershipprovider authentication mechanism. everything works fine, apart of when return application , authenticate using persistant cookie. i authenticated fine, cannot access roles assigned to. effectively, cannot access roles @ all: string.join(",", roles.getrolesforuser(user.identity.name)) returns empty string what might causing that? this can happen when simplemembershipprovider hasn't been initialized. example mvc forms authentication template assumes you'll allowing anonymous access site , doesn’t initialize membership provider until go login page. however, more common security technique require login site access , define menu choices in _layout page determined roles. but, if use persistent cookie, don’t revisit login page roles authenticated user aren’t loaded membership database. what want initialize provider when user enters site values loaded. this, want add following filter in registerglobalfilt

freetype2 - freetype use fallback for missing glyphs -

how can tell freetype use fallback font when string contain character not present in font i'm using default? i need render non-latin glyphs correctly in application. do have manage fallback myself? if so: how detect if there missing glyph in given string? i'm sorry, don't know if need handle fallback yourself, guess do. how detect if there missing glyph, use method: ft_get_char_index if returns 0, means symbol not found.

how to design a login page in jsp? -

my index.jsp consists of user name , password: <html> <head> <title>employee page </title> </head> <body> <br> <p> <h3> <center>please enter user name , password</center> </h3> </p> <br> <br> <form action="login.jsp " method = "post" > <center>username</center> <center> <input type="text" name="username"> </center> <center>password</center> <center> <input type="pass" name="pass"> </center> <center> <input type="submit" name="submit" value="login" onclick="login.jsp" >

android - Monodroid - Handling Click events inside ListAdapter rows -

i have listview arrayadapter set it, , each row in adapter contains 4 buttons need receive , handle click events. in android call setonclicklistener on each button when create cell, mono gives ability set event handlers click event instead. looks there's weirdness in mono though, because run 1 of 2 issues depending on set event handler. arrayadapter getview example 1: view tweetcell = convertview; if (tweetcell == null) { tweetcell = ((layoutinflater)context.getsystemservice (context.layoutinflaterservice)).inflate (resource.layout.tweetcell, null); tweetcell.findviewbyid (resource.id.btn_movetweet).click += (object sender, eventargs e) => movetweet (getitem(position)); tweetcell.findviewbyid (resource.id.btn_unfavoritetweet).click += (object sender, eventargs e) => unfavoritetweet (getitem(position)); tweetcell.findviewbyid (resource.id.btn_hidetweet).click += (object sender, eventargs e) => hidetweet (getitem(position)); tweetcell.findvi

How to create a dynamic table view in android -

Image
i used concept this: (1.) creating custom listview , code below: custom_row_view : <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_alignparenttop="true" > <!-- android:background="#801a1a1a" > --> <tablerow android:id="@+id/tablerow10" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:background="#000000" android:padding="1dp"> <textview android:id="@+id/textview1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_weight="1" android:padding="2dp"

linux - Openssl header not found -- error -

i need compile libwebsocket library for arm target requires openssl functioning. getting following error when build latest libwebsocket @ time of, cmake ... but openssl installed here whereis openssl openssl: /usr/bin/openssl /usr/bin/x11/openssl /usr/share/man/man1/openssl.1ssl.gz =================================== error ================ -- looking 4 include files stdlib.h, ..., float.h - found -- found zlib: /usr/lib/arm-linux-gnueabihf/libz.so (found version "1.2.7") zlib include dirs: /usr/include zlib libraries: /usr/lib/arm-linux-gnueabihf/libz.so compiling ssl support cmake error @ /usr/local/share/cmake-2.8/modules/findpackagehandlestandardargs.cmake:97 (message): not find openssl, try set path openssl root folder in system variable openssl_root_dir (missing: openssl_libraries openssl_include_dir) call stack (most recent call first): /usr/local/share/cmake-2.8/modules/findpackagehandlestandardargs.cmake:291 (_fphsa_failure_message) /usr/local/

bash - AWK, delete record when field match -

i use regular file has 2 fields, 1st account name (with spaces) , 2nd integer number, both fields separated \t , records separated \n . problem need delete records match 1st field string. code below: awk -v apenom="$apeynom" -f "\t" ' $1 != apenom { print $0; } ' $1 > $temp_file_2 it works records not first record, never matches first field first record? try changing script to: '$1 != apenom { print $0; next } { print "mismatch[", $1, "]" }' i have feeling have dirty input. there might space before separating tab character or something. have print out $1 when skipping.

Android receive SMS and mark it as read -

i using broadcastreceiver receiving sms in app. receives , start service handle sms content. works fine, want sms inside "received messages" folder of phone , marked read. possible? here code: public void onreceive(context context, intent intent) { madapter = new dataadapter(context); arraylist<string> numbers = madapter.getnumbers(); if (intent != null && intent.getaction() != null && action.comparetoignorecase(intent.getaction()) == 0) { object[] pduarray = (object[]) intent.getextras().get("pdus"); smsmessage[] messages = new smsmessage[pduarray.length]; int length = pduarray.length; (int = 0; < length; i++) { messages[i] = smsmessage.createfrompdu((byte[]) pduarray[i]); } string sms_from = messages[0].getdisplayoriginatingaddress(); if (numbers.contains(sms_from)) { stringbuilder bodytext = new stringbuilder(); (int = 0; <

datetime - Adding days to date in php -

i read not working me. here code: $today = date_create()->format("d/m/y"); // today 25/04/2013 $num_days = getnumberofdays(); $end_date = date("d/m/y", strtotime($today . " + $num_days days")); the value $end_date 31/12/1969 . doing wrong? from looks you're trying do, don't need $today (as defaults if date not supplied), eg: $end_date = date("d/m/y", strtotime("+ 5 days")); echo $end_date; result be 30/04/2013 if want provide date, need parameters other way round, per the manual : strtotime ( string $time [, int $now = time() ] )

objective c - ios: Updating UITableView inside AFNetworking success callback -

i'm trying load data api , show inside uitableview . used afnetworking network calls, i'm facing problem: can't access mytableview nor self inside success block. @property (weak, nonatomic) iboutlet uitableview *mytableview; @property (nonatomic,retain) nsmutablearray *mydatasource; @synthesize featuredproductstableview; - (void)viewdidload { [super viewdidload]; networkmanager *networkmanager = [networkmanager getinstance]; mydatasource = [nsmutablearray array]; [networkmanager getpath:@"example.com" parameters:nil success:^(afhttprequestoperation *operation, id json) { [mydatasource addobjectsfromarray:json]; [mytableview reloaddata]; } failure:^(afhttprequestoperation *operation, nserror *error) { nslog(@"%@",error); }]; } debugging code shows inside block can't access of self , mydatasource , or mytableview . how can solve issue? thanks. you should use : __block my

accordion - Jquery: SlideToggle on List with divs -

i'm trying use list elements build simple menu website. thing want show '.second-row' div when arrow clicked , hide other open, ways tried wasnt working. somebody me? example here you need second-row corresponds arrow-1 clicked: $('a.arrow-1 ').click(function () { $('.second-row').slideup(); $(this).parent('.first-row').siblings('.second-row').slidedown(); }); here's updated fiddle note: you'll want add logic check last clicked arrow-1 , , return if it's same current clicked 1 slideup()/slidedown() doesn't occur when clicking same arrow-1 twice.

php - PNG files won't upload -

i have following script use upload pictures; file works every other file extension except png files. there reason? this script; // initialization $result_final = ""; $counter = 0; // list of our known photo types $known_photo_types = array( 'image/pjpeg' => 'jpg', 'image/jpeg' => 'jpg', 'image/gif' => 'gif', 'image/bmp' => 'bmp', 'image/x-png' => 'png'); // gd function suffix list $gd_function_suffix = array( 'image/pjpeg' => 'jpeg', 'image/jpeg' => 'jpeg', 'image/gif' => 'gif', 'image/bmp' => 'wbmp', 'image/x-png' => 'png'); // fetch photo array sent preupload.php $photos_uploaded = $_files['photo_filename']; // fetch photo caption array $photo_caption = $_post['photo_caption']; while( $counter <= count($_files['photo_filename']['tmp_name']) )

command, concat and format the result of multiple list -

i search 2 things how concat result of command in file. how format result of net in html /format of wmic i want create command (in bat file) getting information of vm. sample : i use wmic , net. wmic product name,vendor,version,description,installdate /format:htable > vm_info.html net localgroup administrators > vm_info.html the result html file both list. /format:htable functionality provided built-in wmic . wmic provides while net commands not. so, formatting output of net localgroup <html> isn't possible unless write custom program that. but, concat results of 1 command quite simple: wmic product name,vendor,version,description,installdate /format:htable > vm_info.html net localgroup administrators >> vm_info.html notice >> used in second command. that's appends output instead of overwriting file.

javascript - replace for " " (space) doesn't work -

this question has answer here: replace.() not work 3 answers <!doctype html> <html> <body> <p id="demo">click button locate in string specifed value occurs.</p> <button onclick="myfunction()">try it</button> <script> function myfunction() { var =" picture"; a.replace(" ",""); var n=a.indexof(" "); document.getelementbyid("demo").innerhtml= n+a+n; } </script> </body> </html> i replace " "(space) out " picture" in example above but result seem it's not replace replace command. the result should "-1picture-1" after replace it's "0 picture0" with space in front of picture. (i use .indexof(" ") indicate there space in variable or not -1 mean doesn't ) what'

jquery - My cookie gets reset after clicking button -

i have joomla site , using rsform component create multi-page form. saving input field values in cookie before form submitted in case user decides can't finish filling out form. if user returns have function take cookie , loop through form , populate form fields values stored in cookie. can create , read cookie can't repopulate form. here flow. user goes website , website checks if have cookie stored on machine if not gets created. the cookie gets populated when user clicks button go next form view @ time take form , create json stringify serialized array , pass cookie stored. but noticed cookie not populated values until 3 form views deep. example if fill in first 2 textareas , click next button next form view, in console see cookie key pairs values empty. if fill in next textarea , click next button can see value first 2 textareas in console not textarea filled out. hope guys can understand trying say. have been @ weeks , can't figure out appreciated. here link