teleren/devto huggingface dataset:
ftp auto upload files on change
Tags: node, ftp, automation, javascript
Published: 2021-02-20 19:34:45

---
title: ftp auto upload files on change
published: true
description: watch files for change and auto upload them on change
tags: 
- node
- ftp
- automation
- javascript
//cover_image: https://direct_url_to_image.jpg
---
Hello world, this is my first post on dev.

Today we're going to see how to watch files for change and upload them automatically to an ftp server using node.js. This is a real world project that I worked on for a client.

This article is intentionally short, feel free to open the code on this [repo](https://github.com/a-hariti/ftp-auto-upload) in second tab to follow along.

Let's think about the problem for a sec, we have 3 sub-problems:

1. First we need a way to be notified when a certain file changed.
2. Second we need to figure out how to upload a file to an ftp server.
3. And last we will tie out all together and throw in some polish for a reliable end product.

A quick look at the native `fs` module reveals that we have the method `fs.watch(directory, watchHandler)` where the watch handler takes two arguments `(event, fileName) =>{...}` and event is either `change` or `rename`, we are mostly interested in `change` here. This takes care of the first sub-problem.

For the second sub-problem, I used the polished `ssh2-sftp-client` npm package. Which has many great features, but we're interesting in uploading files, so it's basically connect `->` upload file.

The requirement for the source and destination folders needed to be specific for each file of interest. The simplest solution I found for this is a plain text file with each file on one line relying on the order of the items to represent the credentials for the ftp server and the folders. Further details are on the example `config.txt`, but it essentially looks like this: 
`filname username host port password source_folder destination_folder`.

So to answer the third sub-problem, the general flow is like this:

1. Read the files from the `config.txt` file
2. massage the data to correspond to objects we can use down the line.
3. create file watches for each folder and source folders and respond to `change` events when they concern a file from the watched files, and of course some light logging to inform the user about what's going on.

I hope you feel like you've learned something new. Don't forget check the code on [github](https://github.com/a-hariti/ftp-auto-upload) and comment any suggestions/questions you might have.
How to Close an Entire Window
Tags: window, close, tab, quit
Published: 2021-02-20 19:29:29

If you want to close all the tabs open in one window of an application (aka, close a window), use `Shift-Command-W`. (In contrast to using `Command-W`, which only closes an individual tab open in one window of an application.) Just discovered this, and it’s a life-saver. Previously, I just quit VS Code after finishing each repo to avoid ending up with a cluttered screen.
Multiline Comments and Docstrings with VS Code
Tags: vscode, python, comments, docstring
Published: 2021-02-20 19:02:43

Shortcut for multiline comments in VS Code:
`Shift` + `Alt` + `A`

This works for creating a docstring in Python, since a docstring is done in a multiline comment style. The only catch is that the entire line needs to be highlighted in order to wrap it in the triple quotes (in contrast to setting a single line as a comment, where all you need to do is have your cursor on that line then hit `Command` + `/`).

To select an entire line, you can triple click at the end of the line (your cursor must be at the end of the line), but that’s kind of annoying. There’s gotta be a better way! I believe `Command` + `L` is supposed to work, but it’s not working on mine.
How to Safely Delete All Your Node Modules to Free Up Space
Tags: npm, node, modules, delete
Published: 2021-02-20 18:58:59

1. Open the directory on your computer where all your `node_modules` will be found (just `cd` into it from the command line)
2. Run this line while within the above directory to see a list of all the node modules that it contains (along with how much space they’re taking up): `find . -name "node_modules" -type d -prune | xargs du -chs`
3. Double check that nothing in the resulting list is a surprise (for me, none of them came from folders where I hadn’t created a Node project, which is exactly what I expected); also check to see how much total space they take up (it tells you at the bottom of the list; for me, it was 9.4 GB)
4. Run this line to actually delete all the modules: `find . -name "node_modules" -type d -prune | xargs du -chs`
5. It will take a long time for the above line to execute (for me, I think it took about 10 minutes); after, check your computer’s storage (for me, sure enough, I gained about 10 GB of free space)
6. If you ever want to reinstall node modules for any repo (e.g., for an old project that you want to spruce up), just go to its folder and run `npm i` to reinstall all its dependencies (aka, node modules)

*h/t [Mark Pieszak](https://medium.com/@MarkPieszak/how-to-delete-all-node-modules-folders-on-your-machine-and-free-up-hd-space-f3954843aeda)*
Domain-Driven Hexagon: Guide on Domain-Driven Design, Hexagonal architecture, best practices (TypeScript and NestJS examples)
Tags: architecture, webdev, javascript, node
Published: 2021-02-20 18:52:53

Few months ago I've created a repository to gather some architectural patterns and best practices I've been using for the last few years, both at work and for personal projects. At first It was a project for myself, but it grew and have reached a point that I can share it and hopefully more people can learn some useful practices from it.

Main emphasis of this project is to provide recommendations on how to design software applications. In this repository are presented some of the techniques, tools, best practices, architectural patterns and guidelines gathered from different sources.

Code examples are written using [NodeJS](https://nodejs.org/en/), [TypeScript](https://www.typescriptlang.org/), [NestJS](https://docs.nestjs.com/) framework and [Slonik](https://github.com/gajus/slonik) for the database access.

Though patterns and principles presented in this repository are **framework/language agnostic**, so above technologies can be easily replaced with any alternative. No matter what language or framework is used, any application can benefit from principles described in this repository.

This project's architecture is mainly based on:

- Domain-Driven Design (DDD)
- Hexagonal (Ports and Adapters) Architecture
- Secure by Design
- Clean Architecture
- Onion Architecture
- SOLID Principles
- Software Design Patterns

And many other sources and best practices (links to additonal resources in every section).

Check out my GitHub repository to see full tutorial with code examples:
- [https://github.com/Sairyss/domain-driven-hexagon](https://github.com/Sairyss/domain-driven-hexagon)

Also, check out my other repositories:
- [Backend best practices](https://github.com/Sairyss/backend-best-practices) - Best practices, tools and guidelines for backend development.
- [System Design Patterns](https://github.com/Sairyss/system-design-patterns) - list of topics and resources related to distributed systems, system design, microservices, scalability and performance, etc.
Web Monetization Pays
Published: 2021-02-20 18:45:43

I have to share this testimony. Few weeks ago I made a blog about web monetization and how content creators can generate revenue from their content.  I am so excited to announce that my blog has started generating revenue with Coil subscribers visiting my page. Your web monetization revenue increases when coil subscribers visit your page.

Web monetization is still very new and not many people are on Coil subscription.

 
![uphold-payment2.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1613771594233/Pt-9iK4XR.png)

**Photo from my uphold account _an interledger payment pointer_**

Although, the amount is still small.  Amounts over $ 0.02 can be claimed at anytime.  Which is a step ahead of Google AdSense you don't need to wait to get $100 before you make a cash claim. Coil sends micropayment every seconds a subscriber spends on your content. Now imagine over hundred coil subscribers visiting your page. 

**Support Creators**

Support creators by getting a [Coil](https://coil.com/) membership subscription. In return you will have access to all web monetized content, strong privacy protection, ads free and exclusive content.
 Ensure you are using the  [Coil Extension](https://coil.com/#Extension-Install-Section) in viewing the content or else, it won't count.  

You can read my article on web monetization  [About web monetization](https://michy.hashnode.dev/about-web-monetization) 
  
  ***Read more from this site:*** 

 [Webmonetization](https://webmonetization.org/) 

 [Interledger Organization](https://interledger.org/) 

 [Uphold](https://wallet.uphold.com/dashboard) 

 [Gatehub](https://gatehub.net/) 
 [Coil](https://coil.com/) 
https://community.webmonetization.org/uchibeke/a-program-to-get-more-people-into-web-monetization-54j6

https://hammedbabatunde.hashnode.dev/monetizing-your-contents-as-a-content-creator

Lastly, follow me on  [Twitter](https://twitter.com/MichelleMichy_d) 

Your comments and suggestions are welcome.
Build your mobile app landing page with Olive
Tags: tailwindcss, css, javascript, webdev
Published: 2021-02-20 18:23:09

## What is Olive?
Olive is a beautiful one page template for your mobile landing page.

## How is this useful
Building a landing page for your mobile app can get very complicated. Olive aims to change this. You can focus on your business and leave the website styling effort to Olive. Olive is highly responsive on both mobile and desktop, and is easy to edit to meet your needs. Just downloaded, change it and launch your website. You can also use Olive to give your old website a new fresh look!

## Where can you get it
**You can grab olive [here](https://easyui.dev/olive)**
Usar Redis como motor de base de datos
Tags: redis, webdev, spanish
Published: 2021-02-20 18:22:19

#¿Qué es Redis?
Redis es un motor de base de datos en memoria, rápido y de código abierto, basado en el almacenamiento en tablas de hashes (clave/valor) pero que opcionalmente puede ser usada como una base de datos durable o persistente.

#¿Por qué usar Redis?
Como la información queda almacenada en memoria en lugar del disco, tendrás un acceso más rápido a la información y notarás que el tiempo de ejecución de una consulta será más corto. Los proyectos en los que se podría usar y notarías un gran resultado serían:
* Una aplicación de chat
* Listado de elementos más recientes, por ejemplo un listado que siempre se ve al entrar en una sección de la web.
* Administración de carritos de compra en tu web.
* Almacenamiento de sesiones de usuario.
* Streaming completo de contenido multimedia.
* Soporte como caché de tu página web.

#Compatibilidad de código
Redis soporta la mayoría de los principales protocolos y lenguajes de programación, incluidos:
* Python
* Java
* PHP
* Perl
* Go
* Ruby
* C/C#/C++
* JavaScript
* Nodejs

#Inconvenientes de usar Redis
Teniendo en cuenta que, por defecto, Redis se usa para guardar información en memoria y no en disco, el método de persistencia RDB consume mucho I/O (escritura en disco).

Por otro lado, si lo que necesites es trabajar con datos complejos o búsquedas complejas, Redis no es el motor de base de datos que deberías usar.
Price Prediction Of Diamonds
Tags: python, datascience, machinelearning, deeplearning
Published: 2021-02-20 18:07:12

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zf58xkjdl5oa4vxtjzpr.jpeg)

I used Decision Tree, Random Forest, Linear, K-Neighbors and XGBoost Regressions with Python. I chose the best model with the Cross-Validation method. I used the R-Squared method to check that it gives a consistent result. As a result predicted with nearly 99% success rate. There is no 'Overfitting' problem.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ysgm2u6z17v473ij6jmn.jpeg)

I used the 10-Layer Cross-Validation method. The results are below:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hbaxavw4s0elxwtf93vc.jpeg)

It is XGBoost that works best in these datas. I used this regression model for prediction.

{% gist https://gist.github.com/AlicanAKCA/8a906d0212fa335ded4b05ac4734db6c %}
Metadata based image filtering
Tags: python
Published: 2021-02-20 18:03:28

A few years ago, I went for a vacation with my friends ... bla bla bla ... and all the pictures from everyone's phones somehow landed in a single folder on my machine. For some reason I wanted them separate(I don't know why, it was a long time ago) and then what happened is why you're here reading this post.


### Tools:
* Python
* PIL library
* os library

### Key functions:
1. Use `os.listdir` to get the names of image files(requires split on `.` and check extension) in the directory.
2. Function `getCameraModel` uses `PIL.Image` and returns the camera model of image.
3. Function `copy` to copy that image file into the folder with name same as camera model (creates if doesn't exist).

Just put'em all together and you're good to go. Here's the gist.

{% gist https://gist.github.com/tshrv/443f19b1dacd3e994d6bf55b5f37c980 %}

##### and that's the story how `python` saved the day
Currency Exchange Dataset Classification & Sorting And Data Visualization
Tags: python, datascience, prediction, programming
Published: 2021-02-20 17:57:51

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qtth0f49nuir6lwsp0r4.png)
Visualizing the currency exchange dataset loaded from Api by classifying and sorting it with Python. I used different color for each year on the chart. There is about 15 years of data. It is 4082 days. Although it does not include machine learning algorithms, I have written my own data classification and visualization algorithms.
{% gist https://gist.github.com/AlicanAKCA/845cc785a127eb1f9b141c714ad1c2a9 %}
LibreOffice Calc Tips
Published: 2023-01-06 01:11:14

---
title: LibreOffice Calc Tips
published: true
date: 2021-02-20 17:37:48 UTC
tags: 
canonical_url: https://brandonrozek.com/blog/librecalctips/
---

I’ve been working with LibreOffice Calc (or Excel) spreadsheets recently and wanted to share some of the things I’ve learned.

**Absolute vs Relative Cell References**

The main difference between referencing a cell relatively vs absolute is that the absolute reference includes a `$` in the front. This is important if you want to drag a formula across multiple cells.

```
$A:$B

```

**Referring to a sheet name**

To refer to cells in another sheet, first begin the reference with the sheet name, then a period, follow by the cells you wish to reference in that sheet. If the sheet name has spaces in it, then you need to wrap it in quotes.

```
'Another Sheet'.A:B

```

**Referring to a column**

To refer to a single column, you need to repeat the column name separated by a colon.

```
B:B

```

**Get row that matches a query**

For this we’ll use the `MATCH` function. It takes three parameters:

1. The value to match
2. The range of cells to query over
3. Which comparison function to use. Use `0` for equality.

It will then return the first row number that matches the query.

```
MATCH("Bob", B:B, 0)

```

**Query a value based on another from that row.**

To do this, we will need to combine both the `INDEX` function and the `MATCH` function. The `INDEX` function takes three parameters:

1. The range of cells to reference
2. The row number
3. The column number

Use the `MATCH` function as the second argument, and you can reference another column of a row based on a query.

```
INDEX(A:B, MATCH("Bob", B:B, 0), 1)

```

**Refer to a value in a nearby cell**

With the `OFFSET` function you can refer to a cell relative to another. Its parameters are:

1. Reference Cell
2. Row Offset
3. Column Offset
4. Height
5. Width

```
# To see the value in the row above A5 (A4)
OFFSET(A5, -1, 0, 1, 1)

```

**Concatenate Strings**

Strings separated by `&` are concatenated together.

```
"Hello " & "World."

```
How I learned Python in less than a week while it takes months for many
Tags: python, learningtocode
Published: 2021-02-20 17:33:28

So, I just learned Python.

It took me a few days to pick up the syntax and build a couple of simple apps along the way.

No big deal.

So, why am I talking about this?

What people who don't know how to code (but want to learn it) mostly get wrong is that they tend to mix up a programming language with the ability to program.

There's a massive difference.

Just because someone knows the alphabet doesn't mean they can write like Shakespeare.

Anyone who knows how to code in one language can pick up the basics of another language in a week or so. Experienced engineers can read code in a language they've never seen before and mostly understand what's going on. It's quite impressive.

That's what makes learning to code in the beginning quite hard. You not only have to know the very foreign syntax, but you also have to learn the fundamental principles at the same time. So instead of learning one thing, you're learning two things.

This is why I was able to pick up Python relatively quickly. I did not have to learn the basic principles of software engineering like variables, loops, functions, control flow, etc. I already knew them. All I had to do was familiarize myself with the new (familiar-similar) syntax.

So, there's no point in stressing over the specific language. It doesn't matter.

K.

PS! Check out my wonderful website at
www.kristjanvingel.com
Shooting yourself in a foot with django and recovering from it (speeding up the API 200x)
Tags: performance, django, python, api
Published: 2021-02-20 17:25:15

I've been working on my side project in Django and I couldn't not notice that it was taking JavaScript forever to load all the info from the backend API. It could even take 30s to fetch all the data (~150 records).
![Super slow API calls](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6oedw16pgc3rp3eq7b0a.png)
 I generally hate when apps are slow and I needed to do something about. I described how I made it my faster by profiling and strategic optimizations. You can check out the post [here](https://tinystruggles.com/tech/django_slowness_traps/).
JavaScript Quizzz In Hindi
Tags: quiz, tutorial, beginners, javascript
Published: 2021-02-20 17:14:33

###JavaScript code को किसके द्वारा call किया जाता है###
1. Triggering
2. Function/method
3. preprocessor
4. element

###एक function जिसकी कोई return value नहीं होती, उसे कहा जाता है###
1. method
2. static function
3. procedures
4. dynamic function

###निम्नलिखित में से, कौन सा एक ternary ऑपरेटर है?###
1. ?
2. +
3. =
4. %

###निम्नलिखित में से किसे जावास्क्रिप्ट में error नहीं माना जाता है?###
1. syntax error
2. Division by zero
3. semicolon को ना लगाना
4. उपर दिए गये सभी

###जावास्क्रिप्ट किस प्रकार की भाषा है?###
1. high level
2. object based
3. assembly language
4. object oriented


***इन सभी सवालों के जवाब जानने के लिए निचे दिए गये लिंक पर क्लिक करे***
> ###<a href="https://quiz.stackfindover.com/quiz/javascript/" rel="dofollow">Answer</a>###


###इन्हें भी देखे:-###
> <a href="https://quiz.stackfindover.com/quiz/html/" rel="dofollow">HTML Quiz</a>
> <a href="https://quiz.stackfindover.com/quiz/css/" rel="dofollow">CSS Quiz</a>
> <a href="https://quiz.stackfindover.com/quiz/jquery/" rel="dofollow">jQuery Quiz</a>
> <a href="https://quiz.stackfindover.com/quiz/php/" rel="dofollow">PHP Quiz</a>
I delete my live prod database and have no backup
Tags: postgres, heroku, elixir, database
Published: 2021-02-20 17:10:47

Welp. That just happen. I just deleted my live production database and I don't have a backup. 

Yesterday I completed my new website [Logname](https://www.logname.dev) and decided to tell everyone I can about the website(Reddit, Hackernews etc).

After a day has passed, I want to see how many people register. Me being lazy without admin interface I figured I can login to postgres and query it directly.

I hosted it on heroku so I can just use this command `heroku pg:psql <database-name> --app <app-name>` 

I already run this on terminal so I quickly go to previous history and press enter when I see pg command.

I forgot that earlier I had run this command `heroku pg:reset <database-name> --confirm <app-name>`

So now my database has successfully reset and I have lost all of my user if any. 

Honestly I am mad as hell right now and I feel ashamed to people who tried to use my website. 

One of the reason I build this website is so that user can rely on this website to maintain their info for a long time because resume is not something u need often but urgent when needed.

To all who register to give the website a try, I'm really sorry but you need to register and insert the data again but rest assured that this won't happen again.
Why use functions?
Tags: javascript
Published: 2021-02-20 16:21:08

You could write your whole JavaScript script in one long thing. The advantage of is that you read it from top to bottom. And if you only have a few lines of code, that isn't going to be a problem. But if you have 400 lines of code, then it gets tricky (as I found out the hard way).

There are two main reasons to use functions in JavaScript (and probably other languages too, but JS is the one I'm familiar with).

### 1. So you don't repeat yourself
You may have come across the DRY, for don't repeat yourself. If you find you need to write the same block of code twice, it would be better to put it in a function. That way you've only written it once.

You might say "I'm not writing it twice, I'm copying and pasting it", but that's just semantics. Also, if you change something in that code, you have to remember to change it in both places. Maybe it's something you can easily find and replace, but maybe it's not.

It's all about cutting down the amount of work you have to do. And the number of places you might have errors.

### 2. To make it readable
Let's say your script has 400 lines of code. You don't look at it for a year, but when you come back you have to make a change. Good luck finding it! You might have to read through all the lines and figure out what they're doing. Maybe you've written good comments explaining what each bit does. But you could have replaced some of those comments with functions.

If you're reading through your code and you have this:
```
getHighScore();
displayHighScore();
playGame();
calculateHighScore();
setNewHighScore();
```
you can guess what's going on in each of those functions without having to read all the lines within them. If each of those functions contained 10 lines of code, you've just saved yourself from having to read 45 lines of code.

In conclusion: write functions.
What is translation in CSS
Tags: css, tutorial, todayilearned, codenewbie
Published: 2021-02-20 16:11:24

Happy Sunday folks,

This post is part of our "20 day CSS animation post"

{% link https://dev.to/atulcodex/20-days-of-css-animation-post-3g8d %}

In this post, we are going to learn about CSS transform value.

Basically, this property or its value is used to change the position of an element, that's it. There are some variations in his properties.

* transform: translateX(10%);
* transform: translateY(20%);
* transform: translateX(10%) translateY(20%); }

If in confusion play with this codepen, you will understand it properly.

{% codepen https://codepen.io/atulcodex/pen/mdOMMdV %}

And if you guys interested in my free website templates please download them here 👉[AtulCodex Marketplace 🏪](https://www.instamojo.com/atulcodex/).