teleren/devto huggingface dataset:
Python code to copy all objects from one S3 bucket to another
Tags: s3, python, aws
Published: 2019-01-15 04:25:06

---
title: Python code to copy all objects from one S3 bucket to another
published: true
description: This is a very simple snippet that you can use to accomplish this 
tags: s3, python, aws
---

```python
import boto3

s3_resource = boto3.resource('s3')

new_bucket_name = "targetBucketName"
bucket_to_copy = "sourceBucketName"

for key in s3.list_objects(Bucket=bucket_to_copy)['Contents']:
    files = key['Key']
    copy_source = {'Bucket': "bucket_to_copy",'Key': files}
    s3_resource.meta.client.copy(copy_source, new_bucket_name, files)
    print(files)
```
Do you find the business world frustrating? Read this book.
Published: 2019-01-15 04:22:03

---
title: Do you find the business world frustrating? Read this book.
published: true
description: 
tags: 
---

I've struggled with why the business/corporate world is the way it is for years now. I've waffled between pragmatist, idealist and opportunist in my career as a dev. This book helps put into words the frustrations I've had.

Would love to hear what others think if they have already read it!

https://www.amazon.com/Developer-Hegemony-Erik-Dietrich/dp/0692866809
How can I loop over this object in React?
Tags: react, loop, json
Published: 2019-01-15 00:08:32

---
title: How can I loop over this object in React?
published: true
description: React, looping over an object
tags: React, loop, JSON
---

Hi,

I'm learning React. In the following component, I import a JS file (data.js), which looks like a JSON file which includes an object.

Inside the return of the TinTinTile class, I use that object to display all data.
In my example bellow, I can only display the first array in the object. But I need a way to loop over the array jsonResponse.characters.

Now my question is:
How can I loop over jsonResponse.characters?


```
import React, { Component } from 'react';
import jsonResponse from './data';

console.log(jsonResponse);
// const ArrayLength = jsonResponse.characters.length;
// console.log(ArrayLength);

// jsonResponse.characters.foEach(function(i) {
//   console.log(i);
// });

class TinTinTile extends Component {
  state = {};
  render() {
    return (
      <ul id="container" className="cf">
        <li className="list-container">
          <img
            className="image-container"
            src={jsonResponse.characters[0].image_url}
            alt="kir"
          />
          <div className="text-container">
            <h4>Name: {jsonResponse.characters[0].name}</h4>
            <p>Job: {jsonResponse.characters[0].job}</p>
            <p>Age: {jsonResponse.characters[0].details.age}</p>

            <button className="btn">More details ...</button>
          </div>
        </li>
      </ul>
    );
  }
}

export default TinTinTile;
```
Manage Docker as a non-root user
Tags: docker, linux, sudo
Published: 2019-09-22 18:10:56

---
title: Manage Docker as a non-root user
published: true
tags: docker, linux, sudo
canonical_url: https://tech.serhatteker.com/post/2019-01/manage-docker-as-a-non-root-user/
---

By default when you install Docker on Linux, you can only access the Docker daemon as the `root` user, or by using `sudo`. Since the Docker daemon binds to a `Unix socket` instead of a `TCP port`. And by default that Unix socket is owned by the user `root`.

Yes, typing `sudo` all the time could be irritating. And sure, there is a solution for this issue but you should be very cautious when using it. Another warning: **Never. Ever.** Use this `shortcut` method in a production server.

If you don’t want to preface the docker command with sudo, create a `Unix group` called `docker` and add `users` to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group.

However this `docker` group grants privileges equivalent to the `root` user. So this is the main reason for warnings. For more details on how this impacts security in your system, see [Docker Daemon Attack Surface][docker-warning] from official Docker website.

OK, if you are sure about the risks and confirm it, let's continue:


1. Add the docker group:

    ```sh
    $   sudo groupadd docker
    ```

2. Add the connected user `$USER` to the docker group. Change the user name to match your preferred user if you do not want to use your current user:

    ```sh
    $   sudo gpasswd -a $USER docker
    ```

3. Either do 

    ```sh
    $ newgrp docker
    ```
    or `log out` and `log in` to activate the changes to groups.

4. You can now run docker deamon without `sudo` prefix. To test it:
   
   ```sh
   $    docker ps -a
   ```



[docker-warning]: https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
Changelog: Reading Time Now Displayed
Tags: changelog, meta
Published: 2019-01-14 23:36:50

The approximate reading time for a post on DEV is now displayed on feed pages as well as at the top of the post.

## Feed

![](https://cl.ly/62257f2280b3/Image%202019-01-14%20at%206.31.19%20PM.png)

## Post Page

![](https://cl.ly/20fb7da5cb45/Image%202019-01-14%20at%206.32.56%20PM.png)

It will likely also be added in places like liquid tags in the future, and anywhere else it could be contextually helpful.

Happy coding!
Domain Modeling Made Functional - Scott Wlaschin
Tags: ddd, fsharp, functional, modeling
Published: 2019-01-14 21:59:50

---
title: Domain Modeling Made Functional - Scott Wlaschin
published: true
description: 
tags: ddd, fsharp, functional, modeling
---

In the pic is a model of a card game. Just a page, short and clear.

![](https://thepracticaldev.s3.amazonaws.com/i/cqfmfn6a81resph2o3av.png)

In this video Scott introduced functional modeling with F#. It combines DDD and functional method. Algebraic types is composing of types. Composing is the power.

![](https://thepracticaldev.s3.amazonaws.com/i/es882kk5sf7yyloqeaid.png)


{% youtube Up7LcbGZFuo %}

# end

[more info](https://fsharpforfunandprofit.com/ddd/)
Anyone impacted by the U.S. government shutdown? Share your story.
Tags: discuss, career, family
Published: 2019-01-14 21:29:11

---
title: Anyone impacted by the U.S. government shutdown? Share your story.
published: true
description: 
tags: #discuss, #career, #family
cover_image: https://thepracticaldev.s3.amazonaws.com/i/6g0f33siml175lsim5qi.jpg
---
Rejection Response Email Discussion
Tags: advice, career, help, discuss
Published: 2019-01-14 20:58:57

---
title: Rejection Response Email Discussion
published: true
description: What to do with responses from rejections? How to self-correct?
tags: advice, career, help, discuss
---
I recently received feedback from a response I wrote after a rejection from a company. I'll paste the relevant parts of the letter without exposing the identity of the company or person kind enough to give me feedback.

>Kevin,
>...
 
>We found you to have a great breadth of technical domain – it’s clear that your passion for tech has carried you to learn many things, but we found that this breadth may have been achieved at the cost of depth.  It’s not only important to know how we can use something, whether a framework, language or library, but by what patterns and how the underlying technology really functions – this is of huge value when things don’t work like they should.
 
>I think you’re on your way to fixing this issue – I found it impressive that you used Node/Express instead of RoR, which I know isn’t what Flatiron taught you.  I’d focus in on the best way to use this stack and look at the different patterns that are being seen out there (containerized microservices, MVC designs, Restful principles, etc.  This depth will serve you well as a core knowledge, and give you greater context into which you integrate more breadth.

It's after this point that he says goodbye and writes his name which would violate the anonymity granted by the internet so I won't post that information. He was kind enough to give me this input and now I have to do something about it. But what? Any recommendations, be they videos, lectures, books to read, etc. are more than welcome. And any personal experiences or stories about this kind of thing would also be great. I shouldn't be the only person to benefit from this.
The 7 Most Popular DEV Posts from the Past Week
Tags: top7, bestofdev
Published: 2019-01-14 20:34:53

---
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, bestofdev
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. Making the most of it

Darren shares a few helpful shortcuts and to help us maximize our github productivity. 

{% link https://dev.to/_darrenburns/8-productivity-tips-for-github-44kn %}

#2. All it takes is practice

Catherine finally took to the time to learn regex and shares a helpful compilation with the community.

{% link https://dev.to/catherinecodes/a-regex-cheatsheet-for-all-those-regex-haters-and-lovers--2cj1 %}

#3. Who are you?

Emma walks us through the importance of a technical portfolio and things to consider for both front-end and back-end developers. 

{% link https://dev.to/emmawedekind/how-to-build-a-great-technical-portfolio-53bb %}

#4. The Python Way

Ever get stuck in a knowledge crater? Where resources are either too simple or too advanced? Jason intends to explore topics that often fall in this category to help Python novices bridge the gap. 

{% link https://dev.to/codemouse92/introducing-dead-simple-python-563o %}

#5. Gasp.

Andrew shares an exhaustive list of bash commands helpful for programmers with all levels of experience. For example, they cover beginner topics such as navigating the file system to more advanced topics like text processing.

{% link https://dev.to/awwsmm/101-bash-commands-and-tips-for-beginners-to-experts-30je %}

#6. With or without Nodemon (and docker-compose)

A guide to debugging Node.js within a docker container. 

{% link https://dev.to/alex_barashkov/how-to-debug-nodejs-in-a-docker-container-bhi %}

#7. A wave of terror

^^ if that's how double pointers make you feel, read this explanation.

{% link https://dev.to/noah11012/double-pointers-in-cc-2n96 %}


_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!_
Communities or servers for remote jobs/gigs
Tags: javascript, react, remote, jobs
Published: 2019-01-14 19:02:12

---
title: Communities or servers for remote jobs/gigs
published: true
description: 
tags: javascript, react, remote, jobs
---

I have my 3 months contract ending by this month and I'm really worried to get a new job because I have had 60+ odd interviews before this from January '17 to October '17 which made me really quit the IT jobs thing and maybe don't know what to do with my life. Finally I landed at this place in October with React+redux dev job and currently there I'm working on Node+Express+Next+React+Redux Fullstack. But it is ending by this month and I'm afraid to go on that interview spree again.

I read this article/post https://dev.to/colinmtech/how-i-find-six-figure-remote-software-developer-jobs-23jd but it seem to mentioning the main slack communities or discord channels part. 

Can someone please share the list of Slack communities or discord servers to help me and others get remote jobs specifically with Javascript stack and/or remote gigs. that would be really beneficial.

The first one I can share is Reactiflux community which is officially mentioned in React Docs as well. So yeah keep sharing to help out. Also somewhere down the line I feel that for Indian developers the bar is way too high for interviews then other western countries and to get a job. May be simply because of sheer amount of volume here.
Thinking Beyond the LAMP Stack
Tags: aws, ses, s3, automation
Published: 2019-01-14 18:59:08

---
title: Thinking Beyond the LAMP Stack
published: true
description: Discover how one woman's journey changed for the better through AWS.
tags: #aws #ses #s3 #automation
---

Well, hello there. I've had a couple people contact me and ask me to write a post about a project I had completed. This is that post. 

I recently had a project come my way where I need to accept user input in the form of an excel sheet, parse through the rows and cells, and post the responses to a third party system, all while generating logs to the original submitter. 

Hm. 

Immediately my mind went to a traditional LAMP (Linux, Apache, MySQL, PHP) stack website where users log in, upload their sheet, and results appear there. 

It seemed to intrusive through, to ask my users to go through these extra steps. Think of the documentation I'd have to write..

Instead, I thought differently. Most individuals in a work environment use email. How do I harness that?

With AWS' SES (Simple Email Service), S3, and Lambda.

![architecture_overview](https://thepracticaldev.s3.amazonaws.com/i/4oh79bn3fgvypee2xget.PNG)

I created a departmental mailbox to use for the purpose of receiving emails from users with an attachment, something simple like risk@company.org, with certain subjects or phrases triggering a mail rule to redirect the email to... aws-risk@email.prod.aws.edu (more on that in the next paragraph).

![route53](https://thepracticaldev.s3.amazonaws.com/i/clxre49rxq0unwhcvpem.PNG)

I utilized Amazon Web Services Route 53 to create a DNS MX record for this purpose-- I named this one email.prod.aws.edu Note: aws.edu is a registered domain in route 53 for the purposes of this scenario.

![ses](https://thepracticaldev.s3.amazonaws.com/i/r2tfl040u5secqa2ohbm.PNG)

Using Simple Email Service I was able to configure aws-risk@email.prod.aws.edu to immediately, upon email arrival, save its contents to an S3 bucket.

![lambda_arch](https://thepracticaldev.s3.amazonaws.com/i/fi2qqs22qg95qbectu70.PNG)

Here's where those of you familiar with Lambda and AWS will "ahhh" to. One of the triggers for a Lambda function is exactly that-- an object created in S3!

![lambda_code] (https://thepracticaldev.s3.amazonaws.com/i/au9t0gfb2ibwxbob6j08.png) "Small section of the lambda function that checks for the item written in S3"

I was able to write all the code in Python, to parse through the rows and cells in the sheet, POST contents to third party system, and send a log back to the user back through SES. All through that one Lambda function, that awesome S3 bucket, and of course, the hero of the show, SES.
The Difference Between Static and Bound Methods
Tags: babel, javascript, react, webdev
Published: 2019-01-14 18:32:55

---
title: The Difference Between Static and Bound Methods
published: true
description: What are the technical differences between static arrow functions and bound methods on JavaScript (Babel) classes.
tags: babel, javascript, react, webdev
---

Recently, at [work](http://inputlogic.ca), we were coming up with our [React Style Guide](https://github.com/inputlogic/styleguides/blob/master/react.md) (based on [AirBnBs](https://github.com/airbnb/javascript/tree/master/react)). One of the "rules" is to avoid binding methods within the render method (as this creates a new function each render), and a teammate mentioned, "why not just use static arrow functions?"

While both solutions were practically equivalent, I worried about the technical differences. Static methods are defined on the Class *not* on each prototype instance. 

## Wait, so how is the arrow function properly binding the correct `this` to the static?!

This magic had me worried. So I pulled up a [Babel REPL](https://babeljs.io/repl) and wrote two classes:

```jsx
class Static extends React.Component {
  onClickDiv = () => {
    // do stuff
  }

  render () {
    return <div onClick={this.onClickDiv} />
  }
}

class Bound extends React.Component {
  constructor (props) {
  super(props)
    this.onClickDiv = this.onClickDiv.bind(this)
  }
  
  onClickDiv () {
    // do stuff
  }

  render () {
    return <div onClick={this.onClickDiv} />
  }
}
```

The transpiled Bound class was as you would expect, but the Static class resulted in: 

```jsx
class Static extends React.Component {
  constructor(...args) {
    var _temp;

    return _temp = super(...args), this.onClickDiv = () => {
      // do stuff
    }, _temp;
  }

  render() {
    return React.createElement("div", { onClick: this.onClickDiv });
  }
}
```

Oh! So maybe these are technically equivilant! But defining a Class method is still a different syntax than defining a function on a `this` reference. So I dropped the transpiled code into a [FireFox scratchpad](https://developer.mozilla.org/en-US/docs/Tools/Scratchpad).

<img src="http://staydecent.ca/assets/media/class-prototypes.png" alt="Screenshot of the Firefox Console showing the Static and Bound prototypes." />

The only difference seems to be a bound class method exists on the prototype whereas the static arrow function does not.

But, how or why would this matter? In my experience, it usually doesn't, unless you want to mock a class method in your tests (by overriding the definition on the prototype), or — [god forbid!](https://reactjs.org/docs/composition-vs-inheritance.html) — you plan on extending the class.

In the end, because of the techincal difference, we aren't enforcing static methods over bound methods in our style guide, rather both are fine, as long as you're aware of the implications.

Have I missed any other differences between the two? I'd love to know if there's other details to consider.
Coding an Instagram Like Bot with NodeJs
Tags: instagram, node, puppeteer, scraping
Published: 2019-01-14 18:01:57

---
title: Coding an Instagram Like Bot with NodeJs
published: true
description: 
tags: instagram,nodejs,puppeteer,scraping
---


Hey there to everyone,

I just wanted to share this here because maybe someone can learn something from it.

# What? 💻
Yes, I've built an Instagram bot that basically does the following:

- Opens up the Instagram Login page
- Logs in with specific **username** and **password**
- Goes through an **[array]** of tags and loops over them to get the latest 3 images
- Click on the images, like them, close the modal 
- AND REPEAT UNTIL IS STOPPED.

# Why? 

For fun and for educational purposes only, I do not recommend you to use this code in order to spam Instagram.

Therefore this time, I did not give out the Full Code.

# How?

Here is how,

A **40+ minutes** video that I just recorded in about **4 hours**.

Enjoy 🔥

{% youtube jw4exv4qv2E %}

Ps: I also post more about NodeJs and Data Scraping on my blog -> **[LearnScraping.com](https://learnscraping.com)**
Updated Step by step: Serilog with ASP.NET Core
Tags: aspnetcore, serilog
Published: 2019-06-04 19:51:14

---
title: Updated Step by step: Serilog with ASP.NET Core
published: true
tags: aspnetcore,seriLog
canonical_url: https://carlos.mendible.com/2019/01/14/updated-step-step-serilog-asp-net-core/
---

Many of you come to my site to read the post [Step by step: Serilog with ASP.NET Core](https://carlos.mendible.com/2016/09/19/step-step-serilog-asp-net-core/) which I wrote in 2016 and is completely out of date, so with this post I will show you how to setup [Serilog](https://serilog.net/) to work with your ASP.NET Core 2.2 applications.

## 1. Create an ASP.NET Core project

* * *

```
md aspnet.serilog.sample
    cd aspnet.serilog.sample
    dotnet new mvc
```

## 2. Add the following dependencies to your project

* * *

```
dotnet add package Microsoft.AspNetCore.App
    dotnet add package Microsoft.AspNetCore.Razor.Design
    dotnet add package Serilog.AspNetCore
    dotnet add package Serilog.Extensions.Logging
    dotnet add package Serilog.Sinks.ColoredConsole
```

## 3. Change your Program.cs file to look like the following

* * *

```
public class Program
{
    public static void Main(string[] args)
    {
        // Create the logger
        Log.Logger = new LoggerConfiguration()
            .Enrich.FromLogContext()
            .MinimumLevel.Debug()
            .WriteTo.ColoredConsole(
                LogEventLevel.Verbose,
                "{NewLine}{Timestamp:HH:mm:ss} [{Level}] ({CorrelationToken}) {Message}{NewLine}{Exception}")
                .CreateLogger();

        try
        {
            CreateWebHostBuilder(args).Build().Run();
        }
        finally
        {
            // Close and flush the log.
            Log.CloseAndFlush();
        }
    }

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseSerilog() // Set serilog as the loggin provider.
            .UseStartup<Startup>();
}
```

## 4. Inject the logger to your services or controllers

* * *

Change the home controller and log some actions:

```
public class HomeController : Controller
    {
        // Logger instance
        ILogger<HomeController> logger;

        // Logger is injected into the controller
        public HomeController(ILogger<HomeController> logger)
        {
            this.logger = logger;
        }

        public IActionResult Index()
        {
            // Log something
            this.logger.LogDebug("Index was called");
            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
```

Download the complete code [here](https://github.com/cmendible/dotnetcore.samples/tree/master/aspnet.serilog.sample2.2)

Hope it helps!