Posts

Showing posts from April, 2012

c++ - no matching function for call to... error with template class -

i have generic double linked list, , made in vc++ 2010, , worked well, have compile gcc, can't compile it. when call method has iterator parameter, got error: no matching function call 'dllist<int>::erase(dllist<int>::iterator, dllist<int>::iterator)'| [...]note: candidates are: void dllist<t>::erase(dllist<t>::iterator&, dllist<t>::iterator&) [with t = int]| the dllist in .h file, , every method defined inline. iterator class in dllist class. template<typename t> class dllist{ [...] public: [...] void erase(iterator &_first, iterator &_last){...} iterator first(){...} iterator last(){...} [...] class iterator{...} [...] }; and code causes error: ilist.erase(ilist.first(), ilist.last()); (ilist: dllist< int> ilist) how can fix it? void erase(iterator const &_first, iterator const &_last){...} this allows temporary iterators, returned first() , last() , pa

forms - PHP - Escaping em dashes -

i $_post'ing following headline form: google’s new partner android update initiative: promising — maybe; we’ll see and on handler page, if first thing echo "<pre>"; print_r($_post); die(); i see: google’s new partner android update initiative: promising — maybe; we’ll see i understand there functions convert & escape characters , html equivalents, how can ensure content added $_post in correct encoding? cheers, not sure if helps, seems utf-8 encoding got mixed (control characters seem familiar me ...). try output utf8_encode() or utf8_decode() .

I want to create a perl code to extract what is in the parentheses and port it to a variable -

i want create perl code extract in parentheses , port variable. "(05-nw)hplaserjet" should become "05-nw" this: catch "(" take out spaces exsist in between () everything in between () = variable 1 how go doing this? perldoc perlre use warnings; use strict; $s = '(05-nw)hplaserjet'; ($v) = $s =~ /\((.*)\)/; # grab between parens (including other parens) $v =~ s/\s//g; # remove whitespace print "$v\n"; __end__ 05-nw see also: perl idioms explained - @ary = $str =~ m/(stuff)/g

ruby - How do I correctly deal with non-breaking spaces using Nokogiri? -

i using nokogiri parse html page, having odd problems non-breaking spaces. tried different encodings, replacing whitespace, , few other headache inducing attempts. here html snippet in question: <td>amount 15,300&nbsp;at&nbsp;dollars</td> note change &nbsp; representation after use nokogiri: <td>amount 15,300&#xa0;at&#xa0;dollars</td> and outputting inner_text : amount 15,300 at dollars this base nokogiri grab, did try few alternatives solve failed miserably: doc = nokogiri::html(open(url)) and doc.search item in question. note if @ doc, line shows &#xa0; on line. clarification: not think stated difficulty having. can't inner_text show without strange  symbol. i know old, took me hour find out how solve problem, , easy once know. pass string function , "de-nbsp-fied". def strip_html(str) nbsp = nokogiri::html("&nbsp;").text str.gsub(nbsp,'') end you rep

load - Preserve key order loading YAML from a file in Ruby -

i want preserve order of keys in yaml file loaded disk, processed in way , written disk. here basic example of loading yaml in ruby (v1.8.7): require 'yaml' configuration = nil file.open('configuration.yaml', 'r') |file| configuration = yaml::load(file) # @ point configuration hash keys in undefined order end # process configuration in way file.open('output.yaml', 'w+') |file| yaml::dump(configuration, file) end unfortunately, destroy order of keys in configuration.yaml once hash built. cannot find way of controlling data structure used yaml::load() , e.g. alib's orderedmap . i've had no luck searching web solution. if you're stuck using 1.8.7 whatever reason (like am), i've resorted using active_support/ordered_hash . know activesupport seems big include, they've refactored in later versions pretty require part need in file , rest gets left out. gem install activesupport , , include shown bel

javascript - Safari double-submitting ajax calls -

i have noticed safari 5.0.5 (6533.21.1) seems submitting duplicate ajax calls. when run following reduced test case: // jquery 1.6 include $(document).ready(function() { settimeout(function(e) { var req1 = $.getjson('/api/private/customers.json'); console.log('req1 sent'); }, 2000); settimeout(function(e) { var req2 = $.getjson('/api/private/customers.json'); console.log('req1 sent'); }, 4000); }); the safari resources panel , console show 2 xhr requests going out, server log shows 3 xhr requests coming in: xx.xx.xx.xxx - - [10/may/2011:16:50:40 -0400] "get /api/private/customers.json http/1.1" 200 183 "https://sub.mydomain.com/customers" "mozilla/5.0 (macintosh; u; intel mac os x 10_6_7; en-us) applewebkit/533.21.1 (khtml, gecko) version/5.0.5 safari/533.21.1" xx.xx.xx.xxx - - [10/may/2011:16:50:42 -0400] "get /api/private/customers.json http/1.1" 200 183

twitter - Up to Date Tweet-Script for PHP -

since twitter uses oauth there lot of tweet-scripts php floating around web. , of them don't work because they're out of date. i have been looking on 3 hours simple "send message twitter via php"-script. , did not found 1 works good. don't need more simple php-script lets me tweet message. please me out! :/ i use twitteroauth library located here: https://github.com/abraham/twitteroauth/blob/master/documentation step 9 mentions how status update. token / token secret, if check app's page on dev.twitter.com, gives developer token / token secret use if you're 1 controlling app.

c# - ListBox shows (Collection) instead of object's ToString() when List of Collections is bound -

i have listbox bound instance of list of elements of class a, collection. class : list<b> { public override tostring() { return "a"; } } class c { list<a> list; } listbox: <listbox itemssource="{binding list}"></listbox> when application run, every item shows "(collection)" what can make each item show "a" instead of "collection"? the itemssource expecting property ienumerable, it's binding contents of collection instead of list object directly.

windows phone 7 - xna wp7- photoChooser crop -

hey when use pixelheight/width property ing photochooser a. height adjusted b. photochoosertask.completed event doesn't work. have experience , know answers? thanks in emulator, photochoosertask crop known fail in older version of sdk (pre-nodo) , completed event never triggered. on phone, however, works correctly. showing code help, since might missing obvious.

Google App Engine Servlet Design -

i have built server on gae handles 6 different types requests on http post, of involve either creating, updating, or deleting objects datastore. best design this? tell current design , express couple others. my current design has requests sent same servlet, , uses "action" parameter part of post distinguish , handle different requests. code server should run included here. e.g. public void dopost(httpservletrequest request, httpservletresponse response) { if (request.getparameter("action").equals("action_1")) {..code..} if (request.getparameter("action").equals("action_2")) {..code..} . . . if (request.getparameter("action").equals("action_n")) {..code..} } 2._similar above, instead of code here, servlet acts centralized servlet , calls dedicated servlet action. 3._have dedicated servlet each action. what pros , cons above designs , preferred way s

javascript - Pull value from table -

hello have following on page , pull value: 36424. value change im trying create function pull when call on function. <table cellspacing="0" cellpadding="3" rules="cols" border="1" id="osdatacount" style="color:black;background-color:white;border- color:#999999;border-width:1px;border-style:solid;border-collapse:collapse;"> <tr style="color:white;background-color:black;font-weight:bold;"> <th scope="col">count(*)</th> </tr><tr> <td>36424</td> </tr> </table> cheers no need jquery: var table = document.getelementbyid('osdatacount'); alert(table.rows[1].children[0].innerhtml); // -> 36424 see example →

javascript run from web browser -

i wondering if people give me example code people type in address bar automatically download web address typing in javascript line. thanks isn't how urls work already? download when type in web address? no javascript needed!™

tinymce - new PloneFormGen Form Folder has Plain Text Format for Prologue and Epilogue -

when create new pfg form folder, prologue , epilogue textareas come default text format = plain text. intended? if user's default text editor tinymce (both in /personalize_form , in portal_memberdata wysiwyg_editor), expect prologue , epilogue behave same new page content type, comes tinymce. when @ products.ploneformgen-1.5.5 in content/form.py, textfield('formprologue') has default_content_type = zconf.atdocument.default_content_type, seem behave same way normal document content type. thanks! this known issue due bad interaction between bug in archetypes , changes how mimetype determined in recent releases of tinymce. if you're on plone 4 can upgrade products.archetypes 1.6.6 or later fix (this archetypes release included in latest plone release, 4.0.5).

c++ - getters and setters in class -

i trying write program considering have huge array of objects( conatinng data such id, name etc) have display menu : 1) display_menu() { vector< cd > cdarray; //some statements display switch(choice) { //case1 , case 2, ... case x; for(int i=0; < cdarray.size(); i++) cdarray[i].printcd(); //printcd() method of class cd //default } } but lead lot of function call overhead if vector/array large making slow. 2) shall delare function printcd() inline or 3) declare object call function , pass vector/array reference : display_menu() { vector< cd > cdarray; cd obj; //some statements display switch(choice) { //case1 , case 2, ... case x; obj.printcd(cdarray); //cdarray passed reference //default } } is there wrong third approach what approach suggest? you're on analyzing problem. make readable first, worry p

ironpython - Scripting Engine development for newbies -

i developing asp.net application takes stock price historical data external data source yahoo. i'd users able customize application provide rules on how system flag dates entering , exiting trades, , application able simulate success rate of rules. i new concept of scripting engines. have read ironpython typically used this, don't know how structure application this, , guidance on can read more how this, or find open-source reference implementation best. there many technology / implementation options out there, , don't know how pick best 1 need have in mind. thanks help. found here... http://www.voidspace.org.uk/ironpython/silverlight/embedding_ironpython.shtml i'll give whirl.

if statement - Duplicate results in prolog -

i'm terrible prolog. keep getting duplicate result in simple code" mates(bob, john). mates(bob, bill). mates(andrea, sara). mates(andrea, bill). friends(x, y) :- mates(x, z), mates(y, z). calling friends(bob, x). bob twice. if use , if statement argh!!! how can elimiate duplicate results? ie if(result1 == result2) dont print; im looking similar friends, ie result should bob , andrea (because of bill). shouldn't more along these lines? friends( x , y ) :- mates( x , y ). friends( x , y ) :- mates( x , t ) , mates( t , y ). if want similar friends (per comment below), try: friend( x , y ) :- mates( x , t ) , mates( y , t ) , x \= y . the \= operator means 'not unifiable with', should exclude cases party friends his- or herself. exact operator 'not unifiable with' might vary depending on implementation. also bear in mind "correct" solution bit more convoluted might seem mates relationship transitive: if andrea ma

resources - Java - Apache CXF Load WSDL From Jar -

i using apache cxf connect soap api. i've saved wsdl in eclipse project , want load this. project looks this: src gen resources + meta-inf + mywsdl.wsdl i can load wsdl if hard code in path root of drive: static { url url = null; try { url = new url("file:/home/peter/workspace/project/resources/meta-inf/mywsdl.wsdl"); system.out.println(url); } catch (malformedurlexception e) { //blah } } however, if try load wsdl resource fails: static { url url = null; try { url = myserviceclass.class.getresource("/resource/meta-inf/bfexchangeservice.wsdl"); system.out.println(url); //prints null } catch (malformedurlexception e) { //blah } } how load wsdl within project (and, eventually, .jar)? cheers, pete class.getresource loads file classpath , you're on right track. so, store wsdl somewhere on classpath, e.g. source fo

django - Try / except syntax in Python with two of the same exceptions -

i checking emails against 2 lists -- list of domains , list of individual emails. how construct following try statement -- try: 'email in email_list' except doesnotexist: 'domain in domain list' # if email not found except doesnotexist: 'print error message' # if both email , domain not found what syntax need use construct statement? it sounds you're looking like: if email in email_list: # email elif domain in domain_list: # domain else: print "neither email nor domain found" there no need exceptions in case.

c# - How to prevent asp.net ajax postback with JQuery? -

<script type="text/javascript" language="javascript"> function pageload(sender, args) { $('#bvft').addclass("bvft"); $('#new').live('click', function() { $('#bvft').removeclass("bvft"); $('#bvft').show("slow"); }); $('.ddlfrtime').change(function() { var vftime = $('.ddlfrtime').val(); if (vftime != "") { $('#bvft').removeclass("bvft"); $('#bvft').show("slow"); } else { alert("sorry"); } }); } </script> in $('#bvft'), have 1 dropdownlist <asp:dropdownlist id="ddlfrtime" runat="server" width="250px" cssclass="ddlfrtime" autopostback="true" onselectedin

c# - Using DI with a shared library across applications -

i'm facing design challenge can't seem solve in satisfactory way. i've got class library assembly contains of shared orm objects (using entityspaces framework). these objects used in 2 or more different applications why in own assembly. setup has worked fine 4+ years me. i have couple of applications built on composite application block (cab) microsoft's patterns & practices group (p&p). yes, know old i'm part time developer, one-man-shop , can't afford update whatever current framework is. here problem comes in: have been exercising oo design skills , whenever doing substantial refactoring try shift procedural approach more oo approach. of course major aspect of oo design placing operations close data work with, means orm objects need have functionality added them appropriate. proving real head scratcher when consider i'm using p&p's object builder di container within cab , of functionality move orm objects need access services

asp.net - Automatically redirect to login.aspx on submit -

my application showing strange behaviour. whenever press submit button on page save redirects /login.aspx automatically. user signed in , code doesn't redirect login.aspx. i've searched solution files never found text "login.aspx" , database doesn't contain "login.aspx". wonder how system redirects page. page doesn't exist in application. please notice issue on live site. here's error: server error in '/' application. the resource cannot found. description: http 404. resource looking (or 1 of dependencies) have been removed, had name changed, or temporarily unavailable. please review following url , make sure spelled correctly. requested url: /login.aspx version information: microsoft .net framework version:2.0.50727.4211; asp.net version:2.0.50727.4209 the error due write permission on folder.

php - How can I use RegEx to determine the largest chunk between delimiters? -

regex determine longest "part" of phrase, specified delimiters? news stories have sort of structure, title plus bunch of garbage. there way regex out garbage , maintain longest part of title, require using delimiters such | , - , : , etc... here examples eband | jornalismo | saúde | alimentos em conserva podem causar botulismo; saiba como evitar doença obama calls wide-range immigration reform in el paso - san jose mercury news cl + suspensa produção de mortadela com toucinho, suspeita de contaminação bbc news - john kerry travel pakistan amid strained ties not regex think. can split title on "garbage" characters, , sort length of remaining parts. $parts = preg_split('#\s*[-|:+]+\s*#', $title); $parts = array_combine($parts, array_map("strlen", $parts)); arsort($parts); $longest = current(array_keys($parts)); instead of specific delimiters, split on non-word symbols \w (or [^\pl] /u unicode flag).

jquery - How to populate a textbox by clicked a row in a jqGrid? -

Image
requirement: 1) want populate textbox data (e.g. amount: 600.0) when row in above jqgrid clicked. can direct me tutorial ? resources looked at: demos -- trirand jqgrid asp.net jqgrid demos thanks you use onselectrow event along getcell or getrowdata methods: $('#grid').jqgrid({ .... onselectrow: function(id) { var amount = $('#grid').jqgrid('getcell', id, 'amount'); $('#id_of_some_text_box').val(amount); }, .... });

cordova - Integrating phoneGap with native iOS app -

i'm trying create app uses combination of native functionality , phonegap framework. native app has button, upon click of phonegap ui has added view. there way achieve this? there tutorials same? yes, possible. although might getting headaches. app kind of goes other way around, it's phonegap, i'll pop open view native. here link code shows excellent example of how switch between ios , phonegap worlds. new updated recommended article (see update below) these files represent standard plugin used in phonegap. in particular plugin, native view opened on top of phonegap view. notice have custom xib , everything. plugin can modified display xib functionality think of. if implement plugin see how jump , forth. i've heavily modified these classes add lots of native capabilities phonegap project. should check out official phonegap guide phonegap plugins. here important edit was informed original linkwas broken (not terribly surprised answer old , i'

FogBugz Evidence Based Scheduling: How well does it work in the real world? -

my company has been using fogbugz while , happy bug-tracking tool. i've been reading joel spolsky's articles evidence based scheduling feature. sounds great in theory, haven't seen discussion how works in practice. before spend lot of time , effort trying convince co-workers buy in using it, i'd hear people have been using feature in development. have been using fogbugz' ebs? if so, happy it? have estimates been accurate enough helpful? benefit of hindsight, think worth effort set , input of information/estimates requires? there other mechanism found works better? (note: i've deliberately posted stackoverflow.com rather fogbugz.stackexchange.com, since suspect user base @ fogbugz.stackexchange.com might unduly biased in favor of fogbugz -- in particular, ex-fogbugz users who've moved on better unlikely read or post there)

c++ - Working with file streams generically -

i want work file streams generically. is, want 'program interface , not implementation'. this: ios * genericfileio = new ifstream("src.txt"); getline(genericfileio, somestringobject);//from string library; dont want use c strings genericfileio = new ofstream("dest.txt"); genericfileio -> operator<<(somestringobject); is possible? not great inheritance. given io class hierarchy, how implement want? do mean: void pass_a_line(std::istream& in, std::ostream& out) { // error handling left exercise std::string line; std::getline(in, line); out << line; } this can work std::istream , std::ostream , so: // file cout // no need new std::ifstream in("src.txt"); pass_a_line(in, std::cout); // stringstream file std::istringstream stream("hi"); std::ofstream out("dest.txt"); pass_a_line(stream, out); this example do, , programmed against std::istream , std::ostream interfa

Adding return statement to watchable in Java -

how add return statement watchable method in java , still working properly. want searching files, ok have that. want return, when add return statement goes down function stops , watchable stops .. ideas ? for (;;) { watchkey key = watcher.take(); (watchevent<?> event: key.pollevents()) { if (event.kind() == standardwatcheventkind.entry_create) { system.out.println(event.context().tostring()); } } here loop searches, how return , still working? as @dlev says, if want application process watch events @ same time doing other things, way in separate thread. this leaves problem of "returning" information. (i presume printing information standard output not use you.) as observed, can't use return because terminate loop. the basic answer need put information somewhere rest of application can access. example: you create queue object (e.g. concurrentlinkedqueue ), have watcher enqueue data, , have other thread dequ

php - email delivery gets blocked if any one recipient email fromat is incorrect -

i facing problem mail delivery. project based on php application. using smtp send mails . group mail sent email tool. if chance 1 of email address format withing recipient group incorrect (ex dora@yahoo) , email fails delivered. what blocking email? due php inbuilt mail function? or smtp blocks it? please me guys solve issue. first off, question vague. assume not error message when script executes. here how handle this: first thing make sure error handling set display errors . reproduce error -> run script, if possible command-line php -f scriptname.php , send malformatted emails. either fix script inline, or possibly better, ensure emails reach reach script have been validated. there many php tools available this. if need quick fix, php's native filter_var of help. last not least, consider keeping 'testscript' available reproduces steps did above. not want go through every time thing chokes, , hero the great rms once said, if job wo

windows - How to add image in CTreeCtrl list in MFC -

i trying add image before text in ctreelist control not coming up, observed the node name started after space , leaving space bitmap , image not showing up.. here code snap:- cimagelist m_imagelist; cbitmap m_bitmap1; m_imagelist.create(16,16,ilc_color32,1,1); m_bitmap1.loadbitmap(idb_bitmap1); m_imagelist.add(&m_bitmap1, rgb(0,0,0)); treesoft->create(ws_child | ws_visible | ws_border | ws_tabstop | tvs_haslines | tvs_hasbuttons | tvs_linesatroot | tvs_singleexpand | tvs_showselalways | tvs_trackselect, crect(10, 10, 200, 240), this, 0x1221); treesoft->setimagelist(&m_imagelist, tvsil_normal); htree = treesoft->insertitem( l"software production",0,0, tvi_root); hcompany = treesoft->insertitem(l"microsoft",0,0, htree); pls tell me missing here... just testing purposes. create icon 16-bit color palette. instead of ilc_color32 use ilc_color. and instead of rgb(0,0,0)

Android - Activity Reload on Rotation -

i know duplicate question, , know when device rotated, oncreate method called again, , want keep this; don't want go through steps of overriding onconfigurationchanged or sub-classing application class because android doing reloading in best way (especially on saving current values , status). however, have commands inside oncreate method don't want execute them if activity reloaded due rotation, there property/method can tell if oncreate triggered due first application start or due orientation change? for example: if(< oncreate triggered due orientation > == false) // execute commands... else // nothing... alternatively, have events in android triggered before oncreate or before onconfigurationchanged? why not store current orientation in sharedpreferences , compare current orientation stored value in oncreate (and save new orientation sharedpreferences)? that should provide functionality require, unless i've misunderstood something.

php - using AJAX to make loader? status is not returned from DB -

function main() { if(window.xmlhttprequest) { ab=new xmlhttprequest; } else { ab=new activexobject("microsft.xmlhttp"); } ab.onreadystatechange=function(){ if(ab.readystate==4 && ab.status==200) { document.getelementbyid("progress").innerhtml=ab.responsetext; } } ab.open("get","querygoogle.php"); ab.send(); } function test(id) { if(window.xmlhttprequest) { xmlhttp=new xmlhttprequest; } else { xmlhttp=new activexobject("microsft.xmlhttp"); } xmlhttp.onreadystatechange=function(){ if(xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("testdiv").innerhtml=xmlhttp.responsetext; //alert(xmlhttp.responsetext); } } xmlhttp.open("get","test.php",0); xmlhttp.send(); } function interval

jsf 2 - JSF rendered question -

Image
is el-parsing of children elements rendered="false" supposed evaluated? causing me alot of trouble null pointer exceptions , similar. looking @ following example: <p:tab title="#{usercompetencecontroller.gettreename(3)}" rendered="#{!empty usercompetencecontroller.gettreename(3)}"> <xdin:competencetable id="competencebox3" profile="#{usercompetencecontroller.selectedprofile}" tree="#{usercompetencecontroller.getcompetencetree(3)}" maxheight="500px"/> </p:tab> the main issue (besides performance) xdin:competencetable not support null tree -attribute. gettreename(int index) returns null in case, , followed call getcompetencetree(3) returns null, though parent ( p:tab ) has rendered="false" in short: xdin:competencetable parsed el though it's parent has rendered="false" . why? take @

ios - Why does iAd still load data after it has been removed from it's superview, and can this be stopped? -

i have small app iads, , allow people pay upgrade. the iad setup in application's nib. check purchase status in viewdidload method of main uiviewcontroller, , call following methods on adbannerview outlet member: [adbanner removefromsuperview]; adbanner = nil; unfortunately if watch device's data usage, data still downloaded ad. is there way kill iad doesn't load data? i know create iad view programatically , add if user has not purchased product, product working nicely nib , i'd rather not change reason. update: in .h file have: iboutlet adbannerview* adbanner; in .m file in - (void)viewdidload method have: if (purchased) { [adbanner removefromsuperview]; adbanner.delegate = nil; adbanner = nil; } i hope enough remove iad before gets chance download data. alas, isn't enough prevent view downloading data. suspect there delay in being dealloc'd @ time – but don't know how this, short of calling dealloc itself. do

javascript - I want to specific a host of http request, can Greasemonkey help me to do this job? -

i have search "dns" , "host" in userscripts.org, can't found answer. sometimes want test in development enviroment, example, 192.168.22.11 testfunc.mydomain.com but don't want change c:\windows\system32\drivers\etc\hosts file time , restart browser. the question not clear. you want locally reroute mydomain.com 192.168.22.11? greasemonkey can automatically reload pages, changing server or ip, don't recommend that. messy endeavor -- handling href , src attributes, etc. if read question correctly, redirector add-on better fit. ~~~ however , proper way structure site , apps uses relative addresses, amap. use single bit of code detect running server, once per request (or once per app init), , set <base> element and/or appropriate global variable. the point our code runs without changes whether it's dropped on productionserver.com , or testserver.com , or 192.168.22.11 . so, there no need redirects, or slight modi

javascript - why this code has error -

//this part of html code <form> <b>user:</b> <input type="text" name="user" size="25"/> <input type="button" name ="submit" value="confirm" onclick= "mehdi(this.form)"/> </form> <script type="text/javascript"> function mehdi(rno){ rno.user.value = 2 * math.pi ;//this error line user unknown alert(rno); return rno; } </script> what can do? try this <form> <b>user:</b> <input type="text" name="user" size="25"/> <input type="button" name ="submit" value="confirm" onclick= "mehdi(this.form)"> </form> <script type="text/javascript"> function mehdi(rno) { rno.user.value = 2 * math.pi ;//this error line user unknown alert(rno.user.valu

Mondern Java GUI Framework like WPF or Qt? -

does knows gui framework java desktop applications wpf or qt? framework should offer styling , animation features wpf or qt. i want implement 3d flip control like: http://www.codeproject.com/kb/wpf/contentcontrol3d.aspx thanks you can use jni(java native interface). not less qt jambi, supported forums , java.

apache - .htaccess add exception to disabled CGI execution -

have website "protected folder" using .htaccess file. inside folder execution of cgis disabled, .htaccess follow options -indexes -includes -execcgi addhandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi .php4 .php5 .js now i'm in need of executing php script in folder (overiding cgi disabling), lets suposse name of script is my_script.php what best way maintain security in folder deniying execution rights scripts my_script.php ? i have full access .htaccess file can change want. kind regards , lot in advance. p:.

Add row to UITableView crash if initially empty table -

i'm using code below refresh tableview added row into. code works adding row table if there @ least 1 row in table. however, crashes if empty table. nsarray *indexpaths = [nsarray arraywithobjects: [nsindexpath indexpathforrow:[commentsarray count] insection:0], nil]; [commentstableview beginupdates]; [commentsarray addobject:newestentry]; [commentstableview insertrowsatindexpaths:indexpaths withrowanimation:uitableviewrowanimationbottom]; [commentstableview endupdates]; [commentstableview scrolltobottom:yes]; the crash response is: *** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'invalid update: invalid number of rows in section 0. number of rows contained in existing section after update (0) must equal number of rows contained in section before update (0), plus or minus number of rows inserted or deleted section (1 inserted, 0 deleted).' can me? well, error telling when uikit calls tableview:numberof

mod rewrite - .htaccess mod_rewrite add "/" to the end of url -

this .htaccess code: rewritebase /kajak/ rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^moduli/([^/]+)/(.*)$ moduli/$1/index.php/$2 [l] now / appended every url. example, http://127.0.0.1/moduli/novice becomes http://127.0.0.1/moduli/novice/ . how can prevent getting / @ end? while not know answer question, note 2 oddities question , code may related problem @ hand. with rewritebase have in code, rules should not being triggered. while new regex myself, @ ([^/]+) , little confused why capturing it. know ^ matches start of string, never true since have 1 @ real start of string. this being said, write code below: rewritebase /moduli/ rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)/(.*)$ $1/index.php/$2 [l] this rewrite urls below: http://www.website.com/moduli/novice/view http://www.website.com/moduli/novice/index.php/view based on block of code, seems trying do. if not,

caching - Cache miss penalty in deep RISC pipeline -

why cache miss penalty greater in pipelined processor? is because stalling period more if miss occurs @ late stage of pipeline? or because there many instructions in pipeline? usually implement deeper pipeline reduce cycle time of each pipe stage. consider 2 in-order single-issue pipelined processor microarchitectures. ua1 has 5 stage pipeline , 2 ns cycle time. ua2 has 10 stage pipeline , 1 ns cycle time. a full cache miss must (at least) load entire cache line dram. assume takes 100 ns, including row activation, burst reads of line words, , row precharge. when ua1 takes cache miss, stalls 100 ns, e.g. 50 clock cycles, e.g. 50 issue slots. when ua2 takes cache miss, stalls 100 ns, e.g. 100 clock cycles, e.g. 100 issue slots. here cache miss penalty (expressed in instruction issue slots missed), twice large in more pipelined processor.

wpf - Grid column autocollapse -

is possible grid column collapse according child width? , column next him expend , take space got ? if not, whats best way achieve ability? set widht of first gridcolumndefinition auto , second 1 * <grid> <grid.columndefinitions> <columndefinition width="auto"/> <columndefinition width="*"/> </grid.columndefinitions> </grid>

linux - SSH versus WebDAV - what are security vulnerabilities of each? -

i have personal git repository don't want have publicly available variety of reasons (chiefly pride, it's half-pages of scribbled lines), i'm hosting on personal server. i interested in anyone's thoughts on security between following implementations (the host centos 5.6 if matters): ssh using key-based authentication keys using 20-character passphrases; webdav using apache 2.2 , passwords using 20-character passwords. there number of discussions on better, more convienent, etc seem chiefly functional. more/less straightforward break or tap into? said, information in repo not sensitive, collection of bad hobby code. i'm trying find base decision besides coke-vs-pepsi "which tastes better you?" subjective debate. appreciate comments. specific question, general answer. webdav insecure without ssl. https = http + ssl ssh = ssl so https , ssh pretty equal in regard, using private key files better. might easier setup using ssh, ha

android - java.io.IOException: Error running exec(). Commands: [cd, sdcard/.yasmin] Working Directory: null Environment: null -

i try access folder in sdcard , install myapp.apk, use code: runtime.getruntime().exec("cd sdcard/.yasmin"); runtime.getruntime().exec("adb install tefli.apk"); but unfortunatelly have error: 05-11 11:09:57.925: warn/system.err(1399): java.io.ioexception: error running exec(). commands: [cd, sdcard/.yasmin] working directory: null environment: null anybody please have idea. in advance. i not sure fix problem, afaik, each call exec() creates new shell. possible solution following: get process of exec() using: process p = runtime.getruntime().exec(...) . grab process inputstream using p.getinputstream(); . run second command. also note trying access sdcard in root folder , in hardcoded path, consider following: process p = runtime.getruntime().exec("cd /sdcard/.yasmin"); or better: process p = runtime.getruntime().exec("cd " + environment.getexternalstoragedirectory() + "/.yasmin"); hope it'

Custom error messages in jqgrid -

how can display custom error messages required field , other validations in jqgrid forms. you can use attr property of searchoptions set additional attributes of input or select element used in searching toolbar. updated : in comment explained means customize validation messages. can ovewride valuse $.jgrid.edit.msg (see grid.locale-en.js or other localization files). example can use $.jgrid.edit.msg.required = "is missing"; if want make message more dynamic can use custom editrule , build error message inside of custom_func .

.net - use Repeater Item index in Hidden Field -

how set item index in repeater column hidden fields in asp.net. wrote following code not show index value in hidden field. <itemtemplate> <tr> <td> <asp:hiddenfield id="hiddenfield1" runat="server" value='<%# container.itemindex+1 %>' /> <%--<asp:hiddenfield id="hfindex" runat="server" value='<%#container.itemindex+1 %>' />--%> </td> <td> <asp:label id="lblexpenseglcode" runat="server" text='<%# databinder.eval(container.dataitem, "acm_account_code")%>'></asp:label> </td> <td> <asp:label id="lblaccountgldescription" runat="server" text='<%# databinder.eval(container.dataitem, "acm_account_desc")%>'></asp:label> </td> </tr> </i

profiling - Python's profile module: <string>:1(?) -

i using python's (v2.4) profile module profile numpy script, , following entry appears account bulk of execution time: ncalls tottime percall cumtime percall filename:lineno(function) 256/1 0.000 0.000 7.710 7.710 <string>:1(?) unfortunately, appearance makes hard google. how go figuring out exactly? edit profiler run shell follows: python -m profile -s cumulative script.py ignore line. artifact of how profiler implemented. not telling useful. @ "tottime" value it: 0.000. "tottime" amount of time spent executing "<string>:1(?)" excluding time spent executing children of it. so, no time spent here. "cumtime" , "percall" large because include time spent in children. see http://docs.python.org/library/profile.html#cprofile.run more details.

php - time() and date() problems after time change (DST - standard) -

in php output html option list containing dates next 14 days. these appointments @ 18 o'clock: $today_day = date('d'); $today_month = date('m'); $today_year = date('y'); $date_entry = mktime(18, 00, 00, $today_month, $today_day, $today_year); $optionsstr = '<select name="date">'; ($d = 1; $d < 14; $d++) { $date_entry_temp = $date_entry+86400*$d; $optionsstr .= '<option value="'.$date_entry_temp.'">'.date('d.m.y', $date_entry_temp).'</option>'; } $optionsstr .= '</select>'; echo $optionsstr; the user can choose 1 of these dates , submit form. chosen timestamp inserted database. so have entries in database. on page there list of current appointments: mysql_query("select id, name appointments date_time = ".time()); so @ 18 o'clock there should output there entries in database day. works until time changes dst standard time or vi

javascript - Select already selected item in dropdown/select - list -

i've been searching answer question quite time now, no luck, or buggy solutions @ max. the problem im facing have select element (obviously) doesn't fire "onchange" event when selecting selected item. like this: <select onchange="alert(this.value);"> <option>1</option> <option>2</option> <option>3</option> </select> now, select item 1 first. afterwards need able select item 1 again. this feature extremely important success of project i'm working on. any appreciated. edit: (more info) this functionality needed im working on project google maps users presentet dropdown jump country (eg select "spain" in dropdown, google maps sets spain view. the problem comes when want go spain, drag around map, , end in italy. want go spain, cant select dropdown until select else first. boss doesn't :) edit2: solution so theres few solution. 1 of them throw action onblur (when unfocusi

include - Perl : constant & require -

i have config file (config.pl) constants : #!/usr/bin/perl use strict; use warnings; use net::domain qw(hostname hostfqdn hostdomain domainname); use constant url => "http://".domainname()."/"; use constant cgibin => url."cgi-bin/"; use constant css => url."html/css/"; use constant ressources => url."html/ressources/"; ... and use these constants in index.pl, index.pl starts : #!/usr/bin/perl -w use strict; use cgi; require "config.pl"; how use url, cgi... in index.pl ? thanks, bye edit found solution : config.pm #!/usr/bin/perl package config; use strict; use warnings; use net::domain qw(hostname hostfqdn hostdomain domainname); use constant url => "http://".domainname()."/"; use constant cgibin => url."cgi-bin/"; 1; index.pl begin { require "config.pm"; } print config::url; end what want here setup perl module can export from

android - how to find the name of the main activity of an application? -

for example, want start gmail in code/command line, don't know main activity name. am start -n com.google.android.gm/.xxxxx it's available through decompiling apk, it's difficult. thanks. you can plug phone computer , @ ddms log, application launches printed there, e.g: 05-11 09:19:15.725: info/activitymanager(96): starting: intent { act=android.intent.action.main cat=[android.intent.category.launcher] flg=0x2000000 cmp=com.google.android.gm/.conversationlistactivity bnds=[125,410][235,540] } pid 2457 so, com.google.android.gm/.conversationlistactivity , seem right choice, @ least, that's icon seems launch.

iphone - Multiplatform MSBuild project file -

i'm working on project source code should portable possible; is, project (in c#, not relevant) represent application should executed on android (with mono-android), on iphone (with monotouch) , winmobile (with official compact framework). without going details, corresponding msbuild solution consists of independent-platform library (from source code point of view, @ least) declare various interfaces , classes represent abstraction of each feature not common various platform (i.e. ui). in addition, there corresponding library specialize (for each platform) "base library"; effective application executable program uses abstraction , common standard libraries. developing on winmobile , android not problem: mono-android add-in can installed on vs 2010, both platforms can handled ms vs. initially solution created in vs, initial configuration , related projects (android , winmobile) automatically generated. after i've imported solution in monodevelop under mac (the

php - Use asynchronous long polling? -

i have zend–based application uses long polling. makes http post request, blocks application until either returns or times out after 20 seconds. i have need make second request (which non-parallel), unfortunately if first request hangs, ends being 20 seconds (= timeout) before second request executes. what best way make application asynchronous, or @ least non-blocking http request i/o? mmmh, maybe should add more information questions. if 2 requests aren't related (i.e. second 1 doesn't need first 1 finished) can perform several queries without waiting first 1 finish. of course cannot without javascript. for example use jquery ajax function in asynchronous mode (by default it's asynchronous). can chain several ajax calls in jquery second 1 not wait first 1 finished (but careful ajax timeout settings).

asp.net - Redirect from http://sitename.com to http://www.sitename.com -

i using asp.net 4. want 301 redirect http://sitename.com http://www.sitename.com . what's best way (and optional ways) it? my site getting indexed on ip address. how can stop that. you simple check in page_load : protected void page_load(object sender, eventargs e) { string servername = httputility.urlencode(request.servervariables["server_name"]); string filepath = request.filepath; if (!servername.tolower().startswith("www.")) servername = "www." + servername; response.redirect("http://" + servername + filepath); } or add following htaccess file: options +followsymlinks rewriteengine on rewritecond %{http_host} ^domain.com [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc] replacing domain.com , http://www.domain.com domain.

xslt - Altova's and Cooktop's different result -

i have lookup table table take result if buyeritemcode=substring(field[@id='0'], 11,3) subfamily=subfamily lookup table, otherwise '9': <lookup> <code> <buyeritemcode>439</buyeritemcode> <subfamily>016</subfamily> </code> </lookup> xml file looks: <document> <line id="14"> <field id="0"><![cdata[mmm4443 419280600000]]></field> </line> <line id="15"> <field id="0"><![cdata[mmm4443 414390600000]]></field> </line> </document> i need compare data lookup.xml , if data not compare insert constant 9. altova v11 program works, cooktop doesn't, mean comparing false. program looks: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:date="http://exslt.org/dates-and-times"

Exception handling in jQuery plugins -

what considered best way handle misuse in jquery plugin -- ignore, or throw error? in situation i'm working with, have plugin binds functionality image. once bound, can other things through methods, e.g. set or state information can changed client interaction, e.g.: $('selector').myplugin(); $('selector').myplugin('some-method',data); what should 1 when: a selector contains no relevant elements (suspect answer is, nothing, no error) a method, relevant bound element, applied selector no relevant elements a method contains parameter data invalid i feel right thing in cases ignore that's invalid or doesn't apply , proceed without errors. big part of "jquery way" act in predictable fashion as possible, me means, don't break unless have to. on other hand, makes debugging more difficult, since won't ever errors when doing things aren't supposed to. reasonable (e.g., applying plugin set of elements subset relevant). o

model view controller - How to integrate a JMenuBar in an MVC architecture in Java? -

i'm using tutorial build application using mvc architecture : http://www.oracle.com/technetwork/articles/javase/index-142890.html . i'm not sure how or should put code build , add actionlistener of jmenubar inside of it. furthermore, book object-oriented design & patterns cay horstmann " the controller may process mouse , keyboard events windowing system, or may contain user interface elements such buttons , menus. " should follow advice, if yes, how should implement ? how add jframe in main class ? as suggested in how use actions , action convenient way encapsulate this. moreover, action "can used separate functionality , state component." addendum: in simple example , model file representing directory in file system, , view jlabel listens actionperformed() . encapsulation afforded action ensures each menu item , tool bar button produce same result. approach emblematic of swing's separable model architecture .

Python distutils not using correct version of gcc -

i trying compile package on mac osx 10.6.5. package's install script relies on distutils. problem computer's default gcc version 4.2 (i determined running gcc --version in terminal window) when run 'python setup.py build', see output distutils choosing gcc-4.0 instead of 4.2 big problem because code using require gcc >= 4.2. not have admin rights on machine, workaroud, created symlinks send gcc-4.0 gcc-4.2. result code compiles, generated .so files not work (when try import them in python, errors complaining missing init function in shared object). i have tried compiling code on different mac (10.6.6) , works charm: distutils chooses 4.2 without being forced , can import generated shared object without problem. so, compile code on computer without having symlink trickery...i want distutils choose 4.2 automatically should. have tried taking .so files compile , transferring them computer, fails number of reasons (they linked against libraries not present

architecture - N-Tier - responsbility location for insert vs update -

i'm creating application split data layer (using repository pattern & ef 4.0), business layer (poco's additional logic) , service layer (which exposed client using wcf). when i'm saving record database need check , see if i'm updating existing record or inserting new one. should responsibility lie - in service layer lifetime of object explicitly managed, or in data layer saving record implicitly determine action take. all comments welcome - can't decide myself! my first thought think entity framework should able figure out itself, i'm not 100% sure that. barring ef doing you, put logic in repository. pass in customer object repository so: myrepository.save(mycustomer); and in save method of customer, checks if customer has id assigned or maybe can ask ef track state, , insert or update. way, regardless of save gets called--web service, ui, etc. logic taken care of.

java - How to specify SQL column type for a specific database in hibernate mapping file -

is possible set multiple sql column types hibernate property depending on dialect used ? if yes how ? for example, if have column of type char[] , create clob type oracle , text type in sql server. the short answer "no, it's not possible". the long answer "kind of, don't want that": hibernate automatically to extent - is, when define (implicitly or explicitly) property of hibernate type, translate type appropriate rdbms-specific sql type. dialect , descendants responsible translation. you influence how translation occurs - again, extent - extending dialect(s) you're working (like oracle or sql server ) , registering own column types. you're better off relying on default hibernate type mappings, though.

regex - How to use regular expressions with Eclipse's find/replace to refactor code -

i'm still developing regex skills, i'm leaning on community. want refactor code "with eclipse", i've used number of ide's search , replace functions accept regular expressions. i've create general expressions find things, wonder if can take portions of matched pattern , use in replacement value. example, have lot of test functions named following pattern" "testsomefunction1(), testsomefunction2(), testanotherfunction()" i'd them named "test_somefunction1(), test_somefunction2(), test_anotherfunction()". find: "test[a-z]", use replace with:? "test_[a-z]" literally replacing? perhaps, cannot use regex statement in replacement? for sample text you've posted, find expression should test([a-z]*) , replace should test_$1 . this makes use of captured groups referenced $i i captured group index ( 0 entire expression). may want consider case of search string since text permutestring mat

c# - Opening a WebBrowser in a new form in a MDI configuration. It's opening twice for some reason -

ok strange. showed problem other developer , he's stumped too. using vb.net vs 2008. here setup: i have datagridview control, full-row selection when right click on row opens context menu there menu item view more information on intranet site in browser window, opens mdi child form in application. the browser window basic form webbrowser control docked fill whole form the browser window takes url string parameter gets sent webbrowser control navigate new page the problem: for reason, when choose menu item opens new browser window, opens 2 of them. when set breakpoint on menuitem's mouseup event (i've tried click event same results), runs through whole process expected, , when reaches end sub , goes , repeats entire mouseup event method second time! can not life of me figure out why happening. menu item's mouseup event: private sub testmenuitemieclient_mouseup(byval sender object, byval e system.eventargs) handles testmenuitemieclient.mou

textinput - actionscript 2.0 inputtext value -

i have little project in flash , new action script. using actionscript 2.0 , want make alarm app can ring sound when time comes :p. so have 2 inputtext's 1 called alarm_hour , alarm_min. so user enters hour , minute when wants alarm ring. using date class pick hour , minute , checkalarm function looks this: var my_date:date = new date(); var h:number = my_date.gethours(); var m:number = my_date.getminutes(); var mi:string = alarma_minute; var ora:string = alarma_hour; if (((ora == h) && (mi == m))){ _root.sunet.start(0, 99); _root.stare = 'start'; } sunet sound file.. problem if statement never activates don't know why because have made dinamic text , tested values ora , hour , mi , m , equals... doing wrong? thank you! i have managed solve problem accessing inputtext variables in form: "variablename.text" , i've had change inputtext instance name "variablename" , works fine :d

php - yahoo maps api curl settings -

how should configure curl retrieve data yahoo maps api? here current code curl_setopt($ch, curlopt_timeout, 5000); curl_setopt($ch, curlopt_url, $geocodeurl); curl_setopt($ch, curlopt_returntransfer, true); $data = curl_exec($ch); which returns 400 - bad request html file. i've checked $geocodeurl , valid xml file, figure problem must curl options? $geocodeurl is http://where.yahooapis.com/geocode?appid=** app id **&q=battle%20creek,mi&gflags=r i wrote simple class wrapper basic address php object, might job done! added google geocoding wrapper. to answer question, ok url posted, yes mentioned on reply should urlencode params $query = $this->url."?appid=".$this->appid."&flags=".$this->format; $query .= "&location=".urlencode($address); here link wrapper class https://github.com/mrpollo/geocoding-api

javascript - Ext JS - How to Grok the Syntax -

i needed figure out how value of field on form within handler function didn't know how reference field , kept getting errors. spent time looking @ api, code examples , googling. found 1 example works (i imagine there others). assuming form named myform , field 'myfield' var myval = myform.getform().findfield("myfield").getvalue(); maybe i'm new @ this, don't think it's obvious looking @ api docs. question is, when you're trying figure out, what's approach. thanks! assuming have set id of field, can use ext.getcmp(id) have componentmanager up. there's ext.getdom(id) acts wrapper getelementbyid. in addition, many event handler functions allow setting scope of function itself. documentation event should note object setting scope. may able set form field scope object , use this.getvalue() it's hard without knowing you're trying do. to answer question @ hand: more code, more grok. ext js has bit of learning c

Drupal Pressflow problem with hook_block -

i'm having troubles implementing hook_block hook in clean pressflow installation. reason outputs arrayarray blocks. reason $info variable in theme function set to: ["block"]=> array(7) { ["function"]=> string(10) "fwtb_block" ["include files"]=> array(0) { } ["type"]=> string(12) "theme_engine" ["theme path"]=> string(21) "sites/all/themes/fwtb" ["arguments"]=> array(1) { ["block"]=> null } ["theme paths"]=> array(2) { [0]=> string(14) "modules/system" [1]=> string(21) "sites/all/themes/fwtb" } ["preprocess functions"]=> array(2) { [0]=> string(19) "template_preprocess" [1]=> string(25) "template_preprocess_block" } } as can see overwritten custom hook_block method. thinks blocks should rendered using fwtb_block method returns array containing subject , con

android - Statelist drawable for different resource types -

i've got resources different screens in drawable-ldpi, drawable-ldpi, drawable-mdpi. should place statelist file? mean, xml 1 types of resources, in folder shoudl place it? you can create folder inside /res : drawable , , put state list xml in folder. can referenced r.drawable.your_state_list . this way have 1 xml used resolutions. if have other common drawables, can place them here too.