I need to have a validation function, boolean isFloat(String) , to check if a given string can be directly converted to an integer. There are at least two approaches on base of :   in plain Java:  isFloat(String f) {   if (strNum == null) {     return false;   }   try {     Float.parseFloat(strNum);   } catch (NumberFormatException nfe) {     return false;   }   return true; }  in regular expression, hereby I don't list the code   The first approach is more strict forward and easy to understand, whereas one of my colleagues said throwing exception might the whole stack trace, which might affect performance when happening frequently. The second approach might be error-prone as we always need to think about how the expression is formed.  Question: Is the impract of throwing and catching the whole stack trace of an exception really that big?
Question:  Is exception handling in Java actually slow?  Conventional wisdom, as well as a lot of Google results, says that exceptional logic shouldn't be used for normal program flow in Java.  Two reasons are usually given,   it is really slow - even an order of magnitude slower than regular code (the reasons given vary),     and    it is messy because people expect only errors to be handled in exceptional code.     This question is about #1.  As an example,  describes Java exception handling as "very slow" and relates the slowness to the creation of the exception message string - "this string is then used in creating the exception object that is thrown. This is not fast."  The article  says that "the reason for this is due to the object creation aspect of exception handling, which thereby makes throwing exceptions inherently slow".  Another reason out there is that the stack trace generation is what slows it down.  My testing (using Java 1.6.0_07, Java HotSpot 10.0, on 32 bit Linux), indicates that exception handling is no slower than regular code.  I tried running a method in a loop that executes some code.  At the end of the method, I use a boolean to indicate whether to return or throw.  This way the actual processing is the same. I tried running the methods in different orders and averaging my test times, thinking it may have been the JVM warming up.  In all my tests, the throw was at least as fast as the return, if not faster (up to 3.1% faster).  I am completely open to the possibility that my tests were wrong, but I haven't seen anything out there in the way of the code sample, test comparisons, or results in the last year or two that show exception handling in Java to actually be slow.  What leads me down this path was an API I needed to use that threw exceptions as part of normal control logic.  I wanted to correct them in their usage, but now I may not be able to.  Will I instead have to praise them on their forward thinking?  In the paper , the authors suggest that the presence of exception handlers alone, even if no exceptions are thrown, is enough to prevent the JIT compiler from optimizing the code properly, thus slowing it down.  I haven't tested this theory yet.
I've recently searched how I could get the application's directory in Java. I've finally found the answer but I've needed surprisingly long because searching for such a generic term isn't easy. I think it would be a good idea to compile a list of how to achieve this in multiple languages.  Feel free to up/downvote if you (don't) like the idea and please contribute if you like it.  Clarification:  There's a fine distinction between the directory that contains the executable file and the current working directory (given by pwd under Unix). I was originally interested in the former but feel free to post methods for determining the latter as well (clarifying which one you mean). Why don't we feel the subtle speed change of Earth's elliptical orbit? Earth's orbit is a slight ellipse, so to conserve momentum its speed increases when it is closest to the Sun. If the speed changes there is an acceleration. If there is an acceleration there is a force. Even if the change is small and gradual, wouldn't we experience a force because the Earth is so massive? Apache error "Could not reliably determine the server's fully qualified domain name" When I restart my Apache server using the command  sudo /etc/init.d/apache2 restart   I get the following error:  Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName   Is the server using 127.0.1.1 instead of 127.0.0.1? What causes this error? I'm on a Toshiba Satellite C660_EL trying to install .   lspci -v Network controller: Realtek Semiconductor Co., Ltd. RTL8188CE 802.11b/g/n WiFi Adapter (rev 01)   However, I can't get the driver from there to compile (I've installed build-essentials already). Running make (with or without sudo makes no difference) I get  make -C /lib/modules/3.8.0-19-generic/build M=/root/rtl_driver modules make[1]: Entering directory `/usr/src/linux-headers-3.8.0-19-generic'   CC [M]  /root/rtl_driver/base.o In file included from /root/rtl_driver/base.c:39:0: /root/rtl_driver/pci.h:247:15: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘rtl_pci_probe’ make[2]: *** [/root/rtl_driver/base.o] Error 1 make[1]: *** [_module_/root/rtl_driver] Error 2 make[1]: Leaving directory `/usr/src/linux-headers-3.8.0-19-generic' make: *** [all] Error 2   There is a relevant PPA here:  but there's no 13.04 build.   Thanks in advance for any help! What is a good data plan for Internet surfing in northern Italy? I've checked the webpages of some their providers, but franly, just like in the case of those in my own language, I literally cannot find my way around them. So if you wouldn't mind sharing a word of two or advice.  I'm looking for a good solution for mobile internet surfing in northern Italy, that can be connected to a laptop (you know, that usb stick with a SIM card inside kind of thing). 15 Gb or so at some decent speed. Can you perhaps give a recommendation or two of what to get?    Edit: Just to define what I'm looking for exactly. A data plan of 15 Gb with an internet key (usb stick into which a SMS card goes) that you plug into a laptop. Preferably non-contractual, so I can cancel when I leave. I am not interested in surfing on my mobile phone since due to size I still prefer the smaller Nokia-like models for calls (smaller to carry) - no internet on them. TV series with pull out phone screens and pink/purple space ships I’m looking for a TV show where an alien race comes to Earth and sets up big purple/pink cylindrical or cone shaped spaceships in various cities around the world. The Aliens are not hostile but actually created peace and eliminated hunger on Earth.    I believe the aliens had some human features and were wise and calm the main actor had a phone with a pull out screen I believe the main actor worked for or with the aliens I believe that in the last episode some humans and aliens go into some kind of pods and perhaps leave Earth? one of the space ships was located in a major US city. Maybe Washington DC or another East Coast city   Could someone please tell me what TV series this is? I have been searching everywhere and cannot find it. Thanks! In the  there are lots of numbers on display, including 1000, 2500 or 10000. The display is erratic though:    Same number, two displays. Both appear valid to me: 1000 or 1,000 but please, make it consistent. My eyes hurt! :) I just found , but there it's discussing the whole network while I'm asking just for that specific page. For a start. How did Anakin Skywalker survive Order Sixty Six? . When activated, troopers would immediately perceive Jedi as a threat and kill them.  Since Anakin was a Jedi until around the time of the Order, how did the troopers know not to kill Anakin? How large is it possible for a PC to get?  For clarity, here are my parameters:   This is about size categories, not 'feet' or 'inches' or 'meters' or any other precise measurement. This is about Medium to Large to Huge to Gargantuan categories.  This is for an NPC charlatan using this to trick people. (It's an NPC but will have a full PC sheet, so the distinction between PC and NPC doesn't matter). Any means of size category enlargement works for this purpose, including magic spells, magic items, etc. Illusions do not count because it's about actually becoming larger, not just casting an illusion of a gargantuan giant version of yourself.  The character must remain the same physical structure. Polymorphing into a Gargantuan Dragon would not satisfy the need here. Consumable items are fine. This does not need to be permanent. Use filecontents environment to write a binary file In  of mine, I was trying to show how to embed an audio file into the pdf with the multimedia package. The resulting MWE does not stand on its own because it requires an example audio file.  I guess my first question is, does TeXLive include any example audio files? The second, and potentially less uninteresting question is, can I use the filecontents environment, or some other environment, to create a binary file?  \documentclass{article} \usepackage{graphicx} \usepackage[implicit=false]{hyperref} \usepackage{multimedia}  % What goes in here to produce a usable wav file. Happy to use a different environment. \begin{filecontents}{\jobname.wav} \end{filecontents}  \begin{document} \sound[inlinesound]{\includegraphics{example-image}}{\jobname.wav} \end{document} Volumes of n-balls: what is so special about n=5? The volume of an $n$-dimensional ball of radius $1$ is given by the classical formula $$V_n=\frac{\pi^{n/2}}{\Gamma(n/2+1)}.$$  For small values of $n$, we have $$V_1=2\qquad$$ $$V_2\approx 3.14$$ $$V_3\approx 4.18$$ $$V_4\approx 4.93$$ $$V_5\approx 5.26$$  $$V_6\approx 5.16$$ $$V_7\approx 4.72$$ It is not difficult to prove that $V_n$ assumes its maximal value when $n=5$.   Question. Is there any non-analytic (i.e. geometric, probabilistic, combinatorial...) demonstration of this fact? What is so special about $n=5$? I also have a similar question concerning the $n$-dimensional volume $S_n$ ("surface area") of a unit $n$-sphere. Why is the maximum of $S_n$ attained at $n=7$ from a geometric point of view?   note: the question has also been  for those curious to other answers. I would like to use Zapf's Palatino font for the text in my document, which also includes a lot of maths. And I would like a good font for the maths. This is a snapshot of what I am doing.  \documentclass[10pt,letterpaper]{memoir} \usepackage{amsmath} \usepackage{amssymb} \usepackage{mathpple} \usepackage{upgreek} \usepackage{mathpazo} \usepackage{lipsum}  \begin{document}  \chapter{Demo}  Some regular text. \lipsum[1]  Now for some maths.  \begin{displaymath} P_{N-1 + m} = \frac{C}{N-{1} + m} \binom{N_{2} - N_{1}}{m}         \alpha^{m}\beta^{(N_{2} - N_{1}) -m} \end{displaymath}  The number 27 is the sum of the first 5 odd prime numbers: $27 = 1+3+5+7+11$  \end{document}   To me the text and math fonts seem a good fit but the text does not look like Palatino. AWS dynamodb support for "R" programming language Ampscript date range lookup I want to use LookupOrderedRows and return rows between a start and end date (last month range). What is the best way to handle using Ampscript?   I can add one date to the where using   "DateField", @varStartDate,   But if I add the below to add additional where filters  "DateField", @varStartDate,"DateField", @varEndDate,   I get this error:     "Duplicate Key Field Name: DateField"   EDIT: Also I tried the range as the var for the LookupOrderedRows using   set @strRange = StringToDate(Format(DateDiff(@strStartDate, @strEndDate, "M"),"MM/dd/yyyy"))  and then in the LookupOrderedRows just using  "DateField", @strRange  But that got an error as well. Converting *.tif file into headerless (flat) binary file? I am using NDVI files (value range -1 to +1) created from Landsat CDR images to produce a timeseries in TIMESAT software.   My  .tif file has following characteristics.  File type  TIFF,Data Type  Double Precision, Byte Order Host (Intel), Interleave BSQ  As per the requirement of TIMESAT, the image should be headerless(flat) binary file, and values can be stored as 8 bit integer(0-255), 16 bit signed integer(-32767 to +32768) or 32 bit real.   Now i need to change my data type into any of these 3 format and .tif file into headerless binary files.   Any idea? After booting I ran systemd-analyze blame and here are the results:       21.596s systemd-journal-flush.service      18.658s dev-sda8.device      15.099s dev-loop33.device      15.034s dev-loop19.device      15.012s dev-loop34.device      14.989s dev-loop21.device      14.877s dev-loop15.device      14.866s dev-loop26.device      14.773s dev-loop27.device      14.684s dev-loop30.device      14.677s dev-loop32.device      14.649s dev-loop35.device      14.590s dev-loop25.device      14.267s dev-loop23.device      14.192s dev-loop24.device      14.156s dev-loop29.device      14.133s dev-loop16.device      14.065s dev-loop31.device      14.059s dev-loop28.device      13.821s dev-loop20.device      13.531s dev-loop22.device      13.495s dev-loop14.device      13.364s dev-loop18.device   What are these dev-loopxx.device (xx denotes numbers) services and why are they taking so much time? Are they related to the mounting of snaps? Can I reduce the boot time by disabling them? I'm running Ubuntu 18.04 alongside Windows 10. Beamer Presentation: Figure has no number? I am giving a presentation and therefore I am using the  class. I have included some figures and it works, but there is no number after "Figure".  My code:  \documentclass{beamer}  \usepackage{graphicx} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} \usepackage[english]{babel} \usepackage{listings} \usepackage{xcolor} \usepackage{eso-pic} \usepackage{mathrsfs} \usepackage{url} \usepackage{amssymb} \usepackage{amsmath} \usepackage{multirow} \usepackage{hyperref} \usepackage{booktabs} \usepackage{wallpaper} \usepackage{bbm} \usepackage{cooltooltips} \usepackage{eso-pic} \usepackage{everyshi} \usepackage{calc} \usepackage{graphicx} \usepackage{ifthen} \usepackage{graphicx} \usepackage{wrapfig} \usepackage{animate} \usepackage[singlespacing]{setspace} \usepackage[absolute,overlay]{textpos} \usepackage{enumerate} \usepackage{hyperref} \newenvironment{changemargin}[2]{%   \begin{list}{}{%     \setlength{\topsep}{0pt}%     \setlength{\leftmargin}{#1}%     \setlength{\rightmargin}{#2}%     \setlength{\listparindent}{\parindent}%     \setlength{\itemindent}{\parindent}%     \setlength{\parsep}{\parskip}%   }%   \item[]}{\end{list}}  \setbeamercolor{frametitle}{fg=red,bg=white}  \hypersetup{pdfpagemode=FullScreen} \renewcommand*{\UrlFont}{\normalfont}  \usetheme{Goettingen} \useinnertheme{circles} \beamertemplatenavigationsymbolsempty  \setbeamerfont{page number in head/foot}{size=\large} \setbeamertemplate{footline}[frame number]   %%% \begin{document}  \frame[plain]{ \titlepage }  \setbeamertemplate{background canvas}[default]  \frame{ \frametitle{}  \begin{figure} \begin{center} \includegraphics[scale=0.2]{varweakness} \caption{VaR as a quantile} \end{center} \end{figure}  }   \end{document}   Which gives the following frame with the figure:    (I am not sure what is causing the problem, therefore I did not delete any package.)  How can I get a number, e.g. Figure 1:? Why aren't bounties refunded if they are not awarded? I really tried hard to do this on my own, but I keep failing ... Using multi-column and multi-row commands confused me. I know some of you might frown upon such a request but I really need help getting this table implemented .. So I'm sorry if I upset anyone.  My preamble has :   \documentclass[12pt,a4paper]{report} \usepackage[lmargin=3.81cm,tmargin=2.54cm,rmargin=2.54cm,bmargin=2.52cm]{geometry} \linespread{1.5}     Is there a way I can convert this from excel to LaTeX form ? I tried an add-in before but it didn't work for me. Also online generators cannot combine cells the way I want them (unless I didn't find a better table generator ? ) Run apt-get without sudo