This seems pretty silly, but I haven't found a tool that does this, so I figured I'd ask just to make sure one doesn't exist before trying to code it up myself:  Is there any easy way to cat or less specific lines of a file?  I'm hoping for behavior like this:  # -s == start &amp;&amp; -f == finish # we want to print lines 5 - 10 of file.txt cat -s 5 -f 10 file.txt   Even something a little simpler would be appreciated, but I just don't know of any tool that does this:  # print from line 10 to the end of the file cat -s 10 file.txt   I'm thinking that both of these functionalities could be easily created with a mixture of head, tail, and wc -l, but maybe there are builtins that do this of which I'm unaware?
I have a ~23000 line SQL dump containing several databases worth of data. I need to extract a certain section of this file (i.e. the data for a single database) and place it in a new file. I know both the start and end line numbers of the data that I want.  Does anyone know a Unix command (or series of commands) to extract all lines from a file between say line 16224 and 16482 and then redirect them into a new file?
Variance of dot product When reading a proof I came across the following step:  $$\operatorname{Var}(x^Ty) = x^T\operatorname{Var}(y)x$$ $x$ and $y$ are column vectors. How can you derive this? WinError 32 error when trying to delete shapefiles with QGIS python Proof a $2^n$ by $2^n$ board can be filled using L shaped trominoes and 1 monomino Force pagebreak after every sentence/paragraph Is there a way to force a pagebreak after every sentence or paragraph?  This may seem like an odd thing to do, but for catching typos and just general editing I find it much easier to look at a sentence or paragraph in isolation so that I am not tempted to skip ahead.  Currently, I just zoom in so I can only see a few word at a time, but this is not a perfect solution. parsing XML file gets UnicodeEncodeError (ElementTree) / ValueError (lxml) If I have a 18-55mm lens, is there a point in buying a 35mm prime lens? How to switch from Resident visa to Tourist visa status in the Schengen area? I have a 1-year residence permit from one Schengen country that is now expiring. Upon its expiration, I would like to get my 90/180 days validity as a tourist to stay, or return here as soon as possible.  I understand that the tourist short-stay scheme is based on the 90/180 days "counter". But what happens if my previous stay was not tourism but residence (as searching year). Wouldn't that mean that I can quickly exit and re-enter the Schengen area to activate my tourist stay?   Also, is there a way to change this purpose of stay without exiting the Schengen area? What security systems and processes are in place to prevent malicious third parties from hacking/compromising the security of code in the Debian mirrors, or to verify that the packages we get are in fact the ones the maintainers think they are? Canonical Post #2: What is the perfect, and how should I use it? In X-Men Origins: Wolverine,      Wolverine is shot through the head with what appears to be a vibranium bullet by William Stryker. He remarks that the brain will grow back but the memories won't.   So the projectile penetrated the adamantium skull and damaged the brain. Adamantium is an inorganic substance. It will survive anything that would otherwise destroy the rest of Wolverine's body. But if anything (such as vibranium) manages to damage the adamantium, it is not covered by Wolverine's healing abilities.  Does this mean that Wolverine has an Achilles' heel on his forehead? If so, how did he take a bullet to the exact same spot in X-Men: United (at Ice Man's home)? PyQGIS couldn't import processing with standalone script I have read post on that problem (). The problem is even with a sys.path.append it couldn't import processing. It's very frustrated. Here the code I used:  #!/usr/bin/python  def main():     layer = QgsVectorLayer('/path/to/file.shp', "BAT","ogr")     QgsMapLayerRegistry.instance().addMapLayers([layer])      # Testing processing     try :         Processing.runalg("qgis:creategrid")     except:         print "Processing module has not been loaded"      #Check the QgsMapLayerRegistry for the layers     print QgsMapLayerRegistry.instance().mapLayers()     # Check if they are valid     print layer.isValid()  if __name__=="__main__":     import sys     from PyQt4.QtGui import *     from qgis.core import *     app = QApplication([])     QgsApplication.setPrefixPath("/usr", True)     QgsApplication.initQgis()      sys.path.append('home/qsuser/.qgis2/python/plugins')      # try to load processing     try:         from processing.core.Processing import Processing         Processing.initialize()      except:         print "unable to load processing"      main()      QgsApplication.exitQgis()   I could load QGIS and layer is valid that's ok, but processing resist to me. I am on Ubuntu 14.04 I use Pycharm to do it.  I tried on terminal with the python console, it raised this error:  Traceback (most recent call last):   File "&lt;stdin&gt;", line 1, in &lt;module&gt;   File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 572, in _import     mod = _builtin_import(name, globals, locals, fromlist, level)   File "/home/qsuser/.qgis2/python/plugins/processing/__init__.py", line 28, in &lt;module&gt;     from processing.tools.dataobjects import *   File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 572, in _import     mod = _builtin_import(name, globals, locals, fromlist, level)   File "/home/qsuser/.qgis2/python/plugins/processing/tools/dataobjects.py", line 35, in &lt;module&gt;     from processing.core.ProcessingConfig import ProcessingConfig   File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 572, in _import     mod = _builtin_import(name, globals, locals, fromlist, level)   File "/home/qsuser/.qgis2/python/plugins/processing/core/ProcessingConfig.py", line 30, in &lt;module&gt;     from PyQt4.QtCore import QPyNullVariant, QCoreApplication, QSettings ImportError: cannot import name QPyNullVariant   I don't know what I am missing.   Settings :  Qgis 2.12.1-Lyon Ubuntu 14.04 Trusty IDE : Pycharm 5 community Processing : 2.12.2   -- Edit -- And with the changes suggest by mathias kuhn  #!/usr/bin/python  def main():     layer = QgsVectorLayer('/path/to/file.shp', "BAT","ogr")     QgsMapLayerRegistry.instance().addMapLayers([layer])      # Testing processing     try :         Processing.runalg("qgis:creategrid")     except:         print "Processing module has not been loaded"      #Check the QgsMapLayerRegistry for the layers     print QgsMapLayerRegistry.instance().mapLayers()     # Check if they are valid     print layer.isValid()  if __name__=="__main__":     import sys     from qgis.core import *             from PyQt4.QtGui import *     app = QApplication([])     QgsApplication.setPrefixPath("/usr", True)     QgsApplication.initQgis()      sys.path.append('home/user/.qgis2/python/plugins')      # try to load processing     try:         from processing.core.Processing import Processing         Processing.initialize()      except:         print "unable to load processing"      main()      QgsApplication.exitQgis() How do I test a private function or a class that has private methods, fields or inner classes? How do I unit test (using xUnit) a class that has internal private methods, fields or nested classes? Or a function that is made private by having  (static in C/C++) or is in a private () namespace?  It seems bad to change the access modifier for a method or function just to be able to run a test. How do I complete the square from the point I have left off at, and is this correct so far?   I have a normal prior for $\beta$ of the form $p(\beta|\sigma^2)\sim \mathcal{N}(0,\sigma^2V)$, to get:  $p(\beta|\sigma^2)=(2\pi\sigma^2V)^\frac{p}{2}\exp[-\frac{1}{2\sigma^2}\beta^T\beta]$  where $\beta^T\beta$ is   $\sum\limits_{i=1}^p \beta_i^2$.  My likelihood has a normal distribtuion for the data points y of the form $p(y|\beta,\sigma^2)\sim\mathcal{N}(B\beta,\sigma^2I)  $  $p(y|\beta,\sigma^2)=(2\pi \sigma^2V)^\frac{n}{2}\exp[-\frac{1}{2\sigma^2}({\bf y}-{\bf B}{\bf \beta})^T({\bf y}-{\bf B}{\bf \beta})]$  (Note that $\beta$ is a matrix/vector too, \bf does not work.)  To get my posterior for $\beta$ I combined the above, took the exponential parts only, and then expanded to get:  $\exp[-\frac{1}{2\sigma^2}({\bf y}^T{\bf y}-{\bf y}^T{\bf B}\beta-\beta{\bf B}^T{\bf y}-\beta^T{\bf B}^T{\bf B}\beta)]\exp[-\frac{1}{2\sigma^2}({\bf \beta}^T{\bf B})]$.  I dropped the $({\bf y}^T{\bf y})$ term, as is not a function of $\beta$.  Putting into one expression without the exponential:  $-\frac{1}{2\sigma^2}(-{\bf y}^T{\bf B}\beta-\beta{\bf B}^T{\bf y}-\beta^T{\bf B}^T{\bf B}\beta+{\bf \beta}^T{\bf B})$.  I know I need to combine the similar terms and get into the form of the multivariate normal distribution, which is what I am aiming for, but I am unsure how to do this? I probably have to add an extra term to the expression to get it into the correct form?  Note: This is not homework, it's a project, but my Bayesian working knowledge is not good at all and so I need to understand the working out. I intend to integrate out the $\beta$ and then the $\sigma^2$ after getting into the multivariate form. I don't know what to do with this. Nothing works. I hope somebody can help me to find a decision $$n!\leq {\left(\frac{n+1}{2}\right)}^{n}$$ How is the popularity of "recent tags" calculated? How are these calculated? I see them going up and down all the time, and there are obviously way more than 48 questions about C# so how are these calculated? I consistently have more than one terminal open. Anywhere from two to ten, doing various bits and bobs. Now let's say I restart and open up another set of terminals. Some remember certain things, some forget.  I want a history that:   Remembers everything from every terminal Is instantly accessible from every terminal (eg if I ls in one, switch to another already-running terminal and then press up, ls shows up) Doesn't forget command if there are spaces at the front of the command.   Anything I can do to make bash work more like that? "would rather" + subject + past subjunctive What is the difference between:   The company would rather each employee be provided with ID card.  The company would rather each employee were provided with ID card. How do we "restore" notepad after crash? How to handle a native OS (Ubuntu) file upload window in selenium webdriver with python? This is my first time here but I have already posted this question on SO. I keep getting solutions for Windows + Java and not for Linux or python for that matter.  I am using Selenium and Python to automate a file upload application for the past many hours but nothing helpful!   The HTML DOM structure for this file upload is an input tag with its type attribute value = 'file'. I know I can make use of the send_keys.   The problem is I am not supposed to use send_keys() (as per the question I am trying to solve). The assumption is there are other ways of doing it.  Can anyone suggest me alternative ways to upload the file? I do get solutions for windows but not for Linux(Ubuntu). I know there are applications/tools to automate GUI components like AutoIt but there is nothing for Linux close to AutoIt.  I can say I have done my homework to find a solution. Only after not finding anything useful, I am asking this question, please help! which statistic should I use for inter-rater agreement on nominal data, multiple responses I have over 400 open-ended responses. The total has been coded by one rater, and a 10% identical sample of the total has been coded by 2 raters. There is a choice of 14 nominal codes, of which the rater can use any number per case, though most cases have between 1-4 codes. Which statistical test is the most appropriate to determine if I have inter-rater agreement on the 10% sample?   Also am I right in assuming that I will need to treat each code as a variable and look for the level of agreement for each variable?   I'm using SPSS 21.  Much thanks, Kellie