After window resizing, font size changes, etc., how can I easily and quickly check what is the current display width of my terminal?
I'm writing a script which shows the git log for a directory when I cd into it. Such a log can be overwhelming, containing hundreds of lines. So far I have been limiting that to a hard-coded 20 lines (... | head -n 20), which is fine on the screen at work, but too much on the smaller MacBook screen at home.  I would prefer the log to take up about half the (vertical) screen on either terminal. And "terminal" also changes: it's Gnome terminal at work, but iTerm2 at home. And I do not use screen or tmux.  How do I find the number of vertical lines available in a terminal from command line?
How to create a database directory structure for MySQL? Function to determine if two numbers are nearly equal when rounded to n significant decimal digits I have been asked to test a library provided by a 3rd party. The library is known to be accurate to n significant figures. Any less-significant errors can safely be ignored. I want to write a function to help me compare the results:  def nearlyequal( a, b, sigfig=5 ):   The purpose of this function is to determine if two floating-point numbers (a and b) are approximately equal. The function will return True if a==b (exact match) or if a and b have the same value when rounded to sigfig significant-figures when written in decimal.   Can anybody suggest a good implementation? I've written a mini unit-test. Unless you can see a bug in my tests then a good implementation should pass the following:  assert nearlyequal(1, 1, 5)  assert nearlyequal(1.0, 1.0, 5)  assert nearlyequal(1.0, 1.0, 5)  assert nearlyequal(-1e-9, 1e-9, 5)  assert nearlyequal(1e9, 1e9 + 1 , 5)  assert not nearlyequal( 1e4, 1e4 + 1, 5)  assert nearlyequal( 0.0, 1e-15, 5 )  assert not nearlyequal( 0.0, 1e-4, 6 )    Additional notes:   Values a and b might be of type int, float or numpy.float64. Values a and b will always be of the same type. It's vital that conversion does not introduce additional error into the function. Lets keep this numerical, so functions that convert to strings or use non-mathematical tricks are not ideal. This program will be audited by somebody who is a mathematician who will want to be able to prove that the function does what it is supposed to do. Speed... I've got to compare a lot of numbers so the faster the better. I've got numpy, scipy and the standard-library. Anything else will be hard for me to get, especially for such a small part of the project. extended stars-and-bars problem(where the upper limit of the variable is bounded) The problem of counting the solutions $(a_1,a_2,\ldots,a_n)$ with integer $a_i\geq0$ for $i\in\{1,2,\ldots,n\}$ such that $$a_1+a_2+a_3+....a_n=N$$ can be solved with a stars-and-bars argument. What is the solution if one adds the constraint that $a_i\leq r_i$ for certain integers $r_1,\ldots,r_n$?  e.g. for $n=3$, $N=6$ and $(r_1,r_2,r_3)=(3,3,2)$, the tuple $(a_1,a_2,a_3)=(2,3,1)$ is a solution, but $(2,1,3)$ is not a solution because $a_3=3&gt;2=r_3$. Most useful additions in KOMA-Script? (Background: I'm a beginner who will mostly use LaTeX for university articles and reports, but no math. Also, as I reside in Canada, the German typography conventions, which I understand KOMA-Script supports better than LaTeX, are less relevant).  I've read that the KOMA-Script package has a lot of improvements for the default document classes. Yet the 's length, about 250 pages, is somewhat daunting. I plan to read the chapters I'm interested in anyway but it'd be useful to have some pointers about low hanging fruits. I searched the site and  answers say KOMA-Script adds improvements but do not delve into details.  I'll ask this as a community wiki topic and, since the audience of this site is international, feel free to mention German typography if KOMA-Script is better there. How to simulate simple on/off, Single-Pole-Single-Throw switch? I am trying to simulate ON, OFF switch in this simple circuit:  V1 0 1 1.5v Rfan1 3 4 1 S1 1 4 SW ON Rwire1 6 5 0.00001 VV1 0 2 dc 0  VRfan1 3 5 dc 0  VRwire1 2 6 dc 0  .dc V1 1.5 1.5 1 .print dc i(VV1) i(VRfan1) i(VRwire1)  .end   but I got this error:  ngspice stopped due to error, no simulation run!   the circuit I am trying to simulate is like this one:    if I replace the switch with a resistor, the circuit will work normally.  any idea? EDIT  I have fixed my switch as the following:  S1 1 4 98 99 mySwitch ON .model mySwitch SW vt=0 vh=1 ron=1n roff=10k Sphere intersection Stuck I have two spheres that are bounded by spheres for collision detection. I do not want them to intersect. My intersection works. But it gets stuck. Once the function returns true, I cannot get it out. I tried  collideBool = ObjectOne.Intersect(ObjectTwo);  if(collide == true) {     leftright = leftright;     updown = updown; } else { if(GetAsyncKeyState(VK_RIGHT)) leftright -= dt; if(GetAsyncKeyState(VK_LEFT)) leftright += dt; if(GetAsyncKeyState(VK_DOWN)) updown += dt; if(GetAsyncKeyState(VK_UP)) updown -= dt; }  collide = false;   My sphere gets stuck. What is a way around this? Mounting /cow on root failed: Invalid argument overlay mount failed I am using an xps 13 9365, which was data wiped from bios by a friend who then gave it to me thinking it was dead. I tried booting with a USB (current LTS distro (18.04 or similar)) boot disk and got into the language selection / setup menu. By using the F6 option I selected noapic. In bios sata is set to raid and legacy the secure boot option is off.   But when I try to install I get kicked into a tiny font window with the following message  (initramfs) mount: Mounting /cow on root failed: Invalid argument overlay mount failed  Any ideas? I always see commands like this  apt-get -y install    What is the -y tag for and what is the difference between apt-get install with and without the -y tag? Regex for parsing directory and filename I'm trying to write a regex that will parse out the directory and filename of a fully qualified path using matching groups.  so...  /var/log/xyz/10032008.log   would recognize group 1 to be "/var/log/xyz" and group 2 to be "10032008.log"  Seems simple but I can't get the matching groups to work for the life of me.  NOTE:  As pointed out by some of the respondents this is probably not a good use of regular expressions.  Generally I'd prefer to use the file API of the language I was using.  What I'm actually trying to do is a little more complicated than this but would have been much more difficult to explain, so I chose a domain that everyone would be familiar with in order to most succinctly describe the root problem. Axiom of Choice: Where does my argument for proving the axiom of choice fail? Help me understand why this is an axiom, and not a theorem. In terms of purely set theory, the axiom of choice says that for any set $A$, its power set (with empty set removed) has a choice function, i.e. there exists a function $f\colon \mathcal{P}^*(A)\rightarrow A$ such that for any subset $S$ of $A$, $f(S)\in S.$ Is this correct?  My question then is about proving this fact, so that we do not need to put it as an axiom. Now as per the research done on this single object- Axiom of Choice, I believe here that there should be some falsity in my argument. I do not find the mistake.  For any $S\in \mathcal{P}^*(A)$, since $S\neq \emptyset$, $\exists s\in S$. Define $f(S)=s$. Then $f$ is a choice function.  This was showing me that the axiom of choice is proved, but then why it had been put as an axiom? For example, in  book, the author asserts that      It is a metatheorem of mathematical logic that it is impossible to specify the function that assigns to each non-empty subset of $\mathbb{R}$, an element of itself.     There are several notes and books on axiom of choice, but here I am trying to understand through doing some argument for some problem, where problem actually arises. I have a bash script that makes a cURL request and writes the output to a file called resp.txt.  I need to create an exclusive lock so that I can write to that file and not worry about multiple users running the script and editing the text file at the same time. Here is the code that I expect to lock the file, perform the request, and write to the text file: ( flock -e 200 curl 'someurl' -H 'someHeader' &gt; resp.txt ) 200&gt;/home/user/ITS/resp.txt  Is this the correct way to go about this?  My actual script is a bit longer than this, but it seems to break when I add the flock syntax to the bash script. If someone could explain how these file descriptors work and let me know if I am locking the file correctly that would be awesome! How can I prove the immigrant officers that I have significant ties in my home country?  Are there any documents that I need? Can I connect copper wire to aluminum wire? Expanding a parent  to the height of its children I have a page structure similar to this:  &lt;body&gt;   &lt;div id="parent"&gt;     &lt;div id="childRightCol"&gt;       /*Content*/     &lt;/div&gt;     &lt;div id="childLeftCol"&gt;       /*Content*/     &lt;/div&gt;   &lt;/div&gt; &lt;/body&gt;   I would like for the parent div to expand in height when the inner div's height increases.  Edit: One problem is that if the width of the child content expands past the width of the browser window, my current CSS puts a horizontal scrollbar on the parent div.  I would like the scrollbar to be at the page level. Currently my parent div is set to overflow: auto;  Can you please help me with the CSS for this? Not for any specific program, just in general if I wanted to install something via APT how do I know what packages I need to "apt-get install" for that program How can I restore configuration files? Can't mount an IDE HDD - "can't read superblock" error message I'm trying to mount my HDD,  /dev/sdb, which is connected via an enclosure but every time I try do so I get an error message   mount: /dev/sdb: can't read superblock   How do I solve this problem and mount my HDD? Is there an official Marvel Cinematic Universe viewing order? I'm planning on re-watching the currently-released 5 Marvel films prior to seeing The Avengers.  Have Marvel released any sort of official viewing order?  Captain America: The First Avenger seems like the hardest one for me to place in order with the rest.  It takes place prior to the other films, but has the greatest number of references to the other films.  So should it be watched first, or last?  The rest of them are relatively clear, as they're chronological in the order they're released, with the possible exception of The Incredible Hulk and Iron Man 2 happening at the same time. Location of /etc/fstab in El Capitan I want to activate the . But I can't find the /etc/fstab on my mac. osx 10.11.5 El Capitan When my receiver that I have hooked up to my pc turns on it causes my monitors to turn black is there a way to stop this?