teleren/devto huggingface dataset:
Project #2: Docker/Django project from testdriven.io (status: in-progress)
Published: 2022-12-19 02:20:38

I started a course from [Test-Driven Development with Django, Django REST Framework, and Docker](https://testdriven.io/courses/tdd-django/)

**Status**: Complete

**2023-02-25**
I haven't updated this in a while but for a good reason: I was actually doing the work and I can happily report that I have completed this project. According to my logs, I've put in 30+ hours into it and have learned a lot.

I took the TDD Django Project from testdriven and built a CI pipeline which:
- Built a CI version of my latest code commits and ran tests and linting
- Once those tests passed, it built a production docker image and pushed it up to GitHub Container Registry
- If that job was successful, another job pulled down the latest images from GitHub Container Registry and copied the secret `.env` file + production docker-compose file and built the production image in Linode and deployed


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7rrb05vgxq1tpeq7fus1.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6bhb3479c0jouijczzjp.png)

In the end I needed 3 guides to complete this project:
- https://testdriven.io/courses/tdd-django
- https://www.udemy.com/course/github-actions-the-complete-guide
- https://testdriven.io/blog/deploying-django-to-linode-with-docker-and-github-actions/

**2023-01-17**
After getting my first build to run, I was beating my head trying to run the tests. I am trusting my gut in everything and decided to do a [GitHub Actions course on Udemy](https://www.udemy.com/course/github-actions-the-complete-guide). I'll go through this over the next two weeks so that I can really understand Actions. I'm not trying to piece together a buncha random StackOverflow articles. I'm doing this legit.

**2023-01-12**
I've been putting in time this week. In my project, added flake8/black/isort which are great packages I will use for my projects in the future. It got to a point where the tutorial wanted me to sign-up for GitLab + upload my image to Docker Hub but I wanted to use GitHub Actions + GitHub Container Registry. I watched a video from [Nana Techworld](https://www.youtube.com/watch?v=R8_veQiYBjI) and after bashing my head against the wall for an hour I finally got a passing build (though it is incomplete)!


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


**2022-12-24**
Worked on this about 1.5 hours today. It's looking good but it's quite Heroku specific, which I have no plans of using for future projects. Merry Christmas to all

**2022-12-18**
It's going pretty smoothly right now, I've put roughly 2.5 hours into it. The project that we build ends up deploying to Heroku but when I'm done with the project I'll try to adapt it to deploy to my Linode.
There are a few reasons why Java is a good language for beginners to learn.
Tags: java
Published: 2022-12-19 01:59:21

Java is easy to read and understand: Java has a simple, English-like syntax, which makes it easy for beginners to read and understand code.

Java is widely used: Java is one of the most popular programming languages in the world, and it is used to build a wide range of applications, including web, mobile, and desktop applications.

Java has a large and active community: Java has a large and active community of developers, which makes it easy for beginners to get help and support when they are learning to code.

Java has good documentation: There is a wealth of documentation and resources available for Java, including tutorials, reference materials, and forums, which can be helpful for beginners who are learning to code.

Overall, Java is a good language for beginners to learn because it is easy to read and understand, widely used, has a large and active community, and has good documentation.
10 gợi ý mua quà Tết cho gia đình, người thân
Tags: webdev, javascript, beginners, programming
Published: 2022-12-19 01:51:37

Mua quà Tết cho gia đình được xem là một hành động không thể thiếu trong những ngày cuối năm. Tham khảo ngay những gợi ý của SagoGifts để chọn được món quà ưng ý nhé!

[https://sagogifts.vn/qua-tet-cho-gia-dinh/](https://sagogifts.vn/qua-tet-cho-gia-dinh/)
[https://www.facebook.com/Gi%E1%BB%8F-Qu%C3%A0-T%E1%BA%BFt-106905578800951/](https://www.facebook.com/Gi%E1%BB%8F-Qu%C3%A0-T%E1%BA%BFt-106905578800951/)
[https://twitter.com/GQuatet](https://twitter.com/GQuatet)
[https://www.instagram.com/gioquatet2023/](https://www.instagram.com/gioquatet2023/)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/udag92rwvcdbda0gpxyo.jpg)
https://www.linkedin.com/in/gio-quatet-438b56248/
What wrong with this codes?
Tags: javascript, html
Published: 2022-12-19 01:44:02

It doesn't output. What's the functional fix to it?

```
const discountFunc = () => {
	let productPrice = 1000;
	let discountCode = ABCD;
	if (productPrice == 1000 && discountCode == ABCD) {
			return document.getElementById("checkOut").innerHTML = productPrice / 2;
		} else {
			return document.getElementById("checkOut").innerHTML = productPrice;
		}
}
```

```
<section>
				<button onclick="discountFunc()">Get discount</button>
				<p id="checkOut"></p>
			</section>
```
What is Spring Security? pt.3
Tags: java, springboot, security, springsecurity
Published: 2022-12-19 01:33:24


![spring security](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bfl9hswqws30n6rzapw1.png)

## AuthenticationManager, AuthenticationProvider(s), ProviderManager


![AuthenticationManager, AuthenticationProvider(s), ProviderManager](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lukzgx7brr1e5ydxt0kz.png)


### AuthenticationManager (Interface)

```java
public interface AuthenticationManager {
	Authentication authenticate(Authentication authentication) 
throws AuthenticationException;
}
```
Attempts to authenticate the passed Authentication object, returning a fully populated Authentication object (including granted authorities) if successful.


### ProviderManager(class)

```java
for  ( AuthenticationProvider provider :  getProviders ( ) )  { 
	if  ( ! provider . supports ( toTest ) )  { 
		continue ; 
	} 
	if  ( logger . isTraceEnabled ( ) )  { 
		logger . trace ( LogMessage . format ( "Authenticating request with %s (%d/%d)" , 
				provider . getClass ( ) .getSimpleName ( ) ,  ++ currentPosition , size ) ) ; 
	} 
	try  { 
		result = provider . authenticate ( authentication ) ; 
		if  ( result !=  null )  { 
			copyDetails ( authentication , result ) ; 
			break ; 
		} 
	} 
	catch  ( AccountStatusException  |  InternalAuthenticationServiceException ex ) { 
		prepareException ( ex , authentication ) ; 
		throw ex ; 
	} 
	catch  ( AuthenticationException ex )  { 
		lastException = ex ; 
	} 
}

```
We don't need to implement it ourselves since Spring Security manages it for us.

ProviderManager is a class implemented in AuthenticationManager responsible for authentication.

It is in charge of the authentication, but it does not actually carry out the authentication process.
It delegates authentications to AuthenticationProvider(s).
The AuthenticationProvider then passes on the result of the authentication to the ProviderManager.


### AuthenticationProvider

```java

public interface AuthenticationProvider {

	Authentication authenticate(Authentication authentication) throws AuthenticationException;

	boolean supports(Class<?> authentication);
}

```

The boolean supports(Class<?> authentication) method is a method that checks if AuthenticationProvider can authenticate or not. 
The authentication process is performed through the `authenticate()` method.
Accessing MacOS native apis from tauri
Published: 2022-12-19 01:32:19

I recently built an app using [Tauri](https://tauri.app/) where I was trying to access a user's a contacts list using the native macos apis. My code worked in development but the app would crash when bundled and signed. 

To make it work, you need to do two things:

1. Add necessary attributes to `Info.plist`
2. Add the correct entitlements to your `entitlements.plist` file.

I had to do this to access the contact list but I imagine a similar flow is required to access webcam and microphone too.

To access contacts information, I added the following `Info.plist` file to my `src-tauri` directory:

```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>NSContactsUsageDescription</key>
  <string>Why your app needs contacts info</string>
</dict>
</plist>
```

You also need to add the correct entitlements file. This is what mine looks like, placed in the `src-tauri` directory and referenced in `tauri.config.json`:

```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>com.apple.security.personal-information.addressbook</key>
    <true/>
  </dict>
</plist>
```

Happy building with Tauri!
What is risk management?How to improve it ?
Tags: cybersecurity, it, riskmanagment, securityawareness
Published: 2022-12-19 01:25:31

Thanks to the systematic process of risk management organizations can better understand risk inside the organization related to the information systems. Also, can understand specifically what the risk is, what is at risk, how to analyze the risk and respond to it. Also with a risk management plan is possible to know the current controls in place to address those risks and determine if those controls are adequate. To do all this work, the security awareness of the IT staff and employees of other departments must be there. It seems obvious, but on many occasions, threats can be minimized and with this the motivation to maintain a good risk management plan and practices. For this reason, it is highly recommended that continuous training and meetings be held to discuss the plan and ways to improve it. A change management of risk plan needs to have clear documentation, in this way the staff can lay out the tasks and determine the resources needed in case of a breach or threat in an efficient way, acting faster in the situation. Some common examples in risk management plans are not storing sensitive information on their computers. This is to minimize data breaches; this can be solved by storing the data in a cloud to transfer the risk to a company and buy insurance that supports this service and provides more integrity to the system. Another example of strategies to minimize or mitigate risk that should be included in this plan is multifactor authentication, reducing unauthorized persons accessing information and sharing or transferring it. The main cause of threats and security breaches are due to personnel, 75% of them clicking malicious emails or links, so training must be applied to the employees of the organization and that these trainings are given continuously (Dada et al. 2021).
Improve Your Code Quality with These Essential Tips
Published: 2022-12-19 01:08:01

This week, I wanted to talk about the importance of writing clean code in JavaScript.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ufavhwyab9btr5z8vujq.gif)

Here are some tips and resources to help you write more maintainable and scalable code:

**Follow established coding standards and style guides.** There are several popular style guides for JavaScript, such as the Airbnb style guide and the Google style guide. Adopting a consistent style will make it easier for other developers to read and understand your code.

**Use descriptive and meaningful names for variables, functions, and objects.** Avoid using abbreviations or single-letter names unless they are commonly accepted in the JavaScript community (e.g., i for loop indices).

**Write modular and reusable code** by breaking down larger functions into smaller, more focused ones and by extracting common code into shared utility functions.

**Use comments to explain the purpose and intent of your code.** Avoid writing comments that simply repeat the code or that are out of date.

**Use code linters** and static analysis tools to identify potential issues and improve the quality of your code. The most popular JavaScript linting tool is ESLint.

**Regularly refactor your code to remove redundancy and improve its structure and readability.**

Bonus tip - read the book called *Clean Code: A Handbook of Agile Software Craftsmanship,* it's a gem!

I hope these tips help you in your journey as a developer.

Happy coding!
How to create a REACT app
Tags: react, javascript, webdev, beginners
Published: 2022-12-19 00:10:10

To create a React application, you will need to have _Node.js and npm (or yarn)_ installed on your computer. Once you have those tools, you can create a new React app by using the create-react-app command line utility. Here's an example:

```
npx create-react-app my-app
```
This will create a new directory called my-app inside your current directory, and it will generate all the necessary files for a basic React app. Once the app is created, you can navigate to the app directory and start the development server by running the following commands:

```
cd my-app
npm start
```
Alternatively, if you're using yarn, you can use the following commands:

```
cd my-app 
yarn start
```
This will start the development server and open the React app in your default web browser. You can then start building your React app by editing the files in the **src** directory.
Deploy a local kind cluster
Tags: kind, cluster, kubernetes
Published: 2022-12-28 09:56:10

---
title: Deploy a local kind cluster
published: true
date: 2022-12-19 00:00:00 UTC
tags: kind, cluster, kubernetes
canonical_url: https://blog.robertoconterosito.it/posts/deploy-local-kind-cluster/
---

This guide will help you throught the process of deploying a local [kind](https://kind.sigs.k8s.io/) cluster.

> Kind is a tool for running local Kubernetes clusters using Docker container “nodes”. Kind was primarily designed for testing Kubernetes itself, but may be used for local development or CI.

## Prerequisites

This guide assumes you have alreay installed:

- [Docker](https://docs.docker.com/get-docker/)
- [kubectl](https://kubernetes.io/docs/tasks/tools/)
- [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)

## Create a cluster

Create a kind config file called `kind-config.yaml` with the following content:

```
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
 - role: control-plane
 kubeadmConfigPatches:
 - |
 kind: InitConfiguration
 nodeRegistration:
 kubeletExtraArgs:
 node-labels: "ingress-ready=true"
 extraPortMappings:
 - containerPort: 80
 hostPort: 80
 protocol: TCP
 - containerPort: 443
 hostPort: 443
 protocol: TCP

```

Then create the cluster using the following command:

```
kind create cluster --config kind-config.yaml

```

The configured cluster is ready to accept requests on port 80 and 443.

## Install ingress controller

By default k8s does not have an ingress controller installed. To install the ingress controller run the following command:

```
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml

```

This will install the **nginx** ingress controller in the cluster (the most used ingress controller right now, but you can install many other, the only thing you have to do is to change the `ingressClassName` in your ingress resources).

## Test the cluster

To test the cluster you can create a simple deployment and a service:

```
kubectl run hello \
 --expose \
 --image nginxdemos/hello:plain-text \
 --port 80

```

Then create a file called `ingress.yaml` with the following content:

```
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
 name: hello
spec:
 rules:
 - host: hello.robertoconterosito.it
 http:
 paths:
 - pathType: ImplementationSpecific
 backend:
 service:
 name: hello
 port:
 number: 80

```

Then apply the ingress resource:

```
kubectl apply -f ingress.yaml

```

Now you can test the ingress resource using the following command:

```
curl -H "Host: hello.robertoconterosito.it" localhost

```
Cloudflare is increasing the Price - switch to Yearly to save 20%
Tags: cloudflare, cloud, news, blog
Published: 2022-12-18 23:57:30

![](https://helloacm.com/wp-content/uploads/2016/11/cloudflare-300x200.jpg)

I have 5 domains are on CloudFlare Pro. Three of them are at early bird $5.

My total current monthly fee spent on [cloudflare](https://helloacm.com/tutorial-how-to-set-up-a-api-load-balancer-by-using-cloudflare-worker/) are:
3 * $5 early bird pro = 15
2 * $20 pro = 40
[Cloudflare worker](https://helloacm.com/a-simple-rate-limiter-for-cloudflare-workers-serverless-api-based-on-kv-stores/) = 5
Which sums up to 60 - the [cloudflare worker is a usage based](https://helloacm.com/cloudflare-unexpected-high-usage-of-api-requests-how-to-avoid-surprising-billing/), but $5 is more than enough for the current traffic.

From Next May 2023, the early bird is no longer available, and the price will be increasing from 20 to 25, but you can pay yearly to keep the current price.

That means, to have 5 domains, I have to pay 1200 yearly!

![image.png](https://cdn.steemitimages.com/DQmadyzAcwjsYvmCFNoeiCWYtJWmL4YSp8kxLHx6vcxn4de/image.png)


![image.png](https://cdn.steemitimages.com/DQmQT5w6anGnyKzUqFt68CYgG1ULPzh9HpMpJRKi8bfPvCN/image.png)



<hr/>

### [Steem](https://steemyy.com) to the Moon!
You can swap the STEEM/SBD to USDT (TRC-20) via [Steem2USDT](https://steemyy.com/steem2usdt.php)
Concatenating PDF files in Linux
Published: 2023-01-06 02:55:24

---
title: Concatenating PDF files in Linux
published: true
date: 2022-12-18 23:38:44 UTC
tags: 
canonical_url: https://brandonrozek.com/blog/concatenating-pdf-linux/
---

Every so often I need to combine several images into a single PDF. First, to convert an image to a PDF we can use `imagemagick`.

```
convert -quality 100 Image.png Scanned.pdf

```

To combine or concatenate multiple PDF files, we can use `ghostscript`.

```
gs -sDEVICE=pdfwrite \
   -sOUTPUTFILE=output.pdf \
   -dNOPAUSE \
   -dBATCH \
   input0.pdf input1.pdf input2.pdf

```

| Flag | Description |
| --- | --- |
| `-sDEVICE` | Device used for processing the output file type. Use `pdfwrite` to write to a PDF file. |
| `-sOUTPUTFILE` | Path to save the resulting file output. |
| `-dNOPAUSE` | Disables the prompting and pausing at the end of each page. |
| `-dBATCH` | Finishes interpreting after processing the inputted files |

Alternatively you can use `pdftk`

```
pdftk input0.pdf input1.pdf input2.pdf \
	cat output output.pdf

```

Lastly, you can also use `imagemagick`. Do note, however, that this program often leads to larger file sizes.

```
convert input0.pdf input1.pdf input2.pdf output.pdf

```

## Aside: Pixel Densities

One issue I came across is that the pages were of different sizes. This is often because the pages can be of different pixel densities.

To check run `pdfimages` and look at the 3rd to last and 2nd to last columns:

```
pdfimages -list filename.pdf 


page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
   1 0 image 613 77 rgb 3 8 jpeg no 8 0 1071 1076 9456B 6.7%
   1 1 image 2692 3496 rgb 3 8 jpeg no 9 0 329 329 418K 1.5%
   2 2 image 613 77 rgb 3 8 jpeg no 8 0 915 919 9456B 6.7%
   2 3 image 2300 3016 rgb 3 8 jpeg no 15 0 282 282 322K 1.6%
   3 4 image 613 77 rgb 3 8 jpeg no 8 0 937 942 9456B 6.7%
   3 5 image 2356 3024 rgb 3 8 jpeg no 21 0 288 288 150K 0.7%
   4 6 image 1686 2200 rgb 3 8 jpeg no 27 0 204 204 622K 5.7%
   5 7 image 5100 7016 rgb 3 8 jpeg no 33 0 600 600 1193K 1.1%
   6 8 image 613 77 rgb 3 8 jpeg no 8 0 1104 1110 9456B 6.7%
   6 9 image 2776 3720 rgb 3 8 jpeg no 38 0 339 339 231K 0.8%
   7 10 image 613 77 rgb 3 8 jpeg no 8 0 939 943 9456B 6.7%
   7 11 image 2360 3072 rgb 3 8 jpeg no 44 0 289 289 151K 0.7%

```

We can then use `imagemagick` to enforce a certain pixel density. The tradeoff being that the file size might increase.

```
convert -density 300 input.pdf output.pdf

```

If you happen to know a different way to enforce a pixel density that doesn’t have a file size increase tradeoff. Please get in touch.
Use of borders in Tailwindcss
Tags: webdev, beginners, programming, css
Published: 2022-12-18 23:16:50

{% embed https://www.youtube.com/watch?v=LjrgL3qoBLI&t=166s %}

Tailwind CSS is a popular utility-first CSS framework that allows developers to easily build and style web applications with minimal custom CSS. One of the key features of Tailwind CSS is the ability to quickly and easily add borders to elements using its built-in border utility classes.

To use border utilities in Tailwind CSS, you can immediately declare border in class.. You can then use the border utility classes to add a border to any element on your page. For example, to add a solid 1px black border to an element, you can use the border-black-solid class.

To add a border to only one side of an element, you can use classes such as border-t-2, border-r-4, border-b-6, or border-l-8, which will add a border to the top, right, bottom, or left side of the element, respectively.

In addition to the basic border utility classes, Tailwind CSS also provides a number of options for customizing the appearance and style of your borders. For example, you can use the border-dashed, border-dotted, or border-double classes to create a dashed, dotted, or double border, respectively. You can also use the border-2, border-4, or border-8 classes to increase the thickness of your border. Finally, you can use the border-transparent class to remove the border from an element, or the border-current class to use the current color of the text as the border color.

Overall, the border utility classes in Tailwind CSS provide a simple and powerful way to add and customize borders in your web applications. Whether you need to add a basic solid border or a more complex dashed or dotted border, Tailwind CSS has you covered.

Guillaume Duhan
Codecademy: Pattern-searching project
Tags: begginer, codecademy, project
Published: 2022-12-18 22:58:10

Hello, new user here! During the codecademy introductory course to IT, one of the steps is to plan the idea of a pattern searching program, with a roadmap and flowchart, along with a pseudocode. As it is an introductory course, no pratical coding is used, though it's a rather interesting idea. Further down the road, I imagine I will be able to post a code that does pratically what this one does theoretically!

Happy to be joining the DEV.to community!

--------------------------------------------------------------------

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