mirror of
https://github.com/Brandon-Rozek/website.git
synced 2024-11-21 15:56:29 -05:00
New Posts
This commit is contained in:
parent
b8b4894bb4
commit
91ecc135fa
2 changed files with 71 additions and 0 deletions
45
content/blog/convert-djvu-to-pdf.md
Normal file
45
content/blog/convert-djvu-to-pdf.md
Normal file
|
@ -0,0 +1,45 @@
|
|||
---
|
||||
title: "Convert DJVU to PDF"
|
||||
date: 2021-08-27T22:00:00-04:00
|
||||
draft: false
|
||||
tags: []
|
||||
math: false
|
||||
---
|
||||
|
||||
I've recently come across the DJVU file format before and needed to convert it to a PDF. The most reliable way I've found to do it is via the following command.
|
||||
|
||||
```bash
|
||||
djvups FILENAME | ps2pdf - OUTPUT_FILE
|
||||
```
|
||||
|
||||
Where FILENAME first gets converted to the PS file format which then gets converted to a PDF with the name OUTPUT_FILE. To make things easier, I wrote a little script that does this process automatically while preserving the filename.
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
show_usage() {
|
||||
echo "Usage: djvu2pdf [FILENAME]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
show_usage
|
||||
fi
|
||||
|
||||
if ! command -v djvups > /dev/null ; then
|
||||
echo "djvups not found. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v ps2pdf > /dev/null ; then
|
||||
echo "ps2pdf not found. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
djvups "$1" | ps2pdf - "${1%.*}.pdf"
|
||||
```
|
||||
|
26
content/blog/do-while-other-lang.md
Normal file
26
content/blog/do-while-other-lang.md
Normal file
|
@ -0,0 +1,26 @@
|
|||
---
|
||||
title: "Do-While Loop in Other Languages"
|
||||
date: 2021-08-27T21:50:02-04:00
|
||||
draft: false
|
||||
tags: []
|
||||
math: false
|
||||
---
|
||||
|
||||
Some languages like C, C++, and Java have a concept of a Do-While loop which normally look like the following:
|
||||
|
||||
```
|
||||
do {
|
||||
statements;
|
||||
} while(condition);
|
||||
```
|
||||
|
||||
This would ensure that your group of statements at least run once and then continue while the condition is still met. If you're used to that pattern, then it can be annoying when you switch to another language like Python and find that it doesn't exist. To replicate this behavior, its as simple as adding an extra variable.
|
||||
|
||||
```python
|
||||
first_run = True
|
||||
while condition or first_run:
|
||||
first_run = False
|
||||
statements
|
||||
```
|
||||
|
||||
|
Loading…
Reference in a new issue