How to select Max. switching voltage and current of Relay for a LC resonant circuit

Question:
I have a LC resonant circuit as the above shows. And I want to switch the inductor between L1 and L2 with relays (sometimes L1 is used and sometimes L2 is used). The high voltage point between the inductor and capacitor has a voltage about 400Vp-p, and the current in the inductor is about 10Ap-p. Could I think a relay with max. switching voltage no less than 200VDC and max. switching current no less than 5A is needed? Or how should I select a relay for this application?
Answer: I'd stick with solid state - add another couple of MOSFETs to your bridge and select one of the left pairs for driving the appropriate inductor: -
Comment: This is a good idea. By the way, you mean a solid state relay is used to switch the control voltage between the Gates of different MOSFETs pairs?
Comment: No, "solid-state" just means avoidance of mechanical parts that normal relays have. Just normal logic routing to option A inputs or option B inputs with "solid-state (i.e. silicon ICs)" will do the trick. "solid state" doesn't mean "solid-state relay".


How Do I Point OpenSSL to my Custom Config File?

Question: I copied /System/Library/OpenSSL/openssl.cnf to my home folder so I could set default values for certificate creation. How do I set up OpenSSL to use my config file instead of the regular one? I could add a statement to my ~/.bashrc file. I've done web searches and searched the openssl.org website but could not find the answer. One post on Stack Overflow mentioned a parameter -config but was not referenced in a command.
Answer: It would depend on what commands you're running.
If you run req or ca they would support a -config parameter. Which would also be visible if you run openssl req -? or openssl ca -?.
If you want to make it the actual default without exclusively specifying it you should check Correct location of openssl.cnf file.
From the above link for the options of the req command:

-config filename
this allows an alternative configuration file to be specified, this overrides the compile time filename or any specified in the OPENSSL_CONF environment variable.
Comment: Adding -config to my statement worked!
Comment: I'm running req and using the installed Apple version of OpenSSL. So I would have to use -config myfilenameincludingfullpath in my req command? The link you provide does not include that info.
Comment: It does and it includes even more info, see the edit I'm about to make. But yes, that would be what you need to do.
Comment: Okay thanks. I did not see that req was a link in your comment.
Comment: FYI, openssl doesn't want `-config` at the start of the parameter list. Throw it at the end of your command and it will accept it.


Parse cloud code login signup example

Question: I have searched for a lot of tutorials to find actual cloud code functions for a user login signup with username as my email, in Parse. I only have an overall idea about how to get through Parse. But examples are scarce. Kindly share with me some examples or even good tutorials( I have already read the docs in parse.com ). I actually want to have API's set up for login and signup using Parse.
Answer: I'm answering off my phone so I don't want to try to type out a bunch of code, however, for signups what you could do is ask the user for their username, password, email, etc....send that to Cloud Code and using the master key, create a new object just like you would for a custom class.
<code>Parse.Cloud.useMasterKey();
</code>

Parse cloud code login signup example


Deleted Image giving a 301

Question: I have images that were deleted from the site (the page and the media library) but are still being requested which can be seen in the network tab. They are redirected and take a huge amount of time making the page significantly slower. I don't know how images that no longer exist on the page and the media library can still be requested. I tried adding images with the same name but they are still redirected (probably because I set all 404's to redirect to the homepage). attached is an image with the images causing the problem.
Answer: from what I see the issue might be in the redirections you are making and how you are making them. I did some research and you can use this (it is Ask Rubi group that has an article on the topic) to learn more about the redirections.
Comment: Thanks for the info it is greatly appreciated
Comment: Whilst that looks helpful, your answer would be better if you summarised the important points in the article here please (use the 'edit' link) - answers that just link to off-site articles are discouraged, sorry.

Deleted Image giving a 301


UIView not resizing in code or interface builder

Question: I am creating a simple UIView and adding it to my main view - I am also changing the frame however no matter what I try it doesn't resize the view - it just lumps this huge view down onto my superview.  Changing the view size in interface builder has no effect either:
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view
                      calloutAccessoryControlTapped:(UIControl *)control
{
    HotelInformationViewController *vc =
    [[HotelInformationViewController alloc]initWithNibName:@"HotelInformationViewController"
    bundle:nil control:control];

    [self.view addSubview:vc.view];
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil control:(UIControl *)control
{
  if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
  {
    self.view.bounds = CGRectMake(control.frame.origin.x, control.frame.origin.y, 286, 286); //This is the size I want to view to be 286, 286
  }
  return self;
}

Answer: the problem is that you are trying to change the bounds, and you are supposed to change the frame. Bounds is rect in internal view that should be projected to the rect in superview - a frame. Imagine picture of size 300x300. If you have a view on the screen with frame (0,0,100,100) and you want to show the central part of that picture you should set bounds to (150,150, 100,100). As a result you will see the central part of you picture (without resizing) shown in a rect with size 100x100 in upper left corner of a superview.
Answer: You should be calling  self.view.frame = CGRectMake(...). frame is the property that represents position and size of the view within its superview, and is the thing you change to move or resize a view.
(The bounds attribute is the internal boundaries of the view's coordinate system that the frames of the view's subviews exist within, and it's rarely if ever necessary to explicitly set it)


wsjt-x problems with windows 11

Question: When upgrading from previous version of the windows operating system to windows 11 wsjt-x stops receiving the output from the radio.  What should I look for?
Answer: With windows 11 there is a new feature "enhanced audio"

Windows 11 provides additional features to improve the sound quality
with more bass, virtual surround, room correction, and loudness
equalizer.

this will interfere with the working of wsjt-x as it will change the levels as the sound comes in and out.  So you need to turn it off.
To turn it off

Open Settings.

Click on System.

Click the Sound page on the right side.

Under the "Output" section, click the Speakers setting.

Under the "Output settings" section, turn off the Enhance audio toggle switch.

After you do this all the audio enhancements will turn off immediately and you should be able to see the decodes happening in wsjt-x
Comment: Upvoted. This is effectively the same as turning off "speech compression" and all other audio processing on your transceiver when transmitting digital modes, to make sure the digitally-generated sounds are unaffected as they are transmitted.
Comment: Turning off Audio Enhancements is standard procedure, so it doesn't really help to answer this question.
Answer: Was using a fairly modern Dell laptop with Windows 10 and and IC7300 to work WSJTX, with no problems.  A week ago, switched out the Dell for a newer Acer laptop with Windows 11.  Nothing, absolutely nothing could get my IC7300 to work with Windows 11, trying all the fixes, re-downloading drivers, etc.  When I would load up WSJTX to the Acer, everything appeared fine, but after one transmission, the received audio would drop to nothing.  I tried every published fix I could find with no success.  I ended up switching out the Acer and going back to the Dell with Windows 10.  Everything immediately worked again. No problem with the IC7300 - some kind of bug with Acer, or Windows 11. I'll continue to check back for future software updates for Windows 11 and the Acer, and report back in if and when Windows 11 finally works with WSJTX.

wsjt-x problems with windows 11


Why is non-inverting op-amp input resistance on a tee to ground?

Question: In many of the explanations I've read of non-inverting op-amps, the non-inverting input is given a resistance to meet the specs of the op-amp. I'm confused by how the resistance is applied. Since the resistor is just acting to control the input current, I expected it to be inline with the input voltage. However, the resistor is usually attached as a tee from the input going to ground. Why is the input resistor on a tee and not just inline with the non-inverting input?
Answer: Let the resistance looking into the non-inverting input be \$R_{in+}\$
If a resistor \$R_i\$ is placed in series with the non-inverting input, the resistance seen by the source \$v_I\$ is
$$R_I = R_i + R_{in+} \ge R_{in+}$$
If a resistor \$R_i\$ is placed in parallel with the non-inverting input, the resistance seen by the source \$v_I\$ is
$$R_I = R_i||R_{in+} \le R_{in+}$$
Since, for an ideal op-amp, \$R_{in+} = \infty\$, the series case gives
$$R_I = R_i + \infty = \infty$$
while for the parallel case
$$R_I = R_i||\infty = R_i$$
Answer: There are two functions of a shunt resistor on an inverting input.  One is in the case when you need a termination resistor, like in the case when the signal is brought in on a coax or strip line.  The second reason is more subtle, in the non-ideal case (i.e. every real Op-amp) the input has leakage currents, which interact with the various resistances to create a offset voltage on the input to the op-amp.  To partially compensate for this, the resistances seen by each input must be matched, that means in your example, that \$R_{in} = R_1||R_f\$, where the symbol \$||\$ means "in parallel with".
Answer: The resistor does not control the input current. Ideally, there is no input current because the + input has infinite resistance.
What R1 does is it establishes a finite input impedance for the amplifier.
The op-amp's natural very high impedance is not necessary or desirable in some applications.
Also, op-amp inputs generate small DC bias currents: some models more than others. This current needs a path to allow it to flow to the ground, called a "DC return" path. The resistor provides that path.
Suppose that the broader circuit is like this:

simulate this circuit – Schematic created using CircuitLab
The source device happens to be capacitively coupled, represented by C1. (C1 could be part of the amplifier based around OA1, or it could be part of the source device; it doesn't matter.)
So, the only DC path from the + input to ground is through the resistor!
What happens if you remove the resistor? Or connect it incorrectly, in series between the capacitor and non-inverting input? Current flowing out of the + input will slowly charge C1 until a voltage builds up that pushes the + input out of the common mode input range. R1 helps keep C1 discharged.
Note, however, that the bias current flowing across R1 generates a voltage on R1 (V = IR) which creates an offset voltage which gets amplified.
If the op-amp has similar bias currents flowing out of both inputs, this problem can be attacked by choosing a value of R1 which is the same as the combined resistance faced by the - input, as a result of the feedback resistor network.
Thus R1 is chosen in order to establish some desired input impedance, and the magnitudes of the feedback resistors are chosen to balance the bias current to null the offset (while their ratio is chosen for the desired gain).
Some op-amps have built in bias current cancellation. These op-amps have a much smaller bias currents than similar op-amps without the cancellation. Moreover, the remaining uncancelled currents from the two inputs are not similar at all, and may be of different polarity. With these op-amps, the trick of balancing the resistances is not applicable; R1 can be chosen independently of R2 and R3. For instance R1 could be, say, 100 kOhm to set up an input impedance that high, whereas the feedback resistors could be chosen only in the thousands of ohms.
Answer: Briefly, to summarize, there are two motivations:

To minimize the drift of the output due to the bias input current (offset).
In this case \$R_{in}=R_{1}//R{f}\$
To match the input impedance (i.e. in video amplifier).
In this case \$R_{in}\$ must be equal to the impedance of the source, for example 75Ω for coaxial cable in analog video.

Sometime, in case of ac-coupled amplifier, \$R_{in}\$ provide the return-to-ground  path for the input current, as said in the "Horowitz-Hill".
Answer: If your signal into the circuit is referenced to a dc value between the rails of the power supplies (normally 0V or mid-rail) then you don't need an input resistor. You typically use an input resistor to make a "light" connection to midrail (0V) when coupling an input via a capacitor.
Answer: If you remember, an ideal op-amp's inputs do not allow flow of current. So, without a route to ground, the loop's gain will be infinity because no current is flowing there.
Comment: I'm sorry, I disagree. The op-amp loop gain will be 1 + \$\dfrac{R_F}{R_1}\$ irrespective of their being a resistor (R\$_i\$) there or not.
Comment: exactly, this answer is wrong.
Comment: To me, the loop gain is the gain of the complete loop, that is: Aol*R1/(R1+Rf).


Integrating SharePoint 2013 on premises with angular 4 in visual studio

Question: How can I integrate SharePoint 2013 on premises with Angular 4 in Visual Studio?
How to include my custom html template in the home page?
Answer: I have done the following:

Created Angular solution using your favorite IDE outside SharePoint
Uploaded Angular files to /_catalogs/masterpage/myangularapp
Added Content Editor Web Part to SharePoint page and point web part to the Angular app like /_catalogs/masterpage/myangularapp/index.html


Annoying Lock On switch

Question: Can I change the Lock On switching? Using the keyboard and mouse it's really annoying when fighting more than one enemy.
Answer: The switching of lock on targets is notoriously sensitive or unintuitive using a mouse (see here and here, for example).
You can turn off Lock On by pressing F, unless it's mapped differently (obviously). Check your Key Configuration under Controls in the System Menu to be sure.
Unfortunately, the key-binding for 'Switch Lock-on Target to the Left/Right' seems to be fixed to 'Move Camera Left/Right', and changing that is not even an option:
Answer: Unfortunately even this answer doesn't actually fix anything. The game automatically switches to whatever is to your Right, so if an enemy is to your right, you will likely lock onto them after locking onto your enemy in front of you, then it will also likely switch back and forth. This is just bad design that cannot actually be corrected completely (even the so called fixes people come with still ultimately do not actually fix the issue, just make one aspect of it, related to the facing direction of your character, and not the actual auto lock switching.
It's very likely just an oversight like not having keyboard and mouse prompts for a long time (they have them now lol).
Comment: This is a comment, not an answer.
Comment: its a comment that states that the provided solution doesn't work

Annoying Lock On switch


What is the difference between KPR() and DSM()

Question: I am learning advanced theming for which I am using Devel Module kpr() and dsm() functions to print the arrays on the page for finding variables. So I want to know, What is the main difference between kpr() and dsm() functions? And which one is the best for which condition.
Answer: In Devel there are various formatters you can use to dump variables. But the main difference of dsm() is, that it uses drupal_set_message(), which displays the output in the message array via a session, so that the information is preserved between different requests of the same user. This is helpful for debugging code, which doesn't result in a html page to display a normal var dump, for example a form submit. The disadvantage is, that dsm() sometimes produces the output asynchron, not when you expect it, which can lead to false conclusions.
Comment: As I've described this depends on when the code runs you want to debug. Most times both work, but there are cases only one of them works. Or none of them, then you need an IDE and Xdebug.
Comment: But sometimes one of the function is not working. I have installed devel on my fresh installation kpr() is working while the dsm isn't working.


Ps4 free monthly games

Question: I have a question. I am subscribed to PS+, and I started downloading a free game in June. Can I download it anytime I want or is there a deadline before they charge me for it?
Answer: Once you added the PS+ game to your library, you can download and play it any time, as long as you still have PS+.
If you stop having PS+, you can no longer play/download the game AFAIK.

Ps4 free monthly games


How to check performance of WordPress dashboard

Question: We run a Woocommerce shop. The frontend is pretty ok, but the dashboard is really slow. The database is quite large (>2 GB) containing around 140.000 users and more than 50.0000 orders. I checked the performance on a staging server using the same theme and plugins, but a new and clean database. Dashboard performance did not improve significantly. Monitoring plugins is not easy. The P3 Profiler plugin hasn't been updated for years. Probably not a good way to go. The Query Monitor shows valuable information. However, measurements of loading time differ too much between reloads to use it. I then check performance using a temparary access plugin. It creates a token so that tools like Pingdom can check the pagespeed. Do you know a better way to perform these tests?
Answer: From a very high level, off the top of my head these are the main things that contribute to how long it takes to load a page in the dashboard in Wordpress:

Application processing: PHP/Apache doing work
Database processing: PHP calling MySQL and the time for queries to run
External services - calling external API's from the browser or server, waiting for data to come back
Network/loading time overhead. Waiting for the page to come to your browser, downloading other dependencies like .js and .css

Query Monitor and the Network tab in your browser dev tools are good basic tools here to focus in on which of these is your main concern. It's 90% likely that most of the time is spent in the database, but that's not always the case. Maybe a plugin does something stupid and counts up all 50,000 orders using inefficient PHP on every page load.
But you need to find out where the time is spent first - either focus in on database queries and see if it's those or not. Your point 'measurements of loading time differ too much between page loads' smells a lot to me like it points to a problem - might be worth updating your question with high level numbers from QM, particularly time spent on database queries, and any other big variances you notice in any other numbers.
Also getting familiar with server load tools will be useful - at the least what does top/htop show you for server load, memory usage, which processes are busy, etc. What does this look like when your site feels fast compared to when it feels slow?


FirePro W4100 video card drive won't drive a displayport monitor at full resolution

Question: I have an AMD FirePro W4100 card and it has 4 displayport outputs on the back.  I have discovered an infuriating limitation which is that it won't seem to drive my Dell UltraSharp U2713HM 27" monitor at its native 2560x1440 WQHD resolution.  I get this message instead:

Previous generation video cards with DVI outputs had no problem driving this monitor. This monitor has displayport and DVI inputs.  The monitor has on screen controls but no settings about displayport settings or modes.  On the AMD Control Center app I see the following:

The specs for the monitor state that it supports DisplayPort 1.2.
The video card is a display-port-output-only card with 4 displayport connectors.
Even when only one monitor is attached, I can not select 2560x1440 resolution in windows 10, and the warning above is shown.
My theories are:

This is an early model displayport-enabled display and there's something wrong with the displayport support, it doesn't support the same displayport version that the FirePro W4100 supports.
All the display port cables I can buy in a computer store are sub-standard.
There's some configuration or something that I need to change to make displayport work, because this is a PC, and accidental complexity and horrendous piles of vendor-driven BS are required, unlike, say if this was a Mac.

The message when the thing is attached is shown here, and I can not figure it out. It appears to be written in a language that looks like English but makes no sense. Even when this is the ONLY display attached to this video card, the native 2560x1440 WQHD option is not enabled in Windows.   The messages seem to be talking about displayport display sharing:
The help button links to a completely useless page of nonsense about how if you have an HDMI monitor you should use an HDMI cable, and other banal and pointless noise.
The noise is shown here because people might want to verify for themselves that AMD doesn't know how to make help buttons link to actual help about DisplayPort displays and video cards not really working:
<code>Digital Flat-Panels (DisplayPort Monitors)

The My Digital Flat-Panelsgroup becomes available in Standard View and Advanced View if you are using a digital display (such as a monitor or digital TV) that is connected through a DVI, DisplayPort, or HDMI™ connection.

A DisplayPort connection carries both digital and audio signal suitable for connecting to a home-theatre system. Use the various pages in the group to control how images appear on your display. Each page contains settings for configuring different display properties, such as improving image quality, performing color correction adjustments, and adding support for additional HDTV modes.

For graphics cards that support the DisplayPort v1.2 standard, you can connect multiple DisplayPort displays to a single DisplayPort connection as long as the displays are compatible with the standard. Displays can be connected to a hub or using a daisy chain configuration. This type of multi-display capability is made possible through the multi-stream transport feature in the DisplayPort v1.2 standard. To determine the number of displays that can be connected to your card, see DisplayPort Diagnostic Information. For more information on the DisplayPort digital display interface and standard, see http://www.displayport.org.

DisplayPort Connectivity

If your digital flat-panel and graphics card are both equipped with DisplayPort connections, you can connect the panel to your computer using a single DisplayPort cable. This cable supplies video to your digital panel. To obtain audio, a separate connection must be made from the audio output of your computer to the audio input of your digital panel.

Note:You may first need to configure your digital panel for external audio. For more information see, the documentation for your panel.

It is also possible to connect a digital flat panel to a computer if the digital panel is equipped with an HDMI or DVI input. To do this, an HDMI or DVI cable and a DisplayPort-to-HDMI or DisplayPort-to-DVI adapter is required to obtain HDMI/DVI output from the DisplayPort connection on your graphics card. For HDMI, no additional connections are required for audio. For a list of AMD-recommended DisplayPort adapters and dongles, visit http://support.amd.com/us/eyefinity/Pages/eyefinity-dongles.aspx.

Digital Flat-Panel Properties (DisplayPort Monitors)

Display Color for Digital Flat-Panels (DisplayPort Monitors)

HDTV Support for Digital Flat-Panels (DisplayPort Monitors)
</code>
Answer: This turns out to be a common problem with low quality displayport cables.  Oddly enough I still get this message even when I change to other displayport cables, but although I am getting warned, suddenly the full WQHD native resolution has become an available option for me to select in the Windows display settings.


Does right of withdrawal need the original packaging?

Question: I bought a dryer in the EU. I destroyed its packaging and used it once. It was terrible and now I want to return it. Does the right of withdraw need the product returned with the original packaging? Also is it ok if I used it once?
Comment: Do you want to use the "I step back from having purchased it in the first place" 2 weeks or the warranty to get a working hair drier?
Comment: I want to use the 2 weeks stepping back law.
Comment: "Right of withdrawal" sounds odd to my ears. Is there a source that uses that terminology?
Answer: The relevant EU rule doesn't specify a anything along those lines. Instead, it says that "The seller must deliver goods which are in conformity with the contract of sale to the consumer", and that "The seller is liable to the consumer for any lack of conformity which exists at the time when the consumer goods are delivered or becomes apparent within 2 years as from the delivery of the goods, even if the seller was not aware of the lack of conformity". Therefore, "Where consumer goods do not comply with the contract of sale, the seller is obliged to bring them into conformity with the contract of sale", moreover "Bringing the consumer goods into conformity with the contract of sale is free of charge for the consumer. The consumer must not incur any costs for dispatching the consumer goods or the labour and material costs, and must not suffer significant inconvenience".
So you can make a claim with the seller, and they could repair it or replace it. Mandatory return and refund only arises "after the trader has acted on three claims by the consumer for repairing the same goods, another lack of conformity of the goods with the contract of sale is detected within the span of the 2-year period above". Nothing in the law limits the consumer's right in the event that they discarded the original packaging.
Also note that this right exists if the goods are not in conformity with the contract, and does not exist if you are dissatisfied with the product.
Comment: you focus on the warrenty here, not the 2 weeks to rescind the contract.
Comment: 'If you bought a product or a service online or outside of a shop (by telephone, mail order, from a door-to-door salesperson), you also have the right to cancel and return your order within 14 days, for any reason and without a justification.' This is the law I am referring too.


Does Google analytics count as new users if users not revisit within 24hours on IOS14?

Question: With regards to first party cookies, does Google analytics count as new users if the users not revisit on the website within 24 hours as a first party cookie is deleted within 24 hours?
Answer: If GA is looking for a cookie to track the user, and the cookie expires before the users visits your site (24 hours per your question), then we can expect GA to treat them as a new user.
However, it's only _gid that expires after 24 hours; _ga does not, it expires after two years. If a _ga cookie is not present, new Client ID for the new user (aka "New Users" in your GA reports).

iOS 14 tracking changes
As far as I know, in iOS 14 Safari blocks all third-party cookies. I don't know of anything about first party cookies. There is added transparency and privacy reporting in Safari, what is tracking you is more visible. So if a user sees your cookie in their report (and doesn't want it) they can delete it.
As long as you don't have an app (so you're just a website) you only need to worry about changes in the Safari browser.
So really it's just Intelligent Tracking Prevention (or ITP) which has been updated and Apple's new Privacy Reports.
There are not any workarounds to ITP related challenges at the moment. So for now, the best you can do is monitor your data and see if/how the iOS 14 updates are affecting you and then go from there.


Is there any mathematical structure modelling parallel universes (multiverse)?

Question: Is there any mathematical structure modelling parallel universes (multiverse)? If we established such structure, is it science or science-fiction?
Answer: We do have such structure in place:
First, anything beyond the cosmological event horizon is effectively part of a different universe. An extension of that idea is the inflationary multiverse with bubble universes that can even have varying physical laws due to differently broken symmetries. String theory in turn adds its own flavour to that idea via the landscape multiverse.
While these multiverses are essentially just far away places, there are also theories featuring more exotic kinds of multiverses: One of them would be the brane multiverse of string theory where we can have literally parallel universes, another one the many-worlds interpretation of quantum mechanics.
Answer: Yes, you know - the many worlds theory is one of interpretations of quantum mechanics - so you can use quantum physics equation there (Like a probability by Born rule - the probability here can have a little different meaning). But the possible experiments what we would scientifically describe are (yet?) only speculations (Maybe because Copenhagen interpretation became more popular.).
http://en.wikipedia.org/wiki/Many-worlds_interpretation#Comparative_properties_and_possible_experimental_tests
If you mean another universes like a another dimensions we can calculate this by quantity of dark matter in space.
Answer: One that is particularly interesting:
In a paper published in Physical Review X, physicists  Michael Hall, Dirk-André Deckert, and Howard M. Wiseman have proposed a new view of quantum mechanics that may be testable in a way that could prove that it alone is the correct interpretation. They call it the Many Interacting Worlds approach to quantum mechanics.
The view they're proposing is that an infinite number of universes exist, each ruled by classical physics (i.e. no quantum mechanics!)  and that phenomena that we see as quantum mechanical arise because the universes can interact with each other.


If Voldemort killed Harry, and Harry stayed dead, who would kill Voldemort?

Question: Dumbledore said that Harry must die, and Voldemort himself must do it. If that were to happen, and Harry was to actually permanently die, how would Voldemort be killed?
Comment: These two questions aren't duplicates. The answers in the other question do NOT answer this question.
Comment: Relevant quote from *Philosopher's Stone*, thanks to [this question](https://ell.stackexchange.com/questions/137397/what-does-this-sentence-in-harry-potter-mean): "Nevertheless, Harry, while you may only have delayed his return to power, it will merely take someone else who is prepared to fight what seems a losing battle next time".
Comment: I actually don't think this is it. They want to know how Voldemort can be killed if Harry is dead. That said, the answer to that is simply exactly the way he was, because Harry wasn't killed (at least not permanently).
Comment: Harry had a piece of voldy stuck in him. Killing Harry along with that piece would also have helped D's plan to get rid of Voldy - then only nagini the last horcrux would have remained. After (neville or someone else) kills nagini, voldemort would've became mortal. That's why either Harry somehow survives or dies - both are fine, its a win-win situation for D.
Comment: Isn't this a bit speculative? We know how he could be killed, but no who would do it, right?
Answer: If Harry stayed dead, Voldemort could still be killed if his Horcruxes and body were killed.
By this time, all but one of Voldemort's Horcruxes, and with Harry's death the piece of his soul inside Harry, were all killed. Nagini was the last Horcrux remaining, and once she was destroyed, Voldemort would be mortal.

"Harry sat in thought for a moment, then asked, 'So if all of his Horcruxes are destroyed, Voldemort could be killed?'
'Yes, I think so,' said Dumbledore. >'Without his Horcruxes, Voldemort will be a mortal man with a maimed and diminished soul. Never forget, though, that while his soul may be damaged beyond repair, his brain and his magical power remain intact. It will take uncommon skill and power to kill a wizard like Voldemort, even without his Horcruxes." - Harry Potter and the Half-Blood Prince, Chapter 23 (Horcruxes)

Harry had no part in her destruction, that was Neville Longbottom, so Nagini would have still been killed if Harry had stayed dead. While Harry was the one to confront Voldemort in the final battle against him, Voldemort was mortal by then, and could be killed by anyone. All it would take at that point, when he was mortal, would be for someone to cast a Killing Curse at him.
Harry's fate after he died (if he stayed dead or not) was largely irrelevant.
The important thing was for Harry to die so that the piece of Voldemort's soul inside him would die.

"Tell him that on the night Lord Voldemort tried to kill him, when Lily cast her own life between them as a shield, the Killing Curse rebounded upon Lord Voldemort, and a fragment of Voldemort's soul was blasted apart from the whole, and latched itself on to the only living soul left in that collapsing building. Part of Lord Voldemort lives inside Harry, and it is that which gives him the power of speech with snakes, and a connection with Lord Voldemort's mind that he has never understood. And while that fragment of soul, unmissed by Voldemort, remains attached to, and protected by Harry, Lord Voldemort cannot die." - Harry Potter and the Deathly Hallows, Chapter 33 (The Prince's Tale)

Dumbledore telling Harry he needed to die was because he would otherwise be trying to defeat Voldemort without dying (either temporarily or permanently) and if he succeeded then Voldemort would still have an intact soul piece and wouldn't be truly defeated. Killing that soul piece was the entire point of Harry having to die before Voldemort could be defeated.
If Harry lived, once the soul piece died, that was fine - Harry himself didn't need to be dead.
The only reason Harry had to die was because it was the only way to kill the piece of Voldemort's soul inside him. Harry himself being dead didn't matter.
If Harry stayed dead, then the soul piece would also be dead, so mission accomplished.
The important part was Harry dying so the soul piece would, not Harry coming back to life afterwards. In the bigger picture of orchestrating Voldemort's downfall, the most important thing was making sure all of his Horcruxes were destroyed. If Harry stayed dead, the most important part of him dying, the soul piece being killed, would still have succeeded. It worked out so that by the time Harry dies, all the Horcruxes except Nagini were destroyed. Nagini wasn't an object, she was a venomous snake controlled by and loyal to Voldemort, so even people who were unaware that she was a Horcrux would be trying to kill her. Neville, the one who killed Nagini, had no idea she was a Horcrux. The last remaining soul piece was in Voldemort himself. Both of them were clear and obvious targets to try to kill.
Comment: Adding to your answer, there is one more subtlety, which (I think) Dumbledore planned. When Harry gave up his life, he invoked that ancient magic which protects the inhabitants of the castle, just like the protection he had from his mother's sacrifice. (*"Haven't you noticed how none of the spells you put on them are binding? You can't torture them. You can't touch them. You don't learn from your mistakes, Riddle, do you?"*). So Voldemort was extremely vulnerable.
Comment: The most important fact was that Harry was the rightful master of the Elder wand, if Harry dies Voldermort is master of the wand and so is even more powerful then during the first war. This makes him pretty much unbeatable.
Comment: @RichardC True, that is the reason why it happened as it happened: Harry just couldn't loose - not being the Master of Death could however have been a scenario where Harry dies; if, for example, it would not have been Easter when they were captured and Draco had not been at the Manor to get his wand wrestled out of his hand. Then Voldemort would not get ownership either. On the outher hand it could maybe even be a new question, whether Voldemort truly owning the Elder wand would override the magical protection by Harry's sacrifice - or if it would make the Elder wand essentially powerless.
Comment: @RichardC that might not be %100 correct, as Voldemort didn't "defeat" Harry inasmuch as Harry gave up himself. Similar to Dumbledore giving up to Snape and not being defeated
Comment: @user68699 I have already updated my answer (below) accordingly to add this point However I maintain Voldermort almost won the war the first time round due to his strength as a wizard, so it can be argued that even without the Elder wand and given some of the ages most powerful wizards had been killed, or joined Voldermort already, he may well have been unassailable even with the Horcruxes destroyed.
Answer: If Harry had died permanently then Voldermort would have become master of the elder wand. This would have made Voldemort pretty much unbeatable so the fact the Horcruxes where destroyed would not really have mattered.
Re reading this part of the books I realise I am wrong here, Voldermort would never have mastered the Elder wand and in dying Harry would have ensured no one else held the elder wand. But the fact is still that even with the Horcruxes destroyed Voldermort was still a far stronger wizard. Remember he only lost the last wizarding war because of Harry, if he hadn't gone to kill Harry he would not have been defeated. Therefore it was only a matter of time before Voldermort could have conquered the wizarding world.
Harry had to die to destroy the Horcrux he had become but he then had to come back to life so he could reclaim the elder wand, remember Voldermort died because the wand betrayed him turning his own killing curse against him. So if Harry had died then I don't think Voldermort would have been killed, remember during the first war Voldermort almost won. Armed with the elder wand he would have created new Horcruxes and having learnt from his previous mistakes probably been unbeatable.
Comment: Not quite -- it was Harry's intention to die, hence the wand's power would die with him because that wouldn't entail Voldemort defeating Harry. That was one of the reasons why Harry's death being intentional was of such value (along with seeming to give the Hogwarts family the same protection that Harry's mother gave him).
Comment: I have amended the answer accordingly, after re-reading I have realised my mis remembering of the facts :). However even without the Elder wand Voldermort would probably have been pretty unbeatable seeing as the most powerful wizard (Dumbledore) was dead.
Comment: If the Elder Wand really did make its owner unbeatable, then it would pass by inheritance when each owner died from natural causes, and not combat.


Cross Site Publishing - Error displaying item page

Question: After configuring cross site publishing and connecting to my catalog I am presented with my catalog page with my items listed however whenever I select either the item in the catalog or the term in the navigation bar I am presented with

The page you are looking for doesn't exist.

I have disconnected and reconnected the catalog, crawled and recrawled, pointed to catalog and items pages in the term store and still no joy.
Has anyone else encountered this issue and found a resolution?
Answer: Please confirm if all pages are checked in and major version is published.


How do I tile windows side by side?

Question: On the site http://ubuntued.info/como-por-as-janelas-do-ubuntu-lado-a-lado is possible to place the windows side by side with the gnome-do, but this tool does not work in the new Ubuntu 11.04 Natty Narwhal. How do I make this work in the new ubuntu?
Answer: I would also recommend for a day or so you use this really really good guide which shows you how to use some of Unity's features to the maximum
It was created by Octavian Damiean and I have found it very useful. When you have memorised all of it ;) you can go back to your favourite wallpaper

Here is the link for it if the image does not work
direct link
Comment: Holding down the Super (Windows) key brings that up too, but it would be handy to have it as a desktop background.
Comment: just what i was looking for :)
Answer: install compiz-fusion-plugins-extra .The defaults in Ubuntu 11.04 involve Upper Left Corner, Left Edge, and Lower Left Corner being set to Left Half, and Upper Right Corner, Right Edge, and Lower Right Corner being set to Right Half.
Answer: Press and Hold the Super key(Windows Key) until you see a popup that shows all keyboard shortcuts you could use.
There is not option to tile windows out of the box but you could use some of those combinations.

How do I tile windows side by side?


Passing arrays as parameters in bash

Question: How can I pass an array as parameter to a bash function?
Comment: Errr... Three downvotes on a five-year-old question within the same minute?
Comment: [Here](http://tldp.org/LDP/abs/html/arrays.html) you have nice reference and tons of examples.
Comment: @GabrielStaples: Seen it, upvoted it back then. I'm no longer writing complex Bash scripts, and haven't been for a while, so I left good enough alone and didn't really check new answers on whether that checkmark might bear switching around... might do that when I find the time to re-evaluate.
Comment: Here is a comprehensive answer: https://stackoverflow.com/questions/6212219/passing-parameters-to-a-bash-function/23585994#23585994
Comment: Related: [Passing parameters to a Bash function](https://stackoverflow.com/q/6212219/4561887)
Comment: See also: [How to pass array as an argument to a function in Bash](https://stackoverflow.com/q/16461656/4561887)
Comment: Here is the corresponding question for bash "associative arrays" (AKA: "dictionaries", "hash tables", or "unordered maps"): [How to pass an associative array as argument to a function in Bash?](https://stackoverflow.com/q/4069188/4561887)
Comment: @GabrielStaples As there are no answer suggesting the use of `getopts`, please have a look at [Run bash script with arrays as argument, using `getopts`](https://stackoverflow.com/a/75764948/1765658)
Comment: @F.Hauri-GiveUpGitHub: Not the question here. This is about calling *a bash function / subroutine*, from *within* the script. Unless I am very much mistaken, `getopts` is for the *command line* used to call the overall script, which is similar, but distinct.
Comment: @DevSolar Yes, you could use `getopts` in functions! I've edited [my answer](https://stackoverflow.com/a/75764948/1765658) for adding a function sample
Comment: @F.Hauri-GiveUpGitHub Still really really REALLY not what I was looking for, as you would still have to "markup" the array on calling the function. In this your answer does not offer any improvement over the answers below *and* is more complex / surprising, IMHO.
Comment: @DevSolar, passing by reference is pretty clean I think. I don't know if you've seen [my answer on this](https://stackoverflow.com/a/71060036/4561887) since I added it 13 years late.
Answer: You can pass multiple arrays as arguments using something like this:
takes_ary_as_arg()
{
    declare -a argAry1=("${!1}")
    echo "${argAry1[@]}"

    declare -a argAry2=("${!2}")
    echo "${argAry2[@]}"
}
try_with_local_arys()
{
    # array variables could have local scope
    local descTable=(
        "sli4-iread"
        "sli4-iwrite"
        "sli3-iread"
        "sli3-iwrite"
    )
    local optsTable=(
        "--msix  --iread"
        "--msix  --iwrite"
        "--msi   --iread"
        "--msi   --iwrite"
    )
    takes_ary_as_arg descTable[@] optsTable[@]
}
try_with_local_arys

will echo:
sli4-iread sli4-iwrite sli3-iread sli3-iwrite
--msix  --iread --msix  --iwrite --msi   --iread --msi   --iwrite

Edit/notes: (from comments below)

descTable and optsTable are passed as names and are expanded in the function. Thus no $ is needed when given as parameters.
Note that this still works even with descTable etc being defined with local, because locals are visible to the functions they call.
The ! in ${!1} expands the arg 1 variable.
declare -a just makes the indexed array explicit, it is not strictly necessary.
Comment: One thing to note is that if the original array is sparse, the array in the receiving function won't have the same indices.
Comment: This is brilliant, but can Ken or someone explain a couple of things that puzzle me about why it works:  1 - I would have thought that descTable and optsTable would have had to be prefixed with $ when passed as function arguments.  2 - In the first line of "takes...", why is an explicit array declaration needed?  3 - And what does the ! mean in the expression ${!1}, and why is [@] not required or even allowed there?    --   This works, and all of these details seem to be needed based on my testing, but I would like to understand why!
Comment: 1: descTable and optsTable are just passed as names, thus there is no $, they shall be expanded only in the called function
2: not totally sure, but I think it's not really necessary
3: the ! is used because the parameters passed to the function need to be expanded twice: $1 expands to "descTable[@]", and that should be expanded to "${descTable[@]}". The ${!1} syntax does just this.
Comment: I don't think the "declare -a" part is necessary.   The existence of parenthesis already define the LHS of the assignment as an array.
Comment: This answer helped me solve an issue just now. However, I wanted to point out that on my machine (using bash 4.3.42) the "${!1}" and "${!2}" need to have the quotes removed. If you do not, the value of the original array is read as one string and assigned to argAry1[0] and argAry2[0] respectively, basically meaning the array structure is lost.
Comment: Interesting... this means, the local variables in the `try_with_local_arys` are visible in the functions that it calls, such as `takes_ary_as_arg`.
Comment: This is 100% not different from passing no arguments and using `${descTable[@]}`. The `local` keyword allows variables to leak to called functions, which is exactly what's being used here, just in an obfuscated manner.
Comment: This solution depends on the documented "feature" that local variables are visible to the functions that they call.  I'm glad there is a solution, but I can easily imagine cases where this feature make a bug hard to find.  From The Advanced Bash Scripting Guide quoting the bash man page: '"Local can only be used within a function; it makes the variable name have a visible scope restricted to that function *and its children*." [emphasis added] The ABS Guide author considers this behavior to be a bug.' http://www.tldp.org/LDP/abs/html/localvar.html
Comment: With this solution, isn't the length of the second array effectively doubled in the inner function? This is because the spaces are re-interpreted.
Comment: It may be a good solution if you don't want to modify the content of the array.
Comment: What about associative arrays?
Comment: This doesn't work if there's files named `descTable@` or `optTable@` in the current directory. ;)
Comment: How does local arrays of one function descTable and optsTable expanded in other function   takes_ary_as_arg by variable indirection ? someone please help me in understand this.
Comment: @SriramP as explained in a comment before (and I just updated the answer accordingly), because "local variables are visible to the functions that they call".
Comment: This is possible due to *dynamic scoping* in bash.
Answer: Note: This is the somewhat crude solution I posted myself, after not finding an answer here on Stack Overflow. It allows for only one array being passed, and it being the last element of the parameter list. Actually, it is not passing the array at all, but a list of its elements, which are re-assembled into an array by called_function(), but it worked for me. Somewhat later Ken posted his solution, but I kept mine here for "historic" reference.
calling_function()
{
    variable="a"
    array=( "x", "y", "z" )
    called_function "${variable}" "${array[@]}"
}

called_function()
{
    local_variable="${1}"
    shift
    local_array=("${@}")
}

Comment: Three years after the fact, this answer - kept for historical reasons only - received two downvotes within a couple of days. As sadly usual on SO, without any note as to why people think this is warranted. Note that this answer *predates* all others, and that I accepted Ken's answer as the best solution. I am perfectly aware it is nowhere near perfect, but for four *months* it was the best available on SO. Why it should be downvoted two *years* after it took second place to Ken's perfect solution is beyond me.
Comment: Well, you can pass multiple arrays if you include the number of elements of each array. `called_function "${#array[@]}" "${array[@]}" "${#array2[@]}" "${array2[@]}"` etc... still with some obvious restrictions, but really, better to solve the problem in a way the language supports, rather than trying to bend the language into working the way you are used to in other languages.
Comment: @geirha: Well, I guess we'll have to agree that we don't agree, and you will have to let me being the judge of which answer answers my question best. Personally, I much prefer passing arrays by reference *anyway* (no matter the language, to save the data copying); even more so when the alternative is to bend over backwards and pass the array size as additional parameter...
Comment: I know you asked the question, you wrote this answer, and that you accepted the bad answer. That's why I worded it that way. The reason the accepted answer is bad is because it is trying to pass array by reference, which is something you should really avoid. In addition, the example mashes multiple arguments into a single string. If you really need to pass arrays by reference, bash is the wrong language to begin with. Even with bash 4.3's new nameref variables, you cannot safely avoid name collisions (circular reference).
Comment: @geirha: I would ask you to check who's posted the question, who posted this answer, and who probably *accepted* the answer you are calling "bad". ;-) You might also want to check the **Note** in the question, which points out why this solution is inferior to Ken's.
Comment: @geirha: So you deem Ken's answer, which is basically the *only* way you can pass (multiple) arrays in bash, as "bad" because there isn't a better way to do it in bash -- and mine, which *cannot* pass multiple arrays, as better? Think about that for a while...
Comment: Or, you can just go here for a comprehensive answer: https://stackoverflow.com/questions/6212219/passing-parameters-to-a-bash-function/23585994#23585994
Answer: Commenting on Ken Bertelson solution and answering Jan Hettich:
How it works
the takes_ary_as_arg descTable[@] optsTable[@] line in try_with_local_arys() function sends:

This is actually creates a copy of the descTable and optsTable arrays which are accessible to the takes_ary_as_arg function.
takes_ary_as_arg() function receives descTable[@] and optsTable[@] as strings, that means $1 == descTable[@] and $2 == optsTable[@].
in the beginning of takes_ary_as_arg() function it uses ${!parameter} syntax, which is called indirect reference or sometimes double referenced, this means that instead of using $1's value, we use the value of the expanded value of $1, example:
baba=booba
variable=baba
echo ${variable} # baba
echo ${!variable} # booba

likewise for $2.
putting this in argAry1=("${!1}") creates argAry1 as an array (the brackets following =) with the expanded descTable[@], just like writing there argAry1=("${descTable[@]}") directly.
the declare there is not required.

N.B.: It is worth mentioning that array initialization using this bracket form initializes the new array according to the IFS or Internal Field Separator which is by default tab, newline and space. in that case, since it used [@] notation each element is seen by itself as if he was quoted (contrary to [*]).
My reservation with it
In BASH, local variable scope is the current function and every child function called from it, this translates to the fact that takes_ary_as_arg() function "sees" those descTable[@] and optsTable[@] arrays, thus it is working (see above explanation).
Being that case, why not directly look at those variables themselves? It is just like writing there:
argAry1=("${descTable[@]}")

See above explanation, which just copies descTable[@] array's values according to the current IFS.
In summary

This is passing, in essence, nothing by value - as usual.

I also want to emphasize Dennis Williamson comment above: sparse arrays (arrays without all the keys defines - with "holes" in them) will not work as expected - we would loose the keys and "condense" the array.
That being said,  I do see the value for generalization, functions thus can get the arrays (or copies) without knowing the names:

for ~"copies": this technique is good enough, just need to keep aware, that the indices (keys) are gone.
for real copies:
we can use an eval for the keys, for example:
eval local keys=(\${!$1})

and then a loop using them to create a copy.
Note: here ! is not used it's previous indirect/double evaluation, but rather in array context it returns the array indices (keys).

and, of course, if we were to pass descTable and optsTable strings (without [@]), we could use the array itself (as in by reference) with eval. for a generic function that accepts arrays.
Comment: Good explanations of the mechanism behind Ken Bertelson explanation. To the question "Being that case, why not directly look at those variables themselves?", I will answer : simply for reuse of the function. Let's say I need to call a function with `Array1`, then with `Array2`, passing the array names becomes handy.
Answer: The basic problem here is that the bash developer(s) that designed/implemented arrays really screwed the pooch.  They decided that ${array} was just short hand for ${array[0]}, which was a bad mistake. Especially when you consider that ${array[0]} has no meaning and evaluates to the empty string if the array type is associative.
Assigning an array takes the form array=(value1 ... valueN) where value has the syntax [subscript]=string, thereby assigning a value directly to a particular index in the array.  This makes it so there can be two types of arrays, numerically indexed and hash indexed (called associative arrays in bash parlance).  It also makes it so that you can create sparse numerically indexed arrays.  Leaving off the [subscript]= part is short hand for a numerically indexed array, starting with the ordinal index of 0 and incrementing with each new value in the assignment statement.
Therefore, ${array} should evaluate to the entire array, indexes and all.  It should evaluate to the inverse of the assignment statement.  Any third year CS major should know that.  In that case, this code would work exactly as you might expect it to:
declare -A foo bar
foo=${bar}

Then, passing arrays by value to functions and assigning one array to another would work as the rest of the shell syntax dictates.  But because they didn't do this right, the assignment operator = doesn't work for arrays, and arrays can't be passed by value to functions or to subshells or output in general (echo ${array}) without code to chew through it all.
So, if it had been done right, then the following example would show how the usefulness of arrays in bash could be substantially better:
simple=(first=one second=2 third=3)
echo ${simple}

the resulting output should be:
(first=one second=2 third=3)

Then, arrays could use the assignment operator, and be passed by value to functions and even other shell scripts.  Easily stored by outputting to a file, and easily loaded from a file into a script.
declare -A foo
read foo <file

Alas, we have been let down by an otherwise superlative bash development team.
As such, to pass an array to a function, there is really only one option, and that is to use the nameref feature:
function funky() {
    local -n ARR

    ARR=$1
    echo "indexes: ${!ARR[@]}"
    echo "values: ${ARR[@]}"
}

declare -A HASH

HASH=([foo]=bar [zoom]=fast)
funky HASH # notice that I'm just passing the word 'HASH' to the function

will result in the following output:
indexes: foo zoom
values: bar fast

Since this is passing by reference, you can also assign to the array in the function.  Yes, the array being referenced has to have a global scope, but that shouldn't be too big a deal, considering that this is shell scripting.  To pass an associative or sparse indexed array by value to a function requires throwing all the indexes and the values onto the argument list (not too useful if it's a large array) as single strings like this:
funky "${!array[*]}" "${array[*]}"

and then writing a bunch of code inside the function to reassemble the array.
Comment: The solution of using `local -n` is better and more up to date than the accepted answer. This solution will also work for a variable of any type. The example listed in this answer can be shortened to `local -n ARR=${1}`. However the `-n` option for `local`/`declare` is only available in Bash version 4.3 and above.
Comment: This is nice! Small gotcha: if you pass a variable with the same name as your function's local argument (e.g. `funky ARR`), shell will give warning `circular name reference`, because basically the function will try to do `local -n ARR=ARR`. Good [discussion](http://stackoverflow.com/questions/33775996/circular-name-reference#33777659) about this topic.
Comment: After reading that page, I reach the conclusion that:
1. Using arrays in bash is a very idea
2. Play with IFS and avoid arrays in bash if your idea was to write something elegant.
Answer: How to pass regular and associative arrays as parameters by reference in bash
Modern bash (apparently version 4.3 or later), allows you to pass arrays by reference. I'll show that below. If you'd like to manually serialize and deserialize the arrays instead, see my answer here for bash regular "indexed" arrays, and here for bash associative arrays. For printing arrays by value or reference, see my answer here.
Passing arrays by reference, as shown below, is much easier and more-concise, however, so that's what I now recommend.
The code below is also available online in my eRCaGuy_hello_world repo here: array_pass_as_bash_parameter_by_reference.sh. See also this example here: array_pass_as_bash_parameter_2_associative.sh.
Here is a demo for regular bash arrays:
function foo {
    # declare a local **reference variable** (hence `-n`) named `data_ref`
    # which is a reference to the value stored in the first parameter
    # passed in
    local -n data_ref="$1"
    echo "${data_ref[0]}"
    echo "${data_ref[1]}"
}

# declare a regular bash "indexed" array
declare -a data
data+=("Fred Flintstone")
data+=("Barney Rubble")
foo "data"

Sample output:

Fred Flintstone
Barney Rubble

...and here is a demo for associative bash arrays (ie: bash hash tables, "dictionaries", or "unordered maps"):
function foo {
    # declare a local **reference variable** (hence `-n`) named `data_ref`
    # which is a reference to the value stored in the first parameter
    # passed in
    local -n data_ref="$1"
    echo "${data_ref["a"]}"
    echo "${data_ref["b"]}"
}

# declare a bash associative array
declare -A data
data["a"]="Fred Flintstone"
data["b"]="Barney Rubble"
foo "data"

Sample output:

Fred Flintstone
Barney Rubble

References:

I modified the above code samples from @Todd Lehman's answer here: How to pass an associative array as argument to a function in Bash?
See also my manual serializing/deserializing answer here
And see my follow-up Question here: Why do the man bash pages state the declare and local -n attribute "cannot be applied to array variables", and yet it can?
Answer: DevSolar's answer has one point I don't understand (maybe he has a specific reason to do so, but I can't think of one): He sets the array from the positional parameters element by element, iterative.
An easier approuch would be
called_function()
{
  ...
  # do everything like shown by DevSolar
  ...

  # now get a copy of the positional parameters
  local_array=("$@")
  ...
}

Comment: My reason for not doing so is that I haven't toyed with bash arrays at all until a few days ago. Previously I'd have switched to Perl if it became complex, an option I don't have at my current job. Thanks for the hint!
Answer: An easy way to pass several arrays as parameter is to use a character-separated string. You can call your script like this:
./myScript.sh "value1;value2;value3" "somethingElse" "value4;value5" "anotherOne"

Then, you can extract it in your code like this:
myArray=$1
IFS=';' read -a myArray <<< "$myArray"

myOtherArray=$3
IFS=';' read -a myOtherArray <<< "$myOtherArray"

This way, you can actually pass multiple arrays as parameters and it doesn't have to be the last parameters.
Answer: function aecho {
  set "$1[$2]"
  echo "${!1}"
}

Example
$ foo=(dog cat bird)

$ aecho foo 1
cat

Answer: This one works even with spaces:
format="\t%2s - %s\n"

function doAction
{
  local_array=("$@")
  for (( i = 0 ; i < ${#local_array[@]} ; i++ ))
    do
      printf "${format}" $i "${local_array[$i]}"
  done
  echo -n "Choose: "
  option=""
  read -n1 option
  echo ${local_array[option]}
  return
}

#the call:
doAction "${tools[@]}"

Comment: I wonder what the point is here. This is just normal argument passing. The "$@" syntax is made to work for spaces: "$@" is equivalent to "$1" "$2"...
Comment: Can I pass 2 arrays to a function?
Answer: With a few tricks you can actually pass named parameters to functions, along with arrays.
The method I developed allows you to access parameters passed to a function like this:
testPassingParams() {

    @var hello
    l=4 @array anArrayWithFourElements
    l=2 @array anotherArrayWithTwo
    @var anotherSingle
    @reference table   # references only work in bash >=4.3
    @params anArrayOfVariedSize

    test "$hello" = "$1" && echo correct
    #
    test "${anArrayWithFourElements[0]}" = "$2" && echo correct
    test "${anArrayWithFourElements[1]}" = "$3" && echo correct
    test "${anArrayWithFourElements[2]}" = "$4" && echo correct
    # etc...
    #
    test "${anotherArrayWithTwo[0]}" = "$6" && echo correct
    test "${anotherArrayWithTwo[1]}" = "$7" && echo correct
    #
    test "$anotherSingle" = "$8" && echo correct
    #
    test "${table[test]}" = "works"
    table[inside]="adding a new value"
    #
    # I'm using * just in this example:
    test "${anArrayOfVariedSize[*]}" = "${*:10}" && echo correct
}

fourElements=( a1 a2 "a3 with spaces" a4 )
twoElements=( b1 b2 )
declare -A assocArray
assocArray[test]="works"

testPassingParams "first" "${fourElements[@]}" "${twoElements[@]}" "single with spaces" assocArray "and more... " "even more..."

test "${assocArray[inside]}" = "adding a new value"

In other words, not only you can call your parameters by their names (which makes up for a more readable core), you can actually pass arrays (and references to variables - this feature works only in bash 4.3 though)! Plus, the mapped variables are all in the local scope, just as $1 (and others).
The code that makes this work is pretty light and works both in bash 3 and bash 4 (these are the only versions I've tested it with). If you're interested in more tricks like this that make developing with bash much nicer and easier, you can take a look at my Bash Infinity Framework, the code below was developed for that purpose.
Function.AssignParamLocally() {
    local commandWithArgs=( $1 )
    local command="${commandWithArgs[0]}"

    shift

    if [[ "$command" == "trap" || "$command" == "l="* || "$command" == "_type="* ]]
    then
        paramNo+=-1
        return 0
    fi

    if [[ "$command" != "local" ]]
    then
        assignNormalCodeStarted=true
    fi

    local varDeclaration="${commandWithArgs[1]}"
    if [[ $varDeclaration == '-n' ]]
    then
        varDeclaration="${commandWithArgs[2]}"
    fi
    local varName="${varDeclaration%%=*}"

    # var value is only important if making an object later on from it
    local varValue="${varDeclaration#*=}"

    if [[ ! -z $assignVarType ]]
    then
        local previousParamNo=$(expr $paramNo - 1)

        if [[ "$assignVarType" == "array" ]]
        then
            # passing array:
            execute="$assignVarName=( \"\${@:$previousParamNo:$assignArrLength}\" )"
            eval "$execute"
            paramNo+=$(expr $assignArrLength - 1)

            unset assignArrLength
        elif [[ "$assignVarType" == "params" ]]
        then
            execute="$assignVarName=( \"\${@:$previousParamNo}\" )"
            eval "$execute"
        elif [[ "$assignVarType" == "reference" ]]
        then
            execute="$assignVarName=\"\$$previousParamNo\""
            eval "$execute"
        elif [[ ! -z "${!previousParamNo}" ]]
        then
            execute="$assignVarName=\"\$$previousParamNo\""
            eval "$execute"
        fi
    fi

    assignVarType="$__capture_type"
    assignVarName="$varName"
    assignArrLength="$__capture_arrLength"
}

Function.CaptureParams() {
    __capture_type="$_type"
    __capture_arrLength="$l"
}

alias @trapAssign='Function.CaptureParams; trap "declare -i \"paramNo+=1\"; Function.AssignParamLocally \"\$BASH_COMMAND\" \"\$@\"; [[ \$assignNormalCodeStarted = true ]] && trap - DEBUG && unset assignVarType && unset assignVarName && unset assignNormalCodeStarted && unset paramNo" DEBUG; '
alias @param='@trapAssign local'
alias @reference='_type=reference @trapAssign local -n'
alias @var='_type=var @param'
alias @params='_type=params @param'
alias @array='_type=array @param'

Answer: Just to add to the accepted answer, as I found it doesn't work well if the array contents are someting like:
RUN_COMMANDS=(
  "command1 param1... paramN"
  "command2 param1... paramN"
)

In this case, each member of the array gets split, so the array the function sees is equivalent to:
RUN_COMMANDS=(
    "command1"
    "param1"
     ...
    "command2"
    ...
)

To get this case to work, the way I found is to pass the variable name to the function, then use eval:
function () {
    eval 'COMMANDS=( "${'"$1"'[@]}" )'
    for COMMAND in "${COMMANDS[@]}"; do
        echo $COMMAND
    done
}

function RUN_COMMANDS

Just my 2©
Answer: As ugly as it is, here is a workaround that works as long as you aren't passing an array explicitly, but a variable corresponding to an array:
function passarray()
{
    eval array_internally=("$(echo '${'$1'[@]}')")
    # access array now via array_internally
    echo "${array_internally[@]}"
    #...
}

array=(0 1 2 3 4 5)
passarray array # echo's (0 1 2 3 4 5) as expected

I'm sure someone can come up with a clearner implementation of the idea, but I've found this to be a better solution than passing an array as "{array[@]"} and then accessing it internally using array_inside=("$@"). This becomes complicated when there are other positional/getopts parameters. In these cases, I've had to first determine and then remove the parameters not associated with the array using some combination of shift and array element removal.
A purist perspective likely views this approach as a violation of the language, but pragmatically speaking, this approach has saved me a whole lot of grief. On a related topic, I also use eval to assign an internally constructed array to a variable named according to a parameter target_varname I pass to the function:
eval $target_varname=$"(${array_inside[@]})"
Hope this helps someone.
Answer: My short answer is:
function display_two_array {
    local arr1=$1
    local arr2=$2
    for i in $arr1
    do
       echo "arrary1: $i"
    done

    for i in $arr2
    do
       echo "arrary2: $i"
    done
}

test_array=(1 2 3 4 5)
test_array2=(7 8 9 10 11)

display_two_array "${test_array[*]}" "${test_array2[*]}"

It should be noticed that the ${test_array[*]} and ${test_array2[*]} should be surrounded by "", otherwise you'll fail.
Comment: Your example is incorrect because it incomplete. Please give full code of script.
Comment: "Snippets" are only for HTML and JavaScript. Use the `{}` button to code-highlight code in other languages.
Answer: How to pass regular arrays as parameters by value in bash, via manual parsing and serializing/deserializing
The answer below shows you how to pass bash regular "indexed" arrays as parameters to a function essentially by serializing and deserializing them.

To see this manual serializing/deserializing for bash associative arrays (hash tables) instead of for regular indexed arrays, see my answer here.
For a better way (which requires bash version 4.3 or later, I think), which passes the arrays by reference, see the link just above and my other answer here.

Passing arrays by reference is much easier and more-concise, so that's what I now recommend. That being said, the manual serializing/deserializing techniques I show below are also extremely informative and useful.

Quick summary:
See the 3 separate function definitions below. I go over how to pass:

one bash array to a function
two or more bash arrays to a function, and
two or more bash arrays plus additional arguments (before or after the arrays) to a function.

12 years later and I still don't see any answers I really like here and which I would consider to be thorough enough, simple enough, and "canonical" enough for me to just use--answers which I can come back to again and again and copy and paste and expand when needed. So, here is my answer which I do consider to be all of these things.
How to pass bash arrays as parameters to bash functions
You might also call this "variadic argument parsing in bash functions or scripts", especially since the number of elements in each array passed in to the examples below can dynamically vary, and in bash the elements of an array essentially get passed to the function as separate input parameters even when the array is passed in via a single array expansion argument like this "${array1[@]}".
For all example code below, assume you have these two bash arrays for testing:
array1=()
array1+=("one")
array1+=("two")
array1+=("three")

array2=("four" "five" "six" "seven" "eight")

The code above and below is available in my bash/array_pass_as_bash_parameter.sh file in my eRCaGuy_hello_world repo on GitHub.
Example 1: how to pass one bash array to a function
To pass an array to a bash function, you have to pass all of its elements separately. Given bash array array1, the syntax to obtain all elements of this array is "${array1[@]}". Since all incoming parameters to a bash function or executable file get wrapped up in the magic bash input parameter array called @, you can read all members of the input array with the "$@" syntax, as shown below.
Function definition:
# Print all elements of a bash array.
# General form:
#       print_one_array array1
# Example usage:
#       print_one_array "${array1[@]}"
print_one_array() {
    for element in "$@"; do
        printf "    %s\n" "$element"
    done
}

Example usage:
echo "Printing array1"
# This syntax passes all members of array1 as separate input arguments to
# the function
print_one_array "${array1[@]}"

Example Output:
Printing array1
    one
    two
    three

Example 2: how to pass two or more bash arrays to a function...
(and how to recapture the input arrays as separate bash arrays again)
Here, we need to differentiate which incoming parameters belong to which array. To do this, we need to know the size of each array, meaning the number of elements in each array. This is very similar to passing arrays in C, where we also generally must know the array length passed to any C function. Given bash array array1, the number of elements in it can be obtained with "${#array1[@]}" (notice the usage of the # symbol). In order to know where in the input arguments the array_len length parameter is, we must always pass the array length parameter for each array before passing the individual array elements, as shown below.
In order to parse the arrays, I use array slicing on the input argument array, @.
Here is a reminder on how bash array slicing syntax works (from my answer here). In the slicing syntax :start:length, the 1st number is the zero-based index to start slicing from, and the 2nd number is the number of elements to grab:
# array slicing basic format 1: grab a certain length starting at a certain
# index
echo "${@:2:5}"
#         │ │
#         │ └────> slice length
#         └──────> slice starting index (zero-based)

# array slicing basic format 2: grab all remaining array elements starting at a
# certain index through to the end
echo "${@:2}"
#         │
#         │
#         └──────> slice starting index (zero-based)

Also, in order to force the sliced parameters from the input array to become a new array, I surround them in parenthesis (), like this, for example ("${@:$i:$array1_len}"). Those parenthesis on the outside are important, again, because that's how we make an array in bash.
This example below only accepts two bash arrays, but following the given patterns it can be easily adapted to accept any number of bash arrays as arguments.
Function definition:
# Print all elements of two bash arrays.
# General form (notice length MUST come before the array in order
# to be able to parse the args!):
#       print_two_arrays array1_len array1 array2_len array2
# Example usage:
#       print_two_arrays "${#array1[@]}" "${array1[@]}" \
#       "${#array2[@]}" "${array2[@]}"
print_two_arrays() {
    # For debugging: print all input args
    echo "All args to 'print_two_arrays':"
    print_one_array "$@"

    i=1

    # Read array1_len into a variable
    array1_len="${@:$i:1}"
    ((i++))
    # Read array1 into a new array
    array1=("${@:$i:$array1_len}")
    ((i += $array1_len))

    # Read array2_len into a variable
    array2_len="${@:$i:1}"
    ((i++))
    # Read array2 into a new array
    array2=("${@:$i:$array2_len}")
    ((i += $array2_len))

    # Print the two arrays
    echo "array1:"
    print_one_array "${array1[@]}"
    echo "array2:"
    print_one_array "${array2[@]}"
}

Example usage:
echo "Printing array1 and array2"
print_two_arrays "${#array1[@]}" "${array1[@]}" "${#array2[@]}" "${array2[@]}"

Example Output:
Printing array1 and array2
All args to 'print_two_arrays':
    3
    one
    two
    three
    5
    four
    five
    six
    seven
    eight
array1:
    one
    two
    three
array2:
    four
    five
    six
    seven
    eight

Example 3: pass two bash arrays plus some extra args after that to a function
This is a tiny expansion of the example above. It also uses bash array slicing, just like the example above. Instead of stopping after parsing two full input arrays, however, we continue and parse a couple more arguments at the end. This pattern can be continued indefinitely for any number of bash arrays and any number of additional arguments, accommodating any input argument order, so long as the length of each bash array comes just before the elements of that array.
Function definition:
# Print all elements of two bash arrays, plus two extra args at the end.
# General form (notice length MUST come before the array in order
# to be able to parse the args!):
#       print_two_arrays_plus_extra_args array1_len array1 array2_len array2 \
#       extra_arg1 extra_arg2
# Example usage:
#       print_two_arrays_plus_extra_args "${#array1[@]}" "${array1[@]}" \
#       "${#array2[@]}" "${array2[@]}" "hello" "world"
print_two_arrays_plus_extra_args() {
    i=1

    # Read array1_len into a variable
    array1_len="${@:$i:1}"
    ((i++))
    # Read array1 into a new array
    array1=("${@:$i:$array1_len}")
    ((i += $array1_len))

    # Read array2_len into a variable
    array2_len="${@:$i:1}"
    ((i++))
    # Read array2 into a new array
    array2=("${@:$i:$array2_len}")
    ((i += $array2_len))

    # You can now read the extra arguments all at once and gather them into a
    # new array like this:
    extra_args_array=("${@:$i}")

    # OR you can read the extra arguments individually into their own variables
    # one-by-one like this
    extra_arg1="${@:$i:1}"
    ((i++))
    extra_arg2="${@:$i:1}"
    ((i++))

    # Print the output
    echo "array1:"
    print_one_array "${array1[@]}"
    echo "array2:"
    print_one_array "${array2[@]}"
    echo "extra_arg1 = $extra_arg1"
    echo "extra_arg2 = $extra_arg2"
    echo "extra_args_array:"
    print_one_array "${extra_args_array[@]}"
}

Example usage:
echo "Printing array1 and array2 plus some extra args"
print_two_arrays_plus_extra_args "${#array1[@]}" "${array1[@]}" \
"${#array2[@]}" "${array2[@]}" "hello" "world"

Example Output:
Printing array1 and array2 plus some extra args
array1:
    one
    two
    three
array2:
    four
    five
    six
    seven
    eight
extra_arg1 = hello
extra_arg2 = world
extra_args_array:
    hello
    world

References:

I referenced a lot of my own sample code from my eRCaGuy_hello_world repo here:

array_practice.sh
array_slicing_demo.sh

[my answer on bash array slicing] Unix & Linux: Bash: slice of positional parameters
An answer to my question on "How can I create and use a backup copy of all input args ("$@") in bash?" - very useful for general array manipulation of the input argument array
An answer to "How to pass array as an argument to a function in Bash", which confirmed to me this really important concept that:

You cannot pass an array, you can only pass its elements (i.e. the expanded array).

See also:

[another answer of mine on this topic] How to pass array as an argument to a function in Bash
Answer: Requirement: Function to find a string in an array.
This is a slight simplification of DevSolar's solution in that it uses the arguments passed rather than copying them.
myarray=('foobar' 'foxbat')

function isInArray() {
  local item=$1
  shift
  for one in $@; do
    if [ $one = $item ]; then
      return 0   # found
    fi
  done
  return 1       # not found
}

var='foobar'
if isInArray $var ${myarray[@]}; then
  echo "$var found in array"
else
  echo "$var not found in array"
fi

Answer: You can also create a json file with an array, and then parse that json file with jq
For example:
my-array.json:
{
  "array": ["item1","item2"]
}

script.sh:
ARRAY=$(jq -r '."array"' $1 | tr -d '[],"')

And then call the script like:
script.sh ./path-to-json/my-array.json

You can find more ideas in this similar question: How to pass array as an argument to a function in Bash

Passing arrays as parameters in bash


Difference between, "claimed as" and "claimed to be"

Question: What is the difference between:

"She claimed the child as her own"

and:

"She claimed the child to be her own"
Answer: Claim has two meanings.
In the first use it means that she is saying that the object (now) belongs to her.
(Example: "The explorer planted the flag and claimed the country for the Queen of England")
In the second use, it means that she is stating that she believes something is the case
(Example: "John claimed he knew nothing about the missing money").
In the above example they could mean the same thing (except in some edge cases such as 'claiming' the child by kidnapping him for the first case)
Answer: "Claimed ... to be" involves making a verbal statement, for example, by speaking or writing the statement in order to communicate her belief that she has a parental rights over the child. This can be as simple as answering "yes" to the question "is this your child?"
"Claimed ... as" is broader and stronger than just making a verbal statement. It often has the connotation of taking some action based on her belief about her parental rights. It may include making a statement like in "claimed to be", but I think it often means taking action that demonstrates a commitment to the fact being true. An example might be filing court papers to assert custody.
Answer:
She claimed the child as her own

In this example the child wasn't the woman's, but she is now taking it to be.

She claimed the child to be her own

In this example the child is the woman's and she is attempting to make that known.

The meanings of "claimed as" and "claimed to be" will vary depending on circumstance. Sometimes, as shown in your examples, "claimed as" means "is since" and "claimed to be" means "is". Other times "claimed to be" can be used to infer uncertainty regarding claim validity while "claimed as" yields no opposition to a claim.

This land is claimed as part of Uivinio territory.

It is since claim.

This land is claimed to be Uivinio territory.

It may be.
Comment: As I wrote this I kept writing "clam to be" :P .


what is the meaning of division by zero and indeterminate forms?

Question: what is the meaning of the formulas 1/0 and 0/0 by looking at them from the   prospective of calculus and limits ?
and as they are indeterminate forms , how is algebraic manipulation of a function that carries one of those formulas at some point capable of evaluating its limit ?
Comment: If it is not determinate, it is indeterminate.
Answer: In calculus, such expressions are short-hand notations for limits.  $1/0$ isn't indeterminate, but undefined.  But in this context, it could be short-hand for a limit which diverges to $\pm \infty.$   $0/0$ is an indeterminate form, because in various situations, the limit it represents can be any real number or infinity.
Answer: Consider the function $f(x)=\frac{\sin x}{x}$. A graph of $f(x)$ might look like:

It seems that $f(0)=1$, but $f(0)=\frac{\sin 0}{0}=\frac{0}{0}$. Thus, $f(x)$ has an undefined point at $x=0$ - it is an $\frac{0}{0}$ indeterminate form!
Some indeterminate forms will not have a limit. For example,
$$\lim_{x\to 0}\frac{1}{x}$$
is undefined: it diverges to $\infty$ from the positive direction and $-\infty$ from the negative direction. But $\displaystyle\lim_{x\to 0}f(x)$ seems to be $1$. Indeed, this limit is shown here:
How to prove that $\lim\limits_{x\to0}\frac{\sin x}x=1$?
Although this particular function required no algebraic manipulation, clearly more complicated functions would require it.
Answer: You can get intuition by looking at
$$\lim_{x \to 0} ax/x$$
This is of course $a $ but simply taking limits in the numerator and denominator would give $0/0$. This example shows us that in these cases we need more information than just the limits of the numerator and denominator, we need to know how fast they go to these limits. Algebraic manipulation can isolate that information for us sometimes. (In this example, by just cancelling $x/x=1$ for nonzero $x $, though this can be more complicated sometimes).


Best practices in combining validation rules for object fields?

Question: I have a custom object with many fields, I need to ensure some of these fields are required during update (but not insert).
While I can create a validation rule for each of these required fields, I was wondering if I can combine them. The challenge when I combine them is that I cannot custom my message to identify which specific fields are missing. Is there a way to craft a single rule so that I can apply the violating value in the error message?
Also, are there any performance or governance concerns if I create one validation per field. There are around 20 fields to check.
Thanks.
Answer: Since validation rules can only have one message to present to the user, I think combining validation rules is a bad idea. If you are hitting your limit of validation rules on the object you can try asking Salesforce to increase that limit or you will need to turn to using triggers.
Answer: Alternatively, you can write a trigger and display an error with custom message - built based on your criterias for each field.
Answer: You can try to override the edit page with a custom visualforce page and controler that will check the user inputs. Then you can define custom error messages on the page, translate them and have a full control on what exactly is updated.
Comment: Keep in mind validation rules have a much wider scope than user input.


What games can I play on Steam on Debian?

Question: I have installed Steam on my 32 bit Debian Jessie. Looking through the catalogue a lot of them have minimum requirements of Ubuntu as the OS. Can I still play the games?
Answer: If you meet the hardware specs, and have steam installed under debian, then yes you should be just fine playing those games.
Comment: Just a side note, you may not always get the same performance due to more updated system drivers/packages. For example there are reports of better Steam performance under archlinux rather than ubuntu for this reason. Not sure how widespread this is however, or how much you'd notice.


User relationship requests in a view block with accept and decline links

Question: I have a node in which i want to show a user all the relationship requests the current user has received and a status link below that so that the user can accept or decline the request then and there itself without needing to go to the boring Drupal default user relationship page. I am obviously using the user relationship module for this purpose. Anyways, i set out to create a view but after tinkering enough i was unable to do so. What i was able to do was to get a list of all relation requests (also made by the logged in user) I want only the received request.  How can i do this? If it helps, here's my view
Answer: Add requestee relation.
Add context filter by user id (set it on current user with requestee relation). Add filter criteria by relationship status.
Here you can see screenshot of view.


Exporting a theme in a non-minified way

Question: When I am trying to export the theme site in Sitecore 9.3 I get the pre-minified version of css, and pre-minified version of js. How can i export the theme that would contain the normal version of the assets files such as css and js
Comment: If you are using the creative exchange (live) then you typically start out with the original version of the files. Can you provide more detail about how you setup your theme, what documentation you followed to get started, and what you have tried?
Comment: @MichaelWest We do not have any original version of files. Everything has been already minified on the site, and we do not have access to the original version of the files.
Comment: Sounds like you are asking to reverse engineer the optimization steps, something that would be out of the scope of Sitecore/SXA.
Comment: @MichaelWest Also when I am trying to export the specific page (for example home page) I get everything in minified way? Should that happen or? Shouldnt I get for example index.html of that page, styles and etc.?
Answer: Simple answer is you cannot.
I believe you meant pre-optimized-min not pre-minified.

pre-optimized-min - they are not reversible. Items/files with this name were/should be created outside of Sitecore by FE developers. Read about it here. They are responsible for creating output file using preferred methods. You can think of it as single output file. What SXA/Sitecore does in this case is simply treating it like regular jss/css
[CE] When you export your site with theme you export assets (css/jss), in your case the only one you have is pre-optimized-min.

optimized-min - these are auto-generated by SXA using content of your theme (css/jss), on the same level where assets live. Read this article to find out when it will be used depending on AO options and pre-optimized-min presence.
[CE] When you export your site with theme you export assets (css/jss)
but optimized-min is skipped
Comment: Thank you for explaining it correctly, Alan!
Answer: Have you tried disabling the optimization for the site?

In the Content Editor, navigate to sitecore/content/<Tenant>/<Site>/Presentation/Page Designs.
In the Asset Optimization section, in the Styles Optimizing Enabled and Scripts Optimizing Enabled fields, to override styles and scripts optimization settings, select No – to always disable optimization for this site

Here's a link in Sitecore docs
Comment: I have already tried this but could'nt get the original files

Exporting a theme in a non-minified way


How do I hard wire a T8 fluorescent light fixture with grounded plug to a motion sensor?

Question: I purchased a T8 fluorescent fixture with electronic ballast, which came with a wired three-prong plug.  I also, purchased a infrared motion sensor.  I want to hardwire the fixture into the motion sensor but as you can see from the diagram, the sensor instruction shows only one wire going to the light fixture.  How do I hard wire/splice the two together?  I don't mind either removing the plug on the fixture, or using a female plug extension wire connected to the male fixture plug.
Answer: Your light fixture has hot, neutral, and ground.
The diagram actually shows the switched hot and neutral connecting to the light - ground is or should be obvious, it's not shown probably to reduce clutter.
As shown on the diagram, you connect the neutral from the wires supplying the location of the sensor to the fixture wire. It does not connect to the sensor at all. As not shown, you do the same thing with the ground. As shown, you connect the switched hot to the fixture.
Comment: Just so that it's clear, the ground coming out of the light fixture AND the ground from the sensor (green) will both  be connected to the ground line supplying the sensor location?
Comment: @Ron Yes, that is correct.
Answer: Your sensor / switch device is designed to be mounted into an electrical box with permanent wiring.
Your light fixture with its attached cord (with three prong plug) is meant to be connected into an outlet that is itself mounted in an electrical box with permanent wiring. The lamp itself, when configured this way could be considered a temporary connection to the electrical system.
So you have two options to consider in order to wire up this setup. The first one involves installing the necessary electrical boxes and permanent house wiring such that the switch/sensor assembly is controlling the On/Off of an outlet near the lamp mounting location. Then plug the three prong cord from the lamp into the switched outlet.
The second approach involves converting the lamp to a permanent wired installation. (Note that not all lamp fixtures are suitable for this but many are). Like before install two electrical boxes for the switch/sensor and one at the site where the light will mount. Connect the boxes with permanent type wiring with the switched end of the wiring terminating at the electrical box at the lamp fixture location. The lamp fixture is modified to remove the three pronged cord assembly and replace that with pigtail wiring that attaches to the switched wires in the electrical box. Normally in this type installation the lamp fixture then mounts over the electrical box becoming its cover. It is also possible in some instances to pass the switched wires through a wire clamp at the fixture interface with the box electrical box such that the wire joining to the fixture wiring occurs inside the fixture itself. Once again suitable for some fixtures but maybe not all.
Which ever approach you use try to avoid installing by other means where you tap temporary wiring into the permanent wiring supply and then kludge together the switch and fixture wiring with it dangling around in an unsafe manner.
Comment: So, for your first option (installing an outlet), is this the correct sequence? 1. Red output coming out of sensor to the black/hot of the outlet.  2. White/neutral coming out of the outlet to the neutral of the supply line.  3. Ground coming out of the outlet together with ground (green) coming out of the sensor to the ground of the supply line.
Comment: @Ron - Sounds correct.
Comment: Incidentally, the sensor instruction says **"To avoid overheating and possible damage to other equipment, do not use to control receptacles."**  I'm not sure why it says that but, since I'm only going to plug the light fixture into the receptacle outlet, is this a concern?
Comment: It is a specific concern for anyone that would plug in a load into that outlet that exceeded the amperage switching capacity of the switch/sensor unit. One way to avoid problems is to mount the outlet in the ceiling near the fixture and label it "For Lamp Fixture Only". However this is no guarantee that someone in the future would do something unexpected.


Get a pop up text note when opening a tab file

Question: I know this is possible as I have done it before but I need a text note (pop up) to open when a tab file is opened. I know it's a simple one-line in the .tab file but just can't recall what the line is and can't find any info on it.
Answer: Here is one that I use. You can reduce that to two lines.
(One 'set' line. One 'print' line).
  Set Window Message
      Font ("Franklin Gothic Medium Cond", 0, 8, 0, 65280 )
      Position (20, 10)
      Width 50.0
      Height 2.0

  print chr$(12)
  print "  This is where you put the pop-up message"
  print " "

Comment: I just tried this, it should be noted that the above code should go before the table definition.
Answer: Whereas @rossnixon's answer produces message in the message box, maybe the most direct way of popping up a message is to use Note keyword in a TAB file just before the Definition Table. For example Note("Hello,"+Chr$(10)+"This is a popup...") will yield a pop-up with the indicated message.
Answer: With the new 64 bit versions of MapInfo Pro, we have added a number of new events.
One of these is the TableOpened event.
If you create a MapBasic application and sign up for this event, you can show a note, a print message or even use the new Notification window to show a message for any table opened.
Of course it does require that your tool is running.