I can do this as:  if [[ "$is_to_rename" == true ]] then     printf "path %s\n" "a" &gt;&gt; $logger else     printf "path %s\n" "a" fi   But would be nice to reduce the duplicated code printf "path %s\n" "a", so tried the following small code:  #!/bin/bash is_to_rename=true printf "path %s\\n" "a" if [[ "$is_to_rename" == true ]]; then &gt;&gt; $logger; fi   But throws the error:  ./fixer.sh ./fixer.sh: line 66: syntax error near unexpected token `then' ./fixer.sh: line 66: `        printf "path %s\n" "a" if [[ "$is_to_rename" == true ]]; then &gt;&gt; $logger; fi'     It is possible not to keep repeating the code printf "path %s\n" "a"? [And do it in one line? (just for fun)]
Is it possible to redirect all of the output of a Bourne shell script to somewhere, but with shell commands inside the script itself? Redirecting the output of a single command is easy, but I want something more like this: #!/bin/sh if [ ! -t 0 ]; then     # redirect all of my output to a file here fi  # rest of script...  Meaning: if the script is run non-interactively (for example, cron), save off the output of everything to a file.  If run interactively from a shell, let the output go to stdout as usual. I want to do this for a script normally run by the FreeBSD periodic utility.  It's part of the daily run, which I don't normally care to see every day in email, so I don't have it sent.  However, if something inside this one particular script fails, that's important to me and I'd like to be able to capture and email the output of this one part of the daily jobs. Update: Joshua's answer is spot-on, but I also wanted to save and restore stdout and stderr around the entire script, which is done like this: # save stdout and stderr to file  # descriptors 3 and 4,  # then redirect them to &quot;foo&quot; exec 3&gt;&amp;1 4&gt;&amp;2 &gt;foo 2&gt;&amp;1  # ...  # restore stdout and stderr exec 1&gt;&amp;3 2&gt;&amp;4
how to get the selected date in jquery This question pertains to L1 &amp; L2 regularization parameters in Light GBM. As per official documentation:  reg_alpha (float, optional (default=0.)) – L1 regularization term on weights.  reg_lambda (float, optional (default=0.)) – L2 regularization term on weights  I have seen data scientists using both of these parameters at the same time, ideally either you use L1 or L2 not both together.   While reading about tuning LGBM parameters I cam across one such case: Kaggle official GBDT Specification and Optimization Workshop in Paris where Instructors are ML experts. And these experts have used positive values of both L1 &amp; L2 params in LGBM model. Link below (Ctrl+F 'search_spaces' to directly reach parameter grid in this long kernel)      I have seen same in XGBoost implementations.  My question is why use both at the same time in LGBM/XGBoost.  Thanks. Xubuntu 18.04 Persistent Live USB: Will persistence be carried upon full installation to a machine? I've created an Xubuntu 18.04 persistent live USB stick and installed several softwares for web development, such as XAMPP, Sublime Text 3, Google Chrome, etc.. I did some configurations as well in the ~/.bashrc file.  I am wondering if these installation and configuration in my persistent live USB stick be carried over in a full installation in to a new machine using it. How to select faces by area I found this documentation:   Under "Face Selection Mode" it says:     Face Selection Mode:      ...        Area   Selects all faces that have a similar area as those already selected.   But I can't figure out where in blender this option is hiding? Real-time updates for new review tasks How can I take screenshots of YouTube videos in full screen? I am trying to take a screenshot of a YouTube video in fullscreen.  When I pause the video and wait a moment, only the bottom UI bar (play/pause/seek) disappears. The top UI bar (Like/Share/More Info) stays there.  So when I press PrintScreen on the keyboard, the screenshot is polluted by this top UI bar. Is there any way to remove it while the video is on pause? Is there a good reason to use "printf" instead of "print" in java? Handling Calls to Remove a Moderator This discussion informed our process for seven years, but eventually required updates and augmentation. For discussion regarding the successors to this process, please see:    Stack Exchange has some of the best Moderators around — seriously — and that is due in no small part to the communities who scrutinize and vote in our Moderator elections.  We have a rather formal process for electing moderators, but up until now  has been quite informal. On those rare, rare occasion when things just aren't working out, you can see why it becomes such a sticky business to remove someone from a democratically elected position. Our current process is one of &quot;we've got your back.&quot; The Community Team routinely monitors moderator activities, so if a moderator violates the  or fails to uphold the , we can and do intervene. If the disputes and problems persist without resolution, eventually we can ask someone to step down. That's not good enough. We need a much more transparent and prescribed process for when — and more importantly how — to intervene when on-going problems are going unresolved. In urgent situations, we'll step in to protect a site, but ideally the process should be impartial and not subject to accusations of Stack Exchange simply applying undue influence over a community when the whim strikes. The Question: Before we start bouncing around ideas internally, I'd like to hear what you think. What process should be in place to add some checks and balances to deal with higher issues like possible impeachment of a moderator? When and how would such a process come into play? How should such situations be resolved? How do we keep it from being abused? Have at it. This is a round table vetting of ideas. recovering deleted file held open by apache? Suppose an apache log file gets deleted but it's held open by apache; then this is what I am doing:  pid=$(lsof | grep text.txt | awk '/deleted/ {print $2}') fd=$(lsof | grep text.txt | awk '/deleted/ {print $4}' | grep -oE "[[:digit:]]{1,}")  cp /proc/$pid/fd/$fd directorytobecopied/testfile.txt   This is what I am doing to recover the file and put it back where it was. Is there any simpler way of doing this because above code doesn't look good. Furthermore how do I know from where the file was deleted(directorytobecopied) so that I don't have to manually ask somebody where the file was located originialy and put it back there. According to the , you can harden a MySQL server by adding passwords, or removing the anonymous accounts.      If you want to prevent clients from connecting as anonymous users   without a password, you should either assign a password to each   anonymous account or else remove the accounts.   Before hardening, my users table looked like this.   mysql&gt; select user,host,password from mysql.user; +------------------+-----------+-------------------------------------------+ | user             | host      | password                                  | +------------------+-----------+-------------------------------------------+ | root             | localhost | *F3A2A51A9B0F2BE246XXXXXXXXXXXXXXXXXXXXXX | | root             | gitlab    |                                           | | root             | 127.0.0.1 |                                           | | root             | ::1       |                                           | |                  | localhost |                                           | |                  | gitlab    |                                           | | debian-sys-maint | localhost | *95C1BF709B26A5BAXXXXXXXXXXXXXXXXXXXXXXXX | | myuser           | localhost | *6C8989366EAF75BB6XXXXXXXXXXXXXXXXXXXXXXX | +------------------+-----------+-------------------------------------------+   I've remove all anonymous accounts, so that the user table now looks like this.  (I'm using puppet to manage the users, but puppet effectively performs a DROP USER command).   mysql&gt; select user,host,password from mysql.user; +------------------+-----------+-------------------------------------------+ | user             | host      | password                                  | +------------------+-----------+-------------------------------------------+ | root             | localhost | *F3A2A51A9B0F2BE246XXXXXXXXXXXXXXXXXXXXXX | | debian-sys-maint | localhost | *95C1BF709B26A5BAXXXXXXXXXXXXXXXXXXXXXXXX | | myuser           | localhost | *6C8989366EAF75BB6XXXXXXXXXXXXXXXXXXXXXXX | +------------------+-----------+-------------------------------------------+   Why is it that I am still able to login to my test system without a username or a password? What do I need to do to prevent any unwanted users from logging in?   root@gitlab:~# mysql Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 98 Server version: 5.5.32-0ubuntu0.12.04.1 (Ubuntu) .... mysql&gt;    Update:  I've also just discovered that I can login as root, without entering a password.  Update2: I found  which has some good information, but does not solve the issue.   There are no anonymous users.  mysql&gt; select user,host,password from mysql.user where user=''; Empty set (0.00 sec)   I login as root@localhost.  mysql&gt; select USER(),CURRENT_USER(); +----------------+----------------+ | USER()         | CURRENT_USER() | +----------------+----------------+ | root@localhost | root@localhost | +----------------+----------------+    I do not have a default password, or skip-grant-tables defined in my.cnf  root@gitlab:~# cat /etc/mysql/my.cnf |grep -i 'skip-grant-tables'|wc -l 0 root@gitlab:~# cat /etc/mysql/my.cnf |grep -i 'pass'|wc -l 0   Update3:  I have tried performing these steps with puppet, (which should perform a flush privileges automatically). I have also manually flushed privileges and also tried restarting mysql.   Update4: I've also tried changing the mysql root password and flushed privileges. No luck, I can still log in as any user without a password. Distance function is continuous in topology induced by the metric The question is (from Topology without tears) that: Let $(X,d)$ be a metric space and $\tau$ the corresponding topology on $X$. Fix $a \in X$. Prove that the map $f:(X,\tau) \rightarrow \mathbb{R}$ defined by $f(x) = d(a,x)$ is continuous.  My first attempt was that let an open ball, $B_{\epsilon}(a)\subset \mathbb{R}$ and show that $f^{-1}(B_{\epsilon}(a)) \subset \tau$. Since $f(x) = d(a,x)$, $f^{-1}(B_{\epsilon}(a))=B_{\epsilon}(a) \in \tau$.   I am pretty sure the last sentence is wrong. I am not sure if every open ball is an open set in topology induced by metric space.  Please give me some hint and direction. Thanks I'm using 3d to speed up production of 2d graphics of machines and structures (which have a lot of straight lines, objects and little details repeated all over the place).  The goal is to have an isometric background image that repeats seamless. I set the camera with orthographic projection and 45° of rotation.    And manually cut the vertical borders in an image editor in the position where it repeats. Then I can do something like this:    Instead of cutting it manually every time I do a test, I would like to set the camera view position and height from Blender. Then I can render an already seamless repeated image.  Those two Empty objects in the boundaries are where the camera borders should be. However I have no clue how to accurately set up the camera in this case. How can I do this? Make \cite{my reference} show name and year I am trying to figure out how to make author's name and year show up every time I make a reference.  For example:  my_bibtex.bib has this entry:  @article{Franklin1999,  author = {Franklin Allen and Risto Karjalainen}, title = {Using genetic algorithms to find technical trading rules}, year = {1999}, volume = {51}, pages = {245-271}, journal = {Journal of Financial Economics}  }   If in my_paper.tex I use this line:  Important result has been found by \cite{Franklin1999}   My output looks like:  Important result has been found by [1]   But I want it too look like:  Important result has been found by Franklin 1999   I there a way to do it?  My bibliographystyle is set to plain  \bibliographystyle{plain}  \bibliography{my_bibtex} Changing data type in ArcGIS attribute table? Why am I seeing two JPG files instead of RAW + JPG with a Canon 1100D? Why Are Ethernet/RJ45 Sockets Magnetically Coupled? As the title says really, why do ethernet sockets need to be mag-coupled? I have a basic understanding of electronics, but mostly, I can't figure out the right search terms to google this properly. What does the 'B' (or bonus) mean on a basketball scoreboard? I've got an HP Pavilion Touchsmart notebook that came with Windows 8. I've upgraded to 8.1, and now I want to dual-boot an Ubuntu distribution with Windows 10. When dual-booting with Windows 8.1, the Windows Boot Manager always took priority, even after installing GRUB. What do I need to do to get GRUB to be the default bootloader instead of Windows Boot Manager? I was wondering if anybody knew a command that would allow me to open a Nautilus (if that's the right name for the Ubuntu graphic/window explorer) window from the command line at the current directory that the user is at.  So, if I open a command line, and type:  cd /home/myUser/some/long/path/to/a/directory   Then, I'd like to be able to issue some command:  nautilus open-sesame   And have a graphic window opened to /home/myUser/some/long/path/to/a/directory. Is this even possible? I found the following proof arguing for the irrationality of $\sqrt{2}$.     Suppose for the sake of contradiction that $\sqrt{2}$ is rational, and choose the least integer $q &gt; 0$ such that $(\sqrt{2} - 1)q$ is a nonnegative integer. Let $q'::= (\sqrt{2} - 1)q$. Clearly $0 &lt; q' &lt; q$. But an easy computation shows that $(\sqrt{2} - 1)q'$ is a nonnegative integer, contradicting the minimality of $q$.   Clearly, this is a vague proof in that it expects the reader to work out the math involved on his own. I took that as an exercise and worked out the following:  Assuming $\sqrt{2}$ to be rational, let $$\sqrt{2} = \frac{p}{q}$$ where $p$ and $q$ are least possible integers.  Clearly then, $\sqrt{2} - 1$ would also be rational, $$\sqrt{2} - 1 = \frac{p-q}{q}$$ where both $(p-q)$ and $q$ are also integers.  Multiplying both sides by $q$, we get $$(\sqrt{2} - 1)q = (p-q) = q'$$ where $q'$ is an integer. Using, $2&gt;\sqrt{2} &gt; 1$ , we get $$1&gt;\sqrt{2}-1&gt;0$$ proving that $q'$ is a non-negative integer.  As stated in the proof, computing $(\sqrt{2}-1)q'$ we get, $$(\sqrt{2}-1)q' = \frac{(p-q)^2}{q}$$which is not necessarily an integer (in fact necessarily not an integer). However, the proof claims it to be.  Am I missing something or something is wrong with how I proceeded?  Here is a link to the textbook where I found this proof: , (p 32, problem 1.14).  P.S. This is my first post here and my first time with TeX. I'd also like to know if there is anything wrong with the way my question is presented.