Wikipedia:Reference desk/Archives/Computing/2015 September 16

From Wikipedia, the free encyclopedia
Computing desk
< September 15 << Aug | September | Oct >> September 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.


September 16[edit]

'Air' and or 'space' weather simulatiors and designing softwares[edit]

What's the best software(s) to create things like this?

Simulation of air flow/fly testing is desirable for bike(s), car(s), plane(s), building(s) and spaceship(s). Can someone help me please? I'm looking for something/a software(s) i.e. extremely good, with which I can stick by as I don't ever wish to worry or change it in my lifetime after learning it, just wish to update it to a newer version... -- Space Ghost (talk) 07:20, 16 September 2015 (UTC)[reply]

There are many pieces of software to fit all budgets. Search for "Computational Fluid Dynamics". You will find open source, affordable, and extremely expensive softwares; choose one which suits your needs. Autodesk have CFD software with a free trial. This might work for you. 217.158.236.14 (talk) 09:53, 16 September 2015 (UTC)[reply]
Okay. I'm new to this whole thing and thank you for your guidance... Regards. -- Space Ghost (talk) 19:23, 16 September 2015 (UTC)[reply]
217.158.236.14: I do possess some Autodesk products and I'm wondering whether I'll be able to draw products on 'CAD', '3ds Max', '3ds Max Design' and or in 'Architecture Revit' then transfer it the 'CFD' software? The thought acquired also because this states about a design study environment... -- Space Ghost (talk) 20:17, 16 September 2015 (UTC)[reply]

Why Wikipedia uses paid SSL certificates[edit]

Wikipedia uses GlobalSign certificates that costs a lot. Why it doesn't use the free certificates of StartSSL? Hunsu (talk) 09:48, 16 September 2015 (UTC)[reply]

It is all about security. You also assume that Wikimedia didn't negotiate a deal with GlobalSign. The lesson is that even on the internet, you get what you pay for. Want an example, Google for GoDaddy nightmares and you'll have a day full of anecdotes to read. Now, try Network Solutions. Hmmm - mostly just user idiocy, not Network Solutions providing poor service. 209.149.113.66 (talk) 12:15, 16 September 2015 (UTC)[reply]
StartCom suggests the free certificates offered are very limited and unlikely to be suitable for the Wikimedia Foundation. Also why do you say GlobalSign certificates cost a lot? Their website [1] says may be $2,297 for 3 years for a simple set up. The WMF probably has more complicated needs but even $25k is frankly chump change to the WMF.

P.S. To be clear, I'm not suggesting the WMF does, or should, just waste money. But you have to consider that when you're a large foundation with operating budgets in excess of $50 million, supporting quite a few different domains most with many unique subdomains what may seem like a lot to an individual may not seem quite so much. And other stuff like support, feature set, bundled services (does the WMF get their certificates and domain management from the same company?), support, past experiences etc will likely significantly come in to play. Note also it's likely this sort of stuff is mostly managed by paid staff, probably higher level ones since it's important. So wasting many hours on it isn't cheap, not to mention the negative effect on the people they're trying to reach caused by any problems.

Nil Einne (talk) 14:27, 16 September 2015 (UTC)[reply]

Mail list display in online Outlook 365[edit]

So my work uses the online version of Outlook 365 as their mailing program. Recently, the line spacing on the mail list (to the left of the reading pane) has gotten much bigger, meaning I can only see 10 or so mails, even on my 23" monitor. I can't seem to change the line spacing in any of the display option, and google is failing me. Help? 131.251.254.154 (talk) 10:00, 16 September 2015 (UTC)[reply]

Using it also and have had this problem. Try the following . . .
  • On the left, click a particular folder or sub-folder (e.g. Inbox)
  • At the top, go to VIEW
  • At top left, click Change View
  • You're probably currently in the first of 3 choices, "compact"
  • Change this to the second choice, "single"
You'll probably have to do this separately for each folder and sub-folder. Hope this works/helps {The poster formerly known as 87.81.230.195} 185.74.232.130 (talk) 13:57, 16 September 2015 (UTC)[reply]
Hmm, I don't even have a View tab. Must have been disabled by our friendly neighbourhood sys adminds. Oh well, it was worth a try. Cheers anyway! 131.251.254.154 (talk) 08:17, 17 September 2015 (UTC)[reply]

What happens to a regexp when you compile it?[edit]

When you compile a regex, what is happening to it? For, example, in Python:

r = re.compile('wiki')
r.match('wikipedia')

instead of:

s = 'wiki'
re.match(s, 'wikipedia')

r and s are somehow different now.

python -m timeit -s 

for both are different. How are r and s different? --Denidi (talk) 15:04, 16 September 2015 (UTC)[reply]

When you compile a regex in your code, you can use it over and over with just match. When you use re.match, it will be compiled behind the scenes. So, in both cases it is compiled. It is just a matter of who compiles it - you or the library. In my opinion, it is a matter of taste. It is possible a matter of overhead. In the first example, the compiled r still exists after r.match. In the second example, the compiled regex is trashed after the match. Without getting into the internals of the Python interpreter, it is hard to say if that will end in any real difference. 209.149.113.66 (talk) 15:20, 16 September 2015 (UTC)[reply]
A thread on StackOverflow that discusses whether it makes a significant difference. I think the executive summary is: no, unless you're doing thousands of comparisons against the same regexp. The docs say "using re.compile() and saving the resulting regular expression object for reuse is more efficient when the expression will be used several times in a single program"; but also "[t]he compiled versions of the most recent patterns passed to re.match(), re.search() or re.compile() are cached, so programs that use only a few regular expressions at a time needn't worry about compiling regular expressions." AndrewWTaylor (talk) 15:32, 16 September 2015 (UTC)[reply]
The above answers provide some good perspective on whether compiling provides performance advantage. Ultimately, performance depends on your use-case and the gory implementation details.
To answer the question directly, "what happens to a regexp when you compile it"... well, let's focus on one specific case, the regular expression engine in Python 2.7.10. You can start by reading the programmer documentation; and you can read the official HOWTO; but those documents just explains the interface, and do not describe the internals of re.compile at all. For that, you need to grab source code to inspect directly.
When you import re, the python environment brings in code from the regular expression wrapper, and from an implementation library (specifically, the one written by "Secret Labs", a small independent software company that distributes free and non-free python software).
How are r and s different? Well, s is a string of characters (represented as a Python data type); and r is a Python object that contains state created from that string of characters. This Python object serves as the implementation of a state machine, which can be applied to other input strings.
We can tear open the sre python code. This code implements the class for the "regular expression object," of which your variable r is an instance. If you read the code, you will find that compile creates a Python object that interprets your regular expression string. It iterates over your input string, looking for a bunch of magic characters - these are the specific sequences of special characters in regular-expression syntax that command the behavior. Finally, it emits "OPCODE"s for the regular expression engine's internal state machine - which is, essentially, a deterministic finite automaton (or something like it).
All the details of performance - including whether the pattern is pre-compiled or re-compiled each time you use it - are defined in the "cache" inside Python's regular expression engine.
When you run a "match" or any other of the standard regular expression utilities on a string, the regular expression engine will either re-compile a new regular expression tokenizer object, or use one from the internal cache. Then, it will call into the function that represents the state-machine for that regular expression, which will iterate over your input string, and produce an appropriate output.
All told, the code for regular expressions in CPython-2.7 is written in pure python and is only about three thousand lines long. It would probably take a few hours to really read and understand the general flow, and it might take weeks or months to master the details; but that's what is happening. In other regular expression engines - like the ones in your standard Java or perl distributions, there's a similar process.
If you would like to read what Larry Wall has to say on regular expressions, He is regarded by many as the Creator (although there are many doubters, and there are many students of an older magic). Larry Wall has spoken by way of several Apocalypses. This is perl programmer humor, but it's literally true. You may wish to consult Apocalypse 5, Pattern Matching, which is from year 2002 and is very obsolete; but is a great overview: regular expression culture is a mess. There exist many variants, many poor implementations, many contradictory standards; and the result is a widespread and terrifying set of use-cases; so many pieces of code where a regular expression engine is abused beyond reason; so many instances where a piece of code only works in certain carefully-balanced conditions.
Nimur (talk) 16:40, 16 September 2015 (UTC)[reply]
In short, regexes are compiled into bytecode. The bytecode interpreter is written in C (_sre.c). The bytecode does not define a deterministic finite automaton (finite automata can only match regular languages, while Perl-style "regexes" can match much more than that despite the misleading name). It is nondeterministic (evaluated using backtracking, similar to Prolog) and it has state beyond the program counter, such as the contents of previously matched groups for \# backreferences. -- BenRG (talk) 20:55, 16 September 2015 (UTC)[reply]
I may be missing something, but in one case isn't the RE compiled at compile time whilst in the other it is compiled at run time? (I know nothing about python and a little about perl.) -- SGBailey (talk) 23:42, 20 September 2015 (UTC)[reply]
No, Python (well, Cpython, which is what people mean when they say Python without qualification) isn't compiled (well, it is, but effectively at "run time"). The difference between the two ways above is whether the result of the regexp->bytecode compile is stored explicitly in a variable r, or cached implicitly by the regexp library (so, for most cases, no worthwhile difference at all) - that's more of a hint to other programmers (hey, we're using this regexp again later) than to the system. Tangentially, the only place I've heard of where a regexp is really really compiled is the .NET implementation, which has the option to compile not to a regexp-specific microVM like the one BenRG talks about, but instead to .NET CLR bytecodes, which the .NET runtime JIT can then compile down to actual machine instructions. -- Finlay McWalterTalk 00:09, 21 September 2015 (UTC)[reply]

ASP.NET authentication question[edit]

I have run into a problem at work. This is about authenticating a user into an ASP.NET C# web application using username/password Forms authentication.

The thing is, the username/password that the user types in and the application verifies against the database needs to be different from the username that the application actually authenticates and stores in the authentication cookie.

I am using an ASP.NET Login control to do the username/password authentication. The username/password verification is done with a custom-made MembershipProvider class. Is it somehow possible to change the authenticated username after a successful verification in the OnLoggingIn, OnAuthenticate or OnLoggedIn events? JIP | Talk 19:42, 16 September 2015 (UTC)[reply]