Search Results

Search found 4955 results on 199 pages for 'range'.

Page 91/199 | < Previous Page | 87 88 89 90 91 92 93 94 95 96 97 98  | Next Page >

  • Python string formatting too slow

    - by wich
    I use the following code to log a map, it is fast when it only contains zeroes, but as soon as there is actual data in the map it becomes unbearably slow... Is there any way to do this faster? log_file = open('testfile', 'w') for i, x in ((i, start + i * interval) for i in range(length)): log_file.write('%-5d %8.3f %13g %13g %13g %13g %13g %13g\n' % (i, x, map[0][i], map[1][i], map[2][i], map[3][i], map[4][i], map[5][i]))

    Read the article

  • Seeking jQuery-based transition library

    - by justSteve
    I'm looking for a library (or plugin) that help me create a slideshow where (besides the simple ordering of images) I'm able to define the beginning and ending positions (either X/Y, or Zooms) for a given image and the plugin animates the intervening steps between them. Flash has a number of tools/libs like this, i'm sure jQuery has seen similar. Ideally something that offers a range of easing effects as well. I understand these elements are native to jQuery...i'm looking for a time-tested wrapper. thx

    Read the article

  • Selecting and Copying a Random File Several Times

    - by user1252778
    [Edit: see below for final code] I have the following code and I'm trying to figure out where to insert the random.choice code to make it select a single file, copy it, and repeat (here 6 times). import os import shutil import random dir_input = str(input("Enter Source Directory: ")) src_files = (os.listdir(dir_input)) for x in range (0,5): print ('This is the %d time' % x) for file_name in src_files: full_file_name = (os.path.join(dir_input, file_name)) if (os.path.isfile(full_file_name)): print ('copying...' + full_file_name) shutil.copy(full_file_name, r'C:\Dir')) else: print ('Finished!')

    Read the article

  • Rows and Column of Excel File

    - by Mark
    It is possible to write a code that specifying the rows and column of spread sheet in terms of NUMBERS and NOT LIKE (B2:D6) Example: excelSheet.Range("B2:D6").Interior.Color = RGB(100, 100, 255) instead of B2 and D6 I want to write 5 rows and 3 column.. It is posible to write in vb.net 2003 code?

    Read the article

  • Connecting slots and events in PyQt4 in a loop

    - by LukaD
    Im trying to build a calculator with PyQt4 and connecting the 'clicked()' signals from the buttons doesn't as expected. Im creating my buttons for the numbers inside a for loop where i try to connect them afterwards. def __init__(self): for i in range(0,10): self._numberButtons += [QPushButton(str(i), self)] self.connect(self._numberButtons[i], SIGNAL('clicked()'), lambda : self._number(i)) def _number(self, x): print(x) When I click on the buttons all of them print out '9'. Why is that so and how can i fix this?

    Read the article

  • casting doubles to integers in order to gain speed

    - by antirez
    Hello all, in Redis (http://code.google.com/p/redis) there are scores associated to elements, in order to take this elements sorted. This scores are doubles, even if many users actually sort by integers (for instance unix times). When the database is saved we need to write this doubles ok disk. This is what is used currently: snprintf((char*)buf+1,sizeof(buf)-1,"%.17g",val); Additionally infinity and not-a-number conditions are checked in order to also represent this in the final database file. Unfortunately converting a double into the string representation is pretty slow. While we have a function in Redis that converts an integer into a string representation in a much faster way. So my idea was to check if a double could be casted into an integer without lost of data, and then using the function to turn the integer into a string if this is true. For this to provide a good speedup of course the test for integer "equivalence" must be fast. So I used a trick that is probably undefined behavior but that worked very well in practice. Something like that: double x = ... some value ... if (x == (double)((long long)x)) use_the_fast_integer_function((long long)x); else use_the_slow_snprintf(x); In my reasoning the double casting above converts the double into a long, and then back into an integer. If the range fits, and there is no decimal part, the number will survive the conversion and will be exactly the same as the initial number. As I wanted to make sure this will not break things in some system, I joined #c on freenode and I got a lot of insults ;) So I'm now trying here. Is there a standard way to do what I'm trying to do without going outside ANSI C? Otherwise, is the above code supposed to work in all the Posix systems that currently Redis targets? That is, archs where Linux / Mac OS X / *BSD / Solaris are running nowaday? What I can add in order to make the code saner is an explicit check for the range of the double before trying the cast at all. Thank you for any help.

    Read the article

  • Mysql select - improve performances

    - by realshadow
    Hey, I am working on an e-shop which sells products only via loans. I display 10 products per page in any category, each product has 3 different price tags - 3 different loan types. Everything went pretty well during testing time, query execution time was perfect, but today when transfered the changes to the production server, the site "collapsed" in about 2 minutes. The query that is used to select loan types sometimes hangs for ~10 seconds and it happens frequently and thus it cant keep up and its hella slow. The table that is used to store the data has approximately 2 milion records and each select looks like this: SELECT * FROM products_loans WHERE KOD IN("X17/Q30-10", "X17/12", "X17/5-24") AND 369.27 BETWEEN CENA_OD AND CENA_DO; 3 loan types and the price that needs to be in range between CENA_OD and CENA_DO, thus 3 rows are returned. But since I need to display 10 products per page, I need to run it trough a modified select using OR, since I didnt find any other solution to this. I have asked about it here, but got no answer. As mentioned in the referencing post, this has to be done separately since there is no column that could be used in a join (except of course price and code, but that ended very, very badly). Here is the show create table, kod and CENA_OD/CENA_DO very indexed via INDEX. CREATE TABLE `products_loans` ( `KOEF_ID` bigint(20) NOT NULL, `KOD` varchar(30) NOT NULL, `AKONTACIA` int(11) NOT NULL, `POCET_SPLATOK` int(11) NOT NULL, `koeficient` decimal(10,2) NOT NULL default '0.00', `CENA_OD` decimal(10,2) default NULL, `CENA_DO` decimal(10,2) default NULL, `PREDAJNA_CENA` decimal(10,2) default NULL, `AKONTACIA_SUMA` decimal(10,2) default NULL, `TYP_VYHODY` varchar(4) default NULL, `stage` smallint(6) NOT NULL default '1', PRIMARY KEY (`KOEF_ID`), KEY `CENA_OD` (`CENA_OD`), KEY `CENA_DO` (`CENA_DO`), KEY `KOD` (`KOD`), KEY `stage` (`stage`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 And also selecting all loan types and later filtering them trough php doesnt work good, since each type has over 50k records and the select takes too much time as well... Any ides about improving the speed are appreciated. Edit: Here is the explain +----+-------------+----------------+-------+---------------------+------+---------+------+--------+-------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+----------------+-------+---------------------+------+---------+------+--------+-------------+ | 1 | SIMPLE | products_loans | range | CENA_OD,CENA_DO,KOD | KOD | 92 | NULL | 190158 | Using where | +----+-------------+----------------+-------+---------------------+------+---------+------+--------+-------------+ I have tried the combined index and it improved the performance on the test server from 0.44 sec to 0.06 sec, I cant access the production server from home though, so I will have to try it tomorrow.

    Read the article

  • combine lines from 2 prints to single line and insert into mysql database

    - by bleomycin
    Hello everyone i currently have this: import feedparser d = feedparser.parse('http://store.steampowered.com/feeds/news.xml') for i in range(10): print d.entries[i].title print d.entries[i].date How would i go about making it so that the title and date are on the same line? Also it doesn't need to print i just have that in there for testing, i would like to dump this output into a mysql db with the title and date, any help is greatly appreciated!

    Read the article

  • How to lock files in a tomcat web application?

    - by yankee
    The Java manual says: The locks held on a particular file by a single Java virtual machine do not overlap. The overlaps method may be used to test whether a candidate lock range overlaps an existing lock. I guess that if I lock a file in a tomcat web application I can't be sure that every call to this application is done by a different JVM, can I? So how can I lock files within my tomcat application in a reliable way?

    Read the article

  • writing to an ioport resulting in segfaults...

    - by Sniperchild
    I'm writing for an atmel at91sam9260 arm 9 cored single board computer [glomation gesbc9260] Using request_mem_region(0xFFFFFC00,0x100,"name"); //port range runs from fc00 to fcff that works fine and shows up in /proc/iomem then i try to write to the last bit of the port at fc20 with writel(0x1, 0xFFFFFC20); and i segfault...specifically "unable to handle kernel paging request at virtual address fffffc20. I'm of the mind that i'm not allocating the right memory space... any helpful insight would be great...

    Read the article

  • What is the total amount of public IPv4 addresses?

    - by Earlz
    Yes, I am needing to know what the total number possible IPs in the public IPv4 space. I'm not sure where to even get a neat list of all the IP address ranges, so could someone point me to a resource to calculate this myself or calculate the total number of IPs for me? Also, by Public IPs I mean not counting reserved or private-range IP addresses.. Only the ones that can be access through the internet.

    Read the article

  • Write a SQL to meet my requirement.

    - by rgksugan
    I have been trying to solve this problem for a lot of days. But wouldn't. Please help me. I need a SQL to list product_code, product_name, qty_sold, last_order_date for all the products that have been sold within a date range sorted by the number of quantity sold. My Table structure: tbl_product(product_id,product_code,product_name) tbl_order_detail(order_item_id,order_id,product_id,quantity) tbl_order(order_id,order_date)

    Read the article

  • A python code to convert a number from any base to the base of 10 giving errors . What is wrong with this code?

    - by mekasperasky
    import math def baseencode(number, base): ##Converting a number of any base to base10 if number == 0: return '0' for i in range(0,len(number)): if number[i]!= [A-Z]: num = num + number[i]*pow(i,base) else : num = num + (9 + ord(number[i])) *pow(i,base) return num a = baseencode('20',5) print a Errors I get are Traceback (most recent call last): File "doubtrob.py", line 19, in <module> a = baseencode('20',5) File "doubtrob.py", line 13, in baseencode if number[i]!= [A-Z]: NameError: global name 'A' is not defined

    Read the article

  • QueryTables error

    - by ktm5124
    I have the following VBA code inside an Excel macro: With ActiveSheet.QueryTables.Add( _ Connection:=ConnStr, _ Destination:=ActiveSheet.Range("A1"), _ Sql:=SqlStr) .Refresh End With And yet I am getting the error: "Run-time error '1004': Application-defined or object-defined error." The debugger points to this code as the source of error. Assuming that my ConnStr and SqlStr are correct, why am I getting this error? I am using Excel 2007 and I am querying an Oracle database.

    Read the article

  • plane bombing problems- help

    - by peiska
    I'm training code problems, and on this one I am having problems to solve it, can you give me some tips how to solve it please. The problem is something like this: Your task is to find the sequence of points on the map that the bomber is expected to travel such that it hits all vital links. A link from A to B is vital when its absence isolates completely A from B. In other words, the only way to go from A to B (or vice versa) is via that link. Notice that if we destroy for example link (d,e), it becomes impossible to go from d to e,m,l or n in any way. A vital link can be hit at any point that lies in its segment (e.g. a hit close to d is as valid as a hit close to e). Of course, only one hit is enough to neutralize a vital link. Moreover, each bomb affects an exact circle of radius R, i.e., every segment that intersects that circle is considered hit. Due to enemy counter-attack, the plane may have to retreat at any moment, so the plane should follow, at each moment, to the closest vital link possible, even if in the end the total distance grows larger. Given all coordinates (the initial position of the plane and the nodes in the map) and the range R, you have to determine the sequence of positions in which the plane has to drop bombs. This sequence should start (takeoff) and finish (landing) at the initial position. Except for the start and finish, all the other positions have to fall exactly in a segment of the map (i.e. it should correspond to a point in a non-hit vital link segment). The coordinate system used will be UTM (Universal Transverse Mercator) northing and easting, which basically corresponds to a Euclidian perspective of the world (X=Easting; Y=Northing). Input Each input file will start with three floating point numbers indicating the X0 and Y0 coordinates of the airport and the range R. The second line contains an integer, N, indicating the number of nodes in the road network graph. Then, the next N (<10000) lines will each contain a pair of floating point numbers indicating the Xi and Yi coordinates (1 No two links will ever cross with each other. Output The program will print the sequence of coordinates (pairs of floating point numbers with exactly one decimal place), each one at a line, in the order that the plane should visit (starting and ending in the airport). Sample input 1 102.3 553.9 0.2 14 342.2 832.5 596.2 638.5 479.7 991.3 720.4 874.8 744.3 1284.1 1294.6 924.2 1467.5 659.6 1802.6 659.6 1686.2 860.7 1548.6 1111.2 1834.4 1054.8 564.4 1442.8 850.1 1460.5 1294.6 1485.1 17 1 2 1 3 2 4 3 4 4 5 4 6 6 7 7 8 8 9 8 10 9 10 10 11 6 11 5 12 5 13 12 13 13 14 Sample output 1 102.3 553.9 720.4 874.8 850.1 1460.5 102.3 553.9

    Read the article

  • How Do I grep For non-ASCII Characters in UNIX

    - by Peter Conrey
    I have several very large XML files and I'm trying to find the lines that contain non-ASCII characters. I've tried the following: grep -e "[\x{00FF}-\x{FFFF}]" file.xml But this returns every line in the file, regardless of whether the line contains a character in the range specified. Do I have the syntax wrong or am I doing something else wrong? I've also tried: egrep "[\x{00FF}-\x{FFFF}]" file.xml (with both single and double quotes surrounding the pattern).

    Read the article

  • K-means algorithm variation with minimum measure of size

    - by user1464628
    I'm looking for some algorithm such as k-means for grouping points on a map into a fixed number of groups, by distance. The number of groups has already been decided, but the trick part (at least for me) is to meet the criteria that the sum of MOS of each group should in the certain range, say bigger than 1. Is there any way to make that happen? ID MOS X Y 1 0.47 39.27846 -76.77101 2 0.43 39.22704 -76.70272 3 1.48 39.24719 -76.68485 4 0.15 39.25172 -76.69729 5 0.09 39.24341 -76.69884

    Read the article

  • Error while conversion of string to datetime

    - by aswathi
    The conversion of a char data type to a DateTime data type resulted in an out-of-range DateTime value. The statement has been terminated. Please give me most possible answers ALTER PROCEDURE [dbo].[attendance_updatebyemployee_id] @Employee_id int, @AtDate datetime, @FNLogged bit, @ANLogged bit, @LogTime varchar(10), @LogOuttime varchar(10) AS BEGIN SET NOCOUNT ON; update Mst_Attendance set FNLogged=@FNLogged, ANLogged=@ANLogged,LogTime=@LogTime,LogOuttime=@LogOuttime where EmployeeId=@Employee_id and Atdate= @AtDate END

    Read the article

  • compare time using date command

    - by Andrei
    Say I want a certain block of bash script execute only if it is between 8 am (8:00) and 5 pm (17:00), and do nothing otherwise. The script is running continuously So far I am using date command. How to use it compare it current time within the range? Thanks

    Read the article

  • Way around 1mb file size restriction?

    - by Sarevok
    My app needs to save files that will range from about 2-20mb. When I tried to do this I was getting an OutOfMemoryException. I did some reading and it's looking like Android has a file size limit of 1mb. Is this correct? If so, is there a way around this limitation, other than splitting up every file into 1mb chunks?

    Read the article

< Previous Page | 87 88 89 90 91 92 93 94 95 96 97 98  | Next Page >