What language are compilers written with?

Question: Are compilers written in different languages than the language they compile?
Answer: There are three languages involved in a compiler: the language being compiled (source language), the language being compiled into (target language), and the language that the compiler is written in (implementation language).  In general, the implementation language is either a general purpose language like C or C++, or the source language.  The target language can be some language suitable close to the source language that already exists, or assembly.  Sometimes there is a custom intermediate language, so that there can be a common backend for a variety of languages.  This is the way that gcc works.  There is a front end for C, C++, Fortran, Ada, and probably others.  Each one is compiled into the same intermediate language, which is then compiled into architecture specific assembly language.
If the compiler is written in the same language as the one it's compiling, the compiler is called self-hosting. If a language is new, then no compiler exists for it already, which means that its first compiler cannot be self-hosting (otherwise, how would that first compiler be compiled?). As a result, the first iteration of any compiler for a new language is always written in a different language. That having been said, a self-hosting is more convenient; the author(s) only need to be proficient in one language.
Answer: You can write a compiler in, theoretically, any language. Even the one you're compiling.
Comment: You could write a C++ compiler in Fortran, but you certainly wouldn't want to.
Comment: i think i'd rather write that C++ compiler in Fortran than in Javascript...
Comment: I say that because I've never seen, for example, a compiler in Javascript. It may or may not be possible, as I've never seen everything Javascript has to offer.
Comment: why theoretically?what do you mean by that?
Answer: From a little study I made few years ago (2010):

Ocaml ocaml:
parser: (o)caml
core: C
C++ g++:
parser: C
core: C  (now c++)
->  early generated with bison then hand written
D dmd:
parser: C
core: C
Haskell GHC:
parser: haskell (+ C)
core: Haskell
-> formerly in LML
C gcc:
parser: C
core: C
-> formerly BCPL / asm
SmallTalk:
SmallTalk
Lisp:
Lisp
Answer: There's a lot more information about this over at Stack Overflow, like What is the best language to write a compiler in?.
More related at SO
I know questions get moved here from Stack Overflow, but I don't know if it works the other way around too.


removing excess paint on a nick touchup

Question: i dropped a spark plug on the fender of an $8000.00 paint job. i touched up the 2 nicks ,but have a little excess paint outside of nicks. any suggestions on how to remove the excess? i used a product called rub out or rub off  after touching up road rash on my fender flairs at the wheels. worked great but i have misplaced it & don,t remember who made it. any help would be grateful. thanks
Answer: Use 3000 grit sandpaper, then you need a rubbing compound to take out those swirl marks.
Buy meguirs swirl remover it is an amazing compound you can only get it at professional paint supply or lordco ( from Canada) or a parts store it comes in a brown bottle.
This is the professional way.  More professional is probably use 800 grit 1000 grit 1500 2000 then 3000. then swirl remover or cut polish then polish.

removing excess paint on a nick touchup


Using QField to connect to external Bluetooth GPS

Question: I am using QField for field data acquisition. Can QField connect to an external Bluetooth GPS?
Comment: Hi @abbey, if any of these answers solved your issue, accepting the most according it as the right answer will help other's to finde help here, if they have the same issue.
Answer: If you want to use an external GNSS-Reciever on QField in your (Android?) mobile you need to connect your mobile (phone or tablet) to the GNSS using a separate app that provides a mock location to your device.
The app you should use depend on the GNSS brand and configuration. The official QField guide suggests, as for example between several options, Android NTRIP Client.
To use this you have to enable mock locations on your Android device: e.g. if you are using a Leica a good app is Leica Zeno Connect, while Stonex works with Cube Connector.
Comment: This is actually not necessary any more (unless you want to use a correction signal). See the comment below.
Answer: UPDATE: QField supports this native now - no mock location provider required
@Val P pointed out correctly a possible way. I have sucessfully used the NTRIP Client, too. Since QField 1.8.0 there's now a native support built into QField, i.e. you can connect to Buetooth-paired devices from within QField:
https://qfield.org/docs/fieldwork/gps.html <- explanation
https://github.com/opengisch/QField/releases/tag/v1.8.0 <- release notes
How to set it up:
in QField: Settings > Positioning > Positioning device in use: > Scan you can now select from a drop-down via Bluetooth connected devices.
Here's more informations on this: https://qfield.org/docs/prepare/gnss.html#gnss-variables
NOTE: I have not found information about the following things, which you can make use of via NTRIP-client and that do increase accuracy

Unsure if correction via SBAS, WAAS, EGNOS etc. is possible --> YES, see the comment below.
It is not documentet if RTK correction is integrated there, I guess not, otherwise it would be noted in the documentation + there should be a setting in QField. So if you want to use this, you still need to go for the solution using the mock-location feature. --> NO, see the comment below (unless it's already integrated into the RTK-antenna (e.g. reach rs2)).
Comment: SBAS correction configuration can be saved in SiRF or uBlox modules, so you can often set up SBAS corrections on a different platform and then move to the target system.  For example, connect a uBlox-based Bluetooth GNSS to a Windows PC and run the uBlox uCenter application, configure SBAS, then save the configuration.  When you connect to the receiver using QField, SBAS should be used. RTK needs to be fed to the receiver by your application or by some support application.
Comment: QField does not do any RTK correction. It will however work happily with any antenna that does already implement RTK correction.
Comment: @Vincé to be precise, for many antennas RTK works also without mock location as they send this information through bluetooth/nmea (tested with e.g. reach rs2)
Comment: Thanks. I'll update my response.
Comment: Thanks @Matthias, I updated my comment. QField is making nice progess :)
Comment: @Matthias, thanks. I'll update my response


Microsoft Teams file sharing support for on-premises SharePoint

Question: We are using Office365 with Microsoft Teams. I need to know whether there is a solution we can use to connect Microsoft Teams groups in order to receive and store files on SharePoint on-premise instead of Online? Is there a connector that can do that? If this is not an option, is there any other chat software that can integrate into SharePoint?
Answer: Short answer to your question is No.
Microsoft Teams is not available for SharePoint on-premise. It's basically a chat-centered workspace in Office 365.
However it is possible for hybrid environments. Check more details at:
Microsoft Teams integration with SharePoint Server 2013 Enterprise.
Also check below question if it helps you just to show the documents in Microsoft team:
Microsoft Team integration with on premise SharePoint


what does it mean for a prime at infinity to ramify?

Question: I understand what it means for a prime number to ramify in a ring of integers of a number field. However, an infinite prime is an archimedean valuation, what does it mean for an archimedean valuation to ramify in a number field?
Comment: Another way of saying it is that a real place (i.e. an embedding of your number field into $\mathbb{C}$ with image in $\mathbb{R}$) ramifies if it extends to a complex place (an embedding into $\mathbb{C}$ with non-real image). A complex place can never ramify in an extension. For an Archimedean place, splitting and being unramified are the same.
Comment: @Keenan I think you should leave that as an answer, simply in the interest of not having unanswered questions.
Comment: Look at the archimedean valuation that are induced by the different embeddings of the number field into $\mathbb{C}$; each embedding yields an archimedean valuation that "extends" (or "lies over") an archimedean valuation of the base field; the archimedean valuation *splits* if all these extensions are different, and *ramifies* if some of them are the same (just as when you look at the primes $\mathfrak{q}_i$ lying over $\mathfrak{p}$). Consider how to extend the absolute value of $\mathbb{Q}$ to $\mathbb{Q}(i)$, and to $\mathbb{Q}(\sqrt{2})$; the first is an example of ramification.
Answer: On Alex's request I'm leaving my comment as an answer. Let $L/K$ be a finite extension of number fields. A real place $v$ of $K$ (which can be thought of as an embedding of $K$ into $\mathbb{C}$ with image contained in $\mathbb{R}$) is said to ramify in $L$ if it extends to an embedding of $L$ into $\mathbb{C}$ with non-real image. If all extensions of $v$ to places of $L$ are real (the associated embeddings have real image), then $v$ is unramified (also said to be split) in $L$. A complex place of $K$ (an embedding into $\mathbb{C}$ with non-real image) is always unramified. So, the extension $L/K$ is unramified at $\infty$ if all the real places stay real.
For example, in the extension $\mathbb{Q}(\zeta_p)/\mathbb{Q}(\zeta_p+\zeta_p^{-1})$, where $\zeta_p$ is a primitive $p$-th root of unity for some odd prime $p$, the base field is totally real (all its Archimedean places are real) while the top field is totally imaginary, so all real places ramify in the extension.
Comment: The above definition of ramification for real places is the usual one, justified e.g. by the ramification index 2 which appears in a complex valuation over a real one (see Joequinn's answer). However the same phenomenon could also be interpreted as the splitting of the real place under the complex one. In many arithmetic problems, especially in CFT, 2 does not behave like the odd primes, and  the classical definition requires special statements at the prime 2. This inconvenience is removed when using the second definition, see e.g. G. Gras' book "CFT. From theory to practice", Springer, 2003.
Comment: Dear @SanaCHALLI, Normality is irrelevant for the definition.
Answer: I think it's worth adding that while Keenan's answer is a good one, that this is not usually what's given as the definition.  I think this issue can be confusing in the literature because in the case of number fields a lot of the relevant constructions become trivial, but it's often not mentioned what the punch line is.  So, although this question is old maybe this will still help someone.
The Archimedean valuations on a number field $K$ come from the possible embeddings $\sigma:K\rightarrow\mathbb{C}$ (which you can also identify with $Gal(K,\mathbb{Q})$).  For each such $\sigma$, if its image lies in $\mathbb{R}$, the valuation is $v_{\sigma}:x\mapsto |\sigma(x)|$, but if its image does not lie entirely in $\mathbb{R}$, then $\sigma$ and $\overline{\sigma}$ both yield the same valuation $v_{\sigma}:x\mapsto|\sigma(x)|^2$.
Now fix an infinite place $v$ on $K$, let $L$ be a finite field extension of $K$, and let $w$ be an extension of $v$ to $L$.  The extension is said to ramify at $w$ iff $\#\{\tau\in Gal(L,K)\mid w\circ\tau=w\}>1$.  But in reality this all simplifies to what Keenan said.  The only possibilities for $\tau$ satisfying $w\circ\tau=w$ are the identity map and complex conjugation.
Moreover, if $v$ is a real embedding and $w$ is not, you will always have the option of $\tau$ being complex conjugation, so the extension will always be ramified there.  And if the situation is any of the other possibilities ($v$ real & $w$ real; or $v$ non-real & $w$ non-real), then $\tau$ can only be the identity, hence not ramified.
Comment: I realize I'm resurrecting an ancient post here, but do you happen to know a reference for the definition of ramification you give here? If I'm understanding correctly you're saying that the extension ramifies at $w$ if the size of the decomposition group is greater than $1$. I find this strange because for finite places which are unramified the size of the decomposition group can certainly be larger than $1$. It's rather the size of the inertia subgroup that tells you whether the place ramifies.
Comment: @wgrenard I'm not sure of the exact reference right now, since it's been a while, but recall liking Keith Conrad's way of writing about this. I recommend searching some of his content; he's pretty generous about sharing articles online.


windows 10 and ubuntu dual boot

Question: will we face same problem in installing ubuntu alongside windows 10 as we  faced while installing ubuntu alongside windows 8? Did microsoft fixed it?
Comment: And what was the problem with Windows 8?
Comment: grub 2 problem......my computer directly gets booted in windows 8 i tried nearly everything but couldn't fix it
Comment: You did not install Ubuntu correctly. It can be fixed. There are lot's of answers about it. You better clarify your question.
Comment: i followed these steps http://www.everydaylinuxuser.com/2014/05/install-ubuntu-1404-alongside-windows.html
Comment: i am talking about that secure boot , hard boot and some UEFI thing. i read that above things are what causes problem in dual boot
Comment: http://askubuntu.com/a/228069/167850
Answer: Let me write about some of problems to help other people who might encounter the same issues.
My computer came with Windows 8 pre-installed so I shrunk the Windows partition to make room for Ubuntu. That it how it works for the last year.
After the second reboot in Windows 10 upgrade the computer did not boot any more. The grub only displayed a grub rescue command prompt. I found out later that the problem occurred because windows somehow changed the partition scheme. The boot partition was no longer where grub expected it. I don't know how and why this happened.
First what you can do is to see the partitions in grub rescue with "ls". Mine were (hd0,gpt1), (hd0,gpt2), etc. Try to find out which partition is your boot partition. I tried the following commands until i found the right partition:
ls (hd0,gpt1)/

ls (hd0,gpt1)/boot

ls (hd0,gpt2)/

etc.
Then type set in grub rescue prompt. It will display where the grub looks for its files. In my case (hd0,gpt6) has moved to (hd0,gpt7). The set command displayed:
prefix=(hd0,gpt6)/boot/grub

root=hd0,gpt6

Change the prefix and root settings to point to the right partition. In my case commands were:
set prefix=(hd0,gpt7)/boot/grub

set root=(hd0,gpt7)

Then switch from rescue to normal mode:
insmod normal

normal

You should get the normal grub menu. From now on you can boot Windows and finish your Windows upgrade. The problem is that you have to tell grub rescue about the right partitions on every reboot. That is how I did it. I left the problem of grub for later because I was not sure whether Windows will do some more changes to the partitions or boot.
When Windows finished I started to solve grub problems. Press "e" to edit boot options for Ubuntu. I changed all (hd0,gpt6) to (hd0,gpt7) and Ubuntu booted. However, I use encrypted partition and cryptswap. At the boot Ubuntu asked me for the passphrase. Fortunately I saved it at the installation of Ubuntu and entered it at the boot. Ubuntu booted without problems. I corrected the /boot/grub/grub.cfg where I replaced (hd0,gpt6) with (hd0,gpt7) and performed sudo grub-install.
Now it was only the encryption. Since the root Ubuntu partition was raised for one (7 from 6), the swap partition suffered a similar change. I had to change the /etc/crypttab file to point to /dev/sda8 instead of /dev/sda7.
I am using only two partitions for Ubuntu (root and swap). If other operating systems coexisting with windows use more partitions there might be more changes required. Especially if partitions are mounted according to their numbers and not by their UUIDs. Take a look at your /etc/fstab. If the partitions are identified by UUID there should be no problems. But if there are /dev/... lines the number should be corrected if they were changed.
Comment: Does this problem occur for every upgrade to Win 10? Or did it happen only to nobody?
Comment: It does not happen for every upgrade. Unfortunately I don't know why and when it happens.
Comment: After a windows update, my grub run into problem. This solution solved it perfectly. Thanks. It turned out that windows changed my linux boot partition number from 2 to 3.
Answer: I believe the rEFInd Boot Manager works for this:
http://www.rodsbooks.com/refind/
Here are some other boot loaders to consider:
https://en.wikipedia.org/wiki/Comparison_of_boot_loaders

windows 10 and ubuntu dual boot


MS Access, How to determine the command line parameters that the current instance of application has started with?

Question: I need VBA solution to get the command line parameters which has been fed to MS Access at the start up of the current instance of the application. e.g. if it has been started as Runtime and etc
Answer: I don't believe you can get the full command line used to start Access. However, you can certainly add a /cmd option to the startup swtichs, and VBA "command()" will return these values.
thus:
The VBA function command() will return the values after the /cmd
Thus:
A typical startup command line would look like:
"C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE"
"c:\MyCoolProgram\MyApp.accde" /runtime /cmd "Parm1" "Parm2"

The above would be all one line (with a space between). To grab the two passed parms, then
Debug.Print Split(Command(), " ")(0)
Debug.Print Split(Command(), " ")(1)

You can also test if the application was launched with /runtime switch, or that you using the runtime version with this:
If syscmd(acSysCmdRuntime) = true then
   ' runtime version

So you can specify and pass startup parameters with the /cmd startup swtich
Comment: Thanks for help! How the difference between MS-Access run time version and regular ms access which has started with command line /Runtime can be determined if the syscmd(acSysCmdRuntime) is true?
Comment: Actually the "whole" idea of the /runtime switch is to 100% emulate and make the full version of Access behave EXACTLY like the runtime. So if you are testing, or developing a runtime version, then this switch will force Access to behave just like the runtime. (and you cannot install both runtime and full edition on the same computer). If using runtime only edition, then runtime switch is not required. If you must test, then use createObject("Access.Application") as that is not supported in runtime edition.


How to find treasure maps in Red Dead Redemption 2 Online?

Question: The only time I've ever got a treasure map, was when I leveled up and got it from the post office. But, that only happens every couple of levels. Is there a way I can buy or steal a treasure map from someplace without having to level up?
Answer: It is possible to find random NPCs around the map that will sell you treasure maps. Additionally I have managed to find one on a free roam mission (I believe it was a bounty for me) just on a corpse I looted. So just keep looting corpse and keep an eye on your radar for white blips. It might be a map seller.


Remove half opaque pixels when rendering final image

Question: Im doing some work to test styles with a model i came up with. In those styles i wanted to test how it would look like if it were to mimic a prerendered snes sprite, like from the Donkey Kong Country series or Super Mario RPG. The only problem is these pixels that are part of the sprite but have some alpha in it. These half opaque pixels break the whole pipeline i have to treat the sprites and make them look better for the style. Heres how i get them from rendering in blender and after some color reduction and other treatments:

Answer: Just tweak the Film > Filter Size option to 0.00px in the Output side bar menu:


How to decode the event logs in polygonscan mumbai?

Question: This is my transaction hash: https://mumbai.polygonscan.com/tx/0x79ed502a8d319ab3b278781042898115d9d6bece15d3d91626a7a6a39c0873b3#eventlog  The event logs of the event DataCredentialized is not human readable. I am not sure how to decode these logs. It would be helpful if someone could help me with a javascript code to decode these logs. Thanks in Advance!!
Answer: The transaction you linked emits the event DataCredentialized:
event DataCredentialized(bytes32 indexed viewToken, string indexed ipfsUrl);

Taking a closer look at the contract, you will find a viewer function called  viewCredentializedData() that allows you to decode the data by passing the argument retrieved from the event log.
Comment: at left of of `Topics 1` choose `Hex` then copy that data and paste in. `https://mumbai.polygonscan.com/address/0xc47d9b99fcf7c3d71630f6987a29002183902e43#readContract` at `viewCredentializedData` first argument then `Query`
Answer: It seems you cannot decode these logs. The hex values are hashed with the keccak256 function which makes it nearly impossible to get the original values.
In your case you have two indexed topics:

0xa73d61b387464bf2a657f753d27d72552be88c48d7b0e3adc6a3413fb0b01e2d
0x93896ac593a0be8d1921c503fdc75208d8b9d573d83b479b03916c5a6b5781db

Where the 1. value was hashed in the contract with keccak256
The 2. value is also a Keccak-256 hash. Since you wanted to emit a reference type (memory string). You can read more here about Events.


How do you load the Android bitcoin backup key onto Bitcoin Qt?

Question: I have an Android wallet key and I want to load it onto my windows desktop. I am using Bitcoin-Qt, but i dont see an import option anywhere. How can this be done?
Answer: The backup file produced by the Android Bitcoin app is a text file containing lines of the form

5Jhvcnoi9LFxEcg68gTaDB3DiKEJ6TWJuMmyfjv89uEv3AbgdV 2013-01-01T12:34:56Z

The first field is the private key.  This can be imported into bitcoin-qt using the importprivkey command.  Choose "Help > Debug window", go to the "Console" tab, and enter:

importprivkey 5Jhvcnoi9LFxEcg68gTaDB3DiKEJ6TWJuMmyfjv89uEv3AbgdV

where you paste in the private key from the file.  bitcoin-qt will be unresponsive for several minutes while it searches the blockchain for existing transactions involving the new address; this is normal.
Comment: in my case the file doesn't look this way but rather a much longer series of baseXX characters
Answer: This guide was the only one that worked for me. My encypted backup file didn't had the mentioned format, and other guides that explained how to export the nmonic seed didn't work either with wallets like electrum or electron cash, but the exported private key as described here did:
https://bitcointalk.org/index.php?topic=2061691.0
Answer: Please follow the documentation here:
https://en.bitcoin.it/wiki/How_to_import_private_keys_v7%2B


How to show that no. of elements $x$ of group $G$ such that $x^3=e$ is odd?

Question: Let G be a finite group G. Then How can I show that no. of elements $x$ of group $G$ such that $x^3=e$ is odd ?
I read this question in an Algebra book. Since $e^3=e$, e must be one of those elements. But how to find for non trivial elements ?
Comment: it might be useful if you see that you are being asked to show number of elements of order $3$ are even.... Do you believe that showing this is easy?
Answer: Let $T$ be the set of all elements $x$ in $G$ such that $x^3=e$. Since $e\in T$, we will prove that $S=T\setminus\{e\}$ has an even cardinal.
Details are left to you:

If $x$ belongs to $S$, then its inverse $x^{-1}$ is also in $S$.
If $x$ is in $S$, then $x\neq x^{-1}$.
Every element of $S$ can be paired with another element of $S$, so $S$ has an even number of elements.
Comment: Thank you Taladris, your solution is too simple.
Answer: Every element $x$ such that $x^3 = 1 $ is contained in a subgroup $H_x$  of order $3$.
2 different subgroups of order $3$ can intersect only in $1 \in G$, and so the elements such that $x^3$ are $$\lbrace 1 \rbrace \ \ \bigcup \ \ \bigcup_{H_x} \biggl( H_x \setminus \lbrace 1 \rbrace \biggr)$$
In total $2k + 1 $ elements.
Answer: If $x$ is an element of order 3, then $\langle e, x, x^2 \rangle$ is a cyclic subgroup of order 3 in the group. Notice that $x^2$ also has order 3.  For each $x \in G$ of order 3, there is a unique element $x^2=x^{-1}$ which is $\ne x$ and which has order 3.  Thus, the number of elements of order 3 in the group is even.  Since $e$ also satisfies $x^3=e$, the number of elements $x$ such that $x^3=e$ is odd.
Answer: We claim that the number of elements in $T = \{g\in G: g^3 = e, g\neq e\}$ is an even number $N$. The claim follows from recalling that $e^3 = e$, hence the number of elements with trivial cubes is $N+1$, an odd number.
In fact, if $g\in T$, then $\{g,g^2,g^4...\}\subset T$, so, since $T$ is finite, there is a minimal number $N = |T|$ such that $g^{2N} \in T$, and moreover $g^{2N} = g$ since $N$ is minimal. Suppose by contradiction that
$$
2^N-1 = 1 \bmod{3} \text{ or } 2^N-1 = 2 \bmod{3}.
$$
Then, respectively, $g^{2N} = g^2$ and $g^{2N} = e$, both which cannot be since $g \neq g^{-1} = g^2$ and $e\notin T$. Hence
$$
2^N-1 = 0\bmod{3}.
$$
By induction, this is true if $N$ is a non-zero even integer, since $2^2 -1 = 3$ and
$$
2^N = 1+3k \implies 2^{N+2} = 1 + 3(k+1).
$$
Moreover, it follows that $2^{2N+1}-1 = 2 \bmod{3}$, hence $N$ is even. This completes the proof.


$watch inside a service?

Question: Is it possible to set up a $watch on an array of objects inside a service (I'd like the $watch declaration itself to be inside the service)?
Answer: You can add any expression to the set of watches by injecting the $rootScope and using a function a first argument to the $watch method. Pseudo-code:
$rootScope.$watch(function() {
  return //value to be watched;
}, function watchCallback(newValue, oldValue) {
  //react on value change here
});

Don't forget about the third, Boolean argument to the $watch method. You need to specify true if you want to deep-watch an entire object for changes.
Comment: @btm1 I don't think your comment is accurate. What gets watched here is a _result_ of a first function call. There is nothing like "watching the rootScope for the entire application", there is no such concept at play here.
Comment: I've created a jsfiddle example to demonstrate how this works: http://jsfiddle.net/gvJdn/158/
Comment: Is this really the best option? I think this encourages a 'add the rootScope' everywhere which i (when I was a beginner was guilty of) injecting rootScope like I was adding semi colons. It's tough :D
Comment: if you don't mind, i would like you to show us how you reference the returning service value from the first function. I tried my best, but didn't succeed watching for changes. The same value was constantly being returned, over and over.
Comment: This doesn't help as it's watching the rootScope for the entire application.
Comment: @Karl : this is working only when the array is being modified through push method. If I directly initialize the array with another, then it isn't working. (the ng-repeat is not reflecting, but console.log shows modified array) Any specific reason ?
Answer: services by their very nature are like classes and house methods. You can set up a method which you call from your controller who's argument is the scope and applies a watch expression:
app.service('myservice',function(){
    this.listen = function($scope) {
        $scope.$watch(function(){return someScopeValue},function(){
           //$scope.dosomestuff();
        });
    }
});

//your controller

function myCtrl($scope,myservice) {
    $scope.listen = function() {
        myservice.listen($scope);
    }

    //call your method
    $scope.listen();
}

update: If you are trying to watch a private local variable inside of a service, see the accepted answer using $rootScope.  If you are trying to $watch a $scope variable within a local scope than the above is your best bet. They are achieving two very different things.
Comment: That may seem like a dumb question but why are you putting `myservice.listen($scope)` inside a function? Is it for easily reusing it throughout the code or is there some important reason? Besides, if I put the $watch in a factory, will it still work?
Answer: Can you clarify what you want to achieve? As I understand, you are getting an array of objects from the server as your model. Then it's not clear:

Do you want to verify if some objects in the array have been changed
(maybe since the last call to the server in case you do recurrent
pooling)?
Do you want to verify if some objects in the array have been changed by the user via some front-end control elements?

In case 1, you don't really need to use $watch (or rather $watchCollection) but you should iterate through the array you received from the server and verify the changes (the same what $watchColleciton would do). In case the object is different to the one you currently hold - you call object.$save() on this element.
In case 2, use $watchCollection()  on the $scope passed as a parameter to your service function or use $rootScope if you hold your array in the $rootScope.
I can provide you with real code if you would clarify the scenarios.
Answer: Hey just had a situation where I had a pretty big watch setup on 2 different controllers.
As I didn't want to duplicate any code I just defined to function in my service :
angular
    .module('invoice')
    .factory('invoiceState', function () {
        var invoice = {
            client_info: {
                lastname: "",
                firstname: "",
                email: "",
                phone: "",
                id_client: "",
                ...
             }
        }
        invoice.watchAccommodation = function (newVal, oldVal) {
            var accommodation = newVal;
            //Whatever you would normally have in your watch function
        }

Then I can just call this function in the watch of any controller into which I injected the service
function NewInvoiceCtrl(invoiceState) {
    $scope.$watch('invoice.accommodation',invoiceState.watchAccommodation, true);
}

I do not have much experience with AngularJS so I can't really go into the performance aspects of this approach but it works ;)

$watch inside a service?


How come divergence of $\vec E$ is zero in this case where $\vec E=\xi\frac{\left[x,y\right]}{\sqrt{(x^2+y^2)^3}}\,?$

Question: I hope you could help me clearing some doubts about Gauss' law of the electric field that states $\epsilon_0\nabla\cdot\vec E=\rho$. Take for instance the case of a point charge in the origin in empty space. The law states $\nabla\cdot\vec E = 0$ anywhere but the origin, but it's enough to compute $\nabla\cdot\vec E$ to get to a contradiction: $$\vec E=\xi\frac{\left[x,y\right]}{\sqrt{(x^2+y^2)}^3}$$ where I dropped every constant to $\xi$ because that's my favourite greek letter, and considered the 2D case since in my opinion it's a good compromise between complexity and meaningfulness
$$\nabla\cdot\vec E=-\frac{x^2+y^2}{\sqrt{{(x^2+y^2)}^5}}=(x^2+y^2)^{1-\frac{5}{2}}$$ which is clearly not zero except at infinity.
Comment: You can't just use any number of dimensions. Coulomb's law changes in 2D.
Comment: your divergence is wrong - you did not calculate the derivative correctly
Comment: You misunderstand Gauss's Law - you have given the differential form, but have ignored that it comes from the divergence of the E field, meaning an integral over a surface enclosing a volume.
Comment: Jon Custer, may you explain further this point? I know this law comes from the "global" one which states that the electric flux through a closed surface is the inner charge (which I have understood well, actually), I also know the mathematical derivation of the "local" law, but it appears i haven't understood what does it actually mean
Comment: Sanya, Javier: even without doing calculations this doesen't sound right to me: the electric field due to a charge is made of radial vectors pointing toward or outward the charge, with amplitude decreasing with distance. Since the amplitude is decreasing, mathematically speaking every point in space will have both $\vec E$ and its derivatives different from 0, so there's no way $\nabla\cdot\vec E$ is also zero. From the intuitive point of view, every point has a polarized direction through which more field enters than it leaves, thus having a nonzero divergence.
Comment: Ok, just to be sure I made again the calculations for 3D and Javier was right, but still I can't understand why
Comment: it seems to me your intuition of "it decreasing" is a 1D concept. Of course it is decreasing, but we are not looking at a 1D derivative but at a sum of derivatives ... A divergence is NOT a gradient which has a direction.
Answer: As pointed out in the comment, Gauss' law has a precise geometric meaning and so is strongly dependent on the dimension of the space. Let's work in 2D as in your example and apply Gauss' law: the flux of the electric field through a circle centered in the point charge is
$2\pi rE$. This must be equal to the total charge which is $e/\epsilon_0$. This gives for the modulus of the electric field:
$$E=\frac{e}{2\pi\epsilon_0 r}$$
and for the cartesian components:
$$\vec{E}=\frac{e}{2\pi\epsilon_0}(\frac{x}{x^2+y^2},\frac{y}{x^2+y^2})$$
As you can verify the divergence of this is zero:
$$\nabla\cdot\vec{E}\propto\frac{1}{x^2+y^2}-\frac{2 x^2}{\left(x^2+y^2\right)^2}+\frac{1}{x^2+y^2}-\frac{2 y^2}{\left(x^2+y^2\right)^2}=0$$


ola hallengren @databasesinparallel parameter on Azure SQLServer

Question: I have a serverless azure sql server instance with about 50 databases and I am trying to get the @databasesinparallel parameter to work to reindex all databases at the same time rather than one at a time. I get error The value for the parameter @DatabasesInParallel is not supported. Does this not work for azure serverless instances?
Comment: You can figure this out really easily by opening Ola's script and searching for the `@DatabasesInParallel` parameter.
Comment: Not sure you can do cross database calls in Azure anyway
Answer: The relevant code section from the IndexOptimize procedure shows there are two situations that can cause that error:
  IF @DatabasesInParallel NOT IN('Y','N') OR @DatabasesInParallel IS NULL
  BEGIN
    INSERT INTO @Errors ([Message], Severity, [State])
    SELECT 'The value for the parameter @DatabasesInParallel is not supported.', 16, 1
  END

  IF @DatabasesInParallel = 'Y' AND SERVERPROPERTY('EngineEdition') = 5
  BEGIN
    INSERT INTO @Errors ([Message], Severity, [State])
    SELECT 'The value for the parameter @DatabasesInParallel is not supported.', 16, 2
  END

Assuming you're passing in 'Y' for the parameter value, the reason for the error is that SERVERPEROPERTY('EngineEdition') is returning 5, which translates to Azure SQL Database.
Azure SQL Database does not support cross-database queries, so when automating Ola Hallengrens procs in Azure SQL DBs, the objects must be created in all target DBs and are executed individually. If you want to run the reindexing in parallel, I would suggest using Azure Elastic Jobs as these run in parallel across all target databases.
There are some limitations, they don't work with Azure SQL Databases using Private Endpoints for example, but for the most part, Elastic Jobs can perform the reindexing jobs just fine.
Some other alternatives:

Use Azure Automation and PowerShell Workflow to execute IndexOptimize. Workflows can be run in parallel.
Use a Logic App to execute IndexOptimize in parallel branches across your Azure SQL Databases.


Pushtopic transactions out of order

Question: We are seeing an "update" transaction coming before the "insert" transaction.  Replay ID of Insert is higher than the Update Replay Id.  Is this expected to happen?
Answer: This can easily happen. Push topics are not guaranteed to even be received via the streaming api. They are one way with no verification and are processed in the order they are received. In essence, there are no guarantees. If you want or need reliable transfer of data, you will want to create a REST API integration of some kind.
Comment: So the replay ids may come out of order correct?  Thanks

Pushtopic transactions out of order


How to share .bashrc files between two mac user accounts

Question: I have set up two user logins on my computer, one for home and one for work. I would like to be able to share any of my bash and vim settings between the two users. Is there anyway to do this? Thus far, I've been copying them from one account to another, but I'd like to be able to just have one file between the two so I can make changes in only one place. Is this even possible? Thanks.
Answer: You can use the ln tool to create a symbolic link:
ln -s /Users/user1/.bashrc /Users/user2/.bashrc

In this example you are creating a new link for user2 pointing back to the existing file in user1's directory. You may need to use sudo ln ... if the permissions are not set correctly.
Comment: In this context, it probably is better to hardlink, so deleting one user account does not delete the .bashrc file for the remaining account as well.
Comment: Even better, do this but put your bashrc in a shared Dropbox folder so it's available on every machine you use and it's backed up.
Comment: to do that, simply omit the `-s` option to the `ln` command
Answer: There are many ways to accomplish this, but the common idiom I've seen is to install a single file outside each user's home folder and have both ~/.bashrc files source in the common file.
This allows clarity, potential to make user-level changes at a later date, but also only maintain one file that will survive whether or not one or both users are deleted at a later date.
It's a little more work than hard linking the file and my experience in using soft links for this sort of thing is to avoid them since some tools don't handle soft (or sym) links as well as you might hope.
It's also far easier than using code control to deploy files, but that's also a great way to manage change if you are going to be setting up git or mercurial or another version control system anyhow.
Comment: +1 for this solution, I've implemented it with git here - http://github.com/balupton/dotfiles - the big benefit I've found is that I can easily install and use my custom configuration regardless of OS (osx, ubuntu, fedora, etc) as I can maintain their machine specific configuration just like normal but source in the common configuration that syncs between them.
Comment: When this answer states 'source in the common file' is this just a matter of copying the common file to the respective `.bashrc` files every time there is a change to the common file, or is there a more automatic way of doing this?
Answer: You could edit the system-wide .bashrc, which is located in /etc/bashrc.
If you are a bit familiar with Git however, you should consider creating a repository for your "dotfiles". You can use a free Github repository to do so. Tracking your dotfiles in such a way has many advantages:

You can fork or pull from one of the many public dotfiles repositories available, or draw inspiration from them
You can easily install and update the dotfiles across different user accounts and even different machines
You get revision control, which might save you from some troubles in the long run
Comment: Also the install gives you the correct permissions
Answer: As others have noted, you can do this with a symlink, but it's also important to appropriately change the permissions so that both users can access and edit the file.

Remove any existing .bashrc for user2:
rm /Users/user2/.bashrc

Symlink user1's .bashrc to user2's user directory:
ln -s /Users/user1/.bashrc /Users/user2/.bashrc

Change permissions so that both users can modify the file:
chmod +a "user2 allow read,write,execute" /Users/user2/.bashrc

Answer: Let one be a symbolic link to the other.
In terminal.app as user2 use
cd $HOME; ln -s ../user1/.bashrc


How does delaying on-chain randomness effect the security of number guessing games?

Question: Say a number guessing game allows users to submit their guess before block N and reveals the winning number N + 100 games later, which is random number based on the block hashes of block N until block N + 100. Is it still susceptible to any randomness attack?
Answer: It's most likely fine, but theoretically the block hashes are controlled by the miner, so in the case of a 51% attack, you could be at risk.  Adding things not controlled by a miner (like a nonce, a seed, a counter in your own contract, etc.) can make it better.
Answer: Well, here is one scenario that can affect the outcome. Say the winner will receive 20ETH. Alice, who wants to win the auction, can offer a bribe to a miner saying that if the block hash you have is not making me win, don't start the PoW. Assuming this miner doesn't have the majority of the hash rate, the chances of this attack going through are low.


USA to India via Turkey

Question: I have a layover at Istanbul airport for 13 hours and flying from the USA to India. I want to leave the airport to visit Turkey. Do I need a transit visa for 13 hours?
Comment: What citizenship do you hold?
Answer: UPDATE: Turkey is once again issuing e-visas to US citizens.  If you are a US citizen you can obtain an e-visa in advance for US$20, or a visa-on-arrival for US$30.

You haven't stated your nationality, however given your route I'm going to presume you are either a US or Indian citizen.
If you are a US citizen, then currently it is extremely difficult to obtain a visa for Turkey.  You will need to apply in advance at a Turkish Consulate, pay US$200, and only a limited number of visas are being issued.  (There are a few other alternatives such as if you are a resident in another country, but even these are complex)
If you are an Indian citizen, you can obtain a visa in advance via the Turkish e-visa system. This will cost you $43 and will be valid for up to 6 months.  You can also obtain a visa-on-arrival one you arrive in Turkey, however this will be more expensive, take extra time, and is generally not recommended.
Alternatively if you do not wish to enter Turkey then no visa is required to simply transit Turkey - presuming you are arriving in and departing from the same airport (there are 2 main airport in Istanbul - IST and SAW) - although 13 hours is a long time to spend in an airport (there is an air-side hotel to make the stay a little more pleasant, but it's not cheap!)

USA to India via Turkey


Is it safe to derive a Falcon512 key pair from a XOF output?

Question: I'm working on a program that requires multiple key pairs from multiple algorithms to be derived from a single 128-byte master seed. However, I couldn't find an implementation for Falcon512 that allows generating key pairs directly from the seed. Would it be safe if I passed the master seed through an XOF and extended it to the length of the Falcon512 secret key (which is 1281 bytes) and use that to recover the public key from?
Comment: [HKDF is your friend](https://crypto.stackexchange.com/q/76588/18298) Use $L$ to get the desired key size and **info** to derive multiple keys.
Answer: A KDF usually has stronger security requirements than a XOF. I've sometimes called a hash a "poor man's KDF" - it is probably secure but it hasn't been explicitly designed to be secure as a KDF, and it doesn't have a well defined input structure for additional input parameters (such as a label or a salt).
There have been some explorations to use SHAKE as a KDF, such as using KMAC("KDF", k, X) and cSHAKE. None of those have been standardized or studied well though, and using HKDF seems more logical in most circumstances.

As for your use case using the seed to derive the public key is only useful if you don't want to store the public key next to the private key for later (secure) distribution of said public key. The use case is limited.
I've heard a lot about storing the seed instead of private keys or key pairs for PQC. That's all fine, but it would be a good idea to then standardize the way of deriving the key pair from those - even though private keys do not have the same compatibility requirements as public keys. But there are certainly use cases where this might become an issue, e.g. when switching programming environment.
Comment: The problem is that the implementation that i use for HKDF(rust ring crate) doesn't allow me to derive a 1281bytes key, can't i derive a 64bytes child seed from the HKDF and pass the child seed through SHAKE512 to extend it to 1281bytes which is needed for Falcon512?
Comment: Yes, you can absolutely do this, but I've indicated the drawbacks above. Using a true-to-form KDF initially will at least theoretically make your algorithm a bit more secure. It's really a shame that no SHA-3 KDF has been standardized yet; in principle Keccak is able to perform all the "symmetric" functions in a crypto-system but it seems progress has stalled. I've looked at the Falcon spec again, but it just requires "enough entropy" for $f$ and $g$. They certainly do not explicitly specify how to generate those from a seed, i.e. no deterministic key pair generation is specified.


Finding period from action-angle variable in one dimensional potential

Question: I want to calculate the period from the action-angle variable for a particle in a one dimensional potential $V = V_0 \tan^2(q \pi/2a)$.
After doing some algebra I get $$I = \frac{\sqrt{2mE}}{2\pi}  \int_{q_1}^{q_2}\sqrt{1-\frac{V_0}{E}\tan^2{\frac{q\pi}{2a}}}dq.$$
Solving which gives me $$I = \frac{a}{\pi}\sqrt{2mE}\left(\sqrt{1+ \frac{V_0}{E}} - \sqrt{\frac{V_0}{E}}\right).$$ How can I get the period of the motion and how will it behave when $E\gg V_0$ and vice versa? Also how does this picture change if I change $a$ adiabatically with time?
Answer: The trick is to re-express the Hamiltonian in terms of the action variables. In your case this simply means to invert the expression $I(E)$ into an expression $E(I) \equiv H(I)$. This is then your Hamiltonian expressed in terms of action-angle coordinates. Finally, you can compute the evolution of the angle $\phi$ canonically conjugate to $I$ from Hamilton's equations of motion
$$\dot{\phi} = \frac{\partial H}{\partial I}$$
Notice that $\dot{I} = -\partial H/\partial \phi = 0$, $I$ is constant, and thus also the frequency $\dot{\phi}$ is constant for any trajectory.
You are also asking about the behaviour when $E \ll V_0$ as opposed to $E \gg V_0$. This is respectively equivalent to $I \ll a\sqrt{m E}$ and $I \gg a\sqrt{m E}$, as  you should directly verify. You will then see that in the leading-order limit of a small action, the rate $\dot{\phi}$ is independent of $I$ - the system behaves like a harmonic oscillator. However, for large actions (large energies) the frequency will have a steep dependence on $I$.
Good luck!
Comment: thanks for your answer. Would you be able to comment on how the energy of the system changes when I change $a$ adiabatically ?
Comment: @112358 Certain variables will adiabatic invariants. You can assume that $\dot{a}/a\ll \dot{\phi}$. How large will be $\dot{E},\dot{I}$ in that case?


Wood in water and buoyant force

Question: Wood doesn't sink in water because its density is less than water density. So $ΣF=0$. But what is the force that counterbalances the gravitational force if the wood does not sink in water so that there is no water displaced and hence no buoyant force?
Answer: You are working with the false assumption that the wood does not displace any water. This is not the case. The wood will be somewhat in the water, so there is still a buoyant force. This is the force that counteracts the gravitational force.
To be more exact, let's assume a rectangular block of base area $A$ and density $\rho_b$ in a fluid of density $\rho_f$. Since the block is as rest, we can equate the buoyant force and the weight (i.e. $\sum F=0$, as you said in your question):
$$mg=\rho_bV_Tg=F_b=\rho_fV_{sub}g$$
where $V_T$ is the entire volume of the block, and $V_{sub}$ is just the volume of the block that is submerged in the fluid.
Now, we can determine how much of the wood is submerged by defining the total height and submerged height respectively as $H$ and $h$. Therefore
$$\rho_bAHg=\rho_fAhg$$
$$h=\frac{\rho_b}{\rho_f}H$$
Since $\rho_b<\rho_f$, we have that $0<h<H$. Therefore, the block must be submerged by some amount less than its total height (the block is not fully submerged).
Answer:
if the wood doesn't sink in water therefore $A=ρgV=0$

As Aaron Stevens pointed out in their excellent answer, the assumption you made is not correct. The truth is that the piece of wood is not fully submerged in water, but rather it is partially submerged. Take a look at the following diagram:

One can find the exact relationship between the volume of wood submerged, $V_s$ and the whole volume of wood, $V$ by using Archimedes' principle:

Archimedes' principle states that the upward buoyant force that is exerted on a body immersed in a fluid, whether fully or partially submerged, is equal to the weight of the fluid that the body displaces and acts in the upward direction at the center of mass of the displaced fluid – Wikipedia (emphasis mine)

Assuming uniform cross-sectional area, one can consequently infer the relationship between the whole height of the piece of wood, $H$ and the height of the portion submerged in water, $h$.
$$\vec{F_B}+\vec{F_W}=0\implies \rho_l V_sg=mg\implies \rho_l V_s=\rho V$$
Where $\rho_l$ and $\rho$ are the densities of the liquid and of the wood respectively. Carrying on with the above reasoning:
$$\dfrac{V_s}{V}=\dfrac{\rho}{\rho_l}\stackrel{S=\text{ct.}}{\implies} \dfrac{Sh}{SH}=\dfrac{\rho}{\rho_l}\implies \boxed{\dfrac{h}{H}=\dfrac{\rho}{\rho_l}}\tag{1}$$
Conclusion. For wood in particular (ignoring surface tension forces), from eq. $(1)$ we can clearly see that $h=H\dfrac{\rho}{\rho_l}$. The density of most types of wood varies between  $0.4\frac{g}{cm^3}$ and $0.8\frac{g}{cm^3}$ (there are exceptions), which is clearly less than the density of water, $1\frac{g}{cm^3}$. Consequently, $h$ may be even less than half of $H$. In reality, the surface tension forces also decrease $h$ further, plus there are some optical effects like refraction that, especially for thin pieces of wood, may have given you the false impression that the wood is fully outside the water. But it's not the case.
Answer: As Archimedes discovered: every body immersed (partially or totally) in a fluid is acted with a (vertical) force that is equal to the weight of the volume of fluid that it displaces. This is the force you look for. It results from the difference in pressure on the body surface.
Comment: For the problem you consider there is no other force than buoyancy force. If the wood do not sinks to the observer eyes it is because its density is too low; then the depth it sinks is ver small, but not zero.
Comment: yes but wood doesnt displace any volume of water because it doesnt sink. so which is the force if it is not the buoyant ?
Comment: Still for the surface tension to have a component in the vertical direction it is necessary for the wood to sink.
Answer: For better understanding, you can consider the wood as two parts, one that totally sinked into the water and the one does not. In this case, the one which sink in the water will provide the overall force which is counter to the gravitational force.

Wood in water and buoyant force


Receipt Font Match

Question: Can Anyone help me determine what font is being used in this receipt?
Comment: I often wonder *why* anyone needs to match a font on a receipt.... There may be legitimate reasoning. However, all I can think of is to alter reality `:)`
Answer: We get these questions quite often. It's never a font available for sale, it's always something designed by the printer manufacturer, perhaps encoded pixel by pixel.
A few things in the same space are Helvetica Compressed and Monospaced, maybe some other monospaced fonts or try looking at the Latin character range of fonts designed for Far East languages, those often have similarly "naive" alphabets with odd proportions. More loosely, Production Type, a French typeface studio, have made a thing of designing a lot of fonts inspired by the blocky nature of simplistic computer encodings or creating letterforms where the proportions are off. You might want to check out their Minotaur Sans, Proto Grotesk Mono and Dr if you want to find something that suggests this style in a less literal way. PangramPangram's Neue Machina is also a quite interesting take on this space.

Receipt Font Match


RFID distance transmitter

Question: I am looking to have a program which would alert me whenever a certain RFID tag would no longer be read, however I don't want to use NFC since I need the distance to be of at least 50cm+.
Is there anyway to transmit an RFID tag over that distance which would be more cost, space and power effective then just doing it over bluetooth?
Comment: NFC - what does that mean?
Comment: near field communication
Comment: You need to specify a couple of important details before this question can even begin to get an effective answer. First off it is important to know if this is for a one-off or two-off play around project. Second, I think you really need to specify your acceptable power budget at the end where the RFID tag is located.
Comment: thanks for the feedback, by one-off or two-off I assume you mean if data needs to go back and forth (if not, please explain some more or as I thought now, if asking if I've done this before,no I've only handled raspberry pi and arduino microcontrollers via usb and ssh before) to which I say no, I would only have this tag located somewhere and a phone lets say which would alert me if it is no longer reading the tag. The power would be handled by a battery like this? http://tinyurl.com/nrz6pub
Answer: If you really want to use RFID, you will have the following possibilities to reach distances greater than 50 cm:

HF RFID at 13.56 MHz, particularly the tags based on the ISO 15693 standard (not NFC and ISO 14443 which operate on the same frequency), which do not have any security features and the reader has no need to feed the crypto chips within the tags. However, if you use inductive based RFID technologies, keep in mind that the reader antennas diameter has to be in the range of the distance to be bypassed. Some NFC controllers support also the ISO 15693 standard. If you get a reader, checkout for higher energy supply.
UHF RFID around 900 MHz (frequency depends where you use it): Distances up to 10 meters in free space are possible. The disadvantage is the high price due to the more sophisticated hardware.
Comment: Ok thanks, all I needed was something to get my search really started on

RFID distance transmitter


Ways to get Full attack with heavy crossbow?

Question: As far as I am aware, there is no way to get more then a single attack off per turn with the heavy crossbow. Is this true or not?
Comment: Are third-party sources acceptable?
Answer: The trick is reducing reloading to a free action. If you can do that, you can full attack with the heavy crossbow
You could use a repeating heavy crossbow which allows the wielder to make 5 attacks before reloading, but then reloading it is a full round action.
Alternatively, the 1st-level Sor/Wiz spell ghostly reload [trans] (Races of the Dragon 113) reloads the weapon for you but has limitations: it's 1 reload/caster level, maximum 10.
There is also the magic weapon special ability quick loading (Magic Item Compendium 41-2) (+1 bonus; 0 lbs.) that allows storing 100 bolts in a crossbow and reloading a heavy crossbow as a move action (or, if you want, a light crossbow as a free action). Talk to the DM about using the weapon special ability quick loading in conjunction with the feat Rapid Reload (Player's Handbook 99) to allow reloading as a free action so full attacks can be made with a heavy crossbow.
A self-loading crossbow (Arms and Equipment Guide 116) (12,350 gp; 8 lbs.) is a +1 heavy crossbow that can be reloaded by taking a move action. Combine this with the feat Rapid Reload so that the wielder can make iterative attacks. (Unlike quick loading, self-loading explicitly says the combination works.)
Comment: @HeyICanChan Arms and Equipement Guide pg 116(believe thats your source btw :P) has a side panel titled "Self-Loading Crossbows and the Rapid Reload Feat". The side panel states that the Rapid Reload allows you to reload a Self-Reloading Crossbow as a free action.
Answer: Snappie's answer covers all the reasonable answers I'm aware of, but there is a cheesy combo that works RAW. That is an aptitude heavy crossbow with Hand Crossbow Focus (aptitude is a +1 special property from Tome of Battle, Hand Crossbow Focus is a feat from Drow of the Underdark). Aptitude allows a weapon to benefit from feats for other weapons, and Hand Crossbow Focus allows you to reload a hand crossbow as a free action while also working like Weapon Focus. So aptitude lets your heavier crossbow still work with Hand Crossbow Focus, which always provides free-action reloading.
This trick gets better, though, if you take advantage of another property of aptitude—it allows you to always use the weapon proficiently. That means there is no problem putting it on the great crossbow, which has much higher damage, and you don't even need Exotic Weapon Proficiency.
Ultimately, I do not really recommend this. Aptitude is poorly written and easily the most broken thing in an otherwise excellent book. They probably only meant switching feats that give you a choice to work with the weapon, similar to the warblade class feature weapon aptitude (which would be kind of weak for a +1 but not hideously so when combined with the auto-proficiency). But that isn't at all what they wrote and so now we have this broken mess.
Answer: Although it's an epic feat, with all the problems that entails, Instant Reload does allow this. I'm unaware of any other methods to achieve the same result.
Comment: i know this answer is from 5 years ago but my I ask you what do you mean with "with all the problems that entails"?


Xamarin forms - Periodic list view data refresh

Question: We are building Xamarin forms app to run on iOS, Android and Windows 10. We are data binding view model to UI which has List View control. We want the data to be refreshed from rest service, every 3-5 seconds when user is viewing the app. We don't want the data to refresh when app is in background, but refresh the data as soon as app is foreground. I tried using Xamarin.Forms.Device.StartTimer and await Task.Delay, but this does not seem to be working very well, sometimes the data does not refresh when not in interactive debug mode especially with Xamarin.Forms.Device.StartTimer , I am not sure what is going wrong as I am not able to do logging on device. On using await Task.Delay, sometimes the Task gets cancelled. In app onresume event, code makes rest service call which fails with connection refused error.
So I wanted to know which is the best way to handle data refresh, any ideas?
Thanks in advance
Comment: have you tried using platform specific services? http://arteksoftware.com/backgrounding-with-xamarin-forms/
Answer: At last to do periodic refresh, i used Task.Delay and a boolean variable to known whether refresh needs to be performed or not. If user navigates away from the page, i set the boolean variable to false to stop the refresh.


Testing for weak instruments in panel data

Question: Suppose I have hierarchical data such as students clustered into classrooms.  I want to use a two stage least squares regression with an instrument that affects students at the classroom level to test my hypothesis.  What is the appropriate method to test if my instrument is weak?  The Cragg-Donald F-statistic with Stock and Yogo critical values seems appropriate for the general case of identifying weak instruments but it doesn't build in any adjustment for clustering.
Comment: If the $F$-statistic can be computed in the Wald form, correction for clustering can be made. See also [discussion on statalist](http://www.stata.com/statalist/archive/2009-09/msg01179.html).
Answer: The appropriate weak instrument test for testing for weak instruments in panel data or more generally data that is non-i.i.d is the Kleibergen-Paap Wald rk F statistic.  From the STATA documentation of the ivreg2 command:

When the i.i.d. assumption is dropped and ivreg2 is invoked with the robust, bw or cluster options, the Cragg-Donald-based weak instruments test is no longer valid.  ivreg2 instead reports a correspondingly-robust Kleibergen-Paap Wald rk F statistic.  The degrees of freedom adjustment for the rk statistic is (N-L)/L1, as with the Cragg-Donald F statistic, except in the cluster-robust case, when the adjustment is N/(N-1) * (N_clust-1)/N_clust, following the standard Stata small-sample adjustment for cluster-robust. In the case of two-way clustering, N_clust is the minimum of N_clust1 and N_clust2.  The critical values reported by ivreg2 for the Kleibergen-Paap statistic are the Stock-Yogo critical values for the Cragg-Donald i.i.d. case.  The critical values reported with 2-step GMM are the Stock-Yogo IV critical values, and the critical values reported with CUE are the LIML critical values.


Do Science Fiction Stories Follow A Particular Pattern?

Question: I recently started writing a book expanding myself from my typical fantasy genre into SciFi. I have taken a start however I have reached an impasse and can not really decide how I should structure my story. Is their a specific way a Sci Fi  story is structured since I am stuck and can not seem to progress in my story. Please help me find a solution to this problem.
Comment: Hi and welcome to the site.  This is a very broad, general question.  Can you give us some more detail --not necessarily about your story, but about what the specific writing issue is that you are facing.
Comment: I suggest looking first at the subgenres within science fiction. http://www.scifiideas.com/writing-2/writing-advice/a-guide-to-science-fiction-subgenres/  After perusing that, you  might have a better sense. Also, read. :) It's good advice. Some books you can find online. Libraries are free.
Comment: Science fiction stories are structured the same way any story is structured. The focus should always be on what happens in the story and how this affects the characters. This is the same as any other story. Like fantasy, the world of the story is itself always a major character. There isn't any specific way of structuring science-fiction stories. Just write your story the way it should be written.
Answer: Science fiction has some unique staples, but there are a million structures and styles. Certainly there's no single structure that encompasses everything from the taste of genius in "Flowers for Algernon" to the mind-bending dual view of causality in "Story of Your Life"; no single structure that captures both the dark paranoia of Philip K. Dick and the majestic anthropological explorations of Ursula Le Guin.
Don't try to conform to a formula. Instead, figure out what you see as the crux of your story, and figure out your structure according to that. Is your story about a fascinating species of aliens, or is it about the experience of living among people alien to you? The joy of exploration, or the hubris of mankind? Figure out what your story is about, and the structure will follow.
And in the meantime: read short fiction. There's a bottomless treasury online; at Forever and Uncanny and Escape Pod and a dozen others. That way you'll get a sense of the many story structures, unique or commonplace, that SF is capable of.
Answer: If you have written fantasy, sci-fi can be written in the same structure. Pretty much all stories follow a 3-4 act structure (the second act in the 3 act structure can be broken into two acts).
1) 25% of the story. You introduce your characters in their normal life, solving normal life problems, meeting each other in normal-life circumstances. Something happens (an inciting incident that pushes them out of their normal life to solve a problem).
2A) 25% of the story. The character isn't sure what they are doing, but are reacting to the problem as best they can. Usually ends in a setback or game changer, but doesn't have to.
2B) 25% of the story. Through flailing in (2A) the character has learned enough to come up with a plan. This is a more proactive phase, actually planning and executing. Can still have failures, and usually ends in one, but often followed by an epiphany or realization of what needs to be done to solve the problem.
3) 25% of the story. Concluding confrontations, or working solutions. Often full of close calls or harrowing (think Doc and the clock-tower in Back to The Future), then a short aftermath proving there is a new normal life, or life has returned to the previous normal.
Now I say 25% for each, but that can swing 10% either way. Don't count words and curse yourself if the inciting incident lands at 20%.
I am a discovery writer, which means I do not plan a plot or incidents beforehand, I don't write to an outline. I invent characters, and think about them a lot, and then start writing them doing things.
But that said, I also know to write to the above structure. That wasn't invented, it was discovered by distilling thousands of good stories and realizing this structure is a generalization of what good stories have in common, for a beginning, middle and end.
So, while I am writing the normal world, I am looking for an inciting incident that can flow from my characters. I know I want them to get together, but I am not sure how that happens. Once I find one, then I am looking for "reactive" actions to address it. And so on. My characters do what they do, but once I have enough "reactive" I start looking for what will give them a plan.
Your story is probably stuck in some act, and you don't have an idea to get out of that act and into the next. That is what you need to find, and why you stalled.
Answer: Classically speaking, science fiction explores the ramifications of some piece of future technology.  But these days you can find science-fiction versions of plotlines from every genre.  In practice, this means you can use any structure you want.  If you want to write classic science-fiction, however, you should make sure it all goes back to the tech.


Interesting vs fascinating

Question: When I said "fascinating" in basic conversation, my English teacher said interesting in response.
I'd like to catch the specific difference between them.
Comment: The difference is actually somewhat more nuanced than the answer posted below might suggest. For a detailed discussion of the difference between _interesting_ and _fascinating_ in meaning and orientation, see my answer to the EL&U Meta question [Are "commonly available" reference dictionaries too simplistic to answer questions on this site?](https://english.meta.stackexchange.com/questions/13211/are-commonly-available-reference-dictionaries-too-simplistic-to-answer-questio)
Answer: The difference is in intensity: fascinating means extremely interesting.
http://dictionary.cambridge.org/dictionary/english/fascinating
Comment: @Helmar I don't care. If you two have problems with the question, take it up with the OP and stop badgering people who are only trying to help. I don't need anyone's permission to answer a question - and the question is still not closed now, not to mention when I answered it.
Comment: But I _do_ care. You could have helped the OP by giving this as a comment instead of an answer, and helped the people who do care about keeping 'please look this up for me' questions off ELU, to preserve its credibility as a site for linguists, at the same time. _Who_ are you trying to help? There are plenty of other websites for very basic questions and / or those not accompanied by a reasonable amount of research.
Comment: An earlier close-vote set comment read 'This question is too basic; it can be definitively and permanently answered by a single link to a standard internet reference source designed specifically to find that type of information.' It was probably downtoned to be kinder to newcomers, but still applies. And to quote @Rathony, 'We do not encourage an answer to an off-topic question. If you want to help the Original Poster, please post it as a comment'
Comment: Moreover, closed questions are only deleted from the system when the answer(s) have no score. As such your answer might be target of strategic down voting if does get up voted.
Comment: @EdwinAshworth I don't care.
Comment: I don't need your lecturing.

Interesting vs fascinating


Screen Resolution of a Command Line Terminal?

Question: I have disabled the automatic boot into Unity and am booting into a CLI tty with a login shell. While running the CLI login shell the screen resolution is fairly low and only utilizes a tiny portion of my widescreen. I do want to maximise the screen resolution but keep the fonts small. I am actually running this particular install in a virtual machine inside VirtualBox but will also apply it later to other "bare metal" installs on other machines.
Comment: There are two parts to this: the resolution of the screen (a.k.a. mode in the console)  and the font. which one are you asking about?
Comment: @DavidKohen I do wish to increase the screen resolution but keep the font as is (i.e. small).
Comment: You can set the resolution in grub settings.
Answer: You can change the console resolution via GRUB configuration.
In the file /etc/default/grub you can find the following lines, near to the end of the file:
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
# GRUB_GFXMODE=640x480

Uncomment the GRUB_GFXMODE=640x480 line(i.e, remove the # at the beginning). Change the value 640x480 to the resolution you prefer. Now save the file and run:
sudo update-grub

You can now restart your system.
Courtesy: http://ubuntuforums.org/showthread.php?t=1478692
N.B: I have not checked this solution myself, but it should work fine.
Comment: You can also do this from [Grub Customizer](https://launchpad.net/grub-customizer) > Appearance Settings > custom resolution.
Comment: @PaddyLandau, Grub customizer is not part of default Ubuntu installation. It has to be manually installed. So it would be nice if you could add it as another answer with exact steps to install it and use it for this particular purpose.
Comment: I have done as you suggested.
Comment: I am more with saji89 even if Grub Customizer does it. In the time it takes me to download it I had already done the grub editing and rebooted.
Answer: You can use Grub Customizer, a GUI method.
First, you need to install Grub Customizer. Open a terminal (Ctrl+Alt+T) and enter the following commands, one at a time.
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer

The first command will prompt for your password. When the commands are complete, you can close the terminal.
Now you can make your changes.

Open Grub Customizer.
Select the tab Appearance settings.
Select custom resolution and choose the resolution that best matches your screen (or you can type your own).
Press Save; wait while it saves.
Restart your machine to test the changes.

Note: Changing the font is a little buggy, so you may want to avoid doing that.
Comment: +1, for adding a detailed answer about grub-customiser.. :)
Answer: This link has a list of modes you can set in boot time, check them by booting with the shift key (so you can enter grub) and in the kernel line add the vga parameter.
After you found the mode suitable for you, add the vga parameter to the GRUB_CMDLINE_LINUX variable in /etc/default/grub and run
sudo update-grub


Wake On lan to pc with raspberry pi over ethernet

Question: I just want to use my rpi as a wake on lan packet sender. Because I can't Connect my computer directly to the router. So I want to use my raspberry pi as a bridge.My pc is connected by Ethernet to the raspberry that way the raspberry is connected to the internet and gives It to my pc and that way I can set wol packages without being connected to the router I Hope is  clear?
Comment: Why can't you connect your computer directly to your router?
Answer: Your question is very clear and this Rpi project is exactly what you're looking for http://www.jeremyblum.com/2013/07/14/rpi-wol-server/
Comment: I came across your answer in a review queue. It follows the model of a lot of spam the site receives. I was going to flag it and then I saw you have a long history on the site.  Please see the guidance [*here*](https://meta.superuser.com/questions/5329/how-do-i-recommend-software-in-my-answers) for recommending software.  Key points: replace your text with **why** this is what the OP is looking for, what it is, what it does, what makes it a better solution than a random Google hit, and the gist of how to use it to solve the problem.  Just a product link is really more appropriate as a comment.


Transformer half power options

Question: I have a power transformer with 120 and 220 volt primaries for ~650 volt from the secondary.  If I wanted lower voltage from the secondary, is there any reason I couldn't run my 120 volt line voltage into the 220 volt primary of the trafo and achieve the desired result?
Answer: Yes, that will work.  The output voltage will be 120/220 = 55% of what it would be when the input is connected as intended.  The only downside is that the overal power capability will be lower.  If you can live with the lower maximum power output, then this will work fine.
Answer: There is no reason- stay within the current limit specified and you'll be fine, and you can get about half power out of the transformer.
Of course if you have a resistive load, and halve the voltage, the power will be reduced to 25% (or 29% in your case with 220/120).

Transformer half power options


"Invalid base64 data" error when using tramp

Question: I'm using an Intel Edison, and I want to edit files on there with Emacs.  I can connect to the device with tramp, using several methods and explore using dired.  But trying to visit a file gives an error "Invalid base64 data".
Answer: The Edison didn't have some of the utilities tramp needs (base64, uuencode).  Apparently tramp sends a perl script if it can't find them, but it did not work.  It turns out that even when using methods like scp, tramp tries to do inline transfers when the file is below a size threshold, tramp-copy-size-limit.  I can do
(setq tramp-copy-size-limit nil)

to force "external copy" (i.e. using scp) always.

New problem: multi-hops don't allow scp.  E.g. /ssh:proxy|scp:user@remote:file is invalid, which in turn means that external copy is not used for multi-hops.  I guess I'll have to set up an ssh proxy for that:
Host dev # the edison, on another network
User root # on dev
HostName 10.251.1.112 # LAN IP of dev
# nc must be installed on proxy
ProxyCommand ssh -Aq jpkotta@proxy "nc -q 1 %h %p"

/scp:dev:file or /ssh:dev:file with tramp-copy-size-limit set to nil.
Comment: this didn't help
Comment: Yes for files < 10240 bytes, set the limit to nil to force TRAMP to use the specified external method. Otherwise TRAMP defaults to inline methods.


Youtube views using the Flash API

Question: I have a very simple question. Does youtube count "views" if put a YT video into a swf, using their Flash API? I can't seem to find anyplace that explains how views are counted.
Answer: Generally yes, but user have to press YouTube play button.
It's like on normal website. If auto-play is enabled views do not count. It will be to easy to make views counter BOT.
More info:
http://knol.google.com/k/alec-go/youtube-player-apis-when-will-a-view/2vd5zn6va2fqd/13#

Youtube views using the Flash API


Should I write a comment paper regarding the following issue?

Question: I have read a recent paper (actually not published yet but is accepted for publication). In this paper the authors consider two scenarios and discuss performance of the considered scenarios. I am 100% sure that one of the parameters of the performance remains same for both the scenarios but the author provided two lemmas that contain two different mathematical expressions for that parameter. They have stated in the paper that those expressions are one of their main contributions. I can prove that for both the scenarios the performance parameter remains same and my expression is less difficult to compute and more nice looking. So, my question is that should I consider writing a comment paper?
Comment: It depends how interesting that parameter is.  One thing you could do is discuss it with the authors of that paper and see how interesting they think it is.
Comment: @Kimball the parameter maynot be very interesting in itself but here are a few things interesting about its finding in the paper (i) some earlier papers had already found the parameter and the parameter has same mathematical expression for both the scenarios discussed in the paper while authors provide two different expressions (ii) the authors consumed a whole page to find the expressions which I think should not take more than half a page (iii) the expressions provided by the authors are very complex mathematically and the expressions that already exists are quite simple to comprehend.
Comment: @Kimball I would like to discuss it with the authors but the problem is that teh email gets bounced back due to RBL restrictions in the destination email server.
Answer: If your claim is valid, strong and holds for all possible kind of problems that could be supported by the lemmas given by the authors, then you should do the following:
As the paper has been accepted (you should wait. Because, the paper you read is the paper you read might be from author's personal sites or arxiv (as I assume)). So, once the journal/conference publishes the accepted paper online, you could write a comment paper/a short paper based on your claims.
Without online publication by the journal, it is really difficult for you to talk to anyone. I guess.
Comment: I don't understand this at all.  If a paper has been publicly disseminated then you are free to talk to people about it and write other papers related to it.


Lost Coordinates In Creative

Question: I was making a server world, so I made a teleportation pad (/tp command). I chose a random coordinate far from the spawn so no one would see it. So I built the best house that I have ever built, with a lockable door and everything. I was about to do a YouTube video about it. But then my Minecraft crashed. Every time I went on ANY world, including a new world it crashed. I'm on Windows 10 so I searched up if people had the same problem as me. They said to go back to 1.8.9. I did, and the command blocks reset so i lost the coordinates.
Comment: Possible duplicate of [Finding my house in minecraft](https://gaming.stackexchange.com/questions/29516/finding-my-house-in-minecraft)
Comment: What exactly are you asking, a way to get the coordinates from your tp pad? Can you think of any other way to write your question to be a bit more clear matey?
Comment: @Oak I mean that I lost the coordinates to my builds area. Because I made a thing that teleports you to the builds area. But I LOST the coordinates to the builds. And I really worked hard on it.
Comment: Do you have the console logs from that day? They include chat and commands.
Comment: I do, but how do you check those?
Answer: You should be able to access your logs through your minecraft files:
C:\Users\GiraRay\AppData\Roaming\ .minecraft\logs (remove the space in Roaming\ .minecraft !)
Here, you can see a list of winRAR files and txt. documents named after dates of every play session. Each file should contain everything displayed in the chat and every command executed, by cmd blocks and players.
Unless you remember when you built that house, it's going to be a pain to navigate the right file.
Answer: Do you have access to external tools? I'm fairly certain that the only way is with MCEdit or comparable. I solved a simalar problem by going into chunk view, and looked for where the chunks were generated: where I had been.
Comment: I have MCEdit 2, but I don't know how to use it. Sorry I'm not that good at those stuff.
Comment: There should be a button that says 'chunk view'. press it and look around until you find an area of generated terrain. see if your house is in it. if not, repeat.

Lost Coordinates In Creative


disable cache for particular category in magento2

Question: I have a category page with customer specific products, so those products should display based o current customer id. basically caching issues are coming when I'm switching from 1 customer to another customer. How to disable cache only this particular category, or I need to create custom controller and custom product collection?
Comment: Are you using varnish cache or Magento page cache?
Comment: @ZealousWeb yes
Comment: varnish cache..
Answer: If using Magento 2.3.4 + you can create specific layout update for that category as defined here:
https://magento.stackexchange.com/a/303941
and can use cacheable=false in your block in definition or blocks which you do not want to be cached.


How does the Webfilter of Windows Vista's "Parental controls" work?

Question: How does the Webfilter of Windows Vista's "Parental controls" work? Is it integrated in IE or a proxy?
Answer: The controls on Windows 7 disable all other browsers, so it must be IE only.  If Vista is anything like Windows 7 then it is probably the same.  I didn't see any details about it, so I tried installing it.  Wasted a few hours on the whole process.


A word or phrase that someone says frequently is called what?

Question: A word or phrase that someone says frequently is called what? As an example, a friend says the phrase "Faithful God" frequently, say 15 times in day. So, what English word defines the term "Faithful God" with respect to the friend?
Comment: See also [here](https://english.stackexchange.com/questions/429004/name-for-a-word-that-someone-is-known-for-saying/429005#429005)
Comment: I would say "annoying".
Comment: Possible duplicate of [name for a word that someone is known for saying?](https://english.stackexchange.com/questions/429004/name-for-a-word-that-someone-is-known-for-saying)
Answer: If it's something distinctively his, to the point where bringing it up in conversation with Friend #2 causes him to laugh and say, "Friend #1, amiright?" it's a catchphrase.

A catchphrase (alternatively spelled catch phrase) is a phrase or expression recognized by its repeated utterance.

The OED says it originated from the use of "catch" to describe things that catch the eye or ear. 'Catchword' was the original way to express the idea, but is less common now.
A similar idea is the signature phrase. It's less condescending and simply expresses the idea that that idiomatic expression is strongly associated with that person. If you're expressing how fond the friend is of his own turn of phrase, you might use pet phrase.
Answer: old saw TFD  idiom

An oft-repeated saying, maxim, or proverb; a cliché or hackneyed
  expression.

As in:

My dad has a few old saws he never hesitates to share with my kids
  whenever we come to visit.


grep command in bash scripting

Question: grepstr()
{
 grep "$1 $2" $TMP/"ORACLE_SID"_dbmode.txt > /dev/null 2>$1
}

What is the meaning of the above command?
What are $1 and $2? Why it is necessary?
Is there any alternatives for using $1 and $2?
Answer: Is that exactly what the code looks like?
As it is, it is a function that takes two arguments, let's say they're arg1 and arg2.
Then it reads a file called ORACLE_SID_dbmode.txt and prints every line that contains arg1 arg2 (joined together with a space in between), and saves the error messages in a file called arg1.
This is quite confusing, so I don't think this is the actual code.
I would imagine it is actually this:
grepstr()
{
    grep "$1" "$2" $TMP/"$ORACLE_SID"_dbmode.txt >/dev/null 2>&1
}

Changes:

"$1 $2" becomes "$1" "$2"
ORACLE_SID becomes $ORACLE_SID
2>$1 becomes 2>&1

If so, it could be used two ways:
grepstr options string_or_pattern

for example:
grepstr -i something

would make it print (see below) any lines in the file "$ORACLE_SID"_dbmode.txt that include the string something, Something, SOMETHING, etc.
-i means case insensitive and is just an example; any option could be used.
(Also, technically something is not a string, but a pattern, for example [0-9] would match any digit).
The second way is:
grepstr string_or_pattern filename

in which case it will print any lines matching string_or_pattern in filename or "$ORACLE_SID"_dbmode.txt.
That seems less likely, but it is possible, depending how the code is used.
It could also be called like this:
grepstr option1 option2

but that would read from standard input (e.g. the keyboard by default), and print any lines that contained "$ORACLE_SID"_dbmode.txt, which is almost certainly not what was intended, given "$ORACLE_SID"_dbmode.txt looks like a file name, not a string or pattern to match.
If my guess is right, the code isn't >/dev/null 2>$1, instead it's >/dev/null 2>&1, which means output and error messages are not printed.
>/dev/null means that grep's standard output (i.e. the matching lines) is being sent to /dev/null, which is a special file that the operating system just ignores.
2>&1 after >/dev/null means that error messages go there too.
So if the output isn't important, grepstr is probably being called either like this:
if grepstr...

or like this:
grepstr...
if [ $? -ne 0 ]

to only execute some code if there was a match.
In answer to the other part of your question, yes, it could be changed to
grepstr()
{
    grep "$@" $TMP/"$ORACLE_SID"_dbmode.txt > /dev/null 2>&1
}

The "$@" expands to "$1" "$2" "$3"... (i.e. as many arguments as are provided).
I think that way would be better, because it would be more flexible.
On the other hand, if it does require two arguments for some reason I can't think of, then perhaps "$1" "$2" is what the author intended.
Answer: $1 and $2 are parameters. Your snippet is defining function grepstr.
For example, running
grepstr first second

actually runs command
grep "first second" $TMP/"ORACLE_SID"_dbmode.txt

and redirects output to /dev/null (which is message sink, everything put there just disappears).
Basically, when you run script (or function), $1, $2, $3 (etc.) are parameters you gave. You can test whether parameter is set with -z, for example if [ -z $3 ]; then ....

grep command in bash scripting


What experimental bounds do we have on big $G$?

Question: I know that there has been a large amount of controversy surrounding the exact value of the gravitational constant $G$, but I know that there is not a substantial difference in the measured value. So I was wondering what experimental bounds we have on it so far?
Comment: we don't have even good experimental bounds on torsion
Comment: What is torsion? In gravitational theory.
Answer: This page shows the range of some measurements from 1982 to 2014. Basically, it looks like arguments could be made for any value between -460 to +250 parts per million below or above the commonly accepted value of 6.67408 x 10^-11 m^3 kg^-1 s^-2.
http://iupap.org/working-groups/wg13-newtonian-constant-of-gravitation/
Answer: According to NISTconstants, as of 2017,
$$G =  6.674 08(31) \times 10^{-11} \space {\rm m}^3 {\rm kg}^{-1} {\rm s}^{-2}    $$
which means the range is 6.67377 to 6.67439
It's not the easiest measurement to make, large forces from electrical, magnetic, and other sources have to be considered.
Comment: Isn't the number in brackets the standard deviation in the results? That is, G could conceivably be > 6.67439, but the probability of that is < 32%.
Comment: @Allure That's possible, but it could also be a hard limit based on systematics (nonrandom variables).   I tracked a paper that gives experimental results, Phys Rev Lett 23(10), from 1969, but I only have the reference, haven't visited the library.
Comment: @allure that's not the meaning of a confidence interval. In 68% of the hypothetical repeat experiments, an interval produced in that manner would include the true $G$, were the model true


Switch between modes

Question: I seem to have trouble switching between modes. I have to open and start a file in sculpt or I can't use the sculpt feature. For example, I start model and get the basic shape then go up to modes, choose sculpt. My object is there but nothing happens. I can't use any brushes or anything. But if I open a new sculpt file, the sphere is there and I can use all the brushes on it. What am I missing?
Answer: I believe that the issue is arising from either one of the situations below.
1) When you switch to Sculpt mode, the sculpting tools will only act on the previously selected object. Switch back to the Layout mode and make sure that you've got the sculpting object selected.
2) Your object may not have enough geometry to be sculpted on since the sculpting brushes act by moving the existing vertices of the object. So if you are attempting to sculpt on the default cube, for example, the brushes only have the eight corners to work with. You can add more geometry to the object by subdividing it. Alternatively, you can enable Dyntopo located in the header bar while in sculpting mode. This will add additional geometry as you work.
Comment: I never thought about not enough geometry. I'll try that. Thank you.
Comment: It was not enough geometry. Thank you.

Switch between modes


It is worth running a limited company with low income?

Question: I'm selfemployed but the company I work for is not allowing me anymore to be self-employed. My agency suggested me to go limited company rather then getting paid PAYE. I'm earning £20000-24000/year maybe more but that amount is for sure , on this amount of money I would be better of limited company? I'm working in construction so I will have to register the company CIS.
Thank you in advance!
Best regards.
Answer: In my experience no, it's not worth it.
The amounts you are earning do not make it any more tax efficient to be a LC and there is a fair bit of extra paperwork involved, registering is pretty simple but the tax returns are quite complex and you would probably need an accountant to do those for you every year, at around £600 a time, or more.
If you were earning more (Say over £30k) then the tax benefits might be worth it but for your situation I'd go with PAYE.
I am not an accountant or lawyer, but did have to set up a LC for a client I did some contract work for.  I also freelance and do that as self-employed (sole trader) and do an annual self-assessment tax return.


What amount of cash I can take with me when going from Canada to USA?

Question: What amount of cash I can take with me when going from Canada to USA?
I want to travel to US and want to take ~ 12000$ with me. DO I need to declare it and pay any fee?
Comment: $12K cash?  Do you need a lift from the airport? :)
Comment: The US requires you to report it.  They don't prohibit it, nor do they charge any fee.
Comment: There is no limit; you can carry as much as you are comfortable with. You just have to declare any amount above $10,000 and be able to justify the source and the reason you are carrying the cash.
Answer: Travelers leaving or entering the U.S. with more than $10,000 (in any form, that includes cash or checks) are required to declare it by filling out a Report of International Transportation of Currency or Monetary Instruments (FinCEN 105). This applies even if you are passing  through the U.S. in transit to other countries.
Source: eHow
Comment: FinCEN 105 is quite specific as to what is considered a "monetary instrument" and ordinary checks made out to a named recipient (and not endorsed) are excluded.
Answer: In addition to Heidel's point that the US cares you are taking more than $10,000 out of the USA, Canada cares that you are bringing more than $10,000 in. The form you will fill out on arrival is at http://www.cbsa-asfc.gc.ca/publications/forms-formulaires/e311-eng.pdf and you can see they want to know if you have that amount of cash on you.
According to http://www.cbsa-asfc.gc.ca/security-securite/cbcr-dmte/menu-eng.html you don't have to pay any fee, and you are allowed to bring the money, but you MUST tell them about it. Just allow some time to have a conversation with the CBSA on arrival.
Comment: I believe you've got this the wrong way around. The direction of travel is Canada -> US.
Comment: You're right, sorry. I'll leave the answer though, because a searcher might be interested in the other direction


Solidity: Mock function return value

Question: I'm writing an ERC-721 contract but I'm struggling to write a proper unit test when all token ids are minted.
Function I want to test:
    uint256 public constant MAX_SUPPLY = 10000;

    function safeMint() public payable {
        uint256 totalSupply = totalSupply();
        require(totalSupply <= MAX_SUPPLY, "Purchase would exceed max supply");

        //...
    }

In the code above I want to write a unit test so it would throw an error if total supply has reached its limit.
My first approach was to mock totalSupply() so it would return 10,000. Then I would call safeMint() and assert it throws an error with the correct error message.
So my question is how to mock the return value of a function? Or is there some other way to test this?
I tried something like this with hardhat, waffle and smock:
describe('MyContract', () => {
  describe('given mocked contract', () => {
    let mockInstance;
    let account;

    beforeEach(async () => {
      const myContractFactory = await smock.mock('MyContract');
      mockInstance = await myContractFactory.deploy();

      [account] = await ethers.getSigners();
    });

    it('given 10,000 tokens ids minted, when safe mint is called, throws', async () => {
      await mockInstance.totalSupply.returns(10000);

      await expect(
        mockInstance.connect(account).safeMint({
          value: ethers.utils.parseEther('0.123'),
        })
      ).to.be.revertedWith('Purchase would exceed max supply');
    });
  });
});

Above code sets the total supply to 10,000 but when safeMint() is called it does not throw an error.
Answer: The error is in the condition require(totalSupply <= MAX_SUPPLY,. If  both totalSupply and MAX_SUPPLY  are equal to 10,000 then the condition will be satisfied and it will not revert.
The solution is to only allow mint when totalSupply strictly less than MAX_SUPPLY:
require(totalSupply < MAX_SUPPLY, "Purchase would exceed max supply");

Solidity: Mock function return value


How to make a player drop an item when hit

Question: I am making a game on Minecraft when someone starts holding one item. If they get hit by someone they lose the item, and it goes on until a timer finishes. How can I do this? I am still new to command blocks, so any help will be appreciated.
Comment: Have you made any attempt to solve this yourself? Arqade works better when askers show effort to solve their own problems; we see that you have a problem you've worked on, and answerers respond to that. You also get a more specific answer that's tailored exactly to the part you're stuck, and Arqade gets a very specific question. Everybody wins!
Comment: The problem is, I don't know where to get started.
Comment: That's where a little bit of research comes in.  You don't have to solve it yourself, but an effort to do so goes a very long way.
Answer: You could have them via command blocks equip a piece of armour with half a hitpoint on it, so when they get hit the armour breaks, this could trigger the "clear" command to remove the item, and then spawn @players feet the item in question
Answer: You can delete the item there holding if they get it, and you can make them drop the item if you know what item there holding. To do this you need a scoreboard objective testing for when they get hit,
/scoreboard objectives add damage stat.damageTaken

Then in command block do,
/testfor @a[score_damage_min=1]

Then a comparator coming out of that into a command block do,
/replaceitem entity @a slot.weapon.mainhand air

Then with a repeater coming out of that into a command block,
/scoreboard players reset @a damage

Though if you know what item there holding add before the scoreboard reset do,
/execute @a[score_damage_min=1] ~ ~ ~ /summon Item ~ ~ ~ {PickupDelay:60s,Item:{id:"minecraft:grass"},Motion:[0.2,0.5,0.2]}

And replace "grass" in minecraft:grass with the item you want dropped.