teleren/devto huggingface dataset:
Golang: Authenticate Your vault sdk with Kubenetes
Tags: vault, go, kubernetes
Published: 2021-09-17 14:06:46

## Why we should authenticate vault with Kubenetes
When are running our application in Kubenetes pods then we can directly connect vault and pod which will create a token inside the pod at specific location.
So to access the data from vault we need to generate the token with Kubernetes token.
`Benefit`: The main benefit of this method is that we don't need the static token for vault.


## Example
```go
package main

import (
	"context"
	"encoding/json"
	"fmt"

	"github.com/go-resty/resty/v2"
	"github.com/hashicorp/go-hclog"
	"github.com/hashicorp/vault/command/agent/auth"
	vaultKube "github.com/hashicorp/vault/command/agent/auth/kubernetes"
)

// const can be created for these variables
var kubeTokenVaulPath = "{{your kubernetes vault token file path}}"
var KubeTokenRole = "{{your kube token role}}"
var vaultAddr = "{{your vault address}}"
var mountPath = "/v1/auth/{{path for Kv}}"

type VaultAuth struct {
	ClientToken string `json:"client_token"`
	Accessor    string `json:"accessor"`
}
type CredOutput struct {
	Auth VaultAuth `json:"auth"`
}

func main() {
	appLogger := hclog.New(&hclog.LoggerOptions{
		Name:  "my-app",
		Level: hclog.LevelFromString("DEBUG"),
	})

	auth, err := vaultKube.NewKubernetesAuthMethod(&auth.AuthConfig{
		Logger:    appLogger,
		MountPath: vaultAddr + mountPath,
		Config: map[string]interface{}{
			"role":       KubeTokenRole,
			"token_path": kubeTokenVaulPath,
		},
	})

	if err != nil {
		panic(err)
	}

	// this functions returns
	// path which is the url where we need to request
	// header it will generate the headers required for the request
	// body - it will generated the body token request
	path, header, body, err := auth.Authenticate(context.Background(), nil)
	if err != nil {
		panic(err)
	}
	fmt.Println(path, header, body)

	// I am using Resty because direct vault request client was not working
	client := resty.New()
	resp, err := client.R().
		SetBody(body).
		Post(path)
	if err != nil {
		panic(err)
	}
	fmt.Println("output", string(resp.Body()))

	// creds will be the object where we will get
	// the token generated for vault to access data
	creds := CredOutput{}
	json.Unmarshal(resp.Body(), &creds)
	fmt.Println("final obj", creds)
}

```
We need to define these 4 params in order to generate the token for vault from Kubernetes pods token.
```go
var kubeTokenVaulPath = "{{your kubernetes vault token file path}}"
var KubeTokenRole = "{{your kube token role}}"
var vaultAddr = "{{your vault address}}"
var mountPath = "/v1/auth/{{path for KV}}"
```
`mountPath`: will be used to generate the token path. 
Vault have default path with the name `secrets for KV path`



I am Resty client because vault's NewRequest was not working.
Look at how we can use vault's inbuild rawRequest method but wasn't working for me.
`Not Recommended As of Now`
```go
req := client.NewRequest("POST", path)
req.SetJSONBody(output)
resp, err := client.RawRequest(req)
```
Phalcon 5.0.0alpha6 Released!
Tags: phalcon5, release
Published: 2021-09-17 14:18:44

---
title: Phalcon 5.0.0alpha6 Released!
published: true
date: 2021-09-17 14:01:17 UTC
tags: phalcon5,release
canonical_url: 
---

We are very happy to announce the release of Phalcon v5.0.0 Alpha 6!

[Github Tag](https://github.com/phalcon/cphalcon/releases/tag/5.0.0alpha6)

> This release requires PHP 7.4 or PHP 8.0

This release comes a bit earlier than expected but it was necessary.

As we continuously evaluate our processes and fine tune them, we discovered that uploading a new release to PECL was becoming a bit more difficult. Ruud who was responsible for this has recently had an elevated workload and as such could not attend to the task in a timely manner. We therefore requested a brand new account from PECL to ensure that we have a backup account, in cases such as this one.

The new account has been approved and we had to make a change to the maintainers section of the `package.xml` file (what PECL needs) to ensure that everything is in order.

Additionally, we fixed some bugs yay!

Huge thanks to our contributors that reported issues, offered input as well as submitted pull requests with additions and corrections!

NOTE: You can always check our roadmap and the status of our active sprint for v5 in our project page: [https://github.com/orgs/phalcon/projects/4](https://github.com/orgs/phalcon/projects/4)

# Changelog

# [5.0.0alpha6]

## Changed

- Adjusted the constructor for `Phalcon\Storage\Adapter\*` and `Phalcon\Cache\Adapter\*` to allow an empty key prefix to be set if needed. [#15480](https://github.com/phalcon/cphalcon/issues/15480)
- Changed: 
  - `Phalcon\Db\Adapter\AdapterInterface:lastInsertId()` to be identical as `Pdo:lastInsertId()`
  - `Phalcon\Db\Adapter\AdapterInterface:close()` now returns `void` instead of `bool`
  - `Phalcon\Db\Adapter\AdapterInterface:connect()` now returns `void` instead of `bool` and 1st argument default value is empty `array` instead of `null` [#15659](https://github.com/phalcon/cphalcon/issues/15659)

## Added

- Added `Phalcon\Security\JWT\Builder::addClaim` for custom JWT claims. [#15656](https://github.com/phalcon/cphalcon/issues/15656)
Generate Magento admin access token via Postman.
Tags: magento, api, ecommerce, postman
Published: 2021-09-17 13:45:24

Deep dive into the world of the eCommerce giant Magento with this article.

#magento2 #apiautomation #devdocs #postmanapi #accesstoken
#testing #knowledgesharing

Don't forget to follow me if you find it useful.

Salud 🍻
https://medium.com/@prathore28647/how-to-generate-access-token-for-magento-admin-via-postman-d97099d63493
Timer in GitHub CLI
Tags: github, programming, productivity
Published: 2021-09-17 13:43:56

The new GitHub CLI 2.0 includes extensions now.

I always wanted to have a timer or stopwatch in my terminal. This will allow me to use it to timebox my tasks and increase my productivity by minimizing switching from a terminal to a different timer application, like browser, and back to terminal.
It will be also cool if this timer can be big enough on the screen, so I can use it as a timer for my demo sessions to let attendees know how much time left for a break.

So, I decided to build it as a GitHub CLI extension. This will allow me to use it easily in all of my machines.

You can find it on GitHub: 
[https://github.com/anmalkov/gh-timer](https://github.com/anmalkov/gh-timer)

## How to install

First of all you have to install GitHub CLI 2.0, if you don't have it yet. Install [GitHub CLI](https://cli.github.com) now.

After that you can install gh-timer extension:

`gh extension install anmalkov/gh-timer`

## options

`gh timer [units] [number] [mode] [clock]`

#### [units]
`-s, --sec` - seconds

`-m, --min` - minutes

#### [mode]
`-w, --stopwatch` - use a stopwatch mode, otherwise use a timer mode

#### [clock]
`-b, --big` - show a big clock, otherwise show a small clock

## usage examples

`gh timer -s 10`
run a timer for 10 seconds

`gh timer -m 5`
run a timer for 5 minutes

`gh timer -m 5 -b`
run a timer for 5 minutes and show big clock

`gh timer -m 60 -w`
run a stopwatch for 1 hour

`gh timer -h`
show help

If you like it, please don't forget to give it a star on GitHub!

If you have any questions or would like to contribute - you are welcome to contact me!

See you soon.
Help me review code on my typescript side project.
Published: 2021-09-17 13:20:42

Having used Javascript for quite a while now, I recently decided to start a new journey with typescript. I want to be able to write better javascript programs that are self-documented, predictable, and secure.

I thought to myself that the best way would be to get my hands dirty with typescript code. Much as I go through tutorials and videos that teach typescript, I need to have a hands-on taste of typed javascript in the real world.

**Why am I telling you all this?**

I'm looking for some friends who are experienced with typescript, to help review my code and collaborate on my first typescript project. The project is a tiny npm package that I just started working on.

I haven't written a README yet. But the package is a simple javascript database for prototyping database operations from within javascript. 

I bootstrapped the project using a typescript template from tsdx. TSDX is a CLI tool for creating awesome typescript packages easily. Check it out [here](https://tsdx.io/) 


**The motivation**

I chose this projects because I love working with databases in general. But often times I need to protoype some database ops without installing and configuring real database services. In such scenarios, all I need is some way to mock database actions quickly without leaving my code.

The objective of this simple package is to provide a solution to the above stated problem by: Providing simple database from within javascript.

**The goal of the project**

*To help me learn more real world uses of the typescript language.

*To enable me gain confidence in using typescript as the default language for my next Javascript projects. 

*To confidently share my insights and knowledge about using typescript

This project is not specifically about me, or my interests. I welcome anyone who's interested in learning typescript. I think learning together within a community will be of vital importance.

**Why am I posting here?**

Dev community has the most friendly developers from all sorts of backgrounds. People on this platform promote collaboration and are always willing to provide honest feedback.

**Conclusion**
If you're interested in helping out in any way, comment with your github username. I will add you as a contributor to the repository.

You can DM me on twitter [@bk_973](https://twitter.com/bk_973) .
*See you soon*
How to update post params in Elixir Phoenix
Tags: elixir, phoenix
Published: 2021-09-17 13:00:40

Started playing with the [Phoenix Framework](https://phoenixframework.org/) and I have no idea what I'm doing, but it's nice to have that beginner feeling after 14 years in *PHP*, *Python* and *JavaScript*. 

So here I am, trying to create a simple blog with *Phoenix*. 

And one of the first stumbling blocks for me was:

> How on earth, I'm going to add current user id to post parameters?

So I have the following posts schema:

```elixir
defmodule Timphx.Blog.Post do
  use Ecto.Schema
  import Ecto.Changeset

  schema "posts" do
    field :body, :string
    field :published, :boolean, default: false
    field :title, :string
    belongs_to :author, Timphx.Accounts.User

    timestamps()
  end

  @doc false
  def changeset(post, attrs) do
    post
    |> cast(attrs, [:title, :body, :published, :author_id])
    |> validate_required([:title, :body, :published, :author_id])
  end
end
```

And *Phoenix* generated for me the following `PostController`:

```elixir
defmodule TimphxWeb.PostController do
  use TimphxWeb, :controller

  alias Timphx.Blog
  alias Timphx.Blog.Post

def create(conn, %{"post" => post_params}) do
    case Blog.create_post(post_params) do
      {:ok, post} ->
        conn
        |> put_flash(:info, "Post created successfully.")
        |> redirect(to: Routes.post_path(conn, :show, post))

      {:error, %Ecto.Changeset{} = changeset} ->
        render(conn, "new.html", changeset: changeset)
    end
end
```

And now, within the `create` function, I want to add current user to `post_params`. How can I do this?

Turns out `post_params` is a map and it's immutable, so you can't do something naive like:

```elixir
post_params.author_id = conn.assigns.current_user.id
```

> Oh yes, btw, `conn.assigns.current_user.id` is how you get the current user id.

I had to dig into *Elixir* docs (which I see for the first time) and found explanation of [Maps](https://elixir-lang.org/getting-started/keywords-and-maps.html#maps). There I read about the `Map.put` method that allows you to create a new map from a map and a new key value:

```elixir
Map.put(%{:a => 1, 2 => :b}, :c, 3)
```

Eureka! Now I knew how to update `post_params` and add current user there:

```elixir
post_params = Map.put(post_params, "author_id", conn.assigns.current_user.id)
```

So my final code for the `create` function looks like:

```elixir
def create(conn, %{"post" => post_params}) do
    post_params = Map.put(post_params, "author_id", conn.assigns.current_user.id)
    case Blog.create_post(post_params) do
      {:ok, post} ->
        conn
        |> put_flash(:info, "Post created successfully.")
        |> redirect(to: Routes.post_path(conn, :show, post))

      {:error, %Ecto.Changeset{} = changeset} ->
        render(conn, "new.html", changeset: changeset)
    end
  end
```

Slam dunk, done, baby! For now, I'm super stoked!
List of places to post your startup (for FREE)
Tags: startup, beginners, machinelearning
Published: 2021-09-17 12:54:44

I've been struggling a lot with SEO whilst building my startup, and I happened upon a pretty great collection of sites on the internet where you can submit your startup. It takes a while to go through all, but it's great for backlink juice and just general traffic (people use them to discover new products, like e.g. alternative.to).

Here's the GitHub repo with the huge collection of places: [GitHub](https://github.com/mmccaff/PlacesToPostYourStartup)

Not all of them are good tough: like a third of them aren't free and can cost up to ~199$ just to list your project. I went through all of them yesterday posting Namy (my startup), and made my own collection of the best/fastest. Then, since I need SEO juice for Namy, I published them in a blogpost:

https://www.namy.ai/blog/places-to-post-startup

Hope you find this useful for your own projects!!
Prime Number Tester
Published: 2021-09-17 12:54:15

```python
# prime_tester.py
#   This program accepts a n value as input and determines whether
#   or not it is prime.
# by: Scott Gordon

from math import sqrt


def is_prime(n):
    """Determines whether number (n) is prime or not"""
    if n % 2 == 0 and n != 2:
        return False
    factor = 3
    while factor <= sqrt(n):
        if n % factor == 0:
            return False
        factor += 2
    return True


def main():
    print("Prime Number Tester\n")
    n = int(input("Enter a number: "))
    if is_prime(n):
        print(f"{n} is prime.")
    else:
        print(f"{n} Is not prime.")


if __name__ == '__main__':
    main()

```
Photo by <a href="https://unsplash.com/@ryanjohns?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Ryan Johns</a> on <a href="https://unsplash.com/?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
JavaScript: Truthy and Falsy Values
Tags: javascript
Published: 2021-09-17 12:53:35

As well as a type, each value also has an inherent Boolean value, generally known as either truthy or falsy. Some of the rules are a little bizarre, so understanding the concepts and effect on comparison helps when debugging JavaScript applications.

The following values are always falsy:

- false
- 0 (zero)
- -0 (minus zero)
- 0n (BigInt zero)
- '', "", `` (empty string)
- null
- undefined
- NaN

Everything else is truthy. That includes:

- '0' (a string containing a single zero)
- 'false' (a string containing the text “false”)
- [] (an empty array)
- {} (an empty object)
- function(){} (an “empty” function)

A single value can therefore be used within conditions. For example:

`if (value) { // value is truthy } else { // value is falsy // it could be false, 0, '', null, undefined or NaN }`

#Ref: https://www.sitepoint.com/javascript-truthy-falsy/
Responsive Contact Form Using Pure HTML & CSS.|
Tags: html, css, loginform, form
Published: 2021-09-17 12:19:45

Here Is The Complete Responsive Login Form Using Pure HTML & CSS.|
##Source Code
<br>
#HTML Code:
```html
<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="style.css">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Contact Form</title>
</head>
<body>
    <div class="container">
        <form action="" autocomplete="off">
            <h1>Contact Us</h1>
            <div class="inp">
                <div class="name">
                    <input type="text" name="name" id="name" placeholder="Name" required>
                </div>
                <div class="email">
                    <input type="email" name="email" id="email" placeholder="E-mail" required>
                </div>
                <div class="phone">
                    <input type="number" name="phone" id="phone" placeholder="Phone No." required>
                </div>
                <div class="message">
                    <textarea name="message" id="message" cols="30" rows="10" placeholder="Type Here Your Message..." required></textarea>
                </div>
                <div class="submit">
                    <button type="Submit">Submit</button>
                </div>
            </div>
        </form>
    </div>
    
</body>
</html>
```
<br><br>
#CSS Code:
```css
*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    text-decoration: none;
    font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;

}
body{
    height: 100vh;
    width: 100%;
    background: turquoise;
    display: grid;
    place-items: center;
}
.container{
    position: relative;
    height: 450px;
    width: 350px;
    background: rgb(0, 0, 0);
    border-radius: 3px;
    box-shadow: 1px 1px 4px #444, -1px -1px 4px #444;
}
form h1{
    color: white;
    text-align: center;
    margin: 5px;
}
.inp{
    margin: 10px 25px;
}
input{
    color: white;
    height: 40px;
    width: 280px;
    outline: none;
    border: 1px solid white;
    margin: 10px 0;
    box-shadow: 1px 1px 1px rgb(224, 221, 221);
    padding: 15px;
    font-size: 20px;
    background: #000;
}
textarea{
    height: 140px;
    width: 280px;
    color: white;
    outline: none;
    border: 1px solid white;
    background: #000;
    margin: 10px 0;
    box-shadow: 1px 1px 1px rgb(224, 221, 221);
    padding: 10px 10px;
    font-size: 20px;
}
.submit button{
    height: 40px;
    width: 100px;
    background: #0489EE;
    color: white;
    font-size: 20px;
    font-weight: 650;
    cursor: pointer;
    border: none;
    outline: none;
    box-shadow: 0 1px 2px #777;

}
::placeholder{
    color: white;
}
```

##Find Me On:
<br>
<a href="https://www.facebook.com/technicalvandar">Facebook</a>
<a href="https://www.youtube.com/technicalvandar">Youtube</a>
<a href="https://github.com/Technical-Vandar-885/">Github</a>
Why React  ❓
Tags: react, reactnative, javascript, webdev
Published: 2021-09-17 12:15:19

React is the most popular UI framework in 2021, many start-ups are using it and companies are migrating to it. easy to use but you can do a lot of amazing things with it in less time than other frameworks. It is well maintained (by Facebook) and it is backed by a community of millions of developers.

✅Speed:
The React basically allows developers to utilize individual parts of their application on both client-side and the server-side, which ultimately boosts the speed of the development process.

✅Flexibility:
Compared to other frontend frameworks, the React code is easier to maintain and is flexible due to its modular structure. This flexibility, in turn, saves huge amount of time and cost to businesses.

✅Performance:
React JS was designed to provide high performance in mind. The core of the framework offers a virtual DOM program and server-side rendering, which makes complex apps run extremely fast.

✅Usability:
Deploying React is fairly easy to accomplish if you have some basic knowledge of JavaScript. In fact, an expert JavaScript developer can easily learn all ins and outs of the React framework in a matter of a day or two.

✅Mobile app development
If you thought React is for web development only, you could not be more wrong! Facebook has already upgraded the framework for developing mobile native applications for both Android & iOS platforms. So, now that you know the key benefits of the React framework, let’s move forward and also check out top reasons to Choose React JS for your next project.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wehhc7uhbuyft0d7vuu9.jpg)
A Quick 10-Second Programming Joke For Today
Tags: jokes, dailydeveloperjokes
Published: 2021-09-17 12:00:28

---
title: "A Quick 10-Second Programming Joke For Today"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258dc381cf.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ How do programming shepherds count their flock?

___A:___ With lambda functions
 -->
Remember what got you here!
Tags: softwaredevelopment, teamwork, agile
Published: 2021-09-17 11:59:23

---
title: Remember what got you here!
published: true
date: 2021-09-17 11:56:06 UTC
tags: softwaredevelopment,teamwork,agile
canonical_url: https://medium.com/chingu/remember-what-got-you-here-f8f17ae3cd1
---

#### Sprint 3 — Friday

![](https://cdn-images-1.medium.com/max/1024/1*ZpBvH6hWqkS9eibfWIsYKw.jpeg)<figcaption>Photo by <a href="https://unsplash.com/@drew_beamer?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Drew Beamer</a> on <a href="https://unsplash.com/s/photos/motivation?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption>

As you work on projects it’s easy to get frustrated and depressed when you hit obstacles.

As projects progress you’ll find yourself encountering design issues with your app, technology issues with libraries and services, and conflict within your team.

These can be distracting and if not handled maturely and openly with the team can lead to the _“dark side of the Force”_. Namely, questioning why you wanted to become a Software Developer and draining the joy out of it.

If you are having these feelings you aren’t alone! This is just another form of the _Impostor Syndrome_ that hits all of us. And I do mean **_all_** of us!

Handling issues maturely starts with establishing and following a process, as a team, for logging and prioritizing issues so they receive the attention and resources they deserve at the proper point in time. The phrase **_“As a team”_** is critical since following this process must be a shared responsibility, but also one where teammates provide technical and moral support to one another.

> Remember that what got you here as a Developer is the joy from creating something from nothing

If negative feelings and emotions start to affect you take a moment to step back to when you saw your first program display “Hello World” on the screen. Remember that? Don’t let go of it! That’s what got you here. The sheer joy from creating something from nothing.

When you hit issues look at them from the perspective not of _“How can I make this go away???”_. But instead as, _“What happened and why?”_ and _“What can I learn from this that can be used in the future?”_

![](https://cdn-images-1.medium.com/max/1024/1*UN2pHREjZcMY6oGyOtBQBg.jpeg)

### Before you Go!

Chingu helps you to get out of “_Tutorial Purgatory_” by transforming what you’ve learned into experience. The experience to boost your Developer career and help you get jobs.

You can learn more about **Chingu** & how to join us at [https://chingu.io](https://chingu.io/)

* * *