Wikipedia:Reference desk/Archives/Computing/2010 June 16
Computing desk | ||
---|---|---|
< June 15 | << May | June | Jul >> | June 17 > |
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. |
June 16
[edit]Using Open Streem Map within our GPS softwares
[edit]Dear colleagues,
Good day. I am Sayed Habibullah from Kabul Afghanistan. I am wondering if anyone could help me with the question I have, I am using a GPS AVL software for tracking. I have Installed the GPS device into a car and would like the car to start its Travel from Kabul city initially where it will help me to update the OSM Afghanistan Map with accurate address and would like to move on provinces one by one.
Would you be able guide me how can I use/link the OSM in my software so that I am able to see the tracks and location of the car with GPS installed in OSM map within the software I use?
Thanks in advance.
Sayed from Kabul —Preceding unsigned comment added by 58.147.151.122 (talk) 03:52, 16 June 2010 (UTC)
- There is a help section on the OpenStreetMaps wiki: Recording GPS Tracks. That wiki may also be your best source of information for other OSM technical issues. Nimur (talk) 14:22, 16 June 2010 (UTC)
How to remove a folder which isn't there
[edit]I have a folder on my pc which I cannot delete because "this is no longer located in .... Verify the item's location and try again." It's been there for several months, though multiple updates, restarts, shutdowns, chkdsks, virus/adware/spyware scans. It cannot be deleted, moved or renamed because it's not there. If I try putting anything in the folder, a duplicate folder appears which can be deleted but when deleted leaves the old folder.
Any suggestions as to how to remove this once and for all? I run Win7, HD is NTFS. -mattbuck (Talk) 04:09, 16 June 2010 (UTC)
- Where does this folder appear ? On the Desktop ? StuRat (talk) 04:15, 16 June 2010 (UTC)
- Downloads folder. -mattbuck (Talk) 04:55, 16 June 2010 (UTC)
- In that case, how about if you delete the "Downloads" folder, which should take any sub-folders with it. Then recreate the "Downloads" folder. Of course, if there's anything else in the "Downloads" folder you want to keep, you'll need to move that to somewhere else ("Downloads2" ?) until the folder is recreated, then move it all back. StuRat (talk) 14:45, 16 June 2010 (UTC)
- The folder might have a trailing space or dot in the name, or be named "con" or "prn", or otherwise be invalid to Win32 but valid to the NT kernel. Cygwin 1.7 can remove (and create) such files. It is possible to name these files in Win32 with a path beginning with "\\?\", e.g., "\\?\C:\Users\Mattbuck\Downloads\abc.", but not all software supports this. Unfortunately, cmd.exe seems not to. -- BenRG (talk) 06:48, 16 June 2010 (UTC)
- You can delete prn with cmd.exe on NTFS volumes. I've done it before. [1] describes various ways I can't recall which one I used. You may need POSIX compatible utilities. Windows 7 also comes with Windows Powershell by default which may help. BTW has the OP tried safe mode? Nil Einne (talk) 09:28, 16 June 2010 (UTC)
- The folder name has a # and a space in it, but is otherwise alphanumeric. It is not "con" or "prn". I have not tried safe mode. -mattbuck (Talk) 13:02, 16 June 2010 (UTC)
- You can delete prn with cmd.exe on NTFS volumes. I've done it before. [1] describes various ways I can't recall which one I used. You may need POSIX compatible utilities. Windows 7 also comes with Windows Powershell by default which may help. BTW has the OP tried safe mode? Nil Einne (talk) 09:28, 16 June 2010 (UTC)
Often, rebooting the computer will either cause that sort of thing to go away of its own accord, or to let you delete it. ╟─TreasuryTag►Not-content─╢ 09:34, 16 June 2010 (UTC)
"It's been there for several months, though multiple updates, restarts, shutdowns, chkdsks, virus/adware/spyware scans" Nil Einne (talk) 09:36, 16 June 2010 (UTC)(Feel free to delete if you want)
Googling the error message suggests trying to rename or delete it from cmd.exe using the dos-compatible 8.3 filename, which can be seen with dir /x. —Korath (Talk) 10:30, 16 June 2010 (UTC) Tried a Linux live CD? 121.72.182.145 (talk) 12:32, 16 June 2010 (UTC)
C++
[edit]In managed C++ "->" is used to de-reference pointers but this isn't used anywhere for any reason in unmanaged c++ is it? Just revising for an exam; was doing last year's paper as a practice and one of the questions used "->" to dereference an unmanaged object in some example code. Typo? Thanks, Benjamint 10:28, 16 June 2010 (UTC)
- It's the same in both managed and unmanaged C++. (Pedantically, derefencing a pointer looks like *a; a->b is member b of the object pointed to by a.) —Korath (Talk) 10:36, 16 June 2010 (UTC)
- Like Korath says, the arrow operator is specifically used to access a member of a class - although it implicitly dereferences the pointer (unless the operator has been overloaded). Additionally, "->" is used in C++'s pointer-to-member operator, "->*". I would think Managed C++ has the same operator. C++/CLI certainly does.
decltype
(talk) 10:53, 16 June 2010 (UTC)
Another C++
[edit]code fragment:
class A {
public:
virtual void func() { cout << "calling from A" << endl;
};
class B : public A
{
public:
virtual void func() { cout << "calling from B" << endl; }
};
A a = new B();
a.func();
what is the behaviour of a? since the actual object is of type B I'm assuming it will call B's func()? Thanks again Benjamint 10:47, 16 June 2010 (UTC)
- I took the liberty of adding syntax highlighting to your comment, for readability.
decltype
(talk) 10:55, 16 June 2010 (UTC) - As you can see from the syntax highlighting, you have made a few typographical errors, and your declaration is also ill-formed. Assuming you intended to write
"A * a = new B(); a->func();"
(note the arrow operator!) then yes, it would call B::func().decltype
(talk) 10:59, 16 June 2010 (UTC)- thanks a lot ;) it's actually both ways, two parts to the question, a) being with a pointer and operator-> while part b) is what I transcribed here (exactly apart from the missing " ) Benjamint 11:13, 16 June 2010 (UTC)
- There's also a missing "}" in A::func(). I suppose this example is only intended to demonstrate virtual functions - For real code, you would really, really need a virtual destructor in A, or you'd have undefined behavior upon deleting a. Ideally, the functions should also be declared const.
decltype
(talk) 11:24, 16 June 2010 (UTC)
- There's also a missing "}" in A::func(). I suppose this example is only intended to demonstrate virtual functions - For real code, you would really, really need a virtual destructor in A, or you'd have undefined behavior upon deleting a. Ideally, the functions should also be declared const.
- The assignment
A a = new B();
won't compile because the type ofnew B()
isB*
, and there's no constructor for A which takes aB*
. If you wroteA a = B();
orA a = *new B();
thenA::func
would be called, notB::func
. What happens in this case is that A is constructed using its implicit copy constructorA::A(A const&)
, with a reference to the heap-allocated or temporaryB
object as the argument. The copy constructor copies all the data members (there are none in this case) but not the original type of the argument. Variables declared as having type A always have type A, never a subclass of A. -- BenRG (talk) 23:07, 16 June 2010 (UTC)
- The assignment
- One remaining possibility is
A& a = *new B(); a.func();
, where a "reference to A" is bound to the B object, or more precisely, to the A sub-object within B. Still, since the function is declared virtual, the code ends up calling B::func() because the call is resolved dynamically.decltype
(talk) 05:56, 17 June 2010 (UTC)
- One remaining possibility is
Drivers
[edit]1) According to System information for windows I have Raid Controller hardware installed, but it is not working (error 28) because I think the driver is missing. Is it possible to download a free driver from somewhere please? I am using WinXP. I would prefer not to install a driver update scanner as my experience in the past was that they are not very helpful.
2) Would I notice any improvement if I did get the Raid thing working?
3) I do not seem to have any Nvidia hardware. Even so, might I have Nvidia drivers installed on something? Any way of checking? I bought this old computer second-hand, and it has traces of Nvidia that I would like to delete, perhaps due to hardware changes before I got it. Thanks 92.28.251.43 (talk) 12:01, 16 June 2010 (UTC)
Slow starting Windows 7 install?
[edit]So there's a computer with i7-930, 6GB DDR3 1600 and VelociRaptor. It is not slow in any way. I was installing Windows 7 on it and noticed the installer took a very long time to load. Anyone know why? The same disc loads the installer quickly on other computers. 121.72.182.145 (talk) 12:39, 16 June 2010 (UTC)
- If it feels the need to check memory and do a disk scan, then more memory and disk space could make it take longer. Some install programs give you the option to skip such checks. StuRat (talk) 14:38, 16 June 2010 (UTC)
- Could be a slower optical drive, too. Installing from USB is much faster (IMHO). Indeterminate (talk) 16:36, 17 June 2010 (UTC)
Address bar and title bar unchanged
[edit]The article Vuvuzela has a list of references, of which the one now numbered 49 links to the following page, and the quoted expression links to another page, and so on.
- http://www.sport24.co.za/Soccer/WorldCup/NationalNews/Vuvuzelas-unplugged-for-some-20100611 ("website")
- http://www.webtickets.co.za/ ("11 Jul 2010 Vuvuzela™ - Collection")
- http://www.webtickets.co.za/event.aspx?itemid=1644602 ("www.vuvuzelaunplugged.com")
- (new window) http://www.vuvuzelaunplugged.com/ ("Noise Reduction Rate")
The next page is the Wikipedia article Earplug, with the links at the top of the page showing that I am logged into Wikipedia, but the address bar and the title bar are unchanged. Also, I can not go back to the previous page. How can this be explained?—Wavelength (talk) 17:45, 16 June 2010 (UTC)
(For clarity, I am reorganizing slightly my first message.) Also, the links at the top of page ("Wavelength", "my talk", "my preferences", "my watchlist", and "my contributions") work as usual, but the address bar and the title bar are still unchanged. I did not want to test the "log out" link.
—Wavelength (talk) 18:56, 16 June 2010 (UTC)
- www.vuvuzelaunplugged.com is just a frameset with a single frame that contains www.tulazela.com. Because the page is a frameset, by default any links you click on the page remain in the frame, and the address and title stay the same. --Bavi H (talk) 01:04, 17 June 2010 (UTC)
- Thank you. After I read your reply, I read some of the Wikipedia article Framing (World Wide Web) (permanent link here), and points 1 and 6 of the section "Critique" seem to describe aspects of my experience. Also, the article reminded me of transclusion, but I suppose that there are some differences between using framesets and using transclusion.—Wavelength (talk) 06:28, 17 June 2010 (UTC)
Save my old Mac as some kind of image in my new Mac
[edit]Hi all,
I just got a new laptop, and instead of imaging over from my old machine with all of it's crud, I installed a fresh copy of Mac OS X 10.6, and brought over just the files I need from the old computer (Mac OS X 10.5). However, I know that I'll be needing more files from the old one as times go on, and from places that I'd never remember to copy over (usr/opt/bin/etc or whatever). I have five times the amount of hard drive space on my new computer as on my old one, so I'd love to simply place everything in my new computer, or on an external harddrive.
The best option would be some kind of bootable image. I use VirtualBox, but I don't know if I could create a virtual machine of my old machine on my new one. Is there some way I could create a bootable image to put on my hard drive?
Alternatively, some other kind of easily accessible image would be fine.
What are my options, and how would I do them? Thanks! — Sam 63.138.152.135 (talk) 17:58, 16 June 2010 (UTC)
- Hi Sam. I'm not familiar with the ins and outs of making disk images (despite having used OS X since it came out) but I suspect you would be able to do something with Disk Utility, make a disk image of your old hard disk (saving the new file on an external drive) and use that. You could also buy a USB hard disk cradle which lets you use a 'naked' internal hard drive as an external one, then just stick your old HD in there. The forums on Macrumors are pretty busy and no doubt there'll be someone there with the expertise you're after. Brammers (talk/c) 18:38, 17 June 2010 (UTC)
- You can use
dd
to image a disk - first usedisktool -l
to list the disks, and figure out which one is the disk you want to image (it'll be called something like/dev/disk3s10
. Then, as root,dd if=/dev/disk3s10 of=/somewhere/image.dmg
VirtualBox should allow you to mount that .dmg file as a disk. -- Finlay McWalter • Talk 18:50, 17 June 2010 (UTC)
- If you want it to be bootable, you pretty much need to make it a partition, not just an image file. As long as the both machines have FireWire, you can do this fairly easily with Disk Utility:
- Back up your new system, just in case anything goes catastrophically wrong. Time machine's an easy option, if you don't already have a system in place.
- Create a new partition on your HD by selecting your new computer's HD in the Disk Utility sidebar (note: select the drive, not the volume listed under it), then the Partition tab on the right, then "+" under the partition view, then adjust the slider to control how much space it gives the new partition. When you have it set as you'd like, click Apply, and wait for it to do its magic.
- Put the old laptop in Target Disk Mode by powering it on with the "T" key held down (hold until you see a FireWire icon on the screen); this essentially turns it into an external FireWire drive. Plug in a FireWire cable between it and the new computer, and it'll mount on the desktop.
- Back in Disk Utility, select the Restore tab. Drag your old volume (this time you want the volume, not the disk) into the Source field, and the new (blank) partition in as the Destination. Make sure that Erase destination is selected, and double-check that the Destination is the volume you want to clone to. Click Restore, then wait for it to copy.
- Alternately, if you don't need the backup to be bootable, you can store it in a disk image:
- Put the old computer in Target Disk mode (step 3 above).
- In Disk Utility, select File > New > Disk Image from Folder from the menu (note: you can also create the image from a unix device, but Folder mode is generally preferred because it doesn't image "empty" space on the drive).
- In the Select Folder to Image dialog, select the root of your old HD.
- In the New Image from Folder dialog, select someplace on your new drive to store the image; you might also want to switch the Image format from compressed to read-only (faster to create, but takes up more space) or read/write (makes the contents modifiable).
- If you make an image and then later decide you want to recover it to a bootable partition, you can do that (if it's compressed or read-only) by scanning the image for restore (under the Images menu) then using the Restore tab with the image as source. 72.1.134.20 (talk) 22:48, 18 June 2010 (UTC)
Computer control
[edit]I'm trying to get started in pursuing robotics as a hobby. For my first "project", I want to use the computer to send a single voltage down a single cable for a predetermined length of time. What I mean is that if I connect a cable (headphone, Ethernet, serial, etc.) to the computer, and measure the voltage between two of its leads using a multimeter, I should get the voltage I asked the computer to send.
Is this possible? Is it possible with the audio port, and if not, which port should I use? Where can I find a tutorial on how to do this? I know programming, but I've had no experience controlling computer hardware with software. --Bowlhover (talk) 18:06, 16 June 2010 (UTC)
- Hobby electronics with modern PCs is a bit of a pain. In the old days computers often had a "feature connector" or at least a programmable parallel port, which you could easily hook up to external electronics. Modern computers have modern interface ports, which are controlled by smart (and mostly non-programmable) microcontrollers - so it's very difficult to wring General Purpose Input/Output (GPIO) from ethernet, serial, or usb ports. A nice option is to buy (they're not terribly cheap, unfortunately) a little adapter board that sits on USB and gives you GPIO and programmable analog IO - Google found this one (which looks very nice, but I've never actually used it). -- Finlay McWalter • Talk 18:28, 16 June 2010 (UTC)
- Since doing this from the computer is difficult, as far as I am aware, and since devices like the one linked above are expensive, a better option would be to use a microcontroller. Simple ones like the Arduino and its clones cost $20-$30. Using an Arduino you can very easily create your suggested program to make any of its pins to be a certain voltage for a certain amount of time. Even better, and no more difficult, you can read a voltage from a pin, and so you can easily program behaviors like "if pin A reads above X, set pin B to Y," and so can do things like connect wheels to light sensors to navigate a little car. Best of all, you disconnect it from your computer after programming it to make it portable. Look up Arduino projects online to get a sense of its capabilities. — Sam 63.138.152.135 (talk) 18:52, 16 June 2010 (UTC)
- Regarding audio: yes, you can control the output to this, but it's not immediately useful. Say, for example, you set the audio output circuit up to 8-bit mono. That way you can send streams of bytes to the audio output, and by modulating that output you move the cone on a speaker and so play sound. But that only yields a voltage on the audio output when that stream is changing. It's the change that does work, that moves the speaker cone - the value you sent is the position you want the cone to be in. So (simplistically) an increasing stream of byte values yields a +ve voltage, a decreasing stream yields a -ve voltage (the magnitude of that voltage is proportional to the slope on the byte stream, so really its the first derivative
wrtof the byte values wrt time). The trouble is that when the byte stream gets to 255 it maxes out, so there's no more change, so there's no more voltage (i.e the voltage drops to 0). Ditto for falling to 0. So you can't post a constant voltage for more than a very short time, and so it's mostly useless for control applications. If you really want I can post some linux/cygwin code that does this, but I don't think it's worth your effort. -- Finlay McWalter • Talk 19:45, 16 June 2010 (UTC)
- But here's a hack: chop open a USB keyboard and redirect the three lines to the three indicator LEDS (numlock, capslock, scrolllock) - that's three lines you can control from software (they're just on/off output only), plus you can redirect keys (e.g. the numeric keypad) for input (bearing in mind the wiring of the switch matrix to make sure they're mutually independent). That's three lines out output and 108+ lines of input. In linux (on the console) leds can be controlled by setled ; I'd imagine there's some utility that does the same for Windows. -- Finlay McWalter • Talk 20:01, 16 June 2010 (UTC)
Thanks for the responses! I've investigated Arduino, and it doesn't have any analog output, only 5-volt PWM outputs. Unfortunately, that doesn't work; I need something that can output a constant voltage. The same goes for using the keyboard LED's and the speaker: they can't output a constant voltage for an arbitrary amount of time. Are there any microcontrollers that can output a true analog signal? --Bowlhover (talk) 23:38, 17 June 2010 (UTC)
Annoyance with Chrome
[edit]Sometimes, when I click on a link here on the RefDesks, Chrome downloads a .php file and doesn't open the link. I'm not sure why it does this, as it does it sometimes and doesn't do it other times. It appears to happen more often with internal links to archives. It doesn't happen with Firefox or Opera, but I'm not opening a whole new browser just to check something out on a link (unless it's totally necessary). Is there something in the settings for Chrome that I can alter so that it just does what it's supposed to do rather than giving me a .php file titled 'index'? --KägeTorä - (影虎) (TALK) 19:58, 16 June 2010 (UTC)
- It's seeing a content-type for which it thinks it doesn't have a handler. If you can give a concrete example of a link that makes it behave this way, we can see what's up. -- Finlay McWalter • Talk 20:05, 16 June 2010 (UTC)
- Cheers. I went over to the RefDesk Talk page (where this seems to happen most often) and lo and behold, first link I clicked on (the one in Cuddlyable's post about the troll) gave me a .php file. Let's see if we can sort this out. I can open it in Notepad, of course, and inside I see a link to the page, and some other code (?). --KägeTorä - (影虎) (TALK) 20:34, 16 June 2010 (UTC)
- That link works fine for me in Chrome on WinXP. DuncanHill (talk) 20:39, 16 June 2010 (UTC)
- Cheers. I went over to the RefDesk Talk page (where this seems to happen most often) and lo and behold, first link I clicked on (the one in Cuddlyable's post about the troll) gave me a .php file. Let's see if we can sort this out. I can open it in Notepad, of course, and inside I see a link to the page, and some other code (?). --KägeTorä - (影虎) (TALK) 20:34, 16 June 2010 (UTC)
- If you mean the link to the "uranus" diff in Wikipedia talk:Reference_desk/Miscellaneous#Delete banned user question, that link opens fine for me in Chrome 6.0.427.0 dev -- Finlay McWalter • Talk 20:39, 16 June 2010 (UTC)
- That's not the link I meant, but anyway, where you put 'that link' in your post just now, I get a .php file there, too.... It's just me? Even after reinstalling Vista last week and redownloading Chrome? --KägeTorä - (影虎) (TALK) 20:50, 16 June 2010 (UTC)
- Maybe your ISP is doing something to the data stream. I had a similar problem with my ISP where they were trying to save bandwidth or something but it just ended up giving garbled nonsense code to the end user 82.43.90.93 (talk) 22:18, 16 June 2010 (UTC)
- You would expect to see such a problem with any browser, though. -- Finlay McWalter • Talk 22:20, 16 June 2010 (UTC)
- Maybe your ISP is doing something to the data stream. I had a similar problem with my ISP where they were trying to save bandwidth or something but it just ended up giving garbled nonsense code to the end user 82.43.90.93 (talk) 22:18, 16 June 2010 (UTC)
- That's not the link I meant, but anyway, where you put 'that link' in your post just now, I get a .php file there, too.... It's just me? Even after reinstalling Vista last week and redownloading Chrome? --KägeTorä - (影虎) (TALK) 20:50, 16 June 2010 (UTC)
- If you mean the link to the "uranus" diff in Wikipedia talk:Reference_desk/Miscellaneous#Delete banned user question, that link opens fine for me in Chrome 6.0.427.0 dev -- Finlay McWalter • Talk 20:39, 16 June 2010 (UTC)
- Try appending chrome://net-internals/view-cache/ to the beginning of problematic addresses to view the item from the Chrome cache, then see what it says for Content-Type. For example 'that link' above becomes chrome://net-internals/view-cache/http://en.wikipedia.org/w/index.php?title=Wikipedia:Reference_desk/Miscellaneous&action=historysubmit&diff=366268824&oldid=366267489 --Bavi H (talk) 00:27, 17 June 2010 (UTC)
- Cheers. This is what I got:
Content-Type: application/x-external-editor; charset=UTF-8
X-Cache: MISS from sq65.wikimedia.org
X-Cache-Lookup: MISS from sq65.wikimedia.org:3128
X-Cache: MISS from amssq37.esams.wikimedia.org
X-Cache-Lookup: MISS from amssq37.esams.wikimedia.org:3128
X-Cache: MISS from amssq33.esams.wikimedia.org
X-Cache-Lookup: MISS from amssq33.esams.wikimedia.org:80
I don't understand the code, but I guess this reveals at least something about what the problem may be (I'm guessing the word 'miss' may mean something?). --KägeTorä - (影虎) (TALK) 01:34, 17 June 2010 (UTC)
- When I searched for application/x-external-editor, I found a Wikipedia / MediaWiki help page about External editors that suggests your Wikipedia Preferences → Editing → "Use external editor by default" option might be turned on. --Bavi H (talk) 03:43, 17 June 2010 (UTC)
- After experimentation, it looks like it's the next option "Use external diff by default" that's causing 'that link' above to be returned with application/x-external-editor, and if there's no program defined for that type, Chrome just downloads it. The solution would be to uncheck that option. Or setup an appropriate program I guess. --Bavi H (talk) 03:56, 17 June 2010 (UTC)
- Gentlemen, we have a genius in our midst... That has indeed fixed it! Now, I wonder why my editing preferences were set in such a way.... Anyway, right, thanks!! --KägeTorä - (影虎) (TALK) 10:13, 17 June 2010 (UTC)
- You're welcome :) The genius troubleshooting was, of course, a group effort: Finlay McWalter started us on the right track when he suggested the content-type was the problem. --Bavi H (talk) 00:41, 18 June 2010 (UTC)
PHP Question
[edit]I have a php script that adds entries as lines to a flatfile. I would like it to somehow detect if there are more than 20 lines in the flatfile, and automatically delete the excess bottom lines if there are. Is this possible? How could I do it? Thank you 82.43.90.93 (talk) 20:10, 16 June 2010 (UTC)
- The most straightforward way is to read the the file into a variable, use explode('\n', $var) to chunk it into an array, use array_unshift() to add the new line to the top of the array, and then shorten the array to 20 elements. Then implode() it and write it back out to disk. or you could read the file in line-by-line using fgets(), build the output text as a string and write it back out after you've read 19 lines. I'm not sure which would be more efficient, but I personally prefer to work with arrays. --Ludwigs2 20:29, 16 June 2010 (UTC)
- I'm still very new to php, and I don't really understand functions or how to use them just by their names. It helps me to see an example code, then I can play with it and try different things until it works for me. I know it's asking a lot, but could you give an example script for this? Thank you :) 82.43.90.93 (talk) 20:54, 16 June 2010 (UTC)
- You really should have a copy of the PHP manual on your system, so you can look things up. Under the PHP manual, look under "Array functions," and you'll find a list of all of the functions that have to deal with arrays, for example. Under "Filesystem functions," you'll find all the ones to do with reading files. It's an essential part of programming with PHP, because nobody remembers all of the functions—you just remember where to look them up. PHP has a ton of useful functions that can do almost anything you can imagine you'd want to do with them, but their names and variables are idiosyncratic and need to be looked up quite often. The only things you really need to have memorized are control structures, like while and for.
- Here is code that will make sure the file is no longer than 20 lines:
ini_set('auto_detect_line_endings', true); //autodetect file line endings -- useful thing to do first
$file_array = file($yourfile); //read $yourfile into a string array
while(count($file_array)>20) { //while the total array length of the file is greater than 20...
array_pop($file_array); //removes the last element of the file array
} //end of the while block
- Now you'd need to write $file_array back into the file again. --Mr.98 (talk) 22:53, 16 June 2010 (UTC)
- I don't know PHP, but could this possibly be done more efficiently? If the file is something like 100 lines, you end up iterating over that loop 80 times Can't you remove more than one element in a single operation?
decltype
(talk) 12:04, 17 June 2010 (UTC)- Sure, there are a million ways to do it. array_slice is probably the most straightforward, as I look into the manual again. --Mr.98 (talk) 14:22, 17 June 2010 (UTC)
- Hmmm, so would something like work?
$file_array = array_slice( file($yourfile), 20);
decltype
(talk) 09:20, 18 June 2010 (UTC)
- Hmmm, so would something like
- Sure, there are a million ways to do it. array_slice is probably the most straightforward, as I look into the manual again. --Mr.98 (talk) 14:22, 17 June 2010 (UTC)
- I don't know PHP, but could this possibly be done more efficiently? If the file is something like 100 lines, you end up iterating over that loop 80 times Can't you remove more than one element in a single operation?
- Now you'd need to write $file_array back into the file again. --Mr.98 (talk) 22:53, 16 June 2010 (UTC)
- I do this regularly, but it is system-dependent. Because I never run anything on a Windows or Mac, I expect to have the standard Linux/Unix commands. So, I just add this line to my PHP code: exec("tail $FILENAME > tmp; mv tmp $FILENAME"); However, there is a race condition there. If you have a busy site, it is very possible that you will end up erasing the file all together, which is the main reason I am adding to these answers...
- You will want to lock the file before working with it. It is a bit trivial. First, you want to create a locking file: $lock = fopen("mylock","a"); Then, you want to get a lock on that file. Use an exclusive lock just to ensure nothing bad happens. while(!flock($lock, LOCK_EX)); Notice that ends with ;. It will wait forever to get a lock on the file. That isn't good. It should timeout, but I'm trying to keep it simple. When you get exclusive lock, then you can work with it. Remember, lock it before writing to it or removing excess lines. Always lock it first. When you are done working with it, just unlock it with flock($lock, LOCK_UN); -- kainaw™ 12:06, 17 June 2010 (UTC)
Thank you everyone for the help :) I tried Mr.98s code but I just end up with the text "Array" in the file 82.43.90.93 (talk) 14:08, 17 June 2010 (UTC)
- Then you're not writing it correctly. If you try to just print or output an array as an array, you get "Array" as a response. You need to either iterate over the array and print out each element, or you need to convert it to a string. An easy way to do convert an array into a string of values separated by newlines would be to use $array_string = implode("\n", $array);. To iterate over the array, use a foreach construct. --Mr.98 (talk) 14:22, 17 June 2010 (UTC)
Why is it so big? Are the libraries of a bunch of languages included? --Rajah (talk) 20:38, 16 June 2010 (UTC)
Also, "Xcode 3.2, the latest major version, is bundled free with Mac OS X v10.6, but is not installed by default." does that mean if a Macbook is running Snow Leopard it is already on the hard drive? If so, how to install it from the hard drive instead of downloading? --Rajah (talk) 20:40, 16 June 2010 (UTC)
- I can't answer your first question, but can have a go at the second. If 10.6 is anything like 10.4 (which I have on my (very old) iBook, then anything which is not installed by default will be on your install disk. --KägeTorä - (影虎) (TALK) 20:53, 16 June 2010 (UTC)
- Right—it's on your OSX DVD, under "Optional Software" or something like that. (Along with Quicktime 7, if one tires of the dumbed-down Quicktime X.) --Mr.98 (talk) 00:38, 17 June 2010 (UTC)
- As for size, looking at my own install (my "Developer" directory), the biggest folders are "ADC Reference Library" (900 MB), "SDKs" (342 MB), "Applications (160 MB), and a folder called "usr" (150MB). The "Reference Library" looks primarily like documentation; SDKs has a bunch of code; "Applications" contains the Xcode application and other utilities for coding; "usr" has compiler binaries in it. Seems like an awful lot of space devoted to documentation if you ask me—620MB of which are just HTML files, 30,000 of them! --Mr.98 (talk) 00:38, 17 June 2010 (UTC)
- Especially considering most developers are usually connected to a worldwide network of computers that they can search for documentation. Thanks for all your answers! --Rajah (talk) 01:32, 17 June 2010 (UTC)
Color (Laser Printer)
[edit]Are the color printers like this any good ? How are their results ? Are they economical enough to use ? Is the quality like standard color magazines we see or inferior ? Jon Ascton (talk) 20:44, 16 June 2010 (UTC)
The specs for the indicated printer don't seem that great. If you want a printer which produces magazine-quality color prints yet is pretty economical, you should be looking at certain inkjet printers rather than laser printers. I would personally recommend the Hewlett-Packard Officejet Pro 8500 All-in-One A909b Printer (CB862A). I bought mine for less than US$400.Rocketshiporion (talk) 02:44, 17 June 2010 (UTC)
- Magazines use offset printing. Offset printing is a wonderful technology -- both cheap per copy and high quality. But, as you can see from the picture in the entry I linked to, offset printing presses aren't available to you and me.
- The best color prints you and I can get are printed by inkjet printers. The dye-based inks that come with most inkjets blend colors well, but they aren't as great at producing sharp, clear text. Laser printers excel at printing precise shapes (e.g., text). The best tradeoff I've found is the Canon Pixma iP4700. It has five ink cartridges inside:
- cyan (dye based),
- magenta (dye based),
- yellow (dye based),
- black (dye based), and
- black (pigment based).
- So, not only do the photos look great, but it also prints very sharp text, because it uses a pigment-based ink for text. You can buy one for only $50 online. Plus, the ink isn't very expensive, because the printheads are separate from the ink cartridges in the Pixma. As you may have guessed, it's what I use. But no matter what printer you use, don't try to save money on paper. You won't get good results unless you use high-quality paper.
- On another note, I'm not a big fan of HP printers, because they have a tendency to jam. I'm a computer repairman, so I've actually had some calls to remove jams from the HP OfficeJet 8500 mentioned above. Laser printers are also high maintenance. You have to clean out a laser printer each time you replace the toner, or the rollers will start to foul your paper.--Best Dog Ever (talk) 03:25, 17 June 2010 (UTC)
Computer security and privacy online test
[edit]Is there anywhere I can test my browser online to see for example which ports I've got open that could be closed and so on? I tried www.bcheck.scanit.be but it was not anywhere as good as something I'd tried in the past, nor did it tell me how to make improvements such as closing ports etc. I understand that the more stealthy your browser is, the lower the risk of malware problems. Thanks 92.28.251.43 (talk) 16:21, 16 June 2010 (UTC)
- Open ports are usually unrelated to your browser. As for your question, there are plenty of online port testing utilities which a simple search will find. I suggest you try a bunch like [2], [3], [4], [5], [6] until you find something you like. They're mostly free after all. Also may I suggest the computing desk for this sort of question in the future. Nil Einne (talk) 18:14, 16 June 2010 (UTC)
- Sorry posted in wrong place by mistake, and I suppose I meant computer rather than browser. 92.15.1.238 (talk) 20:54, 16 June 2010 (UTC)
The links above just mostly duplicate what the link in the original question does. I'm looking for something that can help turn my computer into "stealth" mode. 92.15.4.168 (talk) 12:04, 19 June 2010 (UTC)
- The solution may be to change the Firewall setting to "no exceptions". which surprisingly still allows internet access. 92.15.27.255 (talk) 19:40, 21 June 2010 (UTC)