teleren/devto huggingface dataset:
Pushing Left, Like a Boss, Part 5.14 Secure Coding Summary
Tags: applicationsecurity, tutorial, beginners, appsec
Published: 2019-09-19 01:51:58

---
title: Pushing Left, Like a Boss, Part 5.14 Secure Coding Summary
published: true
description: This article will summarize the previous articles in Part 5 of this series, and is hopefully something that you can use for your organization as a start for a secure coding guideline for your developers.
series: Pushing Left Like a Boss
tags: applicationsecurity, tutorial, beginners, appsec
---
###This series, and my blog, have moved! [Check it out](https://wehackpurple.com/g8tg)!
---

This article will summarize the previous articles in Part 5 of this series, and is hopefully something that you can use for your organization as a start for a secure coding guideline for your developers. 

###16 Secure Coding Guidelines

* 1. [Input validation](https://code.likeagirl.io/pushing-left-like-a-boss-part-5-1-input-validation-output-encoding-and-parameterized-queries-ad1d4e7136c9) should be used in every possible scenario. This includes [Redirects and Forwards](https://code.likeagirl.io/pushing-left-like-a-boss-part-5-6-redirects-and-forwards-3d97bf46609c).
* 2. [Output Encoding](https://code.likeagirl.io/pushing-left-like-a-boss-part-5-1-input-validation-output-encoding-and-parameterized-queries-ad1d4e7136c9) is required for all output.
* 3. [Parameterized Queries](https://code.likeagirl.io/pushing-left-like-a-boss-part-5-1-input-validation-output-encoding-and-parameterized-queries-ad1d4e7136c9) are mandatory.
* 4. All 3rd party code must be [verified not to contain known vulnerabilities](https://code.likeagirl.io/pushing-left-like-a-boss-part-5-2-use-safe-dependencies-5bda811506).
* 5. Every applicable [security header](https://medium.com/bugbountywriteup/security-headers-1c770105940b) should be used.

###[Read the rest on my NEW blog!](https://wehackpurple.com/icr9)!
Get Last Inserted Id In Laravel 6
Published: 2020-02-10 10:12:06

---
title: Get Last Inserted Id In Laravel 6
published: true
date: 2019-09-19 00:00:00 UTC
tags: 
canonical_url: 
---

In this example i will give you simple example of how to get last inserted id in laravel 6 you can simply get laravel 6 get last inserted record id with examplewhen you create databaseyou many a time use primary key column using the AUTOINCREMENT attribute that means when you insert new re
Naming Things
Tags: javascript, cpp, productivity, jokes
Published: 2019-09-18 23:27:09

So I was implementing a `forEach` method and asked my co-worker, "is there a name for a for-loop that iterates backwards? Something like:"

```javascript
for (let i = myObj.length - 1; i >= 0; i--) { ... }
```

Of course, there wasn't one. So I set out to create one.

Meet `rofEach` and the `rof loop`. It's not only the word "for" backwards, it also means "Reverse Order For".

You're welcome, world. 🎤⬇️
Illusion of differences between Operating Systems, Programming Languages and Web Frameworks
Tags: kanban, wekan, framework
Published: 2019-09-18 21:21:02

---
title: Illusion of differences between Operating Systems, Programming Languages and Web Frameworks
published: yes
description: Illusion of differences between Operating Systems, Programming Languages and Web Frameworks
tags: kanban, wekan, framework
---

You see all those flamewars about Operating Systems, programming languages, web frameworks, and discussion about some of them are "dead" ?

Yes, I tried them all.

After maintaining Wekan many years since 2016-12, I tried updating another kanban software, made with Go and Angular.

Summary: Kanban software is all the same. Same acrobatics to update dependencies. Same kanban features. Same bugs that have already been fixed in Wekan. If both Wekan and that other kanban software used same CSS, user could not see any difference. It does not depend on programming language and web framework.

You have an illusion that there is any benefit or major difference between programming languages and web frameworks, or that those small differences matter in any way.

There is no spoon.

Do NOT participate to any of those flamewars.

So now, please go back to contributing to Open Source.

Best Regards,
xet7

(posted originally at: https://blog.wekan.team/2019/09/illusion-of-differences-between-operating-systems-programming-languages-and-web-frameworks/index.html)
Java 13 is here!
Tags: java, discuss
Published: 2019-09-18 20:51:05

It's official, Java 13 is finally here with new features/improvements. The last 4 releases including this one were pretty quick and most of the people are still working on the older versions. 

Which version are you currently working on?
When are you planning to move to a newer version?

I am currently working on Java 8 and planning to move to Java 9 but I feel there's plenty to catch up.
Embedded Storage for Your Node.js Projects
Tags: javascript, mongodb, testing
Published: 2019-09-18 20:12:25

Sometimes you want to throw together a site quickly and setting up another storage server and connecting to it seems too expensive, too time consuming, or you've used up all your free clusters at MongoDB Atlas 😀.

Everybody needs a quick and dirty storage solution available to pull out for those cases. In this video I build a simple authentication system using NeDB (which looks a lot like MongoDB) and show how I built it by starting with Mocha/Chai unit tests.

{% youtube U_WX915_njc %}

In the next video I'll show how almost all of the code I wrote works just as well with MongoDB, giving you a natural growth path for when your side project becomes popular.
Sticky Footer with Flexbox
Tags: sticky, footer, flexbox, css
Published: 2019-09-18 19:27:03

Flexbox is a method of positioning elements in horizontal or vertical stacks and in my experience, the best method to keep a footer at the bottom of a page.
```HTML
<body>
  <nav></nav>
  <main></main>
  <footer></footer>
</body>
```
To keep a footer stuck to the bottom of the page or the viewable window using Flexbox, you will need to:

  1. Set the footer's parent element's CSS `display` value to `flex` and `flex-direction` value to `column`.```CSS
body {
      display: flex;
      flex-direction: column;
}
```
    `display: flex;` makes the `<body>` element a flexible box layout module and enables a flex context for all its direct children.
    
    `flex-direction: column;` stacks all the children elements in a vertical top-to-bottom position.

  2. Set the footer's sibling expandable element's CSS `flex` value to:
    * `1` - to stick the footer to the bottom of the viewable screen 
    * `1 0 auto` - to stick the footer to the bottom of the page
    ```CSS
main {
      flex: 1 0 auto;
}
```
     `flex: 1;` defines the ability of the element to grow if necessary. If there is available space inside the flex container, the item should take it up. This then pushes the `<footer>` down and stuck to the bottom.

Common Gotchas:
  * Main content element does not expand to occupy all available space.
    - applying `min-height: auto;` to the `<main>` element will fix this.
    - Also, make sure that the body element's `height` is set to `100%`.
```CSS
body {
  display: flex;
  flex-direction: column;
  height: 100%;
}

main {
  flex: 1 0 auto;
  min-height: auto;
}
```
If you are new to flexbox and would like to learn more and understand how it works, [this comprehensive guide to CSS flexbox layout explains everything about the method.](https://css-tricks.com/snippets/css/a-guide-to-flexbox/)
Migrating API from Laravel to NestJS
Tags: discuss, help, node, laravel
Published: 2019-09-18 19:21:09

---
title: Migrating API from Laravel to NestJS
published: true
description: Confused about migrating 2 years of work to another language.
tags: discuss, help, node, laravel
---

> I want your opinion

I've been working as a full-stack developer on mobile and web-based application backed by an API built in Laravel for 2 years. 

Fast forward to today we have 3 developers (excluding myself) working on the same code. 

Recently I've been seriously considering migrating the API to JavaScript. After doing some research I decided on NestJS.

When I started looking at javascript (NodeJS) I was disappointed. None of the backend libraries or frameworks offered as much as Laravel does. I had to setup up very trivial things like server-side validation, dependency injection, error logging, etc. things which Laravel offers right out of the box. NestJS removed most of these concerns. 

###Pros of Migrating to NestJS
* I have a personal desire to shift my work to JS. 
* Migrating backend to JS closes the language barrier between frontend and backend devs. 
* I can handle testing both frontend and backend with Jest.
* There are a lot more developers for Node and JS than for Laravel.
* JS ecosystem (npm) is much better than PHP's ecosystem.
* Node seems to have a leg up in terms of performance. 
* Unfortunately Laravel is cursed by its language of choice (PHP). This scares away a lot of potential new developers.

> Note that I run a team and have to retain my employees. I also need to consider what resources are available in case I hire more employees.

###Cons of Migrating to NestJS
The only issue I have is the time and effort I will have to put in to migrate all our work to a new framework. I (and my team) are comfortable with Laravel but want to migrate to NestJS.

I just wanted to get more opinions about whether migrating is a good or bad idea? And do you think it will be worth it in the long run or not?
the dreaded port error "bind: address already in use", kill it!
Tags: bash, webdev, node, discuss
Published: 2019-09-18 19:18:57

---
title: the dreaded port error "bind: address already in use", kill it!
published: true
description: A quick solution for finding the thing that is using your port
tags: bash, webdev, node, discuss
---

tl;dr:  `lsof -i :<PORT>`, then get PID and run next command with it (be careful running this command) `kill <PID>`. If you want a all in one, you can use this! `kill $(lsof -i :<PORT> | awk 'NR>1 {print $2}')`

So you're cruising along and you go to start your service, just to find out that you had something running on that same port you needed. 

DOH! 

Well here is a quick solution. Just swap out <port> with lets say 3000, or what ever your port is.

`lsof -i :<port>` 


You should see something like this. If you get a empty response, then nothing is running on the port. 
![output of lsof command](https://thepracticaldev.s3.amazonaws.com/i/eltkedfhwyba4pc8yf8a.png)

Now you had the PID, which for our example is `28913`. 

This next part needs your attention! I'm going to show you how to kill the process but ONLY DO THIS IF YOU TRUST YOU KNOW THE PROCESS you're about to kill.

If you kill a process that you have no clue what is doing, it could affect your system in a negative way.

If you kill a app that is in the middle of saving, it could corrupt your data. 

So just be smart before blindly running the next command. 

I see that it's `com.docke` so I know it's docker. I'm find killing it.

`kill -9 28913`. 


**UPDATE**
So as Ben Sinclair mentioned, avoid using -9 with `kill` since it's dangerous. First try `kill $PORTNUMBER`

You now freed up the port. If you run `man kill` you'll see a list of the different signals. 


     1       HUP (hang up)
     2       INT (interrupt)
     3       QUIT (quit)
     6       ABRT (abort)
     9       KILL (non-catchable, non-ignorable kill)
     14      ALRM (alarm clock)
     15      TERM (software termination signal)

-9 forces it to quit no matter what. 

If you want to do a one in all, where it looks up the port and then tries to kill it right away, you can do this command. `kill $(lsof -i :<PORT> | awk 'NR>1 {print $2}')`, if you get the message `kill: not enough arguments` then it's because no process is found for the port so your port should be free. Otherwise, it'll kill and return a new empty line on success.

Have a better solution? Leave a comment! 


---

Varymade LLC.

Current projects are https://charactergenerator4000.com and https://coder.exchange. Please check them out and let us know your thoughts.
Python's enumerate function
Tags: python, beginners
Published: 2019-09-18 19:11:06

This is just a quick post because I've seen some python beginners make some functions that are really in need of `enumerate`, but they don't know it and turn to odd solutions.

## What does it do?

Put simply, `enumerate` is a function that takes in an iterable (typically an array) and, for each item, gives both its index in the array and the item itself.

## When should I use it?

I've seen this:

```
array = ["a","b","c","b"]
for index in range(len(array)):
    item = array[i]
    # code continues using both `index` and `item`
```

This really doesn't hurt too much but `enumerate` can make this a bit cleaner.


In my early days of Python I created a monstrosity like this:

```
array = ["a","b","c","b"]
for item in array:
    index = array.index(item)
    # code continues using both `index` and `item`
```

This is actively bad code, and my thinking "There must be a better way to do this" finally led me to `enumerate`.
The main issue with this, other than possible performance issues if the array is quite long, is that `array.index` only returns the *first* index of the item. That means that the second `"b"` in the array will never get its index (3) run in the rest of the `for` loop. Instead, `array.index` will return 1 for both `"b"`s.

## How should I use it?

`enumerate` is incredible easy. All that is needed is:

```
array = ["a","b","c","b"]
for index, item in enumerate(array)
    # code continues using both `index` and `item`
```

Look at how clean that is. That uses fewer lines than both code blocks above, and is arguably the most explicit and easiest to understand.

List comprehensions can also be used for filtering lists.

Let's say that we want all odd-indexed items that are vowels.

```
test_letters = ["a", "e", "i", "q", "c"]
vowels = ('a','e','i','o','u')

# Not using `enumerate`, just plain old logic
# This ca be confusing, especially if it wasn't documented.

new_arr = []
for i in range(len(test_letters)):
    if i % 2 == 0 and test_letters[i] in vowels:
        new_arr.append(test_letters[i])


# With enumerate
# It's only one line and still makes a ton of sense.

new_arr = [letter for index,letter in test_letters if index % 2 == 0 and letter in enumerate(vowels)]
```

`enumerate` is an incredibly useful function, and anyone learning Python should be using it.
Having issues with Gatsby and Netlify CMS
Tags: help
Published: 2019-09-18 18:19:37

I recently discovered how powerful JAM Stack is and how CMS made it easy for managing sites (especially managing blogs).

I also run a personal blog and found this interesting.

I followed the documentation on the how-to and I have the CMS running. When I make changes in the CMS, it creates pull requests and on publishing, it merges the request.

The issue I have now is that even after deployment, I don't see the new articles on the Netlify domain given to me. (But there are changes in my GitHub repository)

I need help please
What does Javascript better than Kotlin?
Tags: healthydebate, kotlin
Published: 2019-09-18 18:18:38

Serious question, not a troll. Javascript and Kotlin are two very different languages but it's always interesting to take a look at what other developer communities are doing. 

If you know both languages, are there any particular aspects that you find Typescript does better than Kotlin?

Or if you are a front-end developer and don't know Kotlin, what are the parts of Javascript/Typescript where you find that the language is at best, concise, safe and eloquent?

----

The inspiration for this question comes [from my last post](https://dev.to/jmfayard/with-configobject-language-kotlin-issparkingjoy-ic4), I wrote about a nice pattern I found for extracting constants in [Kotlin](https://kotlinlang.org)

```kotlin
with(ConfigObject) {
    println("Language $KOTLIN is sparking $JOY")
}
```

And I was blown away by a comment from KIP who reminded my that almost the same exact thing was possible in Javascript

```typescript
with(ConfigObject) {
    console.log(`Language ${TYPESCRIPT} is sparking ${JOY}`)
}
```

Kotlin is a very nice language, but also a relatively new one and there are still new useful patterns to discover. So I wondered: could I not accelerate this process by taking inspiration from [Javascript's good parts](https://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742)?

I looked at the code produced by colleagues from the front-end, and one thing I like is [object destructuring](https://www.typescriptlang.org/docs/handbook/variable-declarations.html#object-destructuring)

```typescript
const {id, firstName, lastName} = person
```

Kotlin also has [object destructuring](https://kotlinlang.org/docs/reference/multi-declarations.html#destructuring-declarations)
 

```kotlin
val (id, firstName, lastName) = person
```

But in my experience, it's not used very much. One problem is that it is **position-based**. The code above may we working right now, but if someone changes the order of the properties in the `Person` class, the code will fail. Typescript named-based approach is clearly better. Having realized that, I discovered a proposal to implement the same solution in Kotlin https://youtrack.jetbrains.com/issue/KT-19627

Good solution in the long term. But in the long term, we are all dead!

Can I somehow find a pattern that works now to implement something like what Typescript does? As it turns out: YES

{% kotlin https://pl.kotl.in/xXmq1WpKi?theme=darcula %}

Here I used again `with` to transform what I need from my object into something I can easily destructure. It's much more general than what Kotlin offers by default, which works only for "the properties of a data class or a Tuple".
Creating vs Consuming VWC
Tags: javascript, beginners, firstyearincode, html
Published: 2019-09-18 18:12:39

![image of painters hands](https://github.com/gixxerblade/VetsWhoCode/blob/master/weekTwo/paint.jpg?raw=true "Photo by Amaury Salas on Unsplash")

Are you a creator or a consumer?

What kind of person are you? Do you wake up first thing in the morning and check Facebook or do you go and exercise? 

It's easy to fall into a rut, sitting there, binge-watching Netflix, when we know there are better things to do.

Sometimes we consume too much. As developers, we should be trying to build something daily. For example, I am currently going through a coding bootcamp with [Vets Who Code](https://vetswhocode.io/). We are required to create something every daily. Usually, it is through daily code challenges but it can also be something like this article, writing for [dev.to](https://dev.to). There are many different products that have code challenges on them that are suited for beginners, like me. One I like is [edabit](https://edabit.com/challenges). There are pages and pages of code challenges that are both fun and challenging for every beginner to conquer. 

What happens is that beginner's get caught in a tutorial loop, where you don't progress past a certain point. Creating something gets you past that point. It wakes up your brain and makes you want to learn more.

If you are having problems with finding something to create, look deeply at yourself and find your passions, your likes. What are you, as a person, most interested in? Just start with three. For me, its cycling 🚲, my [pickle business](http://www.angrypickles.com/) 🥒, and motorsports racing 🏍. 

There isn’t an exact formula for balancing creation with consumption. It doesn't even mean a 50/50 split. What you need to do is find where you sit and lean towards creating something every once in a while. 

The easiest place to start is to ask yourself two questions:

1. How much have I created in the last month?
2.  How much have I consumed in the last month?

A wise person once told me: "Never stop learning. Pair code with your passions." 

How do you balance creating with consuming? Answer below.
Combining useContext with useReducer (video)
Tags: react, javascript, redux, hooks
Published: 2019-09-18 17:55:36

This is a powerful pattern which gives you a lot of the functionality that Redux provides, with just 2 hooks that come built-in to React.
{% youtube u06qAON66iw %}
Source code available here: Code available at: https://github.com/leighhalliday/demo-infinite-scroll/blob/master/src/WithContext.js
How would you deal with a client who rejected a prototype because of a "lorem ipsum" placeholder?
Tags: discuss, webdev
Published: 2019-09-18 17:38:23

I just sent a Balsamiq cloud prototype to a client and when she replied, I felt like she was mad for seeing lorem ipsum on the prototype.

I politely explained what lorem ipsum was and the purpose of it but she insisted that the content should've been in english so she would know and understand the content of the website and how it would look.

I ended up using hipsum for the placeholder then replied that she'd look for a different provider for their website instead.

How would you feel? How would you go about it? I'm just curious.

Also, there's an email address of a person on the site. Should I email the person directly? This person I'm speaking to gave me her gmail instead of an email address with the company's domain. I'm really pissed right now and think that I should send my proposal to the contact person on the site.

Any reply would be appreciated.
Dear Technology, ...
Tags: discuss
Published: 2019-09-18 17:46:26

---
title: Dear Technology, ...
published: true
description: Open letters from the users to the technology. 
tags: discussion
cover_image: https://thepracticaldev.s3.amazonaws.com/i/tjc6garhdey8p9e8ebzs.jpg
---

I saw this tweet during the recent #DevDicuss on Twitter. 

{% twitter 1174135015485186053 %}

I like the format of writing open letters to technology. Obviously technology cannot respond or even defend itself. But it's good to write away your annoyances. 

What is your _Dear Technology, ..._ letter?
Is Python Object-Oriented or Procedural Language
Tags: python, oop, pythondevelopers
Published: 2019-09-18 17:40:09

Python is widely used in the programming language of today. It has gained great success in the field of scripting, data analytics, machine learning and much more.

But, as a programmer and developer, it becomes mandatory to verify if Python supports the concepts of Object-Oriented Programming Language (OOPS)

Read a detailed tutorial at Is Python Object Oriented
Can NuxtJS handle a site with 150K pages?
Tags: help
Published: 2019-09-18 17:15:20

---
title: Can NuxtJS handle a site with 150K pages?
published: true
tags: help
---

I was thinking of moving one of my sites created in Laravel + Mysql to NuxtJS.
The site contains over 150K pages. Is it possible to move this over to NuxtJS. 
I would like to just make an API for the content and NuxtJS will read data via Axios. The question is if the prerendering is enabled in NuxtJS the number of pages is the issue or not.