text:
Q: Why is memory access in the lowest address space (non-null though) reported as NullReferenceException by .NET? This causes an AccessViolationException to be thrown:
using System;

namespace TestApplication
{
    internal static class Program
    {
        private static unsafe void Main()
        {
            ulong* addr = (ulong*)Int64.MaxValue;
            ulong val = *addr;
        }
    }
}

This causes a NullReferenceException to be thrown:
using System;

namespace TestApplication
{
    internal static class Program
    {
        private static unsafe void Main()
        {
            ulong* addr = (ulong*)0x000000000000FF;
            ulong val = *addr;
        }
    }
}

They're both invalid pointers and both violate memory access rules.
Why the NullReferenceException?

A: This is caused by a Windows design decision made many years ago.  The bottom 64 kilobytes of the address space is reserved.  An access to any address in that range is reported with a null reference exception instead of the underlying access violation.  This was a wise choice, a null pointer can produce reads or writes at addresses that are not actually zero.  Reading a field of a C++ class object for example, it has an offset from the start of the object.  If the object pointer is null then the code will bomb from reading at an address that's larger than 0.
C# doesn't have quite the same problem, the language guarantees that a null reference is caught before you can call an instance method of a class.  This is however language specific, it is not a CLR feature.  You can write managed code in C++/CLI and generate non-zero null pointer dereferences.  Calling a method on a nullptr object works.  That method will merrily execute.  And call other instance methods.  Until it tries to access an instance variable or call a virtual method, which requires dereferencing this, kaboom then.
The C# guarantee is very nice, it makes diagnosing null reference problems much easier since they are generated at the call site and don't bomb somewhere inside a nested method.  And it is fundamentally safer, the instance variable might not trigger an exception on extremely large objects when its offset is larger than 64K.  Pretty hard to do in managed code btw, unlike C++.  But doesn't come for free, explained in this blog post.

A: This may be a semantics issue.
Your first example is trying to dereference a pointer whose content is the address Int64.MaxValue, not a pointer to a variable that has a value of Int64.MaxValue.
Looks like you're trying to read the value stored at the address Int64.MaxValue, which is, apparently not in the range that's owned by your process.
Do you mean something like this?
        static unsafe void Main(string[] args)
        {
            ulong val = 1;// some variable space to store an integer
            ulong* addr = &val;
            ulong read = *addr;

            Console.WriteLine("Val at {0} = {1}", (ulong)addr, read);

#if DEBUG
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();
#endif
        }

A: from http://msdn.microsoft.com/en-us/library/system.accessviolationexception.aspx

Version Information
This exception is new in the .NET Framework version 2.0. In earlier
  versions of the .NET Framework, an access violation in unmanaged code
  or unsafe managed code is represented by a NullReferenceException in
  managed code. A NullReferenceException is also thrown when a null
  reference is dereferenced in verifiable managed code, an occurrence
  that does not involve data corruption, and there is no way to
  distinguish between the two situations in versions 1.0 or 1.1.
Administrators can allow selected applications to revert to the
  behavior of the .NET Framework version 1.1. Place the following line
  in the  Element section of the configuration file for the
  application:
other <legacyNullReferenceExceptionPolicy enabled = "1"/>

A: A null reference exception and an access violation exception are both raised by the CPU as an access violation. The CLR then has to guess whether the access violation should be specialized to a null reference exception or left as the more general access violation.
It is evident from your results that the CLR infers that access violations at addresses very close to 0 are caused by a null reference. Because they were almost certainly generated by a null reference plus field offset. Your use of unsafe code fools this heuristic.


text:
Q: GTM's Noscript tag - is it required? In Google Tag Manager, they provide two scripts which must be added to your pages:

I understand that the purpose of the  section is to load when the user does not have javascript enabled.  If I exclude this  tag from my body, what are the repercussions?

A: Well, you won't be able to measure pageviews for people who have Javascript disabled (but then you knew that).
The only tags that work in the GTM noscript tag are custom image tags, and if you want to get values from the page they need to appended as key/value pairs (i.e. query string) to the GTM url in the noscript tag.
You have to judge yourself if that's worth the trouble for you.
IIRC you cannot verify a site for Google Search Console via the GTM code if the noscript thing is not implemented, but that is about the worst that can happen.

redpajama_set_name: RedPajamaStackExchange


text:
Q: mod_evasive me bloquea la ip de mi servidor siempre He instalado mod_evasive en mi CentOS 7.3 y así probar el Perl de pruebas.
Tal y como esperaba, me lanza el error 403.
Modifiqué el archivo de configuración de evasive para que salte cuando recargan la página dos veces en menos de 2 segundos (a modo de prueba desde un navegador).
Resulta que mod_evasive está bloqueando la IP del servidor y no la del ordenador que hace las peticiones.
Es decir, si salta el módulo no bloquea la IP del que accede (cliente) sino la de acceso (servidor), quedando el error 403 para todo el mundo.
¿Qué está pasando?
¿Es una mala instalación o me estoy perdiendo algo?
añadir que uso apache junto a ngnix
caracteristicas:
SO: CentOS Linux 7.3.1611 (Core)
Plesk Onyx 17.5.3


text:
Q: Increase max_execution_time in PHP? I'm trying to upload large files to my server (my server support post_max_size 192mb and max_execution_time 600 sec). When I upload 100mb files execution will stop after 600 sec so files are not uploaded to the server. How can I increase max_execution_time in PHP (only for the file uploading process)? I have tried:
ini_set ( 'max_execution_time', 1200);
if(move_uploaded_file($_FILES['Video']['tmp_name'],$tmppath)) {
  // ...
}

Any ideas how I can overcome this?

A: Theres a setting max_input_time (on Apache) for many webservers that defines how long they will wait for post data, regardless of the size. If this time runs out the connection is closed without even touching the php.
So your problem is not necessarily solvable with php only but you will need to change the server settings too.

A: Add this to an htaccess file (and see edit notes added below):
<IfModule mod_php5.c>
   php_value post_max_size 200M
   php_value upload_max_filesize 200M
   php_value memory_limit 300M
   php_value max_execution_time 259200
   php_value max_input_time 259200
   php_value session.gc_maxlifetime 1200
</IfModule>

Additional resources and information:

*

*https://www.php.net/manual/en/info.configuration.php

*https://www.looklinux.com/how-to-set-php-maximum-execution-time-in-an-htaccess-file/

2021 EDIT:
As PHP and Apache evolve and grow, I think it is important for me to take a moment to mention a few things to consider and possible "gotchas" to consider:

*

*PHP can be run as a module or as CGI. It is not recommended to run as CGI as it creates a lot of opportunities for attack vectors [Read More]. Running as a module (the safer option) will trigger the settings to be used if the specific module from <IfModule is loaded.

*The answer indicates to write mod_php5.c in the first line. If you are using PHP 7, you would replace that with mod_php7.c.

*Sometimes after you make changes to your .htaccess file, restarting Apache or NGINX will not work. The most common reason for this is you are running PHP-FPM, which runs as a separate process. You need to restart that as well.

*Remember these are settings that are normally defined in your php.ini config file(s). This method is usually only useful in the event your hosting provider does not give you access to change those files. In circumstances where you can edit the PHP configuration, it is recommended that you apply these settings there.

*Finally, it's important to note that not all php.ini settings can be configured via an .htaccess file. A file list of php.ini directives can be found here, and the only ones you can change are the ones in the changeable column with the modes PHP_INI_ALL or PHP_INI_PERDIR.

A: Is very easy, this work for me:
PHP:
set_time_limit(300); // Time in seconds, max_execution_time

Here is the PHP documentation

A: For increasing execution time and file size, you need to mention below values in your .htaccess file. It will work.
php_value upload_max_filesize 80M
php_value post_max_size 80M
php_value max_input_time 18000
php_value max_execution_time 18000

A: // Karvy master upload module
function uploadKarvyData()
{
    ini_set('MAX_EXECUTION_TIME', -1);
    ini_set('memory_limit', '-1');
    or
    ini_set( 'memory_limit', '1024M' );
    ini_set('upload_max_filesize', '1024M');
    ini_set('max_input_time', 360000);
    ini_set('max_execution_time', 360000);
}


text:
Q: Given a % of change and the resulting value after the change, how do you calculate the original value? Given a % of change and the resulting value after the change, how do you calculate the original value?
For example, X increased by 50% = 150. In this case we can easily use guess and check to see that X = 100, but how do you calculate this given any percentage of change and any resulting value?
I though this formula should work, but it does not. As you can see my algebra is quite rusty, so maybe you can help.
start = x
percentage of change = p
resulting value = r

x * (p / 100) + x = r

Which can be simplified to
2(p / 100)x = r

which is equivalent to
x = r / 2(p / 100)

But when I check my work, this is wrong:
100 = 150 / 2(50 / 100)
100 = 150 / 2(.5)
100 = 150 / 1
100 = 150

A: Hint: If a number $x$ changes by $p$ percent, the resulting value is $\left(1+\frac{p}{100}\right)x$.
So the basic equation you have to solve is $\left(1+\frac{p}{100}\right)x =r$.
Your expression "2(p/100)x" is incorrect.


text:
Q: Sexism in conversation moderation, or, why wasn't I suspended? Earlier today I was involved in a conversation on Stack Overflow which resulted in one user, Julia Anne Jacobs, being suspended, and another receiving a warning from a moderator.
The timeline from my perspective is:

*

*Julia posted an answer to this question about Angular.

*Another user, who may remain nameless for the purposes of this conversation, posted a very similar answer to hers, a few moments later.

*Julia believed that her answer was plagiarized, and told the other answerer so.

*Another user, "Concerned Father" (note the gendered and quite literally patronizing name) posted an answer containing some obnoxious tone-policing comments about her frustration with this other answerer.

*A moderator then deleted that answer.

*Due to the fact that high-reputation users have different visibility into things like edit histories and deleted comments, a mutual friend asked me to have a look at the chat conversation.

*I joined the chat, and asked the original answerer to delete their answer because, although it was perfectly usable as an answer, he was high-reputation and she was low-reputation and if he honestly did not care about points, then he should be OK with paying that small cost to avoid the appearance of plagiarism.  He conceded to this point and did so, but not without a significant amount of patronizing comments.

*Our mutual friend knows a stack exchange developer as well, and asked what to do about this, she was referred to a moderator, who she then asked to look at the conversation.

As a result of these events, Julia and our mutual friend both received warning messages from moderators, and Julia received a 7-day suspension.  The message to Julia said "other users were merely trying to help", and that "no one is copying you", but it is not clear how Julia was supposed to know these things given SO's fairly opaque user interface when it comes to tracking provenance of edits for (relatively) low-reputation users.
This timeline raises a number of questions:

*

*Why were there warnings issued at all?  Based on what rules?

*Why was our mutual friend given a warning about "bullying" when she got a moderator involved specifically to make sure things were being adjudicated by the rules of the site?

*Where are the rules that say that summoning allies and colleagues to a conversation is forbidden?

*Why was Julia given an immediate suspension rather than a warning and a reference to the relevant portions of the code of conduct?

*How did the moderators know that the other account was not a sock puppet, and more importantly,

*how was Julia supposed to know that without special moderator spectacles on?

Note please that in summoning me, Julia did not summon a horde of trolls to complain with a social-media cattle call, but rather a specific ally for a specific purpose (someone with high enough reputation to see what was going on in ways that she potentially couldn't).  By blaming her for summoning help, the SO moderator in this case has denied that I have responsibility for my own actions.
Throughout the conversation, all of these interactions reeked of the kind of implicit sexism that pervades the tech industry.  Then, two women participating were warned, apparently for accusing the other answerer of things, but my sternly-worded accusation of sexism apparently didn't even warrant a brief contact from a moderator.  I am open to another explanation as to why, but the default "because I don't present as female in this conversation" is too obvious to ignore.
I feel like the rules here are poorly explained and inconsistently applied, so I don't think anyone deserves a suspension.  Perhaps a moderator should have contacted Julia and explained how some of these site features worked, how to determine whether there was or was not plagiarism, and given other escalation channels to use in the future.  However, if there is a good reason that she was suspended, I feel like I should have a similar length of suspension, or at the very least a warning from a moderator.
I want to be clear about this part - asking for a suspension for myself is not a rhetorical device.  If I am given a 7-day suspension on SO as a result of posting this I will feel that SO is at least a little bit fairer; I won't complain.  I will still be annoyed about an opaque and arbitrary moderation process apparently run by people with no knowledge of or sympathy for the average experience of women in the software industry, but at least there will be an appearance of fairness.
If Stack Overflow is not going to have a reputation for being the same sort of scummy, sexist and racist space as other internet forums, these sorts of problems need to be dealt with with far greater transparency and clarity.  For example, another really necessary step here would be a clear explanation of what a low-reputation user should do in situations like this.  If it's against the rules to call for allies, and "bullying" to summon a moderator, then what options remain?

A: To be completely fair, after my initial investigation into the matter, I was fully prepared to just leave everything be for the remainder of the weekend and finish looking into it the next day. I wasn't even planning to take any action at all, but just to followup and make sure the situation had died down and no one was still arguing. Then she started accusing the other user of sock-puppetry, for no other obvious reason than that user's answer was accepted and hers wasn't. At that point, it became very clear that the behavior wasn't because of a misunderstanding. She was actively throwing out accusations at users with absolutely no evidence whatsoever.
We get users who complain about other users "stealing their answers" more often than you might think, and I have to say that this particular case is probably the most dramatic that I have ever seen. Most cases end fairly quickly without much of an incident. Someone points something out, and the user realizes they were mistaken. That certainly didn't happen here.
Calling in other friends to side with you is definitely not the best approach to resolve a situation. All that does is create a one-sided argument and make the other user feel uncomfortable. Much better approaches would have been to:

*

*simply flag the content for a moderator. Moderators can very easily see timelines of everything that happened and come to very speedy conclusions about what happened on a post.

*come to Meta so everyone can give their input and explain why the person is or is not wrong.

But a three-versus-one conversation in a chat room hidden away in the depths of the site? Not all that constructive.
Now, why weren't you contacted? While your comments about sexism were pretty baseless and I didn't understand why you even brought that up, there was one fact that stood above everything: you were actively trying to defuse the situation. You came up with a logical solution to end the drama - great, that's our favorite thing for users to do. End it and move on.
Why was Julia suspended? Because suspensions are a quick and efficient way to put an immediate stop to certain behavior. Warnings can be ignored, or behavior can continue before the warning even gets read. The behavior being targeted here needed to end right away. I sincerely hope she will calm down and realize that she went off the rails here, because the conversation in chat actually did start off very pleasant and civil before evolving into a train-wreck.

A: sigh I have felt this way at least once on SO, but didn't want to say anything to anyone (other than discussing at home) because I don't want to be "that girl" who's saying "Boohoo, they were snarky and treated me badly because I'm a giiirl" but at the same time...that's what it felt like...
It was as if I had asked a question and then was being encircled by sharks within a few moments of daring to ask anything while wearing makeup in the Hallowed Hall of Nerds. I am also a nerd, regardless of what my picture looks like, albeit I am FAR less skilled than many of the whizkids who post here - which is why I show up - to learn from people who are smarter and more experienced than me. I'm a noob. Sorry, weren't you once? No? That's pretty magical.
It wasn't just the question I'd asked that got picked apart, there were other, unnecessary comments and a lot of snark - BUT not from everyone. There were a few helpful souls who did their best to provide useful, evidentiary and legitimate answers to my question before it was closed, with no concern for some of the other impolitenesses occurring by a couple of other users.
I had actually wondered if I should change my profile picture (I have my account linked with facebook, so it's currently pulling that pic) to something more manly, maybe a big, hairy pair of....beards. Or something. It crossed my mind that then I wouldn't have to worry about (real or perceived) rudeness due to being a female, or looking like I don't have the right to be working in the tech industry.
I hate even playing this game, gender/identity/whatever shouldn't be a factor, and if the answers and reprimands I was given had been solely based on my content's lack of merit, I wouldn't feel so badly.
Don't get me wrong, getting told "Your question isn't cool"...never feels good, but hey - I'm not above trying harder to improve the quality of my postings, as some of the commentary in that thread will illustrate.
I felt like I'd asked a relevant question, followed the "no opinions" guideline by asking for all answers to be backed up with evidence, in hopes that I could learn from some real-world experiences that others have had...and I got put up for "Close This Question - Off-Topic", within five minutes or so.
The person who flagged it was full of veiled insults and snark, and two others came out of the woodwork (in the same five or ten minutes) to start criticizing my sentence structure and other irrelevancies. It's definitely not like I pulled a "Wut does my compuuterz do when I push teh butten?" or anything - I have decent writing skills. Good grief. The worst you can call me is long-winded, and that's just...true. :D
One of those users who stepped in to correct me and pick at the structure of my question did so politely - no problem there. That person provided valuable feedback on utilizing more paragraph spacing to make my question more reader-friendly, and I appreciated that.
The other...while I eventually pried some useful information out of him, was a jerk. And the high-rep user who flagged me as if he was sitting, circling, waiting, was a third.
I DID eventually get a better answer from another user later as to why my question may have been closed (he/she gave me some good insight as to the "off-topic" portion of the closure), but they still were not able to explain why or how asking for a fact-based answer with evidence...is considered "soliciting opinions".
I don't come to tech forums to ask legitimate questions and get answers from people acting like snot-nosed brats, and I was more than a little taken aback. I am glad you posted this question thread, as even though it's an old question...it's still relevant, and it still affects the Stack family of users. Now to go find a picture of something manly. Maybe a lumberjack.

A: 2018 Update to this, from a personal level:
I'm not going to get overly specific, but there were some things going on at the time that prevented me from seeing something that was pretty painfully right in front of us:
We (or at least I) assumed everyone involved was a man, except in the case that the user visibly identified as not being a man. Had we not done that, we would have understood why folks involved continued to get increasingly upset as we continued to apologize for the wrong things.
While this is unfortunately quite late, I take responsibility for this personally, and can only offer the apology I should have offered some time ago.
I know there's an apology right under this, but I essentially stepped on someone's foot and then apologized for setting their couch on fire. Or the reverse of that. In any event, I didn't handle this as well as I could have, and I own that.
I'm sorry.

As I noted as an edit to my previous answer, some mistakes that I can only describe as bone-headed were made on our part in the course of handling a recent situation.
tl;dr; - we failed to realize what was right in front of us, and we mistakenly accused someone that was actively helping the situation cool down of being combative and ill-intended as we floundered in helping a very confused inexperienced user understand what was happening by blaming instead of teaching.
While everything surrounding this chain of events is a bit bizarre, it's our job as the overseers to get stuff like this right. We didn't, which let some people down and hurt them, which means we've got some apologies to make. Let's start there.

*

*satyrwilder was issued a very stern, and completely inappropriate warning for 'ganging up' - this user did nothing more than try their best to defuse the situation while mentioning our code of conduct, and kept reminding people to be nice. She was also not heard when she was trying to tell us that we had / did everything wrong.

*Julia Anne Jacobs was issued a suspension that was excessive in the context of being used to temporarily freeze the situation so that we could make sense of it. She needed our help as a very confused inexperienced user, and we didn't listen. Moreover, we told her she was doing bad things while she was just repeating what other seasoned users had suggested, which we should have seen.

*I'm pretty sure Glyph pulled out some hair as I remained dense in light of him trying his best to say I think you've got this completely wrong.

What bothers me the most is that several of us read the chat transcript and we still managed to get it wrong. We looked at every single letter, we just didn't get it.
To the three of you, we owe you an apology, and we hope that you'll accept it. You trusted us to do a much better job than we did, and we let you down this time. You have also been extremely gracious as we worked through this, and we very much appreciate that.
How in the heck did this happen?
Look back at Glyph's original question. Do you see the mention of a post by "Concerned Father"? Yes, a troll happened upon the confrontation as it was progressing, and took it upon themselves to 'get involved' by typing complete rubbish into a text box. Once we ascertained that it had no connection to either party in the argument, we set it aside as we continued to try and figure out what was going on. In doing that we completely negated the fact that people get harassed on the Internet far too regularly, and how the heightened state of anxiety folks could could have been feeling contributed to things.
We then looked at chat which was getting a little hotter near the end, looked at comments, and issued one suspension to stop things from escalating even more while we worked. That's not an uncommon thing for us to do when people are arguing quite heatedly, but what was really needed was a 'side bar' to explain some things about the system in a much nicer way.
To top that off, instead of thanking someone that worked really hard to keep things sane, we sent a very stern and cold warning, because reactions on our part started happening as the chat was being read.
I then took notice, looked into the situation, and only really understood half of it. 'Snow blindness' is the only term I can think of to describe it. 'Dense' equally applies.
What about going forward?
We, the community managers that oversee the workings of community moderation on our sites, must catch things like this, 'perfect storm' or not. We're going to be extending our training for employees on the community team based on what transpired, and look at existing guidance to fill in ambiguities.
We will also be sharing quite a bit of this with our community moderators, through our existing monthly email to them that goes over important things to know.
Is it possible to keep mistakes from happening in a network of our size? No. Is it our job to catch those mistakes with near-perfect accuracy? Yes, and we need to get better at that, which we're going to do - starting right now.

A: Note
It's very important to see this chat transcript (all of it) for context. I'm going to be posting a follow up answer shortly, we got a few things very wrong when handling this.
Please see this updated answer

Some things here. Just things everyone can take away so this unfortunate chain of events can bear some moderately useful fruit.

although it was perfectly usable as an answer, he was high-reputation and she was low-reputation and if he honestly did not care about points, then he should be OK with paying that small cost to avoid the appearance of plagiarism.

Quick compromise is a great way to resolve a conflict that's escalating rapidly, another approach is to beat on a monotone drum. It's always a source of contention when two nearly-identical answers are posted in quick succession, but there are many, many cases where appropriate and useful answers will be very close to one another; similarity to another answer is no reason to abandon your composition or composure.
Deleting your answer, or 'yielding' is not the right thing to do if you feel that doing so is a tacit acknowledgement of the claims being made. There's essentially one good answer to this, I wrote mine at the same time you were writing your answer, I don't see a reason to abandon the work. Just beat that drum and ignore the rest. If you think retribution is afoot, involve a moderator.
Don't offer to pay for the chewing gum the security guard thinks you stole if you know you didn't steal it.

Throughout the conversation, all of these interactions reeked of the kind of implicit sexism that pervades the tech industry.

Reading additional malice in the apparent presence of an 'ism' into the actions others have taken can really make the problem at hand seem much bigger than it actually is, because that's what happens when you get really angry.
When diffusing situations like this, focus on the what before you focus on the why, or you give the what a significant advantage as it balloons. I am not negating the importance of the why, but that's something to analyze after the situation stops moving.
If the root of pathologically inappropriate behavior seems to be some kind of hate that is in no way relevant to the merits of the contributions that provoke it, we will happily let someone know that the site appears to bring out the worst in them, and that they need to find another place to participate.

I feel like the rules here are poorly explained and inconsistently applied, so I don't think anyone deserves a suspension.

Animuson did a good job of explaining his decisions and I don't think I would have done things any differently. Conflict implies a degree of chaos and there's no practical way of spelling out what gets a warning, what gets a suspension and what isn't found actionable in the context of moderation - it's all about the context and these 'spats' are famous for coming out of nowhere.
We intervene as minimally as possible, and only to the degree that is necessary to curtail disruption. You don't know ahead of time just how much intervention is required, because these conflicts have a nasty habit of never having existed before they become an urgent problem :) It's up to moderators (and employees) to use their training and experience to do the least amount that is needed. If we tried to make that into a flow chart, there would be a giant "... and a human being looks at everything and makes a decision ..." box.
As long as you try to be nice and try not to assume the worst in people, you'll probably never hear from a moderator.

A: If anyone needs to know how the other half experiences SO / SE / ME, etc. do the following as an exercise:

Create a new profile (low rep points) that can be recognized as female
  and participate.  Take notice of how you feel with this profile
  and if your experience is different. Don't try to act like you
  think a woman would act, just do your thing and see if you get a
  different response.

I've done that on tech IRC channels and it's been an eye opening experience.  In general I've felt much more confident and safer under a male sounding nick, was addressed less critically, more supported (as an equal, not condescended to) and my opinions seemed to have more weight (more influence over the conversation).
Having the actual experience is more evidence than screenshots, chat transcripts, interviews, data mining, user IP tracking, etc.
That should probably be part of the training Tim Post mentions in his answer.

A: This whole thing was an anomaly. And it is so because evidence was able to be gathered and employees actually showed up. I have seen this happen many times but never before with clear documentation of it happening. The man acted in a very threatening manner and was able to create a burner account that could do things with just one point of reputation and acted in a way that was clearly against all common decency and kindness yet the ones punished for this where women. The only people making threats where men. The whole thing was so disturbing that it actually set off my post-traumatic stress disorder (PTSD). For a while there I was so freaked out that I tried to contact several moderators including animuson because I genuinely felt that Julia was in real and imminent danger. However all but one of my cries for help fell on deaf ears. Here is the reply I got:

Chango,
I went through the user's history, including all comments made in the
  last week, and I see no evidence of anyone coming unhinged. I saw a
  bit of a debate which (in the grand scheme of things) was probably one
  of the more polite discussions that flare up in comments from time to
  time. I served as one of your elected moderators for years prior to
  ultimately becoming one of the senior community managers, and I'm
  frankly not seeing what you're seeing.
It could be that three of us now have just missed something painfully
  obvious, that can happen in the enormous swath of information one can
  dig out of a profile; a link to a specific comment or incident or even
  a place to start would be really helpful if you think someone is
  coming unglued.
What I'm not seeing is the trolling, which is why I'm not getting the
  vibes that you're getting.
Was the actual trolling itself present in chat, not really comments? I
  took a cursory glance at the transcripts and nothing jumped out at me.
In short, links help, this user is extremely active - there are many
  haystacks here, which one is most likely to contain the needle? :)

I am a United States Air Force vet I was stationed in Turkey. This whole incident has left me severly affected and it has proven 3 things with out a shadow of a doubt

*

*Systemic sexism is clearly happening in Stack Overflow

*The men in charge of Stack Overflow clearly do not care that this is the case

*When forced to deal with it they will mercilessly attack women

If you do not see this, there is something very wrong with you. I beg you to open your eyes, have at the very least a molecule of human decency and compassion. What good can there be of alienating women and minorities from the tech? A woman birthed you, cared for you, loved you and you thank that kindness with cruelty and spite. You are destroying your very humanity and you do it with such glee!
I would write more but I need to curl up into a ball from how sick this whole  torture session has left me. And may something have mercy on your souls.


text:
Q: How to get the reachability/ status of an API? [.NET 4.7.2 WPF]
I am planning to send requests to an API which is on several machines, so I was thinking how I could check the status of the connection between the two machines, when my request looks like the below code?
So on my control app I would like to show a traffic light system of each IP e.g. 192.0.0.1:5555(GREEN avialable) 192.0.0.5:5555(Red not avialable)
I am sending to e.g.192.0.0.1:5555/data/Getname so I would like to know the connectivity before sending the command?
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestURIString);
request.UserAgent = "Test App";
request.Method = method;

if (body != "")
{
     p_CurrentAPIRequest = body;
    request.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), request);
}
else
    request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request);

allDone.WaitOne();


text:
Q: SSIS:Unable to remove Column headers in Flat file destination I am using DataFlow task inside ForLoop Container. What am i excatly doing is that DFT will append a batch of 100 rows each time the for loop will run. But every time, it append rows, Headers are also appended.
I have tried by changing Flat File Connection Manager Editor(General) properties.Setting Header rows to skip to 2. But Still headers are appended. Can anyone help me out on this?

A: First, add an SSIS integer variable in the scope of the Foreach Loop or higher - I'll call this RowCount - and make its default value negative (this is important!).  Next, add a Row Count to your Data Flow, and assign the result to the RowCount SSIS variable we just made.  Third, select your Connection Manager (don't double-click) and open the Properties window (F4).  Find the Expressions property, select it, and hit the ellipsis (...) button.  Select the ColumnNamesInFirstDataRow property, and use an expression like this:
[@User::RowCount] < 0
Now, when your package starts, RowCount has the static value of -1 or another negative number.  When the data flow starts for the first time in your loop, the ColumnNamesInFirstDataRow property will have a value of TRUE.  When the first data flow completes, the row count (even if it's zero) is written to the RowCount variable.  On the second interation of the loop, the Connection Manager is then reconfigured to NOT write column names...
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/5a752fa5-1b3c-4d39-845c-b6cb7a2eb3fb/destination-flat-file-repeated-header-columns?forum=sqlintegrationservices


text:
Q: Build a vector of results using a function and argument as data frame Please advice which function (map/lapply/sapply ..) should I use if I have a function:
foo <- function(x, argument1 = "abc", default_score = def_score_dataframe)
returning score

Where x will be a data frame, argument1 will be changed each time I will run the function and default_score is a data.frame with: name, default_score,  in each row.
What I want is to use a one row function like map/lapply that will take a vector of values to assign to argument1 and to return a data frame with columns argument1_Value and Score
In other words something like this:
res_df <- lapply(argument_values,
                 foo(x, argument1 = argument_values, default_score = def_score_dataframe))

that should give me a result of:
res_df
# argument1_Value Score
#           "aaa"     5

A: I'll answer your problem using an example.
You have a function that operates on a data frame x, a vector (vectorArgument) and another parameter (exponent with default 2)
myFun = function(x, vectorArgument, exponent = 2){
  z = (colSums(x) - vectorArgument) ^ exponent
}

If you apply this function to
df = data.frame(A = 1:4, B = 5:8)
d = myFun(df, c(1,22),3)

# You would get:
> d
A   B
729  64

Now you have a set of vectorArguments in another data frame:
argumentsDF = data.frame(arg1 = c(1,22), arg2 = c(3,3), arg3 = c(17,21))

In order to calculate the above function on df and for each column (margin = 2) as the vectorArgument parameter, do:
result = apply(X = argumentsDF,
           MARGIN = 2,
           FUN = function(y){
             myFun(x = df,
                   vectorArgument = y,
                   exponent = 3)
             }
           )

You'll obtain:
> result
  arg1  arg2 arg3
A  729   343 -343
B   64 12167  125


text:
Q: Can I use arrow function in constructor of a react component? This question is similar to When using React Is it preferable to use fat arrow functions or bind functions in constructor? but a little bit different. You can bind a function to this in the constructor, or just apply arrow function in constructor. Note that I can only use ES6 syntax in my project.
1.
class Test extends React.Component{
  constructor(props) {
    super(props);

    this.doSomeThing = this.doSomeThing.bind(this);
  }

  doSomething() {}
}

2.
class Test extends React.Component{
  constructor(props) {
    super(props);

    this.doSomeThing = () => {};
  }
}

What's the pros and cons of these two ways? Thanks.

A: I think you may want like this. It is the same with your first situation.
it will work in stage-2 with babel. (transform-class-properties : http://babeljs.io/docs/plugins/transform-class-properties/)
(preset-stage-2: http://babeljs.io/docs/plugins/preset-stage-2/)

class Test extends React.Component{
  constructor(props) {
    super(props);
  }
  doSomeThing = () => {}
}

A: Approach 1 is more readable for me and more idiomatic.
Besides, declaring methods inside a class instead of constructor, the methods can be shared.
class Foo {
  test() {}
}

const f1 = new Foo()
const f2 = new Foo()
f1.test === f2.test // true

In approach 2, you will declare all the methods every time you create a new instance:
class Foo {
  constructor() {
    this.test = () => {}
  }
}

const f1 = new Foo()
const f2 = new Foo()
// the method is not shareable
f1.test === f2.test // false

Theoretically the approach 2 is slower, but the impact on performance should be negligible.
I'll simply go for approach 1, since it's used in the React documentation, also I never saw anyone use approach 2.

I just ran some samples to test the performance. In latest Chrome (Mac), declaring methods in constructor is about 90% slower than using bind in constructor.

A: Option 1 is generally more preferable for certain reasons.
class Test extends React.Component{
  constructor(props) {
    super(props);

    this.doSomeThing = this.doSomeThing.bind(this);
  }

  doSomething() {}
}

Prototype method is cleaner to extend. Child class can override or extend doSomething with
doSomething() {
  super.doSomething();
  ...
}

When instance property
this.doSomeThing = () => {};

or ES.next class field
doSomeThing = () => {}

are used instead, calling super.doSomething() is not possible, because the method wasn't defined on the prototype. Overriding it will result in assigning this.doSomeThing property twice, in parent and child constructors.
Prototype methods are also reachable for mixin techniques:
class Foo extends Bar {...}
Foo.prototype.doSomething = Test.prototype.doSomething;

Prototype methods are more testable. They can be spied, stubbed or mocked prior to class instantiation:
spyOn(Foo.prototype, 'doSomething').and.callThrough();

This allows to avoid race conditions in some cases.

A: Check this out:
https://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Creact%2Cstage-2&targets=&browsers=&builtIns=false&debug=false&code=class%20Dog%20%7B%0A%20%20constructor()%20%7B%0A%20%20%20%20%0A%20%20%20%20this.cat%20%3D%20_%3D%3E%20%7B%0A%20%20%20%20%20%20this%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D
We can see babel transpiles
this.doSomeThing = () => { this };

into
var _this = this;
this.doSomething = function() { _this }

edit: I misread your post slightly, but the above is still true and interesting. @CodinCat points out the important thing: declaring a function inside the constructor means it takes time (albeit very little) to add that function to the object when it is created, and also probably takes memory because instances of that class don't share the same doSomeThing method.
edit2: binding (this) to the function actually causes the exact issues I listed above. In other words the two methods are almost exactly the same.


text:
Q: Delphi _Como passar dados para uma propriedade do tipo array de record  unit Exemplo;

interface
uses Classes,
     SysUtils, typinfo;

const

type

  {TRecordRateio}
  TRecordRateio =       Record
    IdContaCorrente   : Integer;
    CodBanco          : String;
    Agencia           : String;
    DVAgencia         : String;
    ContaCorrente     : String;
    DVContaCorrente   : String;
    DVAgenciaConta    : String;
    NomeBeneficiario  : String;
    CodRateio         : String;
    EPercentual       : String;
    ValorRateio       : Currency;
    FloatingRateio    : String;
    DataCredito       : TDateTime;
 end;

 TArrayOfRateio =  Array of TRecordRateio;

  TTeste = class(TComponent)
  private
    fRateio        : TArrayOfRateio;
    function GetRateio(AIndex: Integer): TArrayOfRateio;
    procedure SetRateio(AIndex: Integer; const Value: TArrayOfRateio);

  public
    constructor Create( AOwner : TComponent ) ; override ;
    destructor Destroy; override;
    property Rateio[AIndex : Integer] : TArrayOfRateio read GetRateio Write SetRateio; default;
  published
    property Nome         : String read fNome  write fNome;
  end;

implementation

Uses Forms, Math, dateutils, strutils;

constructor TTeste.Create( AOwner : TComponent );
begin
   inherited Create(AOwner);
   fNome   := '';
end;

destructor TTeste.Destroy;
begin
  inherited;
end;

function TTeste.GetRateio(AIndex: Integer): TArrayOfRateio;
begin
  Result[AIndex].IdContaCorrente  := Self.fRateio[AIndex].IdContaCorrente;
  Result[AIndex].CodBanco         := Self.fRateio[AIndex].CodBanco;
  Result[AIndex].Agencia          := Self.fRateio[AIndex].Agencia;
  Result[AIndex].DVAgencia        := Self.fRateio[AIndex].DVAgencia;
  Result[AIndex].ContaCorrente    := Self.fRateio[AIndex].ContaCorrente;
  Result[AIndex].DVContaCorrente  := Self.fRateio[AIndex].DVContaCorrente;
  Result[AIndex].DVAgenciaConta   := Self.fRateio[AIndex].DVAgenciaConta;
  Result[AIndex].NomeBeneficiario := Self.fRateio[AIndex].NomeBeneficiario;
  Result[AIndex].CodRateio        := Self.fRateio[AIndex].CodRateio;
  Result[AIndex].FloatingRateio   := Self.fRateio[AIndex].FloatingRateio;
  Result[AIndex].EPercentual      := Self.fRateio[AIndex].EPercentual;
  Result[AIndex].ValorRateio      := Self.fRateio[AIndex].ValorRateio;
  Result[AIndex].DataCredito      := Self.fRateio[AIndex].DataCredito;
end;

procedure TTeste.SetRateio(AIndex: Integer;
  const Value: TArrayOfRateio);
begin
  frateio[AIndex].Idcontacorrente  := Value[AIndex].IdContaCorrente;
  fRateio[AIndex].CodBanco         := Value[AIndex].CodBanco;
  fRateio[AIndex].Agencia          := Value[AIndex].Agencia;
  fRateio[AIndex].DVAgencia        := Value[AIndex].DVAgencia;
  fRateio[AIndex].ContaCorrente    := Value[AIndex].ContaCorrente;
  fRateio[AIndex].DVContaCorrente  := Value[AIndex].DVContaCorrente;
  fRateio[AIndex].DVAgenciaConta   := Value[AIndex].DVAgenciaConta;
  fRateio[AIndex].NomeBeneficiario := Value[AIndex].NomeBeneficiario;
  fRateio[AIndex].CodRateio        := Value[AIndex].CodRateio;
  fRateio[AIndex].FloatingRateio   := Value[AIndex].FloatingRateio;
  fRateio[AIndex].EPercentual      := Value[AIndex].EPercentual;
  fRateio[AIndex].ValorRateio      := Value[AIndex].ValorRateio;
  fRateio[AIndex].DataCredito      := Value[AIndex].DataCredito ;
end;

Como acessar a propriedade Teste.Rateio acima?

A: Penso que cometeste o erro de por a popriedade do tipo TArrayOfRateio em vez de TRecordRateio.
Se alterares para
 property Rateio[AIndex : Integer] : TRecordRateio read GetRateio Write SetRateio; default;

e os respectivos Set e Get para receber e enviar um TRecordRateio, ficas com o registo acessivel.


text:
Q: I need to modify the boilerplate login. I need only the email is required to enter I am starting with the use of Boilerplate and I would like to know if it is possible to customize the login that comes by default, for example: I need that only the email is required to enter and not ask for a password.

A: I think that is not possible by default.
But you can modify the login action on the Account controller and force always the same password to all of the users. The line is :
var loginResult = await _logInManager.LoginAsync(usernameOrEmailAddress, password, tenancyName);

Of course do the same on the user creation.


text:
Q: RDLC Expressions I am migrating from crystal reports to RDLC reports for my project i.e. in .NET Core. I developed my reports in RDLC and have used expressions in it. All of it works great locally. Now the issue is; on deploying I am getting the error shown below
An error occurred during local report processing.;The definition of the report 'D:/WebAPI/Reports/rpt_MyReport.rdlc' is invalid.
An unexpected error occurred while compiling expressions. Native compiler return value: '[BC30560] 'GeneratedCodeAttribute' is ambiguous in the namespace 'System.CodeDom.Compiler'.'.
Clearly there's some issue with expressions because on deploying a report with simple fields coming from database, the report works well.
Please help.

A: Please make sure you publish parameters as below.

A: I had same issue. After R&D I found that if we used concatenation within expression in RDLC. It generates this error. Try to remove all the fields (expression) from the RDLC and put just static label text and generate the report.
Hope this should work for you as well.


text:
Q: How can I set a value of an indexed variable? - Pyomo I'm working on a project related with AC OPF (Optimal Power Flow) and I was trying to solve a problem in python, using pyomo.
There are 3 buses and the bus voltage and bus angle are limited. However, the 1st bus must have a voltage=1 and an angle=0.
So, I tried this:
model.busvoltage = Var(model.bus, initialize=1, bounds=(0.95, 1.05), doc='Bus Voltage')
model.busvoltage[1].fixed=True
model.busangle = Var(model.bus, initialize=0, bounds=(-3.14, 3.14), doc='Bus angle')
model.busangle[1].fixed=True

The problem is that I just want to set the busvoltage and busangle for the first bus, without initializing the other ones with those values. I don't know if this is important to write, but I'm using ipopt as solver.
(This is my first time programming in Python) Any help would be appreciated!

A: You're after the .value attribute of the variable. Furthermore, setting the value of a variable and fixing it at the same time can be simplified to calling .fix():
model.busvoltage = Var(model.bus, bounds=(0.95, 1.05), doc='Bus Voltage')
model.busvoltage[1].fixed = True
model.busvoltage[1].value = 1

model.busangle = Var(model.bus, bounds=(-3.14, 3.14), doc='Bus angle')
model.busangle[1].fix(0)

A: Have you considered initializing the value in a constraint rather than in the Var definition?
model.busvoltage = Var(model.bus, bounds=(0.95, 1.05), doc='Bus Voltage')
model.busvoltage[1].fixed=True

def bus_voltage_1_value_constraint(model, b):
    if b == 1:
        return model.busvoltage[b] == 1
    return Constraint.Skip

model.bus_voltage_1_value = Constraint(model.bus, rule=bus_voltage_1_value_constraint)


text:
Q: Javascript scoped access performance - 25 times slower? I am a little bewildered by the extraordinary difference in the apparent speed of execution when assigning to variables declared in a function, and assigning to variables within the upper scope.
I have wrote a little measure function which I keep on the global scope for these kind of things, here's some results:
Chrome (console)
measure("assignment to var in current scope", function(){
  var i = 1;
  (function(){})(i)
})
15:52:49 |INFO| Measure 'assignment to var in current scope' performed 76236944 operations per second
iterations: 10000000    duration: 141   totalcalllag: 9.83

... and in the upper scope
var i = 0;
measure("assignment to var in upper scope", function(){
  i = 1;
  (function(){})(i)
})
15:53:22 |INFO| Measure 'assignment to var in upper scope' performed 2935124 operations per second
iterations: 10000000    duration: 3417  totalcalllag: 9.99

That is 76 million ops/sec for assignment in scope compared with 3million ops/sec for assignment in upper scope for a ratio of ~ 1:25!

IE11 (console)
measure("assignment to var in current scope", function(){
  var i = 1;
  (function(){})(i)
})
15:54:14|INFO| Measure 'assignment to var in current scope' performed 46038396 operations per second
iterations: 10000000    duration: 247   totalcalllag: 29.790000000000002

var i = 0;
measure("assignment to var in upper scope", function(){
  i = 1;
  (function(){})(i)})
8669267
15:54:49 |INFO| Measure 'assignment to var in upper scope' performed 8669267 operations per second
iterations: 10000000    duration: 1183  totalcalllag: 29.5

Here we see 46 million as opposed to 8.5 million ops per second.

The measure function
var measure = function (desc, f) {

    // measure the calling code first
    var start, stop, callLag, nothing = function () {
    };
    var iterations = 0;
    var COUNT = 1000;
    var duration = 0;
    while (duration < 10) {
        COUNT *= 1000;
        start = (new Date()).getTime();
        while (iterations != COUNT) {
            ++iterations;
            nothing();
        }
        stop = (new Date()).getTime();
        duration = stop - start;
    }
    callLag = duration / COUNT;

    // measure for total time between 0.1 & 10 seconds
    iterations = 0;
    COUNT = 1000;
    duration = 0;
    while (duration < 100) {
        COUNT *= 100;
        start = (new Date()).getTime();
        while (iterations != COUNT) {
            ++iterations;
            f();
        }
        stop = (new Date()).getTime();
        duration = stop - start;
    }

    // calculate operations per second
    var opsPerSec = Math.floor(1000 * (iterations / (duration - (callLag * iterations))));

    Log.info("Measure '" + desc + "' performed " + opsPerSec.toString() + " operations per second\n" +
        "\titerations: " + iterations + "\tduration: " + duration + "\ttotalcalllag: " + callLag*iterations);

    return opsPerSec;
};

Questions
I am going to be doing some heavy number crunching with JavaScript soon. Is this behaviour consistent across all browsers? Should I be implementing functions with this in mind? Should I pass parameters to functions internally to avoid accessing them within an upper scope?
... or have I just missed something?

A: In theory it shouldn't make any difference in JavaScript. Variable declaration is very important when it comes to JavaScript since language only has a function scope (as oppose to block scope). I always follow the advice given by JavaScript guru Douglas Crockford (Author of Javascript: The Good Parts).
JavaScript does not have block scope, so defining variables in blocks can confuse programmers who are experienced with other C family languages. Define all variables at the top of the function.
Please read more details at: Variable Declarations
I would also recommend using Crockford's JSLint: The JavaScript Code Quality Tool He also puts warning: JSLint will hurt your feelings


text:
Q: load a php file into a popup and post php variable to that popup (using onclick) I am trying to post the $GLABALS variable to another php file and get it to open in a popup and load the printOnly.php file with the value of the $GLOBLAS variable (which passes the name of the xml file used by $dom.
Currently it opens the popup but cannot find the value of the variable posted but it also loads the variable into the existing navigator window where the value of the posted variable is retrieved without a problem. I want the main window to stay on the original php page and only load the file called in the form to the popup.
On the original page I have:
<form name ="printView" method ="post" action="printOnly.php" target="popUp" >
    <input type="hidden" name="toPopFile" value="'.$GLOBALS["file"].'" />
    <input type="image" value="submit"  class="button" title="print view" src="graphics/printview.png" align="middle" onclick="javascript:viewClick(\'printOnly.php\')" />
</form>

In the file to be loaded into the popup I have:
$file=basename($_POST['toPopFile']); // value to be retrieved which is the name of the xml file currently loaded in original php file

$dom = new domDocument;
if (file_exists($file)) {
    $dom->load($file);
    } else {
    exit('Error ! xml file not found.');
}

And here is the javascript function being called from an external .js file
var view;
function viewClick(url) {
  view= window.open(url,'view text','menubar=yes,scrollbars=yes,resizable=yes,width=640,height=700');
  view.focus();
}

Help! (and keep it simple, I can parrot well, but I don't always understand what I'm doing)

A: Your form is using a POST method already, so I will start with that. It means using your submit button as a real HTML submit button (ie drop the onclick event). Then add a onsubmit handler to your post:
<form name="printView" method ="post" action="printOnly.php" target="popUp" onsubmit="popup(this);">

Add this function in your Javascript to create the popup, and then submit the form to it:
function popup(form) {
    window.open('', 'formpopup', 'view text','menubar=yes,scrollbars=yes,resizable=yes,width=640,height=700');
    form.target = 'formpopup';
}


text:
Q: Confusion about mysql_real_escape_string and strip_slashes I have users entering their name, as in: O'riley.
Before I enter this data into the MySQL DB, I run mysql_real_escape_string.
Problem is, when I then select this data for display and use later, it comes out as: O\'riley.
Obviously, this is the intended operation.  What I'm wondering is if there's someway to be sure I can store it in the DB (still safely escaping possible malicious code), so that I don't have to use strip_slashes() on the output EVERY time I call the data throughout the entire web app?  Or, am I missing something here?
Thanks.
UPDATE
Please refer to the comments in Deceze's answer.

A: I personally always turn off magic quotes because it is doing something I haven't told it to do.  If you dont have the ability to turn it off,   consider including this code at the top of all of your pages.
if (get_magic_quotes_gpc()) {
    function strip_array($var) {
        return is_array($var)? array_map("strip_array", $var):stripslashes($var);
    }

    $_POST = strip_array($_POST);
    $_SESSION = strip_array($_SESSION);
    $_GET = strip_array($_GET);
}

A: If you have magic quotes disabled, and in the case that get_magic_quotes_gpc returned 1 and you did something like @Michael shows and this still occurs, magic quotes runtime may be enabled.
Magic quotes runtime will add slashes to strings when doing database queries and even when writing to files. To disable this in the currently executing script, do:
if(function_exists('get_magic_quotes_runtime') && get_magic_quotes_runtime())
{
    set_magic_quotes_runtime(false);
}

You can also disable this configuration option through php.ini as well, if you can do so. However, if you can't disable it through php.ini permanently, you may need to add @ before get_magic_quotes_runtime and set_magic_quotes_runtime as PHP may through E_DEPRECATED errors if error_reporting is set to log such errors (and this will get fairly annoying).

A: Alright, here's what you need to do. First, based on the comments, from other questions:
ISOLATE
You need to determine what is causing the problem. Is it the server? Is it some hidden code somewhere? What? Some programmers may include code like this on a configuration page:
<?php if (isset($_POST))
    foreach ($_POST as $key => $value) $_POST[$key] = addslashes($value);
?>

So here are some checks to see if it is the server. This is about as solid a way of checking as possible. Create a NEW page. Leave it entirely blank and add this code:
<?php print_r($_POST); ?>
<form action="" method="POST">
<input type="text" name="test" value="O'riley" />
<input type="submit" name="submit" value="submit" />
</form>

Save it and load it in the browser. Hit submit. See if the slash is added still.
If it is still adding it, you need to troubleshoot your server / configuration. If it's a server you're paying for, you need to tell them to fix it or shove it. If it's your own server, then you're going to need to do some messing / googling to figure out how to turn off magic quotes.
If there are no quotes showing up, then there is definitely some code adding slashes to your post variables. It might not be as obvious as the code above, however. You need to run a search on your code for "addslashes", "mysql_real_escape_string", and possibly "str_replace". If you find one of these, you need to disable it. But be advised this may break other parts of your site that are assuming this action is taking place. You're other option for storing it in the database is to do a function similar to the code above, but instead, run stripslashes on it. Then you can run mysql_real_escape_string on it later. (A bit more unneeded overhead.)

A: Use
var_dump(get_magic_quotes_gpc());

somewhere near the actual use of the posted data to see if the Magic Quotes are really off.
Also some weird frameworks may add said quotes for you so grep your code for addslashes and other escape_string-like functions.

A: I would honestly suggest the use of PDO.
PDO employs the use of prepare and execute statements, which in turn adds security and removes some extra headache.
$pdo = new PDO();
$stm = $pdo->prepare('INSERT... (LastName) VALUES (:LastName)');
$stm->execute(array(':LastName' => "O'Rily"));

$stm->fetchAssoc(PDO::FETCH_ASSOC);

You no longer will need to worry about removing the escaping slashes as well as securing basic sql injection tactics.

A: No, it's not the intended operation to store the string as "O\'riley"; it should only be escaped in the query, but not stored this way. I'll guess that PHP puts in the backslash through Magic Quotes, and you escape it again to make it stick.
Disable Magic Quotes.

A: It's possible magic quotes are turned on in your httpd.conf or in a virtual host declaration.
The exact location and file will depend on OS and distro. I'd check Apache configuration files for the php_flag setting.

A: Just use clean the data before inserting in to database,
function check_input($value)
{
    if( get_magic_quotes_gpc() )
    {
        $value = stripslashes( $value );
    }

    //check if this function exists
    if( function_exists( "mysql_real_escape_string" ) )
    {
        $value = mysql_real_escape_string( $value );
    }

    //for PHP version < 4.3.0 use addslashes
    else
    {
        $value = addslashes( $value );
    }

    return $value;
}

$cleandata = check_input($value);

$sql = "INSERT INTO `table_name` SET `field_name`='".$cleandata."'";

While fetching the data and show into it use stripslashes($val)

A: Thank you everyone for the answers.  I will award the +50 out, but I wanted to tell my real solution here, all which people did help with...
I was performing mysql_real_escape_string on all of the data AS SOON as it posted (before any processing).  So, a slash was added to escape the ' character that was submitted.  This, we know is normal.
However, there was no reason that the backslash \ should show up in the DB entry, right?  The escape was there to be sure the ' was entered.
Turns out, AFTER escaping, I would then save the variable to be reloaded to the page in the session, in case the user had an error that PHP found while validating all of the form fields.  In this case, the user's input (formerly O'riley was now printed to their screen as O\'riley.  Then, the user didn't catch this - so they would often just fix their error that PHP caught during validation (unrelated to the name field), and thus the O\'riley would land in the database because mysql_real_escape_string would escape the characters.
Lesson:
When processing a form, FIRST save data for form-refill use.  SECOND validate form fields.  THIRD escape the data for processing into the database.
Or better yet, use PDO and avoid this =).
Comments welcome.  THANKS ALL!


text:
Q: PowerShell error variable loses the content I have a quite big project with many functions in there.
Just 2 questions:

*

*What would be here the "best practice" regarding Error-Handling? To use a local handling per Function, or use only one Error-Logging in the Main-Section?

*The tricky part (!), let's have a look at the strange Error behaviour in the function F_XXX: only $_ delivers an error message, $Error[0] is here empty! Strange enough, when I start the function F_XXX separately (cut out from the module), it behaves as expected, it means: $Error[0] gives an error back. The code:

Blockquote

$ErrorActionPreference = "Stop"
Function F1
{
    try
    {
    # do something
    }
    catch
    {
        # 1. cascade Error to Main?
        # throw $Error[0].InnerException
        # or
        # local Error-Logging?
        write-MyErrorLogging -message $Error[0].InnerException
    }
}

Function F2
{
    try
    {
        # do something
    }
    catch
    {
        # 1. cascade Error to Main?
        # throw $Error[0].InnerException
        # or
        # local Error-Logging?
        write-MyErrorLogging -message $Error[0].InnerException
    }
}
Function F_XXXXXX
{
    try
    {
        cls
        write-host "The install data is copied.."
        $share = "\\my_wrong_path\sql_sources\"
        Copy-Item $share -Destination $installDrive -Force -Recurse
    }
    catch
    {
        $Error[0] #here is nothing!
        $null -eq $Error[0] # here true
        $_.Exception # only here the error-message: wrong path!
    }
}

Blockquote

# here Main
try
{
    F1
    F2
    F_XXXXXX
}
catch
{
    write-MyErrorLogging -message $Error[0].InnerException
}

Blockquote

A: *

*Inside a catch block, it's best to avoid $Error[0], given that the error at hand is reliably reflected in the automatic $_ variable.

*

*If you do need access to previous errors via the automatic $Error variable, use $global:Error inside modules - see the bottom section for details.

*Unless you need to perform additional actions when an error occurs, you can let a script-terminating (fatal) error (which your $ErrorActionPreference = "Stop" statement turns all errors in your code into) bubble up the call stack until it is either caught by a try / catch statement or, in the absence of one, terminates the entire call stack (i.e., the scripts and its callers).

*

*If you do need to perform additional actions, use try / catch, and place the actions inside the catch block (as well as potential cleanup actions in a finally block), followed by re-throwing the error simply by calling throw without an argument.

Thus, you can make do with a single try / catch statement in the top-level scope of your script:
# Turn all errors in this and descendant scopes into
# script-terminating (fatal) ones.
$ErrorActionPreference = 'Stop'

# ... other function definitions, without try / catch

# Top-level code that calls the other functions and catches
# any errors.
try
{
    F1
    F2
    F_XXXXXX
}
catch
{
    write-MyErrorLogging -message $_.InnerException
}

The automatic $Error variable in modules:
Strangely, up to at least PowerShell 7.2.3 (current as of this writing):

*

*Errors occurring in modules - just like ones occurring outside modules - are recorded in the $Error variable that exists in the global scope.

*However, a seemingly unused, module-local copy of $Error exists, which shadows the global variable.
The workaround is to use use $global:Error from inside modules.
The behavior suggests a bug, given that the module-local copy is seemingly never touched and serves no apparent purpose.


text:
Q: Why is creating content with HTML5 Canvas much more complicated than authoring with Flash? I've been doing Flash for couple of months and I love it. I can easily use a rectangle tool to draw a rectangle and do shape/motion tweening within seconds.
Lots of people are talking about HTML5 vs Flash nowadays and I took a look on HTML5 Canvas today.  To my surprised, I see whole bunch of "code".  It's so complicated, they need to make a lot of calls (fill, stroke, moveto, closepath etc...) to make a simple shape. And even dozens lines of code mixing with javascript to do a simple movement???
Am I missing something? It'll make animation 10x more complicated with HTML5 Canvas than Flash.

A: I'm not exactly clear what you're asking. <canvas> is a standard, not an authoring tool. Flash has an authoring tool because it's written by one company that makes its money selling authoring tools for it ($699 for Flash Professional at the time of writing).
I don't do this sort of thing myself, so I'm not familiar with the state of <canvas> authoring tools, but apparently Adobe is going to add some support for <canvas> in some of its products, as mentioned last year by Dave Shea. There's nothing stopping other companies writing designer-friendly authoring tools for <canvas> either.

A: I don't think you are missing anything, the idea behind HTML5 Canvas is to provide the functionality as a standard for all browsers. This is still very new in the grand scheme of things, and not necessarily a complete solution for all people.
Do keep in mind that with anything of this nature, you will probably want to use a library to interact with canvas elements if you plan on using heavy animation. Custom or third party, no need to retype code every time.

A: Canvas itself cannot replace the entire Flash development environment.  The purpose of canvas is to create a cross browser standard for real time graphics, which could potentially reduce the need for Flash Player which is a 3rd party plugin.  Canvas exposes somewhat low-level drawing functions, but entire libraries can be built on top of it (just like tweening libraries in Flash), and development environments can be built which compile to Javascript targeted at a canvas object (Just like the Flash authoring tool).
It's hard to say for sure, but I think the reason we haven't seen many good authoring tools for Canvas yet is because canvas is still pretty slow, lacks many features that FlashPlayer has, and there are issues of uncertainty slowing down the adoption process of HTML5 (eg. video codecs).

A: Good question. I've been working with <canvas> for a couple of years and I'm also a former flash developer.
I don't think too you are missing something. Well, <canvas>, you know, it has to look more complicated than Flash :). Flash is a client tool. It provides an awesome GUI, lots of visual and immediate features and lets the user compose animations sometimes without a single line of code (actionscript). On the other side, with that particular HTML5 tag you can do a lot of things that are easier to do by Flash technology. But there are several advantages about using it, for example:

*

*It's cross-browser (let's assume by IE9 there will be full cross-browser compatibility - btw there is excanvas lib that writes vml in place of canvas in IE<9)

*You don't have to download a plugin to view something

*It doesn't 'overload' the DOM

*You can wrap some logical patterns (draw lines, draw shapes, animate something) inside a library to make it easier to use.

*Once you know how it works, you can design and build awesome smooth and lightweight gadgets/charts/animations

*You don't have to pay to use it :)

*etc.

By the way Flash has a very different goal: it lets the user build everything inside a particular platform without a full integration into the browser. It is a particular (and surely awesome!!) technology wrapped inside the browser with the main scopes that are multimedia and unlimited kinds of animation.
Canvas' goal is completely different. It's a 'new' way to obtain shapes, animations etc. inside the browser, inside a particular page, through that tag. Remember that you have to write JS code that can render something in both 2d and 3d context (isn't it sooo good??? :D)
P.s. take a look at these two canvas projects we (me and my colleauges @ work) have proposed for the software engineering course at university:
AjaxDraw, full <canvas> based painter, it export/import svg files
SketchYourSite, items represented by <canvas> elements

A: You are worried about the "code", but when using Flash AS3 you get to write a lot of code anyway.
I'm porting a small AS3 game I did few years ago to Canvas, and so far I don't see any great difference between the two.
Canvas is more low level, many useful functions are missing and you have to build them, just like the box you mentioned above. Even circles are not available, but you can make a 4-5 lines function to draw a circle, so is not really an issue.
There are three issues so far where Flash is better:

*

*Colorizing/blending is basic (just transparent and additive are really useful) while Flash has almost any Photoshop blend mode available.

*While Flash is finally (after waiting for years) gorgeous at handling sound, the still young HTML5 audio tag is really poor so far.

*Speed. Flash is faster than canvas/JS in the same machine.
Despite this, the main browser vendors are doing their best to improve performances and features, and many issues will be addressed.

A: The Good and the Bad : Flash vs HTML5
History First
As always, it is good to get a bit of facts from history! Flash was introduced in the mid nineties by the company Macromedia. At the time, web technologies were no where close to what we have today. To be honest with you, websites back then looked like crap. One could bring websites to an all new level with the help of Flash. This is why Flash became so popular and it is what it become today : a popular complementary browser plugin.
Yet, we can see quite an impressive evolution in computing power, disk space and Internet connection speed. With that evolution came new web standards and new browsers with rich features. Of course, we came to see the life of JavaScript and CSS with time as well. The powerful trio of HTML/XHTML, CSS and JavaScript are the foundations of HTML5. New and exciting features are at the core of HTML5. I would strongly invite you to read the first chapter of HTML5 For Web Designers.
Very, Very Different
To be able to create a website with Flash components, one must have Macromedia/Adobe Flash (Macromedia was bought by Adobe). I must agree that it is possible to do great stuff with Flash, but it has became dramatically expensive! We have to ask ourselves if this software really worth the trouble...
After all, Flash components are proprietary and some would say that it breaks the open nature of the World Wide Web (WWW). In my humble opinion, Flash can easily make a website bloated because the components usually take a lot of bandwidth. Think about possible users in third world countries (there are more of them than you might think). Also, there has been several security concerns about exploits and flaws (have a quick Google search). Therefore, I always used Flash sparingly. Now, this does not mean that websites are ugly without Flash either. Have a simple look at the tons of website galleries out there like cssline for one.
On the other hand, browser technology is finally getting up to a point where it can grasp HTML5 to do what Flash has been doing for the last 17 years. We haven't seen the full possibilities of certain tags such as canvas because HTML5 will take time to mature. In fact, it is still a work in progress because it will only be a candidate recommandation in 2012 and it will be a proposed recommandation in 2022. Perhaps, you can begin to see how different Flash and HTML5 are from each other.
The End of Story
I believe that you are missing something by not knowing HTML5 and the canvas tag.
Have a look at this HTML5 vs Flash website for demos. Perhaps, you will be able to make an opinion with the help of that site (it would be best to use a modern browser such as Chrome, Safari and Opera). Please have an open mind because HTML5 is still very young compared to Flash. By the way, have you heard about something called WebGL?


text:
Q: Get the first and last letter in alphabetic order for a character vector I am doing an R exercise:
Write a function that splits the string into letters and return the min & max letters according to alphabetical order.
Here's the vector:
cities <- c("New York", "Paris", "London", "Tokyo", "Rio de Janeiro", "Cape Town")

Here's the code I have written:
first_and_last <- function(name){
  name <- gsub (" ", "", name)
  letters <- strsplit(name, split = "")
  c(first = min(letters), last = max(letters))
  }

However, I got errors when I run it:
first_and_last(cities)
#Error in min(letters) (from #4) : invalid 'type' (list) of argument

Kindly let me know what's missing in the code? Thanks!

A: First, your function was nearly correct. I've included vapply() loops to perform the min() and max() functions element-wise then return a data frame of the results. As @Zheyuan Li points out you can also use sapply() and this is valid, but I prefer to avoid sapply() when writing functions (see Why is `vapply` safer than `sapply`?), although both get you the answer :-)
return_first_and_last <- function(name) {
  name <- gsub (" ", "", name)
  name <- strsplit(name, split = "")

  first <- vapply(name, min, "")
  last  <- vapply(name, max, "")

  data.frame(
   first = first,
   last  = last
  )
}

return_first_and_last(cities)
#       first last
# 1     e    Y
# 2     a    s
# 3     d    o
# 4     k    y
# 5     a    R
# 6     a    w

Some notes:

*

*It's good practice to call your function a verb, so I've suggested 'return_first_and_last()'

*letters is a built-in object in R, and it's generally a bad idea to reassign these, even in local function environments. I've kept simply replacing name instead as we don't need this outside the function.

*It looks like capitalisation matters, at least on Linux. So, if we have two of the same letters but one upper-case and one lower-case, min() will return the lower-case version, and max() will return the upper-case version (i.e. your function returns min as a and max as Y, even though there is a lower-case y as well).

A: I am assuming you want element-wise operation, i.e., for each element of cities, extract the first and last letter in alphabetic order. This is what you need:
first_and_last <- function(name){
  name <- gsub (" ", "", name)
  myName <- strsplit(name, split = "")
  result <- t(sapply(myName, range))  ## use function `range`
  rownames(result) <- name
  colnames(result) <- c("first", "last")
  return(result)
  }

first_and_last(cities)

#                first last
# New York       "e"   "Y"
# Paris          "a"   "s"
# London         "d"   "o"
# Tokyo          "k"   "y"
# Rio de Janeiro "a"   "R"
# Cape Town      "a"   "w"

I have used function range(). This will return min and max. It is R's built-in implementation for function(x) c(min(x), max(x)).

Follow-up

Thanks, problem solved. I'm taking an online course in R. In their solution, they used the following line of code. If possible could you please explain, what does this line of code mean. Especially, the double bracket part "[[1]]": letters <- strsplit(name, split = "")[[1]]

strsplit returns a list. Let's try:
strsplit("Bath", split = "")
#[[1]]
#[1] "B" "a" "t" "h"

If you want to access the character vector, you need [[1]]:
strsplit("Bath", split = "")[[1]]
#[1] "B" "a" "t" "h"

Only with a vector you can take min / max. For example:
min(strsplit("Bath",split=""))
#Error in min(strsplit("Bath", split = "")) :
#  invalid 'type' (list) of argument

min(strsplit("Bath",split="")[[1]])
#[1] "a"

I believe the online example you see only takes a single character. If you have a vector input like:
strsplit(c("Bath", "Bristol", "Cambridge"), split = "")
#[[1]]
#[1] "B" "a" "t" "h"

#[[2]]
#[1] "B" "r" "i" "s" "t" "o" "l"

#[[3]]
#[1] "C" "a" "m" "b" "r" "i" "d" "g" "e"

and you want to apply range for each list element, sapply will be handy:
sapply(strsplit(c("Bath", "Bristol", "Cambridge"), split = ""), range)
#     [,1] [,2] [,3]
#[1,] "a"  "B"  "a"
#[2,] "t"  "t"  "r"

My function first_and_last above is based on sapply. Yet for nice presentation, I have transposed the result and given row / column names.

Gosh, I just realize you already sked a question on [[]] 2 days ago: Double Bracket [[]] within a Function. So why are you still asking me for explanation???


text:
Q: Add JSON data to MySQL database I'm developing a Grails concert application where I am acquiring the actual events from bandsintown.com using AngularJS.
 $.getJSON("http://api.bandsintown.com/events/search.json?&api_version=2.0&app_id=FYP&location=Dublin,Ireland", function(result)

I am able to retrieve the events and I now want to turn each event into an object and add them to my database, so I can have a unique page for each event with their subsequent details and whatnot.
Is anyone able to provide me guidance on how to do such a thing?
Thank you!

A: I wrote something a while ago as a plugin which may help you get your head around what you need to do :
private String viewTicketField(String jiraserver, String jirauser,String jirapass, String url, String customField) {
    if (url.endsWith('undefined')) {
        return
    }

    String output=''

    try {
        HBuilder hBuilder=new HBuilder()
        RESTClient http = hBuilder.httpConn(jiraserver, jirauser, jirapass,httpConnTimeOut,httpSockTimeOut)
        http.request(Method.GET ) { req ->
            uri.path = url
            response.success = { resp, json ->
                log.info "Process URL Success! ${resp.status}  "
                def result=JSON.parse(json.toString())
                if (result.fields."customfield_${customField}") {
                    output=result.fields."customfield_${customField}"
                }
            }
            response.failure = { resp ->
                log.error "Process URL failed with status ${resp.status}"
            }
        }
    }
    catch (HttpResponseException e) {
        log.error "Failed error: $e.statusCode"
    }
    return output
}

HBuilder class can be found in src
After you have connected and got back your JSON response you then parse each line
You create a new domain class
String url
String datetime
String app_id
String ticket_url

... and so on this is an entire entry from above url so for each key that you actually require  put in domain class as strings then parse each iteration with above code
{"id":13926481,"url":"http://www.bandsintown.com/event/13926481?app_id=FYP","datetime":"2017-02-23T17:00:00","ticket_url":"http://www.bandsintown.com/event/13926481/buy_tickets?app_id=FYP\u0026came_from=233","artists":[{"name":"Rackhouse Pilfer","url":"http://www.bandsintown.com/RackhousePilfer","mbid":null}],"venue":{"id":3334537,"url":"http://www.bandsintown.com/venue/3334537","name":"Convention Centre","city":"Dublin","region":"07","country":"Ireland","latitude":53.3500292,"longitude":-6.2385286},"ticket_status":"unavailable","on_sale_datetime":null


text:
Q: Как расширить TableView
Не могу расширить по высоте TableView, все layout'ы перепробывал - ничего не помогает. Не понимаю в чем проблема.
Вставляю его в center border pan'а другого окна, кнопки регулируются, таблица - нет. По высоте все стоит на MAX_VALUE. Помогите, пожалуйста.

<?xml version="1.0" encoding="UTF-8"?>

<?import com.jfoenix.controls.*?>
<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import com.jfoenix.controls.JFXButton?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Pagination?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>

<fx:root maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="400.0" prefWidth="600.0" type="BorderPane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
   <bottom>
      <HBox prefHeight="49.0" prefWidth="600.0" BorderPane.alignment="CENTER">
         <children>
            <JFXButton fx:id="btnAdd" alignment="TOP_LEFT" prefHeight="25.0" prefWidth="160.0" text="ДОДАТИ">
               <HBox.margin>
                  <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
               </HBox.margin>
            </JFXButton>
            <JFXButton fx:id="btnEdit" alignment="TOP_LEFT" prefHeight="25.0" prefWidth="160.0" text="ЗМІНИТИ">
               <HBox.margin>
                  <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
               </HBox.margin>
            </JFXButton>
            <JFXButton fx:id="btnDelete" alignment="TOP_LEFT" prefHeight="25.0" prefWidth="163.0" text="ВИДАЛИТИ">
               <HBox.margin>
                  <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
               </HBox.margin>
            </JFXButton>
         </children>
      </HBox>
   </bottom>

      <VBox>
         <children>
            <VBox VBox.vgrow="ALWAYS">
               <children>
                  <TableView fx:id="tableView" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" VBox.vgrow="ALWAYS" />
                  <Pagination fx:id="pagination" VBox.vgrow="ALWAYS" />
               </children>
            </VBox>
         </children>
      </VBox>

</fx:root>

Добавляю его сюда через
dictionaryBorderPane.setCenter((Node) mainListView.getSelectionModel().getSelectedItem());

<Tab fx:id="tabDictionary" onSelectionChanged="#handleDictionaryTab" text="Довідники">
                            <content>
                                <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
                           <children>
                              <BorderPane fx:id="dictionaryBorderPane" prefHeight="975.0" prefWidth="1920.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
                                 <left>
                                    <JFXListView fx:id="mainListView" prefWidth="300.0" BorderPane.alignment="CENTER" />
                                 </left>
                              </BorderPane>
                           </children></AnchorPane>
                            </content>
                        </Tab>

A: Вам может помочь AnchorPane
<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <TableView AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
        <columns>
          <TableColumn prefWidth="75.0" text="C1" />
          <TableColumn prefWidth="75.0" text="C2" />
        </columns>
      </TableView>
   </children>
</AnchorPane>

A: <?xml version="1.0" encoding="UTF-8"?>

<?import com.jfoenix.controls.JFXButton?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Pagination?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>

<fx:root maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="400.0" prefWidth="600.0" type="BorderPane" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
   <bottom>
      <HBox prefHeight="49.0" prefWidth="600.0" BorderPane.alignment="CENTER">
         <children>
            <JFXButton fx:id="btnAdd" alignment="TOP_LEFT" prefHeight="25.0" prefWidth="160.0" text="ДОДАТИ">
               <HBox.margin>
                  <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
               </HBox.margin>
            </JFXButton>
            <JFXButton fx:id="btnEdit" alignment="TOP_LEFT" prefHeight="25.0" prefWidth="160.0" text="ЗМІНИТИ">
               <HBox.margin>
                  <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
               </HBox.margin>
            </JFXButton>
            <JFXButton fx:id="btnDelete" alignment="TOP_LEFT" prefHeight="25.0" prefWidth="163.0" text="ВИДАЛИТИ">
               <HBox.margin>
                  <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
               </HBox.margin>
            </JFXButton>
         </children>
      </HBox>
   </bottom>

      <VBox>
         <children>
            <StackPane alignment="TOP_RIGHT" VBox.vgrow="NEVER">
               <children>
                  <JFXButton alignment="TOP_LEFT" contentDisplay="RIGHT" ripplerFill="#ed6464" text="QWEQWE" textAlignment="RIGHT" textFill="#3b2d2d" />
               </children>
            </StackPane>
            <VBox VBox.vgrow="ALWAYS">
               <children>
                  <TableView fx:id="tableView" VBox.vgrow="ALWAYS" />
                  <Pagination fx:id="pagination" />
               </children>
            </VBox>
         </children>
      </VBox>

</fx:root>

Обратите внимание на VBox.vgrow


text:
Q: MPICH communication failed I have a simple MPICH program in which processes send & receive messages from each other in a Ring order.
I've setup to 2 identical virtual machine, and made sure network is working fine. I've tested a simple MPICH program both machines and it works fine.
The problem arises when I try to communicate between processes on different machines like the above program. I'm getting the following error:

Fatal error in MPI_Send: A process has failed, error stack:
  MPI_Send(171)...............: MPI_Send(buf=0xbfed8c08, count=1, MPI_INT, dest=1,
  tag=1, MPI_COMM_WORLD) failed
  MPID_nem_tcp_connpoll(1826): Communication error with rank 1: Connection refused

*

*SSH is passwordless & works fine on both sides.

*/etc/hosts is configured properly.

*Firewall is disabled on both machines.

*Configured NFS Client/Server and shared a directory between them. (According to this)

*Tried both MPICH & OpenMPI with Hydra

A: Here what i did, And it works!
Installed following package using source code (tarball)
hydra
openmpi

Created hosts file (both node)
# cat /home/spatel/mpi/hydra/hosts
node1
node2

Set variable in .bashrc on (both node)
echo HYDRA_HOST_FILE=/home/spatel/mpi/hydra/hosts >> ~/.bashrc

Use HelloWorld MPI program to run on single node.
node1# /home/spatel/mpi/hydra/bin/mpiexec -np 1 /home/spatel/mpi/mpi_hello_world
Hello world from processor node1.example.com, rank 0 out of 1 processors

Run on multiple node using -machinefile option -np is number of processor
node1# /home/spatel/mpi/hydra/bin/mpiexec -np 4 -machinefile /home/spatel/mpi/hydra/hosts /home/spatel/mpi/mpi_hello_world
Hello world from processor node1.example.com, rank 0 out of 1 processors
Hello world from processor node2.example.com, rank 0 out of 1 processors
Hello world from processor node1.example.com, rank 0 out of 1 processors
Hello world from processor node2.example.com, rank 0 out of 1 processors


text:
Q: Closed map on open cover I thought this was true for a while, but I'm struggling to come up with a proof. I must be missing something obvious.

Let $f: X \to Y$ be a continuous map. Suppose $\{V_i\}$ is a finite open cover and define $U_i := f^{-1}(V_i)$. Suppose that $f_i:= f|_{U_i}: U_i \to V_i$ is a closed map for each $i$. Then $f$ is a closed map.

My idea is as follows. Let $C \subset X$ be a closed set. Then
$$ f(C) = f( \bigcup_i C \cap U_i) = \bigcup_i f(C \cap U_i)$$. So each $f(C \cap U_i)$ is a closed subset of $V_i$. How can I conclude $f(C)$ is closed? Or is this even true? Feel free to add some assumptions if you like.

A: Let $X=Y=\{a,b,c\}$, with topology $\mathscr T=\{\varnothing,\{a\},\{b,c\},X\}$. Let $f:X\to Y$ be the constant map at $a$ and take the open cover $V_1=\{a\}$, $V_2=\{b,c\}$. Then $U_1=X$ and $U_2=\varnothing$.
Now, $f_1:X\to V_1=\{a\}$ is constant (and surjective), so it's closed, and $f_2$ is the empty map, which is trivially closed. But $f$ is not closed because we defined the image $\{a\}$ to be open in $Y$.
I should add, that the problem going on here is that you're defining $f_i$ as a map $U_i\to V_i$, and being closed in $V_i$ won't guarantee you closure in $Y$. If on the other hand, you define $f_i:U_i\to Y$, then if each $f_i$ is closed it follows that $f$ is closed. Your proof for this suddenly works because $C\cap U_i$ is closed in $U_i$, by definition of subspace, so $f(C\cap U_i)$ is closed in $Y$, and hence $f(C)$ is a finite union of sets which are closed in $Y$.
Edit: this answer is wrong, as user gvv has pointed out. I cannot delete my answer because it has been accepted already so OP, if you see this, please give gvv credit.

A: The claim you make is in fact correct, and can be extended to hold for an arbitrary (possibly infinite) open cover $Y = \cup_i V_i$. The proof for the finite case can be deduced from this question: Closedness with respect to an open cover, and I'll sketch a proof for the infinite case.
Suppose $E \subset X$ is closed and define $E_i := E \cap U_i$, $F:=f(E)$, $F_i := f(E_i) = F \cap V_i$ (verify this last equality). Now by assumption on $f$, $F_i$ is closed in $V_i$, hence of the form $F_i = V_i \cap F_i'$ for some $F_i' \subset Y$ closed. To prove that $F$ is closed, we write
$$ F = \cap_i (V_i^c \cup (F_i' \cap V_i)) = \cap_i (V_i^c \cup F_i'). $$
This is a intersection of closed sets (in $Y$) and hence closed.


text:
Q: Blackberry development: how to get XMLReader SAXParser I'm looking to port my working Android XML parser to Blackberry, but the latter's Java feature set isn't as rich? I didn't want to have to write two parsers.
The following code yields "The method getXMLReader() is undefined for the type SAXParser":
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser        sp  = spf.newSAXParser();
XMLReader        xr  = sp.getXMLReader();

Am I just out of luck here?
It's true I am trying to use org.xml.sax. I've read all the XML parsing discussions I can find out there. I wonder now if I can do this? Should I be using org.kxml2 instead because org.xml.sax makes no sense in BlackBerry land?
Thanks for any advice!
Russ

A: You don't need to use the getXmlReader() method.
Now that you have your SAXParser use it to parse a document or stream.
SaxParserFactory spf = SaxParerFacter.newInstance();
SAXParser parser = spf.newSAXParser();

Open your stream or file and call and assign it to a variable. Let's call ours input.
parser.parse(input, handler)

The handler file will implement all of the call backs to handle the events the parser encounters.
I found this explanation of SAX to be quite helpful.

A: I'll answer this though I suspect there are others who know better.
My assessment of BlackBerry is that it's very poor in its API set. So, the SAX XML parser isn't available as it is on Android. Okay, that's cool. It's older and from a "smaller" time.
Worse though, it appears very challenging even to add a third-party library to a BlackBerry application. I followed various posts out there and failed to incorporate my own "third-party" JAR convincingly into a BlackBerry project despite the collective wisdom of a number of web pages on the topic.
I was thinking then of writing my own parsing engine to replace SAXParser.parse(). How hard could it be since my expectations for it are childishly simple?
Very hard indeed since it appears that the JavaME support for java.lang.Class is impoverished as well; it doesn't support the important reflection methods such as getDeclaredMethods() for use in creating the engine (into which I naturally wanted to plug my existing XML parser-handler).
Alas, this makes me wonder just what BlackBerry apps out there are able to do? I'm probably giving this world short shrift, but a couple of days were sufficient for me to go from zero to parsing XML texts off the web on Android, so I expected a very easy time of it here too.
Please feel free to shred my answer. If you can and do, especially if you add a real one, it will doubtless greatly benefit other folk new to BlackBerry development including me later when I come back to the problem (so that I can avoid brute-force stringing through the XML stream instead of cleanly parsing it).