How does light get energy when moving from one medium to another?

Question: It is said that the speed of  light increases when moving from optically denser medium to rarer medium but
as light can be considered as a particle how does it get the energy to increase it velocity
Comment: Good question, +1. But it is better to say a photon is something like a particle and something like a wave. See this. [How can a red light photon be different from a blue light photon?](https://physics.stackexchange.com/q/540485/37364)
Comment: The energy of the photon doesn't change. It's a great question when considering individual photons  It's possible they don't slow down at all and instead weave back-and-forth between the atoms as they propagate through the medium. This causes them to take a longer path.
Answer: Light can be considered a particle, known as a photon, but the energy of each photon is not related to its velocity. Instead, it is given by the Planck formula,
$$
E=h\nu,
$$
where $h$ is Planck's constant and $\nu$ is the frequency of the light. Since the frequency of the light remains constant as it travels from one medium to another, the energy of those photons is also unchanged.
Answer: I would just add to Emilio Pisanty's comment by saying that the frequency remaining a constant as light travels across a boundary separating two media is required because it is required that the tangential component of E be continuous across the boundary.
In turn, that the tangential component of E must be continuous across the boundary separating two media can be found by computing the line integral along any path through the two media and using Stoke's theorem.
Comment: I believe when the OP asks about the energy they are specifically referring to the speed of the photon not the frequency. In other words how does it accelerate as it leaves the medium?
Comment: Good point @BillAlsept!


How can I make everything below an object (arrangement wise) transparent?

Question: For instance, I have a line with a stroke colored navy blue over a shape. How can I make the area covered by the navy blue line transparent, including that area on the shape below?
Comment: @OrionGL This question decisively requires a screenshot and some explanation about the efforts done.
Answer: Let me see if I understood your question right (using Illustrator CS 6):

We start with this shape:

Select the dotted line and from the main menu select Object/Expand Appearance
Select the dotted line again and select Object/Expand

Step 2 and 3 will make each dot of the line to become separate objects.

Select both the dotted line and the background and from the Pathfinder panel, chose Minus Front

This will be the result
Comment: It doesn't matter if the line is dotted, has a stroke etc. It is what you select from the line that will be subtracted from the background in step 4.


"Do not buy hardware wallet from a 3rd party seller" security tip, does it apply if authorized in the official website?

Question: "Do not buy hardware wallet from a 3rd party seller" It's a well-known security guideline for newbies. I wonder though, does it apply for 3rd party sellers that are listed on the official website of the product? E.g. Ledger reseller? If not safe, and you still decide to buy from there, how can you ensure the device hasn't been tampered with?
Comment: https://support.ledger.com/hc/en-us/articles/4404389367057-Is-my-Ledger-device-genuine-
Answer: For Ledger, you SHOULD be ok buying from an authorized reseller, although it is usually recommended to buy from Ledger itself directly.
Ledger Live will tell you if it is a genuine device or not.  Also make sure you generating a new key when you first use your device.


What is the highest-level Shimano MTB series where the crankset arms aren't hollow/bonded?

Question: I'm starting to be wary of the frequency of Shimano bonded crank arm failures and I want to stick to the highest series that still uses the solid, non-hollow crank arms.
Comment: Do note that most of the MTB cranks are hollow forged, not hollow bonded. Only XTR race variants use the bonded construction. On the road side, 105 is hollow forged, while Ultegra and DA are hollow bonded.
Comment: FC-R9200 left crank is now hollow forged, [source](https://weightweenies.starbike.com/forum/viewtopic.php?t=165109&start=75#p1721138).
Comment: @Klaster_1 Interesting, did not know that!
Answer: I agree with MaplePanda that only the highest level of Shimano cranksets feature the weight reducing process of hollow bonding.  This would be XTR on the mountain side and Ultegra and DuraAce on the road side.  These use "Hollowglide" technology which refers to a hollow large chainring, but also appears to encompass the spider of these forged cranks.  See a link for this tech in the comments. While it's possible other groupsets are affected, the bonded crank arm failure was predominately in the Ultegra road cranks.  This is what you'll find online when videos or discussion of the issue is the subject (almost always an Ultegra crankset).
In looking at the MTB crankset section of Shimano's Specification sheet, one can see that Hollowtech2 technology encompasses mountain cranksets up to FC-M6100, a Deore level 12 speed, where apparently a different manufacturing process is utilized as it does not specify the M6100 as Hollowtech2.  It is still a 2 piece crankset utilizing outboard bearings.  For a more traditional crankset that utilizes a cartridge bearing BB, one has to go down to FC-MT101, a Tourney level, square taper spindle crankset.
The link above shows specifications for only the latest 2 or 3 generations of components.  Should one want a higher level crankset that uses a cartridge BB like Octalink, one needs to look back to older 10 speed groups.  I also believe that some Alivo level cranks (FC-M4000) are offered in both 2 piece (outboard bearing) and 3 piece (cartridge bearing) models.
Dipping a bit into the opinion aspect, Shimano maintains a very high quality option for components. I don't feel you should be swayed from one of their Hollow forged cranksets based on some failures largely confined to one road group.  The abundance of opinion and much of what are considered facts point to a high regard for their products including cranksets.  One fact that's ess is XTR level components are backed by a 3 year warranty.  XT level on down get 2 years warranty AND that is transferrable if the sales reciept follows along to the new owner.
Edit: There are several anecdotal reports of high end Shimano cranks failing in very similar fashion. The crank arms made of aluminum are forged in at least 2 parts and these parts are then bonded with some sort of glue or epoxy that cements the pieces together making a whole, hollow, lightweight crankarm. Cross sectioning a crankarm reveals the two pieces that come together are each "U" shaped--the outer aspect is the larger "u" and fits over the inner and smaller "u". They are bonded together to make the whole.  With the cranks that have failed, it appears as though this bonding has failed, leading to a separation of the two bonded sides of the crank leading to complete failure.  BikeRadar has published an excellent discussion of a failure of one of these crankarms.
Note that lower tier Shimano cranks are also similarly manufactured with the end result of a hollow crankarm.  The difference here is that welding is used as the joining process as opposed to chemical bonding with glue or epoxy.
This article from Wired magazine discusses product failure, warranties, and explicitly states how averse any company is to revealing statistics related to product failures, warranty claims and the fiscal set-aside for claims and replacements.
Comment: I may be wrong, but I do believe Hollowtech 2 refers to the axle type. Hollowtech 1 was quite similar to Octalink. "Hollowtech crank arm" is the specification we are concerned about here, but interestingly, none of the cranks seem to have that box ticked off. M6100 uses solid arms, yeah.
Comment: @MaplePanda Hollowtech refers to the light weight, yet stiff hollow forged crank arms.  [See Hollowtech technology](https://bike.shimano.com/en-EU/technologies/component/details/hollowtech.html) from Shimano.  Hollowtech2 does in many ways refer more to the drive side crank attached, 24mm spindle with it's outboard bearing system. It does also encompass the lightweight, hollow forged crank arms. See Hollowtech2 link in other comment.  Agree it's more referring to the attached spindle making a "2" piece crankset
Comment: [Hollowtech2 marketing from Shimano](https://bike.shimano.com/en-EU/technologies/component/details/hollowtech-2.html#:~:text=The%20concept%20of%20HOLLOWTECH%20II,maximize%20a%20rider's%20power%20transfer.&text=HOLLOWTECH%20technology%20is%20an%20ultra,technology%20that%20also%20maintains%20rigidity.)
Comment: That is strange how none have the Hollowtech crankarm box checked. Not until the FC-MX71 where it is. I think this is a BMX crank.
Comment: Perhaps [Hollowglide technology](https://bike.shimano.com/en-EU/technologies/component/details/hollowglide.html) is what the OP hopes to avoid. Still only used on Dura-Ace, Ultegra and XTR.
Answer: Shimano 105 cranksets are welded, not bonded.  So they're stronger but heavier.  Ultegra and Duraace are bonded in modern groupsets.   I can't speak to MTB or Gravel groupsets.
He's contentious, but here's Hambini suggesting that one solution is to get Shimano 105 or a Rotor crankset.   The rest of that video shows his dissection of a failed duraace crankset.  Mind the volume in the first 10 seconds.
Comment: Hambini is an interesting character.  I like that he provides perspective from, call it, an "engineering purist" perspective.  Manufacturing processes that result in variable measurements that swing outside of tolerances are especially maddening to him.  As are design tolerances engineered into a system where it's impossible to manufacture the part while preserving tolerances especially after use. So called, "designed by a 5 year old!"


How to create an UI or a widget that sits on top of all applications in Android?

Question: Can I create an UI or a widget in Android that will sit on top of all applications? There are applications that have widgets like this. One example has a camera icon on top of all the applications that, when clicked, will capture the screen.
Answer: If you want to just display something, you can display it on top of everything even the lockscreen.
If you want something to be clickable, you can display it on top of anything except the lockscreen.
Here's a sample, modify to your needs:
Create a service and do the following:
<code>//These three are our main components.
WindowManager wm;
LinearLayout ll;
WindowManager.LayoutParams ll_lp;

//Just a sample layout parameters.
ll_lp = new WindowManager.LayoutParams();
ll_lp.format = PixelFormat.TRANSLUCENT;
ll_lp.height = WindowManager.LayoutParams.FILL_PARENT;
ll_lp.width = WindowManager.LayoutParams.FILL_PARENT;
ll_lp.gravity = Gravity.CLIP_HORIZONTAL | Gravity.TOP;

//This one is necessary.
ll_lp.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;

//Play around with these two.
ll_lp.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
ll_lp.flags = ll_lp.flags | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;

//This is our main layout.
ll = new LinearLayout(this);
ll.setBackgroundColor(android.graphics.Color.argb(0, 0, 0, 0));
ll.setHapticFeedbackEnabled(true);

//And finally we add what we created to the screen.
wm.addView(ll, ll_lp);
</code>
Comment: Thanks. It worked with android.permission.SYSTEM_ALERT_WINDOW
Comment: Hatcyl, can you please provide me with the entire code if you don't mind so that I will be able to understand the entire flow as well.
Comment: @hatcyl, have you tried the notifierpro app? It shows on top of lock screen as well. And it's clickable. What could that be?
Comment: @hatcyl hey i run this code but got null pointer exception on wm object of window manager. can you tell me why it gives that..? i tried many other things but couldn't get it done.. :(
Answer: The following are more options for how the view is displayed.
This will make it an overlay on top of everything (including lock screen), but not clickable.
    WindowManager.LayoutParams. TYPE_SYSTEM_OVERLAY
This will make it clickable, but it won't be over the lock screen
    WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
This will make it above everything (including lock screen) AND clickable.
    WindowManager.LayoutParams.TYPE_SYSTEM_ERROR
One thing to note about using "TYPE_SYSTEM_ERROR". If you wire-in a click event, anything it invokes will happen behind the lock screen.


JS How can I increase the performance of this Max/Min coding challenge?

Question: I'm trying to solve some 'hackerrank.com' coding challenges.
I'm stuck on this one:
You will be given an array of integers arr and a single integer k. You must create an array arr' of length k from elements of arr such that its unfairness is minimized.
Unfairness is defined as max(arr') - min(arr')
The function should return the minimum possible unfairness
My code works fine for the majority of test cases. However, in three of those test cases - the ones where the size of arr and k is particularly huge - fail due to an excession of the given time limit.
How can I optimize the performance of my code?
Thanks in advance
function maxMin(k, arr) {
    // create array to push unfairness values to
    var unfairnesses = [];
    // sort given array in ascending order
    arr.sort(function(a, b) {
        return a - b;
    });
    // loop over sorted array
    for(var i = 0; i < arr.length - k + 1; i++) {
        // get array with the length of k at position i
        var tempArr = arr.slice(i, i + k);
        // determine Max and Min of the sliced array
        var tempArrMax = Math.max(...tempArr);
        var tempArrMin = Math.min(...tempArr);
        // get unfairness of the sliced array
        var thisUnfairness = tempArrMax - tempArrMin;
        // push sliced-array-unfairness to unfairnesses array
        unfairnesses.push(thisUnfairness);
    }

    // return minimal value of unfairnesses array
    return Math.min(...unfairnesses);
}

Answer: The two first steps could be:

Your array is sorted. Thus there's no need to use Math.max and Math.min - the first element of a slice is the smallest, the last is the largest.
When you eliminate Math.max and Math.min calls, you can remove Array.prototype.slice call. Then you're left with a sort and a single pass over the array.
Answer: To sort the array you're already looping one time over the whole thing.
Then you're looping another time to figure out which one is max and which one is the minimum.
You're looping twice as you can only loop once if you do:
function minMax(array) {
  const safeArray = array ?? []
  // No max or min as array is empty
  if(safeArray.length === 0)
    return [undefined, undefined]

  let max: number = Number.MIN_SAFE_INTEGER
  let min: number = Number.MAX_SAFE_INTEGER
  for(let item of safeArray) {
     max = Math.max(item, max)
     min = Math.min(item, min)
  }
  return [max, min]
}


BKF Conversion to vmware compatable filetype

Question: trying to restore (DR test) exch and dc in one box to vmware environment
unable to use vmware converter, only have NT backup files of server (said box has exch & dc on it windows 2k3 environemnt) any ideas or tools to use etc ?
Answer: BKF isn't a disk image format, but is more like a "ZIP" or other "archive" file (TAR, CPIO, etc). Your best bet is going to be to use NTBackup to restore the backups.
If you still have the original hardware the backups were taken on I'd recommend restoring the backup on the original hardware then performing the physical-to-virtual conversion.
If you don't have the original hardware you might try performing a disaster recovery restore inside a VM you build up for that purpose. With the changes in hardware between the backup and the VM (and no P2V software to "massage" those changes away) you're likely going to have problems.


Can I describe the fact with "You broke my computer" when my son made my computer not working while it wasn't physically damaged?

Question: I am not sure about the usage of the word break. Do English native speakers use it to describe if something stops working?
Comment: Without laying blame, simply saying "it is broken" will work.
Answer: Yes, break can refer to both physical damage and something that no longer works.

I broke my phone screen. Look at the crack!

and

You broke my computer! It still looks okay, but it no longer turns on.

are both proper sentences.
Comment: @WS2 "I would definitely not use it in that way. There are plenty of more appropriate words you could use." You're overthinking this. "Broke" in this context is idiomatic and common usage among native English speakers.
Comment: I would definitely not use it in that way. There are plenty of more appropriate words you could use. In the case of computers there is always the question of whether a malfunction is due to a hardware or software fault. If I knew it was a software matter I would definitely not use "broke". But nor would I use it in the instance you describe. I think the most I'd say is "You appear to have damaged my computer". But diagnosis is never straightforward and you might wish to say "Since you used it my computer no longer turns on".
Comment: @WS2 well ... there goes 'blowed up' too.
Comment: @AleksandrH  "It's broke innit" is certainly "native English". All I was saying was what I, also a native English speaker, would say.
Answer: If we are confident that the computer

no longer works

then I believe the term "broken" is applicable regardless of whether it is a software or a hardware issue. Assuming that it "still works" and that there is a software issue, then the computer is more on the end of being  damaged (as referenced by @WS2) or messed up (more colloquial).


Front derailleur not reaching the "L" screw!

Question: I was having this problem with my bike recently. While the FD can switch without an issue between the second and third (largest) ring, it can't get the chain to the first ring (smallest). I recalibrated the FD but the problem remains as it is. I noticed though that no matter how much I unscrewed the "L" screw, for the known reasons, the FD didn't reached the new limit but only when I gave it a slight push with my fingers. Is there anything I can do to make the FD reach the "L" limit screw? Btw the FD is an Shimano FD-TZ500.
Thanks!
Answer: Either the inboard travel of the derailleur cage is limited by the adjustment of the shifter cable rather than the limit screw, or there is something impeding the derailleur movement.
if the shift cable is tight and you can move the derailleur by adjusting the barrel adjuster then the derailleur is not up against the limit screw.
If the cable is loose, or you can manually push the derailleur up against the limit screw there is something impeding the derailleur movement. Excess friction or binding of the cable in the housing is a common cause of this.
You can pull the cable out of the housing, clean and lubricate with a small amount of chain lube, or just replace the cable and housing as they are not very expensive.
Comment: The cable is loose enough so that the FD can reach the L limit screw, but it seems that the FD can't push itself enough to reach it. I gonna inspect the FD to see if its moving parts are clean, if they aren't i'm gonna clean them etc, and ill post the result, thanks again!
Answer: It just needed reoiling, thanks for your time!
Comment: Great finding and thank you for coming back to share that.  Please mark this as the "Accepted" answer by clicking the green check/tick on the left side.


Custom input view does not work anymore in the iPhone iOS 6 simulator

Question: I have made an app, which has a custom input view, it works fine on the ios 4.3.3 and ios 5.1.1 as well as the new ios 6 if compiled using xcode 4.3 with the base SDK 4 but after updating xcode to the latest version and compiling using the ios 6 sdk the input view does not work anymore. if input button are taped the text doesn't show in the textField. Does anyone encounter this  problem or now its cause ?
Answer: Make sure that you are initializing your custom input view with a frame that has a width or height larger than zero.  From what I can tell, if this isn't the case then iOS 6 doesn't even add the view to the view hierarchy.
In my case, the width of my keyboard view's frame was zero when calling initWithFrame:(CGRect).  Everything worked fine in iOS 5, as the frame width would get set during layout, but in iOS 6 the keyboard wasn't even in the view hierarchy.
I used iOS Hierarchy Viewer to figure that last bit out with having to fiddle in the debugger too much.


Best way to capture key events in NSTextView?

Question: I'm slowly learning Objective-C and Cocoa, and the only way I see so far to capture key events in Text Views is to use delegation, but I'm having trouble finding useful documentation and examples on how to implement such a solution. Can anyone point me in the right direction or supply some first-hand help?
Answer: Generally, the way you implement it is simply to add the required function to your view's controller, and set its delegate. For example, if you want code to run when the view loads, you just delegate your view to the controller, and implement the awakeFromNib function.
So, to detect a key press in a text view, make sure your controller is the text view's delegate, and then implement this:
<code>- (void)keyUp:(NSEvent *)theEvent
</code>
Note that this is an inherited NSResponder method, not a NSTextView method.
Comment: keyUp isn't invoked if you put it in the delegate. You have to subclass the NSTextView and put it there.
Answer: Just a tip for syntax highlighting:
Don't highlight the whole text view at once - it's very slow. Also don't highlight the last edited text using -editedRange - it's very slow too if the user pastes a large body of text into the text view.
Instead you need to highlight the visible text which is done like this:
<code>NSRect visibleRect = [[[textView enclosingScrollView] contentView] documentVisibleRect];
NSRange visibleRange = [[textView layoutManager] glyphRangeForBoundingRect:visibleRect inTextContainer:[textView textContainer]];
</code>
Then you feed visibleRange to your highlighting code.
Answer: It's important to tell us what you're really trying to accomplish — the higher-level goal that you think capturing key events in an NSTextView will address.
For example, when someone asks me how to capture key events in an NSTextField what they really want to know is how to validate input in the field.  That's done by setting the field's formatter to an instance of NSFormatter (whether one of the formatters included in Cocoa or a custom one), not by processing keystrokes directly.
So given that example, what are you really trying to accomplish?
Answer: I've done some hard digging, and I did find an answer to my own question. I'll get at it below, but thanks to the two fellas who replied. I think that Stack Overflow is a fantastic site already--I hope more Mac developers find their way in once the beta is over--this could be a great resource for other developers looking to transition to the platform.
So, I did, as suggested by Danny, find my answer in delegation. What I didn't understand from Danny's post was that there are a set of delegate-enabled methods in the delegating object, and that the delegate must implement said events. And so for a TextView, I was able to find the method textDidChange, which accomplished what I wanted in an even better way than simply capturing key presses would have done. So if I implement this in my controller:
<code>- (void)textDidChange:(NSNotification *)aNotification;
</code>
I can respond to the text being edited. There are, of course, other methods available, and I'm excited to play with them, because I know I'll learn a whole lot as I do. Thanks again, guys.


Why can unsymmetrical tert-butyl ethers be prepared by dehydration of the constituent alcohols?

Question:
Practice problem 11.11 what stops R-O-R from forming at the same rate as the desired product?
Answer: In order to understand why this is OK, you have to understand the mechanism by which this occurs. It is essentially an $\mathrm{S_N1}$ reaction that is most favoured by the conditions (acidic + polar protic solvent).
So, for the formation of an ether $\ce{^tBu-O-R}$ where $\ce{R}$ is a primary alkyl group:

competing formation of $\ce{R-O-R}$ is slow because primary carbocations are very unstable, and
competing formation of $\ce{^tBu-O-^tBu}$ is slow because $\ce{^tBuOH}$ is a poor nucleophile (tertiary alcohols are very bulky).
Comment: @NotEvans, H2O+ is not a bad leaving group. Besides, if it was a bad leaving group, it would not only affect the SN2 rate but also affect the SN1 rate
Comment: @xasthor I think what you are saying is that *after protonation*, it is possible for $\ce{ROH2+}$ to react in an SN2. Yes, it is possible - but then there is no good nucleophile (alcohols are really quite poor). Compared to the SN1 reaction which has everything going for it (very polar solvent + tertiary cation), I don't think it's likely that this SN2 can be competitive in terms of rate. Maybe, at most, you get some side product. If you compare to generic ROH + R'OH, which simply produces a hopeless mixture... this is much better.
Comment: What stops an SN2 mechanism from operating to form  ROR?
Comment: @xasthor Water is a bad leaving group for an SN2 reaction – the *tert*-butyl cation is stable enough to promote loss of water (in an SN1 sense), then ROH can attack (tBuOH is a terrible nucleophile).. there really is only 1 favoured outcome in this reaction..
Comment: SN2 displacement of a primary alcohol (as in an SN2) without prior activation is not a favourable/well known reaction.  Look in any organic chemistry textbook (I suggest Clayden...)- it's well explained and it may help to clarify the basics for you :)
Comment: A key info here is the room T vs the 100+Celsius to form primary ethers. Ether formation is probably an SN2 reaction on a protonated alcohol. Slow addition of t-butyl alcohol to an acidified primary alcohol should give good yields and minimize side reactions. The t-butyl cation should be immediately attacked by the alcohol molecules solvating the protonated alcohol. It would be interesting to react optically active 3-methyl hexan-3-ol and compare to a Williamson synthesis.


Download an APK file on SD card

Question: I want to download an APK file to my SD card so I can take that SD card and put it in my Nook to get Google Play. I honestly don't know what I'm doing and I have an older model of the Nook Color. I only have my phone so I don't even know if this is possible.
Comment: apk files can be installed on any android devices. Filename ends with an extension `.apk`. You can install downloaded apk on phones, tablets etc. Is your nook android? If so, you can install apk files on it.
Answer: You need to use either Your smartphone or the card reader. Insert appropriate for Your nook (apparently it is a tablet according to what Google told me. Have never encountered it before) SD/memory card in the phone/card reader and connect it to Your PC/laptop.
After downloading the needed .apk file on Your computer, copy it into a folder of the SD/memory card (for example "E:\Downloads" or any other name it will be given by the system) and disconnect the card reader/phone from comp. via safe way (most probably nothing will happen if You will simply plug it out, but just in case).
Insert the memory card (if it was in your phone in the first place - take it out beforehand. Don't forget to switch off devices when inserting/unmounting memory cards) into your nook device and switch it on. Go for the file browser (aka File Manager and so on), find the folder you have put .apk file before (Downloads folder for example) and open it via touching it's name. The system will suggest to install .apk file and demand for Your approval of the action.
That should be it, pardon if too much text/too detailed explanation.
Answer: Downloading APK's(Android Package Kits) to an SD Card is trivial. It depends on the browser or the method.
These methods would include:
Browsers

Chromium Based
Mozzila Based

Download Managers

Internet Download Manager

Torrent Download Clients

BitTorrent
QTorrent

Dedicated App Store

Aurora Droid
F-Droid
Aptoide

On Android 5 and above you need to allow Storage access permissions from your devices settings. You can check out this article from Android Central that elaborates more on this topic.
Android 5.0 Lollipop changes the way your SD card works — and that's a good thing
After allowing access to SD Card you can change the default download location per app to select the SD Card to download apps.
For Chromium based Browsers such as Vivaldi, Edge, Brave, Opera, Chrome, and De-Googled Chromium you can change the default download storage/location from the App settings.
This method applies for most things. And most of the time all you have to do is check the apps support page to figure out to change those settings.

Download an APK file on SD card


Multiple meditation practices

Question: Would there be a conflict if I were to practice meditation from various schools? For instance mahasi insight meditation, Tibetan Samantha meditation, as long as the skills are kept separate?
Answer: Probably fine at the exploratory stage. But once you've found the method most suitable to your own development and growth, then it'd be best to dive deep into just that single method. Sorta like pursuing a college degree or graduate degrees, one would take some general courses in his freshman and sophomore years, but then would have to focus on courses specific to their major in junior and senior years.
Answer: In the immortals words of Ron Swanson - "Don't half ass two things; whole ass one thing".  Why scatter your attention and your efforts?  Pick one and follow it wholeheartedly.  Being able to make that commitment alone will be more beneficial than any advantage pursuing multiple paths might bring.
Answer: While both of the techniques mentioned will ultimately bring limited results if 'mastered', there is no conflict or detriment for a newbie to practice both.

Multiple meditation practices


Reclaiming unallocated space from tempdb database in SQL Server Express 2012

Question: I need to reclaim space from tempdb database which has more than 50 GB unallocated space. I have tried DBCC SHRINKDATABASE but it didn't do anything. Please note, I am aware that it has performance implications but I have no choice. I run SQL Server Express on a laptop and really need this 50 GB space. Also I have tried restarting SQL Server/laptop and have ensured that no process is running right now.
Comment: Which SQL Server Express version is in your environment?
Comment: It is SQL Server 2012 - Version 11.0.2100.60
Answer: I have done it using

DBCC SHRINKFILE ('tempdev',10)

Somehow DBCC SHRINKDATABASE was not working. Even DBCC SHRINKFILE ('tempdev',0) or DBCC SHRINKFILE ('tempdev') doesn't work. We have to assign some figure in MB to which it will shrink the database to.
Comment: From this TSQL code DBCC SHRINKFILE ('tempdev',10). What you are going to shrink (data file or log file).
Comment: The data file was the culprit. Log file was small.
Answer: First of all you know the SQL Server Express database limitation.As you said tempdb which has 50 GB.  As per MSDN BOL Here SQL Sever Express supports Maximum database size is 10 GB. And also you can find more SQL Server 2012 limitation details Here.
Note: Before executing the DBCC SHRINKDATABASE or DBCC SHRINKFILE . You must know their nature of execution.

To shrink all data and log files for a specific database, execute the
  DBCC SHRINKDATABASE command. To shrink one data or log file at a time
  for a specific database, execute the DBCC SHRINKFILE command.

DBCC SHRINKDATABASE
Shrinks the size of the data and log files in the specified database
Shrinking a database and specifying a percentage of free space
The following example decreases the size of the data and log files in the UserDB user database to allow for 10 percent free space in the database
DBCC SHRINKDATABASE (UserDB, 10);
GO

Truncating a database
The following example shrinks the data and log files in the AdventureWorks sample database to the last allocated extent.
DBCC SHRINKDATABASE (AdventureWorks2012, TRUNCATEONLY);

DBCC SHRINKFILE
Shrinking a data file to a specified target size
The following example shrinks the size of a data file named DataFile1 in the UserDB user database to 7 MB.
USE UserDB;
GO
DBCC SHRINKFILE (DataFile1, 7);
GO

Shrinking a log file to a specified target size
The following example shrinks the log file in the AdventureWorks database to 1 MB. To allow the DBCC SHRINKFILE command to shrink the file, the file is first truncated by setting the database recovery model to SIMPLE.
USE AdventureWorks2012;
GO
-- Truncate the log by changing the database recovery model to SIMPLE.
ALTER DATABASE AdventureWorks2012
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (AdventureWorks2012_Log, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE AdventureWorks2012
SET RECOVERY FULL;
GO

Truncating a data file
The following example truncates the primary data file in the AdventureWorks database. The sys.database_files catalog view is queried to obtain the file_id of the data file.
USE AdventureWorks2012;
GO
SELECT file_id, name
FROM sys.database_files;
GO
DBCC SHRINKFILE (1, TRUNCATEONLY);

Note: You can reduce the default size of an empty file by using DBCC SHRINKFILE target_size. For example, if you create a 5-MB file
  and then shrink the file to 3 MB while the file is still empty, the
  default file size is set to 3 MB. This applies only to empty files
  that have never contained data.

Before execute the DBCC SHRINKFILE , As Mike Walsh explained very well you must know Here that, is it really necessarily to run that command.
For further your ref Here
Comment: Thank You. Yes. Express has limitation of 10 GB per database. Yet Tempdb was at 50 GB. May be the the limit is only for user databases and not system databases.
Answer: If tempdb did not shrink even after instance restart, then probably initial size is too big.
Please try shrink using DBCC SHRINKFILE to get some space.
USE [tempdb]
GO
DBCC SHRINKFILE (N'tempdev' , 0, TRUNCATEONLY)
GO

Comment: Nopes, Initial size was 10 MB. It ballooned to 50 GB after I ran a bad query with incorrect join thus returning a lot more rows than I wanted.


Can a photon vibrate without any velocity or directional movement; Can it vibrate without moving?

Question: I understand that light travels in a straight line unless gravity says otherwise. However, if it were theoretically possible to keep the energy in a photon without having any directional movement, what would happen? Would the photon dissipate and just transfer its energy to a nearby particle?
Comment: Non-moving photons are not a mainstream physics concept, at least not in vacuum. They are an oxymoron — a contradiction in terms — like a square circle.
Comment: Are you satisfied with zero *average* velocity?
Answer:
Can a photon vibrate without any velocity or directional movement;
Can it vibrate without moving?

So you are essentially asking:
Can a photon have a non-zero frequency $\omega$
while having a zero wave-number $k$ ?
The answer is:
No, it can't, because for photons in vacuum
we have the following dispersion law
$$\omega = c k \tag{1}$$
where $c$ is the speed of light.
This linear dispersion law is equivalent to saying a photon has zero rest-mass.
This would be entirely different if the photon would have a non-zero rest mass $m$.
Then the dispersion law would be
$$\omega^2 =c^2k^2 + \left(\frac{mc^2}{\hbar}\right)^2 \tag{2}$$
where $\hbar$ is Planck's constant.
(You can find more about massive bosons (in contrast to massless bosons)
by searching for "Proca action" or "Proca equation").
From (2) we can see: For massive photons at rest (i.e. $k=0$) we would have
$$\omega_\text{rest}=\frac{mc^2}{\hbar}$$
A massive photon at rest would just sit there and keep its energy.
Answer: Empty space is the condition for the existence of photons. Even on an atomic scale, photons exchange energy between the subatomic particles of gases, liquids or solids, which always (by their very nature) have a distance between them.
The only thing that influences photons during their way through vacuum is gravity. The geodesic path of EM radiation is influenced by masses, it is bended towards it. The bending is the same for EM radiation of any wavelength. Means, the speed of light in a given point of space is a constant value.
Last but not least the gravitational potential influences the speed of light. At higher potential (near masses) the speed of light slows down - seen from a third point -. If the light in the vicinity of a black hole were observed from Earth, the speed of light would be measured with a lower value than on Earth.
Long narrative, briefly summarized. Light needs empty space to come into existence. And light then moves at a specific speed. Standing light in a vacuum is not provided by nature.


How can I display the total number of favorites for any particular buddypress activity stream post?

Question: I like to show the total number of favorites for each individual activity post next to the favorite button just like it shows the number of comments right next to the comment button. Is this possible to implement?
Answer: Unfortunately, it's not really feasible, based on the current implementation of activity favorites in BuddyPress. BP stores this data in a piece of usermeta called 'bp_favorite_activities', which is an array of activity ids. That makes it easy and fast to pull up a list of a given member's favorite activity items; but it makes it almost impossible to pull up a list of the members who have favorited a given activity item, since the data is stored in serialized arrays and can't be reliably or quickly queried properly.
If this is something that your site really needs, you might consider writing a small plugin that does the following:

creates a custom database table linking activity items and individuals
hooks to the bp_activity_add_user_favorite and bp_activity_remove_user_favorite and writes to/deletes from your custom table with the relevant info.

I bet this would be a very popular plugin if you wrote it up and made it publicly available.
If you wrote something really nifty, you might also consider submitting it as a BuddyPress patch.


How to runalltest in package.xml and deploy to org?

Question: I have package.xml file which contains apex classes, test classess , triggers. So, I need to  runalltest in the org only run test class which is contained in my manifest file and deploy to org is there any way to do that?
How can we use ant script to build to runalltest in org?
Answer: No, there is no Metadata API deployment option for "run all tests being deployed". The test run levels available to you are documented (among other places) in the Metadata API documentation.
Your choices are:

NoTestRun (which is not applicable when deploying Apex to production).
RunSpecifiedTests, where you may list a specific group of tests (but you must list them explicitly; you cannot derive the list from package.xml).
RunLocalTests, which is both the default and the best option, runs all tests other than packages tests in your org.
RunAllTestsInOrg, which runs all tests including packaged tests.

It's not a good idea to run only the tests in your deployment, as your code changes may impact the behavior of other code in the target org. Running local tests is usually the right choice.
Comment: can we use ant script to do this?
Comment: I imagine you can, if you're willing to write some Java. I'm not aware of any built-in feature that does this, but I'm not an Ant expert. That build chain is really obsolete at this point.


Brute-Forcing a Chrome Login Data file

Question: Say I have a "Login Data" Chrome file that is encrypted with the user's Windows password. Is there a way I can brute-force the file and try to decrypt it using every password possible?
Comment: Relevant: https://security.stackexchange.com/questions/44493/vulnerability-of-chromes-login-data-file-after-being-orphaned-from-the-host-s
Comment: What do you mean by *'encrypted with the user's Windows password'*? Chrome does not encrypt passwords with the user's Windows password.
Comment: @nobody I read that Chrome uses the Data Protection API (DPAPI) and the "Login Data" file can only be decrypted by the same Windows user that encrypted it because it uses the Windows password, correct me if I'm wrong. But is there any way I can decrypt this file?
Comment: @Safwan Thanks for the clarification. That information is a bit outdated. See my answer below
Answer: Since chrome v80, chrome encrypts cookies and passwords using AES256-GCM with a randomly generated key. The key used for encryption is then encrypted with DPAPI and stored in the 'Local State' file in the user's chrome profile. However, the DPAPI is used in Local_Machine scope which means that any user on the computer where the encryption was done can decrypt the data (i.e. encryption does not rely on user's password at all). I am not sure exactly how the master key for encryption on Local_Machine is derived, but if I remember correctly, it uses environment specific variables.
What this means is that if you only have the "Login Data" file available, you will have to brute-force the 256 bit AES key, which is currently practically impossible. Even if you can get your hands on the user's "Local State" file you will still not be able to decrypt the key unless you can figure out and obtain all the environment specific variables DPAPI relies on. Your best bet would be to gain physical access to the system while any user is logged on and then decrypt the passwords using something like ChromePass
Comment: I don't have physical access to the machine, all I have is the "Login Data" file which is Impossible to crack according to what you've just said. Thanks for your time.

Brute-Forcing a Chrome Login Data file


What is the Html5 API which retrieves image metadata such as file size, format (jpeg, png ..) from image file?

Question: I want to retrieve metadata (width, hight, format ..) from image file (jpeg, png, bmp etc.) in the Html5.
I can use Canvas Api to deal width image.
However, I cannot find Api to retrieve metadata from a file.
Does anyone can know me?
Answer: It looks like this little lib might do the trick for you.


What are these chords?

Question: I'm studying Andantino no. 15: in 'Studi per Chitarra' by Ferdinando Carulli

but I can't figure out what the chords are under the ones, the two and the four. I think 1 could be ii diminished but I was taught ii diminished -> i was a bad chord progression. As for two and four I have no idea.
Answer: The chord at the 1 is an ordinary ii°6 chord. It resolves into a i6/4-v chord progression the first time and a i6/4-V chord progression the second time. It's possible that the v chord is passing and itself a temporary fake-out, as i6/4 normally resolves with very high probability to a dominant-function chord such as V...
...and the chord at the 2, which the v chord resolves to, is a vii°4/3 chord. This is a dominant-function chord, and it resolves to a i6 chord.
The measure at 4 involves a long elaboration on the dominant function. The A is an accented non-chord tone (specifically, an appoggiatura), while the rest of the notes can be explained as I6/4-V7 in C major.

What are these chords?


What are some open souce VoIP software options for LInux that can record?

Question: I am running Ubuntu 21.10 on a Thinkpad X1 Tablet. I pay for a VoIP phone and usually use it via a Grandstream HT502 ATA. But sometimes I would like to use my computer to make the VoIP call. I installed Empathy but am having a lot of trouble using it. I am wondering what other open source VoIP software is available and what do people recommend? I hope to record phone interviews with family members about family history so I would like to be able to record.
Answer: The linphone project meets all these requirements.  Unfortunately the linphone installed from the Ubuntu 21.10 repositories does not have record working, but linphone can be compiled from source.  In addition to the instructions given in the linphone source repository, I had to run
<code>sudo apt install libglew-dev libqt5webview5-dev '^qt.*5-dev$'
</code>


Keep alcohol in spiced rum reduction?

Question: I'm working on a new recipe and want to make a spiced rum reduction without losing the alcohol. Don't just want it thicker or I'd use xanthum gum I want less liquid with stronger flavor and the alcohol content to still be as high as possible. Thought about reducing it in a covered pot at extremely low temp to condensate the alcohol back into it but not sure how it would work out because the water would condensate back into it as well. Any thoughts I'm racking my brain here lol.
Comment: What is *a spiced rum reduction*? Did you add rum into something? Then  use [Stroh rum](https://en.wikipedia.org/wiki/Stroh) to start with a high alcohol content.
Comment: Related: https://cooking.stackexchange.com/questions/37057/can-liqueurs-be-reduced
Comment: Not really what I'm looking for im trying to do something quite different I want it reduced but to keep the majority of the alcohol in it so that when I froth it for my plate it has the full flavor of the rum and spices with almost the full bite of the alcohol
Comment: Its a simple reduction you heat it to reduce the amount of it that you have and bring out more of the base flavors, I'll check out Stroh to see if its what I'm looking for. Thanks for the info.
Answer: You can do something based on freeze-concentrating:

Partially freeze it until ice crystals form
Strain the ice off.

The liquid will contain much of the alcohol and alcohol-soluble flavour compounds, along with some water.
The ice will be mainly water with water-soluble flavour compounds and sugars.  There will be alcohol in it, which will be lost.
Up to now this is just freeze distillation (more properly called fractional freezing).

Melt the ice and reduce it as much as possible.
Recombine with the alcoholic liquid.

I've tested some of the process, with some success.
In the following, all temperatures were measured with a very cheap IR (infrared) thermometer; they're probably fairly consistent on the same materials, but not very accurate (as these thermometers make assumptions about the emissivity of the sample.
I froze a small plastic container of about 50ml of rum: 40% ABV, "Negrita" brand (French), that's been on my shelf for years.  With the freezer turned up to maximum and left closed overnight, the coils, on which the rum was sitting, were down to -36°C.  The rum was frozen into slush rather than  solid.  This is more than cold enough to freeze 40% ABV according to this table of freezing points. Starting from anything but the weakest rum you'll need quite a cold freezer or to be in contact with the coils.  The rum was warming rather fast after I got it out of the freezer, so I didn't get a temperature measurement before straining it. I put it in a tea strainer to drip and collected about the first half (estimated, nearer 2/3 in the end) in one glass (sample 1), before letting the rest melt in another glass (sample 2).  Sample 1 was darker in colour and smelt more strongly of rum.
Then I tried to test the flash point.  Both samples, and a sample taken directly from the bottle (sample 3), were warmed in a water bath, before I tried to ignite some on a teaspoon (which had also been warmed in the same bath and dried).  Below 24°C nothing much happened.  At 24°C a flame followed my lighter flame around the teaspoon without ever really catching, on sample 1 only.  At 28°C I saw the same behaviour, also on sample 3.
At 36°C (I wanted an intermediate temperature but added too much hot to my water bath). Sample 1 ignited, as did sample 3.  Sample 2 displayed the flame-following behaviour that the other samples did at lower temperatures.  This doesn't match the flash points listed at my second link, which I blame on the IR thermometer not being ideal for measuring the temperature of a little rum in a glass (but I didn't have enough for a dipping thermometer); also flash points are notorious for being hard to measure. On further reading I was closer than I thought -- the flame-following behaviour approximated the flash point, but of course the lighter warmed the surface.
By this point I was running out of samples so had to stop (when definitely not ignited I could return them to the glasses, but once ignited I didn't risk it).
But clearly sample 1 was a little more alcoholic than the original, while sample 2 was less alcoholic.
However it was disappointing that I didn't get nice big ice crystals that I could easily strain off.  I also didn't have enough to try a reduction.
Note that commercial spiced rum often starts weaker (35%ABV) than I had, so you may get better freezing.
I no longer think it's worth repeating the process as the freeze isn't very good. Beyond the point I reached you'd probably need to reduce the lot and add a high-strength spirit (such as overproof rum) to get the concentration back up to what you want.
Measuring the alcohol content by flash point is tricky. Larger quantities would help as you could use a dipping thermometer (a medical thermometer might be good around this range). Measuring by density would be affected by dissolved sugar (assumed). This is done in homebrewing, but ABV (alcohol by volume) is generally calculated the change from the input density, which is dominated by sugar. The very driest wines have a density slightly but measurably less than that of water.
Comment: *In this case* I don't believe you have to worry about freeze-distillation concentrating methanol, because you're starting with a spirit that's already been distilled.
Comment: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/68563/discussion-between-rumtscho-and-chris-h).
Answer: You can't reduce a sauce with alcohol in it without losing alcohol due to evaporation. Alcohol is more volatile than water, meaning it evaporates more easily, do when reducing you will lose more alcohol than water, it's unavoidable due to the properties of alcohol. If you want to reduce the sauce and still have it be boozy then you either need to start with a high alcohol content or refresh the alcohol content later. Either way you will need to purchase a very high percentage alcohol to add. I'd suggest doing this separately from your spiced rum so you can concentrate on getting a rum with a good flavor and bumping up the alcohol independently, most high strength rums aren't very palatable.
Comment: I think you're right (in the absence of a still at least -- building one would be fun but illegal in many places) but I have a cunning plan.

Keep alcohol in spiced rum reduction?


Does product sigma algebra of n B(R) (Borel) coincide with B(R^n)?

Question: My question comes from different modes of probability law, which I met. I see two options in equality: set belonged to $B(\mathbb R^n)$ and Cartesian product of B belonged to $B(\mathbb R)$.
Answer: First note that product sigma-algebra is not a product of sigma-algebras. The last object is not a sigma-algebra at all. Look, for instance, two sets $B_1=(0,1)\times(0,1)$ and $B_2=(1,3)\times(1,3)$. Every set belongs to $\mathfrak B(\mathbb R)\times \mathfrak B(\mathbb R)$ and the union $B_1\cup B_2$ does not since it is not a rectangle.
Product sigma-algebra is defined as the sigma-algebra generated by all sets $$B_1\times\ldots\times B_n\in\mathfrak B(\mathbb R)\times\ldots\times \mathfrak B(\mathbb R)$$ It is denoted by
$$
\mathfrak B(\mathbb R)\otimes\ldots\otimes \mathfrak B(\mathbb R)
$$
It coincides with $\mathfrak B(\mathbb R^n)$.
Prove this fact for $n=2$ for simplicity.
First show $\mathfrak B(\mathbb R^2)\subseteq \mathfrak B(\mathbb R)\otimes \mathfrak B(\mathbb R)$.
Take arbitrary rectangle $(a,b)\times (c,d)$. It belongs to $\mathfrak B(\mathbb R)\otimes \mathfrak B(\mathbb R)$ since $(a,b)\in\mathfrak B(\mathbb R)$ and $(c,d)\in\mathfrak B(\mathbb R)$. Then the set of all possible rectangles belongs to $\mathfrak B(\mathbb R)\otimes \mathfrak B(\mathbb R)$. Then the sigma-algebra $\mathfrak B(\mathbb R^2)$ generated by the set of all rectangles is a subset of the sigma-algebra $\mathfrak B(\mathbb R)\otimes \mathfrak B(\mathbb R)$. Recall the reason: $\mathfrak B(\mathbb R^2)$ is a smallest sigma-algebra containing all rectangles, and $\mathfrak B(\mathbb R)\otimes \mathfrak B(\mathbb R)$ is some sigma-algebra which also containes all rectangles, so the first one is nested in the second one.
Next show $\mathfrak B(\mathbb R)\otimes \mathfrak B(\mathbb R)\subseteq \mathfrak B(\mathbb R^2)$.
Let $\mathcal F$ be the collection of all subsets $A$ of $\mathbb R$ such that $A\times \mathbb R\in \mathfrak B(\mathbb R^2)$. Note that all intervals are in $\mathcal F$ and also $\mathcal F$ is a sigma-algebra. The last fact can be checked from definitions easily. Therefore $\mathfrak B(\mathbb R)\subseteq \mathcal F$. So we obtained that for every $A\in \mathfrak B(\mathbb R)$, $A\times \mathbb R\in \mathfrak B(\mathbb R^2)$.
Similarly, for every $B\in \mathfrak B(\mathbb R)$, $\mathbb R\times B\in \mathfrak B(\mathbb R^2)$. Then also
$$
A\times B=(A\times \mathbb R)\cap (\mathbb R\times B) \in \mathfrak B(\mathbb R^2).
$$
And therefore the sigma-algebra generated by the collection of all rectangles $A\times B$ for any $A,B\in \mathfrak B(\mathbb R)$ became a subset of $\mathfrak B(\mathbb R^2)$, so
$\mathfrak B(\mathbb R)\otimes \mathfrak B(\mathbb R)\subseteq \mathfrak B(\mathbb R^2)$.
We prove that these sigma-algebras coincide.
Comment: Thank you for answer. So now, if i know that the class consists of cartesian, one dimensional borel sets generates B(R^n), could you tell me does exist some theorem, which in probability context allows to induce probability measure of n-dimensional random vector (probability law) just by set it on sets in the shape of cartesian product of borels?
Comment: I do not completely sure that I understand your question. Do you mean the following theorem: https://en.wikipedia.org/wiki/Kolmogorov_extension_theorem ? In any case, I see that it is a new question which does not relate to this one.
Comment: @Mentossinho Or possibly you have in mind this theorem: https://en.wikipedia.org/wiki/Carath%C3%A9odory%27s_extension_theorem It is more probable.
Comment: @Mentossinho What do you mean by "induce" a measure? Do you want to specify what you want the measure to be in on sets in the shape of cartesian product of borels? There may be no such a mesaure, but if there is one, then it is unique, because of a "uniqueness of measure" theorem that uses the Pi-Lambda theorem.
Answer: Yes, this holds more generally for separable metric spaces.

Let $X_1, \ldots, X_n$ be metric spaces and let $X = \prod_1^n X_j$, equipped with the product metric. Then, $\bigotimes^1_n \mathcal B(X_j) \subset \mathcal B(X)$. If the $X_j$'s are separable, then $\bigotimes^1_n \mathcal B(X_j) = \mathcal B(X)$.

Since $\Bbb R$ is separable (i.e., it has a countable dense subset), it follows that $$\mathcal B(\Bbb R^n) = \bigotimes^1_n \mathcal B(\Bbb R)$$


Looking for a word that fits for a young grown woodland

Question: I'm looking for a word for a young wood of forest. In German you would say "junger Bestand". What ist the english expression - young stand, young stock?
Comment: new-growth forest?
Comment: And if it is a small area with a few trees? Or a reforested area?
Comment: A *"new-growth forest"* is usually a reforested area (although it doesn't have to be). How large an area are you talking about? You could say *"a stand of young trees"* ... I don't think there's a special term in English for anything smaller than a forest.
Answer: "Stand" would be a suitable word in British English. The National Vegetation Classification system uses the so-called "Stand Type system" to classify woodland. See http://jncc.defra.gov.uk/PDF/fieldguidetowoodland.pdf.
"Stand: A group of growing plants of a specified kind, especially trees:" ref http://www.oxforddictionaries.com/definition/english/stand #6.
Answer: I'm not sure if this exactly has the nuance you're looking for, as it's forestry-related jargon instead of what a layman might say, but there's a term, "secondary forest" used to describe woodland that is recovering after having been disturbed or burned down.
https://en.wikipedia.org/wiki/Secondary_forest
Undisturbed forest would be "old-growth forest" or "primary forest": https://en.wikipedia.org/wiki/Old-growth_forest
Answer: young forest or young stand (which OP mentioned)
"What is young forest? It's the shoots and sprouts of young trees springing up again in incredible numbers from the root systems of older trees following a timber harvest. It's an old field thick with shrubs and saplings. It's a tract of swampland choked with emergent shrubs. Young forest can be a pine barrens greening up again following a prescribed burn carried out by a trained fire crew."  from the website of The Young Forest Project [http://youngforest.org/]
[1]
See the "Young Stand Thinning and Diversity Study A management study evaluating the ecological, operational, social, and economic consequences of alternative methods of managing 30-50 year-old plantations" from Ecoshare's website.
Concerning Peter Shor's suggestion, I found some photos labeled "New growth forests", which, however, proved to be a mixture of new growth and old growth.
What it isn't, of course, is an old-growth forest (primary, virgin, primeval).  And, according to Wikipedia, second-growth forests refers to well established forests that have grown up after a major disturbance to the earlier growth.   See Wikipedia articles on old growth and secondary growth forests.


Why aren't solar panels efficient?

Question: Why can't solar panels produce 1 Kw per 1 square meter?  This is the energy of the Sun's radiation per square meter on Earth but solar panels don't come close. Why can't  we trap all that energy?  Where is the rest of the energy going?
Answer: The Wikpedia article on solar cell efficiency gives a number of reasons that solar cells are less than 100% efficient.  One of the large ones is the thermodynamic limit-a photon of less energy (longer wavelength) than the silicon band gap cannot produce an electron and one with higher energy can only produce as much voltage as the band gap.  Even if you could choose the band gap, this limits efficiency to 34%.  There are many more, smaller, factors that reduce the overall panel efficiency to around 20%.
Comment: Why not split the incoming light into a spectrum using a prism, then create a "spectrum" of band gaps across the solar panel to match?
Comment: This is done in double and triple junction cells. A layer with high band gap absorbs the highest energy photons and transmits the rest. You still can't get a perfect match. These cells are much more expensive than single junction cells, but are used in space.
Answer: No energy conversion process completes at 100% efficiency. Using the sun, gasoline or nuclear, none of these will generate power at 100% of total potential power available.
That figure of 1KW/m^2 is for total available light energy correct? Due to how solar panels work (I don't think I have enough knowledge to speak on this part directly) solar panels are tuned to specific wavelengths to maximize performance. They simply cannot absorb efficiently over the entire solar spectrum. The wavelengths outside of the targeted band are either reflected or absorbed as heat. Furthermore, some energy is lost due to internal resistance. Something that compounds this issue is that solar panels lose efficiency as they heat up, so it is very important to keep them relatively cool.
There are other factors such as how they behave under actual load and how things such as MPPT's come into play but I think I've covered the meat of the question.

Why aren't solar panels efficient?


Do migrated questions get bumped to the front page?

Question: When a question gets migrated, does it get bumped to the front page of the target site?
Answer: Yes. If a question is migrated, its last activity date on the target site is set to the time of the migration, and thus it appears on the front page.
This even works with the realtime updates.
Comment: I hoped so. But after following a few migrated questions that didn't receive **any** attention on the target site, doubt entered my mind...
Comment: @Dennis, I recently noticed the same and was coming here to ask about it. I've noticed that on SO in particular many don't get much attention but it seems to mostly be if they aren't re-tagged and end up left with obscure tags.


drupal and multiple primary key

Question: i have defined a new content type "statetype" and a cck field "state".
i need state field as primary key in this table because i have another table  and i need state field as foreign key. (this code and table is not drupal  and i wrote it myself but related to drupal table)
so i should change state field to primary key  in "statetype" table but drupal have defined vid field in this table as primary key.
 is there any problem if i define multiple primary key (vid,state) or if remove  vid primary key?
Answer: Using db fields with a business meaning as primary/foreign keys is never a good idea. You should always use some kind of id field to do this. If you don't stick to this rule you will run into trouble, as soon your business changes. Then you would have to migrate primary keys, which is a lot more work than just changing and migrating some other data.
In MySql the easiest way is to define a filed as int and auto increment. Use this id field as a foreign key. The other way round reference the nid/vid of the drupal node.

drupal and multiple primary key


What happens if you delete a game from your PS4 library?

Question: I deleted a game from the library, and thought I could get it back. Is there a way to get it back?
Answer: You should be able to re-download the game via the PlayStation Store. Search for the title that you deleted in the store and it should show that it can be downloaded. If it doesn't tell you you can download the game, contact PlayStation support and they will sort it out for you. Alternatively, you can also go to your games library and travel to the
Purchased tab. It should show every game you've purchased on that PSN and allow you to reinstall.


Use a lightning component within a dashboard?

Question: Is the currently possible to build a lightning component and then use it within a dashboard? If so how do I do it.
Answer: The short answer to this is No. There is no way as of today that you can add a lightning component in a Dashboard. There is this idea Ability to add Lightning Components to Dashboards open to allow this feature.
What you can do is instead create a custom tab and use that as a dashboard where you will be able to put your custom lightning components.
Answer: You can expose a Lightning Component in a Classic Dashboard, but it will not work in Lightning. As Jayant says, you would want to vote on that idea. To get this working in Classic, you simply need to create your component, create a dependency app, create a Visualforce page, and finally add the page to your dashboard as a new component. See Using Lightning Components in Visualforce Pages. This is only a temporary workaround and should not be relied upon heavily.


How do we calculate bandwidth from signal formula?

Question:
How can we calculate the bandwidth of distinct signals like this?
I guess the right answer is 90 - 10 = 80 Hz. But I have a hard time understanding why is this calculated in that way. I thought the bandwidth is calculated by the diversity of signals and since there aren't in-between frequencies like 11, 12... in the image there are 5 signals, shouldn't the bandwidth be 5 Hz? What am I missing here?
Comment: I don't think the units were in question. The point is that bandwidth could have different definitions based on context. What are you doing with it, or do you have a preferred definition which could be used to answer the question?
Comment: To answer this question, first you need to define "bandwidth". There are many definitions, and each gives a different answer.
Comment: I only used Herz as bandwidth in my question so I thought it would be clear that I am asking about bandwidth as Herz @MBaz
Comment: What @DanSzabo said: bandwidth is always measured in Hz, but there are many ways to measure it.
Answer: Your intuition is basically correct.  I'm sure they want the answer of 80Hz because that is the bandwidth that you would need to carry these 5 waves, but pure sinusoids that aren't modulated at all can not carry any information.  If they don't carry any information then they are infinitely narrow.  (0Hz rather than 5Hz).  You could modulate them individually to higher frequencies and put them very close together with any loss of information.


Kalanchoe leaves developing brown spots

Question: My Kalanchoe plant leaves have developed brown/balck spots on them. Although fresh leaves are coming the old leaves have started falling by the handful. Any tips what it might be causing it and how I can take care?
Answer: There's an insect of some sort on one or two of the leaves which cannot be seen clearly; you may have a case of scale insect infestation, because the one I can see clearly looks like a little greyish coloured shield on one leaf. Check the underside of the leaves too, as well as the stems, with a magnifying glass if necessary, to determine whether there are other insects on there such as aphids, and carry out the appropriate treatment as recommended in this link https://homeguides.sfgate.com/kalanchoe-pests-61103.html according to what you find.
Comment: Thanks for the pointers. Its looks like either scale infestation or black spot. I have washed the leaves with alcohol and scraped off the brown scales. Fingers crossed now. Should I go ahead and remove all leaves with black spots as well?

Kalanchoe leaves developing brown spots


iChat sends out connections to an IP address when configuring camera and mic settings

Question: Using LittleSnitch I noticed that Messages (iChat) tries to connect to 126.96.36.199 over udp when I open the audio and video preferences for the application.  Apple owns that IP address but does anybody know why it would need to call home?
Comment: It would call home if you have entered any accounts that use Apple's location services. iChat (via AIM) or iMessage would be the reasons I can think of off the top of my head.
Answer: The port is used to "set up Real-Time Transport Protocol (RTP), Real-Time Control Protocol (RTCP)" according to Apple.
According to wiki, "the Real-time Transport Protocol (RTP) defines a standardized packet format for delivering audio and video over IP networks. RTP is used extensively in communication and entertainment systems that involve streaming media, such as telephony, video teleconference applications, television services and web-based push-to-talk features."
Note: iChat became Messages.
Source: http://support.apple.com/kb/TS1629?viewlocale=en_US&locale=en_US


Missing menu in LibreOffice 5.1.2 on Ubuntu 16.04

Question: I have just upgraded my OS from Ubuntu 14.04 to 16.04. I was previously using LibreOffice 5.0 on my 14.04. The 16.04 upgrade installed LibreOffice 5.1.2 although my 5.0 is still intact. When I run the LibreOffice 5.1.2 I noticed that the classic menu is missing and I would like to know who do I display the menu?
Comment: As you are a reputation one user, if an answer solved your problem please accept it, so that the question is marked solved.
Answer: Just type unity in the terminal which will restart the UI and add the menu to the LibreOffice components.
Comment: It should be noted that a logout/login or restart will also do the same.


Can an In the Money Put Option's price $>$ its Strike Price?

Question: The screenshot below suggests thatan ITM put option's price can't overstep its strike price? Why or why not?
Comment: What is your definition of an "in the money" put option? [A common definition](https://www.investopedia.com/terms/i/inthemoney.asp) is that the market price is below the put option's strike price.  Note that neither of these are the actual price of the option.
Comment: @Henry Yes. You're correct about that definition.
Answer: If you own a put, you have the right but not the obligation to sell at the strike price. For most financial assets generally including stocks and bonds(although some commodities have been known to take negative prices), the minimum price they could possibly sell for is zero, because of limited liability. The worst they can be worth is zero, meaning that they generate no cash flows. If an asset has a price ($P$) of zero and you can sell it for the strike price ($K$), then you take a profit of $K-P = K-0 = K$. This is the maximum in the money value of the put because the asset price can't be below zero).
As you can see in the figure below (a call option, but it is the same idea), the time value of an option falls as the underlying price gets farther from the strike price. Therefore, when the ITM value is maximized you are as far as possible as you can get in one direction from the strike price, and we should expect the time value to be small. In fact, if you have a American option where you can exercise early, you will want to exercise this put option early if the price of the underlying ever reaches 0, because you can't make any extra money by waiting, which implies the time value is not just small but actually zero. NB: I believe this is only true when interest rates are positive. With negative rates it pays to wait just to avoid getting negative interest.

I believe it is not generally possible for the total value (ITM + time value) of an option to be above the strike price, which includes when it is out of the money, again as long as interest rates are positive. At exercise, the most the option can be worth is $K$. The expectation of a random variable that takes only weekly positive values less than $K$ must be less than or equal to $K$ ($0 <  E[X / (1+r)^t| 0 \leq x \leq K]  <  K/(1+r)^t < K $ where $t$ is the remaining option life.
Let me say this another way. The most you can ever get at this option at maturity is $K$. What's this worth to you? The absolute maximum this should be worth to you is if you knew for certain that it would be $K$. Then you would have a certain payoff of $K$ and the price would be $K/(1+r)^t$, just like any risk free cash flow. If anything else happens and the price of the underlying is anything higher than zero, this option is worth less than this. An option is out of the money if the price of the underlying is above the strike $P>K$. But the higher $P$ is, the lower the probability of the stock hitting zero is. This means that the total value of the option (ITM + time value) should be falling as the underlying price increases. This convinces me that that it cannot be that the total value of the put option is ever higher than strike price.
Answer: @BKay's explanation is spot on. I often prefer to look at simply numerical examples or charts to get intuition. I'll use 'Julia because it takes only a few lines to show a decent interactive chart like the one below. The code:
<code>using Distributions, Interact,Plots
N(x) = cdf(Normal(0,1),x)

function BSM(S,K,t,r,d,σ, cp)
  d1 = ( log(S/K) + (r - d + 1/2*σ^2)*t ) / (σ*sqrt(t))
  d2 = d1 - σ*sqrt(t)
  opt  = cp*exp(-d*t)S*N(cp*d1) - cp*exp(-r*t)*K*N(cp*d2)
  return opt
end
range = 0.1:0.1:3
@manipulate for r = -0.5:0.01:0.5, d=-0.5:0.01:0.5, t=0.01:0.1:10, s = 0.01:0.1:5, cp_flag = -1:2:1;
    res = BSM.(s, 5, t,r,d,range, cp_flag)
    plot(range, res,label =false ,xlabel = "IVOL",ylabel = "Option Premium",size=(800,550),margin=5Plots.mm, title="$(cp_flag == 1 ? "Call" : "Put") option Premium (S=$s, K=5, t=$t years, d=$d%, r=$r%)", legend=:bottomright, ylim = [minimum(res)*0.99,maximum(res)*1.02])
end
</code>
You will see that neither dividends (negative dividends are unlikely but not unseen if borrow costs are not separately implied), spot price, time nor IVOL can get a put price above the strike price. Only negative interest can actually result in this outcome. Bear in mind that IVOL and/or term to maturity need to be quite (unreasonably) large to even reach the limiting case.

For completeness sake, the same applies to call options, where spot is the maximum (forward in case of dividends and rates). This is an application of the put-call parity, C−P=DF(F−K), with F representing the forward price, and DF being the discount factor. Indeed the maximum put price is DF×K at which point the call is worth DF×F.


Core Data sum of all instances attribute

Question: Using Core Data, I encountered a problem. I have an entity "Movement" with an attribute "amount". How do I make the sum of all the "amount" of all instances? I'd like to understand how to use NSExpressionDescription, but it's good enough NSSet.
Answer: Having a managedObjectContext:
NSManagedObjectContext *managedObjectContext = ...

We create a fetch request with return type dictionary:
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass([Movement class])];
fetchRequest.resultType = NSDictionaryResultType;

Then we create an expression description to calculate the sum:
NSExpressionDescription *expressionDescription = [[NSExpressionDescription alloc] init];
expressionDescription.name = @"sumOfAmounts";
expressionDescription.expression = [NSExpression expressionForKeyPath:@"@sum.amount"];
expressionDescription.expressionResultType = NSDecimalAttributeType;

Set the request properties to fetch:
fetchRequest.propertiesToFetch = @[expressionDescription];

We could also set a predicate if we want.
And last we execute the request and get an array containing a dictionary with one key(@"sumOfAmounts") and its value is a NSNumber with the sum of amounts.
NSError *error = nil;
NSArray *result = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
if (result == nil)
{
    NSLog(@"Error: %@", error);
}
else
{
    NSNumber *sumOfAmounts = [[result objectAtIndex:0] objectForKey:@"sumOfAmounts"];
}

Cheers
Comment: @e1985 one question please: I to calculate the sum of a single instance use: `NSNumber *sum = [fund valueForKeyPath:@"fund_relativeMovement.@sum.amount"];` and I would use the same mechanism that you have written, for this, too. just that I do not know how to set up an instance as an entity before the expression. Thanks!
Comment: Love this! How would I use this to run against a sorted fetchRequest? My table has 2 sections, each with sets of values. I want the unique total of each section.
Comment: Whether this works depends on the type of persistent store used. While it does work when backed by SQLite, I couldn't get it to work with `NSInMemoryStoreType`.
If you are getting an `[ valueForUndefinedKey:]: this class is not key value coding-compliant for the key @sum.` exception, this can be a sign that your persistent store doesn't support this feature.
Comment: @TimBodeit, I did not test it with NSInMemoryStoreType, but I guess you are right. In the past I found issues with different types CoreData persistent stores. In my case, it was the other way around: something that was working in-memory in a test wasn't with SQLite. I ended up using SQLite as well in the test to get the same behaviour as in actual production code.
Answer: Here's a Swift example of summing a managed object's attribute using NSExpression and NSExpressionDescription. The example assumes that the managed object is named Movement and the attribute to sum is  amount.
Example:
 func sumAmount() -> Double {
    var amountTotal : Double = 0

    // Step 1:
    // - Create the summing expression on the amount attribute.
    // - Name the expression result as 'amountTotal'.
    // - Assign the expression result data type as a Double.

    let expression = NSExpressionDescription()
    expression.expression =  NSExpression(forFunction: "sum:", arguments:[NSExpression(forKeyPath: "amount")])
    expression.name = "amountTotal";
    expression.expressionResultType = NSAttributeType.doubleAttributeType

    // Step 2:
    // - Create the fetch request for the Movement entity.
    // - Indicate that the fetched properties are those that were
    //   described in `expression`.
    // - Indicate that the result type is a dictionary.

    let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: "Movement")
    fetchRequest.propertiesToFetch = [expression]
    fetchRequest.resultType = NSFetchRequestResultType.dictionaryResultType

    // Step 3:
    // - Execute the fetch request which returns an array.
    // - There will only be one result. Get the first array
    //   element and assign to 'resultMap'.
    // - The summed amount value is in the dictionary as
    //   'amountTotal'. This will be summed value.

    do {
        let results = try context.fetch(fetchRequest)
        let resultMap = results[0] as! [String:Double]
        amountTotal = resultMap["amountTotal"]!
    } catch let error as NSError {
        NSLog("Error when summing amounts: \(error.localizedDescription)")
    }

    return amountTotal
}

Additional Discussion of Steps:
Step 1 - Create an NSExpressionDescription variable. This NSExpressionDescription indicates what type of function is applied to the arguments. The sum function is being applied to the amount attribute.
expression.expression =  NSExpression(forFunction: "sum:",
    arguments:[NSExpression(forKeyPath: "amount")])

Notice that the arguments parameter is an array. You can pass different types of expressions in the array, but, in our case we only want the amount attribute.
Step 2 - The fetch request is established here. Notice that the result type is specified as a dictionary: fetchRequest.resultType = NSAttributeType.DictionaryResultType. In Step 3 we will use the expression.name value of amountTotal as the key to access the summed value.
Step 3 - We execute the fetch request and returned will be a one element array. The element will be a dictionary which we caste to [String:Double]: let resultMap = results[0] as! [String:Double]. The dictionary's value is a Double because in Step 1 we indicated that the expression.expressionResultType would be a Double.
Finally, we access the sum by calling the dictionary value associated with the amountTotal key: resultMap["amountTotal"]!

References:
NSExpression and NSExpressionDescription
Comment: thanks for the elaboration, this should be accepted
Answer: The best way is to use a fetch for specific values and supply a NSExpressionDescription with a sum: function.
When you execute the fetch you get a one element array containing a dictionary whose keys match the expression descriptions and whose values are the results of the expressions. In this case, you would get a sum key whose value would be the sum of the attributes given the expression.


How can I overcome performance anxiety?

Question: I've been playing for two years and performed a few times already. But recently I seem to forget whatever I'm playing when I get nervous in front of my teacher and small audiences.  Even if i practice multiple times perfectly beforehand, my hands don't know where to go and I end up playing wrong notes. It's as if I've never played it before. Is there any way to improve this?
Answer: I found for myself, that playing with an "open mic" group of performers, helped me to get over playing in front of crowds. Go and listen to some in your area, to see if they play the same sort of music that you do. Ask to join in, when audience numbers are low, and then go from there.

How can I overcome performance anxiety?


Tracking Offsite Conversions with Google Analytics

Question: I'm trying to track my AdWords campaigns through to the final conversion. However, the conversion happens offsite, in a separate session. Many of the conversions are being attributed to that external site, where in reality, the referrer was really the AdWords campaign. Currently, Analytics is properly catching only about 60% of the conversions on the external site.
I've implemented this by placing an iframe on the conversion site, and the iframe contains my Google Analytics conversion code (I defined that page as the goal).
Do you know how to cause the ~40% of conversions that get incorrectly attributed to the referring site to be tied back to the correct ad campaign?
Thanks!
Answer: Look into Tracking multiple domains


Why don't all GA aircraft have yaw dampers?

Question: Why don't they have yaw dampers if they are always "suffering" from adverse yaw?
Comment: You mean aside from the extra cost, complexity, and maintenance required? Yaw damper systems are pretty complicated, a touch of rudder or rudder trim is pretty cheap and easy for a GA pilot to deal with. Small aircraft don't have much of a dutch roll tendency, and passenger ride isn't a concern, so the need for such a complicated and expensive system isn't there.
Comment: A yaw damper is mostly aimed to prevent Dutch roll on long fuselage aircraft.
Comment: I think the fact that most GA aircraft are not swept wing is another factor.
Comment: Because the pilot's leg muscles need exercising.
Answer: A yaw damper means added cost, weight, complexity, and one more system that has to be maintained. That's the downside. The upside, for most GA aircraft is that they relieve the pilot of having to make a "coordinated" turn. In other words, having to apply appropriate rudder input along with aileron input. Is that convenience worth the downside when the pilot has internalized doing that without having to think about it? That's a matter of opinion. For myself, a yaw damper in any of the, say, single engine Cessnas would be a waste.
There are some GA aircraft that could benefit from a yaw damper in other than banking into a turn or leveling from a turn. For example, in level flight the old V-tail Bonanza would yaw around the vertical axis in turbulence to an objectionable degree in my opinion. Very uncomfortable, especially to passengers in the back seat. It would have been great to have had a yaw damper.
Comment: Its worth noting that some GA aircraft do have a pseudo yaw-damper: An aileron/rudder interconnect that applies some rudder when the ailerons are deflected (usually a spring or bungee). I believe some models of the Beechcraft Bonanza have such an interconnect, though I'm not sure if it's on the V-tails.
Comment: @WayneConrad The Ercoupe is an extreme example, but an interesting one: As originally built it had no rudder pedals, and the interconnect between the rudder and the ailerons produced inherently coordinated turns. That plus its limited elevator travel makes it one of the few aircraft certificated as "characteristically incapable of spinning" (because you can't hold it in a stall long enough to develop into a spin).
Comment: @voretaq7 The [Erco Aircoupe](https://en.wikipedia.org/wiki/ERCO_Ercoupe) was famous for its linked rudder and aileron controls.  The linked controls were sold as a safety feature to prevent spins.
Comment: @voretaq7: Hope no Ercoupe pilot ever had to perform a crosswind landing...
Comment: @Vikki I think I read somewhere that the main gear on the Ercoupe could caster allowing crabbed landings in a crosswind.
Comment: [And some like the SR-22 have a full on yaw damper...](https://cirrusaircraft.com/aircraft/sr22/)
Answer: Adverse yaw is the yawing moment that occurs due to aileron deflection.

Yawing moment from aileron deflection: upon a left turn the right aileron deflects downwards and the left one upwards. The downwards deflecting aileron creates more drag friction, pulling the nose of the aeroplane to the right.
Yawing moment from roll velocity. The wing rolling up has a different Angle of Attack than the wing rolling down: the downwards going wing has the lift vector tilted forwards (like in a glider) and vice versa, which creates a yawing moment pulling the aeroplane nose to the right.

So adverse yaw pulls the nose into the opposite direction of where we want to turn, and the effect scales with wing span. One way to counteract this is to couple the rudder to the aileron, and give automatic nose left rudder deflection upon left aileron roll. Some of the Learjets and I'm sure some other aeroplanes have this, a way to automatically fly coordinated turns.
Yaw dampers on smaller planes do not coordinate turns but damp out Dutch rolling: the rudder deflects to counteract yaw velocity. Only airliners have yaw dampers that also coordinate turns.
The thing is that GA aircraft are mostly manually flown, control surfaces are manually deflected. For a yaw damper you need an actuator, so will need to install a powered rudder system. A major cost driver.
Comment: @Bianfable noted and included. OP asks about GA aircraft though.
Comment: "A yaw damper does not coordinate turns but damps out Dutch rolling": That may have been the original intention and the source of the name yaw *damper*, but every yaw damper system on a modern airliner **is performing turn coordination**.
Comment: For what I know, the situation is rather the opposite. Larger airplanes (airliners) are typically underdampened in yaw and prone to dutch roll, esp. at higher speeds. They also have higher demands due to passenger comfort issues. So they require (or 'desire') a yaw damper per se. Turn coordination is a bonus. GA airplanes are typically well dampened naturally (except some, partricularly with V-tail) and have much smaller speed range, and for them turn coordination is the main driver.
Answer: Yaw dampers prevent dutch roll on swept-wing aircraft.
A single-engine propeller GA aircraft with a straight wing has no need for a yaw damper, since it has good directional stability and doesn't have a tendency to develop dutch roll like a swept-wing aircraft does.
Dutch roll is when the tail of the airplane "wags"/moves left and right as the wings roll.


Verifying password restrictions

Question: How to automate and verify password authentication using selenium and java: password should be accept minimum 6 char with at least one number and one special char are must require ?.
Comment: Please give us a little more context. What have you tried so far? what language are you looking to use?  Do you have experience with developing code?
Comment: I can't tell whether you are asking whether a 6-character minimum is ok or telling us that the requirement is a 6-character minimum.
Answer: Basically you will check if the application behaves correctly when valid and invalid passwords are tried.

When using a valid password, the system goes to the landing screen/page;
When using a invalid password, the system displays same error message (and maybe logs the event in a logging database);

You can check a description of scenarios that I wrote for validating a login page here.
You can either use a fixed set of valid and invalid passwords or generate the inputs using a modal-based testing tool like OSMO.
Answer: Random people on the Internet can't tell you what your password policy should be.
If you own defining the policy, you should know there there are different schools of thought on password restrictions; see for example https://security.stackexchange.com/questions/29836/what-are-good-requirements-for-a-password.
If you are a tester, you should ask for the policy the software is supposed to enforce.
Comment: It looks like they have the password policy in place, but his question seems to be more around how to create an automated test to meet that criteria.
Comment: Maybe.  I can't tell from how the question is written.
Comment: He is asking for how to automate test cases for password field
Answer: I would use a regex pattern match. I'm not a guru in this, but there seems to be a good answer in SO here.
To save the extra click, @Srinivas' closest answer is:-
Minimum 8 characters at least 1 Uppercase Alphabet, 1 Lowercase Alphabet, 1 Number and 1 Special Character:

"^(?=.[a-z])(?=.[A-Z])(?=.\d)(?=.[$@$!%?&])[A-Za-z\d$@$!%?&]{8,}"

It will take some playing with, but that should get you what you are after.

Verifying password restrictions


Angular material 17 - vertical slider

Question: I have build a responsive webapp with a slider that turns vertical on small screens. I have recently migrated to material version 17. However the new docs state the following quote:

Vertical sliders and inverted sliders are no longer supported, as they are no longer part of the Material Design spec. As a result, the invert and vertical properties have been removed.

The same webpage states that one can still import legacy code and use it  (also suggested in this answer)

import {MatLegacyButtonModule} from '@angular/material/legacy-button';

However,  when I try to import the legacy slider from @angular/metarial/legacy-slider, I get a compiler error: Cannot find module. I think the reason is that legacy code is completely removed from version 17.
I have tried using css transform: rotate to solve this problem, but this does not allow smooth interaction with the slider (The slider is rendered vertically, but I cannot slide it).
Do you know how to solve this problem? I would appreciate any help.
Answer: You are correct, the legacy components were removed in v17. Also there is no intention from the team to implement a vertical slider (see this git issue).
This leaves you with three options:

Don't use vertical slider in your project
Replace all your sliders to some other components that allow using vertical sliders (there seem to be plenty on npm, but recommendations of libraries is not in scope of SO questions)
Create your own component that suits your needs.

There's also a temporary solution of rolling back to v16 and use the legacy component, but it's probably not sustainable in the long run, so it's probably best as a workaround until you can pick one of the three above options.

Angular material 17 - vertical slider


Sci fi story from the 50s-60s about where cats are the dominant lifeforms and they're called PUTIE

Question: My question is about a book or short story about a creature called a PUTIE and his quest to old Earth ruins. He makes the discovery that his race evolved from the common house cat. "We're not putie, we're cat!" It reminded me a little of Planet of the Apes. I know, not too much to go on, but worth a shot.
Comment: Because, after all, "Puddy tat" and similar variations is a not uncommon way to baby talk about a "Kitty cat", as immortalized in the Sylvester / Tweety Bird cartoons.
Comment: A Google Books search in 20th century works for **"putie "** and **"cats"** turns up no English Language works. Neither does **"putie "** and **"feline"**.
Comment: I don't know the exact spelling of Putti, because It was a story read in my grade school class by the teacher. I don't remember humans in the story either. It was a post-apocalyptic story for kids. :)
Answer: I believe it was Putti. This is 'Breed to Come' by Andre Norton. Humans left Earth, and the rats and cats evolved into sentience. When the humans came back, they recognised the cats from the stuffed toys (Putti) that they took with them.
Comment: The story contains the line you mention *Not Putti but cat!*
Comment: Aw man... I came across that one in my search, but discarded the possibility. :-p Missed opportunities.
Comment: It's Sueelleker for the win! Thanks.
Comment: Thanks for clinching it for me, John.


Subtracting Time for a given user based on allowed Time and multiple entries

Question: I have data coming from a form into a response sheet. This data represents information from a therapy session. It includes the date, time (units), individual id, individual name, etc. Each individual is allotted a certain amount of time which is located in the AllClients sheet (column C). I need help creating a formula that will look at all the data in the Form Responses sheet, specifically the units per session (Column K) for each user, and then subtract it from the allotted time given for each client (Column C). Total units left for each client will be (Column D)
Here is the sheet I am working on.
https://docs.google.com/spreadsheets/d/1X8UVfpkyeba1WD-r8X82qlMA3cCR-_VlSFisHEy3lFY/edit#gid=334495985
Answer: Enter this calculation in cell D2 of the "AllClients" sheet
<code>=arrayformula( if ( A2:A<>"", C2:C - sumif('Form Responses 1'!C2:C, A2:A,'Form Responses 1'!K2:K), ""))
</code>
The result will be:


Animation Nodes loops and Python

Question: I am starting with the animation nodes and I am trying to replace as many nodes as possible with Python code; it is especially nice for the math. However, now I am stuck with the looping. Is it possible to replace the Loop Input and its generators with Python code plus other nodes? thanks
Comment: Hello, are you talking about "Expression" nodes (where you can only write one single line of code) or "Script" nodes, where you can write as many lines as you want in a text block ?
Comment: I understand that in Expression nodes one can put only one line of code so looping would be difficult but in scripting nodes it should be possible. I am just not sure how to reproduce the Loop input and generators in the script
Answer: You just have to know how to access input variables and how to output variables in the script. Otherwise it's just common python operations. Mainly you will have to use for loops.
Let's see how to emulate a loop with a python script, for example to output a list of the location of each object in a given collection.
Here in my collection I have 3 objects.

And here the simple setup to output their locations using a loop node :

Now, to do the same with a script node. Add your script node, add a text block with the + icon. Add a new input of type "Collection", I renamed it "col". Add a new output of type "Vector list", I renamed it "positions".

In a text editor, find your new script textblock and open it. Write a few lines to do the job.
positions = []

for obj in col.objects:
    positions.append(obj.location)

Or with list comprehension
positions = [obj.location for obj in col.objects]

Note that col hasn't been defined in this text block : AN gives it context since you told the script node that a variable named col will be available, as a collection type.
Similarly, you have to define the variable positions and at the end of the execution of the script, AN will automatically gather its value.
/!\ col and positionsare case sensitive. They have to match the variable names you wrote in the script node.
Add an invoke node set to your script, execute the AN tree and voilà :

Animation Nodes loops and Python