teleren/devto huggingface dataset:
Go AWS Notes: KMS - Decryption
Tags: aws, go, kms
Published: 2020-01-06 19:21:21

---
title: Go AWS Notes: KMS - Decryption
published: true
description: 
tags: aws, go, golang, kms
---

I use KMS for serverless apps when I want to put some secrets as an environment variable (Yes, I know SSM exists). I use the serverless app and the serverless-kms-secrets (https://github.com/nordcloud/serverless-kms-secrets) for encrypting secrets and making it convenient for using them in a lambda. 

After installing the plugin, we can encrypt a secret in the command line:
```
sls encrypt -n MY_SECRET -v my-password
```
The plugin readme (https://github.com/nordcloud/serverless-kms-secrets) goes into more detail on how to use it.

Decrypting the secret can be rather simple with Go, but I initially found it a bit tricky when I first tried to use it. My first attempt was something like this:

```go
// Create an AWS Session
sess, _ := session.NewSession(&aws.Config{
		Region: aws.String("us-west-2"),
	})	
svc := kms.New(sess)
mypassword := os.Getenv("MY_SECRET")	
input := &kms.DecryptInput{CiphertextBlob: []byte(mypassword)}	
_, err := svc.Decrypt(input)
```

But this kept throwing an `InvalidCiphertextException` exception. The AWS documentation states that this exception occurs because "the specified ciphertext, or additional authenticated data incorporated into the ciphertext, such as the encryption context, is corrupted, missing, or otherwise invalid." The documentation also mentions that the encrypted secret is bas64 encoded. This means that I have to base64 decode the encrypted secret and use that as the value for the `CiphertextBlob` in the `DecryptInput`:


```go
encpass := os.Getenv("MY_SECRET")
password, _ := base64.StdEncoding.DecodeString(encpass)

```

The resulting output is of type `DecryptOutput` that looks something like:

```go
type DecryptOutput struct {
   _ struct{} `type:"structure"`

   // ARN of the key used to perform the decryption. This value is returned if
   // no errors are encountered during the operation.
   KeyId *string `min:"1" type:"string"`

   // Decrypted plaintext data. When you use the HTTP API or the AWS CLI, the value
   // is Base64-encoded. Otherwise, it is not encoded.
   //
   // Plaintext is automatically base64 encoded/decoded by the SDK.
   Plaintext []byte `min:"1" type:"blob" sensitive:"true"`
}

```

The clear secret is now accessible through the `Plaintext`  field.

P.S.: Remember to do the appropriate error handling.
sensitive-param-filter: A package for filtering sensitive data (parameters, keys) from a variety of JS objects
Tags: javascript, npm, node, webdev
Published: 2020-01-06 19:16:42

`sensitive-param-filter` is a zero-dependency package designed to filter sensitive values from JavaScript objects.
This package can be used to scrub logs, filer data before outputting to a UI, etc.
The defaults provided with sensitive-param-filter should work well for most applications.

```js
const { SensitiveParamFilter } = require('@amaabca/sensitive-param-filter')
const paramFilter = new SensitiveParamFilter()
const rawObject = {
  Authorization: 'Bearer somedatatoken',
  body: {
    info: '{ "amount": 28.64, "credit_card": "4242424242424242", "cvv": "123" }'
  },
  method: 'POST',
  url: 'https://pay.example.com?user=bob.bobbington&password=asecurepassword1234'
}
const filteredObject = paramFilter.filter(rawObject)
// filteredObject = {
//   Authorization: 'FILTERED',
//   body: {
//     info: '{ "amount": 28.64, "credit_card": "FILTERED", "cvv": "FILTERED" }'
//   },
//   method: 'POST',
//   url: 'https://pay.example.com?user=bob.bobbington&password=FILTERED'
// }
```

sensitive-param-filter examines keys to determine which values to filter.
Key matching is done in a case-insensitive, partial-macthing manner (that is, if the param `AUTH` is provided, `Authorization`, `AUTHENTICATION`, etc. will be filtered).

### Key Features

 * Does not modify input objects
 * Performs a deep copy of the input object (note that booleans, numbers, and strings - which are immutable - are technically copied by reference)
 * Does not copy functions
 * Handles circular references
 * Filters valid JSON strings
 * Filters valid and malformed URL query params

Check out the package at https://github.com/amaabca/sensitive-param-filter, or install it via `npm install @amaabca/sensitive-param-filter`
Can a site be too large for the JAMstack?
Tags: jamstack, jamuary
Published: 2020-01-06 19:06:09

The JAMstack is a robust way of building sites where the heavy lifting of content ingestion and site generation happens on build time. This approach eliminates the general back and forth between server and client and serves static assets upfront right from the CDN. Despite the many performance and security benefits that this brings, the JAMstack can seem like overkill for sites with hundreds, if not thousands of pages. With the regular build to deploy cycle, a single one-line change triggers the propagation of a fresh instance, which takes up a lot of time and bandwidth. In a competitive market where frequent content updates are critical—like in the case of a news website—the delay is a significant disadvantage. Thankfully, there are a number of ways to circumvent this problem. The simplest way to address long, hefty builds is to use a static site generator like [Hugo](https://gohugo.io/) that is built to handle large builds. Compared to many other static site generators (SSGs), Hugo can build a site with over 40,000 pages in a matter of minutes.

If migrating your site over to a different framework feels like too much work, try optimizing for the CDN cache. Often, CDNs derive much of their efficiency from files whose checksums have not changed between deploys. In a build that optimizes for the cache, only files that have been changed are re-uploaded and re-processed by the CDN. This means build times can be vastly reduced. Additionally, users benefit from faster site speeds since their browser doesn’t have to re-download files that they already have cached.

In addition to the aforementioned solutions, the JAMstack offers the ability to lean on serverless functions to serve content while waiting on a large build to finish. Rendering content via serverless functions is a great fallback for optimistic URL routing when the page for new content is not yet ready for preview. This concept is akin to server-side serverless rendering. It takes advantage of custom redirects where a 404 is redirected to a serverless function that populates a page with content. This is especially useful if content on a site is decoupled via a separate headless CMS system or database; Because you can easily pull realtime updated content with a serverless function and give users instant access to it.

All in all, a site no matter the size can benefit from a JAMstack approach. Making it work however, will require employing some nifty tricks to fully benefit from the speed, security and maintainability that the JAMstack provides. For more on the approaches mentioned above, check out these resources:

- [Handling browser caching on the Netlify CDN](https://www.netlify.com/blog/2017/02/23/better-living-through-caching/?utm_source=devto&utm_medium=caching-div&utm_campaign=devex).

- [Optimize for large site builds with serverless functions](https://css-tricks.com/static-first-pre-generated-jamstack-sites-with-serverless-rendering-as-a-fallback/)
The 7 Most Popular DEV Posts from the Past Week
Tags: top7
Published: 2020-01-06 18:48:35

---
title: The 7 Most Popular DEV Posts from the Past Week
published: true
description: A round up of the most-read and most-loved contributions from the community this past week.
tags: icymi
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sfwcvweirpf2qka2lg2b.png
---
Every Monday we round up the previous week's top posts based on traffic, engagement, and a hint of editorial curation. The typical week starts on Monday and ends on Sunday, but don't worry, we take into account posts that are published later in the week. ❤️

#1. Let's Do Better

Penelope explains how the tech industry is terrible at accepting name changes. In this post, Penelope explains how we can make our applications better for people who are changing their names.

{% link https://dev.to/penelope_zone/changing-your-name-is-a-hard-unsolved-problem-in-computer-science-kjf %}

#2. It's _Not_ Magic 

Lydia provides a visual explainer on how prototypal inheritance work - the culprit behind built-in methods like `.length()` or `.split()`.

{% link https://dev.to/lydiahallie/javascript-visualized-prototypal-inheritance-47co %}


#3. Weird & Wonderful

James shares the backstory of a handful of common programming languages -- how their names were chosen and what those words mean.

{% link https://dev.to/scottydocs/how-programming-languages-got-their-names-207e %}


#4. Clear Messages

Visual representation is a big part of communicating with an audience. In this post, Kedar shares a list of free illustration resources. 

{% link https://dev.to/kedark/free-illustrations-resources-for-the-web-make-your-next-project-cooler-525c %}

#5. No JS!

After sampling around 30 different libraries, Kiss shares their top ten favorite CSS animation libraries. They even include a quick overview of how to use each one!

{% link https://dev.to/weeb/10-of-the-best-css-animation-libraries-31d7 %}

#6. Question & Answer

Mark shares a thorough list of JavaScript interview questions. The best part? They share the answers too.

{% link https://dev.to/macmacky/70-javascript-interview-questions-5gfi#5-what-is-the-dom %}


#7. New Year, New Blogging Goals

Amruta shares their method for writing blog posts and the four drafts to work with: throwaway, rough, review, and final!

{% link https://dev.to/amrutaranade/how-to-write-a-blog-post-the-four-drafts-method-1k7b %}


_That's it for our weekly wrap up! Keep an eye on dev.to this week for daily content and discussions...and if you miss anything, we'll be sure to recap it next Monday!_
How to document a nodejs api with apidoc
Tags: javascript, tutorial
Published: 2020-01-06 18:21:55

##What is "apidoc" ?
 
Apidoc is a package to create documentation for api from notes in your source code.

##Where can i use it?

The service is compatible with any programming language that allow block documentation.

![Alt text](https://media.giphy.com/media/UurA7STcw7JeZWRs3p/giphy.gif)

##How can i use ?

###First of all you need to configuring the environment:

 - install node from the link "https://nodejs.org/en/"
 
 - install apidoc by command line below:
 ```
  "npm install apidoc -g"
 ```
   
###Now we can start configure the project:


 - install grunt-apidoc "npm install grunt-apidoc --save-dev" 
   
  Grunt is a task generator to apidoc

  - On your root of your project you need to create a "Grunfile.js"

    - In your Gruntfile you need to add the options below to config the
       destination path to apidoc:

```
 apidoc: {
   myapp: {
     src: "app/",
     dest: "apidoc/"
   }
 }
```

  - After that you need to create a file called "apidoc.json" to include information about your project:

```
 {
   "name": "example",
   "version": "0.1.0",
   "description": "apiDoc basic example",
   "title": "Custom apiDoc browser title",
   "url" : "https://api.github.com/v1"
 }
```

Obs:. this file is optional, it is just to describe your project, and you can add this config in your package json if it's a node project, but I preffer a separated file.

###Now we can start making documentation.

To start you just need to comment before your endpoint like below:

````
/**
 * @api {get} /user/:id Request User information
 * @apiName GetUser
 * @apiGroup User
 *
 * @apiParam {Number} id Users unique ID.
 *
 * @apiSuccess {String} firstname Firstname of the User.
 * @apiSuccess {String} lastname  Lastname of the User.
 *
 * @apiSuccessExample Success-Response:
 *     HTTP/1.1 200 OK
 *     {
 *       "firstname": "John",
 *       "lastname": "Doe"
 *     }
 *
 * @apiError UserNotFound The id of the User was not found.
 *
 * @apiErrorExample Error-Response:
 *     HTTP/1.1 404 Not Found
 *     {
 *       "error": "UserNotFound"
 *     }
 */
```
###Let's generate the documentation with the command bellow:

```
"apidoc -i myapp/ -o apidoc/ -t mytemplate/"
```

We need to pass in the command three arguments, first the folder where we can search the comments, second the output and in the end if we make a template the path to template, the final result is the image below:

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/h4dbhol10xri3kac2nfh.JPG)

This is my first post on dev.to, I hope it was of any help, any questions or suggestions just comment below!

 ![Alt Text](https://media.giphy.com/media/3o6fJ1l3Wr1ugMu1Rm/giphy.gif)
JavaScript Interview Coding Questions — 2
Tags: javascript, webdev, career, tutorial
Published: 2020-01-06 18:10:09

Let’s continue to coding assessment questions.

1. This one is about testing hoisting knowledge in JavaScript.
    ```
    // What will be the console outputs? Why?
    callMe1();
    callMe2();

    function callMe1() {
      console.log('I am here');
    }

    var callMe2 = function () {
      console.log('I am here too');
    };
    ```
    You will get an error for `callMe2()`. Console log will be below:
    ```
    I am here
    TypeError: callMe2 is not a function
    ```
    In JavaScript, basically function and variable definitions are moved to top ([which is named as hoisting](https://developer.mozilla.org/en-US/docs/Glossary/Hoisting)). The `callMe2` variable is defined but it is not a function! __This is because, hoisting only moves up to declarations not initializations.__ So, our `callMe2` variable is declared but the function is not assigned to it.

    You can test it in below:
    {% replit @hco/Hoisting %}

2. This one is for testing the knowledge about `const`, `let` and `var`.
    ```
    // 1. What will be output?
    var v;
    let l;
    const c;
    console.log({ v, l, c });
    ```
    Again you will get an error.
    ```
    const c;
          ^
    SyntaxError: Missing initializer in const declaration
    ```
    __You must assign a value while declaring a `const` variable!__

    You can test it in below:
    {% replit @hco/Variable-Declarations %}

3. Another question about variable declarations.
    ```
    // 2. What will be outputs? Try one by one!
    console.log('a:', a);
    var a = 1;

    console.log('b:', b);
    let b = 2;

    console.log('c:', c);
    const c = 3;
    ```
    If you try them one by one you will see the following console logs:
    ```
    a: undefined
    ReferenceError: b is not defined
    ReferenceError: c is not defined
    ```
    __This is because variables which are declared with `let` or `const`  are not initialized until their definition is evaluated!__ So it will throw [ReferenceError](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError). You can read [Temporal Dead Zone](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let#Temporal_dead_zone) part for more detailed information. 

    You can test it in below:
    {% replit @hco/Variable-Declarations %}

__My some other articles:__
{% link https://dev.to/halilcanozcelik/javascript-interview-coding-questions-1-4alk %}
{% link https://dev.to/halilcanozcelik/javascript-interview-coding-questions-3-13gn %}
{% link https://dev.to/halilcanozcelik/chrome-devtool-tips-2eb %}
{% link https://dev.to/halilcanozcelik/create-a-multi-language-website-with-react-context-api-4i27 %}
Neo4j – SSIS – Connection Manager Love
Tags: etl, neo4j, ssis
Published: 2020-02-19 09:33:53

---
title: Neo4j – SSIS – Connection Manager Love
published: true
date: 2020-01-06 17:45:00 UTC
tags: ETL,Neo4j,SSIS
canonical_url: 
---

I’ve not written about the SSIS components for a bit, but I _have_ been working on them – adding things, improving things. One area that was always very basic was the Connection interface. Or lack thereof – indeed the interface was basically just the properties pane of Visual Studio – mmmm Functional.

![](https://xclave.co.uk/wp-content/uploads/2020/01/image.png)<figcaption>A quick reminder</figcaption>

Now though, you can double click on the Connection Manager and you’ll get a better interface – one that makes it easier to read!

![](https://xclave.co.uk/wp-content/uploads/2020/01/image-1-1024x736.png)

I’ve also added two new properties to help with connections, **IPv6** and **Use Encryption** , which hopefully are pretty obvious as to what they mean.

![](https://xclave.co.uk/wp-content/uploads/2020/01/image-2.png)

This is a short post as there’s not much to add, those of you on the mailing list will have found out about these updates last year, and if you want to get your hands on the toolset – please visit: [http://bit.ly/neo4jssis](http://bit.ly/neo4jssis) register and you’ll be sent out the download link. Registration is only used to let you know of updates to the tools, no marketing!
API Design Tip
Tags: api, design
Published: 2020-01-06 17:05:14

Please don't keep Important informations as top level object key, cause then the client has to iterate through the object, find the key, relevent to him, at the same time discard the other irrelevant keys and then extract the data.

**DONOT PUT IMPORTANT DATA AS OBJECT KEYS**

I faced this issue with my AI team, and had to spend a fuckload of time parsing the response

**BAD RESPONSE DATA**: 

```javascript
{
	"i_am_a_unique_id": 50
}
```

**GOOD RESPONSE DATA**

```javascript
{
	"id": "i_am_a_unique_id",
	count: 50
}
```
Browser defaults
Tags: browsers, defaults, behaviours, https
Published: 2020-01-10 16:53:38

---
title: Browser defaults
published: true
date: 2020-01-06 17:11:16 UTC
tags: browsers,defaults,behaviours,https
canonical_url: https://adactio.com/journal/16295
---

I’ve been thinking about some of the default behaviours that are built into web browsers.

First off, there’s the decision that a browser makes if you enter a web address without a protocol. Let’s say you type in `example.com` without specifying whether you’re looking for `http://example.com` or `https://example.com`.

Browsers default to HTTP rather than HTTPS. Given that HTTP is older than HTTPS that makes sense. But given that there’s been such a push for <abbr title="Transport Layer Security">TLS</abbr> on the web, and the huge increase in sites served over HTTPS, I wonder if it’s time to reconsider that default?

Most websites that are served over HTTPS have an automatic redirect from HTTP to HTTPS (enforced with [HSTS](https://scotthelme.co.uk/hsts-the-missing-link-in-tls/)). There’s an ever so slight performance hit from that, at least for the very first visit. If, when no protocol is specified, browsers were to attempt to reach the HTTPS port _first_, we’d get a little bit of a speed improvement.

But would that break any existing behaviour? I don’t know. I guess there would be a bit of a performance hit in the other direction. That is, the browser would try HTTPS first, and when that doesn’t exist, go for HTTP. Sites served only over HTTP would suffer that little bit of lag.

Whatever the default behaviour, some sites are going to pay that performance penalty. Right now it’s being paid by sites that are served over HTTPS.

Here’s another browser default that [Rob mentioned recently](https://v7.robweychert.com/blog/2020/01/v7-viewport-meta-tag/): the `viewport` `meta` tag:

> I thought I might be able to get away with omitting `meta name="viewport"`. Apparently not! Maybe someday.

This all goes back to the default behaviour of Mobile Safari when the iPhone was first released. Most sites _wouldn’t_ display correctly if one pixel were treated as one pixel. That’s because most sites were built with the assumption that they would be viewed on monitors rather than phones. Only [weirdos like me](https://adactio.com/journal/6120) were building sites without that assumption.

So the _default_ behaviour in Mobile Safari is assume a page width of 1024 pixels, and then shrink that down to fit on the screen …_unless_ the developer over-rides that behaviour with a `viewport` `meta` tag. That default behaviour was adopted by other mobile browsers. I _think_ it’s a universal default.

But the web has changed since the iPhone was released in 2007. Responsive design has swept the web. What would happen if mobile browsers were to assume `width=device-width`?

The `viewport` `meta` element always felt like a (proprietary) band-aid rather than a long-term solution—for one thing, it’s the kind of presentational information that belongs in CSS rather than HTML. It would be nice if we could bid it farewell.
Radical Work Paradigm - 3 Hour Workday
Tags: productivity
Published: 2020-01-06 17:07:27

As a new year begins, I have a new work paradigm to propose for all information workers. This one is radically countercultural, but incredibly powerful – even life-changing. It’s the step that will take your personal capabilities to the next level, and give you the daily freedom that your soul yearns for.

## Challenge: During each workday, limit your work to a maximum of 3 hours.

Read More Here: https://www.silasreinagel.com/blog/2020/01/06/three-hour-workday/
When is nesting good or neutral?
Tags: discuss, healthydebate
Published: 2020-01-06 16:24:31

I was reading this post...

{% link https://dev.to/somedood/please-don-t-nest-promises-3o1o %}

And I think we can generally agree on the idea here.

It got me wondering where nesting _isn't_ bad, because in a lot of situations, nesting is a problem.

Is nesting in markdown a smell in and of itself?

```html
<section>
  <div>
    <div>
      <div>
        ...
```

Is this good or neutral or is it something to be avoided when possible?

Is nesting conditional logic _always_ bad, or are there situations where it's more helpful?

This is broad and abstract, so feel free to take it in any direction.
Best tweet-sized programming career lessons
Tags: career, development
Published: 2020-01-06 16:20:21

Before we start - I'm working on [https://cloudash.dev](https://cloudash.dev), a brand new way of monitoring serverless apps 🚀. Check it our if you're tired of switching between 50 CloudWatch tabs when debugging a production incident.

<hr/>

A short while ago I've tweeted a following question:

{% twitter 1213961540581367809 %}

## What’s the best tweet sized lesson you’ve learned in your programming career?

Quite a few of developers from various background decided to share their lessons learned in the Twitter thread and I'd like to share some of them with the dev.to community

1) "Experience comes with time and practice" - [Ania](https://twitter.com/aniawsz) 

{% twitter 1214118300461875200 %}

2) "There is no magic happening in the programming world" - [Xiaoru Li](https://twitter.com/hexrcs) 

{% twitter 1213978283110469639 %}

3) "When things go wrong, blame the process, not people." - [Sophie](https://twitter.com/type__error)

{% twitter 1214083689493278720 %}

4) "Manually verify things you’re very sure to be true" - [Jamon](https://twitter.com/jamonholmgren)

{% twitter 1214091113797013505 %}

5) "Software is not the goal, it is the by-product" (I absolutely love this one by the way) - [Adri](https://twitter.com/afontq)

{% twitter 1213968112804077569 %}

6) How do I set a breakpoint with JavaScript - [Tobi](https://twitter.com/tobiobeck)

{% twitter 1213968014107910156 %}

7) "Make your worst-case estimation for the time you need to solve the problem, double it, and you'll have a realistic timeline." - [Olena](https://twitter.com/frontendgirl)

{% twitter 1214169085610745857 %}

8) "Always back up your database. Always verify that your backups work." - [Harper](https://twitter.com/harpermaddox)

{% twitter 1213968243540602880 %}

9) "“When you became master in one thing, it’s time to become a student in another”" - [Marc](https://twitter.com/_marcba)

{% twitter 1214053223583105024 %}

10) "Solve problems. Learn in public. [Be a +10% engineer.](https://dev.to/tlakomy/become-a-10-engineer-g78)" - [Piotr](https://twitter.com/hasparus)

{% twitter 1214110033442754560 %}

<hr> 

If you're on Twitter, I highly recommend you follow all of those amazing people.

By the way, what are your lessons learned in your career?