Picking pages from PDF document - unix

How can you pick pages from a PDF file?
Pseudo-code synopsis
pick-pages 1,2-69,70-73,100 example.pdf > put_to_new_file.pdf

My best suggestion would be to try something with PDF toolkit - with Split and Merge, and a simple .bat file construction, something like that shouldn't be much hard.

ghostscript, somethign like
gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dFirstPage=3 -dLastPage=3 -sOutputFile=fileout.pdf filein.pdf

This is how I've done it with regular expressions. I counted the number of matches for the following regular expressions:
/Type\s*/Page[^s]
Case insensitive, by the way.

You're after pdftk.

Probably this is not a popular method, but this is one way. You can use pdflatex. For example, you can write a tex like:
\documentclass{book}\usepackage{pdfpages}\begin{document}
\includepdf[pages={1,2-10,11}]{pdf.pdf}\end{document}
You can write a small script to automize this.

As part of my CAM::PDF Perl library on CPAN, I bundle a command-line utility deletepdfpage.pl that does the inverse of what you are asking for, with almost the exact same syntax:
deletepdfpage.pl original.pdf 74-99,101- target.pdf

Related

shell function doesn't work in subfolder?

I have the following code that should open the Recode.xlsx inside the subf folder but doesn't
write_xlsx(mtcars, "subf/Recode.xlsx")
shell("subf/Recode.xlsx", wait=FALSE)
The following code works, so if anyone has an idea on why it doesn't work it would help me
write_xlsx(mtcars, "Recode.xlsx")
shell("Recode.xlsx", wait=FALSE)
Here’s what the documentation of the shell function says (emphasis mine):
shell is a more user-friendly wrapper for system. To make use of Windows file associations, use shell.exec.
And here is another bit of relevant information from the shell.exec documentation:
To be interpreted as relative, the path also needs to use backslashes as separators (at least in Windows 10).
So the following is the correct usage:
shell.exec("subf\\Recode.xlsx")

How to comment out chunk of code in Pact?

How do I comment out a chunk of code in Pact? Is there a shortcut in Atom for this?
I have tried command+? but it comments it out in HTML format.
This does however work in Pact Web (pact.kadena.io)
Pact is a Lisp-like language and so makes use of Lisp-style comments using semicolons (but not block comments). For example, if you wanted to comment out some pact code, you could do the following
(my-module 'my-keys
;(hello-world-old:string (name:string)
; ...)
(hello-world-new:string (name:string)
...)
)
You can make use of semicolons in really expressive ways, which are detailed in this great post here: Lisp commenting convention
Cheers, and happy hacking!

LESSC source maps not working

I'm running lessc as following:
lessc alice/public/local/less/intfarm.less > alice/public/local/css/local/compiled/intfarm.css --source-map=alice/public/local/less/intfarm.map --verbose
the source map is output but it doesn't work. I check the file and at the end I read:
...
,iBAAA;EACA,cAAA;;AA1EZ,IAAI,SA8EA;EACI,gBAAA","file":"../../../../undefined
do I need to set other flags as well?
(shoutout at LESS creators: why not enable this by default and save us hours of work and searching?)
You should not use the > between your source and destiny. In fact your send the output to stdout. The compiler don't know that you are writing the output to intfarm.css and so can not construct the source map link to that file.
Also see: https://github.com/less/less.js/pull/2389
another solution can be using --source-map-map-inline parameter instead of --source-map=... but I think the best solution is the one pointed by Bass Jobsen

Qt: Expand ~ to home-directory

Does Qt have any platform-independent functionality to accept paths like "~/myfile"?
I know about wordexp, but it would be nice with a platform-independent wrapper.
Edit:
Thank you all for the responses. "~/myfile" was just an example. What I am looking for is functionality to handle file-paths as you would be able to write on the command-line. So on Linux, it should accept "~/myfile", "~otheruser/hisfile", "$VAR/file" etc. On Windows, it should accept "%HOMEDIR%\myfile" etc.
You could probably just replace the tilde with the result of QDir::homePath()? Reference here.
I think that the absolutePath (http://doc.qt.io/qt-5/qdir.html#absolutePath) is the way to do it.

Include softlinked folders in unix "find"

How can I tell unix "find" to include in it's recursive search a folder which is softlinked?
-L . This causes it to follow all symbolic (I assume this is what you mean by soft) links.
Interesting - I hadn't come across '-L' (or the opposite, '-H') before. You can also use '-follow' to do the same job. It can be built into expressions (it always evaluates to true), so you might be able to be more subtle with it that using '-L'. However, I wouldn't worry about that subtlety too much - the '-L' is simpler.
find some more information about unix find command at
http://scripterworld.blogspot.com/2009/07/unix-find-command-with-examples-and.html

Resources