Posts

Showing posts from August, 2014

.net - asp.net CustomValidator on multiple controls -

i working page has series of checkboxes @ least 1 box must checked. the validator fires when click submit button , if no checkboxes checked indicates validation has failed. if check 1 of checkboxes validation message not go away until click submit button again. if using on control in had specified controltovalidate , fixed validation issue error message goes away immediately. however in case not setting controltovalidate due need validate several independent controls. so question can cause re-validation of custom validator? instance add on each checkbox onclick="revalidate()" force validation happen again. here sample code wrote demonstrate scenario. <script type="text/javascript"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> function isonecheckboxchecked(sender, args) { if (!$('[id$=checkbox1]').attr('checked') ...

algorithm - A special case of grouping coordinates -

i'm trying write program place students in cars carpooling event. have addresses each student, , can geocode each address coordinates (the addresses close enough can use euclidean distances between coordinates.) of students have cars , can drives others. how can efficiently group students in cars? know grouping done using algorithms k-mean, can find algorithms group n points m arbitrary-sized groups. groups of specific size , positioning. can start? greedy algorithm ensure first cars assigned have minimum pick-up distance, average high, imagine. say trying minimize total distance traveled. traveling salesman problem special instance of problem problem np-hard. puts in heuristics/approximation algorithms domain. the problem needs more specification, example howmany students can fit in given car. lets say, many want. how solve minimum spanning tree rooted @ final destination. each student car is responsible collecting children nodes. total distance traveled in @ 2x t...

XSD for the XML file that Nunit uses -

where can find xsd xml file nunit uses ? for results file? see results.xsd (note didn't display me, in chrome; may have view source, or download, see properly). a transform file, , sample results file, in parent directory . files in documentation package on nunit download page.

ruby on rails - RSpec-2 and Devise -

i create customized devise registration controller , want test rspec. i've tried simple test : it "creates new parent" parent.should receive(:new) post :create end but exception: failures: 1) parent::registrationscontroller post create creates new parent failure/error: post :create, { :commit => "daftar", uncaught throw `warden' # /home/starqle/.rvm/gems/ree-1.8.7-2010.02/gems/devise-1.1.3/lib/devise/hooks/timeoutable.rb:16:in `throw' # /home/starqle/.rvm/gems/ree-1.8.7-2010.02/gems/devise-1.1.3/lib/devise/hooks/timeoutable.rb:16 i put line within test: describe parent::registrationscontroller include devise::testhelpers end i put line: request.env["devise_mapping"] = devise.mappings[:parent] anybody have ideas solve problem? my previous answer little confusing. sorry. updated answer: root cause user not "confirmed" before "sign in". @user.confirm! sign_in ...

javascript - How to append unique spans to a table in jQuery? -

i have quick question, because brain refuses think evening. html <table> </table> <span>2010</span> <span>2009</span> <span>2009</span> <span>2009</span> <span>2008</span> <span>2008</span> <span>2007</span> jquery $('span').each(function() { $("table").append("<tr><td>"+$(span).text()+"</span>)</td></tr>"; }); desired output <table> <tr><td>2010</td></tr> <tr><td>2009</td></tr> <tr><td>2008</td></tr> <tr><td>2007</td></tr> the idea is, want display year not duplicated. i hope understood me. you can't inline string replacement that. you need concatenate using javascript's (stupidly dual purpose) + operator. you can't access span that. use this , jquery sets current el...

NPAPI and Google Chrome on Linux -

i'm working on npapi plugin on linux , have run several issues google chrome (albeit works on firefox). firstly, plugin execution hang , after long harrowing time figured out call npn_evaluate hangs when last parameter (for returned result ) null. works on firefox fine. solution pass address of npvariant type variable parameter , ignore value. after plugin loads fine i'm stuck error message: [8886:8886:195170759489:error:webkit/glue/plugins/webplugin_delegate_impl_gtk.cc(129)] not implemented reached in bool webplugindelegateimpl::windowedcreateplugin() windowed plugin without xembed. see http://code.google.com/p/chromium/issues/detail?id=38229 any ideas on how plugin working? you need use xembed in plugin work chrome. docs here: https://developer.mozilla.org/en/xembed_extension_for_mozilla_plugins firebreath uses method: http://firebreath.org it open source (bsd license), either use plugin or shamelessly "borrow" code xembed.

C: Passing a pointer down, updated pointer can't be accessed from calling functions! -

i've got problem- assign pointer variable in called function, when trying access updated pointer in calling functions, doesnt show updated, , results in seg fault. help! "bottommost function": void comparestrings(char* firstfrag, char* secondfrag, int* longestcommonlength, char* suffix, char* prefix, int* relative_pos) { suffix = firstfrag; prefix = secondfrag; } it called function (the printf triggers fault) int findbestoverlap(char* fragmentarray[], int fragmentcount, int* longestcommonlength, char* suffix, char* prefix, int* relative_pos) { comparestrings(fragmentarray[firstfrag], fragmentarray[secondfrag], longestcommonlength, suffix, prefix, relative_pos); printf("lcl: %i || prefix: %s || suffix: %s", *longestcommonlength, prefix, suffix); } the variables prefix , suffix in turned created in higher calling function, processstrings. void processstrings(char* fragmentarray[], int fragmentcount) { int longestcommonlength = 0...

javascript - Django 1.2.3 - Internationalization - makemessages does not detect all strings -

one more question django concerning localization of javascript files. django provides small , convenient javascript library used gettext internationalize strings in javascript files. i set (at least interpolate function works) , generate po file french language. however, not strings detected. don't know why because same. couldn't find on django trac , official docs. the javascript code in external file included in template , django apparently found because put 2 strings in po file. the inclusion in html template : <script src="{{media_url|default:'/media/'}}js/list.js" type="text/javascript"></script> the javascript code : /* --------------- * upload progress * --------------- */ $(document).ready(function() { $(function() { $('#upload_form').uploadprogress({ //... /* function called before starting upload */ start: function() { $("#upload_fo...

string array in c -

how use string array parameter in c? if write function signature: guess didnt explain myself well... i'll post code i'm trying work. int format_parameters(char* str) { char local_str[201] = ""; int = 0; int j = 0; int flip = 0; while(str[i]) { if((str[i] == '"') && (flip == 0)) flip = 1;//sentence allowed else if((str[i] == '"') && (flip == 1)) flip = 0;//sentence not allowed if(flip == 1) append_char(local_str, str[i]); //check if space else if(flip == 0) { int c = str[i]; if(!isspace(c)) append_char(local_str, str[i]); else { if((strlen(local_str) > 0) && (j < 4)) { //local-str copied param[j] here //printf("j = %d %s\n",j,local_str); local_str[0] = '\0'; j++; } ...

java - How to clear contents of a jTable ? -

i have jtable , it's got table model defined this: javax.swing.table.tablemodel datamodel = new javax.swing.table.defaulttablemodel(data, columns); tblcompounds.setmodel(datamodel); does know how can clear contents ? returns empty table ? easiest way: //private tablemodel datamodel; private defaulttablemodel datamodel; void setmodel() { vector data = makedata(); vector columns = makecolumns(); datamodel = new defaulttablemodel(data, columns); table.setmodel(datamodel); } void reset() { datamodel.setrowcount(0); } i.e. reset method tell model have 0 rows of data model fire appropriate data change events table rebuild itself.

sharepoint - how to programmatically (c#) find and replace in doc and docx file in share point library -

my job find , replace in .doc , .docx files saved in sharepoint document library. have alter documents in document library doing find , replace. please me in this... open xml formats word 2007 (.docx). need single solution find , replace in both .doc , .docx files. library contains .ppt,.pptx , excel sheets also.. i recommend take @ third party tool aspose: http://www.aspose.com/categories/.net-components/aspose.words-for-.net/default.aspx this supports both .doc , .docx, , have similar product powerpoint. experience aspose of high quality , easy implement.

debugging - PHP code debugger on the fly -

i have website on localhost, quite complicated 1 many links there program can debug example, happens when click 1 link?or login, etc , show me each function called in each file , that's happening scripts? you can use eclipse + pdt or netbeans php plugin , install recent version of xdebug . allow set breakpoints, inspect variables, etc. if want overall view of script/framework can use cachegrind files xdebug able produce , use viewer files (e.g. kcachegrind). understand how many times function called, time consuming parts of application are, etc..

c# - Problem with loading CSS while invoking page by Server.Transfer() -

while i'm using response.redirect("~/pages/page.aspx") , style loaded on page, unfortunately not loaded while i'm using server.transfer("~/pages/page.aspx") method. the page looks following: <html> <head runat="server"> <link href="../css/layout/style.css" type="text/css" rel="stylesheet" /> </head> <body></body> </html> how make page load style.css using server.transfer() ? regards the problem use relative path css file, should use abolute path. if css folder inside application root, can use <html> <head runat="server"> <link href="/css/layout/style.css" type="text/css" rel="stylesheet" /> </head> <body></body> </html> or even <html> <head runat="server"> <link href="~/css/layout/style.css" type="text/css" rel=...

.net - Windows Forms Control for visualizing job steps -

i looking (free) windows forms control visualizing jobs step / phases . background: in programm tasks more job steps processed. user should see, actual step (of current taks( processed (at best animated)... assuming application using threads prevent ui locking during these long tasks, recommend looking using built in reportprogress method built background workers. http://msdn.microsoft.com/en-us/library/a3zbdb1t.aspx as control, can update through method. recommend textbox or label though. if isn't option, clarify scenario bit more?

Zend framework module, controller, action specific routes -

in zend framework application, have routes , defaults like: resources.router.routes.plain.defaults.module = "index" resources.router.routes.plain.defaults.controller = "index" resources.router.routes.plain.defaults.action = "index" i want able change default routes module or controller or action e.g. let's assume module/controller/action structure: content --- article --- read --- write --- news --- list --- write user --- auth --- signin --- signout --- access --- check --- update in architecture, for module=content want controller=article default controller , action=read default action. if controller=news chosen action=list becomes default action for module= user want controller=auth default controller , action=signin default action. if controller=access chosen action=check becomes default action. so possible in application...

c# - Type-ing: how to pass the type? -

i have few tables in database , contain different inherited type of datarow. in addition have class supposed handle things in datagrid (my database tables connected datagrids). in order that, 1 of methods in datagrid handler has cast rows exact inherited type of datarow. something this: (tempdatarow datarowtypethatinheritsfromregulardatarow).specialparameter = something; in order that, have pass method inherited datarow type, know how casting. the method this: public void dosomething(datarowtype type) { (tempdatarow type).specialparameter = something; } how pass type? regular 'type' type not compile. , if pass 'datarow' won't know how casting. if using c# 4.0, have considered use of 'dynamic' type? dynamic row = getdatarow(); dosomething( row ); public void dosomething( datarowtypethatinheritsfromregulardatarow row ) { // <insert code here> } public void dosomething( someotherdatarowtype row ) { // <inser...

wpf - Retrieve the end position of the caret in the TextBox to put the Caret in the next TextBox -

how find end position of caret in wpf textbox can`t move right anymore caret? if need find caretindex @ following question . however, if looking jump next textbox under conditions check out following sample. here use textbox property maxlength , keyup event jump next textbox when 1 completed. here xaml: <grid> <grid.rowdefinitions> <rowdefinition/> <rowdefinition/> </grid.rowdefinitions> <stackpanel grid.row="0"> <textbox text="" maxlength="3" keyup="textbox_keyup" > </textbox> <textbox text="" maxlength="3" keyup="textbox_keyup"> </textbox> <textbox text="" maxlength="4" keyup="textbox_keyup"> </textbox> </stackpanel> </grid> here keyup event code-behind: private void textbox_keyup(object ...

java - In Brian Goetz Concurrency In Practice, why is there a while(true) in the final example of a scalable cache? -

in code listing 5.19 of brian goetz book concurrency in practice, presents finished thread safe memoizer class. i thought understood code in example, except don't understand while ( true ) is @ start of public v compute(final arg) throws interruptedexception method. why code need while loop? here entire code sample public class memoizer<a, v> implements computable<a, v> { private final concurrentmap<a, future<v>> cache = new concurrenthashmap<a, future<v>>(); private final computable<a, v> c; public memoizer(computable<a, v> c) { this.c = c; } public v compute(final arg) throws interruptedexception { while (true) { future<v> f = cache.get(arg); if (f == null) { callable<v> eval = new callable<v>() { public v call() throws interruptedexception { return c.compute(arg); ...

ipad - iphone - running app on 3.1 with iAd framework -

i built app in ios 4.1 , app has iad framework. want set deployment target 3.1 app runs on older iphone devices well. add iad banner view, i'm used ib , added ads app. how can make app run on older iphone os , on ipads. you'll have set role of framework weak, , make runtime checks in order handle behavior on different ios versions. the messagecomposer sample project same - can view readme.txt there more details , source code.

python - compatibility between CPython and IronPython cPickle -

i wondering whether objects serialized using cpython's cpickle readable using ironpython's cpickle; objects in question not require modules outside of built-ins both cpython , ironpython include. thank you! if use default protocol (0) text based, things should work. i'm not sure happen if use higher protocol. it's easy test ...

how can i use ugly slugs in wordpress using non-western character? -

hey said in question : how can use ugly slugs in wordpress using non-western character? more details @ : http://en.support.wordpress.com/posts/post-title-url/ if language uses non-western character set, long post titles can break post slugs. fix that, shorten post slug single word. so want keep long post titles evenif use non-western character arabic , please can me? if understood correctly, want edit differently slug title, right? so, in link you've putted, click on post's url in post edit page, , edit slug wish (as described in second image in codex link).

SVN post-commit user permissions -

i've debian webserver subversion running on it. i'm trying use post-commit script update staging version of site. #!/bin/sh /usr/bin/svn update /home/sites/example.com/www >> /var/log/svn/example.log 2>&1 if run command command line logged in user 'derek' works fine but when runs post-commit following error in log file: svn: can't open file '/home/sites/example.com/www/.svn/lock': permission denied ok, realize happening here user calling post-commit script isn't 'derek' hasn't permission. so question user calling post-commit script. the svnserve daemon run derek ... thought mean post-commit command called derek seems not. any ideas how can find out user calling and secondly best practice method allow access user? don't think adding group because group doesn't have write access .svn directories default. update: i've found out user calling post-commit script www-data. how solve problem. ...

actionscript 3 - Different MD5 with as3corelib -

i'm trying md5 file as3corelib , if compare as3 hash php one, different strings. that's do: _loader = new urlloader(); _loader.load( new urlrequest( "image.jpg" ) ); _loader.addeventlistener( event.complete, completehandler ); private function completehandler( event:event ):void { var data:bytearray = new bytearray(); data.writeutfbytes( _loader.data ); var hash:md5stream = new md5stream(); trace(hash.complete(data)); } i've googled issue, finding post similar thing discussed (making hash of string). any idea? try set loader dataformat property urlloaderdataformat.binary prior load() call: _loader = new urlloader(); _loader.dataformat = urlloaderdataformat.binary; _loader.load( new urlrequest( "image.jpg" ) ); _loader.addeventlistener( event.complete, completehandler ); private function completehandler( event:event ):void { var hash:md5stream = new md5stream(); trace(hash.complete(_lo...

vb.net - AVRdude encrypt/decryption HEX file on the fly in VB -

hey looking decrypt hex code file attiny chip , programming using avrdude command line interface. problem being, not want user able see hex file @ given time. can vb.net cryptography crypt hex file before put onto server , decrypt after program downloads server , runs through program without seeing decrypted hex file? obviously hex file can not stay encrypted while being programmed attiny chip how can go can create original hex file programmed within program without having worry writing temporary file hard drive , deleting afterwards? (because close program after temp file , able navigate , open , see code) any great! :o) david as pointed out, if decrypt file on host there in unencrypted form, , can't that. the industry has same problem time time, got ways cryptography: needed prevent else able compiled , runnable file "they" decompile or @ in assembly, needed prevent anyoneelse able run proper, home-brewn files on device. as said, decrypting file...

mod rewrite - mod_rewrite and server environment variables -

the setup have follows: i have 1 apache server acting url rewriting engine (server1). i have second server (apache too) runs web application (server2). first tries authenticate users. part of authentication protocol involves lot of redirection between application server , authentication server. my problem once authencation successfull, authentication server needs redirect user application server, visible server1. effectively, server2 needs able reconstruct url based on server1's parameters. most of environement variable helpful i.e. know host name, script name, page called etcc can 't figure out wether call made through http or https: information wiped in rewrite process server1... anybody knows if/how can information through environement variables? limited in can't use query string parameters... thanks ! this may sound strange, have found part of answer question. the rewrite engine (at least in apache 2, haven't looked anywhere else) allows w...

PHP/Mysql array_pop missing first value -

basically happens this: a person goes specific gallery, galleryid=42. query grab of images in gallery (with value of galleryid=42), , separate query grab of comments associated gallery (for example galleryid=42). there may 4 comments total on 3 different pictures out of 400 total images. as loop through images do/while loop, , display them, search array of comments have been placed each picture loops. if finds picture id matches specific picture, displays comment values (comment, commentauthor, , commentdate). here query images: select * gallerydata galleryid = 42 and query comments: select comment, commentauthor, commentdate, id comments categoryid=42 then use code put comments in reusable query: while(($comments[] = mysql_fetch_assoc($rscomments)) || array_pop($comments)); then use this loop through array find comments associated particular picture foreach($comments $comment) { if($comment['id'] == $row_rsgalleries['id']) { echo ...

attributes - Magento: Difference between loading product through collection than product model -

so trying load product through collection criteria, didn't have sku or id when did following $prodmodel->getcollection() ->addattributetofilter('visibility', $visibility) ->addattributetoselect('*') ->addcategoryfilter($cat) ->addattributetofilter('attribute_1', $sattribute_1) ->addattributetofilter('attribute_2', $attribute_2) ->addattributetofilter('type_id', 'configurable') ->load() ->getfirstitem() when doing got product wanted reason didn't have of attributes, though specified "*" attributes. 1 not getting media gallery attribute. ended doing saying getfirstitem()->getid() loaded product , worked find. i don't understand whey loading product catalog product model have more attributes. i understand asked how of attributes notice mention media gallery attribute specifically. there happens shortcut gett...

How do I do a free text search in Azure Table Storage? -

i have solution azure table storage few tusands "rows" per customer (partition key). how best lightning fast free text search? because of nature of data i'm not able hole word search (eg. search "zur" should match "azure"). just spotted may you: azure library lucene

html - jQuery selected options in conditional statements -

i'm trying display text in div named "msg_box" each selected option. works not live. have refresh see result. the js is.. $(function () { switch ($('#my_options :selected').val()) { case '1': $('.msg_box').html('you selected option one'); break; case '2': $('.msg_box').html('you selected option two'); break; } }); the div text should appear according selected option.. <div class="msg_box"></div> and form.. <select id="my_options"> <option value="0">select...</option> <option value="1">something</option> <option value="2"> else </option> </select> can please share how change html() dynamically? you'll want use a .change() event handler <select> : try out: http://jsfiddle.net/mjnc3/2/ $(function() { $(...

ffmpeg - How to isolate server disaster script in PHP? -

oh goodness. never thought need ask this. unfortunately yes, need to! i have php written script of own uses ffmpeg-php. , ffmpeg-php bastard. input works ok, crashes whole php , server throws internal server error 500. i've tried several times update ffmpeg-php, ffmpeg , on, when input works in version 0.5 in 0.6 wont work. , need sure rest of script processed correctly. , not, because when comes run togdimage() on movie frame have internal server error 500 , no feedback why source. so peace of mind of users decided need isolate part of script messes ffmpeg-php. need way assure if go terribly wrong in part, rest go on. try catch not work because not warning, nor fatal error, horrible server-disaster. suggestions? i think putting script file called ffmpeg-php-process.php , call via http , read result, if internal server error 500 - know not ok. or there other, more neat ways isolate disaster scripts in php? ps. don't write need diagnose or debug or find source of...

iphone - Placing a UITextField in the center of the view -

i have uitextfield , want center field on center of view. ideas? usernamefield = [[uitextfield alloc] initwithframe:cgrectmake(0, 200, 200, 28)]; instead of cgrectmake(some numbers) - want place in center of view. you can directly assign center of desired view: usernamefield = [[uitextfield alloc] initwithframe:cgrectmake(0, 200, 200, 28)]; usernamefield.center = myview.center;

c++ - parallel calculation of infinite series -

i have quick question, on how speed calculations of infinite series. 1 of examples: arctan(x) = x - x^3/3 + x^5/5 - x^7/7 + .... lets have library allow work big numbers, first obvious solution start adding/subtracting each element of sequence until reach target n. you can pre-save x^n each next element instead of calculating x^(n+2) can lastx*(x^2) but on seems sequential task, , can utilize multiple processors (8+)??. thanks lot! edit: need calculate 100k 1m iterations. c++ based application, looking abstract solution, shouldn't matter. reply. you need break problem down match number of processors or threads have. in case have example 1 processor working on terms , working on odd terms. instead of precalculating x^2 , using lastx*(x^2), use lastx*(x^4) skip every other term. use 8 processors, multiply previous term x^16 skip 8 terms. p.s. of time when presented problem this, it's worthwhile more efficient way of calculating result. better algorithms ...

What this mean in javascript? -

possible duplicate: explain javascript's encapsulated anonymous function syntax i have read javascript book have seen code: 1(function() { // code })(); what ? special function ? as written, has syntax error. i'm guessing more like: (function() { // code })(); or (function() { // code } )(); break down: (foo)() // calls foo no arguments. and function() { //creates function takes no arguments. // code } hence create function takes no arguments, , call it. can't see why apart showing can.

c# - AutoEllipsis at the beginning of a label -

i have label on form used display path. path long display, turned on autoellipsis, seems truncate end of string (which more relevant part in particular case). there way automatically truncate beginning? is there control can use display path? there project on code project looks want: auto ellipsis . there demo can download along source.

Jquery Problem With Changing Element Attribute In Internet Explorer -

i using jquery create dynamic links based on user input. have set of elements in ajax loaded div looks this <div class="mxcell"> <input type="text" size="40" class="input_name" value=""> <a href="#" target="_blank" class="dyn_link"> <img src="http://127.0.0.1/images/arrow_right.gif"> </a> </div> now in jquery write $(function(){ $("#right").delegate(".input_name", "change", function(){ var dyn_link = $(this).val() $(this).parent().find("a").attr("href", "http://www.example.com/"+ dyn_link +".html"); }); }); this works fine in chrome/firefox, not in internet explorer. any ideas? ie debugger pointed jquery line 69 character 15. wouldn't know investigate further. update: i solved above using focusout() instead of change() but not still sure whether there better solution ...

Not able to create thumbnails on linux environment in java application -

i not able create thumbnails on linux environment in java application. libraries using packages import java.awt.graphics2d; import java.awt.image; import java.awt.mediatracker; import java.awt.panel; import java.awt.renderinghints; import java.awt.image.bufferedimage; import java.io.bytearrayoutputstream; import java.io.ioexception; import com.sun.image.codec.jpeg.jpegcodec; import com.sun.image.codec.jpeg.jpegencodeparam; import com.sun.image.codec.jpeg.jpegimageencoder; to craete thumbnail graphics2d class craete thumbnails. this working in windows environment , 1 of our linux machine also, not working in other linux machine whihch has no graphics crad in it. please advice , help. thanks in advance try add following system property on command line launches program: -djava.awt.headless=true

wpf - ListView Losing Selection before Start Drag -

i got listview following. user supposed select items , dragdrop somewhere else. not require ctrl+click good. after selection made, when try start drag, left click un-selects teh item got clicked. how can make behave windows explorer, selection dont change when start drag mouse. wasted quite bit of time, tried claimed solutions out there, 1 sub class both listview , listviewitem , messing previewmouseleftbuttondown nothing has worked me. tia! <listview selectionmode="multiple" grid.column="1" > <listview.view> <gridview> <gridviewcolumn width="25"> <gridviewcolumn.celltemplate> <datatemplate> <checkbox ischecked="{binding path=isselected, relativesource={relativesource findancestor, ancestortype=listviewitem, ancestorlevel=1}}" /> </datatemplate> ...

php - Couldn't get desired results via preg_match_all -

i trying program email piping php script take incoming traffic update report via email, , extract relevant information within store database. the email starts introduction, important information displayed in following format. highway : highway time : 08-oct-2010 08:10 condition : smooth (or slow moving etc) i tried code preg_match_all('/(?p<\name>\w+) : (?p<\data>\w+)/i', $subject, $result); note < / < somehow not being displayed here. and matches only: highway : datetime : 08 condition : smooth can tell me what's missing in second regex expression? why doesn't include entire string of words after ":"? you capturing \w+ . matches word characters, not include spaces or parenthesis. try preg_match_all('/(?p<name>\w+)\s*:\s*(?p<data>.*)/i', $subject, $result); try using .*? match new line character

Transaction in REST WCF service -

we having rest wcf service. want save operation on rest service in transaction. there way pass transaction object on wire rest wcf service? here quote roy fielding, guy invented term rest if find in need of distributed transaction protocol, how can possibly architecture based on rest? cannot see how can 1 situation (of using restful application state on client , hypermedia determine state transitions) next situation of needing distributed agreement of transaction semantics wherein client has tell server how manage own resources. ...for consider "rest transaction" oxymoron. this message on rest-discuss list june 9th, 2009.

java - DB2 SQL-Error: -519, SQLState: 24506 -

there strut application throws -519 error sometimes. have restart tomcat whenever error occures. you can find te detail of -519 here it happens. not able understand actual cause , solution. please make sure code fetches results resultset , make sure resultset , preparedstatement close()d. if not ensure these things possible cursor not automatically closed in db2. in case database connection gets returned connection pool not resources have been freed properly. when eactly same sql statement prepared again using same connection error in question. if custom code of yours recommend using pmd , findbugs extensively while developing because warn eagerly not closing resources.

javascript - How to call function using the value stored in a variable? -

i have variable var functionname="givevote"; what need is, want call function stored in var functionname . tried using functionname(); . not working. please help. edit based on same problem, have $(this).rules("add", {txtinf: "^[a-za-z'.\s]{1,40}$" }); rules predifined function takes methodname:, here have hardcoded txtinf. want supply javascript variable here, make code generic. var methodname="txtinf"; here want evaluate methodname first before being used in rules function. $(this).rules("add", {mehtodname: "^[a-za-z'.\s]{1,40}$" }); you have handful of options - 2 basic ones include window[functionname]() or settimeout(functionname, 0) . give shot. edit: if variable string name of function, use those; otherwise, if you're able assign function reference variable (eg, var foo = function() {}; ), use foo() notation, or foo.apply(this, []) , etc. edit 2: evaluate methodname in ...

Is it possible to stream music over a bluetooth p2p connection using iPhones -

i trying connect multiple iphones using bluetooth. thinking of having server/client system. want know upto how many devices can connected using bluetooth? not able find reliable answer online. also if know of tutorials regarding great if point me it. thanks ac a single bluetooth device can connect upto 7 devices in piconet. if device can scatternet can connected more devices.. application level connection can happen if both devices supports required profiles , corresponding role. if trying stream music , profile used a2dp , 1 device need a2dp source , other a2dp sink, in case of iphone supports a2dp source. 2 iphone not connect each other.

Android : Finish Activity from other Activity -

i having application in using menu , on tap on menu item redirecting specified activity. i want make sure when redirected menu item current activity should finished reduce stackflow of activity , better performance. so when tap on tapped activity selected menu activity should redirected activity , finish current activity. so wondering there way can finish activity current activity. or should override onkeydown method.. any on this thanks in advance you can do: intent intent = new intent(....) ; // intent launch new activity // fire intent finish(); // finish current activity

Are there any Quality Management tools other than SonarQube -

we in our organization trying implement source code quality management tool. sonarqube 1 such tool have come across, , it's quite full of features , phenomenal. want compare peers, if there any, before implement it. are there contenders sonar's capabilities , features? squale (free) kalistick metrixware cast

c# - Observer Pattern or just create event handling? -

i want create " modules " layout in web application can add more modules of same type, example: as example , webapp handles subscriptions , email campaigns, , want create interface allow coupling multiple api's, mailchimp, campaignmonitor, icontact, etc... so create imailingservice interface set ground rules , modules implement public class campaignmonitorservice : imailingservice so far good... how fire interface method upon action on webapp? should implement observer design pattern , should simple create event handlers, or other hook? for example, upon user subscription fire addsubscriber method on interface addsubscriber(string email, string[] args); some thing creating list, unsubscribing, etc, etc... what best approach handle such scenario ? event handlers are how observer pattern implemented in .net. pattern first class citizen of .net world, how iterator pattern built in (with foreach , yield return ). if want use pattern wi...

properties - How to programmingly set the loading path of dynamic libraries in java? -

system.setproperty("java.library.path", "pathtolibs"); doesnt work because seems either "java.library.path" read or jvm ignores property. i know can done setting path(in windows), ld_library_path(in posix) or use command java -djava.library.path=your_path. but there programming way of doing this? java.library.path evaluated when vm starts, changing later not have effect on loading native libraries. can use system.load(string filename); specify complete path native library want load, perhaps system.maplibraryname(string) add platform specific file ending (e.g. .dll or .so).

Is it allowed to cache static google maps? -

i'm having issue static google maps generation. api has "a query limit of 1000 unique (different) image requests per viewer per day. since restriction quota per viewer, developers should not need worry exceeding quota". however when using shared connection, instance mobile phone , 3g access (phone operators), limit seems problematic. hence question following: can retrieve image server-side , serve clients? allowed? this faq indicates not: can generate map image using google static maps api store , serve website? text (as of november 2016): can generate map image using google static maps api store , serve website? you may not store , serve copies of images generated using google static maps api website. web pages require static images must link src attribute of html img tag or css background-image attribute of html div tag directly google static maps api map images displayed within html content of web page , served directly end users google. ...

vb.net - Problem while sending JSON DATA -

i have pass json data in particular format. app coded in vb. the following code : dim jsonobject new json.jsonobject jsonobject.item("count") = new json.jsonnumber("0") jsonobject.item("data") = new json.jsonarray("") **jsonobject.item("success") = new json.jsonstring("true")** problem lies in line : jsonobject.item("success") = new json.jsonstring("true") . error message being shown " type 'jayrock.json.jsonstring' has no constructors." just add have imported associated libraries . what should tackle problem ?? try this: dim jsonobject new json.jsonobject jsonobject.item("count") = 0 jsonobject.item("data") = new json.jsonarray() jsonobject.item("success") = "true" in other words, can use primitive types string , integer values.

struts2 - calculate in struts 2 tag? -

i have iterate , want calculate sum of values : <s:iterator value="myvalues" status="mystatus"> <s:property value="value" /> </s:iterator> <s:property value="total.here" /> i want show sum of "value" in "total.here". sorry bad english. thank much. assuming myvalues array or list of integral values accessible action: <s:set var="total" value="%{0}" /> <s:iterator value="myvalues"> <s:set var="total" value="%{top + #attr.total}" /> </s:iterator> <s:property value="%{'' + #attr.total}" />

debugging - Exceptions/errors handling library for PHP -

is there php library handling exceptions/errors(including fatal) in php? should configurable, support log file, send emails, , have integration different browsers console. the best library found lagger - support firephp extension firefox , has own extension google chrome console

soap - how can I parse http post content included well formed XML and binary data? -

i receiving mobile originated mms web app http post. when receive content includes raw information, formed xml , binary formatted data (i.e. image). i want fetch xml can parse , binary data content convert image. following content sample: ------=_part_121809_1523072928.1286496211187 content-type: text/xml content-id: <soap-start> <?xml version="1.0" encoding="utf-8" standalone="yes"?><ns1:envelope xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns3="http://www.3gpp.org/ftp/specs/archive/23_series/23.140/schema/rel-6-mm7-1-4"><ns1:header><ns3:transactionid ns1:mustunderstand="1">gw0110l-m1007n6-m200331g0-snsrpn</ns3:transactionid></ns1:header><ns1:body><ns3:deliverreq><ns3:mm7version>6.8.0</ns3:mm7version><ns3:linkedid>gw0110l-m1007n6-m200331g0-snsrpn</ns3:linkedid><ns3:sender><ns3:number>+16123060744...

criteria - newbie Nhibernate join query in a DetachedCriteria -

i have domain this: class project { ... unit projectunit } class unit { ... ilist<user> users } class user { ... } i have projects based on 1 user, so: each project unit.users contain query user. how can translate detachedcriteria? this assumes have id property on user class , you're passing in user user. detachedcriteria query = detachedcriteria.for(typeof(project),"project") .createcriteria("projectunit","unit") .createcriteria("users","users") .add(expression.eq("id", user.id));

c# - Namespaces - How deep is too deep -

we reorganising of our services projects naming more logical. have following structure: djp.services. type . servicename this seems make sense logical grouping, want know is, acceptable have further levels under based on folders in project. example 1 project called djp.services.management.data under project have "poco" folder , "repositories" folder, means, in principal, objects under these folders have namespace 5 levels deep. is depth of namespace should avoided, or reasonable? any namespace follows logic of application structure fine - regardless of length.

javascript - Why $('a.current').removeClass('current'); is not working? -

why $('a.current').removeclass('current'); not working jquery tabs? http://jsfiddle.net/laukstein/ytnw9/8/ //full js in http://jsfiddle.net/laukstein/ytnw9/8/ $(function(){ var list=$('#list'), elementsperrow=-1, loop=true, // find first image y-offset find number of images per row topoffset=list.find('a:eq(0)').offset().top, numtabs=list.find('li').length-1, current,newcurrent; function changetab(diff){ // a.current set jquery tools tab plugin $('li.current').removeclass('current'); current=list.find('a.current').parent('li').addclass('current').index(); newcurrent=(loop)?(current+diff+numtabs+1)%(numtabs+1):current+diff; if(loop){ if(newcurrent>numtabs){newcurrent=0;} if(newcurrent<0){newcurrent=numtabs;} }else{ if(newcurrent>numtabs){newcurrent=numtabs;} if(newcurrent<0){newcurrent=0;} } // don't trigger change if tab hasn...

Grails: Groovy error reported on tomcat plugin after creating a new project -

i using springsource tool suite version: 2.3.3.ci-r5608-b54 build id: 201008210801 with java 1.6.0.u21 & grails 1.3.5 i created new grails plugin project , after process completed, sts reported problem below. had problem before when creating grails project got fixed if grails clean or project clean. time problem not getting fixed! description resource path location type groovy:the class java.lang.class refers class java.lang.class , uses 1 parameters, referred class takes no parameters tomcatserver.groovy /samplegrails/tomcat-1.3.5-src-groovy/org/grails/tomcat line 439 java problem what can done fix problem? thank you. jay chandran i can't reproduce in sts 2.5.0m3 perhaps it's issue that's been fixed. can install 2.5 http://www.springsource.com/products/springsource-google-download . it's technically milestone release stable , has lot more features (esp groovy , grails) - haven't had issues using it. you might try mailing l...

jquery - JavaScript Event Handler in ASP.NET -

i have following iframe control (intended facebook button): <iframe id="likebutton" src="http://www.facebook.com/plugins/like.php?href=" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" onprerender="setuplink()" </iframe> i have javascript function defined above follows: <script type="text/javascript"> function setuplink() { var iframe = $("#likebutton"); var newsrc = iframe.attr("src"); newsrc += encodeuricomponent(location.href) + lblkey.text; iframe.attr("src", newsrc); }; </script> lblkey label on asp.net page references specific section of page. however, far can determine, function doesn’t called (if put alert() @ start brings nothing up). i’m new javascript, looking around @ articles on web indicate should update src property on iframe. edit:...

broadcastreceiver - Android receive Data_Sms -

my android app sends data sms. phones able receive message except android. have added broadcast receiver in manifest: <receiver android:name=".smsreceiver"> <intent-filter android:priority="10"> <action android:name="android.intent.action.data_sms_received" /> <data android:scheme="sms" /> <data android:port="5009" /> </intent-filter> </receiver> the application not give response when data sms received, although msg reaches inbox. help. it looks might known issue, see stackoverflow question: how send , receive data sms messages this blog seemed suggest possible, comments underneath indicate never got work.

Problem with adding sprite using CCSprite array in cocos2d -

i have problem following code. myspritearray=[[nsmutablearray alloc] init]; star=[ccsprite spritewithfile:@"22.png"]; for(int i=0;i<10; i++) { [myspritearray insertobject:star atindex:i]; } // nslog(@"x=%i",[myspritearray count]); (int i=0; i<10; i++) // opponents nsmutablearray { ccsprite *tempsprite = (ccsprite *) [myspritearray objectatindex:i]; tempsprite.position=ccp(100,100); [self addchild:tempsprite]; } } star object of ccsprite , myspritearray mutable array.the problem when run program crash , say * assertion failure in -[gamescene addchild:z:tag:], /users/salimsazzad/desktop/balon hunter/libs/cocos2d/ccnode.m:305 2010-10-08 19:05:35.854 balon hunter[3967:207] * terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'child added. can't added again'. i can't understand whats wrong,i adding 10 obje...

mysql - How do I use num_rows() function in the MySQLDB API for Python? -

i have statement cursor = connection.cursor() query = "select * table" cursor.execute(query) res = cursor.fetchall() cursor = connection.cursor() query = "select * table" cursor.execute(query) print cursor.rowcount according python database api specification v2.0 , rowcount attribute of cursor object should return number of rows last query produced or affected (the latter queries alter database). if database module conforms api specification, should able use rowcount attribute. the num_rows() function looking not exist in mysqldb module. there internal module called _mysql has result class num_rows method, shouldn't using - existence of _mysql considered implementation detail.

YET another question about installer for Java App -

i read many posts installers java app , i'd opinions best choices. requirements aren't long. need: - installer install java, mysql , run database script file; - create shortcut java app. i'm looking open source/free choices. look nsis . it's pretty easy use, can call out other installers (so user has follow other dialogs completion), , can create shortcuts. it's quite powerful. it generates installers windows only, though; no debs or rpms.

jquery - tabbing between jeditable fields in a table -

i'm using code here http://www.korvus.com/blog/geek/making-the-tab-key-work-with-jeditable-fields/ tabbing between jeditable fields working, , if fields on own works fine. need have fields in table, , time tab key works tabbing last field first, , of course need tab first next , on... $('div.edit').bind('keydown', function(evt) { if(evt.keycode==9) { $(this).find("input").blur(); var nextbox=''; if ($("div.edit").index(this) == ($("div.edit").length-1)) { nextbox=$("div.edit:first"); //last box, go first } else { nextbox=$(this).next("div.edit"); //next box in line } $(nextbox).click(); //go assigned next box return false; //suppress normal tab }; }); the table formatted this <table> <tr> <td class='leftcolumn'> <strong>firstname:</strong> </td> <td> ...

c - Increment and Decrement Operators -

#include <stdio.h> int main() { int x = 4, y, z; y = --x; z = x--; printf("%d %d %d", x, y, z); } output: 2 3 3 can explain this? , i =+ j mean (suppose i = 1 , j = 2 )? simple explanation: --x or ++x : value modified after. x-- or x++ : value modified before detailed explanation: --x or ++x : pre-decrement/increment: first operation of decrementing or incrementing first, assign x. x-- or x++ : post:decrement/increment : first assign value of x , operation of decrementing or incrementing after. lets write code in nicer format , go through code step step , annotate show visually happens: main() { //we declare variables x, y , z, x given value of 4. int x=4,y,z; //--x decrement var x 1 first assign value of x y. //so: x = 3, y = 3 , z = nothing yet. y = --x; //x-- assign value of x z first, var x decremented 1 after. //so: x = 2, y=3 , z = 3 z = x--; printf ("\n %d %d %d", x,y...

exception handling - How to raise a warning in Python without stopping (interrupting) the program? -

i dealing problem how raise warning in python without having let program crash / stop / interrupt. i use following simple function checks if user passed non-zero number. if user passes zero, program should warn user, continue normally. should work following code, should use class warning(), error() or exception() instead of printing warning out manually. def iszero( i): if != 0: print "ok" else: print "warning: input 0!" return if use code below , pass 0 function, program crashes , value never returned. instead, want program continue , inform user passed 0 function. def iszero( i): if != 0: print "ok" else: raise warning("the input 0!") return the point want able test warning has been thrown testing unittest. if print message out, not able test assertraises in unittest. thank you, tomas you shouldn't raise warning, should using warnings module. raising you're generating erro...

qt - How to hide a QWidget under its parent? -

i have modal qdialog, on click of button slides modeless child qdialog out underneath it. problem have child stays on top of parent during animation. i think away applying mask on portion of child overlaps parent, feels i'm missing more obvious way of placing child under parent. i'm using qt 4.5. here's sample code: void mainwindow::on_mymenu_triggered() { parentdlg = new qdialog(this); parentdlg->setfixedsize(250, 250); parentdlg->setmodal(true); parentdlg->show(); childdlg = new qdialog(parentdlg); childdlg->setfixedsize(150, 150); childdlg->show(); qtimeline* timeline = new qtimeline(1000, this); connect(timeline, signal(valuechanged(qreal)), this, slot(childdlgstepchanged(qreal))); timeline->start(); } void mainwindow::childdlgstepchanged(qreal) { int parentx = parentdlg->framegeometry().x(); int parenty = parentdlg->geometry().y(); // move child dialog left of parent. childd...

javascript - Prompting for download -

whats best method prompt user download something? in past i've used window.open('file.pdf'); can see popup blockers having problem this. of course i'll include manual link aswel. i want microsoft download page . whats script prompts this? redirect using javascript. function redirect() { window.location = 'http://www.url.to/your.file'; }

Delphi: Overridden virtual constructor descendant not being called by overload -

yet in series of questions regarding constructors in delphi. i have base class has has virtual constructor: tcomputer = class(tobject) public constructor create(teapot: integer); virtual; end; the constructor virtual times needs call var computerclass: class of tcomputer; computer: tcomputer; begin computer := computerclass.create(nteapot); the constructor overridden in descendants: tcellphone = class(tcomputer) public constructor create(teapot: integer); override; end; tiphone = class(tcellphone ) public constructor create(teapot: integer); override; end; where tcellphone , tiphone descendants each have opportunity own initialization (of members not included readability). but add overloaded constructor ancestor: tcellphone = class(tcomputer) public constructor create(teapot: integer); override; overload; constructor create(teapot: integer; handle: string); overload; end; the alternate constructor in tcellphone calls other vi...

testing - How to Intentionally Create a Long-Running MySQL Query -

i know odd question ask, i'd find out if there mysql query can create without having millions of rows in database consume resources , run long time. ultimate goal test application in cases of resource contention , make sure methods handling failure (specifically server timeout) correct. if there way can test without creating , executing high-resource query, i'd appreciate hearing well. i assume use benchmark() this, although isn't scope of it. select benchmark(9999999999, md5('when end?'));

.net - Why SynchronizationContext does not work properly? -

i have following code: [testmethod] public void startworkinfirstthread() { if (synchronizationcontext.current == null) synchronizationcontext.setsynchronizationcontext( new synchronizationcontext()); var synccontext = synchronizationcontext.current; console.writeline("start work in first thread ({0})", thread.currentthread.managedthreadid); var action = ((action) dosomethinginsecondthread); action.begininvoke(callbackinsecondthread, synccontext); // continue own work } private static void dosomethinginsecondthread() { console.writeline("do in second thread ({0})", thread.currentthread.managedthreadid); } private void callbackinsecondthread(iasyncresult ar) { console.writeline("callback in second thread ({0})", thread.currentthread.managedthreadid); var synccontext = (synchronizationcontext) ar.asyncstate; synccontext.post(callbackinfirstthread, null); } p...

asp.net mvc - Linq to SQL Data Concurrency - Is it safe to use only PKs? -

i getting error in mvc-based website surrounding data concurrency in linq sql: "row not found or changed" after reading several posts on here seems though accepted solution set non-primary key fields updatecheck = false in dbml designer. before taking plunge this, wanted ask, losing if this? to honest, seems me should case, using primary key should fastest way find record anyway. assuming don't have composite pks. i'm not terribly familiar data concurrency scenarios, missing here? thanks time! [edit] thanks feedback guys! give more detail, specific scenario have this: i have article table number of fields (title, content, author, etc.). 1 of fields gets updated (anytime views article), popularity field, gets incremented every click. saw original error mentioned above when updated article text in database. navigated article on live site (which attempted update popularity field). for starters sounds need not using shared datacontext. beyond...

automation - Using Jquery with Seleninum RC user-extension.js -

i want include jquery our current automation project running selenium rc ( written in java ). so can rely on js library writing our java script code extending current user-extension.js. i have heard , searched web , many can done, include source in user extension o adding library core selenium-server.jar. i have tried both approaches out luck. all time try reference jquery in java script code, selenium error "jquery not defined". maybe calling jquery functions wrong inside user-extension.js, don't know. any or guidance appreciated. bye i use runscript() , able attach jquery page in selenium rc http://github.com/tszming/selenium-google-scrapper/blob/master/selenium-google-scraper.php the script not java, believe can use same approach. ** use window.jquery instead of jquery in geteval() call