counting the number of files being copied

Question: I am interested in modifying a bash script file whose purpose is to copy large amount of files to destination path. What i'm trying to achieve is count the number of files as they are being copied.
How can i achieve the objective state above ?
Comment: It would be nice if you could take a look at: [What should I do when someone answers my question?](http://unix.stackexchange.com/help/someone-answers)
Answer: I assume that your file names do not contain a newline.
cp -v file* targetdir | cat -n

Output:

     1 `file_123.png' -> `targetdir/file_123.png'
     2 `file_207.txt' -> `targetdir/file_207.txt'
     3 `file_44.png' -> `targetdir/file_44.png'

or only numbers (GNU sed):
cp -v file* targetdir | sed -n '/.*/='

Comment: @Cyrus  I did the -av , and it worked . Thanks
Comment: does not work if you want to copy a whole directory to a target directory.
Comment: Cyrus - assuming gnu `cp`, it doesn't matter if there are newlines in file names as they're quoted so the `wc` is always right.
Comment: the objective is to copy the content of a directory into a target directory recursively, such that as the content of the directory "files" is being copied , the output of the command is written to a variable.
Comment: @SamGomari: `cp -Rv sourcedir/* targetdir | cat -n` should do the job.


How to add event handler to an inherited winform control?

Question: I need to add an event handler to an inherited control like a datagridview but Visual Studio doesn't allow me. Isn't there a way for an inherited control to fire a base event handler AND the inherited one? in a sequence I specify?
Answer: Events in WinForms typically have a corresponding "On*" method.  Simply call that method, and it'll raise the event.  If you want to raise "CellClick" for example, call "base.OnCellClick(new DataGridViewCellEventArgs(row, column))".
Answer: Your question is unclear.  Assuming that you're trying to handle the base class' event in the inherited control, you can override the OnEventName protected virtual method.  In the override, make sure to call the base method or the event won't fire.
This method exists (AFAIK) for every event in every control in System.Windows.Forms.  If the control you're inheriting does not have this virtual method, you can subscribe to the vent in the constructor.
For example:
class MyButton : Button {
    //First way
    protected override void OnClick(EventArgs e) {
        base.OnClick(e);    //Without this line, the event won't be fired
        //...
    }

    //Second way
    public MyButton() {
        base.Click += Base_Click;
    }

    void Base_Click(object sender, EventArgs e) {
        //...
    }
}

EDIT:
If you're trying to raise the base class' event, you can call these OnEventName methods.
If the base class doesn't have one, the only way to do it is to declare a new event, and add a handler to the original event from the base class that raises your new event.  Note that if you have other code that uses the base class' event, and the evnet is not virtual and doesn't have a raiser method, you're out of luck, unless you can decompile the base clas and find out where the event is raised.


Can different bacteria strains of same species have different genomic sizes?

Question: Can two different strains of a single species have different genomic sizes? I am not asking about plasmid. Can they have different sizes of actual chromosome?
Answer: Yes, and one could argue that the differences between two strains of the same species are entirely due to their collections of genes (and therefore different genome sizes).
Take the plant pathogen Pseudomonas syringae, for example. There are many different strains, categorized by the plant hosts they cause disease on. This host range is determined by different collections of virulence genes in their genomes. So although they are the same species, they can be remarkably different in their genomes. See this (open access) paper by Baltrus, et al for more information.
A point to remember... "species" is a manmade concept, and there can be different definitions. Some species can have less than 90% similarity at the genome level!
Comment: This answer seems decent, but I'm curious what example you have for that last sentence.
Comment: I guess there are two ways to look at it... at the genome level, or homology of orthologous proteins. To keep with the example above, [we found](http://journals.plos.org/plospathogens/article?id=10.1371/journal.ppat.1003204) that several *P. syringae* strains have less than 80% similarity of orthologs.

The same figure shows that there are on average 26 SNPs per KB, which is only 2.6% differences at the genome level, but that also is across only the genome portions that are actually comparable, and the overall differences at the nucleotide level are much higher.


Compare Spread On A Fixed Bond Vs A Loan/FRN?

Question: I was discussing with a colleague, but in short, how do you compare a fixed bond vs a loan/frn when it comes to spread? Theoretically, you should get paid more for holding fixed bonds, as you have duration risk, so in my view you need to take the z spread of said fixed bond, substract the equivalent maturity swap rate, and compare the result vs the DM/zDM of the loan/FRN. Is this right?
Answer: No. You can hedge the interest rate risk of a fixed-coupon instrument at immaterial cost. Don't discount a fixed-coupon instrument more than a floater because of the presense of additional interest rate risk.
Spread calculations such as Z-spread and OAS, if done correctly, are comparable for fixed-coupon and floating instruments without the need for further adjustments.
A Z-spread of a fixed-coupon bond is already approximately equal to its yield minus the swap rate at the bond's maturity (or, even better, minus a weighted average of swap rates if the bond amortizes or pays large coupon). Subtracting the swap rate once again won't give rise to an economically meaningful figure.
Comment: Fully agree with this answer.
Comment: Thank you for that. So would it make more sense to compare a zDM to an ASW?
Comment: For rich-cheap comparisons of credit instruments, backing out and comparing their implied CDS spreads, like VCDS on Bloomberg, is sometimes most insightful. I should also add that although certain textbooks postulate that floaters never have interest rate risk, one can exercise critical thinking and actually calculate the interest rate risk of a high-yield loan:  index+fixed spread, like 600 or 700 bps. It's big enough to warrant hedging if not wanted. Perhaps this is why in some markets, like Brazil, they prefere gearing index*g instead of index+s, for credit-risky floaters.


Production ready substrate chain

Question: Currently i am using substrate-node-template and I have done all my work in that I want to make it production ready, Can someone tell me is there any guide that what changes I have to make in the template node to make it my own chain and how can i deploy it as my own blockchain so it is ready for anyone to connect with it and deploy contracts on that.
Answer: The first resource I'd go is the Network Maintainers section in the Polkadot wiki, where you have guides to set up the validators, nodes...
I want to share with you previous questions on StackExchange about this topic:

Solo Substrate chains - are there any examples yet?.
How to deploy a hardened, secure, production-ready Substrate node?
How we can go live as solochain?

Also, if you want the smart contract functionality on top of the substrate-node-template, you have been using you have to add the Pallet Contracts or the EVM pallets if you want to allow the deployment of EVM smart contracts (Solidity).
You can take a look in these templates:

Substrate-contracts-node, for a node with the pallet contracts.
Frontier, a template with EVM.
Comment: Hey thanks Alex so i have already configured the pallet contract node in my node template and i will be going with the aura consensus just wanna know now that which parts need to be changed in the node template of substrate in order to make the chain mine and i can interact and can deploy smart contracts on it
Comment: You want to run your chain as a solo chain, that means is up to you the security and everything. In case you want to connect to polkadot to  benefit from the pooled security, thought-through governance, and overall scalability of the heterogeneous sharding approach of the network you need to convert your node into a parachain
Comment: https://wiki.polkadot.network/docs/build-pdk
Answer: You first need to decide what consensus you want to use for block production babe or aura, as node-template use aura and substrate uses babe.
You must be familiar with how to set a private network you just need to set up the network on any cloud service like AWS, there is no specific guide on how to launch a production ready chain. You can follow this if it helps.

Production ready substrate chain


Help! Sigma Lens won't manually focus

Question: I have a Canon EOS 60D and a Sigma DG 150-500mm zoom lens that I absolutely love using for bird pictures, I've had it for a few years now and have never had an issue with the manual focus. It's just recently seem to have gotten stuck in autofocus mode even though the lens' switch is set to M. I can still manually move the focus ring but the camera automatically "fixes" it. I'm looking for anyone that may be able to help because I've looked through all the settings on my camera and I can't take good photos of birds in AF mode since they move too quickly for the camera to auto focus in time and the camera always focuses on the wrong thing, (like a leaf in front of the bird.) Please help! Anything is appreciated, thank you!
Comment: I don't know Canon camera so idk where to look, but check the camera registers when you move the switch. My Nikon changes its internal display to match M/AF when the switch moves.
Comment: I don't have this camera, but some searching suggests you can turn off autofocus using the camera's menu system.
Comment: Do you have set micro-adjustments?
Comment: @Tetsujin It sounds like the switch in the lens is broken and not setting the lens to MF when the switch is moved to 'M'. There's no way for the camera to override the AF/M switch (like Nikons can with the switch near the lens release button on the camera body), though the camera can be set to use various different buttons to initiate/pause AF.
Answer: It sounds like the 'AF/M' (autofocus/manual) switch on the lens has stopped working. Short of having the lens repaired, there are a few workarounds you can try.
Back Button AF On
In the 60D's "Custom Controls IV" (C.Fn IV -1) menu, [Menu → Custom Functions IV (the fourth line under the orange camera icon tab) → 1. "AF and metering buttons"], change the setting for the shutter button half-press from the default 'Metering & AF Start' to 'Metering Start'. This means that half-pressing the shutter button will NOT initiate autofocus. Ever. Under any circumstances.
You'll need to assign another button to initiate and maintain autofocus when you desire to use AF. By default, the 60D is set to use the 'AF-ON' button near the upper right corner of the back of the camera to initiate AF. You can also assign the AE-L (Auto-Exposure Lock) button marked with a star '*' symbol to provide the "AF-ON" function.
Once you've set the camera up this way, you'll need to press the back button you have selected for "Metering and AF start" anytime you want the camera to AF. If you release the button, the camera will stop performing AF and leave the focus position of the lens where it was at when you released the button unless you move the focusing ring.

If you've got the AF mode set to "One Shot AF" once AF is locked there won't be any difference between continuing to hold the back button or releasing it until you've fully pressed the shutter button to take a picture. (The "AF confirmation" dot in the lower right corner of the viewfinder will stop showing if you release the button after AF Lock has been achieved.)
If you've got the AF mode set to "AI Servo AF" then Servo AF will be active when the back button you've set to "AF-ON" is pressed and not active when the button is not pressed. When the back button is released the lens will stay wherever it was focused when you stopped pressing the button unless you manually turn the focusing ring.

I prefer to swap the functions of the 'AF-ON' and 'AE-L' buttons on all of my Canon bodies. I have the 'AF-ON' button set to do "AE Lock (Hold)" and the 'AE-L' button set to "Metering and AF start". I do this because my thumb more naturally falls above the 'AE-L button' than the 'AF-ON' button and I use back button AF for almost every frame I take, while only occasionally using the AF-L function since I normally use Manual exposure mode. YMMV.
Back Button AF Off
The other most obvious option is to leave the shutter button half press set to "Metering and AF start" and set the 'AF-ON' or 'AE-L' button to "AF-OFF". Any time you press the back button you've set to "AF-OFF" and hold it down AF will be paused and allow you to manually focus your lens. You'll need to apply continuous pressure to the button set to "AF-OFF" to maintain the manually selected focus position. If you pull your thumb off the back button set to "AF-Off" while holding the shutter button at half-press, the camera will again resume AF while the shutter button half-press is maintained.

Help! Sigma Lens won’t manually focus


Bespoke automatic receipt for specific campaign

Question: We want to send a bespoke receipt (schedule reminder) to donors who donate to a specific campaign. We are struggling to work out how to link the schedule reminder to contributions to that campaign - we've looked into CiviRules and think we have the extension (but can't find it anywhere on our UI). Are we missing something? Is there a way to set up the trigger email without CiviRules and if CiviRules is the best method to do this, do you have any advice on how to set it up?
Comment: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Answer: 1/ if you have civirules installed then
a/ you should see it listed as 'installed' at /civicrm/admin/extensions?reset=1
b/ you should find a CiviRules menu item under Administer (usually gets added at the bottom of the list)
2/ in terms of using it to send out a receipt, if you are wanting to include the amount they you may need an extension such as https://github.com/eileenmcnaughton/nz.co.fuzion.civitoken so that you have 'most recent contribution' value available to insert in to the message (there may be other ways of doing this. just wondering what else might trip you up)
ps i think it would help if you could flesh out in your Q. how bespoke a msg this needs to be, since there is some option in the default receipts to use smarty like IF campaign = goldfish then insert text saying 'thank you for the goldfish food' ELSE 'our goldfish are really hungry'


How much energy is saved when using luggage with wheels?

Question: How much energy is saved when using luggage with wheels as opposed to carrying the luggage? Thanks.
Comment: I think there are too many variables, at the moment, to give a decent answer to this question. Could you try narrowing it down some?
Comment: Transporting an 8 pound piece of small luggage across a flat surface, is more energy used just carrying it or pulling it (if it had a wheel)?
Comment: Energy used when lifting and walking the object = gravitational potential energy of the object after lifting it to height h + energy used to transport the object from point A to point B.

Energy conserved when wheeling the object = gravitational potential energy which was used to lift the object to height h - the amount of friction the wheels face.

However notice that the amount of energy you spend to lift the bag is RETURNED at the end when you place the bag down again, with the only disappointment being that you cannot possibly utilize that energy for anything useful (mostly).
Answer: There is no fundamental physics reason why carrying a bag should use more energy than wheeling it. Whether you be carrying a bag or wheeling it, you are essentially sliding it along a line of almost constant gravitational potential (aside from a little jiggling up and down with your stride), so the bag's total energy isn't changing and in theory does not need to be topped up.
The reason why animals like us expend more energy carrying than wheeling their bags is wholly to do with how animal muscles work. If you could clamp your hand shut around the handle, you would expend no effort carrying the bag. A muscle, even though it does no work on the bag, must be constantly supplied with energy in various chemical forms by the body to stay in a contracted state. This work is dissipated as heat in your forearm muscles as they holds the hand clamped shut. The process is explained in more detail in Malabarba's Answer to the Physics SE Question, "Why does holding something up cost energy while no work is being done?".
A further two factors are that:

In the contracted state, muscles are metabolising ATP and other energy stores and outputting waste, which swiftly "poisons" the tissue if it builds up faster than the circulatory system can get rid of it, leading to a lowered ability of the muscle to work and "tiring";
The contracted state of a muscle, and the accompanying stretched state of connective tissue actually hinders blood circulation to both.

Your muscles and connective tissue can brook neither of these things for long without needing a rest: this is why your arm feels like it's going to drop off if you need to walk without a wheeled truck for you bags for long.
AS for the exact amount of energy used by a muscle to stay in the contracted state, i.e. a quantitative answer to your question, you may need to put this to the biology stack exchange.
Comment: Then why is it so much easier to pull along luggage with wheels than to carry it? Why are most people using wheeled luggage, why not pick it up and carry it? It sure seems easier to pull. Never mind the hand grasping it, assume it's latched onto your belt and it's just being pulled. Thanks.
Comment: You do indeed need to apply less *force* to a bag to pull it on wheels than lift it up. This is different from the energy required. If it's latched onto your belt, then you are describing a *backpack*, which is a great deal easier than holding onto it with your hand. Clipped to your belt, it would almost certainly interfere with your gait.


Tried basically everything and still cannot dual-boot

Question: I wanted to dual boot Ubuntu and Windows for deep learning. I downloaded the latest LTS iso and flashed it onto a flash drive using Rufus. Then, I restarted the computer and went into BIOS. I booted from the USB and started the installer. I had previously made a partition on the hard drive(I have an SSD and a HDD) of about 50 GB. I tried installing on that partition, but then I get an error saying that the GRUB installer errored out. So, I tried disabling fast boot and trying again. I even tried creating a separate FAT32 partition for EFI and manually set the GRUB installation location to that partition(this is on the partition). I even made sure /dev/sda pointed to the SSD and /dev/sdb pointed to the HDD. Still got the same error. No idea what I should do. Please help out...
Answer: I would try making the partition for Ubuntu in the installer and not beforehand.
Leave your 50GB partition as free space, and in the Ubuntu installer create a 50GB partition formatted as an ext4 journaling file system, mounted on /, if you want you can create multiple partitions for the other mount points, although its not needed and you can just have them in one partition. Also you can create a swap partition, I would make it the same mb as your installed ram.
The grub installation location thing at the bottom left of the installer window, just leave it as it is and it should make a folder for grub2 in the efi partition created by windows.
Comment: That's the problem, grub2 installation isn't working...


Are buffer overflow exploits still a practical intrusion method?

Question: With many of the built in (non-added by a user) security measures, are buffer overflow exploits still a practical intrusion method?
What are the major security measures that negate buffer overflow?
Answer: Absolutely. Check the bugs fixed in your OS and you'll see buffer overflows patched. See http://support.apple.com/kb/HT5130 for an example.
Answer: Operating systems and compilers do a lot to try to prevent buffer overflows, but they are certainly still at problem.
The easiest way to avoid buffer overflow is to avoid languages like C that force you to manage buffers (and their sizes) in the first place. If, quite possibly, you cannot avoid using C-like languages, there are a bunch of ways to help mitigate potential problems:
Here's a start: http://en.wikipedia.org/wiki/Buffer_overflow_protection
Answer: Buffer overflows are still a common way to break into native applications, although I suspect the number of people practically exploiting them offensively for real-world intrusions is still quite low because of OS protection mechanisms such as ASLR and DEP and compiler protection mechanisms such as GS cookies (stack canaries).
Stack overflows are often not exploitable nowadays because advances in modern compilers mean that most (but not all) stack-overflows are detected during function execution causing the process to crash rather than yield execution to the attacker.
Heap overflows are very much exploitable, even on modern OSes, and must always be treated as critical.
Unfortunately there's no hard and fast rule as to whether any given specific stack or heap overflow is practically exploitable, however from a defensive point of view, all compiler and OS mitigations are just that - mitigations. They slow attackers down rather than stopping them, and if you're a security researcher you need to report both stack overflows and heap overflows as critical problems, and as a developer you need to fix them immediately.


Subdivision Surface Modifier Problem Blender 2.8

Question: I am having an issue with the subdivision surface modifier in blender 2.8. I am getting this weird spike in my mesh when I smooth it with the modifier as if the vertex is unaffected by the modifier for some reason. There is no random geometry inside the mesh and there are no double vertices.
Answer: Solution: This was an issue with my normals and I found the solution after more experimenting. Blender 2.8 made it less obvious to see the directions of the normals. Also, CTRL-n no longer recalculates normals. The new hotkey is SHIFT-n for "recalculate outside" and SHIFT-CTRL-n for "recalculate inside". I hope this information will help a fellow blender user.


What is the following assembly code doing?

Question: str fp,[sp, -4]!
add fp, sp, #0
sub sp, sp, #12
str r0, [fp, #-8]
str r1 [fp, #-12]

L5:
ldr r3, [fp, #-8]
ldrb r3, [r3]
cmp r3, #0
beq .L2
ldr r3, [fp, #-12]
ldrb r3, [r3]
cmp r3, #0
beq .L2
ldr r3, [fp, #-8]
ldrb r2, [r3]
ldr r3, [fp, #-12]
ldrb r3, [r3]
cmp r2, [r3]
bne .L8
ldr r3, [fp, #-8]
add r3, r3, #1
str r3, [fp, #-8]
ldr r3, [fp, #-12]
add r3, r3, #1
str r3, [fp, #-12]
b .L5

.L8
nop

.L2
ldr r3, [fp, #-8]
cmp r3, #0
bne .L6
ldr r3, [fp, #-12]
cmp r3, #0
bne .L6
mov r3, #0
b .L7

.L6
ldr r3, [fp, #-8]
ldrb r3, [r3]
mov r3, r3
ldr r3, [fp, #-12]
ldrb r3, [r3]
sub r3, r2, r3

.L7
mov r0,r3
add sp, fp, #0
ldr fp, [sp], #4
bx lr

Comment: Very low effort question. You should at least provide some context and what you already discovered.
Comment: please at least format the code better so it's easier to follow
Comment: Thank you! will keep that in mind. I'm new to RE, could you please help me understand the above code
Comment: Have you tried stepping through it with a debugger?
Comment: yes, since there isn't any proper structure to the code, debuggers weren't of much help to me. I understand that there is some kind of if/if-else/switch happening but can't really put my finger on it
Answer: I think this is a strcmp function which was compiled without optimization and is really inefficient.
Here is why:

The function only uses r0 and r1 which are first and the second parameter.
Both parameters are pointer because they are dereferenced
All memory access are byte long
Read bytes are compared against '\0'
Read bytes are compared using the instruction cmp (subtraction without modifying the destination register)
When the byte differs, the returned value is both bytes subtracted (.L6)
If both read byte are equal, pointers are incremented by one and it branches back to the comparison block
They are extra copies on the stack, it's useless and typical from non-optimized code


Visual Sorting array of images in Javascript using CSS3

Question: Check out this demo by FaTaL. It is explained in his blog that he has used CSS3 :target and transitions to achieve this "visual sorting" of images. The target positions have been hard coded in pres.css
The problem is that my array of images is generated at real time. Here is a demo. I want to "visually sort" these images (on button click) alphabetically by file name. How can I achieve such functionality with CSS3 without hard coding the positions ? A JSON object of filename and other parameters will be available at runtime for the sorting.
Answer: I could not think of any CSS solution. So, here is my pure Javascript solution. Live at http://jsfiddle.net/uhAEA/1/.
It sorts based on the value set on each a tag's sortelm attribute.
Answer: This is exactly the kind of stuff I was looking for http://isotope.metafizzy.co/
Hope it also helps some of you out there.


Ubuntu Linux UFW Firewall, Local Intranet Access

Question: At home, I have Ubuntu server with the UFW firewall. What command do I type to turn on local intranet access to my web server, but keep the outside world out from my DSL modem?
Comment: Is the DSL modem a NATing router?  If so, and if you haven't forwarded any ports to the server, then leaving the firewall wide open is fine--nothing's getting past the router.
Comment: This is a just-in-case kind of thing. You never know when some thief finds a router exploit and can play with MAC addresses to get through.
Answer: sudo ufw default deny
sudo ufw allow from 192.168.1.0/24 to any port 80

Assuming the web server is on port 80 and 192.168.1.x is your home subnet. If you explicitly want exclude your router, then assuming it's 192.168.1.1, it would be:
sudo ufw deny from 192.168.1.1 to any port 80


Looking for new ideas for exercises

Question: Sworkit is pretty good for demonstrating and explaining various exercises, but I'm looking for something more. Like difficult and weird exercises, you know, something with an unfamiliar range of motion. I mean, I make up my own exercises here and there, but I'm looking for something that's fun, unheard of, undervalued, and esoteric. What do you know that is like this? This includes the novel use of equipment, like, say using a disconnect grip triangle for some difficult balancing push ups or using a barbell as an ab roller.
Comment: Google the word "calisthenics". That will keep you busy for the next 8 to 10 years :)
Answer: My advice would be to train for skill acquisition, like in gymnastics. There are endless skills to get, so there's plenty of variety, it's very fun IMO

L-Sit / V-Sit
tuck planche / straddle planche / full planche
handstand / handstand pushups
handstand walk / handstand pirouettes
iron cross (there are progressions for this but it's quite advanced)
back bridge
L-pullups / L-muscle-ups
rings muscle ups
Hollow Holds (with ankle weights if you want it harder)
Arch holds
back flip / front flip
pommel horse circles
etc etc

These should keep you busy quite a while. Some of these do require spécial equipment that you'll only find in a gymnasium, but most of if can be done without
Comment: This is good. I also am looking for alternate ways of, or combining, equipment for (safe) unique exercises. Like, the other day I saw a video of a guy using a barbell as an ab roller.
Comment: Most of these are done on the gymnastic rings. I recommend everybody to get a pair of these since they are really cheap, allow you to do a huge range of exercises, and provide a great instability that will work your stabilizers like not much else
Answer: I would highly recommend you try some brazilian jiu jitsu, which is a mixture of grappling/wrestling/submissions/judo. Do a drop in class. You'll be using muscles you never knew existed (a lot of hip motion and weight distribution mechanics). A lot of great condition rolling (6 minute sparring sessions) with an opponent where the fear of claustrophobia and getting choked out has you going hard.
It's basically 3d chess with a human whose body opens up a plethora of moves that you will have to drill and train in to either counter/beat. It's going to suck in the beginning but if you're looking for a workout and a challenge, you'll be hooked (no pun intended).
Comment: Have you seen [this](https://www.youtube.com/watch?v=LbhFdjiPe6w) video?
Comment: Yeah, I think tai chi is great for movement/meditation purposes but not for the average joe looking for self defense martial arts in a short time span.
Comment: Agreed. Just thought to show you. ^_^

Looking for new ideas for exercises


What will happen if we sample the most probable value in the Gibbs sampling?

Question: I am now working with the Gibbs sampling. One problem that puzzled me is that when we use the Gibbs sampling, we always sample randomly from the conditional probability. What will happen if we sample the most probable value instead? Thank you in advance.
Comment: Are you asking what happens if the most probable value is *sampled* or are you asking what would happen if we always just take the mode of the conditional distribution at that step?
Comment: Thank you Matthew. Yes, I am asking what would happen if we always just take the mode of the conditional distribution at each step.
Comment: You would certainly become overconfident in your posterior distributions for all parameters, because you are no longer accounting for as much uncertainty in one parameter. The impact of this is that you would have too low (i.e., too low compared to the true value) variance in your posterior distributions for all parameters (and especially so in the one). I can't really speak with any authority on the other impacts of this design choice. With that said, I have used this approach in **testing phase** to see how close my sampler is to the most likely values to see if my code is making sense.
Comment: Your sampler will also tend to get stuck on a local maxima.
Comment: I was about to ask the same question and then I found this thread. I would like to add a sub-question here: would it be equivalent to some other method like some EM to find the MAP...?
Answer: This would no longer be an algorithm for sampling from the posterior, but rather be an algorithm for optimization of the posterior, i.e., finding the MAP estimator.
In fact, this algorithm would be exactly that of coordinate descent (although technically coordinate ascent). In this algorithm, one at a time, you optimize each parameter while keeping the others fixed. In general, this is considered a rather slow algorithm, especially if the parameters are highly correlated, but somewhat surprisingly, it is the algorithm used by LASSO.


Change OL3 drawing cursor (blue circle)

Question: i'm looking to change the cursor of ol3 during drawing from blue circle to crosshair, i've tried this answer, but it changes only OS cursor not ol3 cursor, is there any idea ?
Comment: My Draw interaction doesn't have a style property. Why is this?
Comment: If you have a new question, please ask it by clicking the [Ask Question](http://gis.stackexchange.com/questions/ask) button. Include a link to this question if it helps provide context. - [From Review](/review/low-quality-posts/82497)
Answer: You can use the Draw interaction's style property to change the default appeal of the cursor. To change the style, you have to provide all of the appropriate properties for the type of the drawn geometry (e.g. stroke, fill, image for polygon).
As you can see in this example, the ol.style.Icon does not work on the draw interaction. This might be a bug, I didn't check the source code. The other two image styles, ol.style.Circle and ol.style.RegularShape work like a charm.
Your best bet for now would be to use a regular shape, and create a star with 4 points, a big outer radius, and a very small inner radius. This way the resulting star could represent a crosshair.
PS: Other option would be not setting the image property of the interaction's style, just altering the browser's cursor over the map while the drawing interaction is active.
Answer: As for the ol.style.Icon you need to specify the correct size of the linked image in order to see the whole part of it. At the same time you can use the scale property to downsample the original image. As in this example.

Change OL3 drawing cursor (blue circle)


I'm trying to find enough sensory description for my book

Question: How do I describe when a person falls unconscious with enough sensory details?
Comment: @KateBunting It's not an on/off switch but a dulling of sensation.  It's like going to sleep and waking up.  You don't realize you fell asleep when it happens, and when you wake up, you don't realize the processes is happening right away.  There are cases where reality can bleed into subconscious experience resulting in a dream where real sensation is interpreted into not real scenarios.  For example, I once had a dream where I was hanging with Scooby-Doo and co. and we were trying to find a source of a mysterious beeping sound... turns out, it was my parent's alarm clock in the next room.
Comment: If they're unconscious, they can't sense anything, can they?
Comment: @KateBunting You're right, but OP wants to know what the character would sense *while* they're falling unconscious.
Comment: @hszmv - Yesss - I know all that; I was being a bit sarcastic at the OP's expense for not providing enough detail about what they _really_ want.
Answer: This is a tricky challenge. We don't usually notice things like falling asleep, or falling unconscious, so it's hard to describe it in real time.
Here are a few options.
Have the character struggle against it
This is a common trope for characters who notice they've been drugged. Think of trying not to fall asleep: you drift out of consciousness and then jolt back awake. Or maybe the world slowly fades into a a dream scape with your thought becoming illogical and disjointed.
You can go back and forth a few times, and then have the character lose the struggle.
Jump cut
This is probably closer to how the experience feels to us. Everything suddenly stops. You can emphasize this by having another character say something that suddenly cuts off.
Then, your character wakes up with a jolt and they have no idea where they are or what happens. They probably feel like crap and they have to figure out what's going on fast. Always a good starting point for some dramatic action.
Intercut with a flashback
This is another trope, but it's a useful one. While the reader is trying to figure out what happened and where the character went, go into a flashback.
One big benefit is that is helps to convey the passage of time. For some reason, when we're unconscious we still get a basic sense of time passing. With the jump cut, you don't get this, which makes it feel a little different from the real experience.
The flashback is a way of putting some time between falling unconscious and waking up. It could be any scene, you could also cut to some other character doing something else (if your point of view allows it), but the flashback has the benefit of feeling a little like a dream the character might be having while unconscious, or some general subconscious processing.
Answer: I recently had surgery, and I clearly remember how I was applied an anesthetic and lost consciousness while the medical personell was still talking to me. To me, the experience was similar to falling asleep, with the difference that there was no transition into dreams. When we fall asleep, our thinking continues from conscious thought into dream seamlessly. You become aware of this transition when you startle awake when you are falling asleep: internally, you had a continuous thought process, but when you wake up again you realize that you had already been dreaming, because in hindsight what appeared to be "thoughts" and "perceptions" had become increasingly unreal and illogical. When I fell unconscious after having been given an anesthetic, all of my perceptions – internal (thoughts) and external (vision, hearing, and other sensory perceptions) – simply faded to nothing over the course of a few seconds. It was very quick.
I don't know how falling unconscious due to other causes might feel. If you are "knocked out", the loss of consciousness is perhaps quite sudden and you do not notice that you lose it, only realizing that you had been unconscious when you wake up (see these questions about how to describe someone waking up from unconsciousness: How do I write a scene when a character wakes up from being unconscious? and Help with describing an unconscious character). Falling unconscious because of psychological (e.g. shock or dissociation) or organic reasons (e.g. due to a decrease of blood flow to the brain) might feel quite different again.
So, to answer your question:
The common approach when you don't know how to describe something you haven't experienced yourself is to do research. You need to find descriptions of what falling unconscious feels like. There will be reports online or in books or articles, or you can find someone who has experienced it and will describe their experience to you.


No TM Grammar registered for this language

Question: What causes the error "No TM Grammar registered for this language" when creating / debugging your own custom syntax in VS Code?
Answer: For me it was that the contributes.languages.id property of package.json needs to match the name property in the tmLanguage.json file. Also, the contributes.grammars.scopeName of package.json needs to match the scopeName of the tmLanguage.json file.
Answer: I hit this problem as a result of defining the grammar in YAML and using js-yaml to translate it, per the VSCode extension docs suggestion.  It looks like js-yaml outputs in UTF-16 LE, which is loaded just fine by the VSCode editor, but the VSCode TextMate grammar parser doesn't support.
Clicking the encoding at the bottom right of VSCode and saving it as UTF-8 fixed the problem.
Answer: Validate your tmlanguage.json file.
Invalid json files are not loaded and registered.
Answer: For me, my tmLanguage.json file was in UTF8+BOM format, which VSCode seems to (silently) not like. Changing it to normal UTF8 format fixed it.


How to either simultaneously delete photo from photo stream and all devices; or

Question: how to designate a photo not to go to the cloud at all.  I'll do something like take a picture of an item at Costco to look it up on the net later.  But I don't want the picture bumped to the cloud, then to my Mac and pad.  It's going to be deleted once it's done it's job.  As it is, I have to delete from my phone, the cloud, the mac and the pad, which gets old.  Or simply leaving them there cluttering up my photos collection.
Comment: I countered the down-vote because I agree that the current setup is a PITA.  If they want to upload the photo automatically and distribute it, then it should also distribute the removal of the pic.  Or the photo should just sit there until you move it to the iCloud folder. I have the EXACT same issue, I take pics of items in stores (or of the kitchen faucet before going to home depot) and these pics end up everywhere, and seem to stick around even after you think they are all deleted.
Answer: Turn off the automatic stream button for streaming file from cloud to Mac and iPad, this may work.


What other technology exists that are safer and simpler then cellular wavelength communication?

Question: Communication without all the hassle. Is it to be presumed that cellular technology is the only form of external communication the world has to offer.
Comment: People interested in answering your question have to put in a lot of effort - **for free**! They have to come up with a new "safer and simpler" approach compared to what you say is the standard to the point where people think no alternatives exist and then they have to explain it in detail. The least you can do is show them that you appreciate it by writing more than 1 1/2 sentences and  no explanation or introduction to your world whatsoever. You will find that people here are extremely helpful if you put just a little bit more work into your question
Comment: I rolled back your edit because that picture adds nothing to the question and adding random pictures into posts is basically vandalism. Please take a look around the site to see how questions and answers are phrased.
Comment: Welcome to worldbuilding. Please take the [tour] and visit the [help], in particular [this](https://worldbuilding.stackexchange.com/help/on-topic) to better understand the type of questions we appreciate here. For your question I have problem understanding if it is about world building at all. To me it sounds more like an electronic engineering question. Can you make this aspect more clear?
Comment: What do you mean by "cellular?"  Cellular technologies make up but a tiny fraction of the communications fabric we use today.
Comment: This link here is the sandbox where you can post your "proposed" questions then people will contribute and tell you how you should create or make your questions a little bit clearer, I upvoted this question so that you can enter this site. https://worldbuilding.meta.stackexchange.com/a/6523/28224
Comment: I have no idea why you added that extra line into the comment, but I removed it because it added no value and made no sense.
Comment: @Shadowzee, FYI you can also use the rollback feature to revert edits
Answer: I'd say it would be speaking, for that is the only thing I got from 10 minutes of brainstorming. If the message is an universal one, like shining a light at a plane means "help me", and that there is the appropriate materials, it could be done, but I wouldn't count on that as communication since you could not make it so that you send a complete sentence, but only what it has to offer, in this case, "help me".
Then, speaking is not that bad. You can instantaneously send a message at the speed of sound, one that most can comprehend if you're speaking in the same language, easily yes because people inside your speaking distance are often in the same country as you. You can also whisper, needing a closer distance but also safe from other peoples ears.
If this is in another world, not necessarily more high tech as this one, there could be underground lines which you connect to through an id, then put earphones on, not counting as wireless, then entering a number to connect to another person on the line. If there are enough lines, and people have specific glasses that allow only them to see their share of information on the line and alerting them, it could be good enough. There would just be people who don't understand why there are no cell phones with this technology.
Phones at home would be similar, since they are in the same place, it could allow for wired only connection, but it isn't as simple as cell phones.
In all of this case, the only method that allows the communication near to the simplicity and safeness of the cell phone is the ground lines.
Comment: I was thinking more along the lines of using other natural forces to tag on to to transmit ....such as light or water or even the effects of gravity on us that we can't necessary feel but is there.
Comment: Unless this spacial awareness observed phenomenon is unclear to you simply Imagen a bubble of water forced in a direction and that surface is reflecting a coded screen of information.
Comment: Obviously behind the scope of understanding around here.
Comment: It may be worth pointing out that radio-frequency devices (including cell phones among countless others) *do* transmit using light. You could use a radio laser (raser?) instead of a broadcast, which has certain advantages and drawbacks, but the same principles would apply.


The onclick event does not work for options

Question: Following is my code which works fine in firefox but not in chrome.
Kindly let me know how to solve this issue. The main idea is to call a js function based on the selected value of select box:
<select onselect="question_type(this.value);" name="qtype" id="qtype" class="form-control input-lg" required>
    <option value="">-- Select question type for this quiz --</option>
    <option onclick="question_type(this.value);" value="mcq">1) MCQs</option>
    <option onclick="question_type(this.value);" value="tf">2) True/False</option>
</select>

Comment: why not use `onchange` instead? [Fiddle](http://jsfiddle.net/Alfie/eLQTY/2/)
Comment: @adeneo it worked in firefox.
Comment: @anton adeneo told that options don't fire mouse events in chrome.
Answer: options don't fire mouse events in chrome.
For a select element you'd use the onchange event on the select itself, and the value of the select will always be the same as the selected option
<select onchange="question_type(this.value);" name="qtype" id="qtype" class="form-control input-lg" required>
    <option value="">-- Select question type for this quiz --</option>
    <option value="mcq">1) MCQs</option>
    <option value="tf">2) True/False</option>
</select>

with jQuery it would be
$('select').on('change', function() {
    var selected = this.value;
});

Comment: even this is not working in chrome:`onselect="question_type(this.value);"`
Comment: @user3027531 - A select element and it's options don't have an `onselect` event ?
Answer: Now I see many people asking why not the change event, well because I dont want to have to do it like this
<select id="custList" class="_List" size="15" runat="server">
            <option disabled="disabled">choose your stuff</option>
            <options......
</select>

Nor would I like to do this either
<select id="custList" class="_List" size="15" runat="server">
            <option selected="selected">choose your stuff</option>
            <options......
 </select>

Sure there is a lot of fancy css stuff you can do together with js to overcome the situation but that means more code and more events and more that can go wrong...
As a user if the option I want is the very first, why would I first have to click on the next one just so I can select the first one! my first intuition is click on the first one! but that does not select the option and it doesn't fire the event :(
So thats a good reason why we want the click event apposed to the change event which we will also use. (Like a belt and suspenders...)
Now I have also read a lot of answers/posts with "You cant, use change" but actually that's not completely true, you can get click events to fire on a select option, however the only way I have gotten it to work is if you define a size > 1 which makes it more a list than a drop-down and maybe that is why it works...
However if you are trying to do it in the following ways it wont work!
$("#select option").on('click',function(){}); //won't work!
$(".option-class").on('click',function(){}); //won't work!
<option ... onclick="myFunc()" value="blah">blah</option> //won't work!

Answer: I've made an interesting discovery, that has a material impact on this question. NOTE: this occurs on Chrome Version 63.0.3239.108 (Official Build) (64-bit), running on Windows 7. What I report here may differ on Chrome running on other platforms, but it is worth investigating anyway, in case the same solution works on other platforms.
I wrote some code, to create pop up dialogues, allowing me to select various options. The code allows the dialogues to appear one on top of the other in sequence, and be dismissed in reverse order. This code was then coupled to two dialogues, both containing select controls.
I then wrote a function, to populate those select controls with option elements, which attached click event listeners to the options. The function was duly called to attach data to the options being appended to the relevant select controls.
Dialogue #1 was then launched. The select control was manipulated, and the click event duly fired on the options I selected, all easily observable courtesy of [1] tracing through the Crome debugger, and [2] the effect the event listener code had on other DOM elements in the dialogue.
Dialogue #2 was then launched, and overlaid over Dialogue #1.
The select control was then manipulated, and ... no click events were fired.
What was the difference?
The difference, was that the select control on Dialogue #1, had a size attribute set (in particular, size="5"). The select control on Dialogue #2, did not have a size attribute set.
The moment I set the size attribute on the select control on Dialogue #2, click events were properly fired once more.
If you want click events to work with options in a select control on Chrome, you must set a size attribute on the select control, viz:
<select id="MySelector" size="6"></select>

If you omit this attribute from your select control, click events will be ignored.
It now remains to be determined, if one has to set the size attribute directly in the HTML file before running the JavaScript code, or whether setting a size attribute in JavaScript before attaching options will also work. Let me get back on this one while I test it.
EDIT: I've just tested to see if adding a size attribute to the select control in JavaScript, instead of in the HTML file, works as a means of enabling proper handling of click events on option elements in Chrome (version details the same as before), and this also works. So, code such as:
sel = document.getElementById("PickSecondaryClue");
sel.setAttribute("size","5");

will also work.
Apparently, there are special caveats applicable to the size attribute in Chrome to take account of - certain values are documented, at least in some versions, as exhibiting unexpected side effects.
Now it remains to see if this works in Firefox too.
EDIT 2: Also works in Firefox. (57.0.2 64-bit)
Comment: UPDATE: I have since discovered that click events on options **do not work at all** in Google Chrome for Android. For that platform, for the moment at least, you **have** to use the onchange event.
Answer: A different approach would be add an event listener to the  and not the options.
var e = document.getElementById("qtype");
var selectedSelect= e.options[e.selectedIndex].value;

the above code will find the select element and call it e. Then find the value selected and call it selectedSelect. Then you can simply pass this value into the question_type() function.
Answer: $(document).ready(function(){
    $("#qtype").change(function(){
        $(this).find('option:selected')
        // do something....
    }
})


Can particle spin actually show quantum effects like the disruption of measurement?

Question: I was going through a quantum objects course on brilliant.org, a few things have been bothering me and though I searched A LOT I can't seem to find any answers. For one, the course implies that a neutron going through a magnetic field aligned on the z-axis will come out of the magnet as spin up and spin down and says that this is due to the spin of the neutron. I've looked it up and people seem to be directing the magnetic moment of the neutron not to its spin properties but to the moment of the quarks within it. Which one is it?
Secondly, 100 particles whose spins are aligned on the positive z axis are taken and passed through a magnetic field aligned with the x axis. This time, it is observed that they come out with their spin aligned either on the positive or negative x axis. They put the ones that came out with their spins aligned on the positive x axis, put it once more in a z-aligned magnetic field and have us observe that they come out with positive and negative spins along the z axis once more. So then, they do the same z-x-z magnet set-up that they had, but they make it so that all the outputs of the x magnet go directly to the z magnet without being observed. Then, they state that now none of them are directed with spin down, because only measurement of a state will change the state itself.
This particular phenomenon is a part of quantum physics as far as I can tell, but given that we have an ideal environment and can do these experiments, will these actually hold out the same way we are told they will? Are they just using these as analogies to explain the topic itself or can I actually put a neutron whose spin has been aligned on the positive z axis, not measure it, put it in to an x aligned magnet and it will come out just as it was? Whereas if I observe it, it will come out as aligned with positive and negative x? Shortly, are the things they are saying experiments that hold true?
Comment: Forget about quarks here. The magnetic moment of the neutron is aligned to its spin, so in a magnetic field spin up neutrons have different energies than spin down ones. The rest sounds like a discussion of standard counterintuitive non-commutativity features of QM, best studied in Feynman's undergraduate text, vIII.
Answer: The neutron is a spin 1/2 neutral particle. That means the only magnetic property it can have is a dipole moment, and it must be aligned with the spin.
It can have an electric dipole moment, but that is parity and time-reversal violating (see: Electric Dipole Moment of the neutron).
Since it is neutral, but has a magnetic moment, it must have internal structure: valence quarks, sea quarks, gluons, all with spins and possibly orbital angular momentum.
How they create the spin/magnetic moment is an area of active research (The Proton Spin Crisis), but it completely irrelevant for the Stern-Gerlach (SG) experiment.
The question seems to think the quarks can move around and change and affect the spin/magnetic moment. This is not the case: you can flip a quark spin, but then you have a $\Delta^0$ baryon, not a neutron. All neutrons are identical and indistinguishable, there is no wiggle room.
Regarding the SG experiment: yes, all that can be done. Your description starts with an unpolarized mixed state, which requires density matrices. A simpler formulation with all the essential features begins with a beam of up ($+z$) polarized neutrons in a pure state:
$$ \psi = |\uparrow\rangle $$
In terms of the $x$ basis, this is:
$$ \psi = \frac 1 {\sqrt 2}[|\rightarrow\rangle + |\leftarrow\rangle]$$
When that is passed though an $x$-oriented SG device, there are two spatial separate beams:
$$ \frac 1 {\sqrt 2}|\rightarrow\rangle = \frac 1 2[|\uparrow\rangle + |\downarrow\rangle]$$
$$ \frac 1 {\sqrt 2}|\leftarrow\rangle = \frac 1 2[|\uparrow\rangle - |\downarrow\rangle]$$
If you then pass the $|\rightarrow\rangle$ beam through a $z$-SG device, you split into two beams of $\frac 1 2|\uparrow\rangle$ and $\frac 1 2|\downarrow\rangle$. (Note, the $\frac 1 2$ gets squared, so each beam has $\frac 1 4$ of the original number of neutrons.)
On the other hand, if you recombine the beams and pass them through the $z$-SG device, you do not have which-way path information, and you need to add them coherently:
$$ \psi =  \frac 1 {\sqrt 2}|\rightarrow\rangle + \frac 1 {\sqrt 2}|\leftarrow\rangle $$
$$ \psi = [\frac 1 2[|\uparrow\rangle + |\downarrow\rangle]]
+
[\frac 1 2[|\uparrow\rangle - |\downarrow\rangle]] = |\uparrow\rangle $$
and when that traverses the SG device, a single up polarized beam emerges.


Bach prelude in C major: unresolved suspension?

Question: I know that in the common practice style, even in free composition where guidelines don't apply strictly, a dissonant suspension must resolve. In the WTC 1 prelude in C major, bar 20 is a C dominant 7th, followed by the expected F. But, contradicting our expectation, it's an FM7 chord, keeping the leading tone at the top of the chord (where it happens to be harshly dissonant with the bass). This could be a 7-8 suspension (considered weak, but passable), but it never reaches F. Instead, it slides down chromatically to a diminished 7th in bar 22. Why did Bach do this, and does this technique have a term?
mm. 20 – 21

mm. 21 – 22
Comment: @justANewbstandswithUkraine No, it doesn't. These are two completely different things, and I don't see how they relate to each other in any way. Please read my entire question.
Comment: Irrelevant to the main question, but why on earth did you take your two excerpts from two different editions?  It's rather disconcerting…
Comment: @PLL I have no idea, those were edited in by someone else.
Comment: Does this answer your question? [Why does Bach sometimes end with flat 7ths?](https://music.stackexchange.com/questions/98282/why-does-bach-sometimes-end-with-flat-7ths)
Answer: I would argue that there is a name for this phenomenon: the E is a chord tone!
Bach has a C7 chord in m. 20, but he decides to keep the E as a chordal seventh (creating a IV7) in m. 21. This is not at all unheard of in this style, and the added seventh dissonance just continues the tension and drive to the dominant that ultimately appears in m. 24.
But we can have our cake and eat it too, if we wish. Recognizing that this seventh is a dissonance with an urge to resolve downwards, there is a predominant prolongation in mm. 21–23. It ultimately moves from a IV7 to a ii half-diminished 6/5, meaning that this E does resolve down to D as expected; it's just delayed by the E♭ over the F♯.
Comment: Really glad someone posted this interpretation.
Comment: Interesting interpretation. So, dissonances can be resolved by both voices moving, it doesn't have to be just one voice? I was under the impression that resolution of dissonance entailed one dissonant voice moving to meet the other in consonance.
Answer: Yes, I would say this can be called an unresolved suspension. The 7th, e, is prepared in the previous chord, but does not resolve upwards into f. Rather it moves downward to form a fully diminished 7th chord.
This shows that the true target of the chord progression is to be found in m. 24, the dominant pedal point, while the f serves as subdominant, which is briefly tonicized.
Bach was fond of the subdominant 7th, btw :)
Answer:
...but it never reaches F.

Probably the most obvious way the F could have been reached would be this...

But instead the E4 is held and my first reaction when hearing that is an allusion to a sequence of seventh chords, here is an example in G...

That's fine, but begs the question why wasn't the E4 resolved after that?
I think the essential dominant/tonic harmony of mm.20-21 is clear enough that it fulfill the two bar phrase patterning that started at m.6. Mm. Here are the last four iterations of that pattern...

In other words mm.20-21 satisfies as an iteration of the two bar phrasing pattern and the music can just continue on to the next phrase.
This is where I think an important rhetorical device is at work. Mm. 21-24 is a build in tension leading to the extend section over a bass pedal dominant. This is the climax of the piece. If m.21 had resolved the E4 to F4 it would have been strong cadential harmony akin to a full stop, a period at the end of sentence. By not resolving that E4, but yet fulfilling the two bar phrase pattern, the effect is more like a comma, and incomplete phrase that leads into the next phrase. Through this effect m.21 kicks off the build of tension toward the dominant pedal. It's a way to avoid a stop at a point where we really want momentum.
So, my way of looking at it is resolving E4 to F4 would have been the pedantic thing to do. It would place formality over artistic effect. Instead, by holding the E4 we get:

an allusion to the sequence of seventh chords which is pretty in its own right
a prolongation of tension that begins a dramatic progression to the dominant

Artistic choices like that are the difference between ordinary and extraordinary.
Answer: What is Bach doing?
This situation does not meet the definition of a suspension, since the resolution, by definition occurs within the "next" harmony. But it also doesn't meet the definition of a pedal point, because the harmony should resolve to meet the pedal point.
There is not a specific label for what Bach is doing here.
But let's call it a suspension
Since suspension is mentioned in the question, it's worth discussing as such, but stretching the definition so that the resolution can be delayed into a later harmony.
In that case, there are two separate issues, it's just that they are typically discussed as a single entity.

Suspensions move downward by step.
Dissonant harmonies resolve.

In a textbook suspension, one has, say, a V7 chord which moves to a I chord, but the dissonant scale degree 4 (the chordal seventh) is suspended into the I chord before moving downward to scale degree 3, a consonance. We typically learn this as a single idea.
But two things are happening: (1) the suspension is moving down by step and (2) the dissonant harmony (V7) is moving to a consonant one (I).
However, these can happen separately, and that is what Bach is doing.
As stated, m. 20 features a C7 chord, but in m. 21, the leading tone E, rather than resolving upward to F, is suspended — and does not resolve within that chord. (It can't, because neither Eb nor D would constitute a harmonic tone.) Instead, it moves downward in m. 22, to Eb, becoming the seventh of an F#o7 chord. This satisfies the condition that a suspension move downward to a tone that is part of the harmony, which itself happens to be dissonant. Bach maintains these tensions until the final measure of the piece. ("Tensions" rather than "dissonances", since there are some harmonies that are technically consonant, but don't feel like resolutions.)
Answer: There's a lengthy discussion of this here:
https://www.reddit.com/r/musictheory/comments/iu65lp/function_of_major_7th_chord_arpeggio_in_bachs/
(But note the early comment: "You're getting some weird-ass answers here." :-) )
I wouldn't see much value in calling it a suspension, unless you want to call the E♭ on top of the subsequent dim7 chord another suspension...   I'd look at it more in terms of voice leading causing the sort of 'crunch' we're more used to hearing in Bach's purely polyphonic works - no-one (I hope) goes through a Bach fugue trying to hang a chord symbol onto every beat of music!
I agree, the harmonic padding does create a surprisingly 'modern' flavour at that point.   I'm sure most of us noticed and savoured that moment when we first played the piece.


Connection through Amman

Question: I'm a Pakistani national and will be flying from Moscow to Cairo via Amman on Royal Jordanian Airline. My Layover in Amman is around 10 hours, if I wish to not leave the airport do I need to get a visa in advance. I called the embassy in Pakistan and they weren't really helpful.
Answer: You do not require a transit visa for Jordan.

TWOV (Transit Without Visa):
Passengers with a confirmed onward ticket for a flight to a third country within 48 hours. They must stay in the international transit area of the airport and have documents required for the next destination.

Source: Timatic using Emirates' website

Connection through Amman


Is "bumption" a word?

Question: "Bumptious" means conceited or pompous. Does the word "bumption" exist to describe such a trait?
Comment: Edit your question. Gumption or bumption?
Comment: The word _bumption_ has appeared in print in the past. See, for example, "[_Boundless Bumption_](https://books.google.com/books?id=h4_NAAAAMAAJ&pg=PA322&dq=%22bumption%22&hl=en&sa=X&ved=0ahUKEwjTuJXp4LnhAhXVuZ4KHRkVBJ8Q6AEILzAB#v=onepage&q=%22bumption%22&f=false)," an editorial in _The Bible Champion_ (August 1918): "Such disgusting self-conceit is so offensive to the great multitude of educated Christians, that it might fitly be termed Unmitigated Gall. _The Bible Champion_ would better characterize it as Boundless **Bumption**." Like _bumptiousness_, _bumption_ seems to mean "conceitedness."
Comment: Bumptious is an adjective, bumptiousness is the noun.
Comment: ...but in the [Dayton chapter notes](https://books.google.com/books?id=sPI-AQAAMAAJ&pg=PA790&dq=%22bumption%22&hl=en&sa=X&ved=0ahUKEwihzNeb5bnhAhWEjp4KHbKTCz04WhDoAQhIMAU#v=onepage&q=%22bumption%22&f=false) of _Banking: Journal of the American Bankers Association_ (June 1912), the term is used in a considerably more positive sense, in a slogan that is "emblazoned on [a shield] on the wall": "Brains, **bumption**, bullion, bankers and borrowers make business." Here, _bumption_ seems to mean something like "nerve" or "self-confidence" or "gumption."
Comment: Bumtiousness, I'm afraid, is the not-very-neat word that does exist. I'd love there to be a word "gumtious", but this doesn't exist!
Answer: Instances of 'bumption' in the wild
The vast majority of matches that Google Books and Elephind searches generate are false positives involving misreadings of line-broken occurrences of assumption, consumption, presumption, or resumption.
Nevertheless, true occurrences of bumption do sometimes occur, albeit not always in situations where the intended meaning is (as one might expect) "conceit." The earliest match I've been able to find is from "Topical Dots," in the [Hobart, Tasmania] Mercury (May 10, 1879):

Higgins expounded his chosen text and delivered himself of a voluminous section from the Scripture of scurril, attaching and vilifying a whole population who had somehow incurred his displeasure. Perhaps his insufferable bumption did'nt go down, or his vanity got hurt, or his pretentious assumption got discounted, for Tasmania is not a good market for mock Turtle. Gentlemen usually got along well enough ; but Higginses—Bah!

The meaning of bumption here is clearly "conceit"—but the writer's tendency to exceed the bounds of contemporaneously accepted vocabulary to suit his purposes is evident in his use of scurril as a noun (evidently back-formed from scurrilous) in the sentence before the one in which bumption appears.
Next, from "Rural Tasmania," in the Launceston [Tasmania] Examiner (July 30, 1887):

Some time ago down south I interviewed a gentleman who owns, I think, the largest extent of irrigated land in Tasmania, as well as the most productive. He was, at the time, in the House, member for this district, and so perhaps a little high in the collar as M.'sP. are apt to be. He said, after introduction, "Ah, Mr. —— I have expected a call from you, sit down. Now, Mr. ——, some of my friends say I have fish on the brain, and others say I have water on the brain." Though, as a rule, diffident in the presence of important people, temptation got hold on me; so I replied, cutting him short, "Mr. ——, there's nothing amiss in those fancies, for the fish couldn't get along well without the water—they'd go bad." The good man wanted to state two texts, favourites of his, on which to elaborate for my instruction, viz : that he, as a salmon commissioner, took a deep interest in pisciculture, and that he was a believer in and practiser of irrigation. And a very worthy colonist he is too, producing more from a given area than any other man I know of here; and employing on the whole more labour. We got along well after this shot at assertive bumption.

In this second instance—also from Tasmania—bumption again seems to mean "conceit." The Tasmanian connection between the earliest two matches for bumption is striking, but none of the subsequent 14 matches I found are from there.
From Ebenezer Smith, "A Paean," in The Season's Musings (1888):

Henceforth, forever, I dispense / With all attention from Pretence; / And scorn alike their grace and bumption, / Whose animalcular presumption / So shames our name, and brings disgrace / On our time honoured Native place, / That Truth exclaims, with scornful stare, / 'Stands this where once stood honest Ayr'?

Smith's choice of bumption here owes a great deal, I suspect, to the demands of meter and rhyme. The meaning of bumption he has in mind is obscure to me, as he presents it in opposition to "grace."
From an identified piece (circa 1890) by H. Milburn McCarty, quoted in "Best of Breed: Col. H. Milburn McCarty as a Country Editor," in The Filson Club History Quarterly (January 1989):

Watterson thinks he could make a model country newspaper—in the which he is much mistaken. A man may succeed in the city and fail in the country. It is not necessary to have much brains to make a popular city paper. As evidence see the Cincinnati Enquirer. Plenty of money is all that is needed. But a country editor, to be popular and prosperous, must have brains, and bumption, and anagosity. Watterson is not deficient in brains, and at times has displayed bumption ; but he is totally deficient in the anagosity that is indispensable to successfully propel long primer type and a Washington hand press.

McCarty's intended meaning for bumption may be entirely idiosyncratic, but it seems to have more to do with "nerve" or "self-confidence" than with "conceit." With regard to anagosity, the author of this article remarks,

"Anagosity" seems to have been a McCarty invention. Like Humpty Dumpty, whom Alice meets in Through the Looking Glass, McCarty expected words to mean just what he wanted them to mean.

McCarty died in 1892.
From Elizabeth Bellamy, "The Heygood Tea Service: A Picture of Life in the South," in The Youth's Companion (Boston, Massachusetts, March 19, 1891):

"Does the Colonel know? Oh, what is he going to do?"
"He doan' know, honey. He's a-settin' by de dinin'-room fiah, an' I ain' got de bumption ter tell him. I ain' had de sperit fur nothin' but ter set up an' hurl my 'pinion at Calamus ; an' all de comfort he kin gimme is jes' ter say cawntinual, 'Dasso.' dasso.' I'm dat thankful you is come, honey, fur you kin tell the Colonel."

This instance involves use of bumption in dialogue as a malaprop for gumption, for comic effect.
From "Canada Needs Discipline," in the Wichita [Kansas] Daily Eagle (June 20, 1899):

The Lawrence [Kansas] Journal says that the Eagle is quarreling with Canada because a whole lot of her people can't speak English, and then the esteemed [newspaper] continues by saying that "there are whole counties, or parishes, in Louisiana in which the English language is seldom heard. And those people and their ancestors havt been there all the time since long before we bought their country." The Eagle is not quarreling with Canada because the Canuck can't talk United States, but because of the claim that the people of Canada are Anglo-Saxon or English. What we said is: Ontario is essentially American, Quebec wholly French, and British Columbia English. The balance of the Dominion is territories largely of mixed Indian and French, Scandanavians anu the like. The Canuck is bumption and needs either discipline or absorption, either snubbing or annexation. Canada would prosper and in time grow modest under the tutelage of Uncle Sam.

This rather astonishing item contains multiple spelling errors, so it is possible that a semiliterate or otherwise incompetent typesetter mistook bumptious for bumption in the manuscript; on the other hand, the same newspaper referred to Kaiser Wilhelm as "Bumption Bill" a year and a half earlier, so bumption may simply have been an accepted word at this publication. In any event, the word bumption appears in a syntactical setting where bumptious would have made more sense.
From an advertisement or Woods Peppermint Cure, in the [Sydney, New South Wales] Evening News (August 22, 1908):

If you have the slightest bumption, / You won't take it for presumption / To be warned against consumption / In its stages immature.
For a cough or cold may breed it, / Should you scorn and never heed it, / And the best thing to [i]mpede it / Is Woods' Peppermint Cure.

The intended meaning of bumption here is unclear to me. Again the writer's decision to use it seems to have been driven by considerations of rhyme, more than anything else.
From J.A. Dungan, "A Nation-wide Epidemic" in The Eclectic Medical Journal (March 1911):

Some person, ignorant as to whether the Christianity or the Science was supposed to do the good [in Christian Science], came along at the right moment with a broad and brilliant smile, which nothing in the circumstances but fanatical faith could inspire, and nothing but monumental bumption keep going, and converted him.

This is another strong example of bumption used in the sense of "conceit."
From F. H. Stachler, "Dayton" in the "Institute Chaptergrams" section of Banking: Journal of the American Bankers Association (June 1912):

Dayton chapter closed the short season since its organization with a banquet at which 200 bankers were present as guests of President Patterson of the N. C. R. The hall was appropriately decorated with the sentiments of the get-together meeting emblazoned on shields on the wall:
"Bankers are the backers of business." "Capital, labor and management make business." "Money and good works should go together." "Bankers control the peace of the world." "Brains, bumption, bullion, bankers and borrowers make business."

This example uses bumption in a very positive sense, with a meaning similar to "gumption."
From "The Back Yard Solves Living Cost Problem" in the Sacramento [California] Union (February 4, 1917):

Digging a living from the soil rather than from tin cans is a necessity for the best development of American life and not a fad. The working hours under modern conditions make it possible for laborers and salaried men, who have the bumption and the will, to improve living conditions for their families, and at the same time keep in reach of the payroll.

As in the earlier Dayton, Ohio, example, this instance uses bumption in a situation where one might have expected to see gumption. The B on a standard typewriter keyboard is adjacent to the G key, so it may simply be a typo, but it seems to me at least as likely that some English speakers use bumption as a variant form of gumption with essentially the same meaning.
From "Boundless Bumption," in The Bible Champion (August 1918):

A handful of men of ordinary ability, meager attainments, and nominal religion, declare themselves to be the chief representatives of world scholarship and piety. Such disgusting self-conceit is so offensive to the great multitude of educated Christians, that it might fitly be termed Unmitigated Gall. The Bible Champion would better characterize it as Boundless Bumption."
...
It is time for some plain speaking and stern dealing with the Apostles of Bumption. We have made the offer, before a great audience of learned and educated men, to furnish ten great Scholars who are Evangelical, for every one who is Infidel. We were not challenged then, nor have been since.

Here bumption again means roughly "arrogance, conceit, temerity, or audacity." In a religious context, such a meaning acquires an even more negative coloration than it normally would, as a form of sinfulness.
From M. R. B., "The Velvet Hammer," in the [Golden, Colorado] Oredigger (November 14, 1921):

I've taken up a lot of space—I'll say it now or die一that Prof. is always bound to have a twinkle in his eye. He's got a lot of gumption—thinks we all should be the same—but bumption we don't understand; he's made us all too tame. Perhaps I've said enough for now, I'll finish in a thrice, tho I can't say that my results are "accurate and nice."

This instance was almost certainly prompted by considerations of rhyme.
From "The Essentials of Success," in the Bartlett [Texas] Tribune and News (May 18, 1928):

A concern might have an extremely well managed store. But if its policy was such that people were not induced to visit it, and if its salespeople had so little bumption that they could not make sales when the people did get there, that concern would never make a go of it.

This may be another instance of bumption as "gumption," although it may instead be read as meaning something like "initiative" or "assertiveness" or "enterprise."
From an unidentified article in The Indian Literary Review, volume 1 (1979) [combined snippets]:

Still, Eddie Trevor remains on the Plantation as the unhappy reminder of the Anglo-Indian presence. Henry is especially sensitive to him, since he was the ex-lover of Ruby. To him Eddie is 'bumption'. He was 'increasingly more cocky, more sure of himself... and always, always playing to the imaginary gallery.' Eddie had a tendency to either 'cheek you or to kowtow'. And most irritatingly for Henry, he uses so many foul words in so many languages for the coolies. Henry thinks that Eddie is always doing things that a man would do for a dare, as though he was forever trying to prove himself. It is true that Eddie has to prove to himself all the time. He belongs to the community the white man would simply ignore, or take for granted otherwise.

It seems to me that bumption is syntactically misplaced in this example, and that bumptious would have been a better choice.
And from William Safire, "The State of the Union, Today," in the Santa Cruz [California] Sentinel (January 6, 1991):

With characteristic bumption, White House chief of staff John Sununu stole a hallowed tradition from the speaker of the House and announced that the president would be the Congress's guest on Jan. 28.

Given that Safire was a fairly conservative editorialist—as well as a writer very conscious of shades of meaning—I can't think that he intended to use bumption here in the sense of "arrogance or conceit"; more likely, he intended it in its other sense of "boldness" or "aggressiveness" or "assertiveness."

'Bumption' as a literary surname, nickname, etc.
The word also appears occasionally as a tendentious surname or nickname. For example, from W. Henry Wills, The Ninth of June (1856), serialized in Novels and Tales:

"O, you needn't look. The big fellow just got out calls himself  Robert Bumption, Esquire; booked in London. The old gentleman in black is Doctor Bole of Matlock; and the tall chap is Mr. Marsden, a counsellor. The box-seat is Bayttam's clerk from Darby, in charge of witnesses for to-morrow's trial."
...
The heavy despairing look which Marsden constantly cast toward the door, left him when he began to cross-examine Mr. Knolliver. The legal mind lighted up at the prospect of reducing this burly witness to the smallest dimensions. It delighted to extract confessions of his various disguises and aliases; of having taken the name of Nobble, and the character of an Eastern Delegate; of having spoken frequently at seditious meetings; of having also made himself known, on the road, as Squire Bumption, a visiting justice of twenty years' standing.

From "Wit and Wisdom" in the [Sycamore, Illinois] True Republican (August 26, 1896), reprinted from the Detroit [Michigan] Free Press:

First Chum— Ill never speak to that Fred Bumption again. He had the audacity to back out of the parlor the other night throwing kisses at me."
Second Chum—Why, the heartless creature! And you right there within reach."

From "American Pusillanimity," in the Wichita [Kansas] Daily Eagle (December 19, 1897):

A week or two ago, a half-breed Dutchman was imprisoned in Haiti, whereupon Bumption Bill, emperor of Germany, charged Haiti five thousand dollars a day for such imprisonment and at the muzzle of some big Krupp guns gave the Haitian president just twenty-four hours in which to settle.

From a list of registered Irish terriers in American Kennel Club Stud Book Register, volume 23 (1907):

RUFUS HENLEY ... By Joe Lee, out of Rosemary, by Breda Muddler, out of Betsy Rigge, by Farndon Mixer, out of Belle Winnie; Breda Muddler by Breda Mixer, out of Iris; Joe Lee by Jackowich, out of Biddy Fancy, by Bumption Blarney, out of Venus; Jackowich by Brickbay, out of Bumptious Biddy.

The cast of characters in Arnold Bennett, The Strange Vanguard: A Fantasia includes a married couple named Mr. and Mrs. Bumption. In the book, Mr. Bumption is a butler employed by Lord Furber.
From an unidentified story in The Right Review (1936):

Sitting alongside Motsah was Bill Bumption, a semitic-looking young man who claimed to be descended from the armigerous Bumptions of Northumberland.

From "'Uncle Tom's Cabin' Ends Season Saturday Night," in the Kent [Ohio] State University Summer News (August 9, 1962):

Although the play is serious in its purpose, it is not without its lighter moments. The classic features such famous comic roles as Bumption Cute and the oily lawyer, Marks.

The collection of proper names containing Bumption is surprisingly extensive, suggesting that the word carries some suggestive meaning even for people who may never have encountered the lowercase noun in their literary travels.

Conclusion
I found 16 matches for bumption as a noun, across a period from 1879 to 1991. As detailed above, these matches break out into four main categories: occasions where bumption means "conceit, arrogance, temerity, or audacity" (four instances); occasions where bumption means "gumption, nerve, boldness, self-confidence, ambition, assertiveness, or aggressiveness" (six occurrences); occurrences where bumption seems to have been erroneously used in place of bumptious (two instances); and occurrences where bumption for to meet the needs of meter and rhyme, but where the meaning is obscure (three instances).
Ten evidently intentional and meaningful instances of a word's use isn't many over a period of 113 years, and even that scanty record is complicated by the fact that writers have used the word to express two quite different meanings. Nevertheless, in my view, bumption is indeed a word, and its absence from the 1971 full-length Oxford English Dictionary is attributable to the dictionary's having failed to notice its multiple occurrences in the wild—not to the OED's having made a judicious determination that the word, despite having appeared multiple times, isn't real.
Answer: No.
"Bumptious" is jocular 19th-century pseudo-Latin, directly from period slang senses of "bump" rather than anything actually Latin (bumpdere? bumere?) that would have created the form "bumption". As such, its actual noun form—when anyone would want it—is "bumptiousness".
As Mr Yargs pointed out above, however, that hasn't stopped some wags from occasionally coining "bumption", whether to fill a rhetorical need (as in his examples) or out of confusion with the Scots term "gumption". You could do so again, if "bumptiousness" doesn't fit your meter or sth.

Is "bumption" a word?


PNG in Illustrator

Question: How to export a PNG file of a logo at a specific pixel dimension in illustrator? I exported many times but none keeps the ratio right. I want the logo to be exported as PNG in square size. I took the artboard according to that. but my PNG gets stretched/reduced.
Comment: PPI is not a quality metric. Number of pixels are. 1200px by 630px at 72ppi and 1200px by 630px at 300ppi **is the exact same image**. Now illustrator is designed to use physical dimensions. So it only makes sense to change the PPI value if you definid the image to be some physical size such a cm or inches. Pixels can not really live side by side as units to physical dimensions.
Comment: Only time its the same size as in illustrator is of you export at 72ppi
Comment: they gonna use it on their publication. 72 PPI will deteriorate the quality? right?
Comment: If it's for a *publication* why are you using PNG rather than supplying a vector file? PNG is typically an inappropriate format for print.
Comment: I am going to submit the vector file. PNG in a specific format (1200 px x 630 px ) is what they ask for. I submitted the original PNG(  export as). but I do not know how to get one in that specific size
Comment: Place the AI file into Photoshop as a Smart Object layer at whatever size/resolution you need.
Comment: Thank you. I am gonna do that. I do not understand why illustrator cant able to do that.
Answer: If you need a file 1200x630 px... Why are you making a square-proportion design?
You could export it, let's say, as a 1200x1200 px file, or 630x630px or whatever, but of course they WILL stretch the file.

Make an artboard on a new file with the correct proportion and decide what will happen to your design inside that file, if it is stretch, do it yourself, if it is a crop, then crop it yourself.
Illustrator has a deficient export dialog box, but you simply need a file on 1200x630px so using the export dialog at 72ppi will export the file at those px dimensions.
Comment: i love to experiment. when 1200 px  x630 px didn't work I tried it for square, circles... etc. Example I shared came from that. Scott's suggestion worked. read posts in adobe forum. illustrator cant do it. photoshop can. Thank you .

PNG in Illustrator


Database of US Maine companies

Question: I'm looking for a database of US Maine companies.
All I found is the page where you can search for companies from here. But I cannot find anywhere a place to download a list.
Answer: https://opencorporates.com/registers is a nice starting point to check whether data is freely available to download.
For example if we check https://opencorporates.com/registers/147 which is Maine they are giving it a score of 0, which means the data is not free available for download.
This doesn't mean you cannot find this database anywhere, but you'll most probably need to contact US Maine jurisdiction or look for paid database somewhere. For example I can see sites like https://mainecorporations.info/ have the database imported in their website. OpenCorporates also does have the entries imported. Which means it's not impossible to find but just hard.
There is also the possibility that these sites are using some kind of automatic scraper bot, which crawls the official website and collects the data.
Answer: Dothub provides a list of US Business entities parsed from official registries https://www.dolthub.com/repositories/dolthub/us-businesses/data/master
Just use the following SQL query.
<code>SELECT *
FROM `businesses`
where state_registered = 'ME'
LIMIT 200;
</code>
Disclaimer: I have no relations with DoltHub, Inc.

Database of US Maine companies


Company stole my IP. Are there costless remedies?

Question: If a well-funded company steals an individual's intellectual property, are there any means to sue or otherwise enforce the IP rights without costing the victim anything?  (I.e., if the victim does not have the means to pay a large retainer to an attorney.)
Answer: Direct civil suits are not the only way to obtain remedies for property violations.  Other options:

Ask.  You can send them a simple letter describing the violation and asking them to compensate you appropriately.
Complain to authorities.  If they engaged in any behavior that constitutes a crime (e.g., criminal fraud) then the state (via district or state attorneys) is responsible for any criminal prosecution.  If the state prosecutes and you are considered a victim, the state generally takes that into account if they are able to prevail against the defender.  Even if they didn't commit a crime, but they have a sufficiently outrageous pattern of abusing individuals' civil rights, state attorneys may decide to threaten or take legal action.
Seek a "litigation investor."  If the size of damages likely to be recovered via
lawsuit is high enough, then law firms will sometimes take cases "on contingency," which typically means the plaintiff does not front any money, but gives up a significant share of any winnings.  There are also independent litigation investment companies that perform the same function based on a similar calculus, but often for even larger cuts of any winnings.
Comment: FWIW, law firms are often willing to take cases like this one on a contingency, while litigation investors are rare (and in some states, prohibited due to common law rules regarding "champerty").
Answer:
Is there anyway I can sue them without costing anything as they have
  made me bancrupt

This most likely varies by country. In the U.S., this is very unlikely or impossible. Even if you litigate in pro per and the court allows you to proceed in forma pauperis, some costs are inevitable: printing and serving (sometimes by certified mail) copies of your complaint/motions/responses, etc.; deposition transcripts; and other costs related to discovery.
Attorney fees are typically the largest portion of a person's litigation expenses. Thus, by litigating in pro per you would not be at risk of retaining a lawyer who might turn out to be be negligent, incompetent, and/or morally inept (and I have encountered many lawyers who are like that). Additionally, it gives you much more control of the pace of your case.
However, litigation in pro per (aka pro se litigation) requires diligence; proficiency in legal research; ability to arguments to the court; and tolerance to frustration, due to (1) the opposing counsel's vexatious conduct (which is the everyday reality in legal proceedings), and (2) the undeniable judicial corruption in many (state & federal) U.S. courts.
I strongly encourage pro se litigation, provided that personal circumstances permit it. For someone who has never litigated, gaining acquaintance with laws, doctrines, rules of civil procedure, and discovery-related issues entail altogether a steep learning curve.


Securing passphrase on DB

Question: I have stored encryption keys on the database that are encrypted with a passphrase. To decrypt it the owner/user must login using his passphrase, and that will be used to decrypt the encrypted keys on the DB. My concern is, to verify whether the entered passphrase of the user is the right one, I would have to store a hashed version of his passphrase. Will there be any security issue or is it enough to stop atleast most of the basic attacks. FYI, the system will only have like 2-3 users therefore I am really worried that they could brute-force the stored hashed passphrase.
Comment: @rjdkolb Not a good idea, for the same reason we don't use SHA2 to hash other passwords.  It's too fast to protect against dictionary attacks.
Comment: Why do you need a hash exactly?  Couldn't your program just attempt to decrypt the user's data with the passphrase provided?  If it succeeds then the passphrase is correct.
Comment: Add a unique random salt to the password before hashing it with at least a sha2 hash. This makes a brute force attack more difficult if an attacker gets into the database.
Answer: We can make use of MAC(Message Authentication Code) rather than just storing the hash of the passphrase in the DB.
MAC Generation
Once the key is encrypted, MAC is generated. We follow Encrypt-then-MAC mechanism.
You can generate a tag = MAC(m, k) where

m is the encrypted key
k is the key you use for encrypting the users' key (passphrase)

This tag is then stored in the DB instead of the hash of the passphrase.
Checking Passphrase
To check if the passphrase is correct or not, we can easily verify it by generating the MAC again in a similar way, with the key as the passphrase from the user. Now, the generated tag and the tag stored in the DB are checked, if they are equal.
If equal, it is a valid passphrase and the decryption of the encrypted key can proceed. Otherwise, we can throw a message to the user that the passphrase is incorrect.
MAC Algorithms
You can use HMAC (Hash based MAC) from OpenSSL for handling the tasks of MAC tag generation. Appropriate bindings would be available for whatever language you are using in your app.
edit: Make sure that a strong hashing algorithm like SHA256 or SHA512 is chosen for HMAC generation (and not MD5 or SHA1 as shown in the examples in the above link)
Answer: If this is implemented as a service rather a file accessible to the users then the client doesn't need to see the hashed password - verification is done on the server. And you can track and respond to multiple failed login attempts. Hence there is little risk from the users.

Securing passphrase on DB