Search Results

Search found 3666 results on 147 pages for 'mr myo min hein'.

Page 60/147 | < Previous Page | 56 57 58 59 60 61 62 63 64 65 66 67  | Next Page >

  • java number exceeds long.max_value - how to detect?

    - by jurchiks
    I'm having problems detecting if a sum/multiplication of two numbers exceeds the maximum value of a long integer. Example code: long a = 2 * Long.MAX_VALUE; System.out.println("long.max * smth > long.max... or is it? a=" + a); This gives me -2, while I would expect it to throw a NumberFormatException... Is there a simple way of making this work? Because I have some code that does multiplications in nested IF blocks or additions in a loop and I would hate to add more IFs to each IF or inside the loop. Edit: oh well, it seems that this answer from another question is the most appropriate for what I need: http://stackoverflow.com/a/9057367/540394 I don't want to do boxing/unboxing as it adds unnecassary overhead, and this way is very short, which is a huge plus to me. I'll just write two short functions to do these checks and return the min or max long. Edit2: here's the function for limiting a long to its min/max value according to the answer I linked to above: /** * @param a : one of the two numbers added/multiplied * @param b : the other of the two numbers * @param c : the result of the addition/multiplication * @return the minimum or maximum value of a long integer if addition/multiplication of a and b is less than Long.MIN_VALUE or more than Long.MAX_VALUE */ public static long limitLong(long a, long b, long c) { return (((a > 0) && (b > 0) && (c <= 0)) ? Long.MAX_VALUE : (((a < 0) && (b < 0) && (c >= 0)) ? Long.MIN_VALUE : c)); } Tell me if you think this is wrong.

    Read the article

  • TypeError when using v 0.8.1 of FLOT library, but no error with v. 0.7

    - by DanielAttard
    I need some help to figure out why I am getting an error when trying to create a simple graph using the jQuery FLOT library. When I reference version 0.7 of the FLOT library, the page renders correctly: http://attardpropertytax.ca/flot07.html But when I switch to version 0.8.1 of the FLOT library, the page returns an error saying: Uncaught TypeError: Cannot read property 'left' of null http://attardpropertytax.ca/flot81.html The HTML is the same for both pages, so I cannot figure out why the new version 0.8.1 of FLOT returns an error, but the old version 0.7 does not. Any ideas? I somehow stumbled across a work-around that managed to fix my problem. I'm nut sure why, but I had to comment-out the following two sections of code from the v. 0.8.1 FLOT library: This was the first spot: // If the grid is visible, add its border width to the offset for (var a in plotOffset) { if(typeof(options.grid.borderWidth) == "object") { plotOffset[a] += showGrid ? options.grid.borderWidth[a] : 0; } else { plotOffset[a] += showGrid ? options.grid.borderWidth : 0; } } And this was the second spot: if (isNaN(v) || v < axis.min || v > axis.max // skip those lying on the axes if we got a border || (t == "full" && ((typeof bw == "object" && bw[axis.position] > 0) || bw > 0) && (v == axis.min || v == axis.max))) continue; I'm sure eventually @DNS will be taking a look at this question and maybe he will be able to help me understand what is going wrong with my code. Thanks.

    Read the article

  • jquery touch punch - draggable on ipad

    - by dshuta
    i am starting to work with the jquery touch punch extensions in order to allow draggability on ipad, but i am getting tripped up right away. probably something terribly dumb on my part. the draggable example from the developer works fine on my ipad: http://furf.com/exp/touch-punch/draggable.html but not for me: http://danshuta.com/touchpunch/ this works fine in my desktop browser, but on the ipad it just focuses on the block and scrolls the entire page as i drag, as if it were just an image or other normal embedded object. as this is what happens normally with jquery/ui on ipad, this makes me think it is not loading or otherwise ignoring the "punch" code from my site (though if i host the jquery files on my site via the same path, those load and function fine in desktop browser). here's the entire code, very basic: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Touchpunchtest</title> <script src="http://code.jquery.com/jquery.min.js"></script> <script src="http://code.jquery.com/ui/1.8.17/jquery-ui.min.js"></script> <script src="js/jquery.ui.touch-punch.js"></script> </head> <body> <div id="draggybox" onclick="void(0)" style="width: 150px; height: 150px; background: green;"></div> <script>$('#draggybox').draggable();</script> </body> </html> what am i missing?!

    Read the article

  • CustomButton Field not aligning in the center

    - by rupesh
    Hi all I have created a custom button and i am placing the bunch of Custombuttons in a verticalfieldManager , I have aligned the verticalField Manager in the center. when i am creating a default buttonField then verticalfield Manager is able to align the buttonfield in the center. but when i am assigning custombuttonfield in the verticalField Manager it's not aligning in the center. here is my custombuttoncode enter code herepublic CustomButtonField(String label,long style) { super(style); this.label = label; onPicture = Bitmap.getBitmapResource(onPicturePath); font = getFont(); this.setPadding(5,5, 5, 5); } public String getLabel() { return label; } public int getPreferredHeight() { return onPicture.getHeight(); } public int getPreferredWidth() { return onPicture.getWidth(); } protected void layout(int width , int height) { setExtent(Math.min(width, Display.getWidth()), Math.min(height,getPreferredHeight())); } protected void paint(Graphics graphics) { int texty =(getHeight()-getFont().getHeight())/2; if (isFocus()) { graphics.setColor(Color.BLACK); graphics.drawBitmap(0, 0, getWidth(), getHeight(),onPicture , 0, 0); graphics.setColor(Color.WHITE); graphics.setFont(font); graphics.drawText(label,0,texty,DrawStyle.ELLIPSIS,getWidth()); } else { graphics.drawBitmap(0, 0, getWidth(), getHeight(),onPicture , 0, 0); graphics.setColor(Color.WHITE); graphics.setFont(font); graphics.drawText(label,0,texty,DrawStyle.ELLIPSIS,getWidth()); } } public boolean isFocusable() { return true; } protected void onFocus(int direction) { super.onFocus(direction); invalidate(); } protected void onUnfocus() { super.onUnfocus(); invalidate(); } protected boolean navigationClick(int status, int time) { fieldChangeNotify(0); return true; } protected boolean keyChar(char character, int status, int time) { if (character == Keypad.KEY_ENTER) { fieldChangeNotify(0); return true; } return super.keyChar(character, status, time); } }

    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

  • Masonry js won't bunch images vertically

    - by user1449737
    The images are being aligned horizontally correctly but they are all spaced out vertically.. Take a look here http://brstudios.co.uk/testing to see what I mean properly.. My mark up is as followed (simplified): <html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript" src="http://masonry.desandro.com/jquery.masonry.min.js"></script> <script type="text/javascript" src="https://raw.github.com/desandro/imagesloaded/master/jquery.imagesloaded.min.js"></script> <script type="text/javascript"> var $container = $('.portfolio-container'); $container.imagesLoaded(function(){ $container.masonry({ itemSelector : '.break', columnWidth : 429 }); }); </script> <style type="text/css"> .break { float: left; width: 429px; margin: 10px 20px; } </style> </head> <body> <div class="portfolio-container"> <?php do { ?> <div class="break"> // Contents taken from MySQL // </div> <?php } while ($row_displayPosts = mysql_fetch_assoc($displayPosts)); ?> </div> </body> </html> I think part of it is working but as you can see by the link provided it isn't moving the elements together vertically. Does anyone have any pointers?

    Read the article

  • What is the optimum way to select the most dissimilar individuals from a population?

    - by Aaron D
    I have tried to use k-means clustering to select the most diverse markers in my population, for example, if we want to select 100 lines I cluster the whole population to 100 clusters then select the closest marker to the centroid from each cluster. The problem with my solution is it takes too much time (probably my function needs optimization), especially when the number of markers exceeds 100000. So, I will appreciate it so much if anyone can show me a new way to select markers that maximize diversity in my population and/or help me optimize my function to make it work faster. Thank you # example: library(BLR) data(wheat) dim(X) mdf<-mostdiff(t(X), 100,1,nstart=1000) Here is the mostdiff function that i used: mostdiff <- function(markers, nClust, nMrkPerClust, nstart=1000) { transposedMarkers <- as.array(markers) mrkClust <- kmeans(transposedMarkers, nClust, nstart=nstart) save(mrkClust, file="markerCluster.Rdata") # within clusters, pick the markers that are closest to the cluster centroid # turn the vector of which markers belong to which clusters into a list nClust long # each element of the list is a vector of the markers in that cluster clustersToList <- function(nClust, clusters) { vecOfCluster <- function(whichClust, clusters) { return(which(whichClust == clusters)) } return(apply(as.array(1:nClust), 1, vecOfCluster, clusters)) } pickCloseToCenter <- function(vecOfCluster, whichClust, transposedMarkers, centers, pickHowMany) { clustSize <- length(vecOfCluster) # if there are fewer than three markers, the center is equally distant from all so don't bother if (clustSize < 3) return(vecOfCluster[1:min(pickHowMany, clustSize)]) # figure out the distance (squared) between each marker in the cluster and the cluster center distToCenter <- function(marker, center){ diff <- center - marker return(sum(diff*diff)) } dists <- apply(transposedMarkers[vecOfCluster,], 1, distToCenter, center=centers[whichClust,]) return(vecOfCluster[order(dists)[1:min(pickHowMany, clustSize)]]) } }

    Read the article

  • Firefox and Chrome do not support cross-domian ajax by default?

    - by Ethan
    The following code works as expected in IE8 and Safari4, but not work in Firefox3.6 and Chrome. All browsers are on Windows. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"></script> <script type="text/javascript"> $(function() { $('#tabs').tabs(); }); </script> </head> <body> <div id="tabs"> <ul> <li><a href="http://www.google.com/">Google</a></li> <li><a href="http://www.msn.com/">MSN</a></li> </ul> </div> </body> </html> Seems that Firefox and Chrome do not support cross-domian ajax by default, right? Is there any easy way to turn on cross-domian ajax in Firefox and Chrome?

    Read the article

  • How can I bind multiple Jquery UI Slider with "year" Select?

    - by arthur_br
    Hi, I'm trying to render sliders instead of select components. Each page has several select components marked with class='jqselect' and all of them will have decreasing year values (some years may be missing). Eg. a select may have values [2010, 2009, 2006, 2005, 2004]. I have tried binding it both following the examples in the jQuery UI doc (but ignoring the missing years) and using selectToUISlider by filamentgroup (http://www.filamentgroup.com/lab/update_jquery_ui_slider_from_a_select_element_now_with_aria_support//). None of them work. Here is what I've done so far: Binding selects with following slider container divs: $('#content div.jqslider').slider({ animate: true, min: $(this).prev().children().last().val(), max: $(this).prev().children().first().val(), slide: function(event, ui) { var select = $(this).prev(); select.val($(this).slider('option', 'value')); console.log($(this).slider('option', 'value')); //debug } }); This renders the slider, but console logs values from 0 to 100 and selects obviously does not change with the event. Using selectToUISlider: $('#content select.jqselect').selectToUISlider(); This does not even render the slider, throwing an error 'b is undefined' in jquery-min.js (line 30, v1.4.2). If I pass the identifier of only one of the sliders, it is rendered but very buggy. Please, I'm stucked in the by two days and any help is much appreciated. Regards, Arthur

    Read the article

  • Heroku "We're sorry, but something went wrong." due to javascript_include_tag

    - by Newton
    Uploading my ruby on rails app to heroku causes the following error: We're sorry, but something went wrong. This does not occur on my local machine. After some debugging, I think I may have spotted the error, but do not know how to fix it. In my file application.html.erb, removing the following line solves the problem, but then my app loses its jquery mobile theme. Any ideas what I could do to fix the problem? Line causing the problem: <%= javascript_include_tag "application" %> application.html.erb file: <!DOCTYPE html> <html> <head> <title>Washapp</title> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" /> <%= javascript_include_tag "application" %> <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script> <%= csrf_meta_tags %> <script> if (window.location.hash == "#_=_") window.location.hash = ""; </script> </head> <body> <div data-role="page"> <%= yield %> </div> </body> </html>

    Read the article

  • How to debug JBoss out of memory problem?

    - by user561733
    Hello, I am trying to debug a JBoss out of memory problem. When JBoss starts up and runs for a while, it seems to use memory as intended by the startup configuration. However, it seems that when some unknown user action is taken (or the log file grows to a certain size) using the sole web application JBoss is serving up, memory increases dramatically and JBoss freezes. When JBoss freezes, it is difficult to kill the process or do anything because of low memory. When the process is finally killed via a -9 argument and the server is restarted, the log file is very small and only contains outputs from the startup of the newly started process and not any information on why the memory increased so much. This is why it is so hard to debug: server.log does not have information from the killed process. The log is set to grow to 2 GB and the log file for the new process is only about 300 Kb though it grows properly during normal memory circumstances. This is information on the JBoss configuration: JBoss (MX MicroKernel) 4.0.3 JDK 1.6.0 update 22 PermSize=512m MaxPermSize=512m Xms=1024m Xmx=6144m This is basic info on the system: Operating system: CentOS Linux 5.5 Kernel and CPU: Linux 2.6.18-194.26.1.el5 on x86_64 Processor information: Intel(R) Xeon(R) CPU E5420 @ 2.50GHz, 8 cores This is good example information on the system during normal pre-freeze conditions a few minutes after the jboss service startup: Running processes: 183 CPU load averages: 0.16 (1 min) 0.06 (5 mins) 0.09 (15 mins) CPU usage: 0% user, 0% kernel, 1% IO, 99% idle Real memory: 17.38 GB total, 2.46 GB used Virtual memory: 19.59 GB total, 0 bytes used Local disk space: 113.37 GB total, 11.89 GB used When JBoss freezes, system information looks like this: Running processes: 225 CPU load averages: 4.66 (1 min) 1.84 (5 mins) 0.93 (15 mins) CPU usage: 0% user, 12% kernel, 73% IO, 15% idle Real memory: 17.38 GB total, 17.18 GB used Virtual memory: 19.59 GB total, 706.29 MB used Local disk space: 113.37 GB total, 11.89 GB used

    Read the article

  • Handling multiple media queries in Sass with Twitter Bootstrap

    - by Keith
    I have a Sass mixin for my media queries based on Twitter Bootstrap's responsive media queries: @mixin respond-to($media) { @if $media == handhelds { /* Landscape phones and down */ @media (max-width: 480px) { @content; } } @else if $media == small { /* Landscape phone to portrait tablet */ @media (max-width: 767px) {@content; } } @else if $media == medium { /* Portrait tablet to landscape and desktop */ @media (min-width: 768px) and (max-width: 979px) { @content; } } @else if $media == large { /* Large desktop */ @media (min-width: 1200px) { @content; } } @else { @media only screen and (max-width: #{$media}px) { @content; } } } And I call them throughout my SCSS file like so: .link { color:blue; @include respond-to(medium) { color: red; } } However, sometimes I want to style multiple queries with the same styles. Right now I'm doing them like this: .link { color:blue; /* this is fine for handheld and small sizes*/ /*now I want to change the styles that are cascading to medium and large*/ @include respond-to(medium) { color: red; } @include respond-to(large) { color: red; } } but I'm repeating code so I'm wondering if there is a more concise way to write it so I can target multiple queries. Something like this so I don't need to repeat my code (I know this doesn't work): @include respond-to(medium, large) { color: red; } Any suggestions on the best way to handle this?

    Read the article

  • How to get timestamp of tick precision in .NET / C#?

    - by Hermann
    Up until now I used DateTime.Now for getting timestamps, but I noticed that if you print DateTime.Now in a loop you will see that it increments in descrete jumps of approx. 15 ms. But for certain scenarios in my application I need to get the most accurate timestamp possible, preferably with tick (=100 ns) precision. Any ideas? Update: Apparently, StopWatch / QueryPerformanceCounter is the way to go, but it can only be used to measure time, so I was thinking about calling DateTime.Now when the application starts up and then just have StopWatch run and then just add the elapsed time from StopWatch to the initial value returned from DateTime.Now. At least that should give me accurate relative timestamps, right? What do you think about that (hack)? NOTE: StopWatch.ElapsedTicks is different from StopWatch.Elapsed.Ticks! I used the former assuming 1 tick = 100 ns, but in this case 1 tick = 1 / StopWatch.Frequency. So to get ticks equivalent to DateTime use StopWatch.Elapsed.Ticks. I just learned this the hard way. NOTE 2: Using the StopWatch approach, I noticed it gets out of sync with the real time. After about 10 hours, it was ahead by 5 seconds. So I guess one would have to resync it every X or so where X could be 1 hour, 30 min, 15 min, etc. I am not sure what the optimal timespan for resyncing would be since every resync will change the offset which can be up to 20 ms.

    Read the article

  • Embed javascript in markdown

    - by Paul Tarjan
    I'm using the Maruku markdown processor. I'd like this *blah* blah "blah" in [markdown](blah) <script src="code.jquery.com/jquery-1.4.2.min.js"></script> <script> ...do stuff... </script> but it complains when I render it with a multitude of errors. The first one being ___________________________________________________________________________ | Maruku tells you: +--------------------------------------------------------------------------- | Could you please format this better? | I see that "<script type='text/javascript'>" is left after the raw HTML. | At line 31 | raw_html |<script src='http://code.jquery.com/jquery-1.4.2.min.js' /><script type='text/javascript'>| | text --> |//<![CDATA[| and then the rest seems like the parser is going nuts. Then it renders the javascript into a div on the page. I've tried making it a CDATA block and extra spacing between the jquery and my script. Help?

    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

  • 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

  • multiple ajax request to action in asp.net mvc

    - by persian Dev
    I am developing an asp.net mvc application and have ajax calls on my page. Here is a form which I load by ajax call to page : The form is located in a partial view <div id="CreateCultureArea"> <% using (Ajax.BeginForm("CreateCulture", "Admin", new AjaxOptions() { OnSuccess = "handleCreateCulture" })) { %> ..... <% } %> </div> The following script is located in a view $('.CreateCulture').live('click', function (e) { e.preventDefault(); var idval = this.id; $.ajax({ url: "/Admin/CreateCulture", dataType: 'html', data: { id: idval }, success: function (mydata) { $("#CultureContentArea").empty(); $("#CultureContentArea").empty().hide().append(mydata).fadeIn(2000); $("form").removeData("validator"); $("form").removeData("unobtrusiveValidation"); $.validator.unobtrusive.parse("form"); }, type: "GET" }); return false; }) </script> When users click on a link with CreateCulture class, the form is loaded to page. But as I saw the requests in firebug, it calls the action multiple times. I read similar posts like mine on stackoverflow.com and most of them suggested removing repetitive "jquery.unobtrusive-ajax.min.js" calss in page, but as I saw the output page I only see on link to the "jquery.unobtrusive-ajax.min.js" script.

    Read the article

  • Greasemonkey script, that creates Kineticjs drag and drop canvas over every website

    - by Michael Moeller
    I'd like to put a drag and drop canvas over every website I visit in Firefox. My Greasemonkey script puts a drag and drop canvas under every page: kinetic.user.js: // ==UserScript== // @name kineticjs_example // @description Canvas Drag and Drop // @include * // @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js // @require http://d3lp1msu2r81bx.cloudfront.net/kjs/js/lib/kinetic-v4.7.2.min.js // ==/UserScript== var div = document.createElement( 'div' ); with( div ) { setAttribute( 'id', 'container' ); } // append at end document.getElementsByTagName( 'body' )[ 0 ].appendChild( div ); var stage = new Kinetic.Stage({ container: 'container', width: 1000, height: 1000 }); var layer = new Kinetic.Layer(); var rectX = stage.getWidth() / 2 - 50; var rectY = stage.getHeight() / 2 - 25; var box = new Kinetic.Rect({ x: rectX, y: rectY, width: 100, height: 50, fill: '#00D2FF', stroke: 'black', strokeWidth: 4, draggable: true }); // add cursor styling box.on('mouseover', function() { document.body.style.cursor = 'pointer'; }); box.on('mouseout', function() { document.body.style.cursor = 'default'; }); layer.add(box); stage.add(layer); How can I drag and drop this shape over the entire website?

    Read the article

  • new to lists on python

    - by user1762229
    This is my current code: while True: try: mylist = [0] * 7 for x in range(7): sales = float(input("Sales for day:")) mylist[x] = sales if sales < 0: print ("Sorry,invalid. Try again.") except: print ("Sorry, invalid. Try again.") else: break print (mylist) best = max(sales) worst = min(sales) print ("Your best day had", best, "in sales.") print ("Your worst day had", worst, "in sales.") When I run it I get this: Sales for day:-5 Sorry,invalid. Try again. Sales for day:-6 Sorry,invalid. Try again. Sales for day:-7 Sorry,invalid. Try again. Sales for day:-8 Sorry,invalid. Try again. Sales for day:-9 Sorry,invalid. Try again. Sales for day:-2 Sorry,invalid. Try again. Sales for day:-5 Sorry,invalid. Try again. [-5.0, -6.0, -7.0, -8.0, -9.0, -2.0, -5.0] Traceback (most recent call last): File "C:/Users/Si Hong/Desktop/HuangSiHong_assign9_part.py", line 45, in <module> best = max(sales) TypeError: 'float' object is not iterable I am not quite sure how to code it so that, the lists do NOT take in negative values, because I only want values 0 or greater. I am not sure how to solve the TypeError issue so that the min and max values will print as in my code My last issue is, if I want to find the average value of the seven inputs that an user puts in, how should I go about this in pulling the values out of the lists Thank you so much

    Read the article

  • Creating a timesheet for work using PHP MySQL

    - by Justin
    I am trying to create a time-sheet for my work. I don't know if getting myself into a lot of work by doing this as I am quiet new to PHP and MYSQL but I do have a good understanding/knowledge of the two. I want the below fields in my database. Job weekPeriod ------A list of weeks Monday Sunday dateWorked ------List Of dates in the form coming from a database e.g. 1/1/2011 startTime ------List of times from 12:00am11:00pm 30 min intervals e.g. 11:30-12:30 endTime ------List of times from 12:00am11:00pm 30 min intervals e.g. 11:30-12:30 totalHours ------Automated amount ------Automated based on dayWorked comments ------Any messages here I want to be able to fill in some drop down boxes through a form that will then submit all information to my database. I want the script to know that if the date worked is on a Weekday Mon-Fri e.g. my rate of pay is 30.00ph On a sat it is 35.00ph and on a Sunday it is 40ph I then want to create a page where i select a particular week and see how many hours i worked and how much i earn and so on. Please let me know if there is such a program already established or if this is something that requires a bit of time and if I could do it being new to PHP and MYSQL

    Read the article

  • Find all A^x in a given range

    - by Austin Henley
    I need to find all monomials in the form AX that when evaluated falls within a range from m to n. It is safe to say that the base A is greater than 1, the power X is greater than 2, and only integers need to be used. For example, in the range 50 to 100, the solutions would be: 2^6 3^4 4^3 My first attempt to solve this was to brute force all combinations of A and X that make "sense." However this becomes too slow when used for very large numbers in a big range since these solutions are used in part of much more intensive processing. Here is the code: def monoSearch(min, max): base = 2 power = 3 while 1: while base**power < max: if base**power > min: print "Found " + repr(base) + "^" + repr(power) + " = " + repr(base**power) power = power + 1 base = base + 1 power = 3 if base**power > max: break I could remove one base**power by saving the value in a temporary variable but I don't think that would make a drastic effect. I also wondered if using logarithms would be better or if there was a closed form expression for this. I am open to any optimizations or alternatives to finding the solutions.

    Read the article

  • Top n items in a List ( including duplicates )

    - by Krishnan
    Trying to find an efficient way to obtain the top N items in a very large list, possibly containing duplicates. I first tried sorting & slicing, which works. But this seems unnnecessary. You shouldn't need to sort a very large list if you just want the top 20 members. So I wrote a recursive routine which builds the top-n list. This also works, but is very much slower than the non-recursive one! Question: Which is my second routine (elite2) so much slower than elite, and how do I make it faster ? My code is attached below. Thanks. import scala.collection.SeqView import scala.math.min object X { def elite(s: SeqView[Int, List[Int]], k:Int):List[Int] = { s.sorted.reverse.force.slice(0,min(k,s.size)) } def elite2(s: SeqView[Int, List[Int]], k:Int, s2:List[Int]=Nil):List[Int] = { if( k == 0 || s.size == 0) s2.reverse else { val m = s.max val parts = s.force.partition(_==m) val whole = if( parts._1.size > 1) parts._1.tail:::parts._2 else parts._2 elite2( whole.view, k-1, m::s2 ) } } def main(args:Array[String]) = { val N = 1000000/3 val x = List(N to 1 by -1).flatten.map(x=>List(x,x,x)).flatten.view println(elite2(x,20)) println(elite(x,20)) } }

    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 Mobile 1.2 Multiple Checkbox Selection Issue

    - by user1819957
    I'm coding a Jquery Mobile 1.2, Jquery 1.8.2, css, and HTML 5 based app that I need to allow the user to select multiple images and execute a command. The following works if I do NOT use the jquery.mobile-1.2.0.min.js library: CSS Code: .image-checkbox-container input[type="checkbox"]{ display: none; } .image-checkbox-container img{ border: 0; margin: 4px; } HTML: JQuery: $('.image-checkbox-container img').live('click', function(){ if(!$(this).prev('input[type="checkbox"]').prop("checked")){ $(this).prev('input[type="checkbox"]').prop("checked", true); this.style.border = '4px solid #38A'; this.style.margin = '0px'; }else{ $(this).prev('input[type="checkbox"]').prop("checked", false); this.style.border = '0'; this.style.margin = '4px'; } }); As soon as I add in the jquery.mobile-1.2.0.min.js library to the code it does not function correctly anymore. The unchecking/unselecting of the checkboxes does not work. I attempted to use the checkboxradio("refresh") but did not have any luck. Any suggestions would be much appreciated. Thanks

    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

< Previous Page | 56 57 58 59 60 61 62 63 64 65 66 67  | Next Page >