teleren/devto huggingface dataset:
Pirrigator, part 7: Problems emerge
Tags: rust, raspberrypi, sideprojects
Published: 2019-06-10 08:33:43

---
title: Pirrigator, part 7: Problems emerge
published: true
description: Automating my greenhouse irrigation with Rust and Raspberry Pi
tags: #rust #raspberrypi #sideprojects
series: Watering tomatoes with a Raspberry Pi
---

![Tomatoes growing in the greenhouse](https://thepracticaldev.s3.amazonaws.com/i/5h0rwak91oqup0xh3q8k.jpg)

At a basic level everything has been working for a few weeks now and the plants are all growing well and looking healthy. But two major, and probably related, problems have emerged.

Firstly the battery has run low several times, causing the charge controller to cut power to the Raspberry Pi to prevent over-draining the battery. We've had pretty dull weather and a fair amount of rain for several weeks so maybe the panel just hasn't been able to provide enough energy. But I suspect another issue.

![Corroded moisture sensors](https://thepracticaldev.s3.amazonaws.com/i/8t0nosdxd0a9qndpsrz8.jpg)

The moisture sensors are corroding really quickly, lasting about two weeks before enough metal has gone to affect the readings. I think the fundamental problem here, and maybe in both cases, is I didn't build any switching into the circuit. All the sensors are powered continuously, even though I only read them very infrequently. There is a constant current flowing through those moisture electrodes powering a continuous chemical reaction with the water in the soil. Similarly the BME280 weather circuit is continually powered even though I only read it every 5 minutes. Reading takes a few milliseconds at most, so even if its energy demand is modest, 99.99% of it is wasted.

It'll be messy but I'm planning to add some additional circuitry using NPN transistors to switch the power to the sensors and control these from Raspberry PI GPIO pins - I still have a few left. A little code tweak would then switch the power on, wait an appropriate time for everything to settle, read the sensor and power it down again.

![Raspberry Pi and home-made irrigation electronics](https://thepracticaldev.s3.amazonaws.com/i/99f6i17vadaa97m13qtr.jpg)

I've also attempted a few refactors of the code and run into Rust borrowing issues. I guess this is the normal Rust learning curve, but at times it has started to feel like hard work. One particular problem I keep hitting is iterating over one part of a data structure, accessing another part inside the loop - the iterator borrows the whole thing so I can't get a second borrow in the loop body. I'm sure there's a Rust idiom to deal with this but my searches have so far come up with nothing. Clearly I need to read more of other people's Rust code.

I'll update again on the performance of modified electronics. Time is running out before we head off on holiday for a couple of weeks and I need something I can rely on by then!
Difference between Imperative and Declarative Code
Tags: beginners, vanillajs, imperativecode, declarativecode
Published: 2019-06-10 08:25:20

---
title: Difference between Imperative and Declarative Code
published: true
description: 
tags: #beginner #vanillajs #imperativecode #declarativecode
---

## Definition and Code Example:
- **Imperative** - Implementing a procedure to follow in rendering a code function. A good basic example: let's assume we have a button with id "btn" in our html file we want to add an event listener to in changing the body background, our imperative code will look something like:

```
    <button id="btn">Change bgColor</button>

     let btn = document.querySelector('#btn');
     let parent = document.querySelector('body');
     btn.addEventListener('click', () => {
        parent.style.backgroundColor = "orange";
     });
 ```


    The above code snippet is an imperative way of solving code issue. Vanilla Javascript style.

- **Declarative** - Relying on methods or packages to handle the processes involved in rendering a code function.
Also solving the above code issue in a declarative manner will look something like this.

 ```
    <button onclick="changeBgColor()">Change bgColor</button>

    <script>
        function changeBgColor() {
            let parent = document.querySelector('body');
            parent.style.backgroundColor = "orange";
        }
    </script>

 ```


    frameworks like React and Vue uses Declarative code and Vanilla old style of adding eventlisteners.

#### to be Cont'd
    Give more intermediate examples.
Protect presentation slides in Java
Tags: protect, encrypt, ppt
Published: 2019-06-10 07:36:39

---
title: Protect presentation slides in Java
published: True
description: protect and encrypt presentation slides
tags: protect, encrypt, ppt
---

With the help of [Free Spire.Presentation for Java](https://www.e-iceblue.com/Introduce/free-presentation-for-java.html), developers can protect the PowerPoint files with password or only allow the presentation slides to be read only, readers could not edit or change the contents on the slides. This article will show you how to protect the presentation slides in Java applications from the following three parts:
<ul>
<li>Encrypt the presentation slides</li>
<li>Set the presentation slides read only</li>
<li>Load an encrypted PowerPoint document and update its password</li>
</ul>
Encrypt PowerPoint file. Users have to enter the password to open and view the presentation slides.

```Java

Presentation presentation = new Presentation();
presentation.loadFromFile("Sample.pptx");

presentation.encrypt("e-iceblue");

presentation.saveToFile("output/Encrypted.pptx", FileFormat.PPTX_2010);
```


Set the presentation slides read only. Users can read the presentation slides without the password. If they want to edit the presentation, it is impossible. The presentation slides have been set as read only.

```Java
Presentation presentation = new Presentation();
presentation.loadFromFile("Sample.pptx");

presentation.protect("123456");

presentation.saveToFile("output/Readonly.pptx", FileFormat.PPTX_2010);
```
 

Modify the password of the protected PowerPoint document. Update the existing password. 
```Java
Presentation presentation = new Presentation();

//load the encrypted document with password
presentation.loadFromFile("Encrypted.pptx", FileFormat.PPTX_2010,"e-iceblue");

//Remove the Encryption
presentation.removeEncryption();
//Set the new password to encrypt the document
presentation.encrypt("Newpass");

presentation.saveToFile("output/Modifypass.pptx", FileFormat.PPTX_2010);
```
How to secure JWT token in React?
Tags: discuss, security, react, webdev
Published: 2019-06-10 07:27:57

---
title: How to secure JWT token in React?
published: true
description: JWT token security
tags: discuss, security, react, webdev
---

I have been working with Axios to React. I was wondering about the security of the JWT Token. Because whenever I request the endpoint through Axios, I have to insert my token in the front end code which is accessible in the browser. How to secure it?

[Percentage Calculator](https://www.rapidtools.co/percentage-calculator.html)
Applications or websites build with Angular Universal
Tags: angular, universal, ssr
Published: 2019-06-10 06:52:49

I've been using [Angular Universal](https://angular.io/guide/universal) for [my blog and personal website](https://samvloeberghs.be/) since I first learned about the technology in October 2016!

**What websites have you built using Angular and more specifically Universal?** What challenges did you face? How do you like it so far?

For those who haven't heard about it yet, Angular Universal is a specific technology allowing Angular applications to be rendered on the server. This gives you some major benefits, like 

- better performance and load times
- better SEO and support for crawlers
- [and many more..](https://angular.io/guide/universal#why-use-server-side-rendering)

Read more about it [here](https://angular.io/guide/universal) and [here](https://github.com/angular/universal). Fire away if you have specific questions!
How to add Android Shortcuts
Tags: android, java
Published: 2019-06-10 06:45:20

---
title: How to add Android Shortcuts
published: true
description: We will look into what shortcuts are and how to set them up in your Android project.
tags: Android, java
cover_image: https://thepracticaldev.s3.amazonaws.com/i/1ei52dgpmiizgxoz9h9g.jpg
---

{% youtube 8FMFTwpkF10 %}
First Two Weeks at Google Summer of Code 2019
Tags: gnome, gsoc, gtk
Published: 2020-04-26 11:54:29

---
title: First Two Weeks at Google Summer of Code 2019
published: true
date: 2019-06-10 06:00:00 UTC
tags: gnome, gsoc, gtk
canonical_url: https://www.ravgeet.dev/blog/first-two-weeks-at-gsoc-2019/
---

Two weeks ago, I wasn’t sure about the technology that was to be used in this project. I was completely unfamiliar with some of the tools that were to be used in this project. But I backed myself and was able to pull off the things.

Things have gone pretty good so far. I have learned a couple of new things that are going to form an important part of this project.

1. Liquid    
  - Liquid forms the basis for this website. All the conditionals and other logics are implemented with the mighty help of Liquid.
2. Pipeplines    
  - Because the website needs Continuous Integration and Deployment, Gitlab CI is a perfect tool for the same. Building efficient pipelines is going to be an important task for this website.

The landing page is the centerstage for this website and will provide routes to various other resources. I am working on some new sections and may remove/alter some of the existing ones. I looking for someone to draw some artworks/illustrations that I need on this website. If you can help with this thing, please file an issue and we will have a healthy conversation. A [wiki](https://wiki.gnome.org/Projects/GTK/WebsiteRedesign) has also been made. All the important information about the project is present here. I have forked the original project for the GTK website into my [workspace](https://gitlab.gnome.org/ravgeetdhillon/gtk-web). The website is deployed using Gitlab CI for now and can be surfed [here](https://ravgeetdhillon.pages.gitlab.gnome.org/gtk-web/).

If you have any suggestions or find an issue, please report it [here](https://gitlab.gnome.org/ravgeetdhillon/gtk-web/issues).

Lemme know if you have any doubt, appreciation or anything else that you would like to communicate to me. You can tweet me [@ravgeetdhillon](https://twitter.com/intent/tweet?screen_name=ravgeetdhillon&original_referer=https://www.ravgeet.dev/blog/first-two-weeks-at-gsoc-2019/&ref_src=twsrc%5Etfw). I reply to all the questions as quickly as possible. 😄 And if you liked this post, please [share](https://twitter.com/intent/tweet?text=Check%20out%20this%20amazing%20blog%20post%20by%20Ravgeet%20Dhillon%20sharing%20his%20thoughts%20on%20First%20Two%20Weeks%20at%20Google%20Summer%20of%20Code%202019&screen_name=ravgeetdhillon&original_referer=https://www.ravgeet.dev/blog/first-two-weeks-at-gsoc-2019/&ref_src=twsrc%5Etfw) it with your twitter community as well.
Updated opinions about Gutenberg editor
Tags: internet, gutenberg, wordpress
Published: 2019-06-11 13:57:58

---
title: Updated opinions about Gutenberg editor
published: true
tags: internet, Gutenberg, wordpress
canonical_url: https://kevinhq.com/updated-opinions-about-gutenberg-editor/
---

Last weekend, I had spare hours to try and play more with the Gutenberg editor. Some days ago, I admitted that my opinions about this changed.

Gutenberg is not that bad. Seriously.

[Continue reading Updated opinions about Gutenberg editor](https://kevinhq.com/updated-opinions-about-gutenberg-editor/)

The post [Updated opinions about Gutenberg editor](https://kevinhq.com/updated-opinions-about-gutenberg-editor/) appeared first on [kevin's tech blog](https://kevinhq.com).
Leverage AWS System Manager Sessions
Tags: aws, awssystemsmanager, development, ssm
Published: 2020-11-12 04:16:05

---
title: Leverage AWS System Manager Sessions
published: true
date: 2019-06-10 05:06:00 UTC
tags:
- aws
- awssystemsmanager
- development
- ssm
canonical_url: https://www.sheldonhull.com/blog/leveraging-aws-system-manager-sessions/
---

# Use Case

Leveraging aws system manager sessions can help with aws development, by eliminating the need to RDP for work that can be done via a PowerShell session. In addition, it can help bypass the need to use SSH tunneling, remote Windows management, or RDP hops into the final destination.

This leverages IAM Credentials, allowing consistent security management in alignment with other IAM policies, instead of having to manage another security setting like remote management would require, potentially reducing the security explore footprint.

- Quickly access an instance that normally would require an additional hop, and then evaluate
- Restart remote service without having to hop into it (or issue SSM prebuilt command docs)
- Interact in other ways that are more adhoc in nature, and don't have prebuilt SSM Documents ready to go.

## Browser

This is a great option for leveraging AWS Systems Manager web console. When you select start a session you'll be presented with the tagged instances by name that you can quickly select and start a remote session with.


Once you've started the session you'll enter into a remote prompt.

## Local Interactive Setup

I use Cmder for my main terminal, with all other terminals normally running in Visual Studio Code. If you open a Powershell session using the powershell plugin you can write your PowerShell in the editor, and the interactively run it in Visual Studio Code using the predefined `F8` key.

### Install on Windows

{% gist https://gist.github.com/sheldonhull/d2c4b009e7da1845081327121a61a05c %}

Ensure your AWS Credentials are setup, and use the session manager plugin after installation by running:

### Start Session

```
aws ssm start-session --target MyInstanceId

```

### Limitations

Refresh rate is slow. Input for large script blocks from Visual Studio Code is also really slow. This means that putting a local function in scope by running `F8` against it and then wanting to run this function interactively can take a while.

The best use case I see is for adhoc administrative or investigative work. If larger scripts are required, then having a script setup to install module or copy from s3 would be a much more performance solution, as it wouldn't require large amounts of console text streaming.
Explain MVC / MVVM / MVP like I'm five.
Tags: explainlikeimfive, webdev, discuss, controller
Published: 2019-06-10 04:57:28

---
title:Explain MVC / MVVM / MVP like I'm five.
published: true
description: Model view controller
tags: explainlikeimfive, webdev, discuss, controller
---

As a junior developer, having a depth knowledge of core concepts is essential.
I have been facing problem to comprehend the difference between MVC, MVP and MVVM. Please someone explain it to me.Thanks Dev.
Publish Your First NPM Package (Vue) - PART 2
Tags: vue, vscode, npm
Published: 2019-06-10 03:55:35

Hi Again,

So following up on yesterday's tutorial, in this one, we're going to create a git repo, push our code to it, then login to npm through the cli, then publish our package that we've created in the previous post.


### 1. Push the code to github

Go to http://github.com
Sign Up or Sign In, then click on the new repository button

![](https://thepracticaldev.s3.amazonaws.com/i/h597f911xohzzc7ya8cw.PNG)

Fill in all the details required by github and click create repository

Once that's done, we're gonna push our code to github.

But before we do that, we're going to include the dist folder in our `.gitignore` so that we don't push our build folder to github.

Open the `.gitignore` file and the following at the end

```
...
dist/
```

Now let's push our code😎

In our terminal we type the following after changing directories to our project folder

```shell
git remote add origin https://github.com/amroessam/simplealertcomponent.git
git push -u origin master
```

Now our code is pushed to our github repository.

### 2. Upload the package to npm

First thing we need to do is to log in to npm, using our terminal

```shell
npm login
```

Add your log in details 

![](https://thepracticaldev.s3.amazonaws.com/i/dzch738sl55diac81vbt.PNG)

It'll confirm that you're logged in, from here onwards, you'll be able to push to npm from your terminal

Now that we have successfully logged in, let's publish the package.

```shell
npm publish
```

If everything works well, you should get the following message

![](https://thepracticaldev.s3.amazonaws.com/i/16uqvfnycr1htrm2egbj.PNG)

You can also confirm, by going to the npm package page
https://www.npmjs.com/package/simplealertcomponent

Now the package is ready to use by simply doing an npm install.

### 3. Celebrate and write a dev.to post about how you published an awesome npm package that everyone can use 😍
At what time of a typical work day does your brain "clock out"? How do you stay productive afterwards?
Tags: productivity, career, brain
Published: 2019-06-10 02:37:13

Hey everyone. I would like to get everyone's replies to these two questions. For me personally, I find it difficult to do tedious or brain-intensive tasks after 2:30pm in my typical 9 to 5.

When this time hits, I switch gears and place my remaining energy on:

- organizing my files and folders
- learning some more JS, Vue, Git/VIM/bash commands
- listening to some professional development courses
- making sure that I didn't miss any important emails
- looking at my meeting notes for once
- actually standing up and getting some water as I proceed to shoot the wind with some coworkers

That about covers it. With that said, let's see what works for you!
Review of Coders: The Making of a New Tribe and the Remaking of the World
Tags: discuss, programming, computerscience, writing
Published: 2019-06-10 01:49:56

---
title: Review of Coders: The Making of a New Tribe and the Remaking of the World
published: true
description: A review of the book Coders by Clive Thompson and some of my favorite quotes from the book.
tags: discuss,programming,computer science,writing
cover_image: https://static01.nyt.com/images/2019/04/05/books/review/05Bowles3/05Bowles3-facebookJumbo-v2.jpg
---

I recently finished *[Coders: The Making of a New Tribe and the Remaking of the World](https://www.amazon.com/Coders-Making-Tribe-Remaking-World/dp/0735220565)* and was really impressed with how Clive covered the history of coding culture. I first learned about *Coders* after reading [this guest post](https://tim.blog/2019/03/21/learn-to-code/) on Tim Ferriss' blog. I put my favorite quotes from the book in this [Coda doc](https://coda.io/d/Favorite-Quotes-from-Coders_d9y6Z_HXoiX/_sum4A).

[![Coders quotes Coda doc](https://cl.ly/1458720c5cb9/Screen%20Recording%202019-06-09%20at%2008.32%20PM.gif)](https://coda.io/d/Favorite-Quotes-from-Coders_d9y6Z_HXoiX/_sum4A)<figcaption><em>Coders quotes in Coda</em></figcaption>

##It's all about efficiency
One takeaway I got from the book was the need coders have for efficiency. Clive writes about this quite a bit in various other articles, but one thing the book drove home is when coders get out of the *flow*. I think this applies to anyone who does deep work and is more or less in the zone. Nothing is worse than when you are in the middle of something in the weeds and someone asks you a question that pulls you out of that context.

##Women were the original coders
I found this part of the book really fascinating since I didn't understand the gender dynamics of women and men engineers from the 60s and 70s. Back in the day, men were more focused on the bare metal, and considered software beneath them. What's more manlier than building a physical machine, right? This opened the door to women pouring into software jobs and women grokked the machines better than men did since they had to know how the physical machine would build and compile their code. 

##You either have scale or a lifestyle business
I think the book shined some light on the dichotomy of building something for the joy of building and building something to reach millions of people. Some people believe that if you build software and release it to through the Interwebs, it should get used by millions of people. Otherwise, it's not worth working on at all. Those who believe in this perspective would also say that anything besides massive scale means you have a "lifestyle business." I firmly believe that we should build things for the sake of experimentation, fleeting interests, and whim. Most projects you work on shouldn't see the light of day but the process is what keeps me coming back to banging my head on the keyboard until I get some code to run without bugs.
PowerShell Core | Update-Help | Get-Help | CentOS
Tags: powershell, centos7, howto, linux
Published: 2019-11-17 17:25:34

---
title: PowerShell Core | Update-Help | Get-Help | CentOS
published: true
date: 2019-06-10 01:26:22 UTC
tags: powershell,centos7,how-to,linux
canonical_url: 
---

Utilizando o help do PowerShell no Linux

![](https://cdn-images-1.medium.com/max/1024/1*yBLUGiGgK4FBVu-_7jSzPA.jpeg)<figcaption>PowerShell Core + Imagem do Tux . Ewerton Jordao</figcaption>

E ae, beleza, pessoal ? Vou demonstrar como obter ajuda no PowerShell, o passo a passo se aplica a todos os sistemas operacionais que o PowerShell suporta, porem nessa demonstração estou em um ambiente Linux(CentOS).

O Help no PowerShell pode ser muito valioso para entender o que o cmdlet faz sem a necessidade de ficar fazendo consultas na internet, com o help consigo saber quais os parâmetros devemos informar para o funcionamento do cmdlet e quais os tipos de dados os parâmetros aceitam.

Para acessar o help offline precisamos executar o comando Update-Help este comando faz o download da documentação dos cmdlets.

![](https://cdn-images-1.medium.com/max/1024/1*MDGwTNbmsOj7Sq6OVoHzVA.png)<figcaption>Executando o comando Update-Help</figcaption>

Obs: o comando de update faz uma serie de downloads porem não consegui capturar no print 😅.

Feito o download, vamos agora consultar de fato o help com o comando Get-Help \<cmdlet que desejo obter maiores informçoes\>.

![](https://cdn-images-1.medium.com/max/1024/1*3cX56Hpm7PLzNcxLMIkvkg.png)<figcaption>Retorno do help para o cmdlet Install-Module.</figcaption>

Podemos retornar informações detalhadas do Install-Module utilizando o **switchparameter -Detailed**.

![](https://cdn-images-1.medium.com/max/1024/1*gigE-mvSfts82Ft62ymgtQ.png)

![](https://cdn-images-1.medium.com/max/1024/1*K_EvdxWpjSPF0u1Qdmgo9w.png)<figcaption>Retorno do Get-Help -detailed</figcaption>

Podemos pesquisar pelo cmdlet e especificar qual o parâmetro quero entender melhor utilizando o -Parameter .

![](https://cdn-images-1.medium.com/max/917/1*f_Wl6uCu2ehpRZe7daufnA.png)<figcaption>Retorno do Get-Help &lt;cmdlet&gt; -Parameter &lt;parametro&gt;</figcaption>

No exemplo abaixo podemos retornar os exemplos de como utilizar o cmdlet utilizando o **switchparameter -Examples**  .

![](https://cdn-images-1.medium.com/max/1024/1*LmraPnSDkFZLyaEJOuTYEw.png)<figcaption>Get-help get-process -examples</figcaption>

E por fim podemos requisitar a pagina do help online.

![](https://cdn-images-1.medium.com/max/1024/1*mJ6At6ObM8L92iWbHUuM3Q.png)<figcaption>Get-Help get-process -Online</figcaption>

Por default o PowerShell vem com o mínimo de informação no help para ser compatível com dispositivos que tem pouco espaço de armazenamento como por exemplo Raspberry, o update do help salva as informações no shell e pode ser necessário elevação de privilégios para conseguir realizar o download completo do help.

É isso, pessoal. Em caso de duvidas: Get-Help 😄.

Não se esqueça, **PS é vida**  😍.