Posts

Showing posts from August, 2010

visual studio - Finding items inside a vector of map given a key (C++) -

i trying debug coding (c++ / quantlib) using vector of maps. find item inside map in turn inside vector. caught error. input: vector<map <date, real> > simulatedprices_; // vector containing 1000 maps vector<date> cds_maturities_; private variable: map <date, real> pricepathj; // reading each map in vector real w_t_; // coding: for (int j = 0; j < no_of_paths; j++) { pricepathj = simulatedprices_[j]; (int = 0; <= itenor_; i++) { //itenor number of element inside vector cds_maturities_ startdate = ......; enddate = ......; w_t_ = pricepathj.find(cds_maturities_[i]); // error in pricepathj saying there no conversion function iterator ... pair<date, real> real. ...... did commit mistakes or if there's pointer type overlooked in above coding? thanks. remarks: variable type real simular type double you can use simple loop , use map's find() function this. return

php add email to a list file csv -

i'm trying build list email using csv file , problem im using cms on simpel site works ! when integreted in cms stop working , says : access forbidden!you don't have permission access requested object. either read-protected or not readable server.if think server error, please contact webmaster.error 403127.0.0.1apache/2.4.7 (win32) php/5.5.8 this code on offline page : </div><div class="clear"></div> <form name="form1" action="<?php echo $_server['php_self'];?>" method="post" class="subscribe"> <input type="text" id="notify_by_mail" name="notify_by_mail" class="email"/> <input type="submit" name="submit" value="go" class="submit"/> </form> this php file code : <?php if($_post['formsubmit'] == "go") { $varn

mongodb - Symfony2 and ODM flushing -

in project i'm using document "question" references (many document "category") after setting category of question , flushing nothing changes in database there code $dm = $this->getdocumentmanager(); $question = $this->getdocumentmanager()->getrepository('ats\quizzbundle\document\question')->findonebyquestion("a?"); $category = $this->getdocumentmanager()->getrepository('ats\quizzbundle\document\category')->findonebylabel("logic"); $question->addcategory($category); $dm->flush(); and there no changes in database, 1 can please ? , here mapping in question's document : /** *@mongodb\referencemany(targetdocument="category") */ protected $category depending on changetrackingpolicy might need persist question before flushing. $dm->persist($question); $dm->flush(); by persisting entity make sure changes in entity registered in unitof

android - How to pass ArrayAdapter<String> from Activity to Fragment -

Image
i have app 1 activity , 3 fragments. in activity have adapter, store log messages - mainactivity.java (keeps adapter strings): private arrayadapter<string> mloglistadapter; public void oncreate(bundle savedinstancestate) { ..... mloglistadapter = new arrayadapter<string>(this, android.r.layout.simple_list_item_1, android.r.id.text1); if (savedinstancestate == null) { mainfragment fragment = new mainfragment(); bundle bundle = new bundle(); bundle.putserializable("log", (serializable) mloglistadapter); //bundle.putparcellable("log", (parcellable) mloglistadapter); getfragmentmanager().begintransaction() .replace(r.id.root, fragment, "main") .commit(); } } and use adapter in first fragment - mainfragment.java (should display list log strings): private listview mloglist; public view oncreateview(layoutin

javascript - gzip compression does not work for all files -

i configured htaccess file active gzip compression on website. config: <ifmodule mod_deflate.c> <ifmodule mod_setenvif.c> <ifmodule mod_headers.c> setenvifnocase ^(accept-encodxng|x-cept-encoding|x{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[x~-]{4,13}$ have_accept-encoding requestheader append accept-encoding "gzip,deflate" env=have_accept-encoding </ifmodule> </ifmodule> <ifmodule filter_module> filterdeclare compress filterprovider compress deflate resp=content-type $text/html filterprovider compress deflate resp=content-type $text/css filterprovider compress deflate resp=content-type $text/plain filterprovider compress deflate resp=content-type $text/xml filterprovider compress deflate resp=content-type $text/x-component filterprovider compress deflate resp=content-type $application/javascript filterprovider compress deflate resp=content-type $application

Python - argparse require either or -

when run script, have pass either -g or -s . code below, throws following error argument(s) passed it. {~/nsnitro}-> ./sg-arg.py status -g test.server usage: sg-arg.py [-h] (-g servicegroup | -s servicename) {status} ... sg-arg.py: error: 1 of arguments -g/--servicegroup -s/--servicename required code: parser = argparse.argumentparser() subparsers = parser.add_subparsers() check = subparsers.add_parser('status') check = parser.add_mutually_exclusive_group(required=true) check.add_argument('-g', '--servicegroup', action='store', help='servicegroup name', type=servicegroup_status) check.add_argument('-s', '--servicename', action='store', help='service name', type=servicegroup_status) args = parser.parse_args() you're adding mutually exclusive group wrong parser. in other words, call have, correct call ./sg-arg.py -g test.server status (notice argument comes before subparser declaration

Python Project Euler 3 -

i'm new python, i'm trying girlfriend learn coding through project euler, suggested start python. unfortunately on problem 3 came strange error. for finding prime factors of smaller numbers, seems work fine, trying find prime factors of 600851475143 chokes. i under impression python extremely forgiving maximum integer values, don't know why doesn't work here. def is_prime (n) : in range (2, n) : if n % == 0: return 0 return 1 n = 600851475143 in range (1, n) : if n % == 0 : if is_prime (i) == 1 : print if lead me right, i'd thankful! david edit: i'm aware how sub-optimal is! since no 1 answered obvious, use xrange instead of range : def is_prime (n) : in xrange (2, n) : if n % == 0: return 0 return 1 n = 600851475143 in xrange (1, n) : if n % == 0 : if is_prime (i) == 1 : print but keep in mind still slow, won't run memo

angularjs - Using $location without html5 mode enabled -

i using rewrite on server side configure routing. site has quite complicated system, e.g. different roles users, taken care on server side. trying use $location, when enable html5 mode no href redirects work. read need redirect calls index.html on server side. there way avoid this? just have @ point: how to: configure server work html5mode in / https://github.com/angular-ui/ui-router/wiki/frequently-asked-questions#how-to-configure-your-server-to-work-with-html5mode you this.

android - Can't launch intent to show local image -

within fragment, trying start intent display local image gallery app on phone. the 3 lines in question are string path = string.format ("content:/{0}.jpg", cachecontroller.static.getpath (m)); android.net.uri uri = android.net.uri.parse(path); startactivity (new intent (intent.actionview, uri)); the value of path content://data/data/appname.subname/files/cache/107.jpg . i tried using file:/ @ beginning of uri didn't help. you trying share image in folder private app. first need copy image public folder , make intent pointing image. have here , here

html5 - How do I set up navigation using CFINCLUDE with subfolders? -

Image
i want set page navigation links in coldfusion , cfinclude pull navigation in on each individual page. if keep pages in root folder navigation works fine, want organize pages in sub folders. when link to: <a href="pages/page2.cfm">page 2</a> i go page 2 when trying to: <a href="page1.cfm">page 1</a> i following error: file not found: navigationtest/pages/page1.cfm. i know need use ../ , if put navigation on each individual page works subfolders, want 1 page navigation , include on other pages. how can set navigation works subfolders in coldfusion? this file structure: this include page: this page code (same on pages except in body it's respective page name (i.e. - default, page1, page2): if have global layout file, file starts <html> tags, add <base href="{domain}" > tag , anchor ( <a> ) tags use root links, images, etc. alternately, can change of link, image, etc. hr

continuous integration - Jenkins: Add build step doesn't work -

i have strange error not able add in build step or post build action in jenkins. i following error when inspect same. error 404 not found http error 404 problem accessing /$stapler/bound/5a0d5381-ed63-4616-8dcb-bbc1edac79b3/render. reason: not found powered jetty:// i have tried following, clearing browser data, updating firefox version 30.0 34.0 upgrading jenkins restarting it manually try edit config.xml add build step. creating new job has same issue. clicking on add build steps nothing. inspecting errors gives me above error. couldn't enable stapler logging also. nothing successful. on highly appreciated.

java - Getting Jersey 1.x and 2.x to coexist -

i've got dropwizard project (using jersey 2.x) need use library has dependency on jersey-client 1.x , i'm having trouble getting both coexist on classpath. looks happening hk2 finding implements providers javax.ws.rs.* , attempting instantiate them. when it's class jersey 1.x, dependency injection needs isn't there , end lots of errors like: caused by: java.lang.illegalargumentexception: multipartconfig instance expected not present. have registered multipartconfigprovider class? @ com.sun.jersey.multipart.impl.multipartreaderclientside.<init>(multipartreaderclientside.java:107) @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:62) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:408) @ org.glassfish.hk2.utilities.reflec

c# - How to create a SOAP service for consume on TFS alert -

Image
i want create c# services , want when file checkin services should execute: did not calling checkinlistener.asmx public class jenkinslistener : system.web.services.webservice { static datetime lasttime; static system.timers.timer atimer; static int count; [webmethod] public void checkin() { //i want execute } and put on tfs but code not executed that code not when close... public sub notify(byval eventxml string, byval tfsidentityxml string, byval subscriptioninfo teamfoundation.subscriptioninfo) you need implements end point above. https://tfseventhandler.codeplex.com/sourcecontrol/latest#release/v1.3/rddotnet.teamfoundation/services/inotificationservice.vb here example built tfs 2008.

media player - Detect if audio is playing in browser Javascript -

is there global way detect when audio playing or starts playing in browser. something along idea of if(window.mediaplaying()){... without having code tied specific element? i looking solution in google, didn't find yet. maybe check data has x value when audio playing. if have button start playing audio file, maybe can sure audio playing adding event listener on rep. button... maybe adding event listener "audio" tag? if remember correctly, audio tag has "paused" attribute... , remember audio has "paused" attribute... also, may want check topic html5 check if audio playing? i jus find 5 seconds ago jaja

javascript - How to prevent web page from scrolling back to the top of the browser? -

i have web page listing of items such books, , it's been rendered javascript, making requests restful services. however, if scroll down bottom of browser, , select view item, , press browser button, page doesn't scroll down bottom. instead, scrolls top of browser. how can make web page scrolls previous location? it depends on how implementing events. i suppose attached event link , set href attribute "#". why scroll goes top. if using jquery, can use preventdefault() method event object , should work. otherwise, if return false in event handler, action should stop. can provide code of how you're calling resful service?

C static array pointer address -

we have code. #include <stdio.h> int* aa(int s){ static int ad[2] = {0}; ad[0] = s; printf("aa() -> %p\n", &ad); return ad; } int main(void) { int *k = aa(3); printf("main() -> %p\n", &k); return 0; } compile, run.. output aa() -> 0x80497d0 main() -> 0xbfbe3e0c or misunderstood or code have problems. we returning same address static array ad why on output differ? in main you're printing address of k pointer variable, not address of array points to. if do: printf("main() => %p\n", k); you'll same address printed in aa .

objective c - Consecutive Primes Challenge -

i working on consecutive primes challenge @ codeeval.com , can't pass automatic grader. think getting correct results possibly missing edge cases. tried recursion couldn't work , slow. figured out solution creating 2 arrays , odd numbers. please let me know if viable solution , if can see mistake. here challenge description: alice has number of n beads, , each bead has number 1 n painted on it. make necklace out of beads, special requirement: 2 beads next each other on necklace must sum prime number. alice needs calculate how many ways possible so. for example: n = 4 there 2 possible ways build necklace. note last bead connects first bead. 1 2 3 4 1 4 3 2 note: necklace should unique. example: 1 2 3 4 same 2 3 4 1 , 3 4 1 2 , 4 1 2 3 . the code has c , obj-c because of limitation in codeeval.com auto grader. here code: bool isprime(int number){ for(int = 2;i<(int)(number/2)+1;i++){ if (number%i

postgresql - Rename the Amazon RDS master username -

changing password done through console. there way change master username after creation on rds postgresql? if so, how? you can't change username. can check following links describe how change master password , if amazon adds ability change username find there: try find @ aws cli rds : modify-db-instance --db-instance-identifier <value> --master-user-password (string) --master-user-password (string) the new password db instance master user. can printable ascii character except "/", """, or "@". changing parameter not result in outage , change asynchronously applied possible. between time of request , completion of request, masteruserpassword element exists in pendingmodifiedvalues element of operation response. default: uses existing setting constraints: must 8 41 alphanumeric characters (mysql, mariadb, , amazon aurora), 8 30 alphanumeric characters (oracle), or 8 128 alphanumeric characters

Where is the salt on the OpenSSL RSA algorithm? -

i find salting technique symmetric routines in openssl option -salt . can't find salt option asymmetric rsa algorithm. a salt parameter makes sense password-based encryption. password used derive key used encryption. when ever pass password openssl encrypt something, might specify salt increase input entropy of whole process. rsa not password-based. keys generated in advance , used directly. so, there no place use salt rsa. there difference in structure of symmetric keys , rsa keys. keys symmetric block ciphers binary strings/arrays. can generated randomly or salted password. rsa keys on other hand have specific mathematical structure , cannot purely random. this because 1 rsa key pair used encrypt communication between 2 parties in 1 direction. 1 cannot generate public key without private key rsa. have generated @ same time. wouldn't make sense let 1 party generate public key , other private key salt, because either the keys not interoperable or far wors

android - How to delete or change the searchview icon inside the SearchView actionBar? -

Image
how remove or change search view icon inside edittext? using appcompat library. i used below code modify , remove it's not working: searchmanager searchmanager = (searchmanager) getsystemservice(context.search_service); searchview.setsearchableinfo(searchmanager.getsearchableinfo(getcomponentname())); view search_mag_icon = (view)searchview.findviewbyid(android.support.v7.appcompat.r.id.search_mag_icon); search_mag_icon.setbackgroundresource(r.drawable.ic_stub); //search_mag_icon.setvisibility(view.gone); finally found solution. try following: try { field mdrawable = searchview.class.getdeclaredfield("msearchhinticon"); mdrawable.setaccessible(true); drawable drawable = (drawable)mdrawable.get(your search view here); drawable.setalpha(0); } catch (exception e) { e.printstacktrace(); }

c# - DataGridViewRow Wrong Cell Index -

i've got problem while trying values through datagridviewrow. problem cell index 7 , when try data cell using code: foreach (datagridviewrow r in this.mydatagrid.rows) { if (convert.toboolean(r.cells[0].value) == true) { datagridviewcomboboxcell cc = (datagridviewcomboboxcell)r.cells[7]; cc.value = toolstripcombobox1.selecteditem.tostring(); edit_subject(convert.toint32(r.cells[1].value), r.cells[7].value.tostring()); } an exception error comes saying cells[7] outofindex . i've tried change cell index 7 5 , it's worked , , no . please need explain because it's weird. ok found solution, problem caused because sql syntax (the datagrid datasource) has different order datagridview columns, didn't because datagrid autofill has been disabled . , i've set datapropertyname each column manually. anyway , response.

java - How to escape a invalid string using regular expression? -

i have below string, being escaped incorrectly. "\"name\":\"\"/test/name=testame\" 001\"" i use regular expression find strings contain above pattern , replace correct escape pattern. @ moment, i'm using hard coding find , replace string, not want. ps: i've no control of above string pattern. i'll have handle incorrectness in application. any suggestions? this help: \\ finds \ \" finds " [a-za-z_-]+ enough match labels , names [0-9]+ match number without screwing or finding much : , = literals , don't need escaping put 'em , you've got night regular expression. i don't see in question prohibit doing substitution using parenthesis, didn't tool you're using replacing can't give many hints. you'll put (part 1 of regexp)some literal hate(part 2 of regexp) as matcher , \1some literal like\2 as substitution string. if going perl you'd use s\mat

methods - Why does eye(size(X)) (where X is some array) throw an error? -

why can use x = randn(size(y)); and x = eye(size(y,1), size(y,2)); but not x = eye(size(y)); ? throws following error, don't understand: error: eye has no method matching eye(::(int64,int64)) the error error: eye has no method matching eye(::(int64,int64)) should tip off on nature of problem. when in doubt, have @ function's methods , check whether types align of them. eye methods you can list methods provided eye calling methods on it: julia> methods(eye) # 7 methods generic function "eye": eye{t}(::type{diagonal{t}},n::int64) @ linalg/diagonal.jl:92 eye(t::type{t<:top},m::integer,n::integer) @ array.jl:176 eye(m::integer,n::integer) @ array.jl:182 eye(t::type{t<:top},n::integer) @ array.jl:183 eye(n::integer) @ array.jl:184 eye(s::sparsematrixcsc{tv,ti<:integer}) @ sparse/sparsematrix.jl:413 eye{t}(x::abstractarray{t,2}) @ array.jl:185 do types align? first, let's generate random data: julia>

html - media queries max width 320px issue -

i have problem media queries in 320px width. tried next codes set query browsers don't recognise it, doesn't work correctly: 1- @media screen , (min-width: 320px) { 2- @media (min-width:320 px) , (max-width:480 px) 3- @media (max-width: 320px){ none of them work me. doing wrong? thanks lot! try @media screen , (min-width:3.33%){ .yourclass{ width : 20%; } } and better u use % instead of px

java - Quick Program help (quick fix) -

i have homework assignment need make array of lightbulb objects. add method "turn them on". need have nested loop have imaginary person turn on every bulb pull string on every other bulb every 3rd , on until every 20 bulbs. code have. compiles when run it, goes forever. please help public class lightbulb { public boolean isturnedon; public lightbulb() { isturnedon = false; } public boolean ison() { if(isturnedon==false) return false; return true; } public void pullstring() { if(isturnedon==true){ isturnedon=false; } isturnedon=true; } } public class lightdriver { public static void main(string[]arg) { int numon=0; lightbulb[]bulb=new lightbulb[100]; for(int a=0;a<100;a++){ bulb[a]=new lightbulb(); } for(int b=0;b<=19;b++){ for(int c=0;c<=100;c=b+

ios7 - iOS 7/8 system keyboard height -

i've spent few days trying research feel answer 1 liner, here goes: this question not refer custom keyboards on ios system keyboard pops first responders. i noticed default keyboard on apps shorter , more slick keyboard end getting on app. here keyboards (sorry not uploading photos, don't have enough rep yet) most apps: http://i.imgur.com/fru19oy.png the keyboard i'm getting: http://i.imgur.com/poeings.png is config i'm missing? os version target issue? thanks! you can add following code: textfield.autocorrectiontype = uitextautocorrectiontypeno; where textfield text field or text view showing keyboard.

java - type does not take parameters in generics -

i have interface takes generic argument: package com.lbv.itf; public interface segment<t extends object> {...} and written couple of years back, compiled in 1.6 , built jar, segment.jar now, have new project using segment.jar , in new project, have class implementing interface: package com.lbv.impl; import com.lbv.itf.segment; public class treesegment implements segment<tree> {...} compiling newer class in 1.7 gives error: type com.lbv.itf.segment not take parameters it looks obvious segment interface takes parameter somehow, not visible while compiling newer class. known jdk compatibility issue or there missing? of great help. update: works if compile newer code 1.6 :(. there compatibility issue 1.6 1.7 on generics type parameters? i using java 1.6 update 45 64 bit and java 1.7 update 60 64 bit this has happend because legacy code compiled option ` 'target=jsr14' ` stripped off type parameters generated

php - db class function not recognised -

getting an: fatal error: call undefined method userscontroller::select() application/models/user.php on line 27 it looks userscontroller not sending select function db.class.php have inside library folder. the db.class.php being loaded not in case. code inside usercontroller.php class is: class user extends model { /** * login method * * @todo: update last_login_time * @todo: add hashing */ public function user_login() { $username = $_post['data']['user']['username']; $password = $_post['data']['user']['password']; $bind = array( ":username" => $username, ); $result = $this->select("users", "username = :username", $bind); //check password returned db against password entered if (bcrypt::checkpassword($password, $result[0]['password']) == true) { session::init(); session::set('user_logged_in', true);

tor - silvertunnel-ng netlib 0.0.4 in android -

i want ask if possible use silvertunnel-ng netlib 0.0.4 on android device. try use have problem security calculation in encryption class of library. warning message : warn org.silvertunnel_ng.netlib.layer.tor.util.encryption - verifysignature(): try fix bug in security calculation openjdk-6 java web start (ticket #59) 04-14 22:01:28.262 [org.silvertunnel_ng.netlib.layer.tor.directory.directorymanagerthread] warn org.silvertunnel_ng.netlib.layer.tor.util.encryption - verifysignature(): original decrypteddigest=01:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff:ff

ios - Change to Different View Controller Immediately after authenticating in a Web View -

i have uiwebview opens webpage in app user can log in account. want app change view controllers after user has logged account without seeing next webpage in webview. code in viewdidload function: - (void)viewdidload { [super viewdidload]; nsstring *webpage = @"myfakewebpage.com"; self.defaults = [nsuserdefaults standarduserdefaults]; [self.activityindicator startanimating]; [self.mywebview sethidden:yes]; self.mywebview.delegate = self; nsurl *myurl = [nsurl urlwithstring:triggerpage]; self.myrequest = [nsurlrequest requestwithurl:myurl]; [self.mywebview loadrequest:self.myrequest]; } and webviewdidfinishload function looks like: - (void)webviewdidfinishload:(uiwebview *)webview { if ([self.activityindicator isanimating] == yes) { [self.activityindicator stopanimating]; [self.activityindicator sethidden:yes]; [self.mywebview sethidden:no]; } [self loadviewcontrollerafterauthentication];

clojure - (gensym) is always unique, `(symb#) is not -- why? -

if write macro uses symb# shortcut create gensym bound global variable, exact same symbol gets generated on , over. however, functions correctly if call gensym manually. simple examples: (defmacro indirection [name & body] `(do (def name# ~@body) (defn ~name [] name#))) (indirection foo 3) (foo) ; ⇒ 3 (indirection goo 5) (goo) ; ⇒ 5 (foo) ; ⇒ 5 the problem apparent if use macroexpand : (macroexpand '(indirection foo 3)) (do (def name__2863__auto__ 3) (clojure.core/defn foo [] name__2863__auto__)) (macroexpand '(indirection foo 3)) (do (def name__2863__auto__ 3) (clojure.core/defn foo [] name__2863__auto__)) this problem goes away if call gensym long way: (defmacro redirection [name & body] (let [rename (gensym)] `(do (def ~rename ~@body) (defn ~name [] ~rename)))) (redirection koo 3) (koo) ; ⇒ 3 (redirection moo 5) (moo) ; ⇒ 5 (koo) ; ⇒ 3 so, why difference? missing? syntax quoting ` reader mac

java - How is the resource clean up being done in the following Apache HttpClient usage with PoolingHttpClientConnectionManager? -

the code being referred under this question on codereview forum . when httpclientpool.getclient().execute(request), r) in query method, have used client send httprequest.. don't need release / clean resources ? does monitor thread's while ((stoprequest = stopsignal.poll(5, timeunit.seconds)) == null) { // close expired connections cm.closeexpiredconnections(); // optionally, close connections have been idle long. cm.closeidleconnections(60, timeunit.seconds); // @ pool stats. log.trace("stats: {}", cm.gettotalstats()); } suffice release connection used client obtained pool. a few questions : does mean let connection expire or go idle them reclaimed pool ? what difference between expiry , going idle ? how physical connections, connection objects, connectionmanager objects, httpclient objects' life cycles maintained , relation between them ? sorry amateur questions. new httpclient. the primary c

ios - Replace character in NSMutableAttributedString -

this works regular nsstring : nsstring *newstring = [mystring stringbyreplacingoccurrencesofstring:@"," withstring:@""]; but there no such method nsmutableattributedstring . how remove instances of comma in nsmutableattributedstring ? do before create attributed string, if can or depending on how source it. if can't can use replacecharactersinrange:withstring: (or replacecharactersinrange:withattributedstring: ), need know range need search , iterate yourself.

java - How to send info to a helper function in jsp? -

i creating game. user must login play game. once click login, should go game. in game random number generated, , 100 buttons. buttons have 1-100 values, selecting 1 of buttons, user guess random number. once button clicked should go helper class , compare results see if number clicked matched random number. appropriate message display based on results. i have created helper class(gghelper.java): public class gghelper extends httpservlet { static int randomnum=0; static string message = ""; public static int randomnum() { randomnum = (int) (math.random() * 100); system.out.println(randomnum); return randomnum; } public static int returnnum() { return randomnum; } public static string clicks(){ httpservletrequest request = null; int num = integer.parseint(request.getparameter("userentery")); if ( num== randomnum) { message = "you won"; } else if (num > randomnum) { message = "your guess high"; } else {

python - Python34: Using Dictionary Comprehension to Copy Values form one list of dictionaries to another -

i writing script process data have list containing dictionaries calculated values. once calculate new ones want append appropriate dictionary new entries. i know list or np array, want learn how use dictionaries. started using list comprehension want better understanding on how use appropriately. making life hard on myself. here simplified examples. i calculate values , place them in dictionary, goes in list correspond each entry. a=[{'low':1},{'low':2}] print(a) [{'low': 1}, {'low': 2}] # entry 0 corresponds sample 1 , next sample 2 b=[{'hi':1},{'hi':2}] print(b) [{'hi': 1}, {'hi': 2}] # entry 0 corresponds sample 1 , next sample 2 c=[{}]*len(a) # initialize list contain dictionary each sample. each dictionary receive corresponding values copied , b print(c) [{}, {}] now try use dictionary comprehensions {c[x].update(a[x]) x in range(len(a))} print(c) [{'low': 2}, {'low': 2}] the

asp.net mvc - how to access input type=submit value in c# mvc controller -

i developing c# mvc application. have index action doubles , post action. in view, user able search project name or number (or other different options). <tr> <th> find name: </th> <th> @html.textbox("namesearchstring", viewbag.currentnamefilter string) </th> <th> <input type="submit" value="search name" name="searchbutton" /> </th> </tr> <tr> <td></td> </tr> <tr> <td></td> </tr> <tr> <th> find project number: </th> <th> @html.textbox("numbersearchstring", viewbag.currentnumberfilter string) </th> <th> <input type="submit" value="search number" name="searchbynumber"

grammar - One Language and Proof How it's ambiguous? -

i took midterm couldn't answer question. how can show following language ambiguous ? l={a n b m c p : n≠m} u {a n b m c p : m≠p} i think hard, can me automated tools or ... how can prove ? consider 1 possible grammar language {a n b m c p : n≠m} : s → x c | x b c x → ε | x b → | a b → b | b b c → ε | c c in grammar, left-most derivation of word not expand , c until other non-terminals have been expanded. similar grammar other half of union ( a n b m c p : m≠p} expand a s before other non-terminal expanded. word in intersection of 2 subsets therefore have (at least) 2 distinct derivations. proving language inherently ambiguous requires proving above true grammar language. such proof based on ogden's lemma, generalization of pumping lemma context free languages; proof consists of demonstrating word can "pumped" in 2 different ways. it relatively easy find proof similar language {a n b m c p : n=m} ∪ {a n b m c p : m=p} inh

ios - Can HKAnchoredObjectQuery query for a deleted HKSampleType in HealthKit? -

i have hkobserverquery set uses hkanchoredobjectquery retrieve new additions hksampletype. there way same thing hksampletype has been deleted? hkobserverquery called on delete there doesn't seem way figure out deleted. thanks! starting in ios 9, can use hkanchoredobjectquery query healthkit deleted samples. use new init method takes resultshandler parameter.

c++ - OpenCV Help - Error: no operator "=" Matches these operands. operand types are cv::Mat = IplImage* -

i have started learning how use opencv , have been following tutorials hosted website. using opencv 3.0, however, seems of tutorial information out of date. i , on tutorial "cascade classifier" link: http://www.docs.opencv.org/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.html they provided example code not running me , cannot understand why. have provided code example below: #include "opencv2/objdetect/objdetect.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" #include <iostream> #include <stdio.h> using namespace std; using namespace cv; /** function headers */ void detectanddisplay( mat frame ); /** global variables */ string face_cascade_name = "haarcascade_frontalface_alt.xml"; string eyes_cascade_name = "haarcascade_eye_tree_eyeglasses.xml"; cascadeclassifier face_cascade; cascadeclassifier eyes_cascade; string window_name = "

ruby on rails - Stack overflow push rejected with no reason -

i'm trying push heroku , get's verifying deploy... step rejects push no reason: remote: =====> downloading buildpack: https://github.com/heroku/heroku-buildpack-ruby.git remote: =====> detected framework: ruby remote: -----> compiling ruby/rails remote: -----> using ruby version: ruby-2.1.2 remote: -----> installing dependencies using 1.7.12 remote: running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment remote: fetching source index https://rubygems.org/ remote: verifying deploy.................................................. remote: remote: ! push rejected <app_name_omitted>. remote: ! [remote rejected] test_botched_deploy -> master (pre-receive hook declined) error: failed push refs 'https://git.heroku.com/app-name-omitted.git' i'm not sure google this. there way enable verbose mode heroku deploys? presuming works locally before push, place s

asp.net - how to assign value to entity got from database -

i have linq query below: public iqueryable<vmemp> getemp(int crewid) { var dt = new empentities(); var e = t in dt.tblemp (t.crewid == crewid) select new vmemp { id = -1, crew = t.crewid, name = t.name, address = t.address }; return e; } i hope can make id auto decrease 1 till end of employee. first's id -1, second's -2, third -3 ... how here? lot use counter variable , decrease every record while project custom poco. public iqueryable<vmemp> getemp(int crewid) { int counter=0; var dt = new empentities(); //load items list of anonymous type var elist = t in dt.tblemp (t.crewid == crewid) .select(s=> new { id = 0, crew = s.crewid, name = s.name, addr

visual studio 2013 - VB.net: Remove ToolStripPanel/ToolStripContentPanel -

while working on project vb.net project in visual studio 2013 community, accidently inserted toolstrippanel/toolstripcontentpanel controls combination. unfortunately however, cannot delete it. can advise how go doing this? there must surely way. unfortunately, cant hit undo either project has been saved since.

grails test-app MetaDataAccessException after upgrade to mysql-connector-java:5.1.34 -

i upgraded mysql:mysql-connector-java:5.1.34 connector. grails version 2.2.4. mysql version 5.6.10. upgrading went smoothly, , application seems go fine. however, 1 of test apps failing. following error happens: error error executing script testapp: org.springframework.beans.factory.beancreationexception: error creating bean name 'transactionmanagerpostprocessor': initialization of bean failed; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'transactionmanager': cannot resolve reference bean 'sessionfactory' while setting bean property 'sessionfactory'; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'sessionfactory': cannot resolve reference bean 'hibernateproperties' while setting bean property 'hibernateproperties'; nested exception org.springframework.beans.factory.beancreationexception: error creatin

cookies - How can I get my XSS script to properly talk to my C server? -

for class assignment, told use xss attack steal cookie. given vm work on , client steal cookie. have ability use telnet make client go url want, unable view directly happens. given website on server vulnerable. since network closed , client able visit sites hosted either provided server or vm, professor suggested write simple c server, have listen on specific port, , send cookie through allow server print it. here server using. listening on port 8888. #include<stdio.h> #include<string.h> //strlen #include<sys/socket.h> #include<arpa/inet.h> //inet_addr #include<unistd.h> //write int main(int argc , char *argv[]) { int socket_desc , client_sock , c , read_size; struct sockaddr_in server , client; char client_message[2000]; //create socket socket_desc = socket(af_inet , sock_stream , 0); if (socket_desc == -1) { printf("could not create socket"); } puts("socket created"); //prepare sockaddr_in structure server.sin_fam

user - What to Order Status in Opencart My Account page -

thanks helps or points me in right direction. i want show order status in opencart user (my account) page. show status status id. pending status id:1 , want show pending status. other status not appear. <a href="#"><?php echo $order_statuses['order_status_id']; ?></a> i put @ account.tpl result error. please me. maybe need modify *english/account/account.php controller/account/account.php template/module/account.tpl* my open cart version 1.5.6.3 custom theme. in account.php have add this. $this->load->model('account/order'); $results = $this->model_account_order->getorders(0, 5); foreach ($results $result) { $product_total = $this->model_account_order->gettotalorderproductsbyorderid($result['order_id']); $voucher_total = $this->model_account_order->gettotalordervouchersbyorderid($result['order_id']); $this->data['

python - How to ssh within iPython notebook? -

i'm attempting ssh within ipython notebook follows: %%bash ssh myserver.something.com however, receive following error: pseudo-terminal not allocated because stdin not terminal. how can ssh within ipython notebook? use ssh -t or ssh -tt in order force pseudo-tty allocation if stdin not terminal.

semantic web - protege how to add a reference to another ontologya -

i tying integrate ontology ontologies. did importing ontologies in protege, works, protege lists classes, normally. looking if there way in reference (uri) of these ontologies , can use them prefix. ofc, building ontology using owl2 i hope me if want reason , materialise facts based on terms relating referenced concept, need import ontology referenced concept belongs. e.g given external ontology following statements: ex:person owl:class; rdfs:subclassof ex:agent. if reference in without importing: ex2:doctor owl:class; rdfs:subclassof ex:person. and make following statement: ex2:jack ex2:doctor. an run through reasoner, materialise following: ex2:jack ex:person. but not following: ex2:jack ex:agent. to materialise latter, need import ontology statements ex:person.

winapi - SendMessage to TextBox Window Child in C++ not working -

char arbc[60]; cout << "message: "; cin.getline(arbc+'\0',sizeof(arbc)+1); system("pause"); postmessage(hwndch,wm_settext,(wparam)*arbc,0); so hwndch window child , child textbox, it's parent main window form. problem wm_settext isn't setting text of textbox string of characters. know it's not problem windowchild because wm_char outputs @ least 1 character in textbox. note: i'm modifying handles of process. you cannot use postmessage wm_settext . that's synchronous message. problem greater when window in different process. system needs marshal text process process. cannot asynchronous message. use sendmessage instead. your other problems include @ least following: the wparam argument wrong. parameter ignored. pass (lparam)arbc lparam instead. documentation quite clear. you should not use c strings in case. use std::string , , c_str() . your use of sizeof wrong. use of getline wrong too. you seem conf