teleren/devto huggingface dataset:
How to analyze Lambda cold starts
Tags: aws, lambda, programming, serverless
Published: 2019-10-21 12:45:50

---
title: How to analyze Lambda cold starts
published: true
date: 2019-10-20 20:19:14 UTC
tags: AWS,Lambda,Programming,Serverless
canonical_url: https://theburningmonk.com/2019/10/analyze-lambda-cold-starts-with-lumigo-cli/
---

{% youtube 8Xy8hjJhEN0 %}

I’m absolutely thrilled to tell you about an exciting new feature for the **[lumigo-cli](https://www.npmjs.com/package/lumigo-cli)**, the ability to **analyze Lambda cold starts**. With the new **analyze-lambda-cold-starts** command, you can analyze cold starts for:

- all functions in all regions
- all functions in a single region
- a single function

You can specify how far back you want the analysis to go. Defaulting at the last hour, you can go as far back as there are relevant log data in CloudWatch Logs. But please keep in mind that **[there is a cost involved](https://aws.amazon.com/cloudwatch/pricing/)** with scanning large quantities of log data – roughly $0.005 per GB of data scanned.

![](https://theburningmonk.com/wp-content/uploads/2019/10/img_5dacc0011691c.png)

Furthermore, you can also power-tune Lambda functions using the new “balanced” strategy, which finds the memory size setting that gives you the best balance between speed and cost.

![](https://theburningmonk.com/wp-content/uploads/2019/10/img_5dacc12e0303a.png)

I hope you will have lots of fun with these two new features. If you have any feature requests or run into any bugs, please don’t hesitate to let me know.

p.s. you can now report bugs using the lumigo-cli itself:

![](https://theburningmonk.com/wp-content/uploads/2019/10/img_5dacc549a5e89.png)

 ![](https://theburningmonk.com/wp-content/uploads/2019/03/img_5c8ca195210d5.png)

Hi, my name is **Yan Cui**. I’m an **[AWS Serverless Hero](https://aws.amazon.com/developer/community/heroes/yan-cui/)** and the author of [**Production-Ready Serverless**](https://bit.ly/production-ready-serverless). I specialise in rapidly transitioning teams to serverless and building production-ready services on AWS.

Are you struggling with serverless or need guidance on best practices? Do you want someone to review your architecture and help you avoid costly mistakes down the line? Whatever the case, I’m here to help.

You can contact me via [Email](mailto:theburningmonk.com), [Twitter](https://twitter.com/theburningmonk) and [LinkedIn](https://www.linkedin.com/in/theburningmonk/).

[Hire me.](https://theburningmonk.com/hire-me)

The post [Analyze Lambda cold starts with lumigo-cli](https://theburningmonk.com/2019/10/analyze-lambda-cold-starts-with-lumigo-cli/) appeared first on [theburningmonk.com](https://theburningmonk.com).

 ![](http://feeds.feedburner.com/~r/theburningmonk/~4/RPaDFcegkSo)
Removendo switch/case de um reducer
Tags: react, redux, javascript
Published: 2019-10-20 19:34:39

# Por quê fazer isso, afinal?

Não sou um grande fã de blocos `switch/case`. Fazendo alguns testes de performance comparando à mapear objetos literais no Javascript ele se mostrou mais lento. Minha opinião é um pouquinho sem fundamentos lógicos, mas vamos explorar um pouco mais dos por que's logo a frente.

Nota: testes de perf. são legais, sim. Mas por vezes, milisegundos pra mais ou pra menos não fazem diferença pro seu usuário. UX é importante, assim como DX! (Developer experience)

# Problemas com switch/case

Como mencionei acima, "object lookup" performam melhor que `switch/case`'s. Outro problema está em sua sintaxe, todo o resto da linguagem usa `{}` para delimitar escopo, enquanto cada case usa `:`. Usando objetos, não precisamos utilizar `break` ou `return` em cada caso. No nosso caso precisamos de `return`'s pois estamos lidando com reducers e eles precisam retornar uma nova versão do state. Objetos são mais fáceis de testar, pois são apenas objetos! Não entende nada de testes com Javascript? Dê uma olhada [aqui.](https://jestjs.io/docs/en/getting-started.html) 

# Resultado

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

O bloco acima foi retirado de um código que estou trabalhando agora mesmo, o qual contém um reducer de carrinho de compras bem simples. Enquanto olhava aquele switch/case que todo mundo ensina me questionei "e se eu fizesse diferente?". Cheguei nesse resultado e, sinceramente, não está de todo mal :P

## Conclusão

Mostrar a si mesmo que você tem algum domínio em cima da ferramenta o qual você trabalha é um sentimento bacana. Você vê que seu código vai além de fórmulas máginas que você copia do Stack Overflow e etc, e consequentemente você fica mais confiante. Trabalho com Javascript há quase 2 anos (não é muito) e sempre que essas situações me ocorrem, gosto pra caramba.

Legibilidade na sua base de código é importante. Talvez hoje eu ache dessa forma melhor, talvez amanhã eu ache `switch/case` melhor. Tudo vai depender do quão fácil é para entender o objetivo do código. Afinal de contas, não posso me dar o luxo de abrir mão da legibilidade baseado em opiniões totalmente arbitrárias.

Alguma sugestão ou opinião? Fale comigo!

> “Code that communicates its purpose is very important. I often refactor just when I'm reading some code. That way as I gain understanding about the program, I embed that understanding into the code for later so I don't forget what I learned.” 
>
> Martin Fowler, Refactoring: Improving the design of existing code.
Data Structures And Algorithms(Day #1)
Tags: tutorial, beginners, todayilearned, java
Published: 2019-10-20 20:13:57

<b> Hello There, My Gorgeous Friend On The Internet </b>

So, After two and a half years of college and almost a year of serious coding, now I want to start competitive programming. And before starting with the challenges, I decided to brush-up my <i>Data Structure and Algorithms</i> skills.

So I've started learning data structures from today and I decided to start posting about it here to keep track of my progress and to share it with you, comrades.

Check out my GitHub repository for all the programs:

{% github jamesshah/DataStructures no-readme %}


## **Introduction**

Data Structure is basically a way to store and organize data for efficient use. Organized data is far more easy to use than unorganized data.For example, think about the words in a dictionary. They are organized in alphabetical order and thus, it is easy to find a word from it. The same way, when in a computer we need to organize data for efficient and easy use; 
*data structure* is the answer.

Data Structures can be-

 1. Linear
 2. Non-Linear

Basic Types Of Data Structure:
 - Array
 - Linked List
 - Stack
 - Queue
 - Tree 
 - Graph

Tree and Graph are two examples of *non-linear* Data Structure.
The rest of them are *linear* Data Structure.

Now, Let's start with the first Data Structure:

## **Arrays**

Simply, an Array is a collection of elements of the same data type such as Integer or String. So, we can use an array to store data of the same data-type. For example, we can store the "name of people" in a String type Array, we can store "age of people" in an Integer type Array, etc.

 - We access elements of an array using index. arr[i] = ith element.
 - Array index starts from 0. i.e. arr[0] = first element, arr[1] = second element.
 
Here is a simple program implementing an Array in Java.

{% gist https://gist.github.com/jamesshah/a88aa4c99204f242e9cf8103a4e7070b file=OneDimensionalArray.java %}

- We can also create Multi-Dimensional Arrays.
- Multi-Dimensional Arrays are useful to implement Matrices.

Here is a simple program implementing a Two Dimensional Array in Java.

{% gist https://gist.github.com/jamesshah/a88aa4c99204f242e9cf8103a4e7070b file=MultiDimensionalArray.java %}


**Pros:**

 - An array is useful for fixed-size data and when we know the total number of elements already.
 - We can do pretty much all the operations on an array such as inserting an element at a particular position, removing an element from a particular position, read the value of an element from a particular position.

**Cons:**
- It is costly to implement dynamic array. i.e, When we don't know the size of an array, we randomly create an array of some size and if we need to put more elements than the size of our array - we need to create a new array of double size, copy all the elements of old array to the new array, and then insert new elements. It is costly in terms of time complexity and thus, not practical.


**Thanks For Scrolling, Stick Around✌🏻.
Happy Coding!**💻🖤
What role has luck played in your career?
Tags: discuss, career
Published: 2019-10-20 19:42:28

---
title: What role has luck played in your career?
published: true
description: Do you feel lucky, punk? Well, do ya?
tags: discuss, career
cover_image: https://thepracticaldev.s3.amazonaws.com/i/hxsb5vzznyc6pwpu9xv6.jpg
---

I think we don't recognize the role of luck enough in our lives/careers.

Let me give you an example from my own life:

I was talking with my boss recently and he brought up why he looked at my application out of the hundreds he got (remote positions advertised on StackOverflow get a LOT of applications).

Basically the whole reason I have the job I have is because the first guy who hired him for a dev job is named Paul Cook so when he saw my application he was curious if I was his former boss.

And that was the reason he gave me a call.

Of course, I had to interview well and be a compelling candidate, but with hundreds of other people applying he could have just as easily never taken a look at my resume.

So, what about you? 

What role has luck played in your career?
30 Day Challenge: 30 Posts in 30 Days
Tags: productivity, beginners, javascript, react
Published: 2019-10-20 19:33:46

---
title: 30 Day Challenge: 30 Posts in 30 Days
published: true
description: 30 Day Challenge: 30 Posts in 30 Days.
cover_image: https://thepracticaldev.s3.amazonaws.com/i/l1ti0i2seavn2qcrnara.png
tags: productivity, beginners, javascript, react
---

My **[first 30 Day Challenge](https://dev.to/miku86/30-day-challenge-finish-line-3imn)** was a huge success & an awesome experience.

Therefore, I announce Round #2.
This time "**30 Day Challenge: 30 Posts in 30 Days.**".

### My **Why** changed a little bit

- I want to strengthen my **"Finding a solution, no matter what"**-skill (I will go on vacation for 5 days & I'll post on [miku86.com](https://miku86.com/) too.
- I want to strengthen my **shipping** skills. I am very good at starting small hobby projects, but then I am afraid that nobody will be interested in them & finally I don't ship them.
- I want to **tackle my fear** of "Nobody cares.".
- I want to strengthen my **writing skills**. (=> simpler to understand)
- I want to benefit from **social accountability**.
- I want to **share my knowledge**.


### Rules

- deadline: 19.11.2019, 23:59 UTC +1
- no copy of an old post

### Questions

- What are your experiences with these kind of challenges?
- Love to hear your feedback, tips, suggestions!

**PS:** If you want to reach out to me or have a question (I love beginners' questions, **beginners are welcome!**), [send me a message](https://miku86.com/). **100%** response rate!
Directories within root after upgrading to MacOS Catalina (10.15)
Tags: catalina
Published: 2019-10-20 19:16:34

After upgrading to MacOS Catalina, you would no longer be able to create directories in the root directory. On attempting to create a directory, you would see a “Read-only file system” error:

  Nitins-MacBook-Pro:/ nitin$ sudo mkdir -p /data/db
  Password:
  mkdir: /data/db: Read-only file system
  Nitins-MacBook-Pro:/ nitin$ 

Upon upgrading, directories existing within the root directory are moved to the path “/Users/Shared/Relocated Items/Security“ and a shortcut on the desktop named “Relocated Items” is created.

Also see: "Dedicated system volume" at https://www.apple.com/macos/catalina/features/
Setting Up a Svelte Project (in seconds) with Degit
Published: 2019-10-20 19:04:01

Getting started with Svelte can be a little bit intimidating for JavaScript developers familiar with one of the more mainstream front-end frameworks.

Thankfully, [Rich Harris](https://github.com/Rich-Harris) (who started Svelte) wrote a useful scaffolding tool called [degit](https://github.com/Rich-Harris/degit). The premise of degit is extremely simple by design -- it copies existing git repositories.

All you need to do is install degit with your preferred package manager:

```sh
npm install -g degit
```

Then, you can use the tool to create copies of a git repository (you can specify if you want to use BitBucket or GitLab, but it defaults to GitHub repositories):

```sh
npx degit user/repo-name target-directory
```

As it happens, Rich set up a [template](https://github.com/sveltejs/template) for Svelte projects that should be used with degit. To get up and going with a Svelte project all you need to do is run:

```sh
npx degit sveltejs/template my-svelte-project
```

This will set you up with a copy of the official Svelte template in a new directory called my-svelte-project. It's important to note, your copy will not be a git repository, if you plan to use git for version control, you'll have to run `git init`.

So what does the Svelte template set you up with?

The template's dependencies are pretty lightweight. Basically, you're getting Svelte, Rollup, sirv-cli, and with a few simple scripts to make development easier.

The basic structure is also super simple; you're given a `src` directory for your Svelte code and a `public` directory where your compiled code will be output.

Here is a list of the scripts you end up with:


```
"build": "rollup -c",
"autobuild": "rollup -c -w",
"dev": "run-p start:dev autobuild",
"start": "sirv public --single",
"start:dev": "sirv public --single --dev"
```

So, in this case, running `npm run build` will compile the Svelte code in your `src` folder, you can set the project to automatically compile on save with `npm run autobuild`. You can save time by running `npm run dev`, which will kick off a server for you and automatically compile your code when you make changes.

I'll run through an example, to illustrate exactly how easy it is to make a new Svelte project.

```sh
npm install -g degit # install degit
npx degit sveltejs/template my-svelte-project # copy the Svelte template

cd my-svelte-project
npm install # install dependencies

npm run dev # kick off a server and auto-compile
```

Now I can navigate to `localhost:5000` and I'm greeted by a simple `Hello world!` Any change to a Svelte file will result in a compilation step and be autoloaded by my browser.

### There's more...

I'm writing [a lot of articles](https://jh.codes) these days, I run a [podcast](https://www.devpath.fm), and I've started sending out a [newsletter digest](https://pages.convertkit.com/674caf55d4/f30f7753a7) about all of the awesome stories I'm hearing.

You can also follow me on [Twitter](https://twitter.com/jakeherrington), where I make silly memes and talk about being a developer.
Array Transformations With `reduce()` Method
Tags: javascript, reduce
Published: 2019-10-20 18:53:55

JavaScript Array has an excellent method `reduce()` that can do amazing transformations with arrays, like flatten it or transform to other data types.
This method runs and executes a provided function on every value of the array and outputs a single value.
In this article, I'd like to share a few examples of how to use it in different cases.

## Method Structure

The method takes a callback and initial value. The callback takes four arguments:
- accumulator - accumulates return value
- value - current value that is processed
- index - index of the current element (optional)
- array - source array (optional)

```jsx
Array.prototype.reduce(function(acc, value, ?index, ?array), ?initialValue)
```
The initial value is optional. If it not provided, the callback will take the first array element and use it as the initial value. If the initial value supplied, the following array elements will run against it, accumulate new results, and you have to make sure you will return it from the function.

Also, I need to mention that running a reducer on an empty array will result in throwing an error. Always check and make sure that the array has at least one element.

## Use Cases

Below you'll find three examples, how you can reduce and transform arrays for your benefit.

#### Return a Sum of Values

If you have an array of numbers, it is straightforward to get a sum of them.

```jsx
[1, 2, 3].reduce((acc, value) => acc + value); // output 6
```
We don't need to specify an initial value. The reducer function will take the first element `1` and use it as a start value to accumulate and return a new result. With arrow function, you don't need to specify a return statement. The new result will be returned by default.

#### Return a Count of Instances

Group values into and object to know how many times a value gets repeated in an array:

```jsx
['a', 'b', 'a', 'c', 'b'].reduce((acc, value) =>
  acc[value]
  ? { ...acc, [value]: acc[value]++ }
  : { ...acc, [value]: 1 },
{})
// output { a: 2, b: 2, c: 1 }
```

Here we specified the initial value as object and on each iteration of arrays element doing a check if the value exists in the object. If it does, we return the object with the previous values (`...acc`) and an incremented value `[val]: acc[val]++`. 

#### Flatten Arrays

If you have an array of arrays, you can easily flatten the values and reduce to one array of values with a litle help of spreading:

```jsx
[['a', 'b'], ['c'], ['d', 'e']].reduce((acc, value) => [...acc, ...value], []);
// output [ "a", "b", "c", "d", "e" ]
```

## Sum Up

`reduce()` method is compelling and flexible, can combine different array methods, like `map()` and `filter()`. Perform mathematical operation or run asynchronous code in the sequence. And because it is flexible, there is more space for mistakes. When combining a few methods and processes into one, it is hard to understand the intention and debug it.
I Completed the 2019 Hacktoberfest... But! 
Tags: discuss, hacktoberfest
Published: 2019-10-20 18:08:13

This is my first time to join and complete the Hacktoberfest and I enjoyed the heck of it. Not only that, but it was also my first time making PR request and getting merged into one of the projects I contributed!

BUT!

There's one thing I'd like to ask you about this one:

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

Why would they not ship the swags to my country, Somalia? Is it because of the US embargo or logistic issues? I joined the event knowing that I won't receive any of it, which is okay, to be honest. I just want to know why the organizers make this decision.

P.S.: For the record, we have a DHL and Aramex offices in my town.
Ruby(Opal) + Express.js + Socket.io. Real time chat Server implementation
Tags: ruby, realtime, node, socketio
Published: 2019-10-20 17:47:54

---
title: Ruby(Opal) + Express.js + Socket.io. Real time chat Server implementation
published: true
description: Reference implementation of a server using ruby + js libraries
tags: ruby, realtime, nodejs, socket.io
---

# Opal implementation of a simple server with Express and Socket.io

Link to the implementation: https://github.com/sebyx07/opal-express-socketio


Demo https://opal-realtime-socket-express.herokuapp.com/

### Run

Installation
```bash
git clone https://github.com/sebyx07/opal-express-socketio.git opal-server
cd opal-server
bundle install && yarn install # install deps
```

Update index.html
```js
var socket = io.connect('https://opal-realtime-socket-express.herokuapp.com', {transports:['websocket']});
// with
var socket = io.connect('http://localhost:8000', {transports:['websocket']});
```


### Usage

Replace

`rake` it's the default rake task that starts the server

go to http://localhost:8000


```ruby
Server.new(8000) do |s, io|
  s # you can access express methods: with get, post, use, etc. Most is supported
    # callbacks, you replace them with do; end blocks

  io # you can use socket-io methods: on, emit etc. Most is supported
     #  socket must be wrapped using Native()
end
```


### Example server usage

```ruby
Server.new(8000) do |s, io|
  # express part
  s.use(Logger) # use middlewares
  s.start! # start the server

  s.get("/") do |_, res| # handle get to root request
    res.sendFile(s.view("index.html")) # send the index html file
  end

  s.get("/:name") do |req, res| # handle dynamic requests
    res.send(req.params.name)
  end

  # socket io part
  io.on 'connection' do |socket| # initialize socket io connection
    socket = Native(socket) # if you have problems with apply for a object, just Native() it

    socket.on('chat message') do |msg| # listen for messages
      io.emit('chat message', msg) # send it back, to all clients
    end

    socket.on('disconnect') do # handle disconnect
      p "disconnect"
    end
  end
end
```

Hopefully, someone will pick this up and build a framework around it. Like with Hyperstack
A rap song about tech interviews
Tags: showdev, culture, discuss, interview
Published: 2019-10-20 17:46:10

---
title: A rap song about tech interviews
published: true
description: https://www.youtube.com/watch?v=sClpvvYIs2s
tags: #showdev, #culture, #discuss, #interviews
---

Song url: https://www.youtube.com/watch?v=sClpvvYIs2s

Quick background on the project: I'm a full time programmer and I love making rap music. I see a lot of humor in the profession/industry, and thought it would be fun to combine the two.

I'm always open to feedback and collaboration (currently in CO, would love to work with a videographer to make a music video)!
Building REST APIs with Java Spring Boot framework
Tags: restapi, java, springboot
Published: 2019-10-20 17:40:17

---
title: Building REST APIs with Java Spring Boot framework
published: true
description: This guide is designed to get you productive as quickly as possible and using the latest Spring project releases and techniques as recommended by the Spring team.
tags: REST API, Java, Spring Boot
canonical_url: https://ranvir.xyz/blog/building-restful-apis-with-java-spring-boot-framework-for-beginners/
---

Java is one of the most widely used programming languages in the world. Not only it is widely used, but it is also being used as the core part of the top software companies in the world. So, if your dream is to work for those top companies, you better know a little bit of Java.

This tutorial will help you to create a CRUD(Create, Retrieve, Update and Delete) based application. In this tutorial, we will create every API for a school management system.

Outcome and Goals
After going through this guide, you will be able to build complex applications using Spring Boot framework.

I would encourage you guys to create a small project of your own as well, as we move forward in this guide.

Why Spring Boot?
While building a web application, the main goal of the developer is to get the application out as quickly as possible. The developer should not be worried about the configuring various layers of the system.

Spring Boot helps us to remove that hassle and helps us to build us stand-alone, production-ready applications that Just works.

With that definition, you might be feeling that this framework is just for small level applications. But that is not true. You can build fairly complex systems using this framework.

[Read the full Post](https://ranvir.xyz/blog/building-restful-apis-with-java-spring-boot-framework-for-beginners/)