Posts

Showing posts from July, 2012

Listen for all events in JavaScript -

i'm trying figure out how listen events on javascript object. i know can add individual events this element.addeventlistener("click", myfunction); element.addeventlistener("mouseover", myfunction); ... i'm trying figure out if there catch-all, i'd this: // begin pseudocode var myobj = document.getelementbyid('someid'); myobj.addeventlistener(/*catch all*/, myfunction); function myfunction() { alert(/*event name*/); } // end pseudocode to pick standard element's events. var myobj = document.getelementbyid('someid'); for(var key in myobj){ if(key.search('on') === 0) { myobj.addeventlistener(key.slice(2), myfunction) } } but @jeremywoertink mentioned other events possible.

How to display 7 digit numbers in matlab list box -

i have been tasked fix bug in matlab program written other people , have issue displaying 7 digit serial numbers in list box. number database , numbers pulled instead of example having serial number 4800801 displayed in listbox control, displayed in scientific notation. here code statement = 'select product_serial_number master_product status = 109 order product_serial_number asc'; curs = exec(conn, statement); curs = fetch(curs); if strcmp(curs.data,'no data') == 0 handles.matrix(1:length(cell2mat(curs.data)),1) = cell2mat(curs.data); end handles.basepre2data = curs.data; set(handles.listbaseprebuild2,'string',handles.basepre2data); r = cellfun(@isnumeric, curs.data); if mean(r) == 1 set(handles.textboxbaseprebuild2total,'string',num2str(length(handles.basepre2data))); else set(handles.textboxbaseprebuild2total,'string','0'); handles.basepre2data = []; end i new matlab not sure how format output 7 digit numb

javascript - HIGHCHARTS PIE - APPLYING AJAX, REFRESH CHART -

im new in js/ajax/json, want apply ajax code chart can redraw depend on data gets in database. line of code has no errors, not refreshing itself. please me make chart dynamic. help/comments/suggestions appreciated. here's code: data.php $<?php $con = mysql_connect("localhost","root",""); if (!$con) { die('could not connect: ' . mysql_error()); } mysql_select_db("survey_processor", $con); $result = mysql_query("select msv_variants.var_text, b.count msv_variants, (select ans_var_id ,count(*) count (select ans_var_id msv_answers ans_que_id = '11') group ans_var_id) b msv_variants.var_opt_id = b.ans_var_id , msv_variants.var_que_id = '11' "); $rows = array(); while($r = mysql_fetch_array($result)) { $row[0] = $r[0]; $row[1] = $r[1]; array_push($rows,$row); } print json_encode($rows, json_numeric_check); mysql_close($con); ?> pie.js $(document).ready(function() { var

java - WebSocketContainer.connectToServer seems to hang -

when try make websocket session through java application using websocketcontainter.connecttoserver seems hang. don't indication there exception, or connection made. code doesn't execute past connecttoserver call. string default_uri = "ws://blah/ws/test"; websocketcontainer wscontainer = containerprovider.getwebsocketcontainer(); session session = wscontainer.connecttoserver(myclient.class, new uri(default_uri)); //this line never gets executed. session above isn't returned nor error system.out.println(session); from example, i'd expect sort of connection error seeing i'm trying establish connection websocket address isn't valid. when using valid ws address don't progress past getting connection return session.

ajax - File posted to MVC Controller is null -

i want post 3 things mvc controller: 1 image , 2 strings. on view , i've got form uses enctype="multipart/form-data" automatically submits form after image file selected. submit handler form: $("#photouploadform").on("submit", function (event) { event.preventdefault(); var imagedata = $("#photouploadfileinput").val(); var guestnumber = $("#guestid").val(); var tcsa_id = vm.getselectedtreatmentareatcsa_id(vm.photographs.selectedtreatmentarea()); var dto = { imagedata: imagedata, guestnumber: guestnumber, tcsa_id: tcsa_id } $.ajax({ url: 'saveimage', type: "post", contenttype: "multipart/form-data", data: ko.tojson(dto), success: function (data) { console.log(submitted); } }); }); the dto object def

html - Emoticons replacement in PHP with some conditions -

this question has answer here: a better way replace emoticons in php? 5 answers i'm looking way replace emoticons in php , code below. function emotify($text) { $icons = array( '3:)' => '<li class="emoti emoti55"></li>', 'o:)' => '<li class="emoti emoti54"></li>', ':)' => '<li class="emoti emoti00"></li>', '>:(' => '<li class="emoti emoti19"></li>', ':(' => '<li class="emoti emoti01"></li>', ':p' => '<li class="emoti emoti14"></li>', '=d' => '<li class="emoti emoti08"></li>', '>:o&#

jquery - insert values at certain index (or indices) javascript -

i have hit block in working on assignment. how insert value given index or indices? for example, i'm working on hangman game. if word "harry", , player guesses letter "r" how turn array of underscores "_ _ r r _"? what have below gets word separate js file, creates array of underscores (one each letter of returned word), , then, when user guesses letter, finds index or indices of occurrences of letter. **i've updated code below. loop towards end goes array of underscores (wordtoguess[]) , splices in users input. need puts last guessed letter in front. example if word "bold" , last letter user guessed "l", wordtoguess array lbold. here know why is? i'm sure easy i'm overlooking, driving me nuts. javascript var word; $(document).ready(function () { setgameboard(); }); //when guess button clicked $('#btnguess').click(function () { checkguess(); }); function getphrase() { word = returnwor

excel - Macro that runs a Macro that opens files and save them as value - Runtime Error 1004 -

i keep getting 1004 runtime error. have slimmed programing down it’s not programception. think may have using excel 2010 save .xls files. not sure. when auto_root.xls opens runs sub auto_open() opens panel.xls panel opens , runs sub update() sequentially opens 7 files in different directories called auto_update.xls auto_update.xsl opens , runs sub flat each open number of files sequentially , saves flat copy of in directory. i have opened each of 7 auto_update.xls files , have run them independently , run no errors. when run them auto_root runtime error 1004. , currentwb.save highlighted on 1 of files. replaced currentwb.save currentwb.saveas filename:=targetfile, fileformat:=xlnormal , recieved same runtime error. attached code have. autoroot.xls!auto update sub auto_open() application.cutcopymode = false dim panelfilepath string dim panelfilename string dim panellocation string dim panelwb workbook panelfilepath = "d:\umc\umc production files\automation fi

doctrine2 - doctrine dql exception: Illegal offset type in /var/www/Symfony/vendor/doctrine/orm/lib/Doctrine/ORM/Query/SqlWalker.php line 601 -

i want produce dql following mysql query: select * `folders` `t` `t`.`library` = @mylib , and `t`.`id` not in ( select distinct(`f`.`id`) `folders` `f` join `folders` `ff` on (`f`.`position` concat(`ff`.`position`, '%')) `ff`.`active` = 1 , `ff`.`library` = @mylib , `f`.`library` = @mylib ) order `t`.`position` asc the query works fine in mysql , returns correct records. generate dql i've tried both below options: 1. $query = $em->createquery("select f mybundle:folders t t.library = :libid , t.id not in ( select distinct(f.id) mybundle:folders f join mybundle:folders ff f.position concat(ff.position, '%') , f.library = :libid , ff.library = :libid , ff.active = true ) order t.position asc") ->setparameter('libid', $library); $result = $query->getresult(); 2. $q1 = $this->createquerybuilder('f') ->select('distinct(f.id)'); $q1->join('\mybundle\entity\folders',

How to add a static library to a project that uses cocoapods (iOS) -

i have project uses cocoapods time. recently, bought external library vendor. library sent me static library (.a) , 2 headers files (.h). i imported both files , added static libraries build phases -> link binary librareis. however, project can not find static library. the same library works fine on project not use cocoapods (and workspace). think compatibility problem configuration made cocoapods. i've tried add static library path header search path , library search path. no success. any suggestions? the standard procedure of adding library is add other linker flags -l${name_of_library_without_lib_prefix_and_.a_suffix} , example libz.a -lz add library library search path. there useful global vars $(project_dir) $(srcroot) you can reference while defining path library add header search path path library headers. can use $(project_dir) , $(srcroot) part of path. as using external libraries cocoapods - there should no difference ap

c# - Unable to set FillBackgroundColor -

i'm using npoi 2.0.6.0 in c# project , i'm running difficulty changing styling. while can affect font , cell borders cannot change background color. private void buildsheet(hssfworkbook wb, datatable data, string sheetname) { var chelp = wb.getcreationhelper(); var sheet = wb.createsheet(sheetname); hssffont hfont = (hssffont)wb.createfont(); hfont.boldweight = (short)fontboldweight.bold; hfont.color = hssfcolor.white.index; hfont.fontheightinpoints = 18; hssfcellstyle hstyle = (hssfcellstyle)wb.createcellstyle(); hstyle.setfont(hfont); hstyle.borderbottom = borderstyle.medium; hstyle.fillbackgroundcolor = hssfcolor.black.index; irow headerrow = sheet.createrow(1); int cellcount = 1; foreach (string str in colheaders) { hssfcell cell = (hssfcell)headerrow.createcell(cellcount); cell.setcellvalue(chelp.createrichtextstring((str))); cell.cellstyle = hstyle; cellcount += 1; }

How to compare time from existing records in rails 4 and mongoid -

lets say, user has task in database. task's attributes week_day: 'monday', start_at: '12:30', ends_at: '13:30' new task should not assigned same user @ time duration. how achieve this. appreciate :) class user has_many :tasks end class task belongs_to :user field :week_day, type: string # e.g 'monday' field :starts_at, type: string # e.g '13:00' field :ends_at, type: string # e.g '13:30' field :user_id end presumably intervals don't cross day boundaries don't have worry that. presence of separate day of week field sort of implies this. you'll need have validations ensure both starts_at , ends_at exist , have right format. you'll need ensure starts_at strictly less ends_at times make sense. luckily hh:mm format compares (i.e. '11:02' < '13:42' strings) can use simple string operators compare times. that leaves overlaps. given 2 open intervals, (a, b

python - Convert word2vec bin file to text -

from word2vec site can download googlenews-vectors-negative300.bin.gz. .bin file (about 3.4gb) binary format not useful me. tomas mikolov assures us "it should straightforward convert binary format text format (though take more disk space). check code in distance tool, it's rather trivial read binary file." unfortunately, don't know enough c understand http://word2vec.googlecode.com/svn/trunk/distance.c . supposedly gensim can also, tutorials i've found seem converting from text, not other way. can suggest modifications c code or instructions gensim emit text? i use code load binary model, save model text file, from gensim.models.keyedvectors import keyedvectors model = keyedvectors.load_word2vec_format('path/to/googlenews-vectors-negative300.bin', binary=true) model.save_word2vec_format('path/to/googlenews-vectors-negative300.txt', binary=false) references: api , nullege . note: above code new version of gensim.

SonarQube scan failing with "is already part of project XXX error is already part of project" -

recently upgraded sonarqube 4.0 4.3.3. post upgrade when try run maven build getting error: failed execute goal org.codehaus.mojo:sonar-maven-plugin:2.4:sonar (default-cli) on project xxx on project yyy module "abc.def.xyz" part of project of other project. the issue scan on multiple branches have modules same name. there way turn off validation? assume have multiple modules maven project below structure: com.company:project com.company:project-module1 com.company:project-module2 in java source code, "com.company:project" renamed "com.company:myproject", new java source strucutre becomes: com.company:myproject com.company:project-module1 com.company:project-module2 when build new source , push analysis data sonar, prompt: [error] failed execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.2:sonar (default-cli) on project myproject: module "com.company:project-module1" part of pr

javascript - What is the meaning of a for/in loop on a string? -

is code valid javascript? for (item in "abc") { console.log(item); } output: 0 1 2 what meaning of for/in loop on string? if think of string array of characters, purpose of looping on string iterate through each of characters. in javascript for..in loops return keys in object or array, you're seeing array indices. more useful format be: var str, item; str = "abc"; (item in str) { console.log(str[item]); } which output 'a' , 'b' , , 'c' . is code valid javascript? it now, there issues in past. note older browsers, array indices weren't supported on strings, backwards compatible way iterate on characters in string is: var str, i; str = "abc"; (i = 0; < str.length; i++) { console.log(str.charat(i)); }

Java servlet DOM manipulation and html output -

i trying html elements id in java servlet, , change content , display document. problem got elements , set them (atleast think so), how display in browser, here have done : @webservlet(description = "profile page", urlpatterns = { "/profile/*" }) public class routeservlet extends httpservlet { private static final long serialversionuid = 1l; protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { response.setcontenttype("text/html"); string uri = request.getrequesturi(); final string start = "/social/profile/"; string userid = uri.substring(start.length()); long id = long.parselong(userid); //response.getwriter().print(id); (info j : inforegistry.getinstance().getinfolist()) { if (j.getid() == id) { file template = new file("profile-template.html"); documentbuilderfactory factory = documentbuilderfacto

php - How to insert the search query string in an anchor -

let's take 3 keywords: sunlight , mirror , eclipse when doing search using form: <form method="get" action="search.php"> <input name="q" type="search"> </form> the url looks nice, this: http://localhost/gallery/search.php?q=sunlight+mirror+eclipse so far good. when trying insert search query string in anchor, this // query string if (isset($_get['q'])) { $current_q = $_get['q']; } <a href="<?php echo 'http://localhost/gallery/search.php?q=' . $current_q; ?>">this query</a> i ugly weirds characters in between keywords, this: http://localhost/gallery/search.php?q=sunlight%20mirror%20eclipse why? , how make nice, when using form? thanks the easiest way use $_server['query_string'] after ? in same way url getting it http://localhost/gallery/search.php?q=sunlight+mirror+eclipse some code <?php $query = $_server[

javascript - Focus selection in layout -

here js fiddle using create expanding boxes products: http://jsfiddle.net/wpneily/vsnag7ja/ using code: var $container = $('#iso-container'), $items = $('.item'); $container.isotope({ itemselector: '.item', masonry: { columnwidth: 60 }, getsortdata : { selected : function( $item ){ // sort selected first, original order return ($item.hasclass('selected') ? -500 : 0 ) + $item.index(); } }, sortby : 'selected' }) $items.click(function(){ console.log('ee') var $this = $(this); // don't proceed if selected var $previousselected = $('.selected'); if ( !$this.hasclass('selected') ) { $this.addclass('selected'); } $previousselected.removeclass('selected'); // update sortdata new items size $container .isotope( 'updatesortdata', $this ) .isotope( 'updatesortdata', $previousselected ) .isotope(); }); $('.noclick').click(function(e){ console.log(

asp.net mvc - How to include more than one class while fetching from database -

i want include 2 classes while fetching. know how 1 class not sure how two. here including student var service = dc.service.include("student").orderby(i => i.id); i not sure how add both student , program you can chain multiple include methods. var service = dc.service.include("student").include("program").orderby(i => i.id);

Comparing two objects with Groovy -

is there easy utility groovy give me difference of 2 different objects? i'm getting message via equals method aren't equal can find properties not being matched? i found easy .properties attribute of object produced map listing property name key , value value. once had difference between 2 maps , i've got answer looking for. each of objects has .properties extension. works python .dict. example object1.properties - object2.properties so these show difference between object1 properties , object2 properties, there exist entity (key+value) differs within object2. if there properties in object2 not shown.

c - User defined signal message -

so, i'm using signals project, , i'm getting not error think. i'll explain, got code, sr2 global variable triggered signal sigusr2 , signal handling working fine. compile , run, , when trigger sigusr2, prints "user defined signal 2" , stops. i have code in while(1) loop , it's not supposed stop. can fix problem printting something, printf commented, keeps printing forever, , can't make new inputs, trigger other signals. int teste( const char* path , const char* cadeia, const char* erro ) { int i, x, stat; int fd = open( path, o_wronly | o_creat , s_irusr | s_iwusr | s_ixusr | s_irgrp | s_iwgrp | s_ixgrp | s_iroth | s_iwoth | s_ixoth ); x = flock(fd, lock_ex); if ( sr1 ) { printf("sr1\n"); //sr1 = !sr1 ; } if ( !sr2 ) { ( i=0 ; i<cadeias ; i++ ) { stat = write( fd, cadeia, strlen(cadeia)); } } else { printf("\n"); ( i=0 ; i<cadeias/2 ; i++ ) { stat = write( fd, cadeia, str

pdflatex - Latex List of Figures -

so i'm trying hide label in cover image. >\begin{figure} >\center >\includegraphics[scale=0.5]{universidade} >\caption* {mycaption} >\end {figure} this way it's not labeling figure not showing on list of figures please ;d you can give caption package option labelformat=empty suppress figure 1 etc. labelling: \usepackage[labelformat=empty]{caption} you can use square brackets specify description figure list, , curly brackets actual figure caption. think should able following supress caption still have entry in figure list: \begin{figure} \center \includegraphics[scale=0.5]{universidade} \caption[mycaption]{} \end {figure}

html - Make image ignore color animation in css -

i have html code: <a href="(link)" target="_blank"><img src="(image source)" title="click go website!" style="position:fixed;top:10px;left:10px;z-index:999"/></a> and here css code: a { color: inherit; text-decoration: underline; -webkit-animation: hue 60s infinite linear; } a:hover { color: #f35626; } but want make image (in html code above) not use css code shown above because css used other parts of site. know how? thanks. you can put class on image link , filter out in css <a class="imagelink" href="(link)" target="_blank"><img src="(image source)" title="click go website!" style="position:fixed;top:10px;left:10px;z-index:999"/></a> css: a { color: inherit; text-decoration: underline; } a:not(.imagelink) { -webkit-animation: hue 60s infinite linear; } a:hover { color: #f35626; }

assembly - Memory usage in assembler 8086 -

i made program in assembler 8086 class , working fine. beside making working program have make use low memory possible. give me tips in aspect? should write , should avoid? the program supposed first print letter on screen , in avery new line 2 more of letters of next letter in alphabet, stop @ z , after pressing key end program. stopping until key pressed i'm using: mov ah,00h int 16h way it? most of want can done in 0 memory (counting data, not code itself). in general: use registers rather variables in memory do not use push/pop do not use subroutines but interact os, need make bios calls and/or os system calls; these require memory (typically small amount of stack space). in case, have to: output characters screen wait keypress exit os however, if serious doing in minimal memory, there few hacks can use. output characters screen on pc, in traditional text mode, can write characters straight video ram (address b800:0000 , further). requires 0

php - incorrect my sql select statement results -

i have small mysql table with: id name status class desk date username it has around 300 records. when selecting data latest record date (formatted), along username , use statement: select date_format(max(date), '%d-%m-%y @ %h:%i'), username latestrecord mytable it returns correct record datetime gives different username not in same selected row. seems doesn't select username same resulted lastest date/time. any idea why happens? if want latest record should add order by , limit clausule's query: select date_format(date, '%d-%m-%y @ %h:%i') latestdate, username latestrecord mytable order date desc limit 1

wpf - Grid row height ratio based on content -

i have grid 2 rows. in each row there listview. in first row there 100 items , in second row there 500 items. not fit on screen, have scrollbars shown @ each listview (no problem) , row heights should in ratio of heights of listviews. 1* , 5* don't know in advance how big these listboxes be. note: each item may have different size, use actual listbox height instead of items count <grid> <grid.rowdefinitions> <rowdefinition /> <!-- keep ratio of rows based on listbox heights --> <rowdefinition /> </grid.rowdefinitions> <listbox grid.row="0"> <!-- 100 items --> </listbox> <listbox grid.row="1"> <!-- 500 items --> </listbox> </grid> any ideas? <grid> <grid.rowdefinitions> <rowdefinition height="{binding height,elementname=listbox1}"/> <!-- keep ratio of rows base

html - :before element not displaying properly in firefox -

Image
why firefox misplace :before element?? <div id='remember_forgot' class='no_hl'> <div> <input id='remember_me' type='checkbox'> <label for='remember_me'>remember me</label> </div> </div> * { font-family: 'helvetica neue', helvetica, arial, sans-serif; font-size: 14px; line-height: 1.3; font-weight: normal; } input[type='checkbox'] { display: none; } #remember_forgot { display: flex; align-items: center; justify-content: space-between; margin: 2px 0; } #remember_forgot>div { position: relative; display: flex; align-items: center; } #remember_me+label:before { position: relative; top: 1px; content: ""; display: block; float: left; width: 13px; height: 13px; margin-right: 4px; font-size: 15px; line-height: 0.8; border: 1px solid black; } #remember_me:c

Can't get loaded model attributes in Ember.js -

Image
i hava model, transaction-result, have loaded of associations in aftermodel hook prior hitting point. can see on transactionresult console output it's runresult association loaded. i'm able access data want via _data but when try get runresult association, receive appears empty ember object. where going wrong? i not 100% sure source of problem when result of association ember return promise, can try that model.get("runresult").then(function(runresult){ console.log(runresult) })

c# - Calling a target from csproj file -

this question related clickonce project trying publish. basically, want have target run publish each testing environment can set publishurl , publishdir accordingly. when building project, want able call new target without using defaulttargets or adding in msbuild param. how can call target without these steps? ex: can call target target like: <target name="clientpublish"> <calltarget targets="publishforeachenv" /> </target> but how call publishforeachenv target directly csproj? hope makes sense i'm not quite sure mean, i'll take crack @ it. to edit csproj, right click on in solution explorer, select unload project . once becomes greyed out , unavailable in solution explorer, right click on again , select edit [your project name] . the file in xml, can sort in there. if towards bottom you'll see target file imports, , should see empty target each beforebuild , afterbuild. can add call custom target here,

ios - cellForItemAtIndexPath is Changing Multiple Cells When Should Change One -

i may not understanding reusing of cells behaviour uicollectionview can tell me why 2 cells having properties changed in cellforitematindexpath when should 1 cell. here's code. -(uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { photocollectionviewcell *cell = (photocollectionviewcell *) [collectionview dequeuereusablecellwithreuseidentifier:@"photocollectionviewcell" forindexpath:indexpath]; if (![[self.userphotos objectatindex:indexpath.row] isequaltostring:@""]){ nsstring *photourl = [self.userphotos objectatindex:indexpath.row]; nsurl *imageurl = [nsurl urlwithstring: photourl]; nsurlrequest *imagerequest = [nsurlrequest requestwithurl:imageurl]; [cell.photoimageview setimagewithurlrequest:imagerequest placeholderimage:[uiimage imagenamed:@"animage"] success:^(nsurlrequest *request, nshttpurlresponse *response, uiimage *image) { cell.photoi

twitter bootstrap - My CSS is not working correctly when "sails lift --prod" as it does when "sails lift" -

what wrong css when lift sails in production mode? ps: use sails v0.10.5, bootstrap v3.2.0 , custom css file custom css stuff. fyi: bad written css tag of mine. no idea why problem in production mode. here problematical tag: .form-signin { width: 300px; padding: : 19px 29px 29px; margin: 0 auto 20px; margin-top: 40px; background-color: @lightgray; border: 1px solid @green; -webkit-border-radius: 15px; -moz-border-radius: 15px; border-radius: 15px; h2 { text-align: center; margin-top: 0px; } } without h2 definition works in development mode.

scope - Haskell Referencing a Type Variable -

i run problem , wanted ask if there's common solution or pattern. is possible make type variable in nested context reference type outer context? example, foo :: -> ... -> .. foo = ... bar :: -> ... now bar 's a different foo's a . typically want, makes life difficult, , need make them same. i've used dirty tricks force type checker unify 2 in past, thwarted. here's latest example (a parsec function) spurred me asking question. data project = ... deriving enum data stuff = ... pproject :: monad m => p m stuff pproject = stuff <- pstuff ... convert stuff <$> penum :: p m project penum :: (monad m, enum a) => string -> p m penum = ... the convert function needed type, hence had specify annotation :: p m project . however, means have introduce m , unfortunately not same m in function signature. type checker reports with: could not deduce monad m1 arising use of penum context monad m is there way referen

php - Undefined Offset 1 on fgetcsv -

the following url contains tab-separated table of data particular day. 1 below january 4, 2011. http://lpo.dt.navy.mil/data/dm/2011/2011_01_04/air_temp i wrote script go through entire date range of 2010-06-01 today, grabbing date , air temperature value , insert database. amount of data kept causing timeout weird miracle able in 2014-03-27. here's script used (probably not elegant solution i'm staring out). public function requestdata(){ $year = 2014; $startdate = new datetime('2014-03-28'); $enddate = new datetime('2014-05-05'); $incrementday = new dateinterval('p1d'); while ($startdate <= $enddate) { $results = []; $startdateformat = $startdate->format('y-m-d'); //format datetime object $startdateurl = str_replace( "-", "_", $startdateformat); //prep date url entry $dayofyear = date("z", strtotime($startdateformat)); //store day of yea

c++ - Invalid types of subscript error -

i having trouble in marked "median" function. getting error says `horse[10][double]' array subscript. not sure how fix , looking friendly help. #include <cstdlib> #include <iostream> #include <math.h> /* name: horses2 author: grant birkinbine date: 03/12/14 18:25 description: program modifies horses program */ //start using namespace std; //class class horse{ private: string name ; int lane; double time; public: horse(string hname , int hlane , double htime){ name = hname ; lane = hlane ; time = htime; } horse(){ name = "" ; lane = 0 ; time = 0 ; } void setname(string hname){ name = hname; } void setlane(int hlane){ lane = hlane; }

java - I need to make permutations with an array using the ArrayList Class. I can't figure out what's wrong -

so im taking ap comp sci class in school, , in class we're learning basics of java. assignment have make permutations taking numbers 1 one-dimensional array, , putting in another, deleting number can't picked again. numbers in array can't repeat. have use arraylist class too. , can't figure out what's wrong! method creates permutations: public static arraylist<integer> createperm() { arraylist<integer> list = new arraylist<integer>(10); integer x = 1, remove = 0; (integer = 0; < 10; i++) { list.add(x); x++; } arraylist<integer> perm = new arraylist<integer>(10); for(integer = 0; < 10; i++) { integer r = (int)(math.random() * 10) + 1; (integer j = 0; j <= list.size() - 1; j++) { if (list.get(j) == r) { remove = j + 1; list

string - Regex replace - match and empty all lines not containing a specific character -

i can not use grep. in fact, in notepad2. when want remove lines containing character "c", using replace dialog (ctrl+h): search string: ".*c.*" replace with: "" (nothing) after that, sort lines , rid of empty lines. but need empty lines do not contain character "c". possible in notepad2? if can in notepad2, can using javascript's string replace too, guess. yes, anchor pattern , use negated character class. find: ^[^c]*$ explanation: ^ # beginning of string [^c]* # character except: 'c' (0 or more times) $ # before optional \n, , end of string

Summary reports in FileMaker Pro 13 -

when creating report, there script can written looks values of previous fields , if current field same value, value not show on list? so field show value if value different previous values… with 1 exception - @ beginning of new slate number, prints values every field. the simple way summarize report field , show sub-summary part (i.e. remove body part layout).

angularjs - my json file does not load in angular js? -

i have basic project in angular js, files index.html <div class="portfolio" ng-controller="portfolio-controller"> <h3>latest works</h3> <div class="col-md-6" ng-repeat="prt in portlist"> <div class="box-portfolio"> <div class="ps"> <div class="lp"><a href="#/{{ prt.id }}"><i class="fa fa-chevron-down"></i></a></div> </div> <div class="box-descrip"> <h4>{{prt.title}}</h4> <p>{{ prt.id }}</p> <p

c# - Autocomplete textbox with xml source not working -

i have web service returns list of strings. trying feed datasource auto suggesttextbox. here webservice returns <arrayofstring> <string>air pollutants</string> <string>air facilities</string> <string>air emissions</string> <string>air pollution</string> <string>air quality monitoring</string> <string>air piracy</string> </arrayofstring> this jquery ajax. $(document).ready(function () { $('#<%=txt_search_extantdata.clientid%>').autocomplete({ source: function (request, response) { $.ajax({ type: 'post', url: "/_layouts/extantlibrarywebservice/getdata.asmx/getsearchdata", data: { 'src': $("#<%=txt_search_extantdata.clientid%>").val() }, datatype: "xml", success: function (xmlres

Access Write Violation When Accessing the Value of a Register in assembly x86 -

compare proto, p1:dword, p2:dword .code compare proc p1:dword, p2:dword mov eax, p1 mov edx, p2 mov eax, [eax] ;getting access violation here mov edx, [edx] ; 1 here too, why? sub eax, edx ret compare endp main proc local thesize:dword mov thesize, 3 mov fill, 5 invoke compare, thesize, thesize ret main endp hey guys, curious why code isn't working? what's alternative way make work, i'm playing around registers , trying similar code when filling array, got stuck @ point. thanks in advance! not sure doing, since looks want dereference mem address, must use addr local vars get/pass address. main proc local thesize:dword mov thesize, 3 ; invoke compare, thesize, thesize ; same as: ; push 3 ; push 3 ; call compare ; want: invoke compare, addr thesize, addr thesize ; same as: ; lea eax, thesize ; push eax ; push eax ; call compare ret main

backup - rsync corrupted my system partition. Does anyone know why and how to recover? -

i did rsync partition on second drive (mounted symbolically linked). seemed go ok, terminal complaining system partition read-only. tried rebooting , no longer boots. complains couldn't mount /tmp/ stops black screen , cursor in top left corner. when boot usb key there nothing chewed up. @ glance files , folders seem there. , seem on backup partition. /etc/fstab looks good. i found 1 minor error in syntax on backup bash, doesn't seem explain this. put -e ssh (extraneously) wasn't meant on ssh , didn't include server. (i forgot --dry-run . should have done it.) here command line of interest bash (below) does know corrupt , how fix it? #now backup rsync -aaxve ssh --progress --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found","/etc/udev/devices","/osback/*","/vpsback/*","/jingleshare/*",&q

How to implement a DataList component in Spring MVC -

i'm working on webapp , wonder if there's chance implement following html element in spring mvc? <input list="browsers"> <datalist id="browsers"> <option value="internet explorer"> <option value="firefox"> <option value="chrome"> <option value="opera"> <option value="safari"> </datalist> thanks in advance! you can whatever want on jsp pages. for example: <form:form method="post" commandname="recipe" action="${home}/admin/recipes"> <div class="form-group"> <label><s:message code="recipe.title" />*</label> <form:input path="title" cssclass="form-control" /> <form:errors path="title" cssclass="error-help" /> </div> <div class="form-group">

How do I print the contents of a struct in C? -

resolved issues on own, using different methods suggested below! :) thanks viewing question! :) i've been learning structs , working on practice lab in c, , code not seem compiling correctly change make it. currently not receiving output , program crashes. i'm still confused on how correctly utilize '*' , '&' symbols when passing them functions well. goals practice to: print contents of array in same format data file print full name of student best gpa calculate , print average gpa print names of students gpas above average print name of youngest student has gpa below average sort structures in array order lowest highest gpa print array again (will in different order last time) how call , print these items student struct? , how access gpa values pass function calculate average? #include <stdio.h> #include <stdlib.h> // define constants #define arr 100 #define first 7 #define midinit 1 #define last 9 #define street 16 #defi

ios - CAShapeLayer rounding corners impacts performance -

i have uicollectionview (ipad) has jarry scrolling.each cell has white rectangle uiview (with rounded corners) has uiimageview in front of top 2 corners rounded. see link below how cell looks - i.stack.imgur.com/ptlig.png here's code uicollectionviewcell uiview * bgview = [[uiview alloc] initwithframe:cgrectmake(5, 5, (self.contentview.frame.size.width - 10), (self.contentview.frame.size.width - 10)*image_ratio + 43.5)]; bgview.backgroundcolor = [uicolor clearcolor]; bgview.layer.cornerradius = 10; bgview.layer.borderwidth = 0.5f; bgview.layer.bordercolor = [uicolor colorwithred: 179/255.0 green:181/255.0 blue:184/255.0 alpha:1.0].cgcolor; bgview.layer.backgroundcolor = [uicolor whitecolor].cgcolor; bgview.layer.shouldrasterize = yes; bgview.layer.rasterizationscale = [uiscreen mainscreen].scale; [self.contentview addsubview:bgview]; self.parablepost = [[uiimageview alloc] initwithframe:cgrectmake(5, 5, (self.contentview.frame.size.w

c# - Fluent Validation Inconsistent with ASP.NET MVC 5 -

i'm using fluent validation v5.5 asp.net v5.2.2 , i'm getting inconsistent results validation. my view model is: public class quoteviewmodel { [display(name = @"day")] public int dateofbirthday { get; set; } [display(name = @"month")] public int dateofbirthmonth { get; set; } [display(name = @"year")] public int dateofbirthyear { get; set; } [display(name = @"gender")] public gender? gender { get; set; } [display(name = @"state")] public int stateid { get; set; } } my controller method is: public actionresult quote(quoteviewmodel viewmodel) { var _validator = new quotevalidator(); var results = _validator.validate(viewmodel); if (!modelstate.isvalid) { return json(false); } return json(true); } my validator is: public class quotevalidator : abstractvalidator<quoteviewmodel> { public quotevalidator() { rulefor(x =&g

java - Getting item position from cursor adapter -

hello need on getting item position using cursor adapter not working error occurs , : cannot cast error. please appreciated albumfragment public class albumfragment extends fragment implements loadermanager.loadercallbacks<cursor>,onitemclicklistener{ private album malbum; private albumadapter madapter; gridview gridview; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view myfragmentview = inflater.inflate(r.layout.fragment_album, container, false); madapter = new albumadapter(getactivity(), null); gridview = (gridview) myfragmentview.findviewbyid(r.id.gridview1); getloadermanager().initloader(0, null, this); return myfragmentview; } @override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); gridview.setadapter(madapter); gridview.setonitemclicklistener(this); } @override public loader<cursor> oncreatel