Search Results

Search found 29841 results on 1194 pages for 'random number generator'.

Page 71/1194 | < Previous Page | 67 68 69 70 71 72 73 74 75 76 77 78  | Next Page >

  • IPHONE - number of row being shown

    - by Mike
    I have a table inside a UIImageView. The table occupies the entire UIImageView. The table contains a series of images. Scroll and paging are enabled. As the table size is the same of its parent view, I can see just one cell of the table at a time. When I roll the table, I see the next or previous cell. I have a variable that must contain the number of the row being shown, but how can I make this table update the variable. I can see that I can use the didSelectRowAtIndexPath to change the variable when the cell is selected, but this is not the case. I need to update the variable when the table is rolled. I want to do the same thing I could do using a UISCrollView and scrollViewDidScroll:, but even if this is possible, I would have to know the number of the row that is visible. How can I do that? thanks.

    Read the article

  • Python - Number of Significant Digits in results of division

    - by russ
    Newbie here. I have the following code: myADC = 128 maxVoltage = 5.0 maxADC = 255.0 VoltsPerADC = maxVoltage/maxADC myVolts = myADC * VoltsPerADC print "myADC = {0: >3}".format(myADC) print "VoltsPerADC = {0: >7}".format(VoltsPerADC) print VoltsPerADC print "myVolts = {0: >7}".format(myVolts) print myVolts This outputs the following: myADC = 128 VoltsPerADC = 0.0196078 0.0196078431373 myVolts = 2.5098 2.50980392157 I have been searching for an explanation of how the number of significant digits is determined by default, but have had trouble locating an explanation that makes sense to me. This link link text suggests that by default the "print" statement prints numbers to 10 significant figures, but that does not seem to be the case in my results. How are the number of significant digits/precision determined? Can someone shed some light on this for me. Thanks in advance for your time and patience.

    Read the article

  • Querying current number of touches on screen without using events on iPhone

    - by nikhil
    I have an application that starts playing a sound when user touches the uiview and changing to different tones as the user slides the finger on the screen. The sound stops when the user lifts the finger. I am using the touchesBegan, Moved and Ended Events for this. My problem is touches Ended (and/or cancelled) is sometimes not fired properly and the sound keeps playing even after the finger is lifted from screen. So as a workaround I would like to implement a timer that would check for the number of touches on the screen and if it is zero it will check and stop the audioplayer if playing. I have been searching for some code that could get me the number of touches like UITouch *touches=[self getAllTouchesonScreen]; or something :)

    Read the article

  • Batch files - number of command line arguments

    - by pyko
    Just converting some shell scripts into batch files and there is one thing I can't seem to find...and that is a simple count of the number of command line arguments. eg. if you have: myapp foo bar In Shell: $# - 2 $* - foo bar $0 - myapp $1 - foo $2 - bar In batch ?? - 2 <---- what command?! %* - foo bar %0 - myapp %1 - foo %2 - bar So I've looked around, and either I'm looking in the wrong spot or I'm blind, but I can't seem to find a way to get a count of number of command line arguments passed in. Is there a command similar to shell's "$#" for batch files? ps. the closest i've found is to iterate through the %1s and use 'shift', but I need to refernece %1,%2 etc later in the script so that's no good.

    Read the article

  • Casting a primitive int to a Number

    - by Tamer
    Let's say that I have the following: int a = 2; Number b = (Number) a; System.out.println(b); // Prints 2 http://java.sun.com/docs/books/jls/first_edition/html/15.doc.html#238146 says that a primitive value may not be cast to a reference type. Does Java know to create an Integer from the primitive int and then cast to the superclass? How exactly does Java handle this behind the scenes? Thanks!

    Read the article

  • BULK INSERT with inconsitant number of columns

    - by aceinthehole
    I am trying to load a large amount data in SQL server from a flat file using BULK INSERT. However, my file has varying number of column, for instance the first row contains 14 and the second contains 4. That is OK, I just want to make a table with the max number of columns and load the file into it with nulls for the missing columns. I can play with it from that point. But it seems that SQL Server when reaching the end of the line and having more columns to fill for that same row in the destination table, just moves on to the next line and attempts to put the data on that line to the wrong column of the table. Is there a way to get the behavior that I am looking for? Is there a table hint that I can use the specify this? Has anyone run into this before? Here is the code BULK INSERT #t FROM '<path to file>' WITH ( DATAFILETYPE = 'char', KEEPNULLS, FIELDTERMINATOR = '#' )

    Read the article

  • How to get surrounding method in Java source file for a given line number

    - by roesslerj
    I have a line number of a Java source file and want to get the sourounding method for that line number programatically. I looked into ANTLR which didn't help me much. Janino (http://www.janino.net) seems promising, I would scan and parse (and if necessary compile) the code. Then I could use JDI and ReferenceType.locationsOfLine(int lineNumber) Still I don't know how to use JDI for doing this and didn't find a tutorial that goes anywhere in this direction. Maybe there is some other way that I am completely missing.

    Read the article

  • How to set Chrome's user script version number.

    - by Atli
    Hey. I've been wondering how I might set the version number displayed for user-scripts in Chrome's extension tab So far the obvious methods have failed: // ==UserScript== // @version 1.1.5 // @uso:version 1.1.5 // ==/UserScript== I know Greasemonkey for Firefox doesn't use a version value, but since Chrome actually displays a version number, I thought it might. Perhaps this is a feature that has not been implemented? Or maybe it was never intended to be there, but it is there because extensions have version numbers, and user-scripts are currently installed as extensions? (I'm using the Linux beta, version: 4.0.249.43, by the way) Thanks. Edit: Seems this is listed as an unconfirmed bug in the Chromium bug database (Issue 30760)

    Read the article

  • How to file split at a line number

    - by superspace
    I want to split a 400k line long log file from a particular line number. For this question, lets make this an arbitrary number 300k. Is there a linux function that allows me to do this? I know split lets me split the file in equal parts either by size or line numbers but that's not what I want. I want to the first 300k in one file and the last 100k in the second file. Any help would be appreciated. Thanks!

    Read the article

  • Checking to see if a number is evenly divisible by other numbers with recursion in Python

    - by Ernesto
    At the risk of receiving negative votes, I will preface this by saying this is a midterm problem for a programming class. However, I have already submitted the code and passed the question. I changed the name of the function(s) so that someone can't immediately do a search and find the correct code, as that is not my purpose. I am actually trying to figure out what is actually MORE CORRECT from two pieces that I wrote. The problem tells us that a certain fast food place sells bite-sized pieces of chicken in packs of 6, 9, and 20. It wants us to create a function that will tell if a given number of bite-sized piece of chicken can be obtained by buying different packs. For example, 15 can be bought, because 6 + 9 is 15, but 16 cannot be bought, because no combination of the packs will equal 15. The code I submitted and was "correct" on, was: def isDivisible(n): """ n is an int Returns True if some integer combination of 6, 9 and 20 equals n Otherwise returns False. """ a, b, c = 20, 9, 6 if n == 0: return True elif n < 0: return False elif isDivisible(n - a) or isDivisible(n - b) or isDivisible(n - c): return True else: return False However, I got to thinking, if the initial number is 0, it will return True. Would an initial number of 0 be considered "buying that amount using 6, 9, and/or 20"? I cannot view the test cases the grader used, so I don't know if the grader checked 0 as a test case and decided that True was an acceptable answer or not. I also can't just enter the new code, because it is a midterm. I decided to create a second piece of code that would handle an initial case of 0, and assuming 0 is actually False: def isDivisible(n): """ n is an int Returns True if some integer combination of 6, 9 and 20 equals n Otherwise returns False. """ a, b, c = 20, 9, 6 if n == 0: return False else: def helperDivisible(n): if n == 0: return True elif n < 0: return False elif helperDivisible(n - a) or helperDivisible(n - b) or helperDivisible(n - c): return True else: return False return helperDivisible(n) As you can see, my second function had to use a "helper" function in order to work. My overall question, though, is which function do you think would provide the correct answer, if the grader had tested for 0 as an initial input?

    Read the article

  • counting number of new entries in guest book

    - by Lucka
    I want to display the number of new(unseen) guest entries in the guest book of a user. I was thinking to count it so that, total number of entries in guestbook minus entries in guestbook at time of last login. However, I think that is not a good approach, because if the user logs in but does not go to his guestbook, in that case, the entries should be still "new", also if some new entry is posted in the user while he is online, it does not work in that case too. Any suggested please?

    Read the article

  • Programatically get own Phone Number in iPhone OS 4.0

    - by sandy
    I am developing an iPhone application for jail broken phones and in this application I would like to fetch user's phone number. I have gone through the entire stackoverflow.com and found some relevant answers but all of them are obsolete and doesn't work with iOS 4.0 anymore. The most famous solution for this problem is NSString *num = [[NSUserDefaults standardUserDefaults] stringForKey:@"SBFormattedPhoneNumber"]; but as I mentioned this solution no more works with iOS 4.0 As my application is intended towards the jail broken phones and not intended the Apple app store so I am not worried about my app rejection, hence any private API will also work for me. Also please let me know if we can fetch IMSI number from SIM using any private APIs of iPhone

    Read the article

  • Finding the average of two number using classes and methods

    - by Have alook
    I want to use methods inside class. Q: find the average of two number using classes and methods. import java.util.*; class aaa { int a,b,sum,avrg; void average() { System.out.println("The average is ="+avrg); avrg=(sum/2); } } class ave { public static void main(String args[]){ aaa n=new aaa(); Scanner m=new Scanner(System.in); System.out.println("write two number"); n.a=m.nextInt(); n.b=m.nextInt(); n.average(); } }

    Read the article

  • Given a number of rectangles that can be rotated, find an enclosing rectangle of minimum area

    - by efficiencyIsBliss
    So, I'm trying to implement an algorithm that takes in a number of rectangles as input and tries to pack them into a rectangle of minimum area. The rectangles can all be rotated by 90 degrees. I realize that this is similar to the bin packing problem, but I am unable to find a good algorithm that accounts for the rotation. I found a paper that discusses this at length here and while I understand the article itself, I was hoping to find something simpler. Any suggestions? -Edit- I think I misstated the problem earlier. We are given a number of rectangles, such that each can be rotated by 90 degrees. We need to find a rectangle that fits all the given rectangles such that no two rectangles overlap, while minimizing the area of the enclosing rectangle. The problem I face here is that we are asked to find the minimum, as opposed to being given an enclosing rectangle and checking if the given rectangles fit or something of that sort.

    Read the article

  • Using VirtualMode on a DataGridView when the number of rows/columns isn't known

    - by Nathan Baulch
    I need to display an unknown length sequence of dictionaries with unknown keys efficiently in a data grid. This sequence is the result of a potentially slow LINQ query that could contain any number of results. At first I thought that VirtualMode on DataGridView was what I was looking for but it appears that the number of rows and columns must be known upfront. I tried adding a single row and column then adding more as needed from the CellValueNeeded event but this doesn't work. Is this even possible with VirtualMode? Or do I need to estimate how many rows are visible on the screen and manually build up the rows/columns? And if so, how do I ensure that a vertical scrollbar is present and react appropriately when a user uses it?

    Read the article

  • MySQL - Return number of rows matching query data?

    - by Keir Simmons
    I have a query as follows: SELECT 1 FROM shop_inventory a JOIN shop_items b ON b.id=a.iid AND b.szbid=3362169 AND b.cid=a.cid WHERE a.cid=1 GROUP BY a.bought The only thing I need to do with this data is work out the number of rows returned (which I could do with mysqli -> num_rows;. However, I would like to know if there is a method to return the number of rows that match the query, without having to run num_rows? For example, the query should return one row, with one result, number_of_rows. I hope this makes sense!

    Read the article

  • Limit number of views per day in Django

    - by ariddell
    Is there an easy way to limit the number of times a view can be accessed by a given IP address per day/week? A simplified version of the technique used by some booksellers to limit the number of pages of a book you can preview? There's only one view that this limit need apply to--i.e. it's not a general limit--and it would be nice if I could just have a variable overlimit in the template context. The solution need not be terribly robust, but limiting by IP address seemed like a better idea than using a cookie. I've looked into the session middleware but it doesn't make any references to tracking IP addresses as far as I can tell. Has anyone encountered this problem?

    Read the article

  • How to generate unique number of 12 digits?

    - by DanSogaard
    I'm working on an app that sends raw data to zebra printer and print out barcodes. And since every item has its own unique barcode, I need to define a variable that automatically generates unique number of 12 digits long. see example: printBar prnt = new printBar("123456789012"); Is there anyway to define a double variable and pass it to a function that return uniqely 12 digits number and pass it over again to the printBar class?. But how to make sure everytime you access it returns a unique value?. I also thought of another way, since am using MS Access db, I can create a column of AutoNumber datatype and assign it to Random, but you don't get the exact 12 digits required, sometimes it generates a value of 10 digits sometimes more or less.

    Read the article

  • count number of business that belongs to subcategory in doctrine

    - by Ibrahim Azhar Armar
    this is follow up of this question. count number of foreign keys i am using doctrine 1.2 and i want to count the number of business that belongs to subcategory. following are the mysql tables. 1.fi_category +----+-----------------+-----------------+ | id | name | slug | +----+-----------------+-----------------+ 2.fi_subcategory +----+-----------------+-----------------+-------------+ | id | name | slug | category_id | +----+-----------------+-----------------+-------------+ 3.fi_business_subcategory +----+-------------+----------------+ | id | business_id | subcategory_id | +----+-------------+----------------+ i am using this DQL. $q = Doctrine_Query::create() ->select('c.name, c.slug, sc.name, sc.slug') ->from('Model_Category c') ->leftJoin('c.Subcategory sc') ->leftJoin('sc.BusinessSubcategory bsc'); which gives me something like this. Array ( [0] => Array ( [id] => 1 [name] => Entertainment & Lifestyle [slug] => entertainment-lifestyle [Subcategory] => Array ( [0] => Array ( [id] => 1 [name] => Arts and Crafts [slug] => arts-and-crafts ) [1] => Array ( [id] => 2 [name] => Family [slug] => family ) [2] => Array ( [id] => 3 [name] => Fashion [slug] => fashion ) ) ) ) i am looking to fetch the number of business, i.e the returned result should be something like this depending on the business it belongs. Array ( [0] => Array ( [id] => 1 [name] => Entertainment & Lifestyle [slug] => entertainment-lifestyle [Subcategory] => Array ( [0] => Array ( [id] => 1 [name] => Arts and Crafts [slug] => arts-and-crafts [business_count] => 35 ) [1] => Array ( [id] => 2 [name] => Family [slug] => family [business_count] => 10 ) [2] => Array ( [id] => 3 [name] => Fashion [slug] => fashion [business_count] => 27 ) ) ) ) tried various ways using DQL, but nothing seems to work out. any idea how should i go with what i want?

    Read the article

  • select from varchar2 column with numeric value sometimes gives invalid number error

    - by Rene
    I'm trying to understand why, on some systems, I get an invalid number error message when I'm trying to select a value from a varchar2 column while on other systems I don't get the error while doing the exact same thing. The table is something like this: ID Column_1 Column_2 1 V text 2 D 1 3 D 2 4 D 3 and a query: select ID from table where column_1='D' and column_2 = :some_number_value :some_number_value is always numeric but can be null. We've fixed the query: select ID from table where column_1='D' and column_2 = to_char(:some_number_value) This original query runs fine on most systems but on some systems gives an "invalid number" error. The question is why? Why does it work on most systems and not on some?

    Read the article

< Previous Page | 67 68 69 70 71 72 73 74 75 76 77 78  | Next Page >