teleren/devto huggingface dataset:
Convert DJVU to PDF
Published: 2023-01-05 22:46:51

---
title: Convert DJVU to PDF
published: true
date: 2021-08-28 02:00:00 UTC
tags: 
canonical_url: https://brandonrozek.com/blog/convert-djvu-to-pdf/
---

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.

```
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.

```
#!/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"

```
Do-While Loop in Other Languages
Published: 2023-01-05 22:47:11

---
title: Do-While Loop in Other Languages
published: true
date: 2021-08-28 01:50:02 UTC
tags: 
canonical_url: https://brandonrozek.com/blog/do-while-other-lang/
---

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.

```
first_run = True
while condition or first_run:
    first_run = False
    statements

```
leaning Ad
Published: 2021-07-07 00:00:41

[name='home']
account/logout [name='logout']
oauth/
admin/
cat_checker/
spi/
pageutils/
static/(?P<path>.*)
__debug__/
# This is an <h1> tag
## This is an <h2> tag ###### This is an <h6> tag
```javascript function test() {
console.log("look ma’, no spaces"); }
```
test() {
console.log("look ma’, no spaces"); }
~</>higherenginer<finane> in data farming......meaning this Net becomes a Land that any [PNG] in the platform is=datafinance 
```~~~ where $ is = what you say it's 
- [ete-ose] this is a complete item payment and onetime code generator 
- [ obalaobe] this is an incomplete item 
- [ijetee-nabe] @mentions, #refs, [links](), **formatting**, and <del>tags</del> supported
- [ALPHA~coding] numbers wax,3-9-18-18-9-3(
 enjoyment á 28 )
 (
)))18
(((((9
))))))3(
...addEventListener("fetch", (event) => {
  event.respondWith(
    handleRequest(event.request).catch(
      (err) => new Response(err.stack, { status: 5000000 })
    )$Cradit,.. 
  );
});

/**
 * Many more examples available at:
 *   https://developers.marconetfarming.com/workers/examples
 * @param {Request} request
 * @returns {Promise<Response>}
 */
async function handleRequest(request) {
  const { pathname } = new URL(request.url);

  if (pathname.startsWith("/api")) {
    return new Response(JSON.stringify({ pathname }), {
      headers: { "Content-Type": "application/json" },
    });
  }

  if (pathname.startsWith("/status")) {
    const httpStatusCode = Number(pathname.split("/")[2]);

    return Number.isInteger(httpStatusCode)
      ? fetch("https://http.cat/" + httpStatusCode)
      : new Response("That's not a valid HTTP status code.");
  }

  return fetch("https://welcome.developers.workers.dev");
}
Updating all npm packages via command line
Tags: javascript, node
Published: 2021-12-30 23:07:13

---
title: Updating all npm packages via command line
published: true
date: 2021-08-28 01:31:00 UTC
tags: javascript,nodejs
canonical_url: https://jason.sultana.net.au/javascript/nodejs/2021/08/28/updating-all-npm-packages.html
---

G’day guys!

Have you ever come back to an old JavaScript or TypeScript project after a while - or perhaps created a project using a CLI tool whose packages are a bit behind - and needed to update all of the packages in `package.json` to their latest versions? It turns out there’s a super convenient way to do this on the command line.

#### Disclaimer

![](https://jason.sultana.net.au/static/img/breaking-changes.jpg)

Here is the obligatory disclaimer for what I’m about to say. Updating packages on an existing project that involves changing a major version is likely to introduce some breaking changes in your usage of the package. You of course should not do this on any production environment unless you’re prepared to face errors descending on your project like the Uruk-hai at the end of Fellowship of the Ring. With that out of the way, let’s see the magic!

```
npx npm-check-updates -u && npm install

```

![](https://jason.sultana.net.au/static/img/magic.jpg)

For those of you that were just after the quick fix, you can leave now 😁. Or if you’re the type that likes to wait until the end of the credits for that bonus scene, read on!

#### What’s this npx business? What happened to npm?

If you’re not a big front-end or nodeJS dev, you might be surprised to see this. `npx` originally started out as an [npm package](https://www.npmjs.com/package/npx) that allowed you to execute another npm package from the command line, even if it weren’t installed globally or on your path. This is typically used for packages installed as `devDependencies` in your project, like a database migration tool, project build tools, etc. Since [2017](https://github.com/npm/npm/releases/tag/v5.2.0) though, `npx` has been bundled with the `npm` cli, so there’s no need to install it nowadays. What’s really cool about npx is that if the package doesn’t already exist in your project, it’ll add it to your dev dependencies and install it before executing.

[npm-check-updates](https://www.npmjs.com/package/npm-check-updates) is an npm package that performs the update of your packages to their latest versions. To quote their docs on npm, _npm-check-updates upgrades your package.json dependencies to the latest versions, ignoring specified versions._

#### What about the double ampersand (&&)?

That’s just a bit of wizardry that tells your shell (yep, even the Windows shell) to execute the first command, wait for it to complete, then execute the second. This is an easy way to put together a rudimentary chain of commands, without using a proper task execution tool like [gulp](https://gulpjs.com/) or [grunt](https://gruntjs.com/).

Anyhoo, that’s all from me today. Happy coding and bye for now. Catch ya!
Android AES DUKPT Library with Secure Shared Preferences
Tags: java, android, aesdukpt
Published: 2021-08-28 01:24:49

Implementation of the ANSI AES DUKPT standard: specified within Retail Financial Services Symmetric Key Management Part 3: Using Symmetric Techniques (ANSI X9.24-3:2017).

Encrypt transactions

Note: Only DATA and PIN encryption

https://github.com/joyner-perez/aes-dukpt-android

Photo by <a href="https://unsplash.com/@jonasleupe?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Jonas Leupe</a> on <a href="https://unsplash.com/s/photos/android-pay?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
Java library for AES DUKPT Transaction Encryption
Tags: java, aesdukpt, encryption
Published: 2021-08-28 01:19:17

Implementation of the ANSI AES DUKPT standard: specified within Retail Financial Services Symmetric Key Management Part 3: Using Symmetric Techniques (ANSI X9.24-3:2017).

https://github.com/joyner-perez/aes_dukpt_x9.24-3-2017

Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Markus Winkler</a> on <a href="https://unsplash.com/s/photos/encryption?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
Refatorar X Refazer: O que considerar antes de tomar essa decisão
Tags: refatorar, refatoracao, refazer
Published: 2021-08-28 01:19:02

---
title: Refatorar X Refazer: O que considerar antes de tomar essa decisão
published: true
description: Nesse post eu compartilho como costumo pensar antes de escolher uma das opções
tags: refatorar, refatoracao, refazer
cover_image: https://images.unsplash.com/photo-1504148455328-c376907d081c?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1143&q=80
---

Se você já entrou em um projeto desatualizado, com arquitetura e código confusos, provavelmente você já se perguntou:

"Será que devemos refazer esse projeto do zero? Ou devemos refatorar?"

Esse é um pensamento que uma hora ou outra vai passar pela sua cabeça, eu tenho pensado nisso durante uns meses e decidi compartilhar como eu costumo pensar nessas ocasiões.

Pra entender como eu escolho um dos caminhos é só acessar o post no meu blog: [Refatorar x Refazer](https://evellynlima.com.br/refatorar-x-refazer/). 

Eu gostei do resultado final e acredito que vale o clique. Boa leitura!

--- 

#### Links úteis

- [Foto tirada por NeONBRAND](https://unsplash.com/@neonbrand)
In terms of infrastructure, how could I build a dev.to like platform but for music?
Tags: devops, webdev, react, nextjs
Published: 2021-08-28 00:25:25

I want to build a dev.to like platform but for music related articles, but I don't know much about DevOps, what would be, in your opinion, my road map for this project?

I saw some articles here with some clones, but nothing about infrastructure.

Thanks in advance!
The only thing we have to fear...
Tags: devops, automation, fear, culture
Published: 2021-09-03 13:25:18

---
title: The only thing we have to fear...
published: true
date: 2021-08-28 00:00:00 UTC
tags: devops,automation,fear,culture
canonical_url: https://jhall.io/archive/2021/08/28/the-only-thing-we-have-to-fear.../
---

On page 14 of the [2021 State of DevOps Report](https://www2.circleci.com/2020-state-of-devops-report.html), the authors compare the blockers to DevOps for “low-evolution” organizations with “high-evolution” organizations:

> Low-evolution teams … cite organizational resistence to change (31%), legacy architecture (28%), shortage of skills (23%), limited or lack of automation (20%), and unclear goals or objectives (20%).
> 
> High-evolution teams' blockers are fundamentally different: legacy architecture (29%), and shortage of skills (29%).

They come to an interesting, if not tautological, conclusion:

> In short, for highly-evolved firms, culture is no longer a barrier. This is ultimately why they’re highly evolved.

In my own practice, I’ve identified a specific blocker to DevOps, which I believe is a subset of the “culture” talked about in the report:

# Fear

This fear takes various forms.

- Fear of deploying on Friday afternoon
- Fear that the code needs more testing before it’s “ready”
- Fear that automated deployments means giving up control
- Fear of hiring under-qualified engineers
- Fear of choosing the wrong technology

Of course when we take a step back, most of these fears don’t really make sense in the context of DevOps or agile software development. The whole point of these concepts is to be able to respond quickly to change. So if we do deploy a broken piece of software, we can recover quickly. If we do hire an under-qualified engineer, they won’t jeaporidize our project, and they can get up to speed. If we do choose the wrong technology we can change it later!

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
Getting previous and next record in Laravel
Tags: laravel, laravelprevnext, php
Published: 2021-08-28 23:50:20

---
title: Getting previous and next record in Laravel
published: true
date: 2021-08-28 00:00:00 UTC
tags: laravel, laravelprevnext, php
canonical_url: https://postsrc.com/posts/getting-previous-and-next-record-in-laravel
---
[This post was originally published at PostSrc 🔥🔥🔥](https://postsrc.com/). If you like this kind of tutorial, I would really appreciate it if you give it a visit.

![Getting previous and next record in Laravel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w5nu5uuhk78060yjjyz1.jpg)

To be able to navigate around through the previous and next resources is a very handy feature to have. This will enable easy navigation between the record on both sides (left and right). The implementation is quite straight forward but certain logic has to be clearly defined to get the right result in the model.  
  
**Example Scenario**

- PostSrc previous and next post
- Laracast previous and next episode series

  
There are several ways to implement this functionality and the simplest way is to use the Model Id. Since by right an Id auto increment, we can assume that the newest post will always have a higher number than the oldest post.   
  
**Previous and Next Implementation**  
To get the previous and next posts we'll be using the code below. Do note that it's within the controller that you have defined in, otherwise any other places suitable in your application.

```php
function show(int $id)
{
    // get the current post
    $post = Post::find($id);

    // get previous post id
    $previous = Post::where('id', '<', $post->id)->max('id');

    // get next post id
    $next = Post::where('id', '>', $post->id)->min('id');

    return view('posts.show', compact('post', 'previous', 'next'));
}
```

  
In the example above we are getting the default post by querying using the "id". To get the previous and next post we make use of the where clause by getting the lowest and highest post model "id" value. Once we get the models, we are comparing them with the other models we are getting the "max" for the previous post and "min" for the next post and this essentially filters the model to get only one that matches the criteria.  
  
**Previous and Next Video / Episode**  
In other case scenarios where you are not making use of the model "id", you need to define a column such as "episode\_number" where it will store the numeric value.

```php
function show(int $id)
{
    // get the current episode
    $episode = Episode::find($id);

    // get previous episode number
    $previous = Episode::where('episode_number', '<', $post->episode_number)->max('episode_number');

    // get next episode number
    $next = Episode::where('episode_number', '>', $post->episode_number)->min('episode_number');

    return view('episodes.show', compact('episode', 'previous', 'next'));
}
```
Async/Await With IAsyncResult Methods
Tags: c, netcore
Published: 2021-08-28 00:34:58

---
title: Async/Await With IAsyncResult Methods
published: true
date: 2021-08-27 23:48:00 UTC
tags: C,netcore
canonical_url: https://jamienordmeyer.net/2021/08/27/async-await-with-iasyncresult-methods/
---

One of the applications that I work with uses PowerShell from with a .NET C# API project. The Nuget package that provides the necessary interfaces is called System.Management.Automation. It is actively maintained by Microsoft, but has API’s that still use the older `IAsyncResult` methodology of asynchronous programming, including the `Invoke` method on the `PowerShell` object itself.

As a result, when trying to add calls to `Invoke` within methods that are written as `async/await` methods, the fallback was the “good ‘ol” `Task.Run` calls:

```csharp
public async Task<bool> IsSessionAliveAsync()
{
    return await Task.Run(() =>
    {
        _powerShell.Commands.AddCommand("Get-PSSession");

        var result = _powerShell.Invoke();
        return (result?.Count ?? 0) > 0;
    });
}
```

However, today I discovered a neat little method in the `TaskFactory` class called `FromAsync`. This method takes an `IAsyncResult` instance as its first parameter, and a delegate that is triggered when the `IAsyncResult` instance completes. And… it’s awaitable! This makes code flow more naturally (in my humble opinion), and removes a level of scoping/nesting from your code:

```csharp
public async Task<bool> IsSessionAliveAsync()
{
    _powerShell.Commands.AddCommand("Get-PSSession");

    var result = await Task.Factory.FromAsync(_powerShell.BeginInvoke(), _powerShell.EndInvoke);
    return (result?.Count ?? 0) > 0;
}
```

Very nice! I’m sure there are plenty of engineers out there that would see this and say “Well, yeah, that’s been there forever!” Hey, I’m just happy that I found it now! ![🙂](https://s.w.org/images/core/emoji/13.1.0/72x72/1f642.png)
JavaScript: Synchronous or Asynchronous?
Tags: javascript, callbacks, promises, asyncawait
Published: 2021-08-27 23:26:47

###Understanding the Synchronous and Asynchronous operations:

In synchronous operations, operation are performed one at a time. The next operation is unblocked only when the ongoing operation is completed.
Simple words, you need to wait for a operation in progress to finish, in order to start the next one in the queue. 

In asynchronous operations, the next operation can be started before the previous one finishes.
Asynchronous programming allows to handling of multiple requests simultaneously, thereby allowing to accomplish more tasks within shorter time span.   

###So what is JavaScript?
At its core, JavaScript is by default Synchronous in nature.

**Let's break it down:**
It is Synchronous because it is Single-threaded. In single-thread one operation is executed at a time.
It blocks other operations in queue, as they need to wait until the previous operation has completed execution.

**In nutshell:**
In JavaScript, only one operation will be executed at a time and the successive operations in stack need to wait until the ongoing operation is completed.

**Question:** If JavaScript is Synchronous in nature, why on this earth Asynchronous JavaScript term so popular amongst JavaScript developers?

**Answer:** The developers manipulate JavaScript to behave Asynchronously. To make this manipulation, there are 3 techniques:

1. Callback function
2. Promises
3. Async/Await.


###Resources I recommend to understand these asynchronous techniques:

**Callbacks:**
Watch this awesome video by [Philip Roberts] (https://youtu.be/8aGhZQkoFbQ) while referring to his [Demo website](http://latentflip.com/loupe/?code=JC5vbignYnV0dG9uJywgJ2NsaWNrJywgZnVuY3Rpb24gb25DbGljaygpIHsKICAgIHNldFRpbWVvdXQoZnVuY3Rpb24gdGltZXIoKSB7CiAgICAgICAgY29uc29sZS5sb2coJ1lvdSBjbGlja2VkIHRoZSBidXR0b24hJyk7ICAgIAogICAgfSwgMjAwMCk7Cn0pOwoKY29uc29sZS5sb2coIkhpISIpOwoKc2V0VGltZW91dChmdW5jdGlvbiB0aW1lb3V0KCkgewogICAgY29uc29sZS5sb2coIkNsaWNrIHRoZSBidXR0b24hIik7Cn0sIDUwMDApOwoKY29uc29sZS5sb2coIldlbGNvbWUgdG8gbG91cGUuIik7!!!PGJ1dHRvbj5DbGljayBtZSE8L2J1dHRvbj4%3D)

[Callback Hell](http://callbackhell.com/): Callback Hell is a Nightmare. Refer this if you want to dig deeper into callbacks


**Promises:**
Video by [Codevolution](https://www.youtube.com/watch?v=YiYtwbnPfkY&ab_channel=Codevolution)


**Async/Await:**
Best article on this topic by [Mostafa Gaafar](https://dev.to/gafi/7-reasons-to-always-use-async-await-over-plain-promises-tutorial-4ej9?ref=hackernoon.com&signin=true)


All 3 techniques in one video by [codeSTACKr](https://www.youtube.com/watch?v=F8xANXY0kaU&ab_channel=codeSTACKr)

----

> I will be creating articles on each of these topics. Need feedback from bloggers & readers of dev community, that will help me to improve my work.
easy project set-up steps (react js)
Published: 2021-08-27 23:18:43

Basic Project Setup

1. npm init -y (this will create a package.json file with some default info)

2. npm i react react-dom express

3. npm install @babel/core @babel/preset-env @babel/preset-react babel-loader --save-dev
npm install webpack webpack-cli --save-dev
npm install webpack-dev-server --save-dev

4. git init

5. Add node_modules dir to .gitignore

6. Create project directory structure
     6.1 Words in bold are directories
     6.2 client
          6.2.1 dist
               6.2.1.1 index.html
               6.2.1.1 style.css
          6.2.2 src
               6.2.2.1 Components
                    6.2.2.1.1 ComponentOne.js
               6.2.2.2 index.jsx
     6.3 server
          6.3.1 server.js
     6.4 database (if necessary)
          6.4.1 db.js
     6.5 webpack.config.js
     6.6 .eslintrc (if necessary)
Snowman
Published: 2021-08-27 22:26:56

This is a simple program to draw a snowman using the graphics module created by John Zelle.

```python
# exercise_4.py
#   This program draws a winter scene with a Christmas treee and a snowman
# by: Scott Gordon


from graphics import *

# Create main window
def main():
    win = GraphWin("Snowman", 800, 600)
    win.setCoords(-8, -8, 6, 6)
    win.setBackground("grey")
    center = Point(0, 0)

# Draw horizon line and color upper half blue and bottom half white
    horizon = Line(Point(-8, 0), Point(8, 0))
    horizon.setWidth(2)
    horizon.draw(win)

    sky = Rectangle(Point(-8, 0), Point(8, 6))
    sky.setFill("blue")
    sky.draw(win)

# Add triangle for tree and color green
    tree_top = Polygon(Point(-3, 4), Point(-5, -4), Point(-1, -4))
    tree_top.setFill("green")
    tree_top.draw(win)

# Add rectangle for tree bottom and color brown
    tree_bottom = Rectangle(Point(-2.5, -4), Point(-3.5, -5))
    tree_bottom.setFill("brown")
    tree_bottom.draw(win)


# Stack 3 circles each smaller than the next moving up the y coord
    snowman_bottom = Circle(Point(2, -4), 2)
    snowman_bottom.setFill("White")
    snowman_bottom.draw(win)

    snowman_mid = Circle(Point(2, -2), 1.5)
    snowman_mid.setFill("White")
    snowman_mid.draw(win)

    snowman_top = Circle(Point(2, -.5), 1)
    snowman_top.setFill("White")
    snowman_top.draw(win)


# Draw snowman's face on the top circle
    snowman_eye1 = Circle(Point(2.25, -.75), .10)
    snowman_eye1.setFill("Black")
    snowman_eye1.draw(win)

    snowman_eye2 = snowman_eye1.clone()
    snowman_eye2.move(-.75, 0)
    snowman_eye2.draw(win)

    snowman_nose = Polygon(Point(1.75, -1.0), Point(2.0, -1.25), Point(1.95, -1.0))
    snowman_nose.setFill("Orange")
    snowman_nose.draw(win)

    win.getMouse()
    win.close()


main()

```
```
Simplest way to add a leading zero to a number in Javascript
Tags: javascript, programming, webdev, ui
Published: 2021-08-27 22:14:00

The simplest way to pad a number with leading zero is to use padStart() method provides by Javascript. We can use this for numbers less than 10.

###Syntax
```
string.padStart(targetLength, padString)
```

####Parameters
**targetLength:** length of the final string
**padstring:** string you want to pad/add to given number.

####Example
```
const number = 9;
console.log(number.toString().padStart(2, '0'))
//Output: 09
```

####Alternatively use can also use:
**1.slice() method**
In this method, we add a zero to the number and slice to extract 2 digit value of the result. We use negative value to select from end of the string.
```
const number = 9;
console.log(("0" + number).slice(-2))
//Output: 09
```

**2. if check for numbers less than 10**
```
const number = 9;
if(number< 10){
console.log("0" + number);
}
else{
console.log(number)
}
//Output: 09
```

**Use case:** When you want to display timer in your web application. You need to pad leading zero to minutes and seconds less than 10.

[![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hqmyq1twcon9ndguelyd.png)](https://www.buymeacoffee.com/hardiquedasore)

Follow us on [Instagram ](https://www.instagram.com/commitandpush/)