teleren/devto huggingface dataset:
Code poem - imagination
Tags: Poetry, javascript, showdev
Published: 2020-05-11 23:49:25

A little poem in code. I find it fascinating how you close you can come to the english language with code.

Maybe learning a foreign language and learning to code have a few similarities?

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/tw8rdy972xo9nthb640f.png)
Time out!
Tags: 100daysofcloud, gads, cloud, alc
Published: 2020-05-11 23:47:06

2,4.


4th day of 2nd #cloudweek
Just finished one of the most interesting labs, or speaking more accurately, I ran out of time. 5 more minutes would have been enough to finish the last task, but in [Cloud storage lab](https://googlepluralsight.qwiklabs.com/focuses/8035644?parent=lti_session). I had spent a little too much time earlier correcting an error, and with qwiklabs, you have timeouts! You can only restart...

Cloud storage is a fundamental resource in Google Cloud, with many advanced features. In this lab, I was supposed to exercise many Cloud Storage features that could be useful in my future designs. I explored Cloud Storage using both the console and the gsutil tool.

I performed the following tasks:

 - Create and use buckets

 - Set access control lists to restrict access

 - Use your own encryption keys

 - Implement version controls

 - Use directory synchronization

 - Share a bucket across projects using IAM

I still don't really understand Task 4: How to Rotate CSEK keys. I wasted time here, that's why I could not finish. I'll go back to the lab to complete it.
Did all the tasks, though I didn't complete Task 8: Cross-project sharing.
Didn't have enough time to Modify role for the 2nd project in order to verify access. 
I'll make sure I revisit and do this again!

__Are you a learner like me(probably on GADS2020 also) or already an expert in the #Cloud(Not just GCP, but also AWS, Azure, etc?). Feel free to drop your comments, tips, advice, or just say hi!__

_I am learning Essential Google Cloud Infrastructure: Core Services by Google on Pluralsight as part of the Google Africa Developer Scholarship 2020 program, Google Cloud in partnership with Andela and this is my #100DaysofCloud challenge._
Reducing CPU Overhead for DirectX API Calls
Published: 2020-05-11 23:44:52

One of the biggest challenges of graphics programming is handling the CPU overhead of the API calls that move memory around and that update buffers and resources. For open-world games, one of the most expensive operations is copying the vertex and index buffers over to the GPU.

## Initial Approach
The first thing I did for my renderer was the naive approach. I made a model struct and each model had it's own index and vertex buffer so that when rendering I would just copy over the vertex and index buffers for each model and then render accordingly. This worked during the initial stage, but once I started adding in more assets and ran the profiler I saw how inefficient it was so I decided to do some simple optimizations.

## The Biggest Optimization
The biggest optimization in the renderer API calls was combining compatible buffers into one big buffer and reducing the number of API calls for updating the index and vertex buffer. This allows us to now have a few large copy operations in the render loop and then use draw calls that index into the unified buffers using offsets stored in each game object as opposed to allowing each game object to store it's own model data and significantly sped up the rendering code.

## Further Optimizations
Further optimizations would be multithreaded rendering calls and using texture atlases to reduce the number of textures that need to be copied. However, given the limits placed on this project that isn't a priority right now.

By Joseph Whittington
4 new challenges
Tags: javascript, computerscience
Published: 2020-05-11 23:39:38

I've added 4 new challenges to our ranked mode, one hard and three medium ones. The hard one is about finding word combinations in a 2D character matrix, it uses a depth-first search strategy. Two of the medium ones are about stock trading, below is a sample.

```JS
function maxProfit(prices) {
  let profit = 0;
  for(let i = 1; i < prices.length; i++) {
    if (prices[i] > prices[i -1]) {
      profit  = profit + prices[i] - prices[i - 1];
    }
  }
  return profit;
}

let arr = [7,5,3,2,1,4,5]
let A = maxProfit(arr);
// A = ?
```
Functional programming for the backend
Tags: nextjs, discuss, functional, webdev
Published: 2020-05-11 23:30:11

Hi DEV Community! I've been using Next.js for the "frontend" of my websites, and I've been loving the speed and simplicity with the functional nature of react. I'm now looking to bring that experience to the backend. **How do you bring functional programming to the backend?** Do you use a functional programming language? Just an object oriented language with some fancy libraries? I'm stuck choosing what to learn for my next project.
Billboarding in Geometry Shaders
Published: 2020-05-11 23:29:50

##Backface Culling

In DirectX, backface culling is on by default which makes dealing with flat objects more difficult. If the flat object is facing the wrong direction, then the object will not be rendered. This is especially a problem when trying to make use of geometry shaders for particles. For the particles, I decided it would be best just to put in a point and append triangles to it to create a quad. If the quad created with the appended triangles did not face towards the camera it would have been culled.

##Billboarding

A solution to flat objects not facing the camera is to have them always face the camera. To have the flat objects always face towards the camera I implemented billboarding in the geometry shader. Billboarding does not necessarily have to be done in the geometry shader, it could be done in the vertex shader but if that vertex also goes through a geometry shader the orientation of the added geometry won’t necessarily be facing the direction you want it to. If the billboarding was done correctly in the geometry shader the object should always be facing towards the camera.

By Taylor Addington
Take the 2020 Ruby on Rails Community Survey
Tags: rails
Published: 2020-05-11 23:12:27

---
title: Take the 2020 Ruby on Rails Community Survey
published: true
description: 
tags: rails, ruby on rails
---
![2020 Ruby on Rails Community Survey](https://dev-to-uploads.s3.amazonaws.com/i/5ylj73gn80nuvophat67.png)

The [Ruby on Rails Community Survey](https://rails-hosting.com/) has been collecting data from Rails developers since 2009. By sharing how you use Rails, you help the data we collect become more accurate and meaningful over time. 

The survey asks questions like:
* How did you learn to code?
* How many Rails applications have you contributed to?
* How often do you contribute back to open source projects?
* Which Ruby gems frustrate you the most? (This is always a fun one.)

We appreciate your contribution to [this survey](https://rails-hosting.com/)! We had 2,000 completions when the survey last ran in 2018. Can you help us get to 2,500 in 2020? If you work on an engineering team, or participate in any local groups that use Rails, your shares are appreciated.

[Take the survey](https://rails-hosting.com/).

Thank you!
Job Search Week 12
Tags: makers
Published: 2020-05-11 21:59:34

I spent most of this week doing job applications and working with Heroku and circle CI. I wanted to get some more practice in with continuous integration and hosting. I also started my first MERN stack project. I decided to go with a message board using CRUD hopefully with that I can get the hang of the MERN stack and then build some other projects.

Day 1

I started the week off by doing a couple of job applications and started looking at using Heroku. It's been a while since I've used Heroku so it took me a little while to get back into it but it was fine once I got it going. 

Day 2

I spent Tuesday mostly doing job applications I mainly used total jobs, linkedin and otta because they're the sites I'm most comfortable using and I like the user interface. I wanted to get a lot of applications out so I could get started on a MERN stack project.

Day 3

Wednesday I made a template for setting up circle CI and Heroku so that with a few minor changes I could have a quick project set up a hosted website with continuous integration. This will help me when doing group projects to get used to using branches.

Day 4

Thursday I started on my first MERN stack project it's a message board app. I started doing the backend using mocha and chai for testing. I'm glad to finally get started on a full-stack project using react because once I've done this I can go back to my glucometer and add more to it.

Day 5

On Friday I continued to work on my message board getting the tests set up and creating an add method and giving the messages an ID and date using TDD. 

Summary

Overall I feel like this week was good I got the template set up which will be very useful and I got started on my MERN stack project and got a few job applications out as well so a productive week!!
Cohesion and Coupling for Secrets Management in CI/CD Work Flows
Tags: secretsmanagement, architecture, coupling, informationsecurity
Published: 2020-05-11 21:59:09

---
title: Cohesion and Coupling for Secrets Management in CI/CD Work Flows
published: true
description: How to make sure you can get what you need to get done with your CI/CD systems and Secrets Management, without having too many separate work flows.
tags: secrets-management, architecture, coupling, information-security
---

TL;DR: If you couple your some other deployment process to your Secrets Management, then you would have to redeploy for new creds. And that's **bad**.

There are a few "tight couplings" to avoid for Secrets Management:

* Coupling to Infrastructure as Code (IaC)
* Coupling to Configuration as Code (CaC)
* Coupling to Application Deployment (CI/CD)

The test is, if I need to do an emergency revocation, do I have to wait for any of the above to complete?

For example, if you happen to be using git2consul for secrets management*, used in one of the above 3 systems, is the only way to update secrets, then you have to wait for a deployment for one of the above to complete. If the lack of those credentials is what's causing the problem in the first place, or the build happens to be broken at the same time as the emergency revocation occurs, you'd be in trouble. 

A kinder, gentler way to decouple these work flows from Secrets Management? You could ensure that Consul could be edited directly for emergency.  While still having a git2consul pipeline for the configs.

If you are generating database creds, and giving them to the application, that isn’t dynamic any longer as the application can not generate them but now receives them.

As long as git2consul isn't the only way to revoke / re-issue creds, I think that makes a lot of sense.

*If you have HashiCorp Vault available, it may be [better to consider Vault for this](https://github.com/breser/git2consul/issues/134), especially since Vault works with `consul-template`, or better yet `envconsul` or [Vault Agent](https://www.vaultproject.io/docs/agent/).
Parallelized vectorization with Dask - a Monte-Carlo example
Tags: python, numpy, dask, parallelization
Published: 2020-05-11 21:52:01

Today, I came across an article on Medium about parallelization in Python ([here](https://medium.com/distributed-computing-with-ray/how-to-scale-python-multiprocessing-to-a-cluster-with-one-line-of-code-d19f242f60ff)); I used that post as an example to practice vectorization principles with Numpy - [you can read my previous post on DEV here](https://dev.to/joaomcteixeira/python-multiprocessing-vs-numpy-vectorization-one-example-4de). The performance gain obtained in a single core with Numpy is outstanding.

**Can we improve the performance of the vectorized Monte-Carlo approach even further?**

[Dask](https://docs.dask.org/en/latest/) offers a Numpy-similar interface with automated parallelization. So, let us try it!

This is the solution I came up with to compute the number pi using a Monte-Carlo approach, in other words, reproducing the same algorithm as in the previous referred posts but with Dask. Here, I am using the default configuration, I am not exploring tweaks in Dask to gain further performance. I find it amazing how Dask keeps the memory profile really low. After all, Dask managed the parallelization in my laptop's 8 threads and the available memory seamlessly.

```python
start = time.time()
sample = 10_000_000_000  # <- this is huge!
xxyy = da.random.uniform(-1, 1, size=(2, sample))
norm = da.linalg.norm(xxyy, axis=0)
summ = da.sum(norm <= 1)
insiders = summ.compute()
pi = 4 * insiders / sample
print("pi ~= {}".format(pi))
print("Finished in: {:.2f}s".format(time.time()-start))
```

In my laptop:

```
pi ~= 3.141615808
Finished in: 107.14s
```

```
CPU~Quad core Intel Core i7-8550U (-MT-MCP-)
speed/max~800/4000 MHz
Kernel~4.15.0-99-generic x86_64
Mem~7178.7/32050.2MB
HDD~2250.5GB(56.6% used)
Procs~300
Client~Shell
inxi~2.3.56 `
```

**Additional notes:**

It is possible to write this statement:

```python
sum = da.sum(norm <= 1)
```

using masked arrays:

```python
mask = da.ma.masked_inside(norm, 0, 1)
trues = da.ma.getmaskarray(mask)
summ = da.sum(trues)
```

Yet this latter form consumes more time, about 20% in my machine.

What are your thoughts?
Cheers
Don't Quote Environment Variables in Docker
Tags: docker
Published: 2020-05-11 21:48:23

---
title: Don't Quote Environment Variables in Docker
published: true
description: While quoting an odd environment variable might make sense to deal with special characters normally, Docker just assumes the quotes are part of the value.
tags: Docker
---

It's usually a good idea to store your app's environment variables separate from the app itself in a `.env` file. This allows you to easily have different values for development, staging, and production.

Normally when writing a `.env` file, you might have an unusual property like an API key that has lots of special characters. Typically you would quote this value to handle that.

```bash
# a normal environment variable, surrounded by single quotes
KEY='example bl4h 5tuFF 123@#%= ksjhbfdg'
```

Your system would know to treat what's *inside* the single quotes as the value of `KEY` and make it available to your app.

But Docker doesn't work this way.

Let's say you're passing a `.env` file into a Docker container via `docker-compose.yml`. Docker would interpret the quotes around the environment variables as part of the value itself!

For a real world example, here's an environment variable passed to the official WordPress Docker image and the resulting output in the container's `wp-config.php` file (value is random and not used for anything, obviously):

```bash
# environment variable in a .env file
WORDPRESS_DB_PASSWORD='Pr65s$CWv{P3k}4j6]I<j=U5n#keN&$D{{Uhv2@L'
```

```php
// output to wp-config.php
// notice the escaped \' at the beginning and end
define( 'DB_PASSWORD', '\'Pr65s$CWv{P3k}4j6]I<j=U5n#keN&$D{{Uhv2@L\'');
```

The database password in `wp-config.php` would be incorrect because Docker considered the single quotes as part of the key value!

So as weird and wrong as it appears, when using `.env` files with Docker, don't quote values! The above example done correctly would then look like this:

```bash
# environment variable in a .env file
WORDPRESS_DB_PASSWORD=Pr65s$CWv{P3k}4j6]I<j=U5n#keN&$D{{Uhv2@L
```

```php
// output to wp-config.php
define( 'DB_PASSWORD', 'Pr65s$CWv{P3k}4j6]I<j=U5n#keN&$D{{Uhv2@L');
```
Dynamic module import with Stimulus JS
Tags: stimulus, webpack
Published: 2020-05-11 21:12:32


### Scoped behavior by default

Being built on top of the mutation observer, Stimulus Controllers are only loaded once a `data-controller="my-controller"` is visible within the DOM. 

This is a great way to scope JS behavior to an element within a page.

With the typical Webpack loader, all the Controllers are bundled within the pack.

```js
// src/application.js
import { Application } from "stimulus"
import { definitionsFromContext } from "stimulus/webpack-helpers"

const application = Application.start()
const context = require.context("./controllers", true, /\.js$/)
application.load(definitionsFromContext(context))
```


### Importing large ES modules

When importing very large JS library you might want to only load them only on pages where the controller is used to avoid loading too much JS on other pages.

One nice feature of Webpack is the ability to dynamically load modules.

Using the lifecycle of Stimulus Controllers you can stick you dynamic import right into the `initialize()` or `connect()` function.


Here is and example to dynamically load `moment`

```js
import { Controller } from "stimulus";

export default class extends Controller {

  connect() {
    import("moment").then(moment => {
      this.moment = moment.default;
    });
  }

  doSomething() {
    const formatedTime = this.moment().format("dddd, MMMM Do YYYY, h:mm:ss a");
  }
}
``` 

and a working demo

{% codesandbox stimulus-dynamic-import-z7coy %}
Day 135 : I Got It
Tags: hiphop, code, coding, lifelongdev
Published: 2020-05-11 21:26:21

_liner notes_:
- Saturday : Wow, woke up to hear that both Andre Harrell and Little Richard both passed. Two legends who helped shape music. So yeah, did the radio show. My co-host created a website with no previous experience https://BeetUnique.com . Real proud of him. We talk about it on the show. The recording is at https://kNOwBETTERHIPHOP.com After the show, watched the Erykah Badu and Jill Scott event. Was really dope to see as they played their tracks back and forth.

![Radio show episode image of Little Richard and Andre Harrell with the words May 9th 2020, BeetUnique.com](https://dev-to-uploads.s3.amazonaws.com/i/jdu2ylozky7qm5scq97u.jpg)

- Sunday : Stayed up late to finish getting the radio show uploaded. Mowed my lawn. Cut my hair. Studied Japanese. Watched some TV. Went to sleep.

- Professional : Had my one on one with my manager. Talked about what we're looking to do this week. Mine mostly revolves around getting a blog post submitted and do my presentation this Thursday for Vonage Developer Day. Also had a team meeting. Really good to see everyone. I recorded a short promo video for my talk. Attended another talk prep session. I think it was my internet connection, but the presenter's slides were not changing for me. I got it working my closing my browser and going back to the site. Then I got a pretty bad headache and took a nap. Got up and started back working on my blog post. 

- Personal : Last night, I spoke to a friend while playing Tic-Tac-Toe on the site I made https://TicReactToe.com It was good to catch up. We even came up with an idea for a really cool side project. Basically moving an event we did to be online. I even bought yet another domain name for it. haha I recently got a small shock as some of my domains renewed. haha I have way too many!

![A lake in Krka National Park in Croatia with waterfalls and a forest surrounding the area](https://dev-to-uploads.s3.amazonaws.com/i/en4c8m0z2j9lerrx5qd6.png)

Going to keep working on this blog post. I want to have it done and turned in tomorrow. Will also review some more Japanese and probably watch some anime before heading to bed.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube 83BRW2px3tQ %}
Deploy Telegram Bot to Heroku For Free | Telegram Bot Development | Part 5
Tags: telegram, node, tutorial, bot
Published: 2020-05-11 21:09:27

{% youtube 9ibGXpxFLQA %}

Telegram bot development using *node.js* and *Telegraf* API.

Step by step guide: 
{% github https://github.com/ishan0445/telegraf-telegram-bot-deploy %}

*What you will learn:*
 - Intro to Heroku, git and micro-bot npm package
 - Deploying to Heroku
 - Testing Bot after deployment
 - And a lot more...

*Requirements:*
 - Please watch previous parts
 - Basic Programming (everything will be taught from basics).
 - Telegram Account.

*Example Bot:*
Search for @covid_19_india_bot on telegram or click here
https://t.me/covid_19_india_bot
Sending Media Files | Telegram Bot Development | Part 4
Tags: telegram, node, tutorial, bot
Published: 2020-05-11 21:09:09

{% youtube jsZW9Nqy6-o %}

Telegram bot development using *node.js* and *Telegraf* API.

*What you will learn:*
 - Creating a start script.
 - Using Nodemon
 - Sending Media Files.
 - 3 methods of sending the media files
 - Sending Location.
 - And a lot more...

*Requirements:*
 - Please watch previous parts
 - Basic Programming (everything will be taught from basics).
 - Telegram Account.

*Example Bot:*
Search for @covid_19_india_bot on telegram or click here
https://t.me/covid_19_india_bot
Handling Inline Queries | Telegram Bot Development | Part 3
Tags: telegram, node, tutorial, bot
Published: 2020-05-11 21:08:53

{% youtube V7s9gLigpxw %}

Telegram bot development using *node.js* and *Telegraf* API.

*What you will learn:*
 - Inline Query.
 - handling inline query using bot.on().
 - creating a bot that will search the dev.to API and the OMDB API
 - And a lot more.

*Requirements:*
 - Please watch Part 1 and 2.
 - Basic Programming (everything will be taught from basics).
 - Telegram Account.

*Example Bot:*
Search for @covid_19_india_bot on telegram or click here
https://t.me/covid_19_india_bot
Inline Keyboards And Menus | Telegram Bot Development | Part 2
Tags: telegram, node, tutorial, telegraf
Published: 2020-05-11 21:08:37

{% youtube uvrhoJdsbmc %}

Telegram bot development using *node.js* and *Telegraf* API.

*What you will learn:*
 - Inline Keyboards and creating menus.
 - Callback_query and handling with bot.action() .
 - async/await.
 - And a lot more.

*Requirements:*
 - Please watch Part 1.
 - Basic Programming (everything will be taught from basics).
 - Telegram Account.

*Example Bot:*
Search for @covid_19_india_bot on telegram or click here
https://t.me/covid_19_india_bot
Category