Wikipedia:Reference desk/Archives/Computing/2015 May 25

Computing desk
< May 24 << Apr | May | Jun >> May 26 >
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.


May 25 edit

Multiple wikis on Bitnami MediaWiki stack? edit

How do you set up more than one wiki on a Bitnami MediaWiki stack? The installation procedure only assists in setting up one, and it doesn't reveal how it does it. How do you add a second wiki? The Transhumanist 04:25, 25 May 2015 (UTC)[reply]

DBpedia edit

Where are the instructions on how to set up and use DBpedia? The Transhumanist 04:43, 25 May 2015 (UTC)[reply]

How to initialize an array of shared_ptr in C++ edit

I want to allocate an array of shared pointers, and then loop through the array to initialize each element. However I can't figure out the right syntax for it:

  std::shared_ptr<int> intArray[2];
  intArray[0](new int);

What's the right syntax for this? My other car is a cadr (talk) 13:10, 25 May 2015 (UTC)[reply]

The standard way to initialize the array is with list initialization. Initializer lists have to be resolvable at compile-time, though, which the result of "new" is not. I don't believe there's any standard way to initialize an array with a run-time determined value. You probably just want to use a for loop to populate the array:
  int intArraySize(2);
  std::shared_ptr<int> intArray[intArraySize];
  for( int i(0); i < intArraySize; ++i ) {
      intArray[i] = std::shared_ptr<int>(new int);
  }
Note you're assigning each element rather than using parenthesis/bracket initialization. Also, the "std::shared_ptr<int>" in the loop body is needed because the conversion of the raw pointer into shared_ptr needs to be "explicit" (to prevent you from accidentally converting something you don't want to and messing up the reference counts.). -- 160.129.138.186 (talk) 16:21, 25 May 2015 (UTC)[reply]
By the way, if you have "programming help" questions (as opposed to general computer questions) you may want to look at StackOverflow, which is a more specialized question/answer site for programmers. (People here will certainly be willing to answer your questions, but you're likely to get more/better answers at a SO.) -- 160.129.138.186 (talk) 16:24, 25 May 2015 (UTC)[reply]
You can only initialize an object when it's constructed. In your example, the shared_ptrs are constructed (and default-initialized) by the first statement. All you can do after that is overwrite them with new values. You can't use the constructor syntax for that; your second statement is a function call, which fails because shared_ptr doesn't define operator().
Contrary to what 160.129.138.186 said, array initializers don't have to be compile-time constants. This works:
  std::shared_ptr<int> intArray[2] = {std::shared_ptr<int>(new int), std::shared_ptr<int>(new int)};
But it probably isn't useful unless you really only want two shared_ptrs.
In the loop or the initializer list, it is probably better to write std::make_shared<int>() instead of std::shared_ptr<int>(new int), since it will (probably) halve the number of allocations by allocating the int and its reference count together. -- BenRG (talk) 23:14, 25 May 2015 (UTC)[reply]
  Resolved

Thanks, guys. My other car is a cadr (talk) 13:21, 26 May 2015 (UTC)[reply]

"Cloud this...", "Cloud that..." and NSA. edit

Nowadays, people talk alot about cloud computing and etc..
The question is how/why the hell cloud computing is becoming/became trendy on NSA surveilance era~?
Why dont people sort of bury this idea under the ground, or at least stop "masturbating" to cloud computing. Are those guys outside current reality?200.223.39.18 (talk) 16:13, 25 May 2015 (UTC)[reply]

In reality, not much has changed, if they wanted to, "The Government" could bug your phone line ever since phones were invented, they could intercept your mail ever since the post was invented. They could bug your livingroom if they really wanted to. They could track your car if they really wanted to. People still use phones, live in houses, post letters and drive cars without worrying too much about the government spying on them. And in reality, you'd have to be pretty paranoid to think that out of the millions of citizens, the government would give two hoots about you or what you do. Legitimate businesses, and even a lot of internet users might not care that the NSA can "spy" on them, since they have nothing to hide. As for specifically "cloud" computing, there's nothing "inherent" in cloud computing that makes it more voulnerable to "NSA Attack" or whatever you want to call "that" idea. Like with any technology you just weigh up the advantages and disadvantages and decide if it's worth it for your situation. Cloud can even be implemented just for services that don't contain any "sensitive data" that you care someone might be spying on, you could use it for non sensitive services, like a "web shop", why would anyone care if the NSA can spy on their store front? Vespine (talk) 22:52, 25 May 2015 (UTC)[reply]
"Since they have nothing to hide." The one who decide what is wrong is not the "legitimate business" owners. Someone saying he has nothing to hide is irrelevant, he is assuming he do nothing wrong according to his own point of view and unless he is the one who decide what point of view is used to check what is wrong or not, his point of view on this case is irrelevant. — Preceding unsigned comment added by 201.79.90.125 (talk) 17:50, 26 May 2015 (UTC)[reply]
The technical difference is that back in the earliest days of bugging houses it took a crew of people and van full of equipment to install the bugs and to monitor one house. This was a rather expensive operation, ensuring that even in a police state only a small number of homes would actually be bugged. However, it has now become vastly cheaper to monitor the internet, and, using computers to flag items of interest, one person can effectively listen in on many conversations at once. So, it is now feasible for monitor everyone's internet usage, all the time. StuRat (talk) 18:33, 26 May 2015 (UTC)[reply]
Ok the unsigned IP clearly has a bee in his bonnet about the NSA, I'm guessing chemtrail level paranoia. I personally am glad that true anonymity is very difficult on the internet, there have been more than enough social experiments that prove how absolutely horrible people can be if they're "guaranteed" anonymity without reprecussion. I see no reason to suppose the internet should or was ever intended to be "free" of laws and regulations, there is more than enough internet crime, terrorism, fraud, child abuse etc that the internet enables with the feeble laws that are in place. The internet is still in its infancy, call it the "wild west", people loved the freedom, but there was a high price for it too, the risk of being shot in the street by some drunk cowboy etc... MOST people in the modern world would not trade places with someone who lived in the wild west and I predict the internet will undergo similar "progress". Vespine (talk) 23:28, 26 May 2015 (UTC)[reply]
"I'm guessing chemtrail level paranoia." I dont know what chemtrail is (will have to check). Its not paranoia, its already set to stone USA spy people. Also this goes against USA constitution, so they made something illegal, I am not saying that because they made something illegal (implemented this surveilance system against constitution rules) they will use the NSA system to do illegal stuff. But the point is that they already made something illegal, so asking questions like "do you think the government would do something bad?" is stupid since the fact that NSA surveilance exist prove they did at least one illegal thing.201.79.90.125 (talk) 12:11, 27 May 2015 (UTC)[reply]

Preview of dump data before downloading large file edit

Is there a way to preview a segment of the data before downloading a 1.5 GB dump file? I would like to know if the file contains the kind of data that I am looking for. Thank you for reading :) — Preceding unsigned comment added by 216.210.108.250 (talk) 18:18, 25 May 2015 (UTC)[reply]

If you're downloading on HTTP or HTTPS, you may find the server supports byte serving, which will allow you to ask to download only a small section of the file. For example, with cURL:
     curl -r 0-1023 https://upload.wikimedia.org/wikipedia/commons/b/b9/Cats_eye.jpg > cat.partial.jpg
will download only the first 1k of the image. But some servers don't support this (they'll send the whole file regardless) or will only support it on some file types. -- Finlay McWalterTalk 19:52, 25 May 2015 (UTC)[reply]
There is the problem though, many of the files in the dumps are compressed SQL files, using the above command to get a segment of that file will yield unreadable output which is not helpful for determining the format and content of the dump file. — Preceding unsigned comment added by 216.210.108.250 (talk) 21:15, 27 May 2015 (UTC)[reply]
Depending on the type of compression used, you may be able to use the corresponding tools to "fix" the "damaged" archive that downloading only a chunk of it produces. For example, if the whole thing is a single zip archive with a bunch of SQL (text) files, you can try downloading a chunk using the above scheme (take as big a chunk as you can, so you get lots to work with) and then:
           zip -FF sqldump.partial.zip --out sqldump.partial.fixed.zip
           unzip sqldump.partial.fixed.zip
Different tools like tar, 7z, etc. often have comparable repair modes. -- Finlay McWalterTalk 21:48, 27 May 2015 (UTC)[reply]
Just to confirm this really works in this kind of circumstance, I've verified this should work for you by creating a large ZIP file with a hundred or so text files inside it, then pulled a fraction of that file out (starting at a random offset) to produce a damaged zip file (one that doesn't start at a local header, and one without the central directory at the end). The Info-ZIP zip and unzip, used as I described above, successfully extracted all the complete files in the damaged zip file. -- Finlay McWalterTalk 12:21, 28 May 2015 (UTC)[reply]
...but if the file uses solid compression (RAR or 7z in some modes, or .tar.gz) then doing this probably isn't practical. -- Finlay McWalterTalk 15:05, 28 May 2015 (UTC)[reply]

Empty Characters Retrieved From String Data From TextBox Into Array Using VBA (Not VB.Net)? edit

Hello, I have a TextBox that I want to take the individual characters and put them into an Array (or a Collection). This would require 2 things: 1. I would have to take the string from the "Text" property of the text box and extract the individual characters. 2. Put those extracted, individual characters into a Collection or an Array. How would I do this in Visual Basic for Applications (I am using MS Word 2007 to do this)? I have already asked a similar question but not aimed at doing this with a Textbox. Also I can't go to any other web sites, I need the information to be here as I cant go to any external links. Thanks for your help in advance!



Edit: I can use the KeyPress event to record every character that's pressed and empty it into the Array or Collection but I don't have a way to tell if any characters have been deleted. Here is the code i am using to do this.

Public Chars As New Collection
Public i As Integer
Private Sub CharTextInput_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    Chars.Add Chr(KeyAscii), i
    i = i + 1
    'KeyAscii Is the character code that was pressed.
    'Chr() converts the specified character code to a character that is enclosed in a string.
    'Chars is a Collection (I like using Collections, their so easy to use!).
    'i is just the Key that is used to locate the character in the Collection.
End Sub

The problem with this is like I said, I don't have a way to identify when a character is deleted from the text box. This is why I need to use the string from the "Text" property to get the characters. —SGA314 (talk) 18:56, 25 May 2015 (UTC)[reply]

Let's start with the string splitting functions:
Private Sub StringToArray(ByVal sString As String, ByRef asArray() As String)
    Dim i as Integer

    If Len(sString) = 0 Then
        '  sString is empty
        ReDim asArray(0)
    Else
        ReDim asArray(Len(sString) - 1)
        For i = 1 To Len(sString)
            asArray(i - 1) = Mid$(sString, i, 1)
        Next
    End If
End Sub

Private Sub StringToCollection(ByVal sString As String, ByRef colCollection As Collection)
    Dim i as Integer

    colCollection.Clear()
    For i = 1 To Len(sString)
        colCollection.Add(Mid$(sString, i, 1))  
    Next
End Sub
Now, for the textbox handling. You can access the current text by just reading the CharTextInput.Text property - the issue is when to do this. Do you want to update something else while the user is typing in the text, or do you want to wait until the user has finished entering the text? Tevildo (talk) 00:20, 26 May 2015 (UTC)[reply]
I want to update the collection every time something changes in the textbox. I think I would have to clear the Collection and then load the characters into the Collection again. I can use the TextBox Changed Event to do this, right? Thank you so much for your help. I didn't know about the Mid function. Thanks again. —SGA314 (talk) 13:10, 26 May 2015 (UTC)[reply]
Yes! I did it! Here is what I came up with based on your way:
Public Chars As New Collection
Private Sub CharTextInput_Change()
    Dim i As Integer
    Dim Text As String
    Text = CharTextInput.Text
 
    For i = 1 To Chars.Count
        Chars.Remove (CStr(i))
    Next
    
    For i = 1 To Len(Text)
        Chars.Add Mid$(Text, i, 1), CStr(i)
    Next
End Sub

So the first thing I do is, I Empty the Text from the TextBox into a String. Next I proceed to clear the Chars Collecteion(In VBA for MS Word 07, the Collection dosen't have a Clear() method) by going through and removing each one.

Finally I use your String Splitting piece of code, only this time I Set the key for each element as the String version of whatever I currently equals in the Loop. Now When I want to access the characters in the Collection, I just do this:

For Each Char In Chars
'Do Whatever With the variable 'Char'
Next

Thanks sooo much for your help. —SGA314 (talk) 13:43, 26 May 2015 (UTC)[reply]