Search Results

Search found 5176 results on 208 pages for 'max fraser'.

Page 85/208 | < Previous Page | 81 82 83 84 85 86 87 88 89 90 91 92  | Next Page >

  • Adding up fractions in PHP

    - by Gamemorize
    I would like to create a loop that keeps adding a set fraction, here in my example 1/3, and which later I can check against for matches with integer values. Obviously when php adds 1/3 + 1/3 + 1/3 the result is 0.9999999, so i thought I could use the occasional round to help me, but this isn't working either. The idea that I had would be that .333 + .333 becomes .666 and that if rounded that would become .667, then + .333 and the result is 1. However round only seems to work, for me, if the number of digits actually decreases. so round (0.666, 3) remains 0.666 <?php $denom = 3; $frac = 1/$denom; $frac = round($frac,3); $value = 0; $max =24; for($f = 1; $f <= $max; $f++){ echo "old value is now at ".$value.".<br/>"; $value = $value+$frac; echo "value is now at ".$value.".<br/>"; $value = round($value,3); echo "rounded value is now at ".$value.".<br/>"; $valueArray[$f] = $value; //and here for ease of testing.... if (($value==1)OR ($value==2)OR ($value==3)OR ($value==4)OR ($value==5)OR ($value==6)OR ($value==7)OR ($value==8)){ echo "match!<br/>"; }else{ echo "no match!<br/>"; } } ?> Am I going about this in a totally stupid way? Accuracy when the value is not an integer is not needed, just that it can == with integers.

    Read the article

  • C++: defining maximum/minimum limits for a class

    - by Luis
    Basically what the title says... I have created a class that models time slots in a variable-granularity daily schedule (where for example the first time slot is 30 minutes, but the second time slot can be 40 minutes); the first available slot starts at (a value comparable to) 1. What I want to do now is to define somehow the maximum and minimum allowable values that this class takes and I have two practical questions in order to do so: 1.- does it make sense to define absolute minimum and maximum in such a way for a custom class? Or better, does it suffice that a value always compares as lower-than any other possible value of the type, given the class's defined relational operators, to be defined the min? (and analogusly for the max) 2.- assuming the previous question has an answer modeled after "yes" (or "yes but ..."), how do I define such max/min? I know that there is std::numeric_limits<> but from what I read it is intended for "numeric types". Do I interpret that as meaning "represented as a number" or can I make a broader assumption like "represented with numbers" or "having a correspondence to integers"? After all, it would make sense to define the minimum and maximum for a date class, and maybe for a dictionary class, but numeric_limits may not be intended for those uses (I don't have much experience with it). Plus, numeric_limits has a lot of extra members and information that I don't know what to make with. If I don't use numeric_limits, what other well-known / widely-used mechanism does C++ offer to indicate the available range of values for a class?

    Read the article

  • php while loop throwing a error over a $var < 10 statement

    - by William
    Okay, so for some reason this is giving me a error as seen here: http://prime.programming-designs.com/test_forum/viewboard.php?board=0 However if I take away the '&& $cur_row < 10' it works fine. Why is the '&& $cur_row < 10' causing me a problem? $sql_result = mysql_query("SELECT post, name, trip, Thread FROM (SELECT MIN(ID) AS min_id, MAX(ID) AS max_id, MAX(Date) AS max_date FROM test_posts GROUP BY Thread ) t_min_max INNER JOIN test_posts ON test_posts.ID = t_min_max.min_id WHERE Board=".$board." ORDER BY max_date DESC", $db); $num_rows = mysql_num_rows($sql_result); $cur_row = 0; while($row = mysql_fetch_row($sql_result) && $cur_row < 10) { $sql_max_post_query = mysql_query("SELECT ID FROM test_posts WHERE Thread=".$row[3].""); $post_num = mysql_num_rows($sql_max_post_query); $post_num--; $cur_row++; echo''.$cur_row.'<br/>'; echo'<div class="postbox"><h4>'.$row[1].'['.$row[2].']</h4><hr />' .$row[0]. '<br /><hr />[<a href="http://prime.programming-designs.com/test_forum/viewthread.php?thread='.$row[3].'">Reply</a>] '.$post_num.' posts omitted.</div>'; }

    Read the article

  • My UL child label elements disappear in IE on accordion menu opening

    - by Scott B
    I've got an app that's working pretty flawlessly in Chrome and FF, however, when I view it in IE, all is well until I click on a header element to activate it (jQuery accordion). What happens then is that I see a brief flash where the content is there, then suddenly the entire left column disappears. This column is generated by a floated label element with a class of ".left" as seen below... <ul class="menu collapsible"> <li class='expand sectionTitle'><a href='#'>General Settings</a> <ul class='acitem'> <li class="section"> <label class="left">This item if floated left with a defined width of 190px via css. This is the item that's disappearing after a brief display</label> <input class="input" value="input element here" /> <label class="description">This element has a margin-left:212px; set via css in order to be positioned to the right of the label element as if in an adjacent table cell. When I add a max-width property to this element, it disappears in IE too!</label> </li> </ul> </li> </ul> As you can see from the comments in the code above (for the two label elements) the description label disappears once I set a max-width on it. It shows up fine otherwise.

    Read the article

  • Random syntactical error in my php code that I can't find

    - by user348538
    Ordinarily I hate coming here with newbie code questions but nobody can find the error with this code. Maybe you guys can :-) <?php defined('SYSPATH') or die('No direct script access.'); /** * to interact with photos * * @author Max Padraig Wolfgang Bucknell-Leahy */ class Model_Photos { private $apiKey = '12664498208a1380fe49fb1b5a238ef0'; private $secret = '03d43dee65a34513'; private $perms = 'read'; private $sigString = 'test'; private $apiSig = md5($_sigString); private $authArray = array('api_key' => $apiKey, 'perms' => $perms, 'api_sig' => $apiSig); private $authArrayImploded = implode('&', $authArray); private $authLink = 'http://www.flickr.com/services/auth/?' . $authArrayImploded; public function get_photos($number = 5) { if(file_exists(APPPATH . 'cache/main_cache.xml') { echo $authLink; } else { echo 'not so good'; /** */ } } } $class = new Model_Photos; $class->get_photos; the error is: Parse error: syntax error, unexpected '(', expecting ',' or ';' in /home/p14s9nnd/public_html/testing.php on line 15 Thank you in advance and sorry Regards, Max

    Read the article

  • How to test a Grails Service that utilizes a criteria query (with spock)?

    - by user569825
    I am trying to test a simple service method. That method mainly just returns the results of a criteria query for which I want to test if it returns the one result or not (depending on what is queried for). The problem is, that I am unaware of how to right the corresponding test correctly. I am trying to accomplish it via spock, but doing the same with any other way of testing also fails. Can one tell me how to amend the test in order to make it work for the task at hand? (BTW I'd like to keep it a unit test, if possible.) The EventService Method public HashSet<Event> listEventsForDate(Date date, int offset, int max) { date.clearTime() def c = Event.createCriteria() def results = c { and { le("startDate", date+1) // starts tonight at midnight or prior? ge("endDate", date) // ends today or later? } maxResults(max) order("startDate", "desc") } return results } The Spock Specification package myapp import grails.plugin.spock.* import spock.lang.* class EventServiceSpec extends Specification { def event def eventService = new EventService() def setup() { event = new Event() event.publisher = Mock(User) event.title = 'et' event.urlTitle = 'ut' event.details = 'details' event.location = 'location' event.startDate = new Date(2010,11,20, 9, 0) event.endDate = new Date(2011, 3, 7,18, 0) } def "list the Events of a specific date"() { given: "An event ranging over multiple days" when: "I look up a date for its respective events" def results = eventService.listEventsForDate(searchDate, 0, 100) then: "The event is found or not - depending on the requested date" numberOfResults == results.size() where: searchDate | numberOfResults new Date(2010,10,19) | 0 // one day before startDate new Date(2010,10,20) | 1 // at startDate new Date(2010,10,21) | 1 // one day after startDate new Date(2011, 1, 1) | 1 // someday during the event range new Date(2011, 3, 6) | 1 // one day before endDate new Date(2011, 3, 7) | 1 // at endDate new Date(2011, 3, 8) | 0 // one day after endDate } } The Error groovy.lang.MissingMethodException: No signature of method: static myapp.Event.createCriteria() is applicable for argument types: () values: [] at myapp.EventService.listEventsForDate(EventService.groovy:47) at myapp.EventServiceSpec.list the Events of a specific date(EventServiceSpec.groovy:29)

    Read the article

  • Interesting Scala typing solution, doesn't work in 2.7.7?

    - by djc
    I'm trying to build some image algebra code that can work with images (basically a linear pixel buffer + dimensions) that have different types for the pixel. To get this to work, I've defined a parametrized Pixel trait with a few methods that should be able to get used with any Pixel subclass. (For now, I'm only interested in operations that work on the same Pixel type.) Here it is: trait Pixel[T <: Pixel[T]] { def mul(v: Double): T def max(v: T): T def div(v: Double): T def div(v: T): T } Now I define a single Pixel type that has storage based on three doubles (basically RGB 0.0-1.0), I've called it TripleDoublePixel: class TripleDoublePixel(v: Array[Double]) extends Pixel[TripleDoublePixel] { var data: Array[Double] = v def this() = this(Array(0.0, 0.0, 0.0)) def toString(): String = { "(" + data(0) + ", " + data(1) + ", " + data(2) + ")" } def increment(v: TripleDoublePixel) { data(0) += v.data(0) data(1) += v.data(1) data(2) += v.data(2) } def mul(v: Double): TripleDoublePixel = { new TripleDoublePixel(data.map(x => x * v)) } def div(v: Double): TripleDoublePixel = { new TripleDoublePixel(data.map(x => x / v)) } def div(v: TripleDoublePixel): TripleDoublePixel = { var tmp = new Array[Double](3) tmp(0) = data(0) / v.data(0) tmp(1) = data(1) / v.data(1) tmp(2) = data(2) / v.data(2) new TripleDoublePixel(tmp) } def max(v: TripleDoublePixel): TripleDoublePixel = { val lv = data(0) * data(0) + data(1) * data(1) + data(2) * data(2) val vv = v.data(0) * v.data(0) + v.data(1) * v.data(1) + v.data(2) * v.data(2) if (lv > vv) (this) else v } } Now I want to write code to use this, that doesn't have to know what type the pixels are. For example: def idiv[T](a: Image[T], b: Image[T]) { for (i <- 0 until a.data.size) { a.data(i) = a.data(i).div(b.data(i)) } } Unfortunately, this doesn't compile: (fragment of lindet-gen.scala):145: error: value div is not a member of T a.data(i) = a.data(i).div(b.data(i)) I was told in #scala that this worked for someone else, but that was on 2.8. I've tried to get 2.8-rc1 going, but it doesn't compile for me. Is there any way to get this to work in 2.7.7?

    Read the article

  • Extending a form field to add new validations.

    - by duallain
    I've written an app that uses forms to collect information that is then sent in an email. Many of these forms have a filefield used to attach files to the email. I'd like to validate two things, the size of the file (to ensure the emails are accepted by our mail server. I'd also like to check the file extension, to discourage attaching file types not useable for our users. (This is the python class I'm trying to extend) class FileField(Field): widget = FileInput default_error_messages = { 'invalid': _(u"No file was submitted. Check the encoding type on the form."), 'missing': _(u"No file was submitted."), 'empty': _(u"The submitted file is empty."), 'max_length': _(u'Ensure this filename has at most %(max)d characters (it has %(length)d).'), } def __init__(self, *args, **kwargs): self.max_length = kwargs.pop('max_length', None) super(FileField, self).__init__(*args, **kwargs) def clean(self, data, initial=None): super(FileField, self).clean(initial or data) if not self.required and data in EMPTY_VALUES: return None elif not data and initial: return initial # UploadedFile objects should have name and size attributes. try: file_name = data.name file_size = data.size except AttributeError: raise ValidationError(self.error_messages['invalid']) if self.max_length is not None and len(file_name) > self.max_length: error_values = {'max': self.max_length, 'length': len(file_name)} raise ValidationError(self.error_messages['max_length'] % error_values) if not file_name: raise ValidationError(self.error_messages['invalid']) if not file_size: raise ValidationError(self.error_messages['empty']) return data

    Read the article

  • jquery accessing dynamic class selectors

    - by dinotom
    Given the following html rendering; <fieldset id="fld_Rye"> <legend>7 Main St.</legend> <div> <table> <tr> <th class="wideCol"><b><i>Service Description</i></b></th> <th class="wideCol"><b><i>Service Name</i></b></th> <th class="normalPlusWidth"><b><i>Contact Name</i></b></th> </tr> <ItemTemplate> <tr class=""> <td class="servDesc">&nbsp;<b>Plumbing Services</b></td> <td class="servName">&nbsp;<b>Flynnsters's Plumbing</b></td> <td class="servContact">&nbsp;<b>Jim Flynnster</b></td> </tr> </ItemTemplate> I am trying to access all the td's with a class of servDesc, get their width into an array and get the max width from that array to reset the css width of that class using jquery on page load. I cant seem to get the right selector for those tags, and I've tried at least 50 variations. My latest try; var maxTdWidth; var servDescCols = []; $("#fld_Rye td#servDesc").each(function () { alert("found one"); servDescCols.push(this.width()); }); maxTdWidth = Math.max.apply(Math, servDescCols);

    Read the article

  • Android: Find coordinates of a certain point X meters from my location moving towards the point I am

    - by Aidan
    Hi Guys, I'm constructing a geolocation based application and I'm trying to figure out a way to make my application realise when a user is facing the direction of the given location (a particular long / lat co-ord). I've done some Googling and checked the SDK but can't really find anything for such a thing. Does anyone know of a way? Example. Point A = Phones current location. Point B = A's orientation in relation to true north + 45 + max distance towards the direction your facing, Point C = A's orientation in relation to true north - 45 + max distance towards the direction your facing. So now you have a triangle constructed. pretty schweet huh? yeah.. I think so.. So now that I have my fancy Triangle I use something called Barycentric Coordinates ( http://en.wikipedia.org/wiki/Barycentric_coordinates_(mathematics) ). This will allow me to test another point and see if it is in the triangle. If it is, it means we're facing it AND it's within the right distance. So it should be displayed on screen. If I'm facing 90 degrees from true north. The distance it travels should be that direction. 90 degrees from true north. It should not be 100 degrees or something from true north! But the problem is I haven't yet figured out how I make the device realise it must go "out" the direction it is facing.

    Read the article

  • Extra space in Opera

    - by HiveHicks
    I'm trying to put a progress bar inside td of my table. Here's the code: <td style="width: 150px; max-height: 16px;"> <div style="height: 16px; max-height: 16px; overflow: hidden; border: 1px solid #80C622;"> <div style="height: 16px; width: 10%; background-color: #bbea7d;"></div> <div style="margin-top: -16px; text-align: center;"> 1470/14166 </div> </div> </td> Chrome, Firefox, Safari and (!) IE displays it correctly, whereas Opera extends the row so there is some extra space above. Here's how it's supposed to look like: http://ipicture.ru/uploads/100616/16el6B3lB1.png Here's how it looks in Opera: http://ipicture.ru/uploads/100616/fE4Ad63N1l.png

    Read the article

  • Absolute Centering Not Working in IE

    - by Vikas Ghodke
    I have a div which is centered in parent div, it working on all browser but not in ie, can you help me out with this. JSFIDDLE span.qbg3 { display: block; text-align: center; background: url(http://powerblanket.com/may2014/wp-content/uploads/2014/05/qbg3.png) no-repeat center center; background-size:cover; padding: 50px 20px; color: #fff; font-weight: 400; font-size: 30px; position: relative; margin-top: -20px; min-height: 350px; } span.inqbg3 { max-height: 100px; display: block; text-align: center; color: #fff; font-weight: 400; font-size: 40px; position: absolute; margin: auto; top: 0px; right: 0; left: 0; bottom: 0px; background: rgba(0, 0, 0, 0.5); max-width: 700px; padding: 35px 0; } span.inqbg3 a { color: #fff; }

    Read the article

  • adding elements in to the doubly linked list

    - by user329820
    Hi this is my code for main class and doubly linked class and node class but when I run the program ,in the concole will show this"datastructureproject.DoublyLinkedList@19ee1ac" instead of the random numbers .please help me thanks! main class: public class Main { public static int getRandomNumber(double min, double max) { Random random = new Random(); return (int) (random.nextDouble() * (max - min) + min); } public static void main(String[] args) { int j; int i = 0; i = getRandomNumber(10, 10000); DoublyLinkedList listOne = new DoublyLinkedList(); for (j = 0; j <= i / 2; j++) { listOne.add(getRandomNumber(10, 10000)); } System.out.println(listOne); } } doubly linked list class: public class DoublyLinkedList { private Node head ; private Node tail; private long size = 0; public DoublyLinkedList() { head= new Node(0, null, null); tail = new Node(0, head, null); } public void add(int i){ head.setValue(i); Node newNode = new Node(); head.setNext(newNode); newNode.setPrev(head); newNode = head; } } and the node class is like the class that you have seen before (Node prev,Node next,int value)

    Read the article

  • Better code for accessing fields in a matlab structure array?

    - by John
    I have a matlab structure array Modles1 of size (1x180) that has fields a, b, c, ..., z. I want to understand how many distinct values there are in each of the fields. i.e. max(grp2idx([foo(:).a])) The above works if the field a is a double. {foo(:).a} needs to be used in the case where the field a is a string/char. Here's my current code for doing this. I hate having to use the eval, and what is essentially a switch statement. Is there a better way? names = fieldnames(Models1); for ix = 1 : numel(names) className = eval(['class(Models1(1).',names{ix},')']); if strcmp('double', className) || strcmp('logical',className) eval([' values = [Models1(:).',names{ix},'];']); elseif strcmp('char', className) eval([' values = {Models1(:).',names{ix},'};']); else disp(['Unrecognized class: ', className]); end % this line requires the statistics toolbox. [g, gn, gl] = grp2idx(values); fprintf('%30s : %4d\n',names{ix},max(g)); end

    Read the article

  • Question on SQL Grouping

    - by Lijo
    Hi Team, I am trying to achieve the following without using sub query. For a funding, I would like to select the latest Letter created date and the ‘earliest worklist created since letter created’ date for a funding. FundingId Leter (1, 1/1/2009 )(1, 5/5/2009) (1, 8/8/2009) (2, 3/3/2009) FundingId WorkList (1, 5/5/2009 ) (1, 9/9/2009) (1, 10/10/2009) (2, 2/2/2009) Expected Result - FundingId Leter WorkList (1, 8/8/2009, 9/9/2009) I wrote a query as follows. It has a bug. It will omit those FundingId for which the minimum WorkList date is less than latest Letter date (even though it has another worklist with greater than letter created date). CREATE TABLE #Funding( [Funding_ID] [int] IDENTITY(1,1) NOT NULL, [Funding_No] [int] NOT NULL, CONSTRAINT [PK_Center_Center_ID] PRIMARY KEY NONCLUSTERED ([Funding_ID] ASC) ) ON [PRIMARY] CREATE TABLE #Letter( [Letter_ID] [int] IDENTITY(1,1) NOT NULL, [Funding_ID] [int] NOT NULL, [CreatedDt] [SMALLDATETIME], CONSTRAINT [PK_Letter_Letter_ID] PRIMARY KEY NONCLUSTERED ([Letter_ID] ASC) ) ON [PRIMARY] CREATE TABLE #WorkList( [WorkList_ID] [int] IDENTITY(1,1) NOT NULL, [Funding_ID] [int] NOT NULL, [CreatedDt] [SMALLDATETIME], CONSTRAINT [PK_WorkList_WorkList_ID] PRIMARY KEY NONCLUSTERED ([WorkList_ID] ASC) ) ON [PRIMARY] SELECT F.Funding_ID, Funding_No, MAX (L.CreatedDt), MIN(W.CreatedDt) FROM #Funding F INNER JOIN #Letter L ON L.Funding_ID = F.Funding_ID LEFT OUTER JOIN #WorkList W ON W.Funding_ID = F.Funding_ID GROUP BY F.Funding_ID,Funding_No HAVING MIN(W.CreatedDt) MAX (L.CreatedDt) How can I write a correct query without using subquery? Please help Thanks Lijo

    Read the article

  • Finding and marking the largest of three values in a two dimensional array

    - by DavidYell
    I am working on a display screen for our office, and I can't seem to think of a good way to find the largest numerical value in a set of data in a two dimensional array. I've looked at using max() and also asort() but they don't seem to cope with a two dimensional array. I'm returning my data through our mysql class, so the rows are returned in a two dimensional array. Array( [0] => Array( [am] => 12, [sales] => 981), [1] => Array( [am] => 43, [sales] => 1012), [2] => Array( [am] => 17, [sales] => 876) ) I need to output a class when foreaching the data in my table for the AM with the highest sales value. Short of comparing them all in if statements. I have tried to get max() on the array, but it returns an array, as it's look within the dimension. When pointing it at a specific dimension it returns the key not the value. I figured that I could asort() the array and pop the top value off, store it in a variable and then compare against that in my foreach() loop, but that seems to have trouble sorting across two dimensions. Lastly, I figured that I could foreach() the values, comparing them against the previous one each time, untill I found the largest. This approach however means storing every value, luckily only three, but then comparing against them all again. Surely there must be a simpler way to achieve this, short of converting it into a single dimension array, then doing an asort() on that?

    Read the article

  • Test for `point` within an attachment in `mail-mode`

    - by lawlist
    I'm looking for a better test to determine when point is within a hidden attachment in mail-mode (which is used by wl-draft-mode). The attachments are mostly hidden and look like this: --[[application/xls Content-Disposition: attachment; filename="hello-world.xls"][base64]] The test of invisible-p yields a result of nil. I am current using the following test, but it seems rather poor: (save-excursion (goto-char (point-max)) (goto-char (previous-char-property-change (point))) (goto-char (previous-char-property-change (point))) (re-search-backward "]]" (point-at-bol) t))) Any suggestions would be greatly appreciated. Here is the full snippet: (goto-char (point-max)) (cond ((= (save-excursion (abs (skip-chars-backward "\n\t"))) 0) (insert "\n\n")) ((and (= (save-excursion (abs (skip-chars-backward "\n\t"))) 1) (not (save-excursion (goto-char (previous-char-property-change (point))) (goto-char (previous-char-property-change (point))) (re-search-backward "]]" (point-at-bol) t)))) (insert "\n"))) GOAL:  If there are no attachments and no new lines at the end of the buffer, then insert \n\n and then insert the attachment thereafter. If there is just one new line at the end of the buffer, then insert \n and then insert the attachment thereafter. If there is an attachment at the end of the buffer, then do not insert any new lines.

    Read the article

  • Is there a way to prevent SQL Server silently truncating data in local variables and stored procedure parameters?

    - by Luke Woodward
    I recently encountered an issue while porting an app to SQL Server. It turned out that this issue was caused by a stored procedure parameter being declared too short for the data being passed to it: the parameter was declared as VARCHAR(100) but in one case was being passed more than 100 characters of data. What surprised me was that SQL Server didn't report any errors or warnings -- it just silently truncated the data to 100 characters. The following SQLCMD session demonstrates this: 1 create procedure WhereHasMyDataGone (@data varchar(5)) as 2 begin 3 print 'Your data is ''' + @data + '''.'; 4 end; 5 go 1 exec WhereHasMyDataGone '123456789'; 2 go Your data is '12345'. Local variables also exhibit the same behaviour: 1 declare @s varchar(5) = '123456789'; 2 print @s; 3 go 12345 Is there an option I can enable to have SQL Server report errors (or at least warnings) in such situations? Or should I just declare all local variables and stored procedure parameters as VARCHAR(MAX) or NVARCHAR(MAX)?

    Read the article

  • Synfony2 validation changes invalid integer to 0

    - by Craig
    I've added validation to a form and found that in some cases it is losing the invalid data I am feeding it and saving 0s instead. The output at the bottom shows that if I post the latitude as 'zzzzzz' (clearly not a number nor between -90 and 90) the form is declared as valid and saved with the value 0 How can that happen given that I have declared the input must be a number? ProxyType.php buildForm() $builder ->add('siteName', null, array('label' => 'Site name')) .... ->add('latitude', 'number', array('label' => 'Latitude')) ->add('longitude', 'number', array('label' => 'Longitude')) .... ; ProxyController.php createAction .... $postData = $request->request->get('niwa_pictbundle_proxytype'); $this->get('logger')->info('Posted latitude = '.$postData['latitude']); $form = $this->createForm(new ProxyType(), $entity); $form->bindRequest($request); if ($form->isValid()) { $this->get('logger')->info('Form declared valid : latlong ('.$entity->getLatitude().','.$entity->getLongitude().')'); .... validation.yml Acme\PictBundle\Entity\Proxy: properties: longitude: - Min: { limit: -180 } - Max: { limit: 180 } latitude: - Max: { limit: 90 } - Min: { limit: -90 } Output [2012-09-28 02:05:30] app.INFO: Posted latitude = zzzzzz [] [] [2012-09-28 02:05:30] app.INFO: Form declared valid : latlong (0,0) [] []

    Read the article

  • Design Pattern for Changing Object

    - by user210757
    Is there a Design Pattern for supporting different permutations object? Version 1 public class myOjbect { public string field1 { get; set; } /* requirements: max length 20 */ public int field2 { get; set; } . . . public decimal field200 { get; set; } } Version 2 public class myObject { public string field1 { get; set; } /* requirements: max length 40 */ public int field2 { get; set; } . . . public double field200 { get; set; } /* changed data types */ . . ./* 10 new properties */ public double field210 { get; set; } } of course I could just have separate objects, but thought there might be a good pattern for this sort of thing.

    Read the article

  • What is a truly empty std::vector in C++?

    - by RyanG
    I've got a two vectors in class A that contain other class objects B and C. I know exactly how many elements these vectors are supposed to hold at maximum. In the initializer list of class A's constructor, I initialize these vectors to their max sizes (constants). If I understand this correctly, I now have a vector of objects of class B that have been initialized using their default constructor. Right? When I wrote this code, I thought this was the only way to deal with things. However, I've since learned about std::vector.reserve() and I'd like to achieve something different. I'd like to allocate memory for these vectors to grow as large as possible because adding to them is controlled by user-input, so I don't want frequent resizings. However, I iterate through this vector many, many times per second and I only currently work on objects I've flagged as "active". To have to check a boolean member of class B/C on ever iteration is silly. I don't want these objects to even BE there for my iterators to see when I run through this list. Is reserving the max space ahead of time and using push_back to add a new object to the vector a solution to this?

    Read the article

  • Store Business Rules in XML Document, Validate afterwards in Java, how?

    - by JavaPete
    Example XML Rules document: <user> <username> <not-null/> <capitals value="false"/> <max-length value="15"/> </username> <email> <not-null/> <isEmail/> <max-length value="40"/> </email> </user> How do I implement this? I'm starting from scratch, what I currently have is a User-class, and a UserController which saves the User object in de DB (through a Service-layer and Dao-layer), basic Spring MVC. I can't use Spring MVC Validation however in our Model-classes, I have to use an XML document so an Admin can change the rules I think I need a pattern which dynamically builds an algorithm based on what is provided by the XML Rules document, but I can't seem to think of anything other than a massive amount of if-statements. I also have nothing for the parsing yet and I'm not sure how I'm gonna (de)couple it from the actual implementation of the validation-process.

    Read the article

  • Centering Divisions Around Zero

    - by Mark
    I'm trying to create something that sort of resembles a histogram. I'm trying to create buckets from an array. Suppose I have a random array doubles between -10 and 10; this is very simplified. I then want to specify a center point, in this case 0 and the number of buckets. If I want 4 buckets the division would be -10 to -5, -5 to 0, 0 to 5 and 5 to 10. Not that complicated right. Now if I change the min and max to -12 and -9 and as for 4 divisions its more complicated. I either want a division at -3 and 3; it is centered around 0 ; or one at -6 to 0 and 0 to 6. Its not that hard to find the division size = Math.Ceiling((Abs(Max) + Abs(Min)) / Divisions) Then you would basically have an if statement to determine whether you want it centered on 0 or on an edge. You then iterate out from either 0 or DivisionSize/2 depending on the situation. You may not ALWAYS end up with the specified number of divisions but it will be close. Then you iterate through the array and increment the bin count. Does this seem like a good way to go about this? This method would surely work but it does not seem to be the most elegant. I'm curious as to whether the creation of the bins and the counting from the list could be done in a clever class with linq in a more elegant way? Something like creating the bins and then having each bin be a property {get;} that returns list.Count(x=> x >= Lower && x < Upper).

    Read the article

  • jQuery trigger function on change

    - by Michael Pasqualone
    I have the following two slider functions which work well and display like so: I have diskAmount and transferAmount stored in global vars, however what I am now trying to figure out is how do I get the sum of the two to initially show as the monthly fee, and then update when either of the two sliders are changed. So in my screenshot above the initial state will be $24.75, and the fee will update if the sliders change. Can anyone point me in the right direction? I get can the initial fee to show, but can't figure out how to get 1 function to call another function within jQuery. $(function() { $("#disk").slider({ value:3, min: 1, max: 80, step: 1, slide: function(event, ui) { $("#diskamount").val(ui.value + ' Gb'); $("#diskamountUnit").val('$' + parseFloat(ui.value * diskCost).toFixed(2)); } }); // Set initial diskamount state $("#diskamount").val($("#disk").slider("value") + ' Gb'); // Set initial diskamountUnit state diskAmount = $("#disk").slider("value") * diskCost; $("#diskamountUnit").val('$' + diskAmount.toFixed(2)); }); $(function() { $("#data").slider({ value:25, min: 1, max: 200, step: 1, slide: function(event, ui) { $("#dataamount").val(ui.value + ' Gb'); $("#dataamountUnit").val('$' + parseFloat(ui.value * transferCost).toFixed(2)); } }); // Set initial dataamount state $("#dataamount").val($("#data").slider("value") + ' Gb'); // Set initial dataamountUnit state transferAmount = $("#data").slider("value") * transferCost; $("#dataamountUnit").val('$' + transferAmount.toFixed(2)); });

    Read the article

  • Is this function thread-safe?

    - by kiddo
    Hello all,I am learning multi-threading and for the sake of understanding I have wriiten a small function using multithreading...it works fine.But I just want to know if that thread is safe to use,did I followed the correct rule. void CThreadingEx4Dlg::OnBnClickedOk() { //in thread1 100 elements are copied to myShiftArray(which is a CStringArray) thread1 = AfxBeginThread((AFX_THREADPROC)MyThreadFunction1,this); WaitForSingleObject(thread1->m_hThread,INFINITE); //thread2 waits for thread1 to finish because thread2 is going to make use of myShiftArray(in which thread1 processes it first) thread2 = AfxBeginThread((AFX_THREADPROC)MyThreadFunction2,this); thread3 = AfxBeginThread((AFX_THREADPROC)MyThreadFunction3,this); } UINT MyThreadFunction1(LPARAM lparam) { CThreadingEx4Dlg* pthis = (CThreadingEx4Dlg*)lparam; pthis->MyFunction(0,100); return 0; } UINT MyThreadFunction2(LPARAM lparam) { CThreadingEx4Dlg* pthis = (CThreadingEx4Dlg*)lparam; pthis->MyCommonFunction(0,20); return 0; } UINT MyThreadFunction3(LPARAM lparam) { CThreadingEx4Dlg* pthis = (CThreadingEx4Dlg*)lparam; WaitForSingleObject(pthis->thread3->m_hThread,INFINITE); //here thread3 waits for thread 2 to finish so that thread can continue pthis->MyCommonFunction(21,40); return 0; } void CThreadingEx4Dlg::MyFunction(int minCount,int maxCount) { for(int i=minCount;i<maxCount;i++) { //assume myArray is a CStringArray and it has 100 elemnts added to it. //myShiftArray is a CStringArray -public to the class CString temp; temp = myArray.GetAt(i); myShiftArray.Add(temp); } } void CThreadingEx4Dlg::MyCommonFunction(int min,int max) { for(int i = min;i < max;i++) { CSingleLock myLock(&myCS,TRUE); CString temp; temp = myShiftArray.GetAt(i); //threadArray is CStringArray-public to the class threadArray.Add(temp); } myEvent.PulseEvent(); }

    Read the article

< Previous Page | 81 82 83 84 85 86 87 88 89 90 91 92  | Next Page >