Jump to content

Wikipedia:Reference desk/Archives/Computing/2015 March 3

From Wikipedia, the free encyclopedia
Computing desk
< March 2 << Feb | March | Apr >> March 4 >
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.


March 3[edit]

Simple program[edit]

Hi,

I'm not sure whether this exists or not, but I'm searching for a relatively simple program (Windows OS, preferably freeware) that probes folders (and their subfolders' subfolders - recursive scan) to determine whether a chosen file exists or not (e.g. Folder.jpeg - preferably case sensitive), and lists all the sub-directories where the said file is missing. Any ideas? Matt714 (talk) 04:20, 3 March 2015 (UTC)[reply]

It's not case sensitive, but you can use the Windows Explorer built-in search feature. Open explorer (⊞ Win+E), navigate to the starting/root location for your search, type the search criteria such as "file:Folder.jpeg" in the box at the top right, and press enter. The "File:" prefix directs the search to look for matching file names, but not content. It may take a few minutes to scan all of the folders. -- Tom N talk/contrib 04:45, 3 March 2015 (UTC)[reply]
The OP wants to list folders that DO NOT contain the specified file. Bubba73 You talkin' to me? 05:59, 3 March 2015 (UTC)[reply]
If case-insensitive is okay, then see my answer in this thread. -- BenRG (talk) 08:03, 3 March 2015 (UTC)[reply]
It's overkill, but installing Cygwin will let you do all sorts of things on Windows easily and freely that are otherwise difficult or expensive. In this case, you would be using a find command, but you'd have to play around a bit with regex and maybe grep to get it to do exactly what you want. SemanticMantis (talk) 15:00, 3 March 2015 (UTC)[reply]
If you're going to install something I'd install Python, or some other decent programming language you're familiar with. It's a straightforward three-liner in Python:
    import os
    for path, subdirs, files in os.walk(r'D:\foo'):
        if 'Folder.jpeg' not in files:
            print(path)
If you want it case insensitive then replace the middle line with if 'folder.jpeg' not in map(str.lower, files):. It would be harder to hack together a solution using standard Unix command-line tools. -- BenRG (talk) 19:45, 3 March 2015 (UTC)[reply]
I don't want to take this too offtopic (particularly since my knowledge is too limited that I can't come up with an example relevant here offhand), although it sounds like it's solve anyway. I'm not convinced the claim that without Cygwin, a lot of things are going to be expensive or difficult is true, at least not without a lot of qualification. Windows PowerShell has been available since 2006, and is available by default on 7 onwards.

It's true the syntax and design is very different most *nix shells (e.g. object instead of everything is a file), at least partially reflective of the fact it's targetted at Microsoft modern Windows enviroment with .Net (also COM etc) rather than the *nix one. But I don't think you can say it's necessarily less versatile, in fact on Windows it can be better particularly when dealing with Microsoft stuff, because it's all targetted around the same thing. I think the interactive shell component is perhaps somewhat weaker, because Windows lacks the tradition of such that *nix has, and I believe PowerShell is targetted at scripting as much as a shell, but I think you're only likely to notice this in specific cases.

Of course if you already have a lot of experience with a *nix shell, than using Cygwin may be a lot easier than trying to learn PowerShell, but that's a special case. For someone who doesn't know either, it's possible learning a *nix shell will be slightly easier, because I'm not sure if there's really the same level of beginner tutorials and introductions for Windows PowerShell (since the set of people using it is still I think small). And similar finding specific examples for a *nix shell may be slightly easier.

But I'm not sure it's accurate to say PowerShell is very hard to learn or to use if you don't have any particular experience anywhere.

Even before PowerShell, I think you could do a fair amount with Windows Script Host/CScript, probably VBScript but may be JScript and these have been part of Windows since even before NT (98). These are of course pure scripting and don't provide the benefits that a good shell (combined with the programs/cmdlets) so I will concur it was still much more limited even if it could also do a lot, particularly when it comes to simple stuff like this. In fact this is somewhat demonstrated by the fact that from XP onwards there were restrictions put on running scripts by default due to people being fooled in to running malicious scripts.

Note that I'm not saying these are necessarily the best choices, or there's anything wrong with Cygwin. Simply the idea it's difficult or expensive without it probably isn't true for many examples you can come up with, in fact you could probably do a lot of it with default Windows tools, particularly since 7.

As a disclaimer, my programming and scripting experience is limited. I have made a few modifications to programs including in Objective C, C++, and Python, as well as made a few minor related Jython/Sikuli scripts and also one or two PowerShell scripts (and a bunch of simple cmd ones), oh and a few minor sh scripts of various types I think.

Nil Einne (talk) 12:12, 4 March 2015 (UTC)[reply]

BenRG'S solution worked like a charm. Thanks everyone. Matt714 (talk) 23:12, 3 March 2015 (UTC)[reply]

That is a really elegant solution. Python has some high-level stuff in it that most languages don't have. I have a program that I could modify in a few minutes for your problem, but the Python program is quite nice. Bubba73 You talkin' to me? 07:27, 4 March 2015 (UTC)[reply]

3D building game[edit]

Can you recommend me a 3D building game with realistic or semi-realistic physics that allows the player to build things and then destroy them? Like for example, building a bridge and then running a extremely heavy train across it, and seeing if the design holds or falls apart. Or building a stupid high tower and then simulating wind to blow it over. The key element here is that I don't just want to build things, I want to destroy them afterwards as well. I'm bored of simulation games that don't allow you any freedom, like train simulators where you cannot derail the trains or crash them into each other. 3dgamequestion (talk) 16:33, 3 March 2015 (UTC)[reply]

Garry's Mod does semi-realistic physics and has a pretty rich sandbox. You can certainly make things that fall down, blow up, or crash. It's very far from a real simulator of structural systems, but it might be enough for what you're looking for. -- Finlay McWalterTalk 16:46, 3 March 2015 (UTC)[reply]
Kerbal Space Program has pretty good physics and mostly everything can be blown to bits - even if you don't want them too. You're limited to building aircrafts and rockets unless you install some mods though. WegianWarrior (talk) 17:10, 3 March 2015 (UTC)[reply]

How to edit a PNG pic ?[edit]

I have this pic: [1].

I'm using it as a background for an HTML page, using Javascript to make the rain appear to fall (with suitable sound effects). However, I'd like to make some changes to the pic:

1) I'd like to lighten the blue raindrops to a soft pastel, so they are more subtle. Note that they aren't just one color blue to begin with, but are a range of blues. One method I've thought of is to put a semi-transparent white window in front, then do a screen grab of that.

2) I'd like to change the white background to transparent. Again, though, there's not just one white, but a range of "almost whites", and I'd like to change those all to transparent.

I'm on Windows 7. So, how can I best edit this pic ? Thanks, StuRat (talk) 18:53, 3 March 2015 (UTC)[reply]

My suggestion would be to install GIMP, which you can download by following the instructions at http://www.gimp.org. It might take you a little while to figure out how to use it, but then there is hardly any limit to what you can do. Looie496 (talk) 19:03, 3 March 2015 (UTC)[reply]
Thanks. Is GIMP able to make both of the changes I need ? StuRat (talk) 20:27, 3 March 2015 (UTC)[reply]
GIMP can do both, yes. I think the tool you'll want to read up on (or play with) most is the Fuzzy Select tool (aka Magic Wand). Basically allows you to select an area based on color similarity. There's a threshold slider you can play with until you figure out a setting that selects all of the whites or all of the blues. If it gets almost everything but not quite there's also a way to add to the selected range by holding [shift or control, I can't remember] and clicking on the unselected area. It can be a pain with a photograph full of shadows and highlights, but contrast looks pretty stark in this image so it should be pretty easy, I think. — Rhododendrites talk \\ 20:44, 3 March 2015 (UTC)[reply]
(EC, same as above) :::The GIMP can do pretty much anything to a raster graphics image that can be done. I only know it superficially, but I suspect you'll get a lot of mileage out of the fuzzy selector [2] and the intelligent scissors [3]. Once you know the basics, most any Photoshop tutorial will also work for the GIMP. SemanticMantis (talk) 20:53, 3 March 2015 (UTC)[reply]
Alternatively, you could generate an image much like that, but more to your tastes, with Inkscape. I don't know much Inkscape either, but I think I could do that in 10 minutes max (draw one drop, clone, scale, gradient... presto). You would have to learn some basics there too of course, but then it becomes a question of if you'd rather know a tool for manipulating raster graphics, or authoring vector graphics? SemanticMantis (talk) 21:36, 3 March 2015 (UTC)[reply]
Paint.NET is another popular free Photoshop-like raster editor. -- BenRG (talk) 22:03, 3 March 2015 (UTC)[reply]
I'll second the use of GIMP to modify the image. I use GIMP a *lot* and there isn't much it can't do - especially if you like to hunt for plugins. If you did want to re-author it from scratch, then I agree that Inkscape is an interesting and potentially useful tool (I use it even more than I use GIMP!). Inkscape can rasterize it's output and export to PNG - and GIMP can import SVG files (which is Inkscape's native format) and turn them into raster images too. So it's simple enough to get the geometry right in Inkscape as a vector image, then rasterize it and flip over to GIMP to do filtering, lighting, color trickery and such. Both tools are free/OpenSource and run on Linux, Windows and Mac OSX - so you have nothing to lose by giving them a try. SteveBaker (talk) 04:18, 4 March 2015 (UTC)[reply]

UPDATE: I downloaded GIMP:

0) The default download method using BitTorrent didn't work and gave me a scary warning that my PC would then be used as a server to upload the software to others. My PC is slow enough already without doing that, thank you very much. They had an alternate link for if BitTorrent didn't work, which I wish was the default. It worked fine, although you apparently have to pick the custom install option to ask for a GIMP icon to be created on your Desktop. I would have thought that would be the default, too.

1) Lightening the blue raindrops worked fairly well using Tools + Color Tools + Brightness-Contrast, although the brightness slider only lightened it a bit each time, so I ended up repeating 3 times to get it to nice pastel blues. I then had to use File + Export As to save it in PNG format, even though that was the format it was in when I read it.

2) Changing the background to transparent is more problematic. I realized that the blue raindrops blend into the white background now, so there is no clear distinction of where the raindrops end and the background begins. And what I'd need to get it to work the way I wanted would be for the currently white background to be 100% transparent, while the area around the raindrops becomes less and less transparent as it gets bluer and bluer. This would allow whatever background I added later to partially show through the raindrop edges. But, this sounds difficult or impossible to actually achieve, so I gave up on this part and stuck with the all-white background. StuRat (talk) 19:30, 4 March 2015 (UTC)[reply]

0) That's just how Bittorrent works. Bittorrent is recommended to reduce costs of hosting the program. The software is free, but someone somewhere has to pay for hosting. You get it for free so, it's reasonable that you upload a bit to help share with the community. But you don't have to. You can also throttle your upload speeds on Bittorrent, so that those uploads won't use more than e.g. 10% of your upstream bandwidth.
1) Gimp stores all projects in its own format. PNG, JPEG, etc don't have any concept of layers, gradients, and other things that can be stored in a Gimp file. This is a conscious decision on the part of the designers: only use one type for storage and manipulation of working projects, then export and "flatten" in to any other common type when you're done.
2) I just tried, and was able to select the BG using the magic wand tool. From there you can delete it, change transparency, etc. You can also put in transparency gradients around each drop, but I'm not sure how to do that. Try creating it in Inskape next, then you will be able to do exactly what you want. SemanticMantis (talk) 20:20, 4 March 2015 (UTC)[reply]
2) Thanks. Does anyone else know how to create transparency gradients around each drop, using GIMP ? StuRat (talk) 20:30, 4 March 2015 (UTC)[reply]
This is actually easier done than described. Here are the steps. They are based on using the menus, but you can do the same using the GUI. I'll leave it to you to figure out how it actually works.
  1. Choose the "Select by color" tool; click anywhere on the white background.
  2. Select->Grow...; grow the selection by 1 pixel.
  3. Select->Feather...; feather the selection by 2 pixels.
  4. Select->Invert; invert the selection.
  5. Layer->Mask->Add Layer Mask...; choose "selection"; add a mask to the layer based on the current selection.
  6. Select->None; deactivate the selection.
  7. Layer->Mask->Edit Layer Mask. This selects the layer mask for editing. (Alternatively, from the Layers tab, click on the icon for the layer mask created before.)
  8. Filter->Blur->Gaussian blur...; use a blur radius of 2.5 pixels. (You're doing this blurring on the layer mask, not the main image of the layer.)
  9. Layer->Mask->Apply Layer Mask.
Experiment to get the result you want. Have fun. --173.49.18.106 (talk) 04:04, 5 March 2015 (UTC)[reply]
Excellent ! I was able to follow those instructions and get it done. I did make some changes, though. I found the "Select -> Grow" option had the effect of cutting off the tails of the raindrops, so I skipped that. I also reduced the feather and blur radii both to 1. It looks pretty good now ! StuRat (talk) 08:51, 5 March 2015 (UTC)[reply]
Here's another, much simpler method to achieve the same result for your picture:
  • Color->Color to Alpha...; In the dialog box that pops up, the "from" color should be white by default. Apply the tool and you will get the result you want. (If you've used the tool earlier in the same editing session, you may have to click the "from" color and set it to white--the background color that you want to turn transparent.) --173.49.18.106 (talk) 13:20, 5 March 2015 (UTC)[reply]
Thanks, I'll give that a try. Will it set the transparency to match how white the color is ? That is, blue should be 0% transparent, white 100% transparent, and a 50% blend should be 50% blue and 50% transparent Ideally a single color of blue should result, with only the percentage of transparency changing. StuRat (talk) 16:58, 5 March 2015 (UTC)[reply]
I don't know the exact behavior; this is my perception of how it works. The operation seems to have some internal threshold of "closeness" to the color to be made transparent. It seems that if the color of a pixel is close enough, the "to be made transparent" color component will be subtracted from the pixel, and the pixel will be turned (partially) transparent based on how close it's to the color. Qualitatively, it works as you described, at least in your example. There are nuances that I don't understand. Maybe it's time to look up the documentation. --173.49.18.106 (talk) 18:17, 5 March 2015 (UTC)[reply]
Worked great ! Result is even better than the long method. StuRat (talk) 07:15, 7 March 2015 (UTC)[reply]

BTW, does everyone else see a weird character in front of the title of each section when you hover over the edit button ? What does that mean ? StuRat (talk) 08:51, 5 March 2015 (UTC)[reply]

It used to be used in old books to mean a new paragraph, and usually had a number after it, for reference. "See §3" for example would refer to Paragraph 3. KägeTorä - () (Chin Wag) 09:08, 5 March 2015 (UTC)[reply]
It's the symbol for section (not paragraph as KageTora suggested). It's very commonly used in legal documents. I think the character shape is derived from a combination of 2 instances of the letter "S". --173.49.18.106 (talk) 13:08, 5 March 2015 (UTC)[reply]
I was going to say 'section or paragraph', but I just didn't. Spent all morning wondering whether I should change it, the tears were overflowing, my mum was going to call an ambulance to have me sectioned, but I came back and saw I had been rightfully corrected. Thank you. To add further information, the reason why it is a double 'S', is because there are multiple sections, just like when talking about 'pp. 15-17' the 'p' for 'page' is doubled. It just doesn't have its own symbol. KägeTorä - () (Chin Wag) 14:22, 5 March 2015 (UTC)[reply]
Haha. That was funny. Had to look it up to find out the special meaning of "sectioned" in British English. :) -173.49.18.106 (talk) 15:31, 5 March 2015 (UTC)[reply]
Yes, they used to call me the Cunning Linguist, but now they call me the Punning Linguist. KägeTorä - () (Chin Wag) 16:36, 5 March 2015 (UTC)[reply]
Perhaps you are a candidate for a Section 8 discharge ? StuRat (talk) 18:13, 5 March 2015 (UTC) [reply]
Cheers, Stu. That proves that it's not just British English. It's also used in Americanese. KägeTorä - () (Chin Wag) 21:08, 5 March 2015 (UTC)[reply]
That goes along with the double (backwards, for some reason) P's for the paragraph symbol: ¶. But why do they now show that symbol in front of a section when you hover over "edit" or the section title ? Were they afraid people didn't know it was a section ? StuRat (talk) 16:58, 5 March 2015 (UTC)[reply]
Unfortnately we cannot answer that question. You would have to ask the Wikipedia staff for that. We don't know about their psychological impulses. KägeTorä - () (Chin Wag) 17:20, 5 March 2015 (UTC)[reply]
Most likely, they just added it as eye candy, to attract more people who are scholars and read scholarly literature, but not realising that most people don't even know what it is. KägeTorä - () (Chin Wag) 17:35, 5 March 2015 (UTC)[reply]
(EC) If you are asking for the purpose for the section symbol, no need to ask anyone (nor come up with weird theories). The section symbol gives you a direct link to the section. You can click it to align/anchor the section (presuming your browser isn't borked) as well as turn your browser URL into a link to the section (meaning a bookmark should be a link to the section), or copy it directly to get a link to the section. It removes the need to either manually compose the link, or to go back to the heading list and find the heading and get it from there. And it appears whenever you hover over the header, regardless of whether it's the edit link or whatever. In fact, AFAIK it should appear even if there is no edit link, e.g. in archive pages (e.g. Wikipedia talk:Reference desk/Archive 112) or protected pages that your user level doesn't allow you to edit (current e.g. for non admins Ulster). See Wikipedia:Village pump (technical)/Archive 135#Link to this section snake, [4], [5], [6] for more. If you're asking specifically why the section symbol was chosen for the link, I think reading through these will probably tell you (the RfC seems a promising start), but I can't say for sure. Nil Einne (talk) 17:44, 5 March 2015 (UTC)[reply]
Oh, it provides link to the section. Yes, that does make it useful, although I'd have just made the section title do that, rather than add an arcane symbol. StuRat (talk) 17:55, 5 March 2015 (UTC)[reply]
Re the above - does anyone know how to get rid of it? I find it most annoying. Tevildo (talk) 08:28, 6 March 2015 (UTC)[reply]
You might want to ask that as a new question. StuRat (talk) 21:26, 7 March 2015 (UTC)[reply]