teleren/devto huggingface dataset:
Go Crash Course XI: Pointers
Tags: go, beginners, programming
Published: 2021-06-04 01:01:14

## Pointers

If you are coming from something like c or c++ you should be familiar with pointers. Go has pointers too. A pointer is a memory address of a variable. 

```go
i := 10
fmt.Println(&i)
n := &i
fmt.Println(n)
fmt.Println(i)
*n = 15
fmt.Println(i)
```

There are a few things going on in these few short lines of code. 

### Address of a variable

We can access the address of a variable with `&` operator. Here we have a variable `i` so `&i` gives us the memory address of `i`.

### Pointer type

We create a new variable `n` with the value `&i`. If we check the type of `n` with `fmt.Printf("%T\n", n)` we will see the type is `*int`. 

### Pointer De-referencing

If we have a value of pointer type how do we get the actual value the pointer is pointing to? Thats where pointer de-referencing comes into play. We already seen an example of that actually. 

```go
*n = 15
```

We de-reference `n` with the `*` operator to access the underlying value and assign `15` to it. 

### Passing pointers to function

If we want to persist the change to a variable passed to a function we need to pass it as pointers. 

```go
func pointer(x *int) {
	*x = 10
}

func value(x int) {
	x = 10
}

func main(){
	a := 5
	fmt.Println(a) // value is 5
	pointer(&a)
	fmt.Println(a) // value is 10
	a = 5
	fmt.Println(a) // value is 5
	value(a)
	fmt.Println(a) // value is still 5
}
```

The same goes for arrays and slices as well. If we pass an array as value and make any changes to it, it wont persist.

```go
func arrval(a []int) {
	a = append(a, 5)
}

func arrpointer(a *[]int) {
	*a = append(*a, 5)
}

func main() {
	ar := []int{1, 2, 3, 4}
	fmt.Println(ar) // [1 2 3 4]
	arrval(ar)
	fmt.Println(ar) // [1 2 3 4]
	arrpointer(&ar)
	fmt.Println(ar) // [1 2 3 4 5]
}
```

One of the main exceptions to this is map. If we pass a map to a function. Map types are pointers by default. We will discuss this further when we talk about maps.

### Pointer receivers

On methods we can have pointer receivers. If a type has a pointer receiver method any changes to the type in the method will persist. This was covered in the section about methods and partly in interfaces. 

## Next Steps

This is Part 11 of this Go crash course series.
Consensus Algorithms
Tags: blockchain, crypto
Published: 2021-06-04 00:25:07


I am going to discuss consensus algorithms. Lets first define what that is. I found this definition off of Geeks for Geeks website. A consensus algorithm is a procedure through which all the peers of the blockchain network reach a common agreement about the present state of the distributed ledger. The consensus protocol makes sure that every new block that is added is the one and only version and is the truth that is agreed upon all the nodes in the network.

Therefore, we have a lot of different  consensus algorithms that various blockchains use. For example, bitcoin uses Proof of work(Pow) and you probably have heard that this involves miners that has to solve a equation and gets paid bitcoin for doing so. This involves a 51% consensus and this is all done with nodes that are all over the world. This is a pretty cool mechanism. 

There are two main drawbacks to proof of work. The first is waste of energy, this is bad for the environment with all of the electricity that is used. The second major drawback is security. Proof of work provides good security only if there is a large network. 

This brings us to the various algorithms that various blockchains have been trying to implement to solve this problem, either by  building new blockchains or building blockchains that can be shared amongst other blockchains.

**Here are a list of Consensus Algorithms** 

 - Proof of work
 - Proof of stake
 - Delegated  Proof- of -Stake
 - Leased  Proof-of-Stake
 - Proof of Elapsed Time
 - Practical Byzantine Fault Tolerance
 - Simplified Byzantine Fault Tolerance
 - Delegated Byzantine Fault Tolerance
 - Directed Acyclic Graphs
 - Proof-of-Activity
 - Proof-of-Importance
 - Proof-of-Capacity
 - Proof-of-Burn
 - Proof-of-Weight
 
You can look up all of those and see how they work. You can see that any algorithm has drawbacks. Sometimes you are sacrificing security or decentralization. I see companies building off of other protocols providing strength in areas that are weaker. For example, Polygon uses Ethereum's security while providing functionality in other aspects. 

Happy coding!
switch statement
Tags: beginners, javascript
Published: 2021-06-01 05:20:29

**syntax**:
switch(x) {
  case 'value1':  // if (x === 'value1')
    ...
    [break]

  case 'value2':  // if (x === 'value2')
    ...
    [break]

  default:
    ...
    [break]
}
**Switch**
Switch statement is a part of JavaScript "Conditional" Statements, which are used to perform different actions based on different conditions. Use switch to select one of many blocks of code to be executed. ... without break, if condition is true the all the next block will be executed .If no case is matched then the default code is executed (if it exists).

e.g.
let add = 1 + 3;

switch (add) {
  case 3:
    alert( 'small' );
    break;
  case 4:
    alert( 'Correct' );
    break;
  case 5:
    alert( 'big' );
    break;
  default:
    alert( "no values" );
}

In the above example  switch start to compare add to first case which is 3 .The match fails now it will the second case which is 4.well That's the correct match.so the execution start from match 4 until the nearest break.
Note:If there is no break then the execution continues with the next case without any checks.

**Grouping of “case”**

if we want the same code to run for case 3 and case 5:

let add = 3||5;

switch (add) {
  case 4:
    alert('wrong!');
    break;
  case 3: // (*) grouped two cases
  case 5:
    alert('right!');
    alert("3 or 5");
    break;
  default:
    alert('not matched" );
}

I hope you will get the idea from a  example above.

**Type matters:**
Let’s make a point of that the equality check is always strict. The values must be of the same type to match.

e.g.

let n= prompt("Enter a  number");
switch (n){
  case '0':
  case '1':
    alert( 'One or zero' );
    break;

  case 2:
    alert( 'not a string ');
    break;

  case 3:
    alert( 'Nnot a string');
    break;
  default:
    alert( 'no match');
}

For 0, 1, the first alert runs.

But for  2 and 3 the result of the prompt is a string "2" "3", which is not strictly equal === to the number 2 or 3.So we’ve got a dead code in case  in  both Thus default variant will execute.
how to be more confidence! 

Tags: backend
Published: 2021-06-04 00:20:09

I start learning coding before 2 years ago and start working as backend developer since 10 months. I start learning javascript and when started my career I got introduced to AWS, terraform…, before that i have never heard anything about them.
now i feel disappointed most of the time because it’s really hard to me to follow other team members. Sometimes they asking me about my opinion about some stuff and i really don’t know what to say. I like what I’m doing and i working so hard to learn, but some times i feel that  i will lose the job which i like and also so afried to of losing the salary. Is there any advice or have any one experienced this feeling
Tackle that Big Task
Tags: advice
Published: 2021-06-04 00:11:49

Sometimes a programming task (or really any task) feels like a really big unknown. The thing to do at that point is to break it down into a bunch of smaller unknowns.

Go through them one at a time by exploring, experimenting, and learning so that each one is no longer an unknown. After a bit of this, you may want to revisit the big unknown.

The first thing you'll notice is that it is not so big anymore. The second thing you might notice is that what you now know changes your perspective on the problem. You realize the original trajectory you had when it was one big unknown was a bit off target.

This is an opportunity to adjust. This reframing will lead you to ask new and different questions. It will send you down the path of unlocking another set of small unknowns that propel you forward.

Big, daunting tasks can kill momentum. Breaking those big tasks down and making steady progress creates momentum.
🚀 Puppet Content Templates 0.1.0 🚀
Tags: pdk, development, pct
Published: 2021-06-04 16:29:26

---
title: 🚀 Puppet Content Templates 0.1.0 🚀
published: true
date: 2021-06-04 00:00:00 UTC
tags: pdk,development,pdk,pct
canonical_url: https://puppetlabs.github.io/iac/pdk/development/2021/06/04/pct-early-release.html
---

# ✨ PDK Puppet Content Templates 0.1.0 released ✨

We are proud to announce the first release for the new PDK templating system: **Puppet Content Templates (PCT)**.

**Puppet Content Templates** codify a structure to produce content for any Puppet Product that can be authored without direct oversight of the Puppet PDK team.

To get started download the release from the [pdkgo repo](https://github.com/puppetlabs/pdkgo/). A step by step guide is included in the README.

> ⚠️ PCT is currently in an EXPERIMENTAL phase and feedback is encouraged via [pdkgo/discussions](https://github.com/puppetlabs/pdkgo/discussions). ⚠️

## Create all types of content 🎨

A **PCT** can create any type of a Puppet Product project. You can create Puppet [control repos](https://github.com/puppetlabs/control-repo), Puppet [modules](https://puppet.com/docs/puppet/7/modules_fundamentals.html), Bolt [projects](https://puppet.com/docs/bolt/latest/projects.html), and more!

A **PCT** can also create one or more independent files to be used inside a project. You can create Puppet [classes](https://puppet.com/docs/puppet/7/lang_classes.html), [facts](https://puppet.com/docs/puppet/7/fact_overview.html), [functions](https://puppet.com/docs/puppet/7/functions_ruby_overview.html), or other tooling configuration files such as CI files, gitignores, or rubocop.yml.

Since a PCT is external to the PDK code base, Puppet Product teams, Partners and the wider OSS Community can publish their own content without input or effort from the DevX team. This enables a single tool to support many products.

## Building blocks 🧱

A set of individual **PCTs** can be combined to produce something as simple as a Puppet module with several Puppet classes or as complex as a complete Puppet Control repo with roles and profiles ready to deploy.

We want to enable a building block experience. An experience where you can pick and choose from an array of templates to build the content you want. We aim to be like your favorite building block toy, where you choose your components and end up with a wonderful structure.

An opt-in experience, where you choose what is added to your content, instead of dealing with a long list of files you’ll never use.

## Customizable 📐

Each **PCT** comes with parts that can be controlled via configuration. These parts have common defaults, but can be changed to suit your environment. The idea is to enable quick deployment of templates, but allow customization to suit your needs.

This user can customize how PCTs operate by using YAML files and never need to know how to make a template.

If you want a more drastic change, you can copy the **PCT** and add your own files and changes, then use that **PCT** without having to get a pull request approved.
IAC & DevX Updates; beta software and community engagement
Tags: team, status
Published: 2021-06-04 22:38:59

---
title: IAC & DevX Updates; beta software and community engagement
published: true
date: 2021-06-04 00:00:00 UTC
tags: team,status
canonical_url: https://puppetlabs.github.io/iac/team/status/2021/06/04/status-update.html
---

## Community Contributions

We’d like to thank the following people in the Puppet Community for their contributions over this past week:

- [`puppetlabs-java_ks#370`](https://github.com/puppetlabs/puppetlabs-java_ks/pull/370): “(MODULES-11067) Fix keytool output parsing”, thanks to [durist](https://github.com/durist)
- [`puppetlabs-kubernetes#519`](https://github.com/puppetlabs/puppetlabs-kubernetes/pull/519): “Allow configuring of waiting times during sa creation”, thanks to [ZloeSabo](https://github.com/ZloeSabo)
- [`puppet-strings#276`](https://github.com/puppetlabs/puppet-strings/pull/276): “README.md: update link to docs”, thanks to [kenyon](https://github.com/kenyon)

Check [all the ways to reach us](/iac/team/2021/01/20/reaching-out.html) if you want to directly contact us about anything module related.

## New Module / Gem Releases

The following modules were released this week:

- [`puppetlabs-vcsrepo`](https://github.com/puppetlabs/puppetlabs-vcsrepo) (`5.0.0`) - this is a re-release of the 4.0.1 code unchanged to signify that this version contains a breaking change. Apologies for the confusion.

### Cloud CI Update

The work on our P.o.C for developer box provisioning is making progress. We have managed to reduce a couple vulnerabilities with the help of the security team and we have started work on the configuration improvements needed to limit developer box provisioning.

### PCT 0.1.0 Experimental Release

The DevX team are pleased to announce the availability of our new prototype for Puppet Content Templates (PCT)! Version `0.1.0` is a pre-release and still very much experimental, however, we’d love to hear feedback on how the new experience is in creating Puppet content. Check out [James’s](https://github.com/jpogran) [blog post](/iac/pdk/development/2021/06/04/pct-early-release.html) for all the details, including how to download and install it and provide feedback.

### Trusted Contributors is now live!

Not to brag too much, we have some pretty good Puppet developers within our team. But maintaining high quality modules is more than just knowing how to write code to manage the right configuration files. Often knowing the idiomatic usage patterns is even more important. The domain experts are those who use our modules and the technology stacks those modules manage. They know what kind of functionality the module might need, or why it should work one way and not the other. The new [Trusted Contributors](https://puppet.com/ecosystem/trusted-contributors/) program empowers these experts to help make a difference with partial ownership and the ability to participate in roadmap direction. Read more about it and apply [here](https://puppet.com/ecosystem/trusted-contributors/).
Why do you estimate?
Tags: estimates, noestimates, team, practices
Published: 2021-06-06 06:50:24

---
title: Why do you estimate?
published: true
date: 2021-06-04 00:00:00 UTC
tags: estimates,noestimates,team,practices
canonical_url: https://jhall.io/archive/2021/06/04/why-do-you-estimate/
---

Discussions of “proper” estimation are en vogue again. Maybe they always have been, and I’ve just noticed again.

There’s a lot of cargo-culting with questions like “Should I use T-shirt sizes or the Fibonacci sequence to size tasks?” and “Should we use story points or hours?”

There’s also a lot of contrary posts with hashtags like #noestimates, claiming that estimates are all doomed to fail, so you shouldn’t even try.

But what both sides tend to usually overlook is the reason for estimating.

Unless or until you know _why_ you want to estimate something, any effort, even with the aide of a time machine that can reveal perfect predictions, will be a waste.

If you knew with 100% certainty that Task A would take 3.6 hours, and Task B would take 19 minutes, what would you do differently?

If you can’t answer this question, then estimates are are of no value to you.

On the other hand, if you do have an answer to that question, then you know how much of an estimate you actually need. Consider some (very simple) examples that could apply to these two imaginary tasks:

1. Both tasks accomplish the same goal, so we’ll select the faster one.
2. Both tasks have the same business impact, so we’ll do the faster one first, to reap the business benefits sooner.
3. We only have 2 hours before the demo. Anything that takes longer isn’t worth doing.
4. We need to do both tasks regardless. The order doesn’t matter.

With these goals in mind, we can reach entirely different conclusions about how (and if) to estimate:

1. We don’t need to know the absolute time for both tasks. We just need to know which is easier/faster. This is probably known intuitively without any real discussion.
2. Same as #1. We’ll do both tasks, but we probably know intuitively which to do first.
3. It’s probably intuitively clear than Task B can be done before the demo. Maybe we need to discussion Task A for a while to determine if it’s worth doing before the demo.
4. The estimates make no difference, so skip that, and just start working.

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
9 Tips for Tech Demo Teams
Tags: programming, testing, testdev, webdev
Published: 2021-06-03 23:45:48

Hi all,

After holding a demo of a new entrepreneurship app with our team, I was inspired to write an <a href="https://medium.com/geekculture/9-tips-for-tech-demo-teams-c22ffb4d099f?sk=ebe1f6d501cb8728e7900cb55d9fed71"> article</a> for teams who are planning to give a tech demo. The tips that I discuss in detail are the following: 

* Identify the audience.
* Discuss the features you will focus on.
* Plan out how to handle critical questions.
* Test the features you plan to demo relentlessly.
* Establish roles.
* Work out the logistics.
* Set limits on preparation.
* Stay flexible under adversity.

Let me know what you think of it and I hope it helps with your demo planning.

<a href="https://medium.com/geekculture/9-tips-for-tech-demo-teams-c22ffb4d099f?sk=ebe1f6d501cb8728e7900cb55d9fed71">9 Tips for Tech Demo Teams</a>, Geek Culture
June 3rd, 2021: What did you learn this week?
Tags: weeklylearn, discuss, weeklyretro
Published: 2021-06-03 23:28:47

It's that time of the week again. So wonderful devs, what did you learn this week? It could be programming tips, career advice etc.

<center>

![Yoda wooping someone's butt](https://media.giphy.com/media/yDYAHbqe5DfyM/giphy.gif)
</center>

Feel free to comment with what you learnt and/or reference your TIL post to give it some more exposure.

{%tag todayilearned %}

And remembered, if something you learnt was a big win for you, then you know where to drop it as well.👇👇🏻👇🏼👇🏽👇🏾👇🏿

{%link https://dev.to/devteam/what-was-your-win-this-week-4ko9 %}

<center>

![Little kid making a fist as if to say "Yes!"](https://media.giphy.com/media/6brH8dM3zeMyA/giphy.gif)
</center>
How to run a cron as a non-root user in Docker 🦾
Tags: development, docker, linux, security
Published: 2021-06-29 19:32:18

---
title: How to run a cron as a non-root user in Docker 🦾
published: true
date: 2021-06-03 23:15:00 UTC
tags: development, docker, linux, security
canonical_url: https://www.benjaminrancourt.ca/how-to-run-a-cron-as-a-non-root-user-in-docker
cover_image: https://www.benjaminrancourt.ca/images/how-to-run-a-cron-as-a-non-root-user-in-docker.jpg
---
Yesterday, I was looking to add a **cron** to an existing **Docker** image, but it took longer than I would like. Even though I previously had a [recipe for adding a cron to a Docker image](https://www.benjaminrancourt.ca/run-a-cron-job-with-docker), I had **new contraints** that made this solution unsuitable... 😐

Let's go over all the constraints I had:

- Using a Debian-based image
- The user running the image is a unprivileged user
- The cron is not the only process
- There is an entrypoint script

After searching on the internet, I finally found a working solution with the help of this [Stack Overflow answer](https://stackoverflow.com/a/54356073). So if anyone needs it, this article could serve as a reference. 😁

I hope again it will helps you as well! 😎

## Dockerfile

Make sure to replace `APPLICATION` by the directory you want and `NON_ROOT_USER` by the name of your unprivileged user. 😉

```Dockerfile
# https://hub.docker.com/_/debian
FROM debian:buster-20210511

WORKDIR /opt/APPLICATION

# https://packages.debian.org/search?suite=buster&keywords=cron
# Install packages for our application
RUN apt-get update && apt-get -y install \
    # Cron to periodically restart some services
    cron=3.0pl1-134+deb10u1 \
	&& echo "*/5 * * * * /opt/APPLICATION/restart.sh > /proc/1/fd/1 2>&1" >> /etc/cron.d/restart-cron \
    # Give the necessary rights to the user to run the cron
    && crontab -u NON_ROOT_USER /etc/cron.d/restart-cron \
    && chmod u+s /usr/sbin/cron

COPY --chown=NON_ROOT_USER:NON_ROOT_USER . .

USER NON_ROOT_USER

ENTRYPOINT ["./entrypoint.sh"]

```
<figcaption>Minimal code of a custom Docker image with a cron.</figcaption>
## entrypoint.sh

```bash
#!/bin/bash
echo "Start cron"
cron
echo "cron started"

# Run forever
tail -f /dev/null
```
<figcaption>A simple entrypoint script that launchs cron.</figcaption>
## restart.sh

```bash
#!/bin/bash
echo "Restart the services..."

# ...

echo "Services restarted."
```
<figcaption>A custom script that will be executed at a certain frequency.</figcaption>
Day 380 : Push through
Tags: hiphop, code, coding, lifelongdev
Published: 2021-06-03 22:20:50

_liner notes_:
- Professional : Pretty productive day. Had a couple of meetings. Followed up with some folks. Finally submitted a rough draft of the blog post I've been working on to the SDK team.

- Personal : Went through a bunch of tracks for this week's radio show. Afterwards, I hit a wall on trying to figure out how to get a push notification when clicked to go to a website working. So yeah, that happened.

![A view from atop a hill in Paptsdorf, Germany overlooking a field with some houses, forests, and other mountains at sunset.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zbptm5yu2broxkhgykwl.jpg)

Hopefully get this push notification issue worked out. Definitely need to push back the start of the project's launch. I'm going to work on other stuff on the site and go back to the notifications issue and see if I can push through. May work on the radio show for this week also. I can't believe it's already Thursday!

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube TaeYhVWJ5A8 %}
Get 35% Off For Your Next Landing Page
Tags: html, webdev
Published: 2021-06-03 22:02:28


**We are excited to share 35% discount for the first 10 Dev.to customers.** We have designed Frontendor with the goal to be flexible, highly customizable but intuitive and easy-to-use.


👉🏻👉🏻 Grab the deal today: https://gumroad.com/l/F50/devto

👉 Why Frontendor:
✅ 100+ UI Blocks/Sections.
✅ 8+ Beautiful Templates.
✅ Online Copy-Paste Tool.
✅ Built Using Bootstrap.
✅ Supports all browsers.
✅ Use on unlimited projects.
✅ Free Updates & Support.
✅ Loved by many customers. We're rated 5/5 stars on Gumroad.

Everything designed and coded to be easy to customize. Customize your fonts, colors, and spacing in 5 min with CSS variables.

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

Each block has its own HTML & CSS, COPY-PASTE these blocks to any existing codebase without conflicts.

👉 6 more reasons why you should invest in this package:
✅ No hassles, No need to think about design and inspiration.
✅ Best for startups, product makers, and marketers.
✅ Save time, don't develop everything from scratch.
✅ Online library to make it more fun and organized task.
✅ Excellent user experience in both mobile & desktop.
✅ Not satisfied, money-back guarantee.


👉🏻👉🏻 Grab the deal today: https://gumroad.com/l/F50/devto

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

Thanks for reading this😻