I have a custom logger class which implements the ILogger interface. The custom logger is a separate assembly/nuget. I was trying to use stacktrace to find the name of the calling method but it seems it differs if used in the program versus a unit testing project. Is there a more convenient way to get the calling method e.g. the calling assembly method name? public class MyClass {     private void HelloWorld() {         var myLoggerProvider = new LoggerProvider(Config);         LoggerFactory.AddProvider(myLoggerProvider);         var logger = LoggerFactory.CreateLogger&lt;Program&gt;();         LogInformation(&quot;HelloWorld&quot;);    } }  //   Inside custom logger  ////...      public void Log&lt;TState&gt;(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func&lt;TState, Exception, string&gt; formatter)     {        //   Get the calling function name       var classFunction = new StackTrace(4).GetFrame(0).GetMethod().Name;     }  ///....
When logging in C#, how can I learn the name of the method that called the current method? I know all about System.Reflection.MethodBase.GetCurrentMethod(), but I want to go one step beneath this in the stack trace. I've considered parsing the stack trace, but I am hoping to find a cleaner more explicit way, something like Assembly.GetCallingAssembly() but for methods.
I have a simple question about calculating distances in PostGIS.  I would like to get the distance between two geometries. I am using this sid : 4269 in meters what i am doing now is this : ST_Distance((a.geom,b.geom)) FROM ... but I am getting result in degrees. I think that I should work with geography but how can I cast a geom to a geography? I tried with (a.geom::geography) but i am getting an error.  What can I do to get my result in meters?   Thank You I am running a query like   select id from students where school_id='67153fb1-8f79-441d-a747-ca3778cf6d3d';   on table that looks like                                      Table "public.students"           Column       |            Type             |             Modifiers                   -------------------+-----------------------------+------------------------------------      id                | uuid                        | not null default gen_random_uuid()      school_id        | uuid                        |  Indexes:     "students_pkey" PRIMARY KEY, btree (id)     "students_school_id_idx" btree (school_id)   The query plan for the select statement with just where looks like below-  explain select id from students where school_id='67153fb1-8f79-441d-a747-ca3778cf6d3d';                                             QUERY PLAN                                             --------------------------------------------------------------------------------------------------  Bitmap Heap Scan on students  (cost=581.83..83357.10 rows=24954 width=16)    Recheck Cond: (school_id = '67153fb1-8f79-441d-a747-ca3778cf6d3d'::uuid)    -&gt;  Bitmap Index Scan on students_school_id_idx  (cost=0.00..575.59 rows=24954 width=0)          Index Cond: (school_id = '67153fb1-8f79-441d-a747-ca3778cf6d3d'::uuid)   This is fairly fast.  Now we add order by to the query with id that degrades the query.(Such a query is generated by Rails like student.first with some condition)  explain select id from students where school_id='67153fb1-8f79-441d-a747-ca3778cf6d3d' order by id asc limit 1;                                                  QUERY PLAN                                                  ------------------------------------------------------------------------------------------------------------  Limit  (cost=0.43..488.51 rows=1 width=16)    -&gt;  Index Scan using students_pkey on students  (cost=0.43..12179370.22 rows=24954 width=16)          Filter: (school_id = '67153fb1-8f79-441d-a747-ca3778cf6d3d'::uuid)   How can I improve the speed to return the results of this query? Currently there are around 4990731 records in the table and is taking more than 2 minutes! Its running on RDS with db.t2.medium instance.  UPDATE After running Analyze students;  explain select id from students where school_id='67153fb1-8f79-441d-a747-ca3778cf6d3d' order by id asc limit 1;                                                        QUERY PLAN                                                         -----------------------------------------------------------------------------------------------------------------      Limit  (cost=8.46..8.46 rows=1 width=16)        -&gt;  Sort  (cost=8.46..8.46 rows=1 width=16)              Sort Key: id              -&gt;  Index Scan using students_school_id_idx on students  (cost=0.43..8.45 rows=1 width=16)                    Index Cond: (school_id = '67153fb1-8f79-441d-a747-ca3778cf6d3d'::uuid)      explain analyze select id from students where school_id='67153fb1-8f79-441d-a747-ca3778cf6d3d' order by id asc limit 1;                                                                           QUERY PLAN                                                                              -----------------------------------------------------------------------------------------------------------------------------------------------------------     Limit  (cost=8.46..8.46 rows=1 width=16) (actual time=1.853..1.855 rows=1 loops=1)      -&gt;  Sort  (cost=8.46..8.46 rows=1 width=16) (actual time=1.851..1.852 rows=1 loops=1)            Sort Key: id            Sort Method: quicksort  Memory: 25kB            -&gt;  Index Scan using students_school_id_idx on students  (cost=0.43..8.45 rows=1 width=16) (actual time=1.841..1.843 rows=1 loops=1)                  Index Cond: (school_id = '67153fb1-8f79-441d-a747-ca3778cf6d3d'::uuid)     Planning time: 0.145 ms     Execution time: 1.874 ms How can I find just the *.mp3 files with a recursive command like ls -R *.mp3 in a directory that contains several sub-directories and at the end copy these files in a directory that I choose.  Thanks for your support. What are the details surrounding the brass brazier required for the Find Familiar spell? In our campaign, I play a warlock and brass braziers are hard to come by. I want to carry a brass brazier in case my familiar dies and I need to again cast find familiar.   How bulky is a small brass brazier? Can it be carried for several weeks without hindering long distance foot travel? That is, because of its shape or weight, does the typical brass brazier reduce my speed? What's the price of a small, simple brass brazier? How long would it take a brass worker to make a small, simple brazier? How long would it take the brass worker to make one specifically designed to be eminently portable? In both cases, assume the brass worker works nonstop exclusively on the brazier.     What I'm looking for are references, similar cases, and information that can help handle these issues properly and accurately. First and foremost in D&amp;D 5e (especially RAW) and then other RPGs and even real world, if they could be used to make estimates about the answers to these questions when we compare how similar cases translate to D&amp;D 5e mechanics. How to trim whitespace from a Bash variable? Make Vim show ALL white spaces as a character How to change sign text color in Minecraft? I have gone through every single website and video to try to make a sign with colored text, but nothing works. Can anyone help me to get a sign to say:  Place Block(dark blue and bold text)  I really want this for a map I am making and I need help. I have a laptop running 11.10 with 2 network interfaces, wired and wireless.  Wireless interface connects to the router with DHCP and connects to the internet. Wired interface is connected to a switch. I want the computers on the switch to get their IP addresses from the router not my laptop.     How would I go about setting this up? Bridging the interfaces? A method to count occurrences in a list I must have a blind spot, but I cannot find what it is.   I made a small python script that removes VLC from the sound menu. It runs perfectly in any way I run it from the terminal or from a launcher or whatever you can think of.   What the script actually does is nothing more than get the get the current settings:  gsettings get com.canonical.indicator.sound interested-media-players   edit the list, and set the changed list by:  gsettings set com.canonical.indicator.sound interested-media-players "['newlist']"   These commands are executed by a python script,. However, when run from a cronjob (crontab -e) only the gsettings - get - part works, but not the gsettings - set - section. That the get section works fine with cron, I checked by making the script write data (the original as well as the edited) to an external file.  Not a python problem  To see if the problem is related to python code, I created a bash script that applies a changed sound menu items list. The story is the same: the bash script runs fine from the command line or a launcher, not from cron, while any other command in the same script would run fine. Also, if I add any command at the end of the script below, it works fine and it looks like the script is satisfied with its own work.  Why is the gsettings set command not working when initiated from cron?  This is the script:  #!/usr/bin/python3 import subprocess  def read_soundmenu():     # read the current launcher contents     get_menuitems = subprocess.Popen([         "gsettings", "get", "com.canonical.indicator.sound", "interested-media-players"         ], stdout=subprocess.PIPE)     return eval((get_menuitems.communicate()[0].decode("utf-8")))  def set_current_menu(current_list): # this takes no effect from cron     # preparing subprocess command string     current_list = str(current_list).replace(", ", ",")     subprocess.Popen([         "gsettings", "set", "com.canonical.indicator.sound", "interested-media-players",         current_list,         ])  current_list = read_soundmenu() for item in current_list:     if item == "vlc.desktop":         current_list.remove(item) set_current_menu(current_list) Is it a problem if a UK visa was issued but not used? Last year, my wife and I were issused 6-month visieor visas for the UK. She did not travel with me and, therefore, didn't use her visa. I am currently applying for a visitor visa for my daughter and myself.  Will the fact that my didn't use her visa have any negative affect on our new application? Changing affiliation on publication Why are my render times 30+ minutes, but other people's are ~3 minutes? What are the limitations of healing magic? While reading Sorcerer's Stone, I just finished the chapter where Harry walks in on Snape and Filch bandaging Snape's leg.  In a previous chapter Neville falls off of his broom and we see that magic can easily heal his broken wrist.  If magic can heal an injury like broken bones, why wouldn't Snape heal his leg, which was just torn up by a 3-headed dog?  My initial thought was that only certain people specialize in healing magic, but while poking around this site I came across this question:   This shows that Snape had at least some healing abilities.  So why didn't he heal his own leg?  Are there limitations that prevented Snape from healing his own wounds? What are those zigzagged folded paper things you see in supernatural anime? In a lot of supernatural anime, like Shin Sekai Yori, or Tokyo Ravens there often appear these large ropes with folded paper things hanging from them:    As far as I can tell, they serve to seal or mark places that are sacred or in some way supernatural, like shinboku, or holy trees:    What are these folded paper things, and what purpose do they really serve? Exercise 3.5.12. Let $ f: \mathbb N \times \mathbb N \to \mathbb N$ be a function, and let c be a natural number. Show that there exists a function $a:\mathbb N\to \mathbb N$ such that $$a(0)=c$$ and $$a(n++)=f(n,a(n))\;for\;all\;n\in \mathbb N,$$ and furthermore that this function is unique. Tao gives the hint: first show inductively, by a modification of the proof of Lemma 3.5.12, that for every natural number $N\in \mathbb N$, there exists a unique function $a_N:\{ n\in \mathbb N:n\lt N\}\to \mathbb N $ such that $a_N(0)=c$ and $ a_N(n++)=f(n,a(n))$ for all $n\in \mathbb N$ such that $n\lt N$.  In my opinion, we could solve it by proving that $\forall n\in \mathbb N,a(n)\in \mathbb N$ according to mathematcial induction.  The property P(n) is:$$\forall n\in \mathbb N, a(n)\;is\;unique$$ P(0) is true. And if P(n) holds, P(n++) is true because different natural numbers must have different successors. $$a(n++)=f(n,a(n))$$ $$a(m++)=f(m,a(m))$$ $$n++=m++\Rightarrow n=m\Rightarrow a(n++)=a(m++)$$ It's similar to the proof of  Proposition 2.1.16 (Recursive definitions): Suppose for each natural number $n$, we have some function $f_{n} : \mathbb{N} \rightarrow \mathbb{N}$ from the natural numbers to the natural numbers. Let $c$ be a natural number. Then we can assign a unique natural number $a_{n}$ to each natural number $n$, such that $a_{0} = c$ and $a_{n{++}} = f_{n} (a_{n})$ for each natural number $n$.  This proof indicates both the existence and uniqueness of the function $a$. I don't know why Tao says it's informal.  But regarding the hint, how do we get the function f even if we've got the conclusion from the hint. Also it seems like the function a(n) can be diffentent considering different N. I don't know if the hint is correct. Suppose k is an integer such that $6k + 1$, $12k + 1$, $18k + 1$ are primes. Show that $n = (6k + 1)(12k + 1)(18k + 1)$ is a Carmichael number. Suppose k is an integer such that $6k + 1$, $12k + 1$, $18k + 1$ are primes. Show that $n = (6k + 1)(12k + 1)(18k + 1)$ is a Carmichael number.  This is a question on a past exam that I find difficulty to answer. Can anyone help? What does $\sum_{k=0}^\infty \frac{k}{2^k}$ converge to? This problem comes from another equation on another question (. I tried to split it in half but I found out that $$\sum_{k=0}^\infty \frac{k}{2^k}$$ can't be divided. Knowing that $$\sum_{k=0}^\infty x^k=\frac{1}{1-x}$$ I wrote that $$\sum_{k=0}^\infty \frac{k}{2^k}=\sum_{k=0}^\infty \left(\frac{\sqrt[k] k}{2}\right)^k=\frac{1}{1-\frac{\sqrt k}{2}}=\frac{2}{2-\sqrt[k] k}$$ But that's not what I wanted. Could anyone help me? How to resume baking fluid simulation? It happens sometimes that after finishing bake (e.g., for fluid simulation) we wish we could continue the simulation for two more seconds :(    How to use the cached bake to continue the simulation?  We played with the settings, but with no success. How can I install a package without installing some dependencies? I'm trying to install the package LaTeXila, and the output looks like this:  $ sudo apt-get install latexila --no-install-recommends Reading package lists... Done Building dependency tree        Reading state information... Done The following extra packages will be installed:   latexila-data latexmk luatex tex-common texlive-base texlive-binaries   texlive-common texlive-doc-base texlive-latex-base Suggested packages:   rubber texlive-latex-extra debhelper Recommended packages:   texlive texlive-latex-recommended texlive-luatex lmodern   texlive-latex-base-doc The following NEW packages will be installed:   latexila latexila-data latexmk luatex tex-common texlive-base   texlive-binaries texlive-common texlive-doc-base texlive-latex-base 0 upgraded, 10 newly installed, 0 to remove and 0 not upgraded. Need to get 29.3 MB of archives. After this operation, 74.5 MB of additional disk space will be used. Do you want to continue [Y/n]?   I don't want to install the texlive packages. I've installed texlive manually from . Any suggestions?