Wikipedia:Reference desk/Archives/Computing/2013 July 22

Computing desk
< July 21 << Jun | July | Aug >> July 23 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


July 22 edit

Excel 2010 MOD function edit

I have a spreadsheet that I'm using to record & total times (processed to the minute, data entered to 15 minutes).

I'm subtracting two timestamps to get a duration displayed as hh:mm. I can total the durations up. One day of 8 hours is 0.33333, so four days of this is 1.33333. Using the hh:mm display, this shows as 08:00 since it throws the 1 day away. I want it to display as 32:00.

Therefore I am using my own formula to display the answer:
=RIGHT(100+INT(24*SUM(O1102:O1147)),2)&":"&RIGHT("0"&INT(60*MOD(24*SUM(O1102:O1147),1)+1/24),2)

This worked fine on Excel 2002 on XP. I have now migrated to Win7 & Excel 2010. Instead of displaying 32:00, it often displays 32:60 Which means that MOD(a,b) is returning b as a valid answer. Surely it should return 0 <= return value < b

Anyway I've fixed it in a clunky fashion with:
=RIGHT(100+INT(24*SUM(O1102:O1147)),2)&":"&RIGHT("0"&IF(INT(60*MOD(24*SUM(O1102:O1147),1)+1/24)>=60,INT(60*MOD(24*SUM(O1102:O1147),1)+1/24)-60,INT(60*MOD(24*SUM(O1102:O1147),1)+1/24)),2)

But is there a better way? -- SGBailey (talk) 10:05, 22 July 2013 (UTC) (after the event)[reply]

If you use the custom format [hh]:mm it will display the correct number of hours. AndrewWTaylor (talk) 10:02, 22 July 2013 (UTC)[reply]
Great, thanks. Is that format documented anywhere? -- SGBailey (talk) 10:05, 22 July 2013 (UTC)[reply]
Yes, it's in the help for Custom Number Formats. AndrewWTaylor (talk) 10:13, 22 July 2013 (UTC)[reply]
I can find no help for custom number formats. Within the Format Cells | Number | Custom, there is no help button. Within Help, if I type Custom format or Format nothing relevant pops up. -- SGBailey (talk) 10:35, 22 July 2013 (UTC)[reply]
Also, why DOES the mod function (appear to) go wrong. -- SGBailey (talk) 10:35, 22 July 2013 (UTC)[reply]
I found the help by going to the Format Cells dialog and pressing F1 (the standard key for help); this gives a page with three links, one of which is "Create a custom number format". As for the problem with MOD, I also found some help saying "The MOD function now [i.e. in Excel 2007/2010] uses new algorithms to achieve both accuracy and speed", so you might expect differences. To debug it further you could break down the formula into its components to see where it's not doing what you expect. AndrewWTaylor (talk) 12:30, 22 July 2013 (UTC)[reply]
Are you sure the problem is in the MOD function ? In the second half of your original formula you have
INT(60*MOD(24*SUM(O1102:O1147),1)+1/24)
Walking through this step by step ...
  1. If 24*SUM(O1102:O1147) is just less than an integer ...
  2. ... then MOD(24*SUM(O1102:O1147),1) will be just less than 1...
  3. ... so 60*MOD(24*SUM(O1102:O1147),1) will be just less than 60 ...
  4. ... so 60*MOD(24*SUM(O1102:O1147),1)+1/24 may then be just greater than 60 ...
  5. ... and INT(60*MOD(24*SUM(O1102:O1147),1)+1/24) will give the result 60.
Can you explain why you are adding 1/24 in step 4 ? Gandalf61 (talk) 13:04, 22 July 2013 (UTC)[reply]
Ah, no I can't - it seems strange to me now. Unless I find a simple example, let's call this closed. Cheers. -- SGBailey (talk) 13:09, 22 July 2013 (UTC)[reply]

Map Editor for In-car GPS navigation device edit

Does there exist a map editor to run on a Windows PC that

  • is able to open the map files used in a common brand (TomTom, Garmin, Mio, TeleAtlas, etc.) of GPS device. I want to plan a future journey and see what roads will be displayed.
  • allows me to add or edit information e.g. add a private access road or a local name.
  • is cheap or free ? DreadRed (talk) 14:17, 22 July 2013 (UTC)[reply]
Off the top of my head, I can't think of something that will open the proprietary formats of the listed systems, nor give you complete control over writing to those files (I know of a couple that can read and perhaps convert, but not write), and it's unlikely that such an application would be free if it exists.  drewmunn  talk  14:57, 22 July 2013 (UTC)[reply]
OpenStreetMap allows you to export data in XML or raster-image format, and also provides a mechanism for extending and editing the data-set, using an in-browser interface, or using the programs Merkaartor or Potlatch 2. If you intend this data for personal use (and not for sharing and upload to the OpenStreetMap data project), then you can edit as much as you want, in as speculative a fashion as you desire.
Then you can export your new map data to a mobile device that is capable of interpreting the data. For example, here is a manual for installing an OSM data set on a Garmin-brand device. Nimur (talk) 15:13, 22 July 2013 (UTC)[reply]
I am trying to download base map in osm format and this HTTP request doesn't work: http://api.openstreetmap.fr/xapi?* [key=value][bbox=-70,12,62,84]. 2A02:8422:1191:6E00:56E6:FCFF:FEDB:2BBA (talk) 15:50, 23 July 2013 (UTC)[reply]

Why is China getting Class C subnets? edit

Why is China getting Class C subnets like say this one?

http://whois.arin.net/rest/net/NET-142-4-118-0-1/pft

I understand that China is a tiny little country with minute networking needs, but can't this all be swept under a single Class B so the rest of the world can just firewall that off? Hcobb (talk) 16:37, 22 July 2013 (UTC)[reply]

See IPv4 address exhaustion. Also Classless Inter-Domain Routing. Dmcq (talk) 10:30, 23 July 2013 (UTC)[reply]

Maps and ariel photos showing hotels edit

This past weekend I went on a trip to a meeting held at a convention center. I wanted to look at hotels near the convention center - close enough to walk. In the past, I've been able to go to websites that show maps or satellite photos and have it show me the location of all hotels. Last week I looked at four such websites and now I could not see how to have it show me all hotels - they would show me only ones from certain chains. (The chains were different on different websites.) I suspect that the only hotels a website would show are paid sponsors. Is there a good website that shows all hotels near a location? Bubba73 You talkin' to me? 16:44, 22 July 2013 (UTC)[reply]

This site claims to do just that, using your exact location. I haven't used it though so I can't gurantee it's usefulness. Hope this helps, --Yellow1996 (talk) 16:49, 22 July 2013 (UTC)[reply]
That website finds hotels near your current location. I don't see any way to specify the location. I want to check prices and make reservations for where I am going. Also, it is useful to have an aerial photo, for instance I would have been able to see that one hotel was just across the parking lot and two others wer just across the street. Bubba73 You talkin' to me? 18:24, 22 July 2013 (UTC)[reply]
I was in a sub-section of this site. The page I've just linked to allows you to specify a specific address. As for aerial pictures, I'm not sure. --Yellow1996 (talk) 01:15, 23 July 2013 (UTC)[reply]
That is better. There is an option to map up to 5 hotels, but it doesn't work, even if I have some selected. Bubba73 You talkin' to me? 01:23, 23 July 2013 (UTC)[reply]
Doesn't work for me, either. There must be a bug in the site that doesn't register when the radio buttons are checked off, so it always thinks you don't have any selected... --Yellow1996 (talk) 01:29, 23 July 2013 (UTC)[reply]
Your heading uses "ariel" instead of "aerial". Please see "Aerial" and wikt:aerial.
Wavelength (talk) 17:06, 22 July 2013 (UTC)[reply]
You're right - I can't spell. Bubba73 You talkin' to me? 18:20, 22 July 2013 (UTC)[reply]
Google maps will do this. Zoom in to the right area (maybe just a few streets across), then type "hotel" into the search box. Google will place markers on hotels and even smaller motels and B&B places (and also the odd business supplying hotels with things). You can zoom out a little and pan around to find something to meet your requirements.
Similar features are available on other sites like tripadvisor.com, laterooms.com, hotels.com and so on. Of course, many are restricted to hotels that either have availability for the dates you select and/or are advertised on the specific site, but even for pretty obscure locations I can find plenty of places to stay. Astronaut (talk) 16:04, 23 July 2013 (UTC)[reply]
Thanks, Google Maps worked. I had tried TripAdvisor and Hotels.com last week, but they did not show me all of the hotels - only a few, IIRC. But perhaps there were no rooms available for the ones it didn't show. Bubba73 You talkin' to me? 03:43, 24 July 2013 (UTC)[reply]
  Resolved

Help with map generator code edit

I am doing a map genedator with python.
User are able to select the map size (x and Y) and it generate a map.
The problem I can't find a way to create each pixel in the order I want.
A some example:
With my original idea if the user selected a 3x3 map it would create the map this way, selecting how each map pixel will be one after another
323
212
323
1=This pixel of the map is selected first.
2=All the pixels with this number are selected
3= All pixels with this number are selected

as some example, the same idea with 5x5 map
54445
43234
42124
43234
54445

but my map generator create the map like this:
as some example a 3x3 map
123
456
789

This is the actual code that produce it

   for row in range(len(object.tile_list)):
        
       for collumn in range(len(object.tile_list[row])):
              ALL THE MATH AND RULE STUFF THAT WILL SELECT WHAT THE PIXEL OF THE MAP WILL BE

How could I create a code that do as I said? — Preceding unsigned comment added by 201.78.179.109 (talk) 18:07, 22 July 2013 (UTC)[reply]

You haven't really described why a given point in the desired map takes its value. For example, I don't see why the 4 values in the middle of the edges of the 5x5 map aren't 3 instead (why is 4 right and 3 wrong?). What you're essentially doing is creating a function in two variables and then iterating over that, sampling it at integer intervals. There are many functions in two variables which can produce a symmetrical pattern somewhat like these; linear (arithmetic), geometric, distance, etc. To write code, you'll have to figure out a more formal definition of what the right answer is. -- Finlay McWalterTalk 20:05, 22 July 2013 (UTC)[reply]
This map generator would produce the map based on some statistics. It would select the first pixel(area) at random and continue from there. If some square you are generating is connected to a square that is already generated, it has 90% chance of being of the same time and 10% of being of a different type (what this different type will be is based on some rules).
Based on my rules diagonal squares are not connected to some square. So, witha 5x5 map it start map creation with square 1, and then continue by selecting all the closest connected squares (at the same time) to already generated squares (square 1), those squares are the squares 2. Then it continue by selecting all the closest connected squares (at the same time) to already generated squares (square 3).
Remember I said that a square connected to other have 90% of being the same. when creating multiple squares at the same time, you do all squares at the same time, on a board like this:
323
212
323
The 90% math would be make to each square 2 separated. As some example you would do the check one time to each 'square 2' (so do the check 4 times), as some example, if you get less than 10% on the first square, you will just change the type of this square, you will need to do the same test 3 more times(one to each other square)to know you will keep them with the same type of change them. — Preceding unsigned comment added by 201.78.179.109 (talk) 20:45, 22 July 2013 (UTC)[reply]
Your description of selecting the NSEW adjacent squares and processing them sounds a lot like a flood fill, only one where the "colour" mutates (by your 90% rule) rather than being constant. I have Python code for that (which handles recursion with a queue or stack) at File:Wfm floodfill animation queue.gif. If you used that, but changed a couple of lines:
 if img.getpixel((x,y)) == targetcolour:
   img.putpixel((x,y), newcolour)

to

 if img.getpixel((x,y)) == uninitialised:
  if random.randint(1,10) == 10:
    newcolour = randomise_new_colour()

  img.putpixel((x,y), newcolour)
that might make for a nice terrain -- Finlay McWalterTalk 21:23, 22 July 2013 (UTC)[reply]
Thanks will check that when I have, time. While vising some website I had the idea of a map generator based on world statistics, of course this data would be hard to get, this idea stuck into my head and I decided to try with chess statistics by hand, but then I discovered some rpg (rhand morningstar missions), that had some terrain statistics (dm can roll a d100 to check how the area (6 mile diameter hexagon) he will enter will (there is 5 main ground types) be, and if he is leaving this terrain he can roll again for the next terrain (because this is connected to the old one, there is 90% of the ground type being the same). I posted this idea last friday on a forum while we were discussing rpg settings (while also posting the rpg statistics) and some made a python code for me that generate a map in ascii text, but he gone and I decided to change it (never coded with python before) to better suit my original idea and fix some of his bugs, but the main part that was very diferent is the order that it generate the terrain.
Here is the wip code http://pastebin.com/vfXN79d3 201.78.179.109 (talk) 12:54, 23 July 2013 (UTC)[reply]
I am back again, looking at the flood fill gave me some idea. Doing something like this:
1-create a counter variable and put its value as 0. 2-create a list of pixels and put the first value as pixelist[0] as the middle pixel of map. 3-do a while that repeat until (counter +1) < amount of pixels on map. 4-Check the pixel on pixelist[counter] and check the connected squares, if they are empty and were not added to the pixelist before, add them to the pixelist. 5-Check connected squares of the pixel pixelist[counter], if no connected square pixelist[counter]= random value, if it has connected squares do the math based on connected squares to find its value.6-Counter = counter +1
This created a program that on a 3x3 map would create the map this way:
726
514
938
Instead of my original idea of
323
212
323
Anyway thats way better than what the initial code was doing.
Thanks for the recommendations and here is the lastest code that use the ideas I said here, if anyone wants to try and check. Remember I start never coded with phyton until 2 weeks ago and I started to do it with that code. So if the code is a mess, you know why. http://pastebin.com/1jbxf8QD

Censorship in Hong Kong edit

I've been asked why people in Hong Kong would not have access to the site HeartsSpeak.org. HS is a non-profit that helps connect photographers with animal shelters who could use their artistic assistance. I don't know exactly what they mean by "can't access" and I can think of no technical reason why they'd have any issues. Would this be blocked by the Great Firewall of China? Would users get a standard error page saying that the site they are trying to access is blocked? Is HK even affected by the Firewall? I didn't see any mention of HK specifically in the article on the Firewall. Dismas|(talk) 19:06, 22 July 2013 (UTC)[reply]

It's apparently not blocked by the GFWoC. -- Finlay McWalterTalk 20:11, 22 July 2013 (UTC)[reply]
I call shenanigans on http://www.greatfirewallofchina.org - its "OK/FAIL" indicator does not provide enough meaningful information to determine anything. I suspect the pass-fail criteria is entirely based on whether a DNS lookup succeeds or fails, and nothing more. A domain name server that fails to resolve a lookup is not the same as a network firewall that is dropping or blocking network traffic - even if the superficial symptoms look similar to an average end-user. Nimur (talk) 22:49, 22 July 2013 (UTC)[reply]
GFWoC does not filter Hong Kong. So it will be irrelevant. Graeme Bartlett (talk) 10:19, 24 July 2013 (UTC)[reply]

Thanks, all! I guess I'll just have to find out what they mean by "can't access" and go from there. Dismas|(talk) 10:53, 24 July 2013 (UTC)[reply]