Wikipedia:Reference desk/Archives/Computing/2015 June 8

From Wikipedia, the free encyclopedia
Computing desk
< June 7 << May | June | Jul >> June 9 >
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 8[edit]

How can computers allocate running time to a running program efficiently?[edit]

Given two scenarios, in the first the computer has to deal with tasks that require little time but full-power, and in the second there are the tasks that imply a long-processing time.

How can the computer know that the latter will take long to finish, so there is not point in giving it full-power, however, the first will take little time to finish, so give it full-power for a fraction of a sec, and you are rid of it.

Otherwise, how would the computer choose how much processing/memory each running process gets? --Llaanngg (talk) 00:27, 8 June 2015 (UTC)[reply]

While you're waiting for an explanation, a read of priority queue would probably help you out. Dismas|(talk) 01:10, 8 June 2015 (UTC)[reply]
Scheduling (computing) is the main article. Many operating systems use a multilevel feedback queue which gives less CPU time to processes that have used more CPU time recently, on the theory that they're less likely to finish soon. -- BenRG (talk) 10:42, 8 June 2015 (UTC)[reply]
In many cases how much CPU time a process should take should be highly predictable. For example, for any repeated operation, like rendering frames of a video, once you know the average CPU time to do one step (render one frame), it's just a matter of multiplying by the number of reps (frames) to get the total CPU time estimate. In other cases, like sorting, there's an average time and worst case time, both of which can be calculated before starting. Of course, just because it's easy to do doesn't mean it's actually done or that this info will be put to good use. StuRat (talk) 03:36, 9 June 2015 (UTC)[reply]

Strange characters on websites[edit]

Hello. Something is going on with certain fonts I see on some websites. Some special characters are showing up as the wrong character. For example, where I should see a ä, a appears. Ø shows up as ÿ, ñ looks like Ò, ë as Î, and so on. (I checked what the characters were supposed to be by copying and pasting the offending characters into Word.) It doesn’t happen with all characters; Basic Latin is unaffected, as are some lesser-used characters such as ă and ć. Cyrillic and Greek characters are also unaffected. And it is not apparent on an entire website. If the same character appears elsewhere on the page in a different font, it looks fine. What makes this happen?    → Michael J    01:01, 8 June 2015 (UTC)[reply]

Could be a font or encoding error, such as a font that doesn't have those characters or a non-Unicode font that's pointing to wrong characters because of that. RegistryKey(RegEdit) 05:22, 8 June 2015 (UTC)[reply]
Those particular errors are consistent with text that's encoded in Latin-1 or Windows-1252 being incorrectly decoded as Mac OS Roman. I suspect the problem is an old, pre-Unicode Macintosh font. -- BenRG (talk) 10:47, 8 June 2015 (UTC)[reply]
Is there a way to fix it? (I have a PC using Windows 7, not a Mac, by the way.)    → Michael J    15:08, 8 June 2015 (UTC)[reply]
If you're running Chrome you can do an encoding substitution. See here. RegistryKey(RegEdit) 04:41, 9 June 2015 (UTC)[reply]

How to initialize an array of shared_ptr in C++ Continued[edit]

The following code works fine with GCC, but Visual Studio 2013 complains about "error C3074: an array can only be initialized with an initializer-list".

boost::shared_ptr<A> arrayOfA[100] = boost::shared_ptr<A>(new A);

I do understand that my code is wrong w.r.t the C++ standard, but is there a better way than repeating boost::shared_ptr<A>(new A), boost::shared_ptr<A>(new A), boost::shared_ptr<A>(new A)... one hundred times? I could write a loop to do it, but then that would cost three lines per array, and I have numerous such arrays. I asked a related question previously[1]. My other car is a cadr (talk) 10:52, 8 June 2015 (UTC)[reply]

Here are three options:
    // Custom subclass of shared_ptr
    template<class T>
    class my_shared_ptr : public boost::shared_ptr<T> {
    public:
        my_shared_ptr() : boost::shared_ptr<T>(boost::make_shared<T>()) {}
    };
    // Custom array of standard shared_ptrs
    template<class T, size_t n>
    class my_shared_ptr_array : public boost::array<boost::shared_ptr<T>, n> {
    public:
        my_shared_ptr_array() {
            for (size_t i = 0; i != n; ++i)
                (*this)[i] = boost::make_shared<T>();
        }
    };
    // Helper function for standard array of standard shared_ptrs
    template<class T, size_t n>
    void initialize_shared_ptr_array(boost::shared_ptr<T> (&a)[n]) {
        for (size_t i = 0; i != n; ++i)
            a[i] = boost::make_shared<T>();
    }
-- BenRG (talk) 18:28, 8 June 2015 (UTC)[reply]
Thank you very much! Would C++11 make this easier somehow? My other car is a cadr (talk) 00:46, 9 June 2015 (UTC)[reply]
Resolved

Internet Radio[edit]

I am looking to set up an 'internet radio' station, a website that broadcasts a set program of pre-recorded music and other content. I have created a number of other websites for different purposes before, but never anything of this nature. I imagine it would involve a lot of differences to what I am used to, some specific programming to get it to run as intended (though I would not be surprised if it was as simple a matter as downloading existing software and hosting it on a server), but have no idea where to even start looking for instructions.

Thank you,

86.24.139.55 (talk) 14:50, 8 June 2015 (UTC)[reply]

Popular internet streaming systems include Shoutcast and Icecast (see List of streaming media systems for a longer list). You can host these on servers you control yourself or you can find a hosting package (just search for "shoutcast hosting" etc.) where the server is in someone's datacenter. In some cases the hosting is free (it's paid for by the hosting company inserting audio ads into your stream) and in other cases you have to pay a few dollars per month. -- Finlay McWalterTalk 15:07, 8 June 2015 (UTC)[reply]
I should clarify that I already have access to a server I use to host my other websites, and would want software I can upload to that. Were I to download something like this Shoutcast and put it on the server, I would want to be able to stream music tracks (having paid the appropriate license fees), content recorded and saved on my computer, and live content made elsewhere, being streamed direct to the site. Would all of these be possible (as a few internet radio hosts I've seen seem to be limited only to a playlist of music tracks they have the rights to) and would I need any extra software for this? The live content would be created by someone else that already has podcast recording equipment, would this be compatible? 86.24.139.55 (talk) 15:22, 8 June 2015 (UTC)[reply]
If your server is a real server (a leased server) then it should work; if it's a virtual server then it might work (depending on the Quality of Service criteria your hosting plan covers); if it's a website hosting plan then it won't work (those usually don't allow, or charge very heavily for, long-running user processes). If you run your own server you can upload your own content to it, and use an "auto dj" function to play that content unattended. The major servers at least allow you to switch between auto-dj and live content, streamed from a client computer. You'll have to talk to this someone else about what equipment and software they have. -- Finlay McWalterTalk 18:13, 8 June 2015 (UTC)[reply]
It's currently a website hosting plan, but I was looking at upgrading to a complete server to cope with the increased load from this and another major website project ongoing. I'll just have to get the software set up and have a look through what it can do, then, and once I'm sure I know what I'm doing, pay for the upgraded capabilities? Simple enough, done that before with my forum site. 86.24.139.55 (talk) 22:45, 8 June 2015 (UTC)[reply]

Data[edit]

Best storage medium for back up of 2TB of data? — Preceding unsigned comment added by 202.118.236.130 (talk) 15:07, 8 June 2015 (UTC)[reply]

I'd go with an external hard drive. Try looking at Amazon.com's selection. In my experience, the Seagate external hard drives have been very reliable. -- 143.85.169.29 (talk) 15:20, 8 June 2015 (UTC)[reply]
I'd say it depends on what your requirements are beyond storage space. Are you looking for something that you can easily access? Is it a one-time dump or will you be periodically adding/deleting data? Does it need to be on-site? How much redundancy do you need? How long does it need to last? Hard drives are cheap, but they're not redundant (unless you buy more than one, but then you have to get into RAID configurations unless you want a lot of manual work). And since you're probably storing it in the same location as the computer you're backing up, something like a fire or flood could damage both. You could also use something like Amazon Glacier or a VPS. Mr.Z-man 17:44, 8 June 2015 (UTC)[reply]

Don't understand this unhelpful shortcut[edit]

In Microsoft Word, Shift+F7 brings up the thesaurus, so when using the program in Windows 8 desktop mode, I'll often (without thinking) hold down the function key and press Shift and F7. This invariably leads to a weird situation, effectively holding down the Shift key: any letter I type is capitalised, if I click in the document, it highlights everything between that spot and the cursor, and commands don't work because it interprets Ctrl+S as Shift+Ctrl+S, which doesn't do anything. This affects the whole system; I always have to restart, because even mouse-clicking the start button (I use Classic Shell to give a Windows 7 appearance to the desktop) brings up the Windows 8 start screen, just as if I clicked it normally while holding down Shift. So my questions (1) What is the point of this feature? (2) Is there a way to turn it off easily, without restarting my computer, and ideally with a single button click or hotkey combination? Either knowing how to disable it entirely or how to undo it once I've enabled it would be helpful. A Google search for <"windows 8" function shift f7> brought up tons and tons of irrelevant pages, and I don't quite know how to narrow it down. I never use my computer except in desktop mode, so I don't know if this is a problem in other modes. Nyttend (talk) 15:36, 8 June 2015 (UTC)[reply]

Could this be a case of StickyKeys? -- 143.85.169.29 (talk) 15:49, 8 June 2015 (UTC)[reply]
I already considered that, and I don't think so. I've accidentally activated StickyKeys before by hitting the Shift multiple times in short succession, and it always gives me a warning that I'm about to turn it on. I never get any warning with this "feature": no popup window and no sound. Nyttend (talk) 17:13, 8 June 2015 (UTC)[reply]
I've had this happen when the system somehow misses the key-up event for Shift, and thinks you're still holding it down. Tapping Shift fixes it. -- BenRG (talk) 17:35, 8 June 2015 (UTC)[reply]