Converting all .haml files in a dir to .html in another dir - haml

In a simple website I'm working on, I have a directory haml and a directory pages. The haml folder contains the .haml files I work on, and the pages folder contains my converted .html files.
I know I can convert the files, from the website root directory, by doing:
haml haml/about.haml pages/about.html for each file.
However, is there a way to convert all the .haml files in my haml folder to an equivalent .html file in the pages folder?
Something like: haml haml/*.haml html/*.html
Thanks!

There is a nice html2haml gem for this purpose
and you can run it on a directory using
find . -name \*.erb -print | sed 'p;s/.erb$/.haml/' | xargs -n2 html2haml

guard watches haml files, compiles them, you can set an output dir as well.
https://github.com/guard/guard-haml sounds like an option.

There's a python script that sounds like it will do exactly what you want...
I haven't tested it, but per the README, it sounds like it's as simple as:
python haml2html.py [input_dir] [output_dir]

Related

force ANTLR to generate the output files in a specific folder

I don't like to have the ANTLR generated files in the same location as my .g4 grammar and other version-controlled documents. I would like to put all the generated files in a separate nested folder that can be excluded via .gitignore. What I have tried so far is to create a folder <someFolder> inside the main folder and from inside that folder ran:
cd <someFolder>
antlr ../<grammarFile.g4>
however, it still spills all the generated files in the parent folder.
P.S. It shouldn't matter but my environment is macOS.
From https://github.com/antlr/antlr4/blob/master/doc/tool-options.md:
-o outdir
ANTLR generates output files in the current directory by default. This option specifies the output directory where ANTLR should generate parsers, listeners, visitors, and tokens files.
in the example above, from the main folder run
antlr <grammarFile.g4> -o <someFolder>

Pycharm SASS: output css in relative directory

I'm trying to setup a file watcher in PyCharm for my SASS files. I've followed the official guide and it worked jsut fine (https://www.jetbrains.com/help/pycharm/transpiling-sass-less-and-scss-to-css.html#)
Now I'd like to change the destination of the compiled CSS files to a specific folder, relative to the SASS file. Basically, the output directory should be ../css/ when starting from the SASS file, because my structure looks like this:
app1/
static/
css/
myfile.css
sass/
myfile.sass
app2/
static/
css/
myfile2.css
sass/
myfile2.sass
I'm not sure I understand what values I should put in arguments and output paths to refresh. I'm currently using the default settings (https://imgur.com/a/rrIJHeR)
I solved it. For anyone struggling with the same issue, here's how I fixed it:
Arguments = sass\$FileName$:css\$FileNameWithoutExtension$.css
Output = css\$FileNameWithoutExtension$.css
Working Directory = $FileParentDir$
Here's an image of the setup :

make: Convert .pdf files in a folder to .txt files without using loops

I want to convert all .pdf files in a folder into .txt files with make without using loops and with the help of pdftotext. The new .txt files shall keep the original file name. Additionally, the new file gets a new file extension.
Example:
test1.pdf --> test2.newextension
Everything's written within a Makefile file. I start the conversion by typing in "make converted" in my console.
My first (miserable) attempt was:
converted:
#ls *.pdf | -n1 pdftotext
However, there are 3 things still missing with it:
It doesn't repeat the process
The new file extension isn't being added to the newly created files.
Is the original name being kept or being given to the pdftotext function?
I used to program with the bash and Makefile is completely new to me. I'd be thankful for answers!
You can refer to this simple example:
SOURCES ?= $(wildcard *.pdf)
%.txt: %.pdf
pdftotext $< $#
all: $(SOURCES:%.pdf=%.txt)
clean:
rm -f *.txt
If no SOURCE was defined, it'll just try to get all *.pdf files from the local directory.
Then we define a pattern rule teaching make how to make *.txt out of *.pdf.
We also define target all that tried to make a txt file for each .pdf file in SOURCES variable.
And also a clean rule deleting quietly all .txt files in current dir (hence be careful, potentially dangerous).

Wget file format

I have to download all site content and then parse the downloaded folder for "*.pdf" files. I am downloading site using wget -r --no-parent http://www.example.com/ But the problem is that sometimes link looks this
http://www.foodmanufuture.eu/dpubs?f=K20
and the dowloaded pdf is downloaded with name "dpubs?f=K20" and file format is not specified, it does not look like this "dpubs?f=K20.pdf", is there a way to check how many pdf files I have in this folder?
Have you tried the --content-disposition flag? From the man page:
If this is set to on, experimental (not fully-functional) support for "Content-Disposition" headers is enabled. This can currently result in extra round-trips to the server for a "HEAD" request, and is known to suffer from a few bugs, which is why it is not currently enabled by default. This option is useful for some file-downloading CGI programs that use "Content-Disposition" headers to describe what the name of a downloaded file should be.
So it tries to ask the server for a filename. I tried it for the URL you gave and it seemed to work.
You could use the command
file filename
Like this:
file pdfurl-guide
pdfurl-guide: PDF document, version 1.5
You could use:
file *
To know exactly which files in your folder are pdf files

How to index plain text files (other than *.txt)

I want to index all source code of my application. The code library contains multiple extensions - .html, .js, .py, .php, .json etc. I wish to index them all. However my first try to index them like so
bin/post -c gettingstarted ~/Projects/myapp/
was not successful. I see that it indexed only *.txt files.
I found a solution. For some reason, Apache Solr does not index .js, .py and some other files by default. So, to force it index them, you have to do it like this:
bin/post -c gettingstarted -filetypes js,py ~/Projects/myapp/