teleren/devto huggingface dataset:
Connecting your App to MongoDB Atlas .. Important Notice
Tags: mongodb, node, javascript, express
Published: 2020-01-13 18:39:21

When you are using MongoClient to connect to MongoDB Atlas,  it is important to know that there are 3 layers of connection.

1- connect to the cluster ..


```javascript 

mongo.connect(process.env.DATABASE_URL, (err, db) => {
  if(err) {
    console.log('Database error: ' + err);
  } else {
    console.log('Successful database connection');
  }
});

  
```

using the code above will not deliver you to the database, although you will not get any errors, you will find that your operations on the database-collection are not successful.
again, there is no errors in this connection, so you won't understand why your interaction with the DB is not successful.

2- connect to the database: 


```javascript

//DB and authentication
mongo.connect(process.env.DATABASE, (err, cluster) => {
  if(err) {
    console.log('Database error: ' + err);
  } else {
    //connecting to the cluster
    console.log('Successful database connection');
    
    //connetcing to the database
    const db = cluster.db(DATABASE_NAME);
  }
    
 });

```
in the code above, the ``` connection.db() or cluster.db() ``` function -if you want to think of it this way- to connect us our database.


3- connect to  the collection :

```javascript

//DB and authentication
mongo.connect(process.env.DATABASE_URL, (err, cluster) => {
  if(err) {
    console.log('Database error: ' + err);
  } else {
    //connecting to the cluster
    console.log('Successful database connection');
    
    //connetcing to the database
    const db = cluster.db(DATABASE_NAME);
   
   //conneting to the collection
   const coll = db.collection(COLLECTION_NAME);
 
   //do your stuff on the collection here.

  }
});


```

in the code above we reached our collection, so we can do our operations on it correctly.

remember to put all of the code that is doing operations on Database inside the MongoClient connection.

Happy Coding..!!
how to convert this chart into a react class or function component and rnder it to the main div 
Tags: react
Published: 2020-01-13 18:36:18

this is a sample chart ....
i dont know how to convert it into class compnent and 
render it to the root element 



// Create hover state and set alternative fill color
let hs = polygonTemplate.states.create("hover");
hs.properties.fill = chart.colors.getIndex(0).brighten(-0.5);

let animation;
setTimeout(function(){
  animation = chart.animate({property:"deltaLongitude", to:100000}, 20000000);
}, 3000)

chart.seriesContainer.events.on("down", function(){
if(animation){
  animation.stop();
}
})

amCharts
More info
Accessibility Features
About amCharts
Press Kit
amCharts Blog
Getting support
The Docs
The Docs: Changelog
Subscribe to amNews
Products
amCharts 4: Charts
amCharts 4: Maps
amCharts 4: TimeLine
WordPress Plugin 
Legacy products
Version information
Tools & Resources
Free SVG Maps
Online Chart Editor
Pixel Map Generator
Visited Countries Map
Visited States Map
Contact Us
contact@amcharts.com
Support Center
Legal Stuff
Privacy Policy
Terms & Conditions
Facebook
Twitter
LinkedIn
Copyright © 2006-2020, amCharts. All rights reserved.
We use cookies on our website to support technical featur
init 1 - Trying To Enter The Dev World
Tags: career, linux, beginners
Published: 2020-01-13 18:24:53

#Introduction

Hello, Dev! This is my first post, so please forgive me if I am breaking any Dev best practices. I intend to write a set of articles in attempt to explore my current thoughts, and to seek wisdom from the Dev community as I try to grow in my career. 

#The Problem

I currently work in the field of RPA (Robotic Process Automation). While I've learned a lot while working in the field, I feel I may have reached a ceiling. It's not entirely too technical, and I do love the development part of it the most, so I figure I want to pivot more into a developer role. Additionally, I've come to realize that RPA most of the time is more of a hindrance than a boon (it only serves to increase technical debt within an organization). This is something I'm not comfortable with based on a morality standpoint. 

So I'd love to get more into a traditional development role. No chance for that within my current organization: I've been pigeonholed as the RPA expert, as well as my group doesn't really have any true development roles available. 

So I need to enter the world of development through another organization.

#My Background

My primary coding language in the past has been python. I have used it in personal projects, as well as I have developed some machine learning POC's in the past for work. 

I love Linux, and I use Arch Linux at home. I also am currently learning C/C++ & Rust.

#My Goal

To find a role that falls more in line with my want of a developer career. I'd ideally like to work with Linux, but that is not a must. I'm open to learning any language, but I'm particularly attracted to more systems level languages. Beyond that I'm not really sure what kind of development work I want to be doing. 

I need to figure out the following: 

- What area of development I want to work in
- How I can build skills in that area

I'll spend the next month mulling over these points, but in the meantime if anyone has any insight, feel free to comment.
3 ways to get a domain's IP address - Linux Tips
Tags: linux, bash, ubuntu
Published: 2020-01-13 18:23:20


We can use `ping`, `nslookup` and `dig` to get a domain's IP:

```bash
$ ping google.com
PING google.com((2607:f8b0:4006:819::200e)) 56 data bytes
```

```bash
$ nslookup google.com
Non-authoritative answer:
Name:	google.com
Address: 172.217.12.174
Name:	google.com
Address: 2607:f8b0:4006:819::200e
```

```bash
$ dig +short google.com -t a
172.217.12.142
```
vscode package recommendations
Tags: vscode, documentation
Published: 2020-01-13 18:15:28

---
title: vscode package recommendations
published: true
description: now you can forget
tags: vscode, documentation
---

I love using extensions in vscode. However one of the things that worries me is what if another engineer on the project doesn't have this installed. How do they discover the package and have the option to install it if they want.

I don't have to worry about this anymore as vscode allows you to create a `.extensions` file in the `./.vscode` directory, within your project. Which can look something like this....

```json
{
    "recommendations": [
        "the-name.of-the-package" // which can be found by looking to the title on the packages page.....
    ]
}
```

Now when someone does a search for `@recommendations`, these packages which come up.

This also has the added benefit where I can find an extension for a specific project that I'm working on from time to time, document it in this file and then install it in the future when I come back to the project.
Interview Prep #4: URLify String
Tags: career, beginners, cpp, interview
Published: 2020-01-13 17:51:08

## Problem

Whenever data is sent as a URL, spaces are replaced by `%20`. In this problem we are given a piece of text and we are supposed to URLify it. Wherever we encounter space we should replace it by the `%20`.

Notice that when we replace a `space` by a `%20`, we are taking up two more characters. In this problem we are given the text as a string followed by a bunch of spaces so that we have enough space to URLify the string. Additionally we are also provided with the length of original text in the string.

```
Example:

Input: "pan cakes  ", 9 
(The text is "pan cakes" followed by two spaces to accommodate the "%20")

Output: "pan%20cakes"
```

## Solution

In most of the string editing problems it's a good idea to start from behind and work our towards the start of the string. We will first estimate number of spaces in the text. Then we'll use two pointers to edit the string from behind.
 
The _first_ pointer will be at the end of the actual text and _second_ pointer will be the end of the string. We'll then work our way backwards. If the first pointer finds a space we will make the `%20` string at the position of second pointer. Then the second pointer will be reduced by 3 and first by one. If the first pointer runs across a _not_ space, we will just move the character from the first pointer to the second pointer position.

If this sounds confusing, it is fine. I think its one of those problems where the explanation is more confusing than the actual algorithm. Try reading the code and rewriting it yourself to get a hang of it.

```cpp
string urlify_string(string& s, int true_length) {
  // find number of spaces
  int space_count = 0;
  for (auto i = 0; i < true_length; ++i) {
    if (s[i] == ' ') {
      ++space_count;
    }
  }

  // second counter
  int final_index = true_length + 2 * space_count;
  // i is the first counter
  for (auto i = true_length - 1; i >= 0; --i) {
    if (s[i] == ' ') {
      s[final_index - 1] = '0';
      s[final_index - 2] = '2';
      s[final_index - 3] = '%';
      final_index -= 3;
    } else {
      s[final_index - 1] = s[i];
      --final_index;
    }
  }
  return s;
}
```

> References: Cracking the Coding Interview - Gayle Laakmann McDowell
Have a marvelous day 😄
Fellow freelancers, is any of you successful at estimates?
Tags: freelancing, discuss, watercooler, productivity
Published: 2020-01-13 17:36:55

I'm talking about time estimates.

I just got off the phone with a client who (with extreme kindness) made me notice how I am quite consistent at giving overly optimistic deadlines.

I've been doing this job for 10 years and apparently no matter how hard I try to fix my calculations I keep failing.

Has any of you mastered the game? Any tips to spare? 🙏
Asking The Right Question In The Interview
Tags: devrel, career, interview
Published: 2020-01-13 17:31:05

Sometimes it feels like you are on the losing end of the interview. The engineer across the table is hammering you with technical questions. 45 minutes later, you've talked through the answers to some technical problems.

Then it happens. The engineer asks if you have any questions.

![](https://media.giphy.com/media/mzPZiIDA7qNdS/giphy.gif)

If you reply with a resounding "No" you may have just passed up a huge opportunity.

The time after the obligatory technical interrogation can be the most informative. You can find out if you are a culture fit, learn more about the project, ask about team dynamics, find out more about the stack, or figure out the answer to anything else on your mind.

You can use this time to directly engage the other person on a level that you normally would on the job. Treat them as a peer. You could convince that person you are a good fit for the team. If you are interviewing for a leadership role, feel free to flip the script and take command of the interview for a few minutes. "What motivates you everyday?" "What is the hardest problem you had to solve recently?" "If you could change one thing about the team, what would it be and why?"

If you're in the first panel of the day, maybe ask: "What kind of person are you looking to fill the role?" Then respond to their answer with examples of how you fulfill their version of the ideal candidate. Knowing who the team is looking for could help you progress in other panels throughout the day.

Prior to the interview it helps to make a list. Conduct some research. No matter how well you make think you know that company, recent news and events, the contents of their quarters earnings call may alter your perception. Jot down any questions you may have. Be sensible who you ask each question to, because not everybody has the answer.

This time could be the most important part of the interview. Some of the best places to work are looking for people who are creative thinkers, who are able to break the mold and innovate beyond their peers. Given the churn involved with JavaScript, some engineers want to work with others who can't stop, won't stop learning.

Asking questions demonstrates a willingness to cooperate and learn, an ability for critical thinking. Don't forget to have questions ready for every stage of your next interview. Maybe someone is waiting for you to ask the right question nobody else did.


![](https://media.giphy.com/media/3oriO5EMLxl1f7funu/giphy.gif)
Coding Boot Camps: Talking to Stephen Bilham and His Experience 
Tags: podcast, watercooler, beginners, techtalks
Published: 2020-01-13 17:23:43

{% youtube 4ynj0YRZ0W8 %}

In this episode of the Zeal Twitch live stream. I took the opportunity to have a conversation with our intern Stephen Bilham about his experience going to a Coding Boot Camp. These are the high-level questions that were asked during our conversation with deeper dives and tangents along the way.

- What are you doing before the coding boot camp?
- What got you interested in web development?
- Why did you want to go to a coding boot camp?
- How did you find out about your coding boot camp school?
- What did you expect going into the coding boot camp?
- What were your experiences during the coding boot camp, any challenges?
- What are hoping to get out of an internship?
- Any words of wisdom for people considering a coding boot camp?

If you're interested in connecting with our wonderful intern you can find him on LinkedIn here: https://www.linkedin.com/in/srbilham/

If there are other questions you would like me to ask during our next intern conversation this Friday, January 17, 2020, leave it as a comment in the post. 

I hope you enjoy the VOD.

Want to watch live? Follow the Zeal Twitch Channel here, https://www.twitch.tv/codingzeal/
Random python fact of the day
Tags: python, jokes
Published: 2020-01-13 17:07:06

If you have an abstract base class with a static method, then the order of decorators should be like that:
```python
@staticmethod
@abstractmethod
def my_fancy_method():
    pass
```

If you switch them around you would get `AttributeError: attribute '__isabstractmethod__' of 'staticmethod' objects is not writable`. Now you know.
Reuse EDMX files with .NET Core or .NET Standard 2.1
Tags: dotnet, csharp, vbnet, legacy
Published: 2020-01-14 08:10:57

---
title: Reuse EDMX files with .NET Core or .NET Standard 2.1
published: true
date: 2020-01-13 17:00:00 UTC
tags: dotnet, csharp, vbnet, legacy
canonical_url: https://christophweigert.com/reuse-edmx-files-with-net-core-or-net-standard-2-1/
---

 ![Reuse EDMX files with .NET Core or .NET Standard 2.1](https://christophweigert.com/content/images/2020/01/modelinitial.png)

If you previously an EDMX file for your database first model generation you are left out for .NET Standard or .NET Core Support. But there is at least a workaround that you can use to target .NET Standard 2.1 or .NET Core Apps with 3.0 or newer.

You have to create a separate project and link your EDMX, Context and Model files. This solutions works independently of C# or VB.NET. The magic lies in the build action "EntityDeploy" introduced with Entity Framework 6.3. Updating the model needs to be done in the .NET Framework project.

This is project file I created. Feel free to reuse it but change vb to cs in case you want to use it with a C# model.

<!--kg-card-begin: markdown-->
```
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>netstandard2.1;net472</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="EntityFramework" Version="6.4.0" />
  </ItemGroup>

  <ItemGroup>
    <EntityDeploy Include="..\Test.EntityFramework\YourEdmx.edmx" Link="YourEdmx.edmx" />
    <Compile Include="..\Test.EntityFramework\YourEdmx.Context.vb" Link="sbEntities.Context.vb" />
    <Compile Include="..\Test.EntityFramework\Employee.vb" Link="Employee.vb" />
  </ItemGroup>

</Project>
```
<!--kg-card-end: markdown-->

If you have many model classes you can use a neat feature or visual studio. Right-click inside your new project and click "Add \> existing item"

![Reuse EDMX files with .NET Core or .NET Standard 2.1](https://christophweigert.com/content/images/2020/01/image-1.png)<figcaption>Before manually modifying your project file you can use the "Add As Link" feature from Visual Studio.</figcaption>

For further reference you can see the [Microsoft Documentation](https://docs.microsoft.com/en-us/ef/ef6/what-is-new/#ef-designer-support), [GitHub Issue](https://github.com/aspnet/EntityFramework.Docs/issues/1748) or the [sample repository](https://github.com/efcore/EdmxDotNetCoreSample/).
C9 Lectures: Dr Erik Meijer - Functional Programming Fundamentals
Tags: haskell, functional, review, computerscience
Published: 2020-01-13 16:53:42

It is an excellent introduction to functional programming. Tasks and examples are illustrated in Haskel. The course covers the bulk of syntax and features of the language. It demonstrates FP and OOP solutions for the same problems, that might improve understanding of both approaches.

# For beginners: 
It explains the major part of functional programming concepts. An exotic and elegant syntax of Haskel is carefully introduced to students. They are forced to wrap their heads around an entirely new way to solve problems and write code. It might enhance an overall understanding of programming.

# For experienced:
It contains an exciting introduction to the history of programming and computer science in general. The lecture also presents some state of the art research in the field, reference multiple books for future reading. It is an excellent gateway to the world of theoretical computer science.

The course is published on [Channel 9](https://channel9.msdn.com/Series/C9-Lectures-Erik-Meijer-Functional-Programming-Fundamentals/Lecture-Series-Erik-Meijer-Functional-Programming-Fundamentals-Chapter-1)
Registering a domain name on AWS
Tags: aws, domainnames, domainregistrar
Published: 2020-01-13 16:50:34

This post was orginally published on my [blog](http://abitdeployed.com/2019/10/01/registering-a-domain-name-on-aws/).

I have been blogging for a few years and for each one of my blogs, I have chosen to have my own domain name instead of using a free one such as blabla.blogspot.com or blabla.wordpress.com. There is something about blogs with their own domain names that makes them seem more ‘legit’ or ‘professional’ which is why I always recommend new bloggers to consider getting their own domain name. It is fairly cheap and easy to setup. Of course, you need to get your own hosting as well but we will not touch that topic in this post.

Until recently, I had only used GoDaddy for buying domain names. It is one of the most popular domain registrars. In case you are not familiar with what a domain registrar is, it is simply a service that lets you purchase and register domain names. You know who is also a domain registrar? AWS.

Yes, you can actually purchase domain names from AWS. Their domain registrar is called **Amazon Route 53**. It’s a DNS service but it also provides domain registration. For this blog, I chose to try something new and got my domain name from AWS instead of GoDaddy. And I can’t begin to tell you how easy it was.

#### _Fun Fact: Route 53 is named after the TCP or UDP port 53 which is used for addressing DNS requests._

Since I already have an AWS account setup, it took me a few simple steps to purchase my domain name. You can create your own account [here](https://aws.amazon.com/).

Once you are logged into AWS, go to Route 53:

![](http://abitdeployed.com/wp-content/uploads/2019/09/Screen-Shot-2019-09-30-at-6.18.19-PM-1.png)

Then, check to see if your domain name is available. Most likely, your first few choices won’t be available. For example, _techcrunch.com_ is taken.

But, techsurfbar.com is available! Sweet! This would make a great name for for a bar for nerds who like to surf (internet?). Hmmm.

![](http://abitdeployed.com/wp-content/uploads/2019/10/Screen-Shot-2019-09-30-at-8.28.44-PM.png)

You can also choose to buy a domain with a different top-level domain such as _.net_, _.info_, _.link_, and _.net_. Note that the price varies for different types of domains. Some domain names are very popular and hence, are more expensive.

Pick your favorite domain name, click the `Add to cart` button, scroll down and then click `continue`.

On the next page, enter your contact information and click `continue`. Finally, you have to agree to some `Terms and Conditions` and click `Complete order`.

That’s it! It’s just like buying your monthly supply of toilet rolls on Amazon. Well, not exactly the same but very close.

Overall, I found the experience to be very convenient and since I already use AWS, I found it better than using GoDaddy. Once, I bought my domain, I configured it to point to my hosting’s nameservers and that was it!
Game Genie Good Guy – 4 days project
Tags: python, retrogaming, basic
Published: 2020-03-09 11:28:19

---
title: Game Genie Good Guy – 4 days project
published: true
date: 2020-01-13 16:46:21 UTC
tags: python, retrogaming, basic
canonical_url: https://daniele.tech/2020/01/game-genie-good-guy-4-days-project/
---

I started a tiny project because I need some cheats in a game on my Playstation Classic that now is modded for RetroArch.

I don't want to use cheat inside retroarch also because I have a Gameboy Advance and I cannot run this <a href="https://en.wikipedia.org/wiki/Game_Genie">Game Genie</a> codes.

The <a href="https://www.romhacking.net/utilities/1054/">original Game Genie Guy</a> with inserting the Game Genie codes can generate a new rom or an IPS file with this codes included.

The cool part was to discover that the most used tool was only for Windows but was including the source code... in BCX-BASIC.

So I looked for a tool that convert this language to another that can run on Linux, patching it to use the command line and optimizing it.

The final touch was a GUI that can generate a IPS patch like the original tool, but also test the converter to generate a C and C++ version (this one just for fun).

So you can <a href="https://github.com/Mte90/Game-Genie-Good-Guy">find everything on GitHub</a> and the <a href="https://github.com/Mte90/Game-Genie-Good-Guy/releases/tag/1.0.0">official release with a built version of the tool</a>.

The tool <a href="http://www.romhacking.net/utilities/1484/">is published also on RomHacking</a>, so I can say that I am officially contributing to the rom hack scene.

The post [Game Genie Good Guy – 4 days project](https://daniele.tech/2020/01/game-genie-good-guy-4-days-project/) appeared first on [Daniele Mte90 Scasciafratte](https://daniele.tech/eng).
Safely access nested object with ES6 Destructuring
Tags: javascript, productivity, tutorial
Published: 2020-01-13 16:34:57


How can we use ES6 Destructuring to access values from nested object or array without using safeguards with `&&` operators?

Let's start with a basic example of destructuring. This is how we can destructure values from the object and assign them to variables.
We can also rename variables to a different name and give default value ie. if an object doesn't have that key(this is important for our topic)

```javascript
  const data = {
    id: '123',
    value: 'someValue'
  };

  // access id and value from data with destructuring 
  const { id , value } = data;
```

Now let's try to access the nested object.

```javascript
  const data = {
    user: {
      id: 1,
      name: {
        first: 'Amit',
        last: 'Chauhan'
      }
    }
  };
```

If we want to safely read firstName from this data this is how we would write without destructuring

```javascript
  const firstName = data && data.user && data.user.name && data.user.name.first;
```

Let's do it with destructuring.

```javascript
  const {
    user: {
      name: {
        first: firstName // rename variable to firstName
      } = {} // this part is where we give default value to empty object so code doesn't break
    } = {} 
  } = data;
  console.log(firstName); // Amit
```

We can use destructuring to access an array as well.

```javascript
  const dataArray = [{
    name: {
      first: 'Amit'
    }
  }];

  const [{
    name: {
      first: firstName
    } = {}
  } = {}] = dataArray;
  console.log(firstName); // Amit
```


Bonus tip

We can use destructuring to swap variables.

```javascript
let a = 10;
let b = 20;

[a, b] = [b, a];
console.log({ a, b }); // { a: 20, b: 10 }
```