How to script permissions for all logins/users/tables/schemas

Question: Over the years, I have used countless scripts and applications to generate all permissions for SQL Server databases. I have used both paid and free tools. I feel that not one of them seems to be accurate in every instance. I am simply looking for a way to generate all permissions for a given database along with confidence that the script is correct and able to be used after a backup/restore from another instance. Does anyone have a method they have confidence in and use regularly
Answer: I have a couple of stored procedures that I wrote and use on a regular basis.

sp_SrvPermissions
sp_DBPermissions

They each have three outputs.

Principals : A list of the database/server principals and associated info including create/drop scripts.
Role membership : A list of what roles each database/server principal belongs to along with add/drop scripts.
Permissions : A list of individual permissions (EXECUTE, INSERT, UPDATE, CONNECT etc) for each database/server principal.

Obviously the Srv sp is for the Server principals and the DB sp is for the database level principals.  The DB sp also has an 'All' option for the database name.  With this option it runs through and pulls all permissions for all databases.
Note: This was originally intended as a research tool so there are a fair number of options that will let you parse down your data.  Just roles, everything but roles, just a specific principal name etc.
Comment: Great couple of scripts! I use them a lot too, really handy pair of sp's. And been able to transfer password's and SID's, thumbs up for you Kenneth
Comment: Good scripts Kenneth! sp_DBPermissions seems to return everything I need with the exception of "VIEW DEFINITION" that is granted to users on a database. No records are returned for those.
Comment: @JohnZabroski I'm good at t-sql and understand the system views a lot better than I understand the SMO objects. Not to mention the system views tend to change slower so my scripts run over a wider variety of versions.  I've thought about re-writing as Powershell as an exercise but haven't gotten around to it yet.
Comment: Odd.  That should show up.  I would a) confirm that under the database they are explicitly granted VIEW DEFINITION (not through a role, AD group etc) and then double check the system views. sys.database_permissions joined to sys.database_principals.  If it's not in those views it won't show up in the SPs.
Comment: @KennethFisher What led you to write your own vs. use SMO?  I am trying to figure out how to script out Database-Level permissions right now with SMO, and not sure it is possible.
Answer: sp_help_revlogin
See: How to transfer logins and passwords between instances of SQL Server on MSDN
Worked reasonably well for me this past summer.
Comment: sp_help_revlogin only transfers server principal information.  It doesn't transfer anything at a database level.  Very useful for what it does though.
Comment: if you move/migrate to a new server you should not need to script every db permission over. They will come along with the migrated db.
Comment: Very true. Unless you happen to be migrating between SDLC levels.  Say copying over dev with test but then you want to put the dev permissions back the way they were.
Comment: @KennethFisher you usually have roles for that.
Comment: @spaghettidba Don't the permissions for the roles change between dev & test? Or prod & test?  Or at least the members?  It's handy to have that type of thing scripted out.
Comment: @KennethFisher sure, it's nice to have them scripted out. For me it's usually just a matter of adding/removing members to/from roles.


Convert .shp into .tif using QGIS

Question: I have some .tif world image with 1km x 1km spatial resolution. I also have .shp file with 2km x 2km grid data. I need to convert .shp file into .tif in the same spatial resolution and projection as .tif world image.
Is it possible to process in QGIS?
Answer: You can try the following:

rasterize your shape : Raster>Conversion>Rasterize
save as GTiff. There you can check if proj and resolution are ok
Answer: Go Raster->Conversion->Rasterize.  In the dialog box set the resolution of the output you want either as the size of the output or pixels.  You can be more exact in terms of extent of the final raster (to ensure it matches the tif file exactly) by editing the gdal_rasterize command that is auto generated in the bottom text box.  See the documentation for gdal_rasterize for more information on the various settings.

Convert .shp into .tif using QGIS


What genre is Preserved Valkyria

Question: For a long time I have been wondering what kind of genre songs like "Preserved Valkyria" and "Everlasting Message", etc, are.
I would call this kind of music something along the lines of fast paced modern classical insanity.
One day I came across these songs from some artist I didn't know, but I really love the songs, so digging a little deeper I found the following.
Preserved Valkyria and Everlasting Message are both made by Penoreri, but these two are the only ones of this kind he made, the rest is all jazz.
The songs were featured in the game Sound Voltex III, where there are a few more of these kind of songs, like "For UltraPlayers".
So now having some reference material, I still couldn't find a place where there was a note of which genre these songs are categorised in and if there are more artists that make this kind of music.
Does anyone have a clue?
Answer: According to google translate's versions of  Penoreri's website ,
(apologies for the clumsy translations of the words from this website)
" SOUND VOLTEX III - GRAVITY WARS " is categorised as a Konami-like music game"
(Konami is a Japanese entertainment company who are big in the video games market)
Penoreri's own profile from the same website categorises his musical range thus :
"Although adept at catchy music in pop such as Shibuya-kei and Akishibu system, jazz fusion and techno pop, such as a synthesizer lock, it is doing the music production to the genre free. Activities in regardless of genre from pop to classical."
My own take on "Preserved Valkyria" and "Everlasting Message" is that they sound like film or game music (intended to accompany some kind of visual action). Because of the slightly hard-edged sound and the use of electronics, the sound is modern, but hints at older more retro influences. The music itself has strong influences from jazz (piano part), 70s-80s progressive rock, and classical. 70s-80s progressive rock is often influenced by classical, but there are classical influences in Penoreri's music which sound slightly different from those typical of progressive rock, so I would put both as influences.
Comment: I know about konami and that penoreri mostly makes jazz/piano, but I didn't want my music to be blandly labled as "soundtrack". Thnx for your awnser though, and sorry for my late response, you got burried under emails x3

What genre is Preserved Valkyria


Prolog - ODBC interface

Question: I have a requirement like inserting a large data from visual prolog end to the oracle database and also most importantly all the data needs to be injected through a single stored procedure call. I have tried them passing the data as string values, but there is  a constraint in visual prolog like the length the string variable cannot exceed '250' characters. So passing them as strings is not viable for my requirement. so I tried passing the data in the form of prolog list using term_str(). But unfortunately the list/array item is not handled at the oracle end. My DBA has suggested me to pass the large data in the form of an array objects.
Do anybody have an idea how to convert the array data into an array object in visual prolog. or any other recommendations for inserting the large data into database through a single stored procedure call??
Answer: Not sure about Visual Prolog, but for SWI there is a nice
 chapter in the manual on the ODBC

Prolog - ODBC interface


Ubuntu 20.04 is consuming more battery

Question: My battery backup is 4 hours when I am using Windows But at the time of using Ubuntu20.04, it decreases to 2.5 hours. Is there any way by which we can reduce the power consumption when we are using Ubuntu 20.04?
Comment: Have you installed `tlp`?
Comment: Not yet, Should i try it? Is it helpful?
Answer: I observed laptop fan was spinning high frequently while in Ubuntu 20.04 LTS and consequently my laptop's battery backup was reduced (compared to running on 18.04 LTS)
Two ways to improve battery life:

use powertop utility with --auto-tune flag. You can also use it to investigate which hardware component in your system is using most power and when. Installation steps: https://linoxide.com/tools/install-use-powertop-ubuntu-16-04/
use my tiny little script: https://github.com/melvinga/cpuPowerProfilesForLinux
It makes zero compromise on performance and my laptop battery backup improved from 5-6 hours to 8-10 hours.

Let me know if either of the above works for you.

Ubuntu 20.04 is consuming more battery


Adding noise to real MRI data

Question: I designed an algorithm for MRI data denoising which has good properties under heavy Rician noise (sigma is greater than 80). The method was tested on some phantoms and Rician noise generators. Now I want to test the algorithm on real MRI data. In the MRI data, which I have, the noise level is low. Is it methodologically correct adding noise to a real MR image to increase its level based on Rician noise generator?
Answer: Using real data is a way to validate the assumption that your algorithm will behave with real data in a similar way to the behavior with generated data.
In a general sense.
When we want to test an algorithm we can create tests, that are other algorithms that provide inputs and evaluate outputs of the algorithm we are design (your denoising algorithm).
Sometimes acquiring real data is difficult, but we can, making some assumptions generate data with similar distribution from data generator (the procedure by which you apply noise using your Rician noise generators), this makes easier to test your algorithm in much more data, and get more confidence about the algorithm.
When you write your data generator you are making one assumption about the types of distortion the images may have. Testing with real data you may find effects that are not documented, not studied, not expected. This is why in the real world the performance of algorithm may be degraded with measured data compared to generated data. Testing with real data will give you one idea of what is the impact of the neglected effects.
Different neglected effects may occur. The response may be non-linear and the  noise do not follow Rice distribution. The parameters of the noise distribution may depend on the position differently from what you assumed (you may have assumed that the distribution of the noise is independent of the position). Your scanner(s) may have different responses due to different temperature. Different scanners (same of different models/manufacturer) may produce data with different characteristics.
When you add noise to your images you are testing how the algorithm performs with the same real images and different Rician additional noise. There is nothing wrong in doing so, but you must know that worse quality images may have more of the distortions you are not considering.

Adding noise to real MRI data


Maximal ideals of polynomial ring containing a fixed element

Question: We know that for a field $k $ and $f\in k [x]$, the only maximal ideals of $k [x]$ containing $f $ are the ideals generated by prime factors of $f $. Now, I want to know that if $R $ is an arbitrary commutative ring with identity, is there any description for maximal ideals containing $f $?Or, can we find $\cap_{f\in m\in Max (R [x])}m$?
Comment: Consider the case when $f$ has degree zero. Then you see that in your question you can replace $R[x]$ be an arbitrary ring. So then you are asking for the max-Spectrum of the ring $R/fR$. That is, your question is whther there is a description of Max-Spec(R) for an arbitrary ring R.
Comment: $f $ is not a constant term in general, so $max (R [x]/f)\not=max (R) $  in general case.
Comment: Right -- so your question is harder than an impossibly general question. The intersection of the max ideals of A containing f "is" the intersection of the max ideals of A/(f) which is the Jacobson Radical of A/(f). If you want more then you can look up properties of the Jacobson radical.
Answer: Let's think about this...
To get out of the issue raised by Corbennick, let us assume that $f\in R[x]\setminus R$.
Next let $\mathfrak m\subset R$ be an ideal and consider $I=\mathfrak m+(f)\subset R[x]$ and observe that $R[x]/I\simeq (R/\mathfrak m)[x]/\left(\bar f\right)$, so if $\mathfrak m$ is a maximal ideal in $R$, then the maximal ideals in $R[x]$ containing $\mathfrak m$ and $f$ are exactly those corresponding to  maximal ideals of $(R/\mathfrak m)[x]$ containing $f$, so this is the case covered in the question.
Next let's consider a maximal ideal $\mathfrak M\subset R[x]$ and let $\mathfrak m=\mathfrak M\cap R$. In order to get some traction, we'd like this to be maximal, so let's assume that $R$ is a Jacobson ring. (Finitely generated algebras over a Jacobson ring are also Jacobson, and so are fields, and $\mathbb Z$, so many of the most obvious rings are such.) In that case $\mathfrak m$ is also a maximal ideal and we're winning. Obviously, if $\mathfrak M$ contains $f$, then it also contains $\mathfrak m+ (f)$, so we're in the situation described above.
So we can conclude the following:

Claim: Let $R$ be a Jacobson ring and $f\in R[x]\setminus R$. Then the maximal ideals $\mathfrak M$ of $R[x]$ containing $f$ are exactly those for which the image of $\mathfrak M$ in $\left(R/(\mathfrak M\cap R)\right)[x]$ is generated by a prime factor of the image of $f$ in that ring.

Note:

I don't think one can say more than this.
One can get a similar description without the Jacobson assumption, assuming instead that $R$ has finite Krull dimension and using the above process to give a recursive description of these ideals based on the dimension.


in xAct, how to set the components of a tensor to be zero

Question: OBASuppose there is a vector $A^{a}$ appears in the result in different component form like $A^{\mu},A^{\nu},A^{\alpha}...$,
I want all of them to be zero because the components of the tensor are zero, what method can I use?
Answer: You have two main ways of doing this:
expr /. A[_] -> 0

or
expr /. A -> Zero

where Zero is a xTensor object that returns 0 for any input indices.


NFS to NFS mount

Question: I have a machine that I need to bridge NFS files to. Can I mount an NFS directory on machine2 from machine1 and then mount the mounted NFS directory on machine2 on machine3 via NFS? Do you see any problems with that? I am basically bridging some subnet domains this way, in a certain fashion. My development machine is on a different and separate (unbridged) than where I would like to use the files, and I would like this machine1(dev machine) -> machine2(passthrough machine) -> machine3(test machine) connection. And no there is no way to move the test machine as it's a chassis :) and it's two buildings away.
Answer: You CAN re-export an NFS mount.
It is a really REALLY BAD IDEA™. If the first server's export fails, the second machine's export will suddenly lose its contents, and show an empty directory.
Comment: Plus one for the TM superscript :-)
Comment: exclude, for the moment that this is *exactly* what I am doing in answer to the question I asked here: http://serverfault.com/questions/89269/is-there-a-way-to-do-something-like-lvm-over-nfs
Answer: hrm. My kneejerk reaction is that it sounds like a bad idea, but I can't think of any technical reason that it wouldn't work.
So you're doing this because machine3 is unable to talk to machine1?
Comment: I don't think there is a "technical reason" for this, it's just not the "best practice". Like pointing NS records for domain.com to ns1.domain.com/ns2.domain.com, or mounting NFS and re-sharing it over Samba.... or setting your secondary MX record to the virtual IP of the machine your primary MX points too. While all of that may work in theory AND practice, you're asking for some major headache down the road... and most likely at 3AM.
Answer: I have tried this a long time ago and this does not work.  I believe that this is some type of security issue as this could violate the restriction of hosts placed on the exported filesystem.
Comment: it will work just fine.. it's just not a generally recommended thing to do :)
Answer: Last I looked (NFS v2,3) pass-through mounts like this are specifically disallowed by the NFS Protocol for security and performance reasons.
Answer: You can not reexport an nfs mount over nfs. You could export the nfs mount via smb if that works for you.

NFS to NFS mount


Responsive jquery carousel slider and lightbox

Question: I'm looking for a responsive carousel slider with lightbox window (responsive too).

Carousel slider needs to be with thumbnails, and draggble to navigate to next/last slide.
Needs to show more than 1 slide in the portview.
Needs to be infinite (when you're in the last image, the next is the first, but without going to initial, have to be cycle).
When click in a image, open a responsive lightbox window. It needs to resize (when screen resized) and be always in center of screen. The width and height are setted in %.

I search a lot in the internet and didn't find a complete solution with these requirements.
It can be free or pay.
Thank you.
Answer: Hi Have you tried caroufredsel? It's free and pretty extensive.
Link


Entity Framework with Oracle - Edmmapping

Question: I'm working with the Entity Framework 6 on an Oracle legacy database.
The EF maps for example Number(1) automatically to bool or Number(2) to byte, but I need to have them all as Int32.
I have added the edmMappings block to the app.config like described by Oracle: https://docs.oracle.com/cd/E56485_01/win.121/e55744/entityDataTypeMapping.htm#BABGBJCI
But it doesn't work, it always generates bool and int16 instead of int32
My Mapping in the app.config:
<code><oracle.manageddataaccess.client>
    <version number="*">
      <edmMappings>
        <edmNumberMapping>
          <add NETType="int32" MinPrecision="1" MaxPrecision="1" DBType="Number" />
          <add NETType="int32" MinPrecision="2" MaxPrecision="3" DBType="Number" />
          <add NETType="int32" MinPrecision="4" MaxPrecision="5" DBType="Number" />
          <add NETType="int32" MinPrecision="6" MaxPrecision="10" DBType="Number" />
          <add NETType="int64" MinPrecision="11" MaxPrecision="19" DBType="Number" />
        </edmNumberMapping>
      </edmMappings>
      <dataSources>
        <dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) " />
      </dataSources>
    </version>
  </oracle.manageddataaccess.client>
</code>
I tried different things in this block, but nothing changes. Is there something else I need to configure?
Comment: Did you figure out a solution to your problem? I'm stuck with the same thing.
Answer: I had the same issue. I remove the reference "Oracle.ManagedDataAccess" from the package and set the reference to the installed driver from the Oracle Developer tools (C:\Program Files (x86)\Oracle Developer Tools for VS2015\odp.net\managed\common\Oracle.ManagedDataAccess.dll). Then the mapping is going.
Comment: What I understood from this answer is that you removed the NuGet packages that installed the Oracle.ManagedDataAccess.dll and instead installed the dll from Oracle Visual Studio Developer Tools manually through Add Reference and it worked. Is this correct? I did this exact procedure but sadly the EdmMappings are still not taken into account.
Answer: In case you didn't do this already: in addition to the edmMappings I think you have to change the type of your properties in your model entities as well. E.g. in Visual Studio, open the model diagram (*.edmx) right click the property with type Number(X) in your database, open Properties and change 'Type' to the type you want.
Comment: Try to make the answer clear by highlighting the crucial information.


What are reasons to have a site 'down for maintenance'?

Question: What are reasons to have a site 'down for maintenance'?
I seen a few go down with this message. I have seen others that are never down for maintenance. What are reasons a site may be down? And what can I do (if possible) to not have a site go down (read-only) for maintenance?
Answer: Valid reasons for scheduled downtime may include:

hardware or OS maintenance, eg patching or upgrades
Running a cold backup
Running some sort of daily maintenance job to keep things going smoothly.
Implementing changes to infrastructure
Periodic database maintenance, eg. rebuilding indexes or defgragmenting data
Having unplanned downtime and pretending it's scheduled.

There are a number of approaches to reduce downtime, both scheduled and accidental. But it all really depends on the specific requirements of your platform and applications.
Comment: The "Having unplanned downtime and pretending it's scheduled." is a good point.  Been there before...
Answer: Generally, if you are upgrading hardware, sometimes upgrading software, or making any changes where users data might be lost, you are doing maintenance and want to put up a message. Now, depending on how you do your upgrades, you may not need to be down, but if you are a single developer working on a single site/product, it's going to be fairly hard for you to have the redundancy required to not take your site down when making changes.
For software, upgrades are generally fast and don't necessarily require going into "maintenance mode". However, I'll give you an example using Rails: when upgrading a site, you generally have to upgrade the actual code and then upgrade your database so that the code can use it properly (in Rails, this is running your migrations). Many times, code will break if the database does not have the correct tables and columns, so, if you allow users to access your site in-between upgrading the code and upgrading the database, they could potentially see errors. It is usually better if they see a message telling them that the system is down and will be back up at X time.
As far as not having to go down for maintenance, it generally requires separate servers that are fully "redundant" and once the new site is uploaded and ready, you switch all users to point to it. Keeping data redundant, however, is not easy.


Common emitter transistor

Question: In a Ce transistor, why does an increase in voltage between (collector and emitter) affects voltage between (collector and base) but not Voltage between (base and emitter)?
Comment: Where did you learn that increasing \$ V_{CE} \$ affects \$ I_B \$? Add context into your question (and not in the comments).
Comment: Oh sorry.. I misinterpreted my book..
Answer:

simulate this circuit – Schematic created using CircuitLab
Here a simplified example.
If you increase V1 then the voltage Vce will also increase.
The voltage Vbe can only vary a very little bit. For now see it as stable at 0,6V.
That makes  Vcb = Vce - 0,6V.  Therefore if Vce increases then Vcb increases as well. The increase of Vce and Ib is therefore a result of increasing V1.
Comment: Why Vbe can vary a little bit only?
Comment: See the junction BE as a diode in the conducting state. Due to the physical construction of the transistor the voltage over this junction can not vary much. For more explanation look in the theory of diode and transistor
Comment: Oh alright!....
Answer: The collector base junction is reverse biased therefore, an increasing collector voltage has minimal change on the voltage between base and emitter.
This is because the B-E region is forward biased and exhibits a "stiff" impedance electrically. This makes it not susceptible to the extra few nano amps that arise from the increase in voltage across the reverse biased collector-base junction.
Comment: So increasing Vce increases Collector voltage only? It doesn't decrease emitter voltage?
Comment: Increasing the collector voltage significantly will cause a small increase in collector current and this will tend to raise the emitter voltage slightly if the emitter has an emitter resistor to ground. If the emitter is directly connected to ground then its voltage is fixed at 0V potential and cannot move. It certainly will not decrease! This change in collector current flows to the emitter and not the base (except for the small leakage mentioned in my answer).

Common emitter transistor


How to create FM Radio Mesh

Question: What (devices transmitters, receivers and transceiver) do i need to create a fm radio mesh, instead of using a single transmitter with big antenna, i want to build fm transceiver mesh radio to cover an area, whereby when you tune in to that channel and you are within the area you'll get to hear what is broadcasted in that channel. Lets say a coverage of 30kms
Comment: @Duston I'm located in Africa where the laws regarding broadcasting are flexible. I'm trying to distribute FM frequency from 87.5 to 108.0 MHz
Comment: Where are you located and what kind of FM transmission are you trying to distribute?
Comment: There are low power FM stereo transmitter kits readily available (at least in the U.S.) that you could use.  There are also not low power FM stereo transmitter kits (not legal without a license in the U.S.) readily available.  You could put those on the far end.  The problem then is how to get the audio there.  How did you plan to do that?  Wirelessly ("Studio-transmitter Link (STL)"?  analog phone line?  Internet?  Each has their challenges.
Comment: @HitherJoe if you are using your skills to build something useful for the community around you I think you deserve some applause! not many people do that, and most of the ones who do, want to be paid lots of money for it
Answer:
whereby when you tune in to that channel and you are within the area you'll get to hear what is broadcasted

That is impossible.
FM is pretty much the worst technology you can use for meshing:

You can't put multiple transmitters on the same frequency; FM can't deal with that, and there's no mechanism to share the same frequency in FM
FM doesn't allow for sensible equalization, meaning that with FM you cannot have a multiple, geographically distributed transmitters that forward the same signal. Such a network would be called Single-Frequency Network (SFN) (and it's not even meshing – it's just bringing the same signal to different transmitters and transmitting from there; which is what radio stations would like to do, and why radio stations all over the world are happy to get rid of FM and move to technologies that allow you to do SFNs. DAB is such a technology.)

You could come up with a cellular network, where you use at least 4 different frequencies, and then you have a central planner person, who assigns different frequencies to transmit the signal on. You need at least 4 different frequencies, because no two neighboring transmitters can use the same transmit frequency (because a receiver that can receive both can't work); the problem of "how many different frequencies do I need to ensure that no two neigboring transmitters have the same frequency" is the same problem as "how can I color any map, so that two neighboring countries don't have the same color". And this problem is solved - it's the famous Four Color Theorem. You need four colors.

So, if meshing FM is impossible, and even transmitting the same signal from transmitters in different places is impossible, what could you do instead?

Option: Do not use Meshing. Use something with which you can cover 30 km directly. Do not use FM.
Your use case sounds like a very classical use case for which Digital Radio Mondiale was invented. You don't need much power or a high mast to cover an area of 30 km in radius with DRM. Transmitter software is free. There's large installations of that – All India Radio uses it, BBC World, Vatican Radio… It can, but doesn't have to, work in the same band as FM (it's commonly deployed in 47 – 68 MHz, 87.5 – 108 MHz or 174 to 230 MHz).
Option: Instead of a Mesh, build a Single-Frequency Network. Do not use FM.
Should your terrain be too mountainous to allow for direct line of sight connection or one with few reflections, but you can still establish a connection for the audio signal to multiple transmitters, you can build a SFN.
Broadcasters all over the world do that, using DAB+, which replaces FM currently all over Europe, for example. DAB+ is much more robust at lower transmit power than FM, while delivering the same audio quality or better. It is capable of equalization, which makes it theoretically and practically possible to build SFNs. Transmitter software is free, but you will need multiple transmitters and a way to synchronize them (GPS clock, probably), and a way to get the signal to each transmitter. As far as I'm aware, there's no free transmitter software yet that does the synchronization, so this will need some development effort.
Option: Use existing mesh-capable networks.
There's a few technologies that allow you to build wide-area mesh networks (as I explained above, FM is not one of them). The Wifi-adjacent IEEE 802.11s standard allows you to connect many Wifi routers to cover whole cities with wifi (or use B.A.T.M.A.N.). You can use that same technology to stream arbitrary data. However, since wifi is not a broadcast protocol, your network throughput would scale proportionally to the number of listeners. You might alleviate that with IPv6 multicast groups, but I'm not knowledgeable enough about these in cooperation with IEEE 802.11s in practice.
To transport stereo sound that is about the same quality as broadcast FM (i.e., good enough for music, but not quite as good as spotify or CDs), you roughly need 24 kb/s of bandwidth (click on "raw" here to download an example) (for speech, you need much much less, think 8 kb/s). So, your worst-case network load is $N_{\text{listeners}}\cdot24\,\text{kb/s}$; with a mediocre Wifi link carrying say 12 Mb/s of usable payload, a single Wifi origin would allow for 500 concurrent listeners - whether they listen to the same broadcast program or different ones. If you can add cable connections between a few of the meshing access points, you get potentially in the order of a million subscribers.
Option: Use existing cellular networks.
Same audio bandwidth consideration, but data distribution becomes the problem of the EDGE/UMTS/LTE/LTE+/5G carrier. Say you have someone sitting at home listening to 24 kb/s audio for 16 hours a day, 30 days a month. That amounts to 5.2 GB per month. You have conflicting information on where you are (you say "Africa, where regulations are low" in your comments, but your bio says "Virginia, USA", which is not very close to the parts of Africa with low regulation), but a lot of African countries have excellent mobile network coverage at affordable prices. This might be a surprisingly cheap option!
Comment: Wikipedia very briefly says 802.11s does support broadcast and multicast.

How to create FM Radio Mesh


Making a website for a church and need don't know what technology to use for calendar

Question: So its been about two years since I've done any web development and recently I've been asked to redesign and create a my church's website. Since its just composed of basic pages holding info theres nothing really technical about them. My only concern is the calendar section, I'm wondering what technology should I use for the calendar in order for someone at the church to be able to update events on the calendar site.
Answer: There is a drupal distribution called OpenChurch which can get you started. It probably has a lot more than you need though e.g.

calendar/events
blog
gallery
social media integration
podcast page for sermons, etc.

But you could switch-off the stuff you don't need. I have played with it in the past for a project.
You can also self-host as it is opensource.
Answer: I would suggest using a static web site generator such as the Python ones listed here. This would let you have a source page, (in plain text/markdown), for them to edit and then a script to publish it to the server.

Python is Free and most/all of the tools listed in the linked article are as well so no costs. So no financial burden
Python and the associated tools can run on many platforms from Raspberry Pi up including older hardware often what is available
Once it is all set up the technical knowledge required is minimal.
The church can use the blogging facility to post thoughts for the day/week/month easily.

I would specifically recommend Pelican with Invoke to publish it, Nikola or Hyde are also good for the site generation.


Setting gmail to sync / push / notify on wifi only?

Question: I have a droid mini that is running 4.2.2 and I want gmail to only sync automatically on WIFI only; never on 4g / network / whatever. How do I do this without rooting the phone?
When I first bought the phone, gmail allowed me to chose to sync on wifi only (and by sync, I mean that it would notify me of new emails and download them or what not on wifi only). This is how it was originally set up. I work for a local cable company and this was great. I know this is how it was originally set up because 1) I set it up that way and 2) when I setup up new internet connections in customer's homes, I would use the wifi on my phone to verify that their internet was working. As soon as the wifi would connect I would usually hear my phone announce I had emails, letting me know the wifi was connected.Then today, I was having an issue with Google play store. I took my phone into Verizon where they claimed to only have 'soft reset' the phone. Now, not only does gmail download / notify /syn (whatever) whenever it wants but the setting for wifi only is completely gone. I distinctly remember something like 'sync on wifi only' or 'push on wifi only' or something like this. I assume there has been some update or something recently and I have no idea how to check this. I would, however, be happy to uninstall the update if i could get it to work on wifi only again.

So long story short, how the hell do I get gmail to 'whatever' on wifi only without rooting?
Answer: You can use an app like Llama or Tasker to activate sync only when on WiFi. If you turn off sync, that also turns off syncing of your calendar/contacts/tasks et al in your Google account.
The Gmail app should have an option to only download attachments via WiFi within your specific account options.
Comment: I would definitely recommend Tasker. IF you google around you'll find some good tutorial videos as Tasker is not super easy to figure out. However, once you do, you're in automation haven!


How To Filter On Bcc Info

Question: I've created a rule that checks for messages sent to a distribution list, but I'm finding that the rules is missing messages in a thread where the sender moves the DL address to BCC. Basically, I want to check if my name is not on the To: or CC: fields. How can I write a rule that takes this into account?
Answer: You have to create the following rule:
Apply this rule after the message arrives
 move it to the BULK folder
 except if my name is in the To or Cc box
This will move any mail not specifically sent to you to the BULK folder.
Note that if someone sends you a personal email but uses the BCC field, this rule will fire as well. Note also that you may need to check "...and stop processing rules"  to all your other rules.
Answer: i am assuming you mean to have outlook check emails when received for your name on the TO or the CC and you want to add the BCC to the filter.......
BCC is intended to hide from the email receiver others that have been copied on the same email. so no, you cannot check for anything in this field.
hope this helps
Comment: Yeah, but can't I filter to check if my name isn't in the To: or CC: box? I didn't see that option.

How To Filter On Bcc Info


Dwell Time computation from Real-Time user location

Question: We have a collection of real time user locations from our application. Each record contains longitude, latitude and the time at which the geo location was captured. How can I compute the dwell time at an user's stationary place from this data?
Answer:
We have a collection of real time user locations from our application. Each record contains longitude, latitude and the time at which the geo location was captured. How can I compute the dwell time at an user's stationary place from this data?

Things to consider when collecting the data:
If you are using a Library such as: react-native-mauron85-background-geolocation and the Ionic Framework you would set the stationaryRadius to define an area within which the device reporting its location is considered to be stationary.
When there are obstructions and reflecting surfaces multi-path reception is likely. The signals arrive at the receiver at slightly different times and, depending on which signal the receiver chooses to believe for any given sample, the distance from the satellite also differs. Multiply this behavior by several satellites, then factor it into the overall position calculation, and the net result is that the receiver perceives abrupt shifts in position. Sometimes these can be significant - say 40 or 50 feet.
Higher level software in the receiver tries to smooth this out. Generally speaking, it does a better job of this when the tracker is moving. This is because your true change in position per unit time is much larger than the random shifts caused by multi-path reception.
You can average the reported position over a period of time to get a circle within which the device is likely to be. Using secondary information like IP address and WiFi positioning can provide additional information to narrow down the guess faster. See also: Wireless Technologies.
Here is an example that shows you where you are using Mozilla's Geolocation API, click on "Geolocation Live Example" and give permission to share your location (not with us at SE, with Mozilla).
Once you have fairly accurate data it's simply a matter of defining a radius and minimum dwell time (which would be a moving average).
If they are moving fast then a shorter stay is a dwell, while at a slower speed a dwell wouldn't occur until a longer period of time.
Advanced mathematical modeling is necessary to analyze a better result and not get confused by meandering and backtracking.


Why does 0 resistance mean 0 voltage?

Question: According to Ohm's law,$$
\left[\text{voltage}\right]~=~\left[\text{current}\right] \times \left[\text{resistance}\right]
.$$Does that mean if there is no resistance, then there can be no voltage? Why is that so? If you make a circuit with no load, and no resistors, why does the voltage have to be zero?
Comment: Possible duplicate of [Does voltage drop occur with zero load and zero resistance](https://physics.stackexchange.com/q/144907/)
Comment: The question seems to answer itself.  You know the relations between resistance, current and voltage, so I'm not clear why you don't see the connection between zero resistance and zero voltage.
Comment: It is remarkable how many wrong answers you can get by asking about the Ohm's law. Consider a circuit with a battery V, resistor R, and superconductor in series. The current in the superconductor is $I=\dfrac{V}{R}$, the voltage on the superconductor is zero. The Ohm's law for the superconductor is correct $V_s=R_s I$ or $0=0\cdot I$
Comment: Hint: if the voltage is non-zero, what will the current be?
Comment: See also [How can Ohm's law be correct if superconductors have 0 resistivity?](https://physics.stackexchange.com/q/62664)
Answer: tl;dr-  No, the $V$ in Ohm's law is meant as voltage drop, not absolute voltage; it's better to write it as $\Delta V = IR = 0 ,$ which just means that there's no voltage drop between the terminals of the resistor when $R=0.$

Ohm's law is $\Delta V = IR$
Ohm's law is a concept, not a specific algebraic equation, so it can be written different ways.  $V=IR$ is common, but it's kinda lazy.
A better expression would be$$
\underbrace{\Delta V}_{\begin{array}{c} V_\text{in} - V_\text{out} \end{array}} ~~=~~ IR
~,$$i.e. that the change in voltage from one end of the resistor to the other is $\Delta V$.  This better reflects the concept,$$
{\def\place#1#2#3{\smash{\rlap{\hskip{#1px}\raise{#2px}{#3}}}}}
{\def\hline#1#2#3{\place{#1}{#2}{\rule{#3px}{2px}}}}
{\def\thline#1#2#3{\place{#1}{#2}{\rule{#3px}{0.5px}}}}
{\def\vline#1#2#3{\place{#1}{#2}{\rule{2px}{#3px}}}}
{\def\tvline#1#2#3{\place{#1}{#2}{\rule{0.5px}{#3px}}}}
%
\hline{0}{75}{70}
\hline{230}{75}{70}
\place{25}{70}{\Large{\bullet}}
\place{0}{77}{\begin{array}{c} {\phantom{\small{\bullet}}}\sideset{_{\phantom{\text{in}}}}{_{\text{in}}}{V} \\ \hspace{50px} \end{array}}
\place{250}{70}{\Large{\bullet}}
\place{225}{77}{\begin{array}{c}{\phantom{\small{\bullet}}}\sideset{_{\phantom{\text{out}}}}{_{\text{out}}}{V} \\ \hspace{50px} \end{array}}
\tvline{30}{40}{5}
\tvline{30}{50}{5}
\tvline{30}{60}{5}
\tvline{30}{70}{5}
\tvline{255}{40}{5}
\tvline{255}{50}{5}
\tvline{255}{60}{5}
\tvline{255}{70}{5}
\place{-10}{70}{\llap{\large{I}}}
\place{297}{70}{\rlap{{\Large{\blacktriangleright}}}}
\place{70}{50}{\rule{160px}{50px}}
\place{73}{53}{\color{white}{\rule{154px}{44px}}}
\place{30}{40}{\underbrace{\hspace{225px}}_{\lower{10px}{\Large{\Delta V ~~{\equiv}~~V_\text{in}-V_\text{out}}}}}
\place{75}{72}{\begin{array}{c} \hspace{150px} \\ \text{Resistor} \\ \small{\text{resistance, } R~{\equiv}~\frac{\Delta V}{I}} \\ \hspace{150px} \end{array}}
%
\phantom{\rule{300px}{100px}}_{\hspace{25px}\huge{.}}
$$Then in this case,$$
\require{cancel}
{\def\place#1#2#3{\smash{\rlap{\hskip{#1px}\raise{#2px}{#3}}}}}
{\def\hline#1#2#3{\place{#1}{#2}{\rule{#3px}{2px}}}}
{\def\thline#1#2#3{\place{#1}{#2}{\rule{#3px}{0.5px}}}}
{\def\vline#1#2#3{\place{#1}{#2}{\rule{2px}{#3px}}}}
{\def\tvline#1#2#3{\place{#1}{#2}{\rule{0.5px}{#3px}}}}
%
\hline{0}{75}{70}
\hline{230}{75}{70}
\place{25}{70}{\Large{\bullet}}
\place{0}{77}{\begin{array}{c} {\phantom{\small{\bullet}}}\sideset{_{\phantom{\text{in}}}}{_{\text{in}}}{V} \\ \hspace{50px} \end{array}}
\place{250}{70}{\Large{\bullet}}
\place{225}{77}{\begin{array}{c}{\phantom{\small{\bullet}}}{\sideset{_{\phantom{\text{out}}}}{}{V_{\text{out}}}} \\ \hspace{50px} \end{array}}
\tvline{30}{40}{5}
\tvline{30}{50}{5}
\tvline{30}{60}{5}
\tvline{30}{70}{5}
\tvline{255}{40}{5}
\tvline{255}{50}{5}
\tvline{255}{60}{5}
\tvline{255}{70}{5}
\place{-10}{70}{\llap{\large{I}}}
\place{297}{70}{\rlap{{\Large{\blacktriangleright}}}}
\place{70}{50}{\rule{160px}{50px}}
\place{73}{53}{\color{white}{\rule{154px}{44px}}}
\place{30}{40}{\underbrace{\hspace{225px}}_{\lower{10px}{{\left.V_\text{in}-V_\text{out}~{=}~\left(0\Omega\right)I~{=}~0\right.~~~~{\Longrightarrow}~~~~\boxed{\left.V_\text{out}~{=}V_\text{in}\right.}}}}}
\place{75}{72}{\begin{array}{c} \hspace{150px} \\ \frac{\Delta V}{I} ~{=}~ \cancelto{0\,\Omega}{~R~} \\ \hspace{150px} \end{array}}
%
\phantom{\rule{300px}{100px}}_{\hspace{25px}\Large{,}}
$$so zero resistance basically just means zero voltage drop in a passive resistive element, e.g. an ideal resistor.
Where's $V=IR$ come from?
Voltage is a relative thing.  For example, say that you have a AA-battery; they're specified to have a $\Delta V=1.5 \, \mathrm{V}$.  However, you could just as readily say that one terminal of your battery is at $1000000000\,\mathrm{V}$ while the other is at $1000000001.5\,\mathrm{V}$; so long as you keep the voltage difference consistent, it's accurate, if slightly misleading out-of-context.
$V=IR$ works the same way.  Here, they set $V_\text{out}$ to $0\,\mathrm{V}$, such that$$
\require{cancel}
\Delta V
~~=~~ V_\text{in} - \cancelto{0\,\mathrm{V}}{V_\text{out}}
~~=~~ V_{\text{in}}
~~=~~ V
~~=~~ IR
~.$$So basically, $V=IR$ assumes a context in which you specify one terminal of a resistor to be at $0\,\mathrm{V}$.
So, if you use Ohm's law only once in a circuit analysis, and you're willing to say that the output terminal of the resistor is at $V_{\text{out}}=0 \, \mathrm{V}$, then you actually can use $V=IR$ directly.
But, in practice, most folks just use it as shorthand for $\Delta V = IR$.
Example circuit analysis
Here's an example of Ohm's law in action:

$\hspace{50px}$

For $R_1$, Ohm's law predicts$$
\Delta V
~~=~~ I R
~~=~~ \left(1.5\,\mathrm{A}\right) \left(6\,\Omega\right)
~~=~~ 9\,\mathrm{V}
\,.$$This leads to the voltage drop of $9\,\mathrm{V}$ shown in the figure.
Then since$$
\underbrace{{\Delta V}_1}_{9\,\mathrm{V}}
~~{\equiv}~~ \underbrace{{V_1}_{\text{in}}}_{12\,\mathrm{V}} - {V_1}_{\text{out}}
\,,$$${V_1}_{\text{out}}=3\,\mathrm{V}$, as shown in the figure.  And that's Ohm's law!
Using the same math shows that ${\Delta V}_2 = 3\,\mathrm{V}.$  But, note that it's also true that ${V_2}_{\text{in}}=3\,\mathrm{V}.$  As described in the above section, this is a direct consequence of ${V_2}_{\text{out}}=0\,\mathrm{V}.$
Then to address the case of $R=0\,\Omega$ asked about in the question, it should be clear that while $\Delta V = 0 \, \mathrm{V}$ follows from Ohm's law, that just means that $V_{\text{in}}=V_{\text{out}},$ not that they're both zero (unless one of them is selected as their common reference or/and one of them happens to be at $0\,\mathrm{V}$ due to other circumstance).
The shorthand $\cancel{\Delta} V \to V$ has led to widespread confusion
When I originally wrote this answer, I included the section about why Ohm's law is often written as $V=IR$ rather than the more proper $\Delta V = IR$, as this is a known source of frequent confusion.  However, after looking around the internet a bit, it seems that the frequent use of the shorthand has led even Wikipedia's article on voltage to get it mixed up in parts!  (Other parts of the Wikipedia article are correctly written.)
So to be clear:

Voltage, $V$, is also known as electric potential.
Voltage drop, $\Delta V$, is also known as electric potential difference.
Voltage drop only reduces to voltage when one of the points is selected as the common reference, e.g. as with $V_{\text{out}}=0.$
Voltage drop is often referred to as "voltage" in simple scenarios where one of the points is already the common reference.

For example, a AA battery's voltage drop is typically specified as $\Delta V = -1.5\,\mathrm{V}$, meaning that a AA battery should raise the voltage from the input terminal to the output terminal (where in/out are defined by the sign convention on the current, $I$).  However, it's more common for people to say that a AA battery has a voltage of $1.5\,\mathrm{V}.$

Despite being a useful shorthand in simple cases, that context-switching seems to cause conceptual confusion and tends to be grossly impractical in larger circuit analyses.

HyperPhysics and much of the response to this SE.Physics question are helpful.  Note that HyperPhysics does use the shorthand at places, too, but their use appears appropriate.
Comment: Voltage is a difference of electric potentials, not a difference of voltages. There is no "in" and "out" voltage, just a voltage between input and output. There is no "delta" in the Ohm's law, just voltage. There is no such thing as "absolute voltage", voltage is relative, just like speed. "Voltage drop" is a technical concept that is not helpful here, but only adds more confusion. And yes, the Ohm's law is a "specific algebraic equation" indeed.
Comment: @safesphere "_in_" and "_out"_ voltages are the voltages at the "_in_" and "_out_" terminals, where flow direction is determined by the charge sign convention (i.e., in the direction of positive $I$).  Then, what do you mean about "_voltage drop_" being a "_technical concept_" that only adds more confusion?  It seems incredibly simple to me, plus I think that it's taught to kids in school these days.  I mean it's a basic, introductory principle for learning about electronic circuits; folks need to understand voltage drop to, say, understand how batteries work together in a flashlight.
Comment: Voltage is measured between two terminals. You could measure the "in" voltage, for example, between the "in" terminal and the ground, but this is misleading, because the ground has nothing to do with the question and only brings an irrelevant complication. In this question you simply measure the voltage between the "in" and "out" terminals. It is one voltage, not two voltages.
Comment: @safesphere Ohhh I think that you're misunderstanding voltage; naw, voltage **_isn't_** between two terminals; that's voltage drop.  Rather, voltage is kinda like pressure, and voltage drop is kinda like pressure drop (via the hydraulic analogy).  But I think that it's commonly confused because voltage drop is often referred to as voltage using the shorthand described in the second half of the answer.
Comment: It's actually pretty interesting reading the [Wikipedia article on voltage](https://en.wikipedia.org/wiki/Voltage).  They get the distinction right in a lot of places, but the first sentence is very misleading, which they only rectify in a parenthetical note in the first sentence.  I hadn't realized that this was such a commonly confused topic!  Basically, the Wikipedia article points out that they're using a shorthand, and they give the formally correct definition too, but the article on "_voltage_" still largely conflates it with voltage drop.
Comment: From your link, "Voltage is the difference in electric potential between two points". You are confusing voltage with electric potential, but not only that. Your bigger confusion is thinking that it (whether you call it voltage or potential) can be measured in one point. It cannot. The absolute electric potential is not an observable value. This comes from the U(1) symmetry, the symmetry, which per the Noether theorem results in the conservation of the electric charge. Hope this helps.
Comment: @safesphere It can be defined at a point, but as I point out in the second part of the answer, the definition at any given point is selectable.  But, yeah, I'll check into common definitions; I see where you're coming from, as Wikipedia does use the word "_voltage_" like that in their article.  I'm using the definition as from [HyperPhysics](http://hyperphysics.phy-astr.gsu.edu/hbase/electric/elevol.html), where it is electric potential; professionally, I'm used to seeing electric potential being called "_voltage_" and the difference being called "_voltage drop_".
Comment: Sorry to rant here, but the Wikipedia article's just so silly I'm not sure what to make of it.  I mean in the very first sentence, they explicitly point out that they're talking about $\Delta V$ and not just $V$.  And so, clearly, they **_must_** be aware that they're talking about voltage drop and not voltage, as they are in other parts of the article, too.  But then they bounce back-and-forth between getting it right and wrong.  And then the Wikipedia article on "_voltage drop_" doesn't do anything to correct it.  I've never seen Wikipedia make such a large, stupid mistake before.
Answer: Do not assume that a lack of resistors connecting two points implies that the resistance is zero between those points. In fact, it's the reverse: The conductivity is zero, the resistivity is infinite, the current is zero, and therefore the voltage difference is undefined. That is, you can apply any voltage you wish between two unconnected points.
In contrast, if you connect a perfect conductor between two points (e.g., an idealized superconductor or circuit wire), then the resistance is zero between the points, the conductivity is infinite, the voltage difference is zero, and the current is undefined. Here, the current is determined by the rest of the circuit.
Answer: Voltage is not 0 since the potential difference is determined by the source. In the limit of 0 resistance, it will be like completely turning on a faucet as opposed to letting it trickle. You get an increase in current keeping the p.d. roughly constant (assuming the source has a sufficiently large capacity). The "0 resistance" is what is commonly referred to as a short circuit in everyday circuits. The high levels of current will be evident even from the thermodynamic properties of the wire since there will be significant heating.
Comment: current source?
Comment: Wrong answer. The voltage is indeed zero and the current can have any value we want. No heating in the superconductors either.
Comment: I specifically stated "in everyday circuits". Superconductors are a beast of their own. If the voltage is 0 then you cannot have a current in the normal circuit because that would imply that the electric field is zero
Comment: You should address your comments using the @ sign. Otherwise no notification is sent to whom you respond.
Answer: It is important to realize that equations in physics have physical meaning behind them. So mathematically yes, $R=0$ means $V=0$, but what does this equation actually mean?
This equation is for when we apply a voltage to an ohmic material to determine what current will flow through it. Therefore, we are already assuming the object has resistance. If $R=0$ then we do not use this equation, since it no longer applies.
This is what I mean by saying our equations have meaning. The resistance does not determine potential difference. The resistance determines the resulting current due to a potential difference.
Comment: I disagree with this answer. Ohm's law is valid if $R=0$, you just have to read it backwards: no matter what current you put in, the voltage will always be zero.
Comment: by applying a force somewhere else to push electrons along your zero-resistance material. To a very good approximation, this is just what happens in the cables in a circuit.
Comment: Ohm's law does apply when $R=0 \, \Omega$; in fact, an ideal wire is basically just a resistor with $R=0 \, \Omega$, while real-life wires fall short of this ideal, having small-but-non-zero resistances.
Comment: @Javier How would we "put in a current" with no voltage difference?
Comment: @Nat I am not debating the usefulness or existence of $R=0$. And as for your other comment, I know the math works out fine, but I guess it just seems weird to me to say that resistance determines the potential difference. I guess it's kind of like if we use Hooke's law with $k=0$, are we even talking about ideal springs anymore?
Comment: That weirdness probably comes from getting the causality reversed; this is, resistance doesn't _determine_ the relationship between voltage and current, but rather is _determined by_ that relationship.  That may seem like a subtle distinction, but it should address the feeling of weirdness about what happens at zero resistance.
Answer: No. $V=IR$ is only valid for an ideal resistor. For instance, an ideal inductor has $R=0$, but the voltage across it is $V=L{dI\over dt}\ne0$.
An ideal circuit with no load and no resistors does not have $R=0$, it has $R=\infty$. $I=0$, so $V$ is given by the indeterminate form $0\times\infty$, which means any value is valid.
Comment: -1: The Ohm's law is valid for an ideal resistor, including $R=0$.  Consider a superconductor fed by a current source. The Ohm's law stands: $0=0\cdot I$.
Comment: @safesphere How does that disagree with my statement? All I say is that $R=0$ does not imply $V=0$, since not every component with $R=0$ is an ideal resistor.
Comment: The question is about the Ohm's law that applies to ideal resistors, so the question is about an ideal resistor with a zero resistance (superconductor). For such a superconductor (DC current), $R=0$ does imply "V=0". I didn't actually downvote.
Comment: I disagree on your reading of the question. Part of OP's question is "If you make a circuit with [...] no resistors, why does the voltage have to be zero?" The resolution to that question is that Ohm's law does not apply *in general*, but only if you have ideal resistors in the first place.
Comment: Perhaps misreading the question is the reason why you are in a negative territory here counting my virtual downvote ;)
Comment: @safesphere Well, agree to disagree I suppose.

Why does 0 resistance mean 0 voltage?


Impact of frequent row major / column major conversions using LAPACK/BLAS?

Question: If you call a library like LAPACK or BLAS (which are written in FORTRAN and use column major order) from a C-like language that uses row major order, won't you lose performance and use a lot of memory due to the creation of transposed matrices? Tests are best, of course, but can anyone with experience tell me whether optimized libraries still improve performance, even after that overhead?
Comment: I haven't tested the performance penalty, but you might use a library or a toolkit that hides away memory layout. E.g. in NumPy (relevant parts written in C), you can choose the memory layout on array object creation.
Comment: If I am not mistaken, BLAS and LAPACK have a "transpose" argument that tells if you want the operation done with $A$ or with $A^T$. So you can effectively pass matrices to BLAS either in row-major or column-major order, you just have to specify it. No explicit transpositions are performed. Of course, some algorithms might perform better with row-major and some with column-major storage, but this seems a different issue.
Answer: Many of these libraries have C interfaces that swap the meaning of the ordering internally without swapping the data. Also, using C-style double pointers for 2-D matrices is probably the wrong choice in the first place (due to the double lookup), so you can make your data appear column-major by indexing into a linear C array or use libraries that work around these issues.
Comment: It turned out that the LAPACK port I was using, CLAPACK, didn't have that option but a more recent one called LAPACKE did.
Answer: You can use the identity C^T = (AB)^T = B^T A^T to use BLAS to compute on row-major arrays from C.
In any case, the overhead of transposition is usually not a bottleneck compared to O(N^3) BLAS3 or LAPACK routines, but I should note that I am oft to point out counterexamples from my own research.
Answer: Straight from the horse's mouth (https://www.netlib.org/lapack/lapacke.html#_array_arguments),

Note that using row-major ordering may require more memory and time than column-major ordering, because the routine must transpose the row-major order to the column-major order required by the underlying LAPACK routine.

So yes, at least for LAPACKE, there is a performance penalty if you use a layout that requires transposition internally. I've confirmed by testing dgels with some old version of OpenBLAS and indeed, two extra allocations occur when using row-major layout. I couldn't get a good measurement of how it impacts performance.
On the other hand, for OpenBLAS' CBLAS interface, no extra allocations occur for any of the configurations.


Which birds could replace pigeons as message carriers?

Question: Pigeon post has a long tradition in human history. The first mentioned uses of pigeons as message carriers go back to ancient Egypt and proofs of their usage are found all over Europe, northern Africa and asia from ancient history till now.
Pigeons are used because of their strong natural homing abilities and have been breeded for centuries to optimize these abilities. If they depend on the magnetic field of earth (as is the most common theory), smell (like especially some newer Italian studies suggest), true navigation (using landmarks), possibly even celestial navigation (by the stars) or a mixture of all these is still not finaly solved. Nevertheless I am interested in some alternative birds which I could use as message carriers instead of pidgeons for my fantasy world but I couldn't find trustworthy informations about which birds have strong natural homing abilities. So my question is:
Are there any other birds instead of pigeons which could be suitable as message carriers and could have been bred like pigeons in our timeline?
Comment: Right, related but not the same. The linked question asks specificaly for the feasibility of ravens as carrier birds, I want to know which birds in general could have been bred to message carrying.
Comment: It also mentions sparrows in one of the answers, but I don't see the information being backed up by references anywhere.
Comment: Nearly any migratory bird will have good navigational skills, your luck may be out if you need a message sending in the winter though!
Comment: [spoons](https://worldbuilding.stackexchange.com/questions/120828/my-carrier-pigeons-have-been-replaced-by-spoons-how-can-i-send-messages/120834)
Comment: Related: https://worldbuilding.stackexchange.com/questions/42/are-ravens-a-genuinely-realistic-way-of-carrying-messages
Comment: As far as I know, pigeons are used due to their remarkable ability to find themselves by sensing the earth's magnetic field, so perhaps some other migratory birds could be an option
Answer:
Encyclopaedia Britannica, s.v. Homing (animal behaviour):

Most of the best-known examples of strong homing ability are among birds, particularly racing, or homing, pigeons. Many other birds, especially seabirds and also swallows, are known to have equal or better homing abilities. A Manx shearwater (Puffinus puffinus), transported in a closed container to a point about 5,500 km (3,400 miles) from its nest, returned to the nest in 12 1/2 days.
Non-avian animals that have homing abilities include some species of reptiles and fishes. When female loggerhead sea turtles (Caretta caretta) emerge from their shells, they imprint on the unique magnetic field signature of the beach on which they hatched and can navigate back to it as adults to lay eggs of their own. In addition, experimental studies have shown that several species of salmon can navigate back to their spawning streams by using their olfactory senses to find the unique chemical signature of the waterway, and juvenile sockeye salmon (Oncorhynchus nerka), like loggerhead sea turtles, also appear to navigate using magnetic fields, from the ocean back to their spawning streams.

"Homing Ability in Birds", in Nature 170, 237 (1952), https://doi.org/10.1038/170237a0:

A recent issue of Ibis contains two important articles on the direction-finding abilities of birds (94, No. 2). In the first article G. V. T. Matthews describes an extensive series of homing experiments carried out with 249 lesser black-backed gulls (migratory species) and 91 herring gulls (a restricted nomad), together with twenty other sea birds. On release the lesser black-backed gulls showed a significant homeward orientation which was absent when the sun was obscured by clouds [...]. The herring gulls showed a much lesser ability to 'home', and this could be explained by there being a much smaller proportion of able navigators among them. Matthews also carried out experiments in which the earth's magnetic field was masked by airborne magnets; this in no way affected homing ability.
In the second article Gustav Kramer describes experiments carried out with starlings and homing pigeons. The starling's ability to reproduce constant compass directions was demonstrated in two ways: first, by using migratory activity as an indicator, the bird tending to take up a constant direction; second, by training the birds to choose one of several (up to twelve) feeders symmetrically distributed around the cage. If the incidence of light were changed by use of a mirror arrangement the direction chosen by the bird changed correspondingly. The sun was shown to be a governing factor, the orientation faculty (in experimental conditions) vanishing if the sun were hidden. The correct direction was reproduced regardless of the time of day.
Answer: Storks -- they are migratory and thus have good navigation, they are large enough to carry decent sized messages, they have some interesting colors ...and - as everyone knows - they already deliver babies.
Answer: I think falcons might work, they are already trained by people, so we would not have to learn how to train them.


Response time limit in SQLite

Question: Is there way to limit response time on SQLite?
I have SQL request, which executes from 0 to 10 seconds depends on device performance. This SQL is OPTIONAL. If request takes more than 3 sec, it should be terminated. I would prefer do not run this SQL if I could know apriori that it takes more than 3 sec.
Answer: Use the sqlite3_progress_handler interface to register a callback function.
As @JeremyP suggested, you can pass in a a pointer to NSDate, or something else storing time as context to compare against. If it reaches above a certain threshold then return a non-zero value from the callback registered with this function to terminate the operation.
int progressHandler(void *context) {
    NSDate *start = (NSDate *)context;
    NSTimeInterval wait = -[start timeIntervalSinceNow];

    if (wait > 3.0) {
        return 1;
    } else {
        return 0;
    }
}

The second argument to this function is how often your callback should be invoked. This value is in # of jump opcodes executed and will vary by machine. For context, on my Macbook, it processes around 20 million opcodes every second. A decent number for your use-case might be 10K-100K.
sqlite3_progress_handler(db, 100000, &progressHandler, (void *)someDate);

Comment: Why do you need the NSTimer?  The callback function takes a void* parameter that you can use to pass it (a pointer to) the time at which the query started.
Comment: You are right. Don't need the NSTimer. Feel free to update the answer.

Response time limit in SQLite


Maximum helicopter height

Question: Helicopters or dual/quadcopters stop rising after reaching some height from the ground. What causes that? And what one should do if he want to prevent this, if he want the helicopter to keep rising up?
Comment: This question appears to be off-topic because it shows [insufficient effort](http://meta.physics.stackexchange.com/questions/5778/what-counts-as-sufficient-prior-research-when-asking-a-question)
Comment: Density of air decreases as you go up, and when helicopter goes up it looses lift until it reaches point where air density is so low that helicopter's lift isn't enough to go up
Comment: have you Googled for *helicopter maximum altitude* or something similar? I just had a quick look and Google found dozens of relevant articles.
Comment: How can I know where the helicopter stops lifting?
Answer: In the most simplified view, a helicopter is basically a really powerful fan, which is something that pushes air (and therefore feels a force in the opposite direction). When you get high enough, the air starts thinnning, so there is less to push, so that force becomes too low to hold it up. Imagine the limiting case of outer space: nothing would happen.
There's nothing you can really do to combat this, except run your motors faster and faster as the air gets thinner. Eventually you have to rely on things like rockets that don't need an atmosphere to gain momentum.
Comment: Thanks,
How can I know where the helicopter stops lifting?
Comment: That would probably be very complicated in reality, but you could start by searching google for the thrust your motor and blades can produce at a given air density, find the density as a function of height, and see when that matches the weight of the helicopter. You might be able to come up with ballpark numbers easily.
Answer: A helicopter is not fundamentally different from a fixed-wing aircraft.  Fixed-wing craft also have maximum altitudes for the same basic reason - thrust (or airspeed at the wing) vs. air density.

Maximum helicopter height


How to clean install Windows 10 onto a working system?

Question: To clean install on a working system, for Windows 10, just download the ISO from Microsoft

but, how do you establish that the license is valid?  And, how do you obtain the license key?
The working, but virus infected, system doesn't have a sticker with licensing information on it.  I intend to dual-boot to Linux, but, with various UEFI intricacies, want to know what the options are in a worst-case scenario -- assuming that Windows is totally broken and unrecoverable.
Leaving aside fixing UEFI or other problems.  Clean install.  See also:
<code>you can download an iso from the MSDN Subscriber Downloads and install a clean Windows 10 with said iso.
</code>
How exactly does that process work?  Bearing in mind that the working system has a license.  (Apparently, applying Windows Updates records the license on Microsoft servers...?)
Comment: Possible duplicate of [Reset Windows 10 from USB](http://superuser.com/questions/1148506/reset-windows-10-from-usb)
Comment: @Ramhound not sure where I read that...
Answer: After Windows 7 that is Windows 8 or later version preinstalled on a laptop, we never need to enter the product key manually. If we reinstall the proper version of Windows (Home, Professional, etc). The installation process reads the product key automatically from the BIOS.
Comment: Yes, Many tools are available online. Just an example take a look at this [video](https://www.youtube.com/watch?v=i3Apbh1QuNE).
Comment: this is windows 10, so UEFI.  Can I read the product key from the firmware?  Either human or machine readable.  "save key" utility?
Answer: Microsoft has several methods of distributing licenses and entitlements to Windows 10. Depending on the method you obtained your copy of Windows, you may either have a product key, or a digital license which requires no product key. The Digital license is based on your hardware, so during activation it is automatically applied and activated. The following information was obtained here:

Activation helps verify that your copy of Windows is genuine and hasn't been used on more devices than the Microsoft Software License Terms allow. Depending on how you got your copy of Windows 10, activation will use either a digital license or a 25-character product key.
Digital license (called a digital entitlement in Windows 10 Version 1511) is a method of activation in Windows 10 that doesn't require you to enter a product key.

You upgraded to Windows 10 for free from an eligible device running a genuine copy of Windows 7 or Windows 8.1. - Digital license
You bought genuine Windows 10 from the Windows Store and successfully activated Windows 10. - Digital license
You bought a Windows 10 Pro upgrade from the Windows Store and successfully activated Windows 10. - Digital license
You're a Windows Insider and upgraded to the newest Windows 10 Insider Preview build on an eligible device that was running an activated previous version of Windows and Windows 10 Preview. - Digital license
You bought a copy of Windows 10 from an authorized retailer.    - Product key (On a label inside the Windows 10 box. A digital license will be given to your device for Windows 10 based on the valid product key you entered.)
You bought a digital copy of Windows 10 from an authorized retailer. - Product key (In the confirmation email you received after buying Windows 10 or in a digital locker accessible through the retailer's website. A digital license will be given to your device for Windows 10 based on the valid product key you entered.)
You have a Volume Licensing agreement for Windows 10 or MSDN subscription. - Product key (Available through the web portal for your program.)
You bought a new device running Windows 10. - Product key
(Pre–installed on your device, included with the device packaging, or included as a card or on the Certificate of Authenticity (COA) attached to the device.)

One of the most common ways a digital license was obtained was during the free Windows 7/8 upgrade to Windows 10 via the GWX icon. If you obtained it this way, you will not need to enter a product key at all. After the system installs, it will just activate and work.
If you can access the Settings app on your running machine now, you can go to the Update & Security section and click Activation. Here you will either get Activated via Digital Entitlement, or be shown that Windows is simply activated which implies that a Product key was used (either embedded or manually entered).
Digital Entitlement Activation
Answer: You don't need to reinstall Windows. Since Windows 8 there is a build in way to reset Windows to the original state, which is the same like doing a clean install.
Start the Settings app, go to System & Security -> Recovery and select "Reset this PC"


Restricting access to limited data extennsions in journey email test and preview

Question: I have a user role that has only permission to create and edit email in email studio but can't see any data extensions or subscriber data. But, now I have to give them access to journey builder and they should be able to test email from there. During that, they are able to view all customer data in data extensions, which is not good. Is there any way to restrict them to see only specific data extensions or folders in that space.
Thank you
Comment: That, or a separate business unit, which would probably not be a practical solution in many adhoc situations. That's pretty much it for data separation. Be careful: As of today, once you set something to "shared", be aware it becomes accessible for ALL BUs via SQL / AMPScript, SSJS regardless of sharing settings. You might not _see_ it on the UI, but you can query it or perform lookups. So be careful not to create another problem by fixing one.
Comment: The only thing that comes to my mind is using shared dataextension for everything they should not be able to see and then restrict access to shared dataextensions.
Answer: unfortunately restricting the view only to a specific folder or Data extension not possible.
I will suggest planning your DE and user's roles according to the Business unit if you don't wanna show other business DE to other users.


Set default Finder window size

Question: What's the recommended way to set the default size of a Finder window in macOS Mojave? I've tried following advice like that given in How to set default finder window size?, but no luck. It's annoying how hard Apple make this, but even if I could edit a plist file, that would be sufficient for now...
Answer: So, it seems a year later, nobody had been able to solve this one, (couldn't find any solutions posted any website) so I decided to give it a shot. After some extensive research, I've arrived at the following solution.
macOS Version: This was tested on macOS 11.0 Big Sur and on macOS 10.15 Catalina as well
Customizing the default dimensions of the Finder window

Open the Terminal application, enable the "Quit Finder" menu item
defaults write com.apple.finder QuitMenuItem -bool true; killall Finder

In Finder, open a new window and configure its size/dimensions to the exact way you like it

Quit the Finder application (⌘ Q)

Launch the Finder application

When you first open the Finder application, a window is not created, which is a bit unintuitive ¯\_(ツ)_/¯

In Finder, create a new window (⌘ N)

The position/dimensions of this window should be exactly the way you like it. Finder determined what the position/dimension ought to be using configurations stored in the ~/.DS_Store file. Every time a Finder window is moved or resized, the ~/.DS_Store file will be written to.

Any future windows should default to opening with this size/position on the screen.
Note: If you try to open a Finder window on a larger screen, don't expect the window to be centered. Finder doesn't store the relative offset of the window to the screen, it stores the X/Y pixel offset from the top-left corner
Note: Don't try and be clever by removing write access to ~/.DS_Store, it didn't work out for me. Finder's reaction to losing write access is to ignore the ~/.DS_Store file completely, causing every new window to open with the factory-default window configurations
Comment: I think this will only work for Finder windows that you open in the default location. For instance, as a test, if you run in Terminal `mkdir test && open test`, I expect Finder will revert back to its stock size. There isn't really a way to do what you're asking (unless a developer can find the private functions used so they can be overridden in SIMBL, or some such.)
Comment: If it worked @Noldorin don't forget to [mark the answer as accepted](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)

Set default Finder window size


I plan on working for a US company from abroad for three months. Do I need a US address at this time to remain a tax resident of my state?

Question: I am considering spending three months abroad while working remotely. While I plan on returning to my current state (New Jersey), I do not want to continue to pay rent when I'm not here, which means I would not have a NJ address during this time. Would that change my tax residency? I would like to remain resident of the state to avoid tax complications. I would also appreciate any resources you could direct me to.
Comment: Where would you get mail?  It's possible that you might get time-sensitive things by US Mail (e.g. summons to jury duty, notice of IRS audit), so it might be a good idea to have a friend or family receive your mail.  Then that becomes your temporary residence...
Answer: I'm familiar with being a part-year state resident in a a state that also collected income tax. Looking over New Jersey it appears to be the same. That is they look at your intent for the move as to whether it is temporary or permanent. From your situation, the intent definitely appears to be temporary and you'd be a full-year resident of NJ as a result. If you could document your intention to stay long term in another state or country (driver's license, residency permit, bank accounts, etc.), you could make the case that the move was indeed intended to be permanent, and then would not be subject to NJ state income tax for the period you did not live there.

For New Jersey Income Tax purposes, your residency status depends on where you were domiciled and where
you maintained a permanent home during the tax year. Generally, when you change your domicile during the
year, you are a resident of New Jersey for part of the year (part-year resident) and a nonresident of New Jersey
for part of the year (part-year nonresident). Your move is generally considered a change of residency status
(resident to nonresident or vice versa) if, at the time you moved, you intended to permanently leave one home
and establish a new permanent home somewhere else.

In regards to US income tax, you'd still have to file that the same as you previously did as the length of stay outside the US wouldn't allow for you to be eligible the Foreign Earned Income Exclusion.
Comment: The last paragraph could be improved by mentioning, even in passing, the ability to potentially claim foreign tax credits against foreign employment income; the current implication of that last paragraph is that the OP may pay double tax, which is quite unlikely (it would depend on the tax treaty between the US and the foreign country).
Comment: Agreed, however eligibility for the FEIE is quite complicated and outside of the scope of the OP question. I just wanted to make it a point that federal taxes wouldn't change in this instance and provide the relevant information from the IRS if they were interested in learning more.
Answer: Interestingly, say you sold your home and moved overseas FOREVER !
Your tax residence location would still be NJ.
Here's a clear explanation re US'ers who live overseas for a long time:
https://vhd.overseasvotefoundation.org/index.php?/ovf/Knowledgebase/Article/View/1030/1/which-state-do-i-vote-in-if-i-no-longer-maintain-us-residence
If you holiday overseas for three months,
and indeed "get rid of" your rental or owned home in NJ when you leave,
there are absolutely no US tax implications, whatsoever.  You do not even "tell them" about it; it is fortunately completely irrelevant.
The one and only change would be, on your next tax return, you'd have "changed address" - that's it.  Nothing else.


A regression manhwa where female lead is to be married to someone but betrayed by her brother

Question: I once saw a recommendation wherein the title has a word "lie" in it but it's not You're Eternal Lie I think the female lead has also blonde hair and the male lead has dark hair. I also remembered that she was to be married to male lead but her brother betrayed her due to jealousy. I guess she was more powerful than her brother that's why he is jealous. I remembered both leads were in a carriage going to the male lead's place but female lead was assassinated by her brother. She then regressed to a time where she thought her brother was only concerned for her that's why he keeps on advising her to just live a low-key life and now when she returns back in time she realizes it was only because he only do it for his own benefit.
Answer: Sounds like My Sweet Enemy, Thy Name is Husband.

Canach Riadon — a slave who rose to emperor and the man I wed in my first life. Yet our ill-fated marriage left my family murdered and my homeland destroyed at his hands. Now given a second chance, I vow to succeed in this political marriage and save all I love... Or will his love save me first?
Comment: Hi, welcome to SF&F.  Can you describe this and explain how it matches?


How to run mvim (MacVim) from Terminal?

Question: I have MacVim installed and I am trying to set it up as the editor for Git (version control),  but I can't run 'mvim' from the command line as it isn't recognised. How do I setup mvim so I can run it from Terminal?
Comment: Disclaimer: this would work for Linux so I suppose it is similar on a Mac. Try to see the path (use "`echo $PATH`") and add the folder to the MacVim executable to it if it's not there already (use "`export PATH=$PATH:path/to/folder`"). Mind the `$` signs, they are important!
Comment: Try `vim` from the command-line.
Answer: I don't think I'd to add anything to the path, did
brew install macvim

mvim -v

should then open macvim in the terminal, you can also go ahead and alias that
alias vim='mvim -v'

Comment: Anyone reading this today using homebrew you'll have to run `brew linkapps` after installing macvim.
Comment: `brew linkapps --system` if you want it in your /Applications folder.
Comment: The '-v' option works if you've installed from source or from download as well as shown in other answers.
Comment: If running `brew linkapps` didn't help, also run `brew doctor` and watch for macvim-related warning messages - you may need to run `brew link --overwrite macvim` if suggested.
Comment: With this -v flag for some reason changing the font doesn't work.
Answer: There should be a script named mvim in the root of the .bz2 file. Copy this somewhere into your $PATH ( /usr/local/bin would be good ) and you should be sorted.
Comment: Since mvim is simply a shell script, you can download it directly from the MacVim source at GitHub here: https://raw.github.com/b4winckler/macvim/master/src/MacVim/mvim
Comment: As per  :help mvim I had to add `/Applications/MacVim.app/Contents/bin` to my path then it worked fine.
Comment: Where do you find the bz2 file?
Comment: You can locate the file by using find from your root directory. `sudo find . -name mvim` Mine was in /Applications/MacVim-snapshot-64/mvim.
Comment: A year ago that was what you got when you downloaded MacVim. Now it's a.tbz file, but the script is still there.
Comment: It's now located in the DMG you download.
Comment: I also can't find where macvim or the bz2 file is
Comment: `mvim` can also be had directly from [source](https://github.com/b4winckler/macvim/blob/master/src/MacVim/mvim).
Comment: Sorry for last incorrect comment. I left correcting edit open and it expired after 5 minutes (I hate that limit). mvim is actually located in the TBZ which also contains the MacVim.app which you get from the normal [downloads location](https://code.google.com/p/macvim/downloads/list). Personally I think mvim should be inside the MacVim.app bundle though (see this [thread](https://groups.google.com/forum/?fromgroups=#!searchin/vim_mac/mvim$20location/vim_mac/S1jCDYPmYx0/wXKwu1IEb5AJ) for discussion).
Answer: If you go the brew route, the best way to install would be:
brew install macvim --with-override-system-vim

That will provide mvim, vim, vi, view, etc. in /usr/local/bin (all symlinked to the copy in the Cellar). This also removes the need to create any aliases and also changes your vi, vim, etc. to all use the same Vim distribution as your MacVim.
Comment: Dave, that sounds like a PATH problem, /usr/local/bin needs to be first in your PATH.  This answer, pointing at brew, should be the number one answer, as it gets you everything you need.
Comment: fyi running `brew doctor` should notify you of any PATH or configuration issues for brew.
Comment: Whilst the `--override-system-vim` did create some of the symlinks for me, it failed to override `/usr/bin/vim` and `/usr/bin/vi` and so I still had to manually `alias` these in my `.profile`.
Comment: Awesome! Thanks for posting this. I added --override-system-vim and didn't even realize how useful it would be.
Comment: This did not work for me, not sure that this argument still works??
Answer: If you already have macVim installed: /Applications/MacVim.app/Contents/MacOS/Vim -g will give you macVim GUI.
just add an alias.
i use gvim because that is what i use on linux for gnome-vim.
alias gvim='/Applications/MacVim.app/Contents/MacOS/Vim -g'
Comment: Note: also useful if homebrew refuses to install macvim because you're staying on "this old version" of macOS for whatever reason. :)
Comment: Thanks for that tip, @tekHedd. I'm staying on "this old version" of macOS because I have 32-bit versions of expensive software that I don't want to replace and which has been converted to a subscription model, so I'm keeping the "old" OS so I can run the "old" software that I paid for "in perpetuity" for as long as I reasonably can. YMMV.
Comment: Also using `alias vim=/Applications/MacVim.app/Contents/MacOS/Vim` is a great idea. Then you don't need to install MacVim via either MacPorts or Homebrew to update Vim in your terminal, you can just install the release packages from the GitHub release page.
Answer: In addition, if you want to use MacVim (or GVim) as $VISUAL or $EDITOR, you should be aware that by default MacVim will fork a new process from the parent, resulting in the MacVim return value not reaching the parent process. This may confuse other applications, but Git seems to check the status of a temporary commit message file, which bypasses this limitation. In general, it is a good practice to export VISUAL='mvim -f' to ensure MacVim will not fork a new process when called, which should give you what you want when using it with your shell environment.
Answer: Assume MacVim is installed in the Application folder.
Instead of adding MacVim path to your environment, create a link by typing this in terminal:
sudo ln -s /Applications/MacVim.app/Contents/bin/mvim /usr/local/bin/mvim
Then, open a new terminal window/tab and type mvim.
Answer: If you have homeBrew installed, this is all you have to do:
brew install macvim
brew linkapps

Then type mvim in your terminal to run MacVim.
Comment: Warning: `brew linkapps` has been deprecated and will eventually be removed!
Comment: Well that's how to do it with a fresh installation, I think he's asking how to make an alias when it's already installed.
Answer: Here's what I did:
After building Macvim I copied mvim to one of my $PATH destinations (In this case I chose /usr/local/bin)
cp -v [MacVim_source_folder]/src/MacVim/mvim /usr/local/bin

Then when you invoke mvim it is now recognised but there is an annoying thing. It opens the visual MacVim window, not the one in terminal. To do that, you have to invoke
mvim -v

To make sure every time you call mvim you don't have to remember to add the '-v' you can create an alias:
alias mvim='mvim -v'
However, this alias will only persist for this session of the Terminal. To have this alias executed every time you open a Terminal window, you have to include it in your .profile
The .profile should be in your home directory. If it's not, create it.
cd ~
mvim -v .profile

include the alias command in there and save it.
That's it.
Comment: Probably better to `ln -s` it than `cp` it.
Comment: With this `-v` flag changing the font doesn't work. `-v` enables vi mode. Can imagine that other things don't work in this mode, besides setting a custom font.
Comment: Tried this but it didn't work for me.  VIM_APP_DIR=~/Downloads/MacVim-snapshot-64/MacVim.app
$ mvim -v x.x
Sorry, cannot find MacVim.app.  Try setting the VIM_APP_DIR environment variable to the directory containing MacVim.app.
Comment: This works when you build MacVim from source, https://github.com/macvim-dev/macvim/blob/master/README_mac.txt, thanks @douglas
Answer: I'm adding Bard Park's comment here for that was the real answer for me:

Since mvim is simply a shell script, you can download it directly from the MacVim source at GitHub here: http://raw.github.com/b4winckler/macvim/master/src/MacVim/mvim
Comment: /usr/local/bin was in my PATH, but the bin folder was absent. I had trouble working directly in /usr/local, (probably a permissions issue), so I created a bin directory in my Documents folder. There I created an mvim file, into which I copied the contents of Bard Park's link. I dragged the bin folder with the mvim script to /usr/local. I was asked for my password, then allowed to place the mvim script where I wanted it. But the script didn't run yet. I entered:  sudo chmod 755 mvim   to give the script execute permissions. Now from the command line when I type mvim filename, MacVim launches.
Comment: In order to drag the bin folder into /usr/local, first I entered: open .  from the command line in /usr/local. Doing so brings up the finder GUI for that file location.
Answer: I'd seriously recommend installing MacVim via MacPorts (sudo port install MacVim).
When installed, MacPorts automatically updates your profile to include /opt/local/bin in your path, and so when mvim is installed as /opt/local/bin/mvim during the install of MacVim you'll find it ready to use straight away.
When you install the MacVim port the MacVim.app bundle is installed in /Applications/MacPorts for you too.
A good thing about going the MacPorts route is that you'll also be able to install git too (sudo port install git-core) and many many other ports. Highly recommended.
Comment: Don't use mac port versions unless you absolutely need to. It installs all the dependency libraries ignoring darwin native ones. This can i.e. replace your perl 5.10 with 5.8 in path etc. Check homebrew (brew) system instead.
Comment: @SlavaNadvorny maybe true when this was written.  I currently have a development environment with MacVim, scipy, haskell, multiple versions of erlang, python and perl all functioning properly with macports.  The same was not possible with brew (at this time this was written).  I do like brew's non-sudo install and wished it worked in this case.
Comment: Thanks I'll give this a go.  I installed MacVim and Git using the UI installers.  But its looking like Macports is the way to go.
Comment: Using homebrew works great too `brew install macvim`.
Comment: fwiw, I used both normal MacVim app (installed via downloaded) _and_ the MacPorts version (`sudo port install MacVim`), in fact at one point, I had both installed (which is fine, but unnecessary). The `port` MacVim didn't have the "version" string set (it was null) and asked to upgrade itself (via the gui) which produced an error (no permission, of course), so since I wasn't sure what version I was running, I ultimately `port uninstall MacVim` and just kept the "normal" MacVim app, and updated my path `PATH=$PATH:/Applications/MacVim.app/Contents/bin` to find `mvim` etc from terminal.
Answer: For Mac .app bundles, you should install them via cask, if available, as using symlinks can cause issues. You may even get the following warning if you brew linkapps:

Unfortunately brew linkapps cannot behave nicely with e.g. Spotlight using
  either aliases or symlinks and Homebrew formulae do not build "proper" .app
  bundles that can be relocated. Instead, please consider using brew cask and
  migrate formulae using .apps to casks.

For MacVim, you can install with:
brew cask install macvim

You should then be able to launch MacVim like you do any other macOS app, including mvim or open -a MacVim from a terminal session.
UPDATE: A bit of clarification about brew and brew cask. In a nutshell, brew handles software at the unix level, whereas brew cask extends the functionality of brew into the macOS domain for additional functionality such as handling the location of macOS app bundles. Remember that brew is also implemented on Linux so it makes sense to have this division. There are other resources that explain the difference in more detail, such as What is the difference between brew and brew cask?
 so I won't say much more here.
Comment: Could we add some clarity about what the difference between using the cask install vs not cask install? Hard to tell what the differences are when both cask and not cask install commands work...
Comment: I added a short blurb but I don't know all the details so I didn't go into detail.
Answer: This works for me:
λ brew link --overwrite macvim
Linking /usr/local/Cellar/macvim/8.0-146_1... 12 symlinks created

How to run mvim (MacVim) from Terminal?


Punishment for those who do not know

Question: I am a student in America. When my teacher and I were talking about Islam he asked will people be punished if they do something wrong thinking it is right and die with it. So they don't ask forgiveness because they think it is right.
Comment: **** Comments are intended for constructive criticism and seeking clarification, not for answering questions or tangential discussion.
Answer: To answer your question, we should know that the person who did "something wrong" thinking it was right, we shall first see if this person has access to information to know if it is wrong or not.
If this person has no means to know that what he/she did is wrong, then there is no need to ask for forgiveness because there is no admission to guilt in the first place.
If however, there was a way for them to find if what they did is wrong, but they were too lazy to look it up, that is a different issue. They might be punished for the laziness and/or the actual punishment for the act itself.
Comment: @asmaHuda There is an Aya in Quran (No bearer of burdens shall bear another's burden) Fater, verse 18. You are not responsible for some else's fault. You will be rewarded if you teach him/her what to do, or to stop doing the wrong thing. But not punished if you don't
Comment: btw are we punished for not teaching him/her about the ruling of somthing ( though we know they neeed it ) bcs of shyness?

Punishment for those who do not know