My computer loses internet connection while router is ok

Question: It happens when I play games mostly. My desktop pc loses its internet connection (connected via ethernet) for a small amount of time (1-2 sec), dropping from games and raidcall and every other programm that uses internet.My laptop in the same time keeps having internet connection via wireless(always leave a stream on from twitch.tv to check). I've changed all cables but nothing happened.I have re-installed my network driver (have Asrock H77M for mobo) , switched to Linksys WAG200G from Thomson 585 v8 , still not fixed , disabled windows defender still not fixed, checked with MBAM for malware , still not fixed and disabled IPv6 cause I've read sometimes it bugs with IPv4, still not fixed and I disabled some other programms that used internet connection but still nothing happened.I have disabled windows updates (have win7 64bit on a new pc), and I use eset smart security 5 as an antivirus.My ISP says it's not my internet dropping and I can see it on my router - all LEDs working properly but I lose connection on my desktop.Also I've unchecked the energy option at the device management -> network adapter.
EDIT : I've read somewhere about NVIDIA and ASUS having something to do with that problem but they didn't elaborate much.I am using NVIDIA and ASROCK(which was ASUS ago iirc) just in case this helps.
Comment: Have you verified this problem isn't just simply your ISP? You should enable Windows defender that wouldn't cause you to lose your internet connection.  Your ISP has every reason to claim its not them, have them come out, verify ALL their equipment.  I had a problem like this and it ended up being my ISP.
Comment: Yes I've contacted my ISP many times and it's not on their side.I'm telling you that one of my computers only lose connection and not the other.
Answer: You've mentioned that it happens when you play games mostly. It sounds like your computer is overheating.
Comment: Can't be.It's brand new and temps are around 30-40 celsius.
Comment: @user2192519 - Just because your comptuer is new doesn't mean it can't overheat.
Comment: True but I told you it is around 40 degrees and isn't overheating. plus I can't understand how overheating would make it lose internet connection instead of turning off or something else.
Comment: What is around 40 degrees? Your CPU? How about the GPU? If your wifi adapter located closely to the GPU it may be overheating. Try to use the ethernet cable instead
Comment: Nothing gets over 50 degrees with temps running around 40 when gaming.And I say  again I am using ethernet and not wireless...
Answer: In the end it was ESET Smart Security 5 blocking UDP port 5355 which resulted in games + other programms losing connection with their respective servers. I tried to add that port to firewall's trusted zone but it wouldn't work. Just uninstalled it and changed to avast.


Has work been done on PID controllers for optimal trading?

Question: Commonly, stochastic control is the basis for optimal trading (either in execution or market-making). Has any research been done (or why not, if none) as to PID controllers for these applications?
Answer: Check the code below for basic logic. You may need to improvise it (may be).Just a quick and dirty work. In case it works, reshare. Enjoy !!
How PID controller works - a crash (fast fast) course ?

PID controller works on Error to minimise error !! Wow, that is mouthful. Error(e) = SetPoint (SP) - ProcessValue (PV). This is the most basic thing.
Now there are three terms in PID controller equation which are actually multipliers

kp - this dictates how much the output change with each unit change if error (repeat error).

Kd - Tricky part starts from here. Kd is a multiple also but it is multiple of rate of change of error i.e. how much error is changing wrt time
-3. Ki - Ki is also multiple but it is multiple of a term which has past memory of error i.e. Ki multiples  summation of error.

Now you see...Kp dicatats how much you output changes wrt to difference between setpoint and actual value i.e. proprotional part , Kd dicatact how the rate of change of error affect the output, ki dictate how much error is minimised. Suppose Setpoint and output becomes same then error is zeror, there is no rate of change of error and summation of error is also zero.
<code>
//@version=5
indicator("PID Controller", overlay=false)
// Input Variables
lookback = input.int(title="Lookback Period", defval=20, minval=1)
kp = input.float(title="Kp", defval=0.1, minval=0)
kd = input.float(title="Kd", defval=0.1, minval=0)
ki = input.float(title="Ki", defval=0.1, minval=0)
price_src = input(close, title="Price Source")
// Variables
var float error = 0.0
var float error_sum = 0.0
var float error_diff = 0.0
var float pid = 0.0
// Arrays
var float[] pid_array = array.new_float(0)
// Loop
for i = 0 to 10
// Calculate error and PID
error := price_src - ta.sma(price_src, lookback)
error_sum := error_sum + error
error_diff := error - nz(error[1])
pid := kperror + kierror_sum + kd*error_diff
// Add PID value to array
array.push(pid_array, pid)

// Wait for next bar
//bar_wait(0)

// Calculate average PID value
var pid_sum = 0.0
for i = 0 to array.size(pid_array)-1
pid_sum := pid_sum + array.get(pid_array, i)
var float pid_avg = pid_sum / array.size(pid_array)
// Plotting
plot(pid_avg, color=color.green, linewidth=1, title="PID")
</code>
Comment: This is just a general implementation of PID (available in any Control book) it has nothing to do with trading or marketmaking, which was the subject of the question. And the question asked for research results, of which AFAIK there are not any published for these applications.
Comment: As it's currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Comment: edited the answer
Comment: Edited the answer and because gentleman wanted one, code is given. Please note that PID control implementation in context of trading would be more of trailing stop loss and there are good algorithms for trailing. So rather than going for PID code in which you want to control some outcome but which you can not in context of stock market, hence try using stop loss algorithm. One such could be Chandelier exit or use indicator such as  Garman-Klass-Yang-Zhang Historical Volatility with Kaufman's Adaptive Moving Average (Trading view indicator name: JFD-Adaptive, GKYZ-Filtered KAMA [Loxx])..


How can i interpret the observed difference in a/b test?

Question: I conducted an a/b test but I was confused about how to interpret the result.
I got 0.5% difference between control and treatment groups and statistical significance for the difference (p <0.05).
In my opinion, I can only say that the two groups are different (the change effects treatment group significantly) but how can I interpret the 0.5% difference in observation? Can I say that there is significantly 0.5% difference? When it comes to null hypothesis is "A and B has no difference and I rejected it with p value, I cannot assume how different those two groups are?
Then, how should I confirm "~% lift" through A/B test?
Comment: Given that this sounds like a statistics issue, you might want to post this in the [Math StackExchange](https://mathoverflow.net/), or [this one](https://math.stackexchange.com/) as well. But I think [Cross Validated](https://stats.stackexchange.com/) is the correct StackExchange to ask this question, they deal with statistics
Answer: You are correct that a significant null hypothesis result only tells you that A and B are different, but it doesn't quite tell you how different they could reasonably be, given the sample size and variability in addition to the observed (sample) difference of 0.5%.
To determine a range on values the population difference could reasonably be, calculate the confidence interval. This will yield a result like, "With 95% certainty, the actual difference between A and B is between 0.28% and 0.79%." The math for confidence intervals is closely related to null hypothesis testing, so if results are statistically significant at the 0.05 level, then the lower bound of the 95% confidence interval should be greater than zero.
Here're a couple ways of calculating confidence intervals with R for the kind of data in A/B testing.
Obviously, of course, you already know the actual difference is most likely about 0.5%. Confidence intervals let you rigorously quantify how big "about" is in your instance.
Answer: I am not a statistician, but if you want to more easily see the difference between two values, use the actual difference between your results and not percentage difference.
E.g. "There were 2000 more users doing X than Y" should show a greater difference than "There were 0.05% more users doing X over Y".
Comment: This is an explanation for how to lie with statistics?
Comment: @RayButterworth No. But, I assumed this would be how it would be interpreted. It isn't to lie, it's to show the difference. At times 0.05% can be a big deal but you are presenting it to people who don't understand this. So, to avoid all the explaining which takes things nowhere, you present the data in a different format to make it easier for them to see the difference. I remember an article giving percent values that were very close (I think it was 51% vs 50%, but that diff was seen as a big deal). To me, this isn't a problem, to someone who isn't well versed, they won't see it the same way.


What are the white nodules on my Peperomia Polybotrya, near where the leaves fell off?

Question: I'm very new to indoor plants so thought I would ask some more experienced indoor gardeners as I am coming up empty after a few weeks of Google searching. I've had these small white nodules appear on the stems of my Peperomia Polybotrya, near where the leaves have fallen. Not sure exactly what they are, if they are caused by the recent seasonal change, or possibly exposure to recent construction (I have wiped the leaves down but not sure if I can do anything about the soil?) If anyone knows what these nodules are and how to fix them (if that even is a problem) it will be greatly appreciated.
Answer: They are harmless.  They are sites where roots could grow and are called adventitious roots. The definition from the article is

plant roots that form from any nonroot tissue and are produced both
during normal development ... and in response to stress conditions, such
as flooding, nutrient deprivation, and wounding


Someone else created a wallet for me to use. Is this a scam?

Question: Someone on social media is offering me to mine bitcoin and they take 10% of any profit I make. I started talking and long story short I was told to download blockchain wallet app.
They provided me the login credentials and I was told once I login to change my password etc. Does this sound like a scam or legit? I mean about them giving me a user id for a blockchain wallet app and I gotta buy bitcoins, transfer them to this wallet and they will mine bitcoins.
Variant:
The attacker requests that the user creates a new blockchain wallet and then shares the login credentials instead of creating the wallet for the user.
Comment: I've edited this question to make it more generic for use as a canonical question and answer pair.
Comment: People that have this question may also find [How do I recover from a cryptocurrency scam?](https://bitcoin.stackexchange.com/a/91950/5406) useful.
Answer:
I was told once I login to change my password

It is important you understand why this is a trick intended to deceive you.
Wallets don't contain bitcoin.
Wallets contain a "private key" - it is this private key that gives you control over an amount of bitcoin.
The person who creates a wallet can copy this private key and use it to make a new wallet that has control over the bitcoin. Including control over bitcoin added by you days months or years later.
You changing the password on a wallet does not keep the private key secret and safe if someone else has previously already seen the contents of the wallet.
If it helps, think of the wallet as one of those keysafes with a user-changeable combination to unlock it. If someone has previously  copied the keys inside, changing the combination that opens the keysafe doesn't keep you safe at all.

Keysafe with resettable combination - like a bitcoin wallet. It doesn't contain money. It contains keys that maybe someone already has copies of. Changing the combination on the keysafe (wallet) doesn't make those copies of the keys disappear.

See also
Mining deceptions

I've been asked to share wallet credentials to participate in mining. Is that a scam?
Am I Being Prodded By A Bitcoin Mining Scammer?
Mining in the wallet
Blockchain Wallet
How can I get a private key for this address

Wallet deceptions

I NEED YOUR HELP URGENTLY Bitcoins
Comment: Nice analogy with the keysafe
Comment: Hey RedGrittyBrick, this answer is outstanding. I added the topic to our list of Canonical Question and Answer pairs: https://bitcoin.meta.stackexchange.com/a/698/5406. I think we may want to close a few of the topics you linked as duplicates of this one here.
Answer: This is almost certainly a scam.
Never ever give anyone anything else than an address (things that start with 1..., 3..., or bc1...). If they ask for anything else, this is very suspicious.
A common scam is to make you create a wallet, have them add "watching" coins to it which are never yours but show up as balance, and then tell you you need to add more coins before you can withdraw.
Answer: Yes, it's definitely a scam. As the old adage goes, "if it is too good to be true, it is too good to be true". The Bitcoin wallet application that you are using is governed by a seed words and not the user ID/password for the online login. So, in your case the attacker created this wallet for you, noted down the seed words and told you to login. Now, if you change your password your account details are going to be shielded from the attacker, but your wallet details and control would still be in the attacker's control. On the other side, the attacker is closely monitoring if you have deposited any bitcoins in the wallet, and as soon as he sees it, he is going to spend it.
Comment: @mrsss, stay away from it. You can only watch the coins getting added, but only the attacker can spend it
Comment: I don't see why you should be worried about your email account if you haven't shared your password of that account. Email addresses are meant to be public. However, DO NOT send bitcoins to the wallet.
Comment: If you still want to use the site, make a brand new account. (There might be a way to create new wallet with new seed words - I am not sure - but I would be reluctant to try that unless you are sure you know what you're doing). Also, do not use the same password as the seed words can be seen in the settings section of the page, which would again compromise your wallet.


Does Windows 8 have gestures for tablet?

Question: On Windows 8 tablets such as Surface, is it possible to use gestures? The first one that comes to mind is an equivalent of the back button.
Answer: I found a article detailing gestures for a different tablet(Kupa X11)

http://liliputing.com/2012/03/list-of-windows-8-touch-based-gestures.html

Summarized

Swipe from the right (Charms menu)
Swipe from the left (Switch apps)
Swipe slowly from the left (Snap apps)
Swipe from left-and-back (Show running apps)
Pull down from the top (Close app)
Swipe down (Bring up additional menus)
Swipe down on an item (Select)
Pinch (Zoom)
Swipe left/right in Internet Explorer (Move back, forward)
Answer: These are some of the new Windows 8 Touch Gestures.

Source: Windows 8 Blog
Answer:
Swipe from the right to open the Charms bar
Swipe from top or bottom to open the app's menu
Swipe from the left to switch between recent apps
Swipe from the left into the screen and back out to open a list of open Modern apps
Swipe from the left and hold, then let go to dock a recent app at the side of the screen
Swipe from the very top to the very bottom of the screen to close a Modern app

Of course, the usual stuff like pinch to zoom and swiping to scroll works in most apps depending on context like you would expect.


How to block access from the tor user

Question: I am a Japanese university students.I studied the Tor.
I want to block tor users to access the web server.Is there a way to block access other than to block the exit node of the tor.
Comment: No. Blocking Tor exit nodes is the only way to block Tor users. In all honesty, there's really no reason to block Tor users anyway, since your website can be attacked with or without Tor.
Comment: Can you please share some more details: why do you want to block Tor users and what kind of website and processes on it you want to put aside from Tor?
Comment: Supplement:                                           I learned that a malicious user will come to attack using the tor. However, it is difficult to block to find the only malicious user. So I thought trying to block the tor user. Block of only malicious user is the future challenges.
Comment: A malicious user will also come to attack using the normal Internet. Are you going to block the Internet user too?
Answer: Tor is just a network instrument, there are many of them... The crime exists inside malicious user's mind, and it has no relation to any tool he uses. So - blocking Tor won't help you a bit, if your task is to protect the website from malicious activities. My good advice to you - forget about 1990-years AtGuard tactiks with a blocklists in txt files: it does not work at all nowdays. Focus on hardening and guarding your website itself, and it will work fine regardless of the connection methods used by user.

How to block access from the tor user


Partman doesn't allow set mount point to a LVM on Debian installation

Question: While installing Debian the partman doesn't allow set an LVM as root file system, cant set / as mountpoint to a LVM filesystem, but when choose "use entire disk and setup LVM" partman comes with a recipe very next to what i want, just make a small /boot partition and I need one bigger because already had system crash with this default setup because of it.
There is a question where people tell it need to be with another tool and is impossible do it with partman but doesn't tell how to switch tool, I believe it is choosing text mode installation and I will try.
Would be nice if there is a way to change the scheme done by partman at any point, change size, mountpoint, label, names, etc.
The recipe  "use entire disk and setup LVM" from partman generate it:

I just need it but with bigger /boot
There is this question asking how to expand boot partition in front of LVM and @solsTiCe told to move the boot partition at the end of the drive allowing increase size, with "use entire disk and setup LVM" recipe I can do it but then I will end with boot at end of drive but its so jerry-rigged to do on a fresh install.
There is this page describing it is done with a custom preseed recipe but looks like an overkill and I dont know how to do preseeding partionning recipes load on Debian install.
Answer: You can move to Ubuntu that comes with 1G boot recipe on partman, just remember to increase the % size of main partition as you can see done here:
Ubuntu with partman recipe
You can also, if have huge memory, remove swap as you can see here.


Travel Outside UK Whilst on Garden Leave & Waiting for New Visa Decision

Question: I am currently on garden leave and have a Tier 2 work visa through September 13. My current employer will notify the Home Office that my job has been terminated by September 23. Fortunately, I have a new job offer with visa sponsorship in process. My new employer says they "sent off for my new visa" a few weeks ago. My question is this: can I travel outside the UK on my current visa while waiting for a decision on my new visa? I do not want to put my new visa application at risk by leaving the UK on a holiday.
Answer: No.

You must not travel outside of the UK, Ireland, the Channel Islands or the Isle of Man until you get a decision. Your application will be withdrawn if you do.

Source: Skilled Worker Visa Update your visa if you change job or employer


How does this 'sed' substitution command with lots of @ signs work?

Question: Can anyone explain how this sed command works?
sed 's@+@ @g;s@%@\\x@g' | xargs -0 printf "%b"

Comment: The normal way to do this is using slashes, but that may become cumbersome if you search and replace something with slashes.  That is not the case here, so even though it is perfectly fine it confuses future maintainers like you.
Comment: … and leads them to learn something new about `sed` this way! :)
Answer: In sed, substitute commands are usually written as s/pattern/replacement/options. However, it's not necessary to use / - you can use other characters if it is convenient, so it could be s@pattern@replacement@options or s:foo:bar:g. s@+@ @g is like s/+/ /g - replace all + with spaces. Similarly s@%@\\x@g replaces all % with \x (a single backslash is an escape character in sed, so you need two to get an actual backslash).
A string like foo+%2Fbar will then become foo \x2Fbar. printf "%b" will expand the backslash-escaped sequences like \x2F (the ASCII character whose hexadecimal value is 2F, which is /) to finally give you foo /bar.
Comment: In brief, a URL->filename decoder.
Answer: The command you're asking about for decoding +es and % sequences from URLs is not just a sed command, it's a pipeline that processes input with sed, then pipes it to xargs for further processing. First lets look at the sed command:
sed 's@+@ @g;s@%@\\x@g'

You may be more accustomed to seeing it with / rather than @ as the separator, which could easily have been done here without complication since / appears in neither of the search patterns nor either of the replacement texts. This command is equivalent:
sed 's/+/ /g;s/%/\\x/g'

Like /, @ is a perfectly good punctuation character for sed.
On each line of input:

s@+@ @g (s/+/ /g) substitutes (s) occurrences of + with a space. This affects all +es on a line (g), not just the first one.
; ends the action ("command") and allows you to specify another one in the same "script."
s@%@\\x@g (s/%/\\x/g) substitutes (s) occurrences of % with \x. As before, it acts on all rather than just the first of each line (g).
In \\x the \\ represents just one \ because \ has a special meaning to sed. Its special meaning is actually as the character you use to take away the special meaning of another character that comes after it that would otherwise have special meaning. So it must be escaped as \\.

Now let's look a the xargs command, whose purpose is to run printf.
xargs constructs command lines. If you run xargs command..., where command... is one or more word, xargs runs command... with additional command-line arguments read from its input. In this case, the input to xargs is the output of sed, because of the pipe (|). Normally xargs interprets any whitespace in its input to mean that the text before and after it constitutes separate arguments, but the -0 option makes it split arguments at occurrences of the null character instead.
In the intended use of your command, a null character won't appear and xargs will run printf %b with just one additional command-line argument, the output of the sed command. Thus, while not equivalent in general, in this case the whole pipeline might instead have been written like this using command substitution instead of xargs:
printf '%b\n' "$(sed 's/+/ /g;s/%/\\x/g')"

As for what printf is intended to do here, as muru says the %b format specifier consumes and prints an argument (like %s) but causes backslash escapes--of the sort the sed command on the left side of the pipe was written to generate--to be translated into the characters they represent.
Suppose I run that command and pass http://foldoc.org/debugging%20by%20printf as input. I get http://foldoc.org/debugging by printf as output, because the %20 sequences are translated into spaces.
Answer: That's the beauty of sed, it applies its paradigms to itself...  After the command (such as s or tr or nothing), the next character is considered the separator.
You should choose wisely to avoid interference with the shell and the command itself, and keep the thing readable, but it's perfectly valid to write something as horrid as:
echo 'arrival' | sed srarbrg

...and get brrivbl as a result, which is what you expect. You can have fun making it really cryptic, such as in:
echo 'arrival' | sed s\fa\fb\fg   # \f is form feed, chr(12)

The common use is to use the slash as delimiter, but when your expression contains the delimiter, it makes it easier to grab what the intent is. Your delimiter can be anything in the ASCII8 range (multibyte delimiters such as £ provoke an error).
Just remember the goal is to make things easier, not more cryptic.
Comment: Running with the cryptic idea, this is a valid sed command, though it doesn't do anything useful: `sed "snack is an apple or something" <<< "I sed your snack is an apple or something"`
Comment: Nice! Yes, you can use `sed` commands as brain teasers too, how geeky is that?


Disable USB autosuspend for Wester Digital My Passport Ultra

Question: I recognize this question has been asked on these forums before but I'm having no luck with any of the solutions.  Here's my situation.  I recently purchased an Intel Nuc.  Ubuntu is stored on an SSD, my media is stored on a Western Digital My Passport Ultra.  I realize this is not optimal, but it's what I have...
This computer is supposed to be my media server but after a while sitting idle the connected harddrive disables therefore rendering it useless.  This is obviously a problem.  I can't pull out the harddrive as it does not have SATA connectors.
I do not have powertop, powernap or laptop power management stuff installed it's just straight Ubuntu, no bells or whistles.
Here is my drive after running "lsusb"
Bus 001 Device 002: ID 1058:0827 Western Digital Technologies, Inc.
I'm incredibly new to linux, meaning three days have passed since I installed, so anything you could do would help.  Thanks.
Answer: I created my own udev rule. Create file: /etc/udev/rules.d/usb-power.rules.
Try this rule:
<code>ACTION=="add", ATTR{idVendor}=="1058", ATTR{idProduct}=="0827", RUN="/bin/sh -c 'echo 0 >/sys/\$devpath/authorized'"
</code>


New Azure Active Directory app which a user did not create is listed in account

Question: My company uses Office 365 and SharePoint online for all of our work.  I was just looking around in our Azure account and noticed a new app registered under Active Directory -> App Registration titled SharePoint Online Client Extensibility Web Application Principal that was created on 2/13/2019.  It has a client secret and exposes this API https://microsoft.spfx3rdparty.com/user_impersonation.  I didn't create this and am the only person internally who would has accessed account.  Is this some kind of default app that Microsoft may have added to my account?  Is there a way I can turn it off without deleting it, to see if it breaks anythings?  And if so turn back on?
Answer: SharePoint Online Client Extensibility Web Application Principal  is default App created that is required for SPFx sign in. I think it would have been created when you deploy first SPfx solution on your SharePoint online.
You should not delete it, it will break you SPfx solution. there are threads around this on what happens when it is deleted accidentally.
https://github.com/SharePoint/sp-dev-docs/issues/2473
https://github.com/SharePoint/sp-dev-docs/issues/2522
One of comment from
I guess that the "SharePoint Online Client Extensibility Web Application Principal" is supposed to handle SPFx signins and therefor needs permissions to Sign in users from AAD granted globally and that this one lacks the grant that was previously globally deployed from Microsoft.
To restore you have to use powershell with below command(https://github.com/SharePoint/sp-dev-docs/issues/2522#issuecomment-422296053)
Connect-AzureAD
Get-AzureADDeletedApplication
Restore-AzureADDeletedApplication -ObjectId <your_object_id>

So do not delete it if you need SPFx solutions to work.
Hope this helps...Happy coding..!!
Comment: I figured this might be a default app, but given that I'm the only one who's touched the site I thought it was best to confirm rather than assume.  Thanks!


Most efficient way to determine CouchDB access permission

Question: I'm using the CouchDB permission system with per-db-and-user access rights. Each DB represents an app, which are being displayed in a home-screen-like overview and in other places. I need an efficient way to make CouchDB tell me whether a user has access to a db or not - for example a GET /_all_dbs that only returns the DBs for which current user has access. Polling a view or document turns out to be too slow once there are more than a dozen or so apps to display on one page, although I could still tune a view poll with limit=1. Isn't there a better way though?
Answer: Query the _security document of the database.
curl http://localhost:5984/db_name/_security
{"admins":{"names":["dbadmin"],"roles":["reader"]},"members":{"names":[],"roles":[]}}
For every database that has admins/users couchdb has a creates a special document called _security that holds a list of all the users for that database. You can make a curl request to that document and get an array that will give you all the admins and members for that database.
Edit
You know your application best but here is a strategy that I think could be helpful? Every couchdb user is stored in the _users database.  It is just like any other database. You can create a view on it and then query it. You can even add additional fields to the documents to help with querying. How about when you create a user on a database you update the corresponding document in the _users database as well.
Now if you call  _users/_all_docs?include_docs=true you get a list of users along with the databases they have access to. One request and you have everything you need.
Comment: Thanks. It's still not quite an ideal solution since 1) it's probably not going to be faster than polling a view since it's still one request per DB and 2) one basically has to reimplement the code that CouchDB uses to check whether a user has access or not - which is thankfully not much, since couchdb doesn't have sophisticated read access permissions.
Comment: I am not sure in that case what is the best approach. One thing I would like to add is that if you have created a view then you can query it with multiple keys at once.  Can you share the view that you are using currently to query?
Comment: Querying multiple keys is not going to help - one view query can, as far as I know, only go to one DB - if you need to check access against 20 DBs you will have to do 20 requests.

Here's what I'm going to do:
1) Cache the accessible applications in the user's session.
2) Wipe this session state at Login, such that I don't need to implement a Cache update mechanism that's too complex.
Comment: All right. You know if it does not sound too complex I have another suggestion. It is too big for the comment so I am going to add it in the answer. Let me know if it helps.
Comment: Thanks for your suggestion. It's an interesting idea. I'd say it makes sense to do this if you a) don't use roles to give database access to users and b) never leave the members field empty such that access is always restricted, i.e. if you always assign all the users you want to give access directly to the members and admin fields. However, in a general case where roles are used and/or access can be left open to all users, it's quite a complex update code you're going to have with your suggestion - hence why I won't use it in my case.


What does 大出天下 mean?

Question: It is found in an exhibition of Qin Dynasty held in Xi'an city. The exact words are 秦国35代国君发奋图强,做好了"大出天下"的准备。I have checked the words online for the meaning, but finding no answer.But roughly I think it might mean something ambitious, because it is about a growing country with some hard working kings.
Comment: 大出天下 in today's China would be "The Great Belt & Road Initiative"
Comment: Where did you see it? I haven't seen the word
方便的话解释下出处
What are you talking about is大出于天下?There is no opponent who can beat you at present
Comment: It is an allegorical comparative reference between what 大出于天下 represented in "Qin Dynastic China's" road to unification conquest of ancient "China", and what the "The Belt & Road Initiative" represents to the present day Chinese leadership's dream to "Initiate" a "Pan-Global Highway" of World trade. Is there any other country at this moment who could "beat" this Belt & Road Initiative's  大出于天下?
Comment: To continue, this Belt & Road Initiative therefore signifies present day China "Going Forth", (大出),  into "the wide, wide World", (天下), not, I believe, to conquer the World, (no country can do that), like the Qin Dynasty conquered the other Kingdoms.
Answer: Let's look at similar phrasing words
大赦天下 grant amnesty within China on a grand scale
大出天下 sounded like "on a grand scale, set off from Qin to conquer the rest of China".
Since Qin was preparing to unify China around that period, '出' in '大出天下' was more likely suggesting "出咸谷關" (out of Qin's border) or '出征' (send off the army/ campaign)
Comment: You have made an interesting comparison, but still I think it is a little weird these two phrases are of the same structure. In 大赦天下, the 天下 is the object of the verb赦, but it is not the case of the other phrase.
Comment: @NanningYouth 天下 in 大赦天下 is not the object. It should be 大赦(于)天下,not everyone is 赦免ed, only the ones in prison are 赦免ed. However, 天下 is the scale of the action. Similar to 大(规模)出(征)(于)天下.
Answer:
It's good to think in classical Chinese. 大 is adverbial on 出 emphasising its extent. Similar constructions include 大叫 (to yell loudly),  大敗楚軍 (to defeat utterly the armies of Chu) etc.

大出天下 feels like neo-classical Chinese to me (which is a very effective means of communication in the context of a historical exhibition). It's not an established expression in the classics, but understandable. With the Qin rulers being the grammatical subject of the sentence, 出 perhaps can be parsed very literally as in exiting the borders of Qin, but this clearly conflicts with the grammatical object 天下 ('all that is under heaven'): it makes no sense to exit the target of your conquest.
出 here is similar to that in 水落石出 (stones appear as water recedes). For understanding, I think it does no harm to make clear the intransitivity of 出 (meaning 'to appear' instead of 'to exit (sth.)', see eighth definition here) by adding the preposition 於 before 天下 to make the phrase adverbial, as in

大出天下 ↔ 大出於天下 (phrase adverbialised) ↔ 於天下大出 (phrase inverted)
to make Qin known in all that is under heaven

Similarly, we observe the adverbial nature of  天下 in the much more common expression 稱霸天下 too: it must not be the object because the transitive 稱 ('to declare (oneself)') is already matched with the noun 霸 ('overlord; hegemony').
Answer: 秦国35代 should be near the end of Qin Dynasty. At then, internally it was corrupted, externally it was surrounded by fierce enemies. Its 35th emperor, a wise, ambitious emperor decided to lead his kingdom to regain its past glory and "raise" high above (大出) the competitors/enemies who had grabbed land from its original territory (天下) and threatened its survival.
出 has the following meanings:
"to rise", "to go out", "to come out", "to produce", "to go beyond", "to put forth".
Comment: 35代国君 means kings of 35 generations, not the 35th king, in my opinion.
Comment: @NanningYouth 古曰"代", 現稱"任", or "屆". But you are free to stick to your opinion, as this is really a trivial argument regarding the question.
Comment: Maybe your right. I was just wondering whether this phrase means a singular noun or a plural one. The efforts made by 35 generations (terms) of kings should be much bigger than a single man, but of course that is my opinion based on the face meaning of the phrase, which could have been written as 第35代国君 to avoid undue misunderstanding. 大出天下 is rarely seen elsewhere, I didn't find the same in my search online.
Comment: @NanningYouth This is the first time I see this phrase too. From history, I guess "復出天下" was more of the interest of the emperor, but the note writer (注釋者) wanted to make a stronger case out of it and replaced 復 (re-emerge) with 大 (rise above all).
Answer: Where did you see it? I haven't seen the word
方便的话解释下出处
What are you talking about is大出于天下?There is no opponent who can beat you at present
Comment: If you want to answer this question, please explain the meaning of 大 and 出 in this context. e.g. 大= grant; 出 = campaign
Comment: I have said elsewhere that I met this phrase for the first time. It is 大出天下, not 大出于天下, the 于 doesn't exist. I would also like to know the origin of this phrase. Who is the author? Could it be 司马迁?

What does 大出天下 mean?


Is it possible make the pod reach inside the Hangar 21?

Question: In The Final Stand trailer transport pod is launched and lands inside the Hangar 21. I've tried that numerous times and it always lands short. Is it at all possible like in the trailer, or is it just scripted and not possible in the actual game?
(skip to 1:50)
Answer: It is possible to do I've seen it done before but not quite as far in as in the trailer, I do believe they nerfed it at some point as it did propel you as far any more, it requires a great deal of precision to get it into the hanger.


Game with static scene and bouncing balls. How to?

Question: How to make a game with a static scene and balls that can bounce on it? What is used for this, generally? Physics engines? Even if this is a simplistic example?
Comment: I think this would be an good question if you elaborated more on what you are trying to accomplish.
Answer: The easiest way would to be use a physics engine. Box2D has been ported to nearly every popular language. However, its impossible to make a more specific suggestion as you provide no contextual information.
Answer: The simplest way would be good if the static scene only has straight walls and flat ground. All you would have to do is multiply one of its components speeds by -1. If it collides with a wall, this would be the x component. If it is the ceiling or floor, this would be the y component. If you want to add in friction, multiply instead by -.7 or something similar.


Add custom menu item type

Question: Is there a way to add custom menu type to the menu editor? I know I can add items dynamically with the wp_get_nav_menu_items filter, but I would like to have the position of those items configurable.
Answer: I decided for now, I will use a custom css class and detect it in a wp_get_nav_menu_items filter. From there, I can get the data I need to set the URL.

Add custom menu item type


distance between two points on different direction

Question: I want to measure the distance between two points on the horizon and vertical axis. Is any function on GIS can achieve this?
Comment: Welcome to GIS SE.  As a new user, please take the [Tour](http://gis.stackexchange.com/tour).  You've left a lot of details out of this question, to the point that it can't be answered.  Every GIS package has a way to measure distances; in fact, most probably have more than one way, plus programming interfaces to enable others.  Please edit the question to specify the exact GIS software you intend to use, what you have tried, and what difficulty you have encountered.
Comment: Are you trying to do what my answer assumes or are the two points located on the same plane? Similar answer exists either you have to calculate the angle of the line and then do a triangle solution, or create a 3rd point at the so the east-west and north-south lines can be calculated separately.
Answer: Note: many GIS distance calculators only calculate 2D distances either on the ellipsoid surface or a planar surface.
Subtract the first point's elevation (z) from the second point's and take the absolute value. That's your vertical distance.
Create a third point that has the elevation of point 1 but the xy (or lat-lon) coordinates of point 2.
Run a distance calculator on point 1 and point 3 to get the horizontal distance.


Why do stocks gap up after a buyout is announced?

Question: It seems like often a when a company announces they will be bought, the stock will immediately jump at a great deal, often instantly. Why exactly does this happen? How do market participants immediately come to agree on a single, much higher price without the market's usual random walk search&discovery?
Answer: The price gaps up because the offer is for a price above the current price. Therefore people want to buy now before the price jumps to the offer level.
Of course it does depend on the tone of the announcement,  which party is making the announcement, and are they announcing an offer or a deal.
If the price is $10, and the offer is for $12; then the price may quickly jump. The early buyers will make the most quick money. They hope that the deal is done quickly, or if not the final price ends up higher.
There are risks. The company could reject the offer. The due diligence could expose a problem. The regulators could reject the deal based on anti-trust issues. The deal could take many months to complete. Or the final deal could be for shares in the new company.
The risks are one reason people sell after the deal/offer is announced. In other cases the seller finally is seeing a profit, or a smaller loss and wants out while they can.
Answer: The "random walk" that you describe reflects the nature of the information flow about the value of a stock.  If the flow is just little bits of relatively unimportant information (including information about the broader market and the investor pool), you will get small and seemingly random moves, which may look like a meander.  If an important bit of information comes out, like a merger, you will see a large and immediate move, which may not look as random.
However, the idea that small moves are a meander of search and discovery and large moves are immediate agreements is incorrect.  Both small moves and large moves are instantaneous agreements about the value of a stock in the form of a demand/supply equilibrium.  As a rule, neither is predictable from the point of view of a single investor, but they are not actually random.  They look different from each other only because of the size of the movement, not because of an underlying difference in how the consensus price is reached.
Comment: @Philipp A potential company buyout is a particular bit of news that affects a stock's price.  The asker appears to be under the impression that aside from magnitude there is something special about a price change due to buyout news that is not special about smaller price changes.  There is not.
Comment: What has any of that to do with a company buyout?


Is there a material lightning does not strike?

Question: I was imagining the possibilities of creating a ship mast which could not get struck by lightning. Is there a material it could be made of that would never get struck by lightning?
Comment: Ordinary wooden masts protected by lightning rods connected to the salty sea? See the work of [William Snow Harris](https://en.wikipedia.org/wiki/William_Snow_Harris). Fun factoid: before the invention of the lightning rod, buildings were quite often destroyed in fires started by lightning strikes. After Ben Franklin, that became rare. Franklin invented the lightning rod in 1752; only ten years later, King George III of Great Britain installed  lightning rods at Kew Palace, London.
Comment: In the rain, no matter what the material of the mast, the mast will be covered in rain.  And rain is not pure water, it includes enough other stuff to be conductive. And any particulates that have settled on the mast before the rain will likely add to its external conductivity. Consequently, using something like a lightning rod to direct the lightning safely is probably going to be more effective than just building a non-conductive mast. (At least, without adding a certain amount of handwavium. )
Comment: "Is there a material lightning does not strike?"  You'd need something without *any* charged particles.
Comment: @AlexP make your initial comment an answer please :)
Comment: "Is there a material it could be made of that would never get struck by lightning?"  What technology level?  In the far future, you could handwave the ability to make "neutronium".
Comment: @RonJohn Anything with a higher resistance than air wouldn't be struck.
Comment: Besides the insulating properties of a wooden mast, many of the components of a sailing ship are covered in tar, to help slow decay.  Tar is also at least a partial insulator.
Comment: Even if you'd find a material that in itself wouldn't get struck, during rain it would become wet and possibly hit by lightning.
Answer: It's not the material per se which makes it lightning proof, but rather what's around it.
When a difference of potential starts building up, sooner or later it will cause a discharge and produce the lightning.
The discharge happens at the point which offers the least resistance to the discharge current flow. Therefore in a world made of gold, a wooden stick is almost sure to never get a lightning (unless it gets close enough to the other pole...).
Even in a world made of vacuum and only your perfect pole, a lightning would happen, because you can't store infinite energy in a finite volume.
Comment: In other words, if the electric field is strong enough it can tear electrons out of any material through the vacuum.
Comment: Let's just say the lightning in a vacuum would be extremely rare, but also extremely deadly. Most likely cataclysmic level of destruction every time it happens.
Comment: I mean, you can't have traditional lightning in a vacuum anyway, because any atmosphere that would generate an electrical charge would fall into the space occupied by the vacuum.
Answer: I think there are two main physics principles to consider.

The conductivity of the material. Typical sailing masts are wood, which is generally considered an insulator. However we know that lightning will hit trees and wooden masts. Electrical potential is a lot like water pressure in some ways. Normally glass stops water (like wood stops electricity), but at firehose pressures water breaks through. If the potential is high enough, an arc will go from the clouds to the ground.

The geometry of the mast. Charges build up on the surfaces of objects, and the tighter the curvature of the surface, the more charge density you can get. (I am using a lot of improper terms here because its been a while since I studied electrical engineering.) So if you have a sphere, the charges will be spread around the surface pretty evenly. If you have a spiky ball, the spike tips will be more strongly charged than the sides of the spikes. The places of high charge density are more likely to arc. In the case of a ship, the mast is a really big spike. On the ground, trees are big spikes.

So, I think the best you can do is 1) use smoother, less spiky geometry where you can, and 2) make a lightning rod that is spikier than the mast.
Comment: Exposed wood really isn't a very good insulator.  The conductivity can be measured with a multimeter and a couple of nails.  It's actually one way the moisture content is assessed.  Salt water (sea spray) is more conductive than pure water, and lightning does tend to come with rain.  So at least the outer layer of the mast will be wet wood, possibly salty, and therefore quite conductive.
Comment: "Typical sailing masts are wood" --> In 2023? I have seen few wood masts made after 1970s - at least in this world.
Comment: I assumed we were in a pre-steam environment since we were sailing. Obviously sailing is still a thing with new materials. My bad.
Comment: just out of interest: A hollow wooden circle in which you hang the sail would be more 'resistant'. But because it is still the most outward part of the ship it would get hit (?). learned something today!
Answer: Make your whole ship out of a resistor
Sure, you could go the boring, so-called "practical" route (yech) of installing a lightning rod. But why do that when you could instead make your entire ship out of paraffin wax, fused quartz, PET, or Teflon? Sure to turn heads, and a great conversation-starter!
You see, lightning takes the path of least resistance to the ground or water. Steel, aluminum, and wood are better conductors than air, which is why lightning prefers to travel through those when it can, rather than through the air. So all you have to do is make your mast (and, for good measure, the rest of your ship) out of something with a higher resistivity than air. Lightning will take one sideways look at your plastic ship and go the long way around.
This table tells us that air has a resistivity of 1.3×10^16 to 3.3×10^16 Ω m. Selected entries from the table:
<code>Aluminum            2.82×10^−8
Titanium            4.20×10−7
Stainless steel     6.9×10^−7
Wood (damp)         1×10^3 to 4
Wood (oven dry)     1×10^14 to 10^16
Air                 1.3×10^16 to 3.3×10^16
Paraffin wax        1×10^17
Fused quartz        7.5×10^17
PET                 10×10^20
Teflon              10×10^22 to 10×10^24
</code>
Comment: Making ships out of paraffin wax, fused quartz, PET and Teflon is... more than a bit impractical.
Comment: @RonJohn Not if there's an air path to take. Teflon has 100,000x more resistivity than air, so it will receive 1/100,000 of the current if the circuit has an equal volume of Teflon or air. Also, the development of a lightning bolt iteratively ionizes the air along the path that already had the most current, so it is a "winner take all" scenario. If the Teflon had 1/100,000th of the current as the bolt began to form, it wouldn't be the "winner" so it would end up with much less than 1/100,000th of the current by the time the bolt fully forms. The main bolt would just go around it
Comment: @worldbuilder Hey, did I say it would be smart? Did I say it was seaworthy? No! I said lightning wouldn't strike it. You get what you ordered, pal.
Comment: @RonJohn Artificially applied voltage in a tube is not lightning. We're talking about a boat.
Comment: @RonJohn Fascinating
Comment: The real problem, though, is that "does not" is absolute, while even Teflon will conduct electricity, given enough voltage.
Comment: "Is there a material lightning **does not** strike?"  Put some in a thermionic tube, add enough voltage and it'll conduct electricity.
Comment: +1, this is the right answer. A few additional points: (1) ceramics could be added to the list, as they are commonly used as high voltage insulators and potentially could be strong enough. (2) the whole mast doesn't need to be made of the insulator - as long as the bottom of the mast is well insulated from the ship then the mast will not be struck. (3) this applies to the rigging as well - each rope will need an insulator where it connects to the ship. (4) having insulated the mast the lightning will go around it and strike the deck instead, so it's probably a terrible idea.
Comment: Hmm, maybe I'm wrong about point 2 actually. Lightning could still travel down the mast and then exit the mast at the bottom, travelling through the air again before finally striking the deck. Better make the whole mast out of ceramics to be sure. (Point 4 is still correct though - protecting the mast means the rest of the ship is in greater danger.)
Comment: @N.Virgo Yeah that's why I say the whole boat needs to be made of an insulator. If the mast is an insulator and the hull is metal, then lightning has a slightly easier path if it strikes the hull than if it strikes the water (because the hull is slightly higher than the water). Best to take a scorched-earth policy and make the whole ship out of plastic so lightning has no choice but to go around. Also ceramics won't work because, although they are resistors, they aren't as good resistors as air. See https://ceramique-technique.com/en/properties/volume-resistivity-electrical-properties
Comment: @RonJohn I'd have to agree that I would not trust sailing on a boat made of plastic or wax lol
Comment: What about covering the entire surface of the boat with teflon or pet. Even a thin layer will cover the difference between dry wood and air. This will also ensure your boat will be very durable against rot.
Comment: @causative fair enough, but I'm not the one who criticized your answer, I only agreed with them.
Answer: No, yes, kinda...
If the potential difference between two ends of a length of material is great enough, it will conduct electricity. It doesn't matter what it is. However, the nature of the material may be that it melts, burns, or explodes when that happens. So when you ask the question, "is there a material lightning does not strike?" the simple answer is "no."
However, you can't always control what's around the object. In other words, if the base of your ship's mast is made of metal and for some weird reason that metal extends through the ship to touch the water below, the metal at the base of the mast becomes a great place for lightning to strike and topple the mast.
Except! Your ship is on an ocean of water and pretty much anywhere is a better place for lightning to strike than the ship, itself. It's a common misconception that altitude alone makes something significantly more susceptible to a lightning strike. That's true only if there's a better conductor to ground than every where else. Thus, a wet tree in a rain storm is a little closer to the potential discharge than the surrounding grass and is therefore more likely to be hit.
But change that to a tree on a 10 square-meter island in the middle of a massive lake and the odds of that tree being hit drop tremendously because the surrounding water represents a better conductor than any amount of water on the tree.
Keep in mind that lightning striking the masts of sailing ships are kinda uncommon. Modern statistics say the odds are four out of every thousand strikes during rough weather. Those are low odds. But as the linked article explains, it's still valuable to do something to mitigate the effects.
In other words, you don't want to try to make your mast a better insulator, you want to do something to make your mast a better conductor, so when the lightning does strike it goes exactly where you want it to and discharges in a much safer manner.
But if you insist that you want a better insulator, avoid rainy weather. It's the only way to solve the problem. Water is a more than satisfactory conductor.
Comment: I was looking this up and lightning strikes on boats are extremely common, far more than on land. In fact, especially on the east coast, electrical damage from boats getting struck by lightning is common, 1 in 10,000. Moreover, the statistically highest chance of getting struck by lightning is on a sailboat, which interestingly is 4x more likely to get struck than a pontoon boat.
Comment: @worldbuilder Sailboats typically have deep keel into the water. Pontoon boats typically have a significantly shallower draft and usually nothing deep or pointy under the water.
Answer: Another alternative is keep your mast metal, but make it actively charged via Van de Graaf electrostatic generator or similar.
The lightening happens because electrostatic potential levels of clouds and ground (or sea) are different. When that difference (i.e. voltage) becomes high enough, even the things that are usually not conductive become so due to dielectric breakdown, and electricity flows from one potential level to the other, until they equalize.
As other say, which path is preferred depends on its conductivity, and solutions offered so far focus on reducing that aspect.
However, another alternative is making your mast at the same charge as the clouds. That way it won't be interesting target for the lightening which wants to reach opposite polarity charge (just like the lightning that has started from cloud potential towards ground potential does not decide "ok let's get back to the same place in cloud where I started" - there is no reason why it would go back to the same electrostatic potential).
Of course, it would use energy, and you must watch you do not overcharge it, as otherwise you could create your own lightning from your mast to the sea (even in the absence of the storm outside).
Comment: Do you think there is a systematic and automated way to do this? I like the idea of matching the electrical potential with that of the clouds, although I'm not sure this is realistic to do
Comment: you could check electrostatic potential of the sea, and charge in opposing direction. Still, it is worldbuilding material idea, not "let's patent it and make a bestseller yacht product" (in reality, it is cheapest and safest to use real-world protection methods where you **want** the lightning to struct your arrester - but it does not seem to fit your worldbuilding theme)


What is the difference between "Rest of the things" and "Remaining things"?

Question: In which context these words find their use? are they synonym to each other?
Comment: DO NOT post duplicate questions.
Comment: @Joe..I searched the portal but couldn't find any practical and relevant info.. :-(
Comment: What did you find when you looked up *rest* and *remain* in the dictionary (and adjusted for meaning and part of speech)?
Answer: I would say : "Rest of the things" is used when you talk about many things but are not supposed to do some action with the rest of the things.
"Remaining things" will be used in a situation where suppos you have got 5 tasks to do and you have completed 2 , 3 are yet to be taken care of. So you are supposed to perform some action on the remaining 3 things/tasks.
They are not very significantly different though.
Answer: Rest of the things is used when we do not know the quantity of things.
On the other hand, Remaining is used when the quantity of things is known to us.
Let's clear it up with a couple of examples.
Lets assume that in case one I do not know how many pages a book contain.

1) I've read twenty pages today, I'll read the rest of the pages tomorrow.

And in case two we know that a book contains fifty pages.

2) I've read twenty pages today, I'll read the remaining thirty pages tomorrow.

Above was just an example, you can substitute the pages with whatever you wish.


What is the "global parameter" in a Logic Pro Midi script?

Question: The documentation for Logic Pro Midi says rather cryptically "The Scripter plug-in has one global parameter." But it doesn't say what that global parameter is.
What is it? And is it global within the instrument, or within all scripts running in all instruments in a particular song?
Answer: What is Global Parameters?
Global Parameters is a wrapper (of sorts) that displays the Script Editor interface which, in turn, is used to create your own MIDI processing plug-ins using Scripter (JavaScript) API.
All GUI enabled user defined controls are displayed below the Global Parameters as 'Script Parameters'

Is it global within the instrument, or within all scripts running in all instruments in a particular song?

The script has a channel strip specific scope

The Global Parameter opens the same Script editor and hence has a global scope (will run the same script in exactly the same way across Logic) BUT the user written script has a channel strip specific scope i.e. when the script on a channel strip is run, it will affect the components of that specific channel strip only.
Comment: Thanks! That's a bit of a bummer, and limits what the scripting can be used for. Future Apple developers reading this -- it would be cool if instruments could share info through scripts and code in one instrument could affect another.
Comment: Just curious - what 'info' do you want instruments to share? MIDI data? and how do you want one instrument to affect another?
Comment: So instruments driven by a shared midi track can "coordinate". Like in a jazz band how different instruments take turn soloing.
Comment: If I understand you correctly, you want multiple instruments to play the same MIDI data. This can be done in 2 ways - 1. using track aliases 2. creating multi-layered instruments using Track Stack (Summing).
Comment: I have a lot of ideas but this is among them.


Magic Mouse 2 for Mac

Question: Magic Mouse 2 appears as it is connected but it will not scroll; when you click on something it will not put on the screen what you clicked on. I have to triple click on the item to get rid of it on the screen.  I would like to know if there is a problem with the mouse.
Answer: Minimum OS requirement is El Capitan, 10.11
Ref: Apple KB - Magic Mouse 2 - Technical Specifications

System Requirements

Bluetooth-enabled Mac computer with OS X v10.11 or later

Magic Mouse 2 for Mac


Good resource for geometric optics

Question: I'm looking for a good resource (preferably a book) on geometric optics. I am thorough with the basics (the mirror formula, lensmaker's formula, thin lens formula, etc). What I want is something that focuses specifically on various applications and extensions of these formulas to different situations. I would like a resource that supplements an introductory course in geometric optics while not venturing too much beyond the basic formulas.
Comment: Why don't you read the book of inventor of Opticks? Download PDF version of Newton's OPTICKS. Hurry!
Comment: Welford: Useful Optics    http://www.press.uchicago.edu/ucp/books/book/chicago/U/bo3628689.html
Answer: As far as I understand, detailed theory knowledge of ray optics will only ever take you so far, because in real laboratory situations the setups are much too complex to deal with using pen and paper. This means that, in practice, all the relevant physics gets implemented by an appropriate ray-tracing software package.
As a beginner, it is therefore important that you're familiar with all the ways that an optical system can be less-than-perfect (such as spherical or chromatic aberration, coma, astigmatism, and so on), and their physical origin, but it is also equally important that you have a go at ray optics software and try and get some traction with it. If nothing else, it should be fun!
To get started with that, try the question Software for geometrical optics on this site.

Good resource for geometric optics


How can I make a Beorning Shapechanger in MERP?

Question: My friends and I are starting a MERP campaign and only I have experience with  MERP. One of my friends wanted to be a shape-changer, but my Second Edition MERP book does not cover how to use Martial Arts, Adrenal Defense, or Shape Change, so I am at a complete loss.
Comment: Welcome to RPG.SE! Take the [tour] if you haven't already, and check out the [help] for more guidance.
Answer: These skills are address in the Second edition rule book.
On page 218, under section A-6.2 Martial Arts and Adrenal Defense
Adrenal Defense says:

If a character is not using Armor or a shield and he moves at least 5 feet during a round, his skill bonus for Adrenal Defense is added to his normal DB. This applies to each melee, missile, and directed spell attack which he is aware of  (i.e., it does apply to an attack that surprises him)... there is no stat bonus for this skill.

The Martial Arts skill is listed on the same page in the same section and I have posted it here:

There is a new optional profession that is called Shape Changing, it is designed specifically for this type of character. It can be found on page 217, and reads as follows:

The cost of being a Shape Changer is pretty high, but there they are, such as it is.
So in summary:

Adrenal Defense is a bonus DB to add to their character normal base DB, but only if the character can see the attack coming, but it can be pretty high making the character very hard to hit.
The Martial arts skill is a little complicated and hard to advance because there are two distinct paths, one striking and one sweeps, and the Novice level has a pretty low attack maximum but it must be advanced through development points before you can increase the Standard Level, and BOTH must have higher or equal number of ranks before you can advanced Expert.
The Shape Changer as the complicated formula on how you can voluntarily shape change, and although you get a bonus to this each level, this is countered by the fact you only get 14 development points (rather than the normal 15).  You can also have circumstance where you are forced to change (you get angry, or take a hit, or fall).
Comment: Rather than posting screenshots (or quotes) of large blocks of copyrighted content, it's better to simply quote or paraphrase only what's necessary to answer the question. In this case, rather than posting the entirety of those two rules sections, it's better to simply tell the querent where that information can be found (and briefly summarize it, if necessary).
Answer: The skills you've mentioned are all in Rolemaster (in its various versions), which is what MERP is based on.

Option 1: So the (not easiest) way to do this would be to run Rolemaster instead of MERP (they're compatible, but Rolemaster is like a 6-volume encyclopedia to a single-volume dictionary of MERP!) - This is what I did for my MERP campaign. It has all these skills as well as a much larger set of options (how much money do you have?) and characters and so on; if you choose this option, ask for more details!
Option 2: Somewhat less effort!. Create a custom race for the Beorning, base in on "Men" and then add some special skills for them to use in the new categories.

The three skills translated from Rolemaster to MERP are:

Adrenal Defense: Special Skill. No bonus except for rank. Each rank gives a direct bonus to DB if the character is aware of the attack. First ten ranks give +5 each, next ten give +2 each etc. Miscellaneous Skill.
Martial Arts: Combat Skill, Strength adds, use tooth and claw when in bear form, use grappling and unbalancing otherwise. Frankly this skill should be there for any character anyway to allow fisticuffs!
Shape Change (Control Lycanthropy in Rolemaster) Taken from RMC2; use the table on MT-2 (p 77 to resolve) use the "General" column to determine if the change is successful, then adjust modifiers as you feel; -30 for daylight, +20 for full moon, etc. This skill is based on Constitution and Self Discipline in Rolemaster, so for MERP, Constitution is a good fit to add to it.
Comment: I thought MERP is what then became Rolemater… Might be wrong?
Comment: No trouble - if it's the answer you'll use please tick :)
Comment: RM Arms law came out in 1980, Character Law in 1982; MERP was 1984.


Scriptual references for Adi Shankaracharya and Chhatrapati Shivaji Maharaj being Lord Shiva's avatars

Question: I have read about Adi Shankaracharya being incarnation of Lord Shiva, similarly in many articles, Chhatrapati Shivaji Maharaj is shown as a
Avatar of Lord Shiva. I want to know about the scriptural references about the same.
Comment: [Are there any other Puranas that predict Adi Shanakaracharya besides the Bhavishya Purana?](https://hinduism.stackexchange.com/q/14738/3500). This partially answers your question
Answer: Did not find any about Chatrapati Shivaji Maraj but I do have a lot of references of Adi Shankaracharya being Shivavtaar.
The Kurma Puran Purva Bhag Chapter 30 verses 33-34 states clearly that in the Kali-yuga, lord Rudra (known as Nila-Lohita) will incarnate on earth in order to reestablish the principles and doctrines of the Shrutis and Smritis in order to bring welfare for all his devotees and if we observe the deeds and preachings of Adi Shankaracharya, it is he who did this work. In the Linga Puran Purva Bhag Chapter 40 verses 19-25 it has been stated that in Kali-yuga, even Bramhans become critics of the Vedas and other scriptures in order to carry forward their own agenda, in such time, lord Rudra (Nila-Lohita) incarnates as Shankara in order to reestablish the doctrines of the Vedas and other scriptures. The same above Adi Shankaracharya which has been stated in the Purans have been stated in the Shaktisangam Tantra Chinnamasta Khand as well.


Doctor Who time paradox Captain Jack

Question: Jack is the face of Boe and has lived for millions (or billions) of years; The Doctor has called him a fixed point in time and space. In the short of 'time crash'  the paradox of meeting himself and the Tardis' colliding would destroy a portion of the universe the size of Belgium. The Doctor is a very important part of the universe, but Jack being a "fact" is also very important. What would happen if he time traveled and met himself long enough to create a paradox? Canon if possible
Comment: Whats unclear ?
Answer: The best answer you will get is that whatever the writers want to happen will happen.  There are a veritable crap-ton of paradoxes in Doctor Who (and I've only watched the reboot), and none of them are handled the same way.
In Father's Day:

Rose saves her father, creating a paradox, and then somehow creates a bigger one by touching the baby version of herself.  In this case, Reapers came to "fix" the problem.

In A Good Man Goes To War:

We learn that Amy and Rory named their child after their best friend from childhood who was their child.  Nothing happens.

In The Hungry Earth:

Amy and Rory wave to each other from a distance, even though that should not be possible since Rory is later erased from time.

And then there's the whole Clara thing.  Basically, it is impossible to know, because Doctor Who is invariably inconsistent.
Comment: Amy and Rory isn't really a paradox...  and in the last portion that happened because that time wasn't a fixed moment... The fix moment was created when the last episode with amy / rory happened... Wibbly Wobbly timey wimey
Comment: In Episode One and Two of The Three Doctor's, (Classic series) the Chancellor comments that the Doctor can't cross his own Time Stream, the First Law of Time forbids him to meet his other selves. The response? Its an Emergency and the first law will be obeyed later...making it alright. It is definitely up to the writers and I think the only "canon" answer you'll receive is as @DoctorWho22 put it, "Wibbly Wobbly timey wimey.."
Comment: Generally in the Doctor Who universe, maybe it is not a paradox.  But by its base definition, it definitely is a paradox.  They use the "fixed point" thing when it's convenient.  The timeline has been rebooted a few times now, though, so even the "fixed points" are pointless (ha!).
Comment: Actually from a pretty good User on here named BSW or something he mentioned something called The Web of Time and some other stuff that helps repair paradoxes and stuff like that.
Comment: @DoctorWho22 If you're referring to the middle spoiler, yeah, it's called the bootstrap paradox.  There's information that came from nowhere - how did the name come into existence?

Doctor Who time paradox Captain Jack


Minimizing flights between planets

Question: This may be a peculiar question. I'm a completionist with my games, but I also hate wasting too much time in a play through hunting down power ups. In Metroid Prime 3, I try to avoid flying between planets any more than I have to, and while I'm on a planet, I try to pick up as much stuff in one trip as I can.
In Metroid Prime 3, what is the minimum number of flights in Samus' ship needed to complete the game?  Also, what is the minimum number of flights needed for 100% completion?
Comment: I couldn't tell you offhand, but aside from the story backtracks, but you will have to again at least 1 more time after you get the plasma beam.
Answer: In terms of just completing the game, the number of cross-planet flights is 8. This doesn't count flights before reaching Bryyo nor the flight to Phaaze.

Start with completing Bryyo and moving to Elysia. (1)
Must go to Bryyo with Plasma Beam to get Screw Attack to continue with Elysia. (2)
Complete Elysia and go to Pirate Homeworld. (1)
Must go to Elysia with Grapple Voltage to get Spider Ball to continue with Pirate Homeworld. (2)
Complete Pirate Homeworld and go to Valhalla. (1)
With pirate code, go to Pirate Homeworld to activate Leviathan. (1)

For 100%, the number of flights is 10. Simply go to Norion and Bryyo once you're finished with the Pirate Homeworld and clean them out before going to the Valhalla. Remember to also clean out every planet as much as you can whenever you happen to be there.
Note that this count does not include the Elysia trip necessary to activate the pickup location data for the Pirate Homeworld. If so then that's another 2.
Source

Minimizing flights between planets


Estimating robust variance without cluster id in survival model

Question: I built a survival model with coxph. I have a large dataset (1 000 000 instances) and the global model is not proportional. It cannot be improved by introducing time-dependent coefficients or stratifying. My understanding is that estimating robust standard errors is in order in such a case. Coxph allows estimating robust standard error with robust = TRUE, but in the survival package documentation, it is always used together with cluster id option. I do not think that using clustering variables exists in my data. Does it make sense to estimate robust errors without cluster id in coxph?
I would appreciate any help.
Comment: With such a large data set you are very likely to have proportional hazard (PH) tests fail, just as normality tests tend to fail with large data sets. Robust errors are fine, but please evaluate whether the deviation from PH is large enough to be important in practice.
Comment: Thank you. It is true, about large data, but I have never seen the theory about a threshold of ph deviation being too large or not, so I would not know how to assess it.
Comment: That's not a statistical question about a "threshold." It's a practical consideration informed by your understanding of the subject matter. Examine, say, a loess-smoothed plot of scaled Schoenfeld residuals versus time, as you can get with the cox.zph function in R. Even if it's not completely flat, the deviations might not be very large in comparison to the overall level of the hazard ratio/regression coefficient.
Comment: Thank you EdM@, it is very helpful.
Answer: The coxph model used to have the option robust=TRUE, it may still in fact, or it has been deprecated. This is because there's a connection between the robust error estimator and the frailty methods for repeated measures. The documentation says the following:

The cluster term is used to compute a robust variance for the model. The term + cluster(id) where each value of id is unique is equivalent to specifying the robust=TRUE argument.

So just create a unique row identifier and use it as a clustering variable to get robust variance. One way (in R) is to say mydat$id <- 1:nrow(mydat).
As the question: does it make sense? Sure! A parallel can be drawn to, say, comparing the generalized estimating equation with identity link. In the GEE one must specify the correlation structure as exchangeable or independent. The exchangeable structure has the residual-covariance for a particular cluster $\Sigma_{exch} = (1-\rho)I + \rho J$ where $I$ is the identity matrix, $J$ is the all-one matrix, and $\rho$ is the correlation. The identity structure is simply $\Sigma_{ident} = I$. The two are identical when the cluster size is 1.
The generalized estimating equation takes the form $0 = \sum_{i=1}^n D^T V^{-1} X^T\left( Y - g(X\beta)\right)$. The $A$ bread matrix is $\partial D(\mu) / \partial \beta$ and gives the usual model-based error and is related to the expected information. The $B$ meat matrix is $X^T\left( Y - g(X\beta)\right)  \left( Y - g(X\beta)\right) ^T X / n$ and is related to the observed information. (The book by Stefanski and Boos will give a thorough treatment on the subject). But this is all a long way of saying that if you have an exchangeable correlation matrix with clusters of size 1, it will give the same result as with an independence correlation structure, that is the sandwich error estimate $\text{var}({\beta}) = A^{-1}B(A^{-1})^T$.
Comment: `robust=TRUE` is not deprecated.  And it's a good thing that it isn't, because the robust variance estimator isn't the same thing as a frailty estimator -- not only are the assumptions and variances different, even the point estimates are different.
Comment: Thank you very much, Adam. This is very helpful. Coxph estimates the robust variance without including cluster-id at all. I assume it is equivalent to including cluster-id unique for every instance. Would you be kind enough to explain the last sentence in simpler terms?
Comment: @Milo hmm, sure, but what is the confusion? even I'm a little unclear how exactly the sandwich is calculated for a cox model specifically. Are you aware of the sandwich? Are you aware of the A, B matrices? I can try to link some  other SE posts for background.
Comment: I do not know A and B matrices and the term exchangeable correlation structure. I know that the sandwich estimator uses square residuals. This is probably not the subject that can be explained in one go. Thank you a lot.
Comment: @Milo see if the edit clarifies things at all.
Answer: Insofar as the problem is calculating a robust variance, the answer from AdamO (+1) solves the problem. You can calculate a robust variance estimate for a Cox model with only 1 data point per individual, if you specify robust = TRUE or include a cluster(id) term in the model with id values specified for the individuals.
For a Cox model, Therneau and Grambsch explain in Chapter 7 how the matrix product $D'D$ provides a robust "sandwich"-type estimator of the coefficient covariance matrix, where $D$ is the matrix of "dfbeta" residuals (score residuals scaled by the covariance of coefficient estimates). The "robust" variance is an adjustment like that with generalized estimating equations (GEE). (As Thomas Lumley notes in a comment, that's different from a frailty(id) term, which is like a mixed model.) You can do that directly with your data set.
The question is whether a robust variance estimate is what you should focus on here. Yes, as AdamO explains here, with a robust variance estimate you can do inference on the Cox model coefficients when the proportional hazards (PH) assumption is violated, and those coefficients (whose point estimates will be the same as in the usual Cox model) can be thought of as an average over all events--depending on the data, perhaps close to a time average.
There might, however, be even more to learn from investigating the reason for the apparent failure of PH.
First, it's possible that the massive scale of your data set gives a "statistically significant" violation of PH that doesn't really matter in practice. That's like the case with normality testing of large data sets--as hazards are never perfectly proportional and real data are never exactly distributed normally, large data sets can lead to "statistically significant violations" of model assumptions that have no practical significance. Look at the plots of scaled Schoenfeld residuals over time to see just how big you PH problem is. AdamO discusses the problem of PH in large data sets here.
Second, if the PH violation is large enough to be practically important, that might be a sign that something is wrong with your model. Therneau and Grambsch say on page 148:

There are several possible model failures that may appear as time-varying coefficients but would be dealt with more fruitfully by another approach. These include the omission of an important covariate, incorrect functional form for a covariate, and the use of proportional hazards when a different survival model is appropriate.

Omission of an important covariate will lead to PH violation even if the omitted covariate is balanced between groups. As the at-risk population changes over time with respect to the omitted covariate, "the operative hazard is the average hazard of those at risk at each time point, a mixture of hazards" (Therneau and Grambsch, page 150). There is also a bias toward 0 in the coefficient estimates of the included predictors.
On page 150, Therneau and Grambsch also say "a finding of lack of proportionality should lead one to check functional form diagnostics." Something as simple as a log transformation of a predictor might provide adequate PH.
It's also possible that the underlying survival phenomenon doesn't follow PH. As Therneau and Grambsch note, an accelerated failure time (AFT) or an Aalen additive model might be called for instead. (A Weibull model assumes both AFT and PH, so use a different AFT distribution if you want to deal with a PH violation.)
With this large a data set, you presumably have an opportunity to evaluate such possibilities in some detail. You might not have to limit yourself to accepting the violation of PH.


How to detect low battery under load?

Question: I was measuring the voltage across a 12v VRLM battery when I noticed something : the battery had 11.7 volts without the load and when the load was added, the voltage dropped to 11.4. I don't want to have to disconnect my battery just to get a low battery indicator to work properly. How can I know if my battery is low when I have it "in use"?
Comment: How close to the battery were you measuring this voltage?  When current is drawn by the load, there will be resistive loss between the load and the battery, and this will lower the voltage measurement, in proportion to the current drawn.  There is also a loss within the battery, in the connection between cells.
Answer: You decide what the "low" threshold voltage level when the battery has its load on it. This way you will know when the battery gets to critical level of capacity corresponding to what load it is expected to power. Trying to do this when the battery is unloaded will not give you a realistic in system usage scenario.
Think about your car. Its battery stays connected to the alternator / voltage regulator all the time -- unless you remove the cable to do service work.
Comment: So If I had a varying current draw at different times, I would have to have an amp meter to help calculate?
Comment: @skyler - The in system usage of the battery may have to be characterized for a certain load. Some systems have an average load that does not change too much. Others have loads that will vary a lot depending upon what is happening at the time (i.e. sometimes a big motor may be on and other times it may be off). One strategy you could use would be to measure the voltage for low battery tests when the system is in the known highest load mode. It would not necessarily be necessary to have an load current measurement if your system can be characterized at that load. (continued)
Comment: (continued from above). You could also choose to use another known system state at a lower battery draw to make your measurements. It would also be possible to measure at multiple states if each was characterized.
Comment: On the other hand you could just determine the worst case voltage that you can let your battery get down to and then measure the voltage frequently while the system goes through various levels of current draw on the battery.

How to detect low battery under load?


When is work done by static friction force positive and when is it negative?

Question: So we say that a work done by a force is positive when both the force as well as the displacement of the body are at acute angles with each other. With this logic, consider a man standing on a plank which is placed on a smooth horizontal surface. Now the man starts running over the plank and the questions asks us whether the work done by friction on the man w.r.t ground frame is positive or negative. Applying Conservation of momentum, we know that from ground frame, the displacement of man will be towards right and also the friction force on the man is towards right, so answer should be positive work done, BUT, the answers says the following: At the point of contact, man's foot is moving backwards and friction force acts forwards, so work done is negative! How? i don't understand this solution, please help.
Comment: How is the mans foot moving backwards? Only when it is off the ground.
Comment: how do we move forward, we press the ground backwards and so our foot moves backwards thus pushing us forward.
Comment: See https://physics.stackexchange.com/q/480860/
Answer: The reason for your confusion is very simple: you have a misunderstanding of exactly what "displacement" means in the definition of work.
When you're calculating work done on an object (for example, a person) by a certain force, the displacement you need is NOT the displacement of the whole object! Instead, you need the displacement of the exact point/part of the object to which the force is applied.
That's it, that's just how work is defined. So it doesn't really matter at all where the whole person is moving, the displacement you care about is (by definition of work) the displacement of the exact part of the person to which the friction is applied, i.e. the foot.
Addendum: this is less important, but it seems that some people who commented on this question misunderstood the situation (which wasn't described very carefully by the OP). The person is trying to walk to the right along the plank, but the plank itself is on a slippery surface, so it's slipping to the left. So his foot is stationary with respect to the plank, but moving to the left with respect to the ground.
Comment: thanks a lot, this got my basics cleared!
Answer: In the frame of reference where the plank is stationary, the man is accelerating forward. In that frame, his foot is stationary, so static friction does no work. His leg pushes him forward. His leg does positive work.
In the frame where the man's center of mass is stationary, the plank and the world are accelerating backwards. This is a non-inertial frame, so it will be more complicated. There will be a fictitious force acting on the world, accelerating it backward. The force acts on the man, accelerating him backward. It is just enough to balance the force from the man's leg pushing forward. The total force on the man is $0$, which is why he stays still. Fictitious forces take a little getting used to.
In this accelerated frame, the man's foot is moving backward, trying to accelerate the plank and the world. The plank and world are moving backward. So the work done on the world is positive. The world is so massive that the man's foot doesn't change its motion noticably.
This might also help. Is work done in rolling friction?


Why is there an x in French deux?

Question: The Latin from which French evolved has duo, duorum/duarum, duos, and so on, while the contemporary French pronunciation also omits the 'x'. Why did Middle French spell deux with an x?
Answer: It is due to a confusion. In the middle age, the custom was to abbreviate the words ending by -us into -x. So "deus" was written "dex", this tradition was kept, but, afterward, it was added a 'u' into "dex". For further information: https://fr.m.wikipedia.org/wiki/Abréviation_médiévale#X_(-us)
Comment: Can you give an example where this word is written "dex"?
Comment: You can find some examples here (notably p. 121, "parmi les flans qu'en vos dex mains"): https://digilib.phil.muni.cz/data/handle/11222.digilib/128666/monography.pdf. I should point out in that time, in French, god and two were homograph both were written either "dex" or "deus". But, sometimes, in order to distinguish, the word 'god' was in upper case and the word 'two' was in small letter.
Comment: Thanks for the reference. But if "dex" is just a scribal abbreviation why haven't the editors expanded the abbreviation? I don't see any other abbreviated words in this text.
Comment: It seems that the editors have not taken into consideration some abbreviations. I have found "homes" (p. 116), the abbreviation of hommes (men), without a tilde on 'o' ("on" & "om" was abbreviated 'õ'). Probably, those kinds of font or keyboard with these symbols doesn't exist or are not widespread.
Answer: It comes from the Latin accusative plural masculine: duos. The oldest spellings in French are duos and deus, then deux, with x as an alternative spelling for final /s/, as in dix, yeux, and many other words. It is not true that the contemporary French pronunciation "omits the x"; the x is still pronounced (as /z/) in liaison.
More here: http://www.cnrtl.fr/etymologie/deux
Comment: And in _deuxième_, also as /z/
Comment: Its pronunciation in a liaison context is true, however /z/ does not even approach the latin/English x sound. The question was why medieval French writing started inserting x for -us in deus, another answer seems to say it began as a form of abbreviation.

Why is there an x in French deux?


Publish an alpha APK on google play developer console

Question: I want to publish my alpha APK on google's developer console. The question is whether it will be visible in the google play store? Or will it be only available for testers to whom I send the opt-in link?
Comment: https://support.google.com/googleplay/android-developer/answer/3131213?hl=en
Comment: It will only show to that particular account where it is uploaded and to whom your sending apk link must added on play store (their Google Id)
Comment: Thanks! I must say that this is really not clear from googles documentation regarding the topic.
Comment: Yeah google never could create any clean UI, in any of their services, google play, google analytics, google maps api, google whatever
Answer: If you publish it as Alpha version, it will be published on the Play Store but visible only for those subscribed to the tester program.
This is granted via the testing link provided when you link your Google+ community to the Alpha version APK.


Implementing NSCopy

Question: I'm a little confused on the correct way to make my class support NSCopy mechanics and I'm hoping someone can help clear things up for me.
The big question is this:
If my class is mostly immutatble except for a collections property, when I'm implementing the 'copyWithZone' method through NSCopy inheritance, do I need to do the version where I'm returning a self that had a retain called on it like this:
<code>- (id)copyWithZone:(NSZone *)zone
{
     return [self retain];
}
</code>
or do I need to do the other version that takes in to consider the policies used by NSCopyObject as outlined in the Memory Management programming guide published by Apple? (I've read a number of posts about how NSCopyObject is dangerous so one has to be careful with their implementations).
<code>- (id)copyWithZone:(NSZone *)zone
{
    NSCell *cellCopy = NSCopyObject(self, 0, zone);
    /* Assume that other initialization takes place here. */
    cellCopy->image = nil;
    [cellCopy setImage:[self image]];
    return cellCopy;
}
</code>
My class has ivars are a mix of primitive types, object types and an NSArray collection. I'm intending the class to be semi-immutable in the sense that clients cannot modify any of the intrinsic properties after the class was created initially but at some point the client will receive additional related data that needs to be appended to the class. Additionally, when clients are holding on to an instance, they should have their own copy instead of sharing it so it is a deep copy instance as opposed to a shallow copy.
The code:
<code>@interface MySampleClass : NSObject {
NSString *myName;
NSString *myTitle;
BOOL     isAFlag;

NSArray *aListOfProperites; // collection holds objects of another class named 'MySampleProperty'
}

@property (nonatomic, copy, readonly) NSString *myName;
@property (nonatomic, copy, readonly) NSString *myTitle;
@property (nonatomic, readonly) BOOL isAFlag;

@property (nonatomic, copy, readonly) NSArray *aListOfProperties;

-(id)initWithNameTitleAndFlag:(NSString *)aName title:(NSString *)aTitle flag:(BOOL)aFlag;

-(void)addProperty:(MySampleProperty *)aProperty;
@end

@implementation MySampleClass

-(id)initWithNameTitleAndFlag:(NSString *)aName title:(NSString *)aTitle flag:(BOOL)aFlag
{
    self = [super init];
    if (nil != self)
    {
       [self setMyName:aName];
       [self setMyTitle:aTitle];
       [self setAFlag:aFlag];
    }
    return self;
}

// all of my object setters do a 'copy' instead of retain or assign
-(void)setMyName:(NSString *)aNewName
{
if (aNewName != myName)
{
     [myName release];
     myName = [aNewName copy];
}
}
- (id)copyWithZone:(NSZone *)zone
{
// do I do a simple retain on the object or follow NSCopyObject policies?
}

@end
</code>
Answer: If your class was totally immutable, I would suggest a shallow copy. However, because it isn't, you're going to have to do a deep copy in order to avoid bugs (if anything makes a shallow copy of your class, expecting a deep copy, and then changes it, the original object will change as well, when it doesn't seem like it should). Do a deep copy.
Comment: Abel, if my response has sufficiently answered your question, don't forget to mark it as the answer! Thanks... ;)
Comment: Doing the deep copy makes sense. So what is the right way to implement 'copyWithZone'?
Comment: You can go about doing it like this: http://pastie.org/1241957 (this code is untested, but it should work - run tests on your own to confirm).

Implementing NSCopy


Does Skype Trump SSLStrip?

Question: I am using SSLStrip against my own computer, but am not being redirected to HTTP. Skype automatically starts up and logs in at my computer's startup, so I was wondering whether the fact that port 80 is already in use (by Skype) defeats SSLStrip. It is my understanding that except for the fact that they are being redirected to a non-encrypted connection, it is impossible for a victim (or their AV) to tell SSLStrip is being used against them. If that is correct I would like to know if anyone has a way to cause Skype to restart on the victim computer so I can get port 80.
Comment: Microsoft is ignoring the RFC's to address SSLStrip,  IE contains more known vulnerabilities than any other piece of activity maintained code. The reflective XSS filter is completely and totally non-functional.
Comment: Just thought of a possible way while writing the question, sending a DeAuth token to the browser and disconnecting them for a second. I will test and see if it works.
Answer: SSLStrip does not downgrade from HTTPS. It tries to prevent upgrade to HTTPS.
I think this is a misunderstanding of how SSLStrip works.
The idea is that SSLStrip stops plain text HTTP sites from upgrading to HTTPS. It will not work if you start by entering "https://" in your browser right away.
What it does is that it installs itself as a man-in-the-middles and then transparently forwards traffic largely without changing it. HOWEVER: If the HTTP page contains any HTTPS links then SSLStrip will "strip" these HTTPS links out and replace them with plain old HTTP.
So if your web server does not even speak plain text HTTP, on default port 80 or elsewhere, then you can't upgrade to HTTPS either. And in that case SSLStrip is not the right tool for whatever you're trying to do.
Answer: SSLstrip works by listening for https traffic and redirecting it to http.
For one thing Skype does not use http it uses its own proprietary protocol. For another they do not offer a non-encrypted version of their protocol the way https does with http so the concept of an SSLstrip type attack will not work.
For those reasons SSLstrip will not work against Skype.
Comment: This is true, but my question is asking if Skype will prevent SSLstrip from working at all by preventing it from binding to port 80.
Comment: Skype does not bind port 80, why should it?. And usually sslstrip is not running on the same computer as Skype does. Maybe your are missing some understanding of how client-server communication with TCP works, what the bind is for and who will do it.
Comment: @KnightOfNi I apologize if my answer was not clear. One way of using SSLstrip is to listen on an unrelated port like 1234. When traffic destined for a https port (443) passes through the attacker's computer, it is redirected to SSLstrip's port (1234), through firewall rules for example. Even if SSLstrip is running on the same machine as Skype, it is not a problem what port Skype wants to use.
Comment: When I was working with SSL-inspection, Lync (Lync later became part of Skype for business) proved impossible to decrypt due to SSL certificate pinning. I do not know if Skype does the same.

Does Skype Trump SSLStrip?