Is there a cleaner way of getting the last day of the previous month?   Also, is the Date.addMonth() function smart enough to deal with months having different numbers of days? As in, if I subtract 1 month from October 31st, do I get Sept 31st or Sept 30th?   //Get Last Day or previous month. Date LastMonth = date.today().addmonths(-1); Date FirstOfLastMonth = date.newInstance(Lastmonth.year(), lastmonth.month(), 1); Integer numberOfDays = Date.daysInMonth(FirstOfLastMonth.year(), FirstOfLastMonth.month()); Date LastDayOfLastMonth = Date.newInstance(FirstOfLastMonth.year(), FirstOfLastMonth.month(), numberOfDays);
Is there a function or method to give the last day of a month? For example if the date is 27 feb 2013, the last date should be 28 feb 2013 , it become 29 if its a leap year. if the date was 2 jan then it should return 31 Jan.  If there is no function then any ideas on how we can get this?  Thanks
I've installed emacsformacosx on my OSX box.  I'd like to shove my macmini in a data center and run it headless.  I've gotten x-windows working.  If I run xeyes, it displays on my Windows 7 client.  Emacs works from the command line on the osx box.  However, if I start up emacs from the windows client, it pops it up on the server instead of the client.  What am I doing wrong? Frequentism and priors Robby McKilliam says in a comment to  post:     It should be pointed out that, from the frequentists point of view, there is no reason that you can't incorporate the prior knowledge into the model. In this sense, the frequentist view is simpler, you only have a model and some data. There is no need to separate the prior information from the model   Also, , @jbowman says that frequentists use regularization by a cost/penalty function, while bayesians can make this a prior:     Frequentists realized that regularization was good, and use it quite commonly these days - and Bayesian priors can be easily interpreted as regularization.   So, my question is, can frequentists in general incorporate into their models what Bayesians specify as priors? Taking the regularization as an example, is the cost/penalty function really integrated into the model, or is this a purely artificial means of adjusting the solution (as well as making it unique)? Is it possible to redirect connections to a specific IP/port to an external IP/port?  Example:   Server A has the external IP xxx.xxx.xxx.xxx Server B has the external IP yyy.yyy.yyy.yyy User sends a request to server A on port 2106, I want to redirect it to server B at port 2106. How to remove top and bottom whitespace of longtable? I am using longtable instead of tabular environment and noticed that it puts some additional whitespace at the top and at the bottom of the table. Is there some way to remove it (something less hacky than \vskip -\baselineskip before the table)?  Small piece of code for illustration:  \documentclass[12pt]{book} \usepackage{longtable}  \begin{document}  Linelineline  \begin{longtable}{l l} cell1 &amp; cell2 \end{longtable}  Linelineline  \begin{tabular}{l l} cell1 &amp; cell2 \end{tabular}  Linelineline  \end{document}   And that's what I am getting:    Common tabular environment does not have any additional margins, but longtable does. Prove that $A\ge0, B\ge0$ and $A\ge B$ implies $B^{-1}\ge A^{-1}$ Does anyone know how to prove the following:       Suppose $A$ and $B$ are both positive definite and $A - B$ is positive semi-definite.   Show that $B^{-1} - A^{-1}$ is also positive semi-definite.    I really appreciate any comments! The energy stored in a capacitor is $$ U= \dfrac{1}{2} CV^2 $$    So when I have a 1F supercap charged to 1V the energy is 0.5 J. When I connect a second supercap, also 1F in parallel the charge will distribute and the voltage will halve. Then    $$ U = \dfrac{1}{2} 2F (0.5V)^2 = 0.25 J $$  What happened to the other 0.25 J? When is "self" required? I have been using classes for only a short while and when I write a method, I make all variables reference self, e.g. self.foo.  However, I'm looking through the wxPython in Action book and notice that "self" isn't used all the time. For example:   import wx  class TextFrame(wx.Frame):     def __init__(self):         wx.Frame.__init__(self, None, -1, 'Text Entry Example',             size=(300, 100))         panel = wx.Panel(self, -1)         basicLabel = wx.StaticText(panel, -1, "Basic Control:")         basicText = wx.TextCtrl(panel, -1, "I've entered some text!",             size=(175, -1))         basicText.SetInsertionPoint(0)         pwdLabel = wx.StaticText(panel, -1, "Password:")         pwdText = wx.TextCtrl(panel, -1, "password", size=(175, -1),             style=wx.TE_PASSWORD)         sizer = wx.FlexGridSizer(cols=2, hgap=6, vgap=6)         sizer.AddMany([basicLabel, basicText, pwdLabel, pwdText])         panel.SetSizer(sizer)   The one below does use "self".  import wx class ButtonFrame(wx.Frame):     def __init__(self):         wx.Frame.__init__(self, None, -1, 'Button Example',             size=(300, 100))         panel = wx.Panel(self, -1)         self.button = wx.Button(panel, -1, "Hello", pos=(50, 20))         self.Bind(wx.EVT_BUTTON, self.OnClick, self.button)         self.button.SetDefault()     def OnClick(self, event):         self.button.SetLabel("Clicked")   If I remember correctly, "self" is reference to a particular instance of the class, so when is it not necessary? Is there a general rule of thumb? Calculations in quotient rings Why is there a peeking duck in my profile pic? In , you may see something odd: a peeking duck.    I've just recently uploaded this new profile picture of mine. I checked it after the upload and everything's fine. After a few hours, I opened my profile and there it is, the duck has somehow become afraid of the people viewing it.  Is this a bug, a feature, or is it just the duck?  I am about to re-upload my profile pic, but I've decided to drop first this topic to meta.  And if you're curious,  is the original picture.    ADDITIONAL: I've used the non-gravatar way to upload the picture.  ADDITIONAL 2: The problem only shows in the profile view. No problem in chat, less info profile view, and in the questions and answers.  UPDATE: Re-uploaded picture. Status normal (for now, at least). How to store and preserve lots of data? I have many DVDs with movies and games, they are getting old and dusty, some of them are damaged. And I have more than 300 GB of general files in my PC. I want to store and preserve all of my data and keep them for a long long time.  I want to know what is the best and more reliable storage media that I should use and... I can buy. I will copy all of my DVDs to a new media and throw all of my DVDs away. It will take a very smaller physical space.  I think that everything that I need to store is currently 800 GB.  I do not like optical discs, because they are fragile and I have lost many CDs and DVDs. Hard drives would be good, but they can suddenly stop working, and it is very expensive to recover data from a broken hard drive.  Other questions: How often will I have to copy the files to a new storage media? Is it good idea to have another copy of each file stored in another storage media?  Edit: If I put all of the movies and games in a HDD, if the HDD stops working, I will lose everything. This is how valuable they are for me: If I lose 10% of them, I will not cry, because I can get new ones, but if I lose 90%, it will be a disaster.  Edit 2: I do not think that that online storage is reliable even if I pay for it, because they may be closed or may get bankrupt. They are not from my country and it would be difficult to get the files back. Prove recursively defined sequence converges I would like some advice on how to solve problems like the following: Let $(x_n)$ be a sequence defined by $x_1= 3$ and $x_{n+1} = \frac{1}{4-x_n}$. Prove that the sequence converges.  My strategy is to use the Monotone Convergence Theorem, but I am having trouble showing that the sequence is decreasing and bounded below. Here's my work so far:  Decreasing: The first 4 values are $3,1,1/3,3/11$, so let's assume $x_n \leq x_{n-1} \leq \ldots \leq x_1$. Want to show $x_{n+1} \leq x_n$. We have $x_{n+1} = \frac{1}{4-x_n}$. I want to have an upper bound for the RHS, but can't find one and don't really know where to go from here.  Bounded below: I wanted to show that all values are positive, but if we assume $x_n &gt; 0$, that doesn't rule out $x_{n+1}$ from being negative. Which one of these two statements is correct?     Our staff do ...      Our staff does ...   And is staffs ever correct? "Least Astonishment" and the Mutable Default Argument Selenium 2: Open link in new tab and close tabs How can I accept the Microsoft EULA agreement for ttf-mscorefonts-installer? After a recent update, ttf-mscorefonts-installer prompted me to accept its license agreement.     ┌─────────────────┤ Configuring ttf-mscorefonts-installer ├─────────────────┐  │                                                                           │   │ TrueType core fonts for the Web EULA                                          │                                                                               │ END-USER LICENSE AGREEMENT FOR MICROSOFT SOFTWARE                             │                                                                               │ IMPORTANT-READ CAREFULLY: This Microsoft End-User License Agreement           │ ("EULA") is a legal agreement between you (either an individual or a          │ single entity) and Microsoft Corporation for the Microsoft software           │ accompanying this EULA, which includes computer software and may include      │ associated media, printed materials, and "on-line" or electronic              │ documentation ("SOFTWARE PRODUCT" or "SOFTWARE"). By exercising your          │ rights to make and use copies of the SOFTWARE PRODUCT, you agree to be        │ bound by the terms of this EULA. If you do not agree to the terms of          │ this EULA, you may not use the SOFTWARE PRODUCT.                              │                                                                               │                                  &lt;Ok&gt;                                         │                                                                           │   └───────────────────────────────────────────────────────────────────────────┘    Screenshot:   For some reason my terminal will not allow me to accept, or for some reason I am pressing the wrong hotkey...  I've tried every letter on the keyboard and Enter among others...  I'm sure there is a very simple and obvious solution to this.  I've also just tried to remove the package completely however the terminal states that due to the package not being correctly installed, I should reinstall the package before removing it.  Very frustrating!  Essentially, because I cannot successfully install this package, I can't really ever upgrade my system because I always have to end up terminating the terminal with the license agreement (thus the upgrade fails). Python scope: "UnboundLocalError: local variable 'c' referenced before assignment" I am trying to figure out this:  c = 1 def f(n):     print c + n  def g(n):     c = c + n  f(1) # =&gt; 2 g(1) # =&gt; UnboundLocalError: local variable 'c' referenced before assignment   Thanks! How to force a node group input field to display a slider? I have created a couple of node groups with some "group-inputs-sliders" (The one called "Roughness" in the bottom picture). I would like it to have the blue-bar slider like the blender native ones. Thanks (: Is there a gender-neutral pronoun that can replace “his” or “her”? Is there a 'biblatex in a nutshell' guide out there? I'd like if someone explained to me the essentials on how to use biblatex (what lines I have to write in my document, which files I have to have, how many times and what I have to compile), so then I can go to  to customise it further. How can you draw more detailed/smoother images in pygame?