Posts

Showing posts from May, 2015

ios - Cell.selectedBackgroundview not showing -

Image
cell.selectedbackgroundview isn't working. have figured out selectedview placed behind image in cell resulting in no visible image (i worked out making image small saw tick behind image). there way fix this? code seems fine must have layers static nsstring *identifier = @"cell"; uicollectionviewcell *cell = [collectionview dequeuereusablecellwithreuseidentifier:identifier forindexpath:indexpath]; uiimageview *productimages = (uiimageview *)[cell viewwithtag:100]; productimages.image = [uiimage imagenamed:[allproducts_sections[indexpath.section]objectatindex:indexpath.row]]; collectionview.backgroundcolor = [uicolor greencolor]; cell.selectedbackgroundview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"tick 1.png"]]; collectionview.allowsmultipleselection = yes; return cell -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring * cellidentifier = @"cell...

html - Javascript change urls in main menu according to language -

i'm complete noob on javascript need know if , how can done: i have site 2 languages, english , italian. italian pages on url www.mysite.com/ita/index.hmtl while english pages on www.mysite.com/eng/index.hmtl the user changes langages flag icons. problem is, can't change menu links separately ita , eng sites, can't edit html directly. right when user goes on english site, menu links still point italian pages. so there javascript code change urls in page, when user goes english version of site on page www.mysite.com/eng/index.hmtl all urls changed /ita/ to /eng/ ? you can use regular expression change links var url ='www.mysite.com/eng/index.hmtl', lang = '/ita'; url = url.replace(/\/\w*/,lang); console.log(url); => www.mysite.com/ita/index.hmtl

c# - Make Entity Framework work with object interface and Ninject -

i have object interface defined in domain layer: public myclass: imyclass { public int id {get;set;} } public interface imyclass { int id { get; set; } } now iam trying use interface in context don't find way: public dbset<imyclass> myclasses{ get; set; } don't work when ef try create db i setup ninject module (binddlmodule) with bind<imyclass>().to<myclass>(); and create kernel in context ikernel _kernel = new standardkernel(new binddlmodule()); but don't know how use _kernel in dbset configuration type of mapped implementation edit 1 an example illustrate mocking entities testing: public class1 { ... public class1(){...} public class2 class2property {get;} public void setclass2 (class2 class2value) { //logic here } } public class2 { //simple class construcor , few properties } in test write class1 c1 = new class1(mock.of<class2>()) in way class2 constructor not called , test ...

c# - ObservableCollection changing a value assigns a different value on same DataGrid row -

i wondering if possible assign value datagrid column when selectionchanged event combobox has been raised? for example, in combobox inside datagrid have 2 values of "0" , "1" if user selects "0" - column inside grid , in same row called id show "0" if user decides select "1" id in same row change "1" the other thing have data inside observablecollection, if combo 0, need id of 0 observablecollection. i hope understandable. ------ code ------- <datagrid.columns> <datagridcomboboxcolumn selectedvaluebinding="{binding cid}" selectedvaluepath="cid" header="cid" width="70"> <datagridcomboboxcolumn.editingelementstyle> <style targettype="combobox"> <!--<eventsetter event="selectionchanged" handler="abc"></eventsetter>--> ...

java - How to copy dependencies of a multi module project? -

i have project depends on different project-module in workspace. i'm trying copy dependencies (including module) lib folder creating executable jar has no packaged jars inside itself. but maven-dependency-plugin keeps complaining not copy module classes target folder of project. might wrong? my.groupt my-module 1.0 <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-dependency-plugin</artifactid> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputdirectory>${project.build.directory}/lib</outputdirectory> </configuration> </execution> </executions> </plugin> result: failed execu...

ios - How to do SVN setup for XCode 5? -

Image
i trying setup svn project. have created project last month want manage on svn. not getting proper options this. using following steps this xcode>preference>accounts> add repository source control>commit> select files initial commit>add comment after want check mark option push remote. disable. please guide me missing here. more details have attached screenshot. option @ left bottom. svn doesn't have push command. when commit changes, sent repository. that's why there 1 step svn - commit. that's difference git, have 2 steps - commit local repository, push remote repository.

java - Spring ContextLoaderListener ignores tag -

i dont know if im missing ive read documentation , asked lot cant figure why app behaving way. web application keeps complaining java.io.filenotfoundexception: not open servletcontext resource [/web-inf/applicationcontext.xml] during start up. this happens if web.xml file contents tags <context-param> <param-name>contextconfiglocation</param-name> <param-value>some/nonexisting/path.xml</param-value> </context-param> heres complete web.xml <?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name>j2ee...

Compare Dates PHP -

i want shows result current month, have no idea how this, current output this. output 2014-04-11 -> array 2014-04-11 2014-04-05 2014-03-29 php $date = date('y-m-d'); echo $date; echo "<pre>"; foreach ($submissions $test){ if($date >= substr($test['thing']['created'], 0, 10)){ echo substr($test['thing']['created'], 0, 10); echo "<br>"; } } echo "</pre>"; my current code wont work checking if whole number greater or equal to, ideas anyone? just try strtotime : $year = date('y'); $month = date('m'); foreach ($submissions $test) { $timestamp = strtotime($test['thing']['created']); $testyear = date('y', $timestamp); $testmonth = date('m', $timestamp); if (($month >= $testmonth && $year == $testyear) || $year > $testyear) { // test passed } }

How to Generate Google C++ Unit Test XML Report for total project in vc++ -

i want generate xml file project uses google c++ testing. if project present in c:\projects\xyz\xyzunittest\xyzunittestd.exe. in case how can export gtest outputs xml file. want classes test results in 1 xml file. if add new should update results. yes got setting in environmental variables.

ruby on rails - bootstrap theme: has-error is not working with password field -

i have following code: <div id="example1" class="has-error"> <section> <label class="input"> <%= f.label :email %> <%= f.text_field :email, placeholder: "enter email"%> </label> </section> </div> <div id="example" class="has-error"> <section> <label class="input"> <%= f.label :password %> <%= f.password_field :password, placeholder: "enter password" %> </label> </section> </div> i have downloaded theme wrap bootstrap , working fine when ran above code not able see changes password field should getting using "class="has-error". it works fine "text" type not working password field. guess has theme using. not sure, saying because when working without theme above code worked fine both types "text" "password...

c# - How do I send multiple users message using a gridview with templates -

how send mltiple users message using griview should connected 2 tables namely login(from usernames retrieved , shown) , second table message (where message stored particular usernames). have connected login not able insert values message table. message table has msg_id , username , message columns. here design: .aspx </asp:content> <asp:content id="content2" contentplaceholderid="contentplaceholder2" runat="server"> <asp:gridview id="gridview2" runat="server" autogeneratecolumns="false" enablemodelvalidation="true" datasourceid="sqldatasource1" onrowcommand="gridview2_rowcommand"> <columns> <asp:boundfield datafield="username" headertext="username" sortexpression="username" /> <asp:boundfield datafield="password" headertext="password" sortexpression="password" ...

asp.net mvc - ASP:NET MVC: return file : internet explorer 11 new tab? -

ie9, chrome , firefox can open new tab code bellow, ie11 force download instead of open new tab. byte[] filebytes = system.io.file.readallbytes(contentdetailinfo.contentfilepath); response.appendheader("content-disposition", "inline; filename=" + contentdetailinfo.contentfilename); return file(filebytes, contentdetailinfo.contentfilemimetype); try response.addheader("content-disposition", "attachment;filename=\"" + contentdetailinfo.contentfilename +"\"") more: w3.org

database - how to take the url from the url and compare it to a given table in php -

<button type="button" class="btn btn-primary"> <?php echo $_get['url']; ?> </button> <?php $goturl=$_get['url']; $con=mysqli_connect("localhost","stud_user","123456","stud_db"); if (mysqli_connect_errno()){ echo "oops! ran problem!" . mysqli_connect_error(); } $result = mysqli_query($con,"select * users url='<?=$goturl;?>'"); while($row = mysqli_fetch_array($result)){ echo $row['verification_value']; } if($verification_value == 'unverified'){ $val = 'unverified'; } else { $val = 'verified'; } ?> <button type="button" class="btn btn-info"> <?php echo $val; ?> </button> <br /> <?php mysqli_close($con); ?> <hr /> hi newbie in php , m using code fetch site.php?url=website.com , u...

python - How to get all mappings between two lists? -

we have 2 lists, , b: a = ['a','b','c'] b = [1, 2] is there pythonic way build set of maps between , b containing 2^n (here 2^3=8)? is: [(a,1), (b,1), (c,1)] [(a,1), (b,1), (c,2)] [(a,1), (b,2), (c,1)] [(a,1), (b,2), (c,2)] [(a,2), (b,1), (c,1)] [(a,2), (b,1), (c,2)] [(a,2), (b,2), (c,1)] [(a,2), (b,2), (c,2)] using itertools.product , it's possible tuples: import itertools p = it.product(a, b) [p p in p] which gives: out[3]: [('a', 1), ('a', 2), ('b', 1), ('b', 2), ('c', 1), ('c', 2)] you can itertools.product , zip from itertools import product print [zip(a, item) item in product(b, repeat=len(a))] output [[('a', 1), ('b', 1), ('c', 1)], [('a', 1), ('b', 1), ('c', 2)], [('a', 1), ('b', 2), ('c', 1)], [('a', 1), ('b', 2), ('c', 2)], [('a', 2), ('b', 1), ('c...

c# - Linq query to obtain count from a List -

i trying construct linq query in c# following scenario. "given particular token "to identify count of documents in exists" private list<document> documents = new list<document>(); class document { string filename; public string filename { { return filename; } } dictionary<string, int> tokens; public dictionary<string, int> tokens { { return tokens; } } public document(string filename, dictionary<string, int> tokens) { this.filename = filename; this.tokens = tokens; } } with knowledge came expression: documents.where(d => d.tokens.keys.any(k => k == word)).count(); but not sure whether 100% correct. in need of expert advice on this. to make use of o(1) lookup time of dictionary should use containskey instead. documents.count(d => d.tokens.containskey(word));

How to access the model from the controller in zend? -

this controller class locationcontroller { ..... public function testareaction(){ $this->_helper->layout->disablelayout(); $this->_helper->viewrenderer->setnorender(true); $myarray = $_post['data_post']; $product_ids = $_post['product_ids']; echo "test1"; $model = new application_model_ordernames(); echo "test2"; $model -> saveordernames(); } } and model : <?php class ordernames { public function __construct(){ } public function saveordernames(){ return 1; } } ?> what im doing wrong ? why cannot access "test2" string in browser? thx this full controller class : <?php use application\model\cronos, application\model\dbtable; class locationcontroller extends \lunchbox\controller { public function indexaction() { if (!($locationurl = $th...

java - How to handle repeated value in jdbc while joining multiple tables -

Image
following jdbc code fetch data multiple tables public set<bill> fetch(long billno) { system.out.println(" billproductdetailsbusiness fetch()"); status = "success"; set st = new hashset(); con = connectionfactory.getconnection(); try { string query = "select distinct bpd.product_id,bpd.bill_no," + "bpd.qty, bpd.unit_price up,bpd.selling_price sp," + "bpd.discount_percent dp, " + "bd.*,cu.*,pr_dl.*, " + " colors.color,pmodeld.model_no, ptype.product_type, " + "sizes.size, pbrand.brand,suppd.name " + "from bill_product_details bpd " + "left join bill_details bd " + "on bd.bill_no=bpd.bill_no " + "left join product_details pr_dl ...

eclipse - Linked Files and Folder in IntelliJ -

Image
as previous eclipse user switched intellij able access folder external project inside ide, while developing. in eclipse using feature creating linked resources . i wonder if there feature in intellij helps me access external files , folder in similar way (for instance, if want edit configuration of application server located outside project). yes can adding new content root in module. project structure ( alt + ctrl + shift + s ) - modules - " my-module " - + add content root have contents of added folder available in project.

php - Ajax Call not returning successful but script executes -

i have ajax call made using custom callback function invoked redactor.js - ajax itsself posts data function stores information in database. know post being made , script executing because information itsself being stored correctly .success function of ajax call not completing , cannot life of me figure out why. my call in full below. 'data' not logged in console , have attempted manner of alerts etc $.ajax ({ url:'<?php echo base_url('cms/page/'.$this->type.'/create/'.$this->page_id); ?>', type:'post', datatype: 'json', data: 'content=' + $('#redactor').redactor('get')+'&status=draft&title='+ $('#title').val() +'&sub=' + $('#sub').val()+'&id=<?php echo $this->page_id;?>&tags='+$('#tags').val()+'&dynamic_save=true&post_page=true...

javascript - how to open JQuery model popup dialog over iframe? -

i using jquery ui dialog modal popups. have iframes in page well. open modal dialog iframe open within iframe. i want when model popup open user cant allow click on background link. so please let me know how can prevent user click on background area ? the iframe page within page. if use dialog in page loaded in iframe load in iframe. need add code open dialog box on main page or use parent call parent page , execute javascript code. there problem if iframe , parent page share same domain have access parent javascript if different domains iframe can not access parent javascript. work around use postmessage. need add code open dialog box in main page , use postmessage communicate between parent , iframe security restrictions of browsers. good luck.

How to tell AutoMapper not to map object graph entirely -

i have series of classes have relations each others. like: public class patient : entity { public virtual string firstname { set; get; } public virtual officebranch originalofficebranch { set; get; } } public class officebranch : entity { public virtual string title { set; get; } } and dtos: public class patientdto : basegeneraldto { public string firstname { set; get; } public officebranchdto originalofficebranch { set; get; } } public class officebranchdto : basegeneraldto { public string title { set; get; } } i have used automapper map them each other. i'm using nhibernate persisting. when updating patientdto , automapper causes changes in officebranchdto nhibernate dirty session flush occurs absolutely unwanted. what want know how can tell automapper not map object graph entirely. mean map patientdto patient not both patientdto , officebranchdto . workaround use add ignore each mapping manually like: mapper.createmap<patient...

Using PInvoke in C# with function pointer and delegate -

i'm new in c#. i have c file (and im using make dll file) : extern "c" { typedef int (__stdcall * t_fun)(int); __declspec(dllexport) int __stdcall executec(int n, t_fun f) { return f(n); } } then want use in c# code using pinvoke. public delegate int f_delegate(int n); [dllimport("executec.dll")] public static extern int executec(int n, f_delegate func); public static int funcs(int n){ return n; } static void main(string[] args) { int x = executec(13, funcs); system.console.writeline(x.tostring()); } and when start program ends immediatly. problem here? the code in question fine. can verify pasting brand new projects , discovering works well. the plausible explanations can see are: the program runs correctly , ends after starts because expected behaviour. after program prints single value , terminates. your code in fact different presented in question.

javascript - Animate CSS3 rotation onclick with prev and next -

i have circle need transform 90 degress when onclick fired on .next class , -90 degress when clicked on .prev i have managed create following code based on google myself too! $('.next').on('click',function(e){ $('.object').animate({textindent: 90}, { step: function(now,fx) { $(this).css('-webkit-transform','rotate('+now+'deg)').css('-moz-transform','rotate('+now+'deg)').css('transform','rotate('+now+'deg)'); }, duration:2000 },'linear'); }); $('.prev').on('click',function(e){ $('.object').animate({textindent: 0}, { step: function(now,fx) { $(this).css('-webkit-transform','rotate('+now+'deg)').css('-moz-transform','rotate('+now+'deg)').css('transform','rotate('+now+...

angularjs - the diffrence between angular.foreach and "for" -

i tried todo example in angular home page (no.2) , modified little code cause wired problem. when add 2 todo, dispaly ok displayed “4 of 4 remain [archive]”,then select 2 todo item , click "acrhive". result should “2 of 2 remain [archive]", acctually display “2 of 4 remain [archive]". replace ”for“ loop wiht "angular.foreach" function, result correct. can explain diffrence when use between "for loop" , "angular.foreach"? coding shown belowing: <html> <head> <meta charset="utf8"> <script src="js/angular.js"></script> </head> <body ng-app ng-controller="todo"> <span>{{remains()}} of {{total}} remain</span><span>[<a href="javascript:void(0)" ng-click="archive()">archive</a>]</span> <ul> <li ng-repeat="todo in todos"> <input type="checkbox" ng-model...

c - What does the macro _bnd(X,bnd) mean? -

recently read implement own printf use macro _bnd(x,bnd),but don't understand mean of macro. #define _bnd(x, bnd) (sizeof(x) + (bnd) & ~(bnd)) i know bitwise operator , sizeof() it's internal implementation magic, playing implementation-dependent properties of addresses of arguments variable-argument functions. unless need know means, best stay away it. otherwise may tempt rely on it. and macro should be #define _bnd(x, bnd) (sizeof(x) + (bnd) & ~(bnd)) ^ check in post also can know expanding basic arrithmetic operation.for should know sizeof() , tilde operator , bitwise operatior .

sql - Strange better mysql query perfomance on bigger schema -

Image
i have strange problem query , mysql innodb schema on server.. that query has high query time (about 1,6 - 2 seconds), , db empty. in order verify performance on bigger data set have cloned db, , populated thousand more rows. strange thing query take less time before (0,5 seconds). using explain command on both query gives same results. i have no idea, can see metric or difference between db?? edit: i try dump ddl of both schema: mysqldump -u user -ppwd -h ***** -d myschema > myschemaddl.sql then have ran diff command 2 dump , result: there no difference.. this example of result: edit 2: screenshot of explain extended result. results equals both db.. databases have storage issues similiar hard drive fragmentation. after lot of inserts , deletes data stored in suboptimal format. if clone backup new database created in 1 batch operation optimized internal storage. in case mysqldump return same information. you may: use mysql optimize table c...

height of element not updated after angularjs updates dom until I interact with page -

i'm learning angularjs apologies if don't explain well. i have unordered list populated array using ng-repeat . list contents can changed selecting different category select box. when list scrolled down, further populated using infinite-scroll type arrangement. the problem is, after array changed selecting different category, result of elem.height() (where elem refers <ul> ) still reflects height of <ul> before updated. when scroll page down, result of elem.height() updated correct value, not before infinite-scroll code has seen old incorrect value , made undesired http request. i'm hoping enough information describe problem. there way of forcing elem.height() updated after angularjs has modified dom?

java - Number verification - if it is number, eponential values, it should pass otherwise it should fail -

i using ^[-+]?[0-9]*\\.?[0-9]+([ee][-+]?[0-9]+)?$ regular expression, working fine cases. values 123e104 failing validate. i guess 123e104 not exponential value. since 123e104 invalid exponential value. result should false or not match 123e+104 common way javascript , languages denote string representation of large exponent.

radio button - Change radiobutton multiple times using jQuery -

i can't seem change between radio buttons correctly using jquery. bug in jquery? example here: http://jsbin.com/yafik/1/edit code jsbin: <input type="radio" name="test"> <input type="radio" name="test"> <input type="radio" name="test"> <input type="radio" name="test"> <script> $("input").eq(1).attr("checked", true); $("input").eq(2).attr("checked", true); //$("input").attr("checked", false); $("input").eq(1).attr("checked", true); </script> you can try uncomment third line: $("input").attr("checked", false); , i'd expect reset checked attributes. i expect set second radiobutton checked. if @ source code, both second , third radiobuttons checked. use .prop() boolean values $("input").eq(1).prop("checked", t...

common lisp - defclass type information for performance -

in following program, removing line (declare (type (simple-array bit) arr)) makes running time increase more factor of 3, using sbcl. type information given in defclass macro via :type on other hand appears have no impact on performance. (defclass class-1 () ((arr :type (simple-array bit)))) (defun sample (inst) (declare (type class-1 inst)) (let ((arr (slot-value inst 'arr))) (declare (type (simple-array bit) arr)) ;; 3x running time without (map-into arr #'(lambda (dummy) (if (< (random 1.0) 0.5) 0 1)) arr))) (let ((inst (make-instance 'class-1))) (setf (slot-value inst 'arr) (make-array 10000 :element-type 'bit)) (loop 1 10000 (sample inst))) how can have same performance benefit without having declare arr slot simple-array bit each time use it? latter particularly annoying since (as far have found out) requires introduce binding via let or similar each time; cannot write (slot-value inst 'arr) in place need it. ...

XCode stops when connect to BLE device -

Image
i new ios development, , study bluetooth low energy (ble, bluetooth 4.0) ios. when click ble device on tableview have scan. if didn't use xcode run project on iphone 5c , can connect ble device , change other viewcontroller . but stop following picture when run project on iphone xcode . could teach me why happened ? and how debug condition ? i new ios , so...sorry question if there has stupid. in advance you put breakpoint. click on "blue arrow" (near green light).

Where to put Groovy bean definitions in a Spring Boot webapp? -

using spring boot can jar created webapp (allowing me execute java -jar test-0.1.0.jar want). configure spring beans using groovy bean def syntax, separate file beans.groovy contain definitions. how can have groovy file included in jar , how can tell spring load it? i've seen few examples around web showing how define beans way spring boot, none explain how groovy file included in jar , run webapp. springapplication accepts resource paths sources, include string ending in ".groovy", e.g. public static main(string args[]) { springapplication.run("classpath:beans.groovy", args); }

matlab what is code segment calculating? -

i have being trying figure out matlab code doing. takes 3 data points x , corresponding y values: x ,y and fit: fy = polyfit(x, y, 2) which second order fit of 3 x, y data points. then followed line of code: u = -fy(2) / (2*fy(1)) this seems calculate x value in range between x(1) , x(3) i'm not sure calculating? why multiplying fy(1) value 2? fy(1) coefficient of x^2 term, , fy(2) coefficient x term. 2* makes me think derivative, let's see looks like. first original quadratic fit: fy(1)*x^2 + fy(2)*x + fy(3) now derivative: 2*fy(1)*x + fy(2) ahah, starting familiar. setting equal 0 , solving x? 2*fy(1)*x + fy(2) = 0 2*fy(1)*x = -fy(2) x = -fy(2) / (2*fy(1)) yep, that's it. it's computing x location derivative of quadratic fit equals zero. , happens @ place first derivative of curve equals zero? maximum or minimum. so, code finds x coordinate of max or min of quadratic fit of data. accurate peak finder?

c++ - Methods belonging to multiple classes -

i making small project extension of larger body of work. part of larger project there class contains number of methods. use of these methods methods in new class feel there must better way duplicating code different class name! there way make method belong multiple classes (i should mention of c++)! cheers, jack there speaking 2 possibilities: inheritance: if new class (b) , class you're interested in (a) represent is a relationship. composition: add class you're interested in (a) field in new class (b). can use methods. if class has more methods need, violates single responsibility principle , , should split it. if b have methods same name a, consider introducing interface methods common both classes (in general this+composition seems better solution inheritance).

c# - Child in recursive data table -

i have following table pnlparentid id operator 12 13 * 12 14 * 12 15 * 12 1 - 12 2 - 13 21 / 13 20 / i want tree of ids each different operator how can change following code ? working on hours , appreciated . var q= p in typeddatatable p.parentid == null // parents select new { parentid = p.parentid, child = c in typeddatatable c.parentid == p.id select new {childid=c.id, parentid = c.parentid} }; i prefer use class storing data (which may have auto-generated if used linq sql): class typeditem { public int id {get;set;} public int parentid {get;set;} public list<typeditem> children {get;set;} public typeditem() { children = new list<typeditem>(); } } then create ...

java - org.hibernate.hql.ast.QuerySyntaxException -

i getting exception:org.hibernate.hql.ast.querysyntaxexception: unexpected end of subtree when excute below query : <query name="fetchcspecificationbyattidextid"> <![cdata[from > cproductspecifications attributeid=:attributeid , > extractedproductid in (:extractedlist)]]> </query> detailed stack trace is: org.hibernate.hql.ast.querysyntaxexception: unexpected end of subtree [ com.bemol.dao.product.cproductspecifications attributeid=:attributeid , extractedproductid in () ] service method calls query : list<cproductspecifications> cspeclist=(list<cproductspecifications>)this.basedao.findbynamedqueryandnamedparam("fetchcspecificationbyattidextid", new string[]{"attributeid","extractedlist"},new object[]{aid,extractedlist}); perhaps extractedlist empty? try empty check first.

C# calculate decimal -

i want calculate price doing simple sum. example: float hourpay = 18.30 int minutesworked = 125 minutesworked \ 60 * hourpay = 38,124999999 i got these values in c# function , running 2 problems: private decimal calculateprice(int minutes) { float test = minutes / 60 * setting.hourpay return; } the problems are, test returns 36.6 not correct , rounded off 1 decimal. i want correct answer parses decimal , rounds 2 decimals. the problem starting dividing 2 integers, results in integer: float test = minutes / 60; note test get's 2 , because decimals cut off if 2 integers divided. calculation right: 2 * 18.3 = 36.6 test should 2.083... . solution cast integers floats first: private decimal calculateprice(int minutes) { float test = (float)minutes / 60.0f * setting.hourpay; return; } then division not ignore decimals , result exprected. can leave out explicit cast of minutes : float test = minutes / 60.0f * setting.hourpay; this...

Right align bars JQPlot -

i have produced following graph using jqplot, reason bars start in middle of xaxis. i need move them right, i've looked @ docs , couldn't work out. suggestions? $(document).ready(function(){ var ok_before = [4, 3, 1, 0]; var ok_bars = [3, 4, 5, 4]; var ok_after = [1, 1, 2, 4]; var err_before = [5, 0, 2, 0]; var err_bars = [1, 0, 2, 0]; var err_after = [2, 8, 4, 8]; var dateticks = [['2014-01-01' ], ['2014-01-02' ], ['2014-01-03' ], ['2014-01-04' ], ['2014-01-05'], ['2014-01-06'], ['2014-01-07'], ['2014-01-08']]; var xaxis2ticks = ['we', 'th', 'fr', 'sa', 'su', 'mo', 'tu', 'we'] var yvals = ['wo1028', 'wo1026', 'wo1025', 'wo1024']; plot1 = $.jqplot('chart3', [ok_before, ok_bars, ok_after], { animate: true, animatereplot: true, series:{ ...

ios - How to use the Toolbar with UIKeyboard in table view cell -

i have issue [uitextview(toolbar) addkeyboardtoolbar] , in tableview:cellforrowatindexpath added method [cell.textview addkeyboardtoolbar]; i got issue in crashly like crashed: com.apple.main-thread exc_bad_access kern_invalid_address @ 0x00000008 this code below. can please me on thankz in advance. - (void)addkeyboardtoolbar { uitoolbar *toolbar = [[uitoolbar alloc] initwithframe:cgrectmake(0.0f, 0.0f, self.bounds.size.width, 44.0f)]; [toolbar setbarstyle:uibarstyleblack]; [toolbar settranslucent:yes]; // toolbar.items=[nsarray arraywithobjects: [[uibarbuttonitem alloc]initwithtitle:@"spacer" style:uibarbuttonitemstylebordered target:self action:nil], // [[uibarbuttonitem alloc]initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:nil action:nil], // [[uibarbuttonitem alloc]initwithtitle:@"done" style:uibarbuttonitemstyledone target:self action:@selector(hidekeyboard)], // ...

php - Searching multiple values in sql table, with a range -

i have table contains ingredients. example: id | title | ingredients 1 | ex1 | ketchup, chicken, salt, honey, mountain dew 2 | ex2 | beef, pepper, chili, honey, salt and when user searchs ingredients like: ketchup, salt, honey i generate sql-query: select * recipes where( (ingredients '%ketchup%') , (ingredients '%salt%') , (ingredients '%honey%') and returns recipes containing these specific ingredients, , works grey. now. i've added range-slider, pick how many of entered ingredients should match search return anything. lets chose 2 ingredients should match @ least, want make php function outputs sql string pairs of entered ingredients, don't have mindset it. example: (ingredients '%ketchup%') , (ingredients '%salt%') or (ingredients '%ketchup%') , (ingredients '%honey%') or on. ketchup & salt pair, ketchup & honey pair, salt & honey pair. and of course variable ther...

c# - datacontractserializer deserialize list<> always empty -

i'm deserializing data received web-service. the problem deserialization of list returns empty list , no exception generated. can me figure out why? have tried several possible syntax. code below closest correct solution cannot deserialize correctly list of classes. <arrayofbatch xmlns="http://schemas.datacontract.org/2004/07/myns" xmlns:i="http://www.w3.org/2001/xmlschema-instance"> <maasbatch> <batchname>all users</batchname> <users> <maasusers> <firstname>bob</firstname> <lastname>thetest</lastname> <sourceemail>bob@source.com</sourceemail> <sourcetenantid>111</sourcetenantid> <targetemail>bob@target.com</targetemail> <targettenantid>222</targettenantid> </maasusers> </users> </maasbatch> </arrayofbatch> code: list<maasbatch> lstmaasbatches = null; try { ...

java - How to increment time every second in Libgdx -

i try add time game increment every second. how fix that? i add code below float timer; timer += delta; if(timer<=delta+1000)//every 1 sec { time = time+1; timepoint.setsentence(""+time/100); timer = 0f; } as note, delta gdx.graphics.getdeltatime(). 'time' string. looks time increment slowly. means when time run 1,5 sec, 'time' still increase 1. divide 100 because if not increase more faster/sec, i use timeutils class libgdx produced similar result. thanks before. this should work. note time/100 results in 0 0-99 , 1 100-199. that's not effect wanted. float timer; timer += delta; if (timer >= 1) { time++; timepoint.setsentence(""+time); timer -= 1; } the problem set timer 0. if 1.1f example (because last delta 0.1f), lose 100ms. don't reset timer 0f, decrease 1f instead.

if statement - How to write this nested IF function in Excel -

i trying write following function in excel. if p2 greater or equal 3 , ad2 0 or if p2 greater or equal 2 , ad2 greater or equal 1 or if p2 greater or equal 1 , ad2 2 then following: (h2+v2)/(p2+ad2),-999) i have had go @ writing following no avail. =if(and(p2>=3,ad2>=0),or(and(p2>=2,ad2>=1)),or(and(p2>=1,ad2>=2)),(h2+v2)/(p2+ad2),-999) any pointers in right direction appreciated novice @ excel functions. many thanks, ash erm... i think right: =if(or(and(p2>=3,ad2=0),and(p2>=2,ad2>=1),and(p2>=1,ad2=2)),(h2+v2)/(p2+ad2),-999) you need nest different and conditions within or function... easiest way it, have seperate functions in cell each , build step @ time, until you're sure it's right.. can paste function 1 cell if required. say below in cells a1 , a2 , a3 =and(p2>=3,ad2=0) =and(p2>=2,ad2>=1) =and(p2>=1,ad2=2) then total formula in cell: =if(or(a1,a2,a3),(h2+v2)/(p2+ad2),-999)