teleren/devto huggingface dataset:
For dict in Python
Tags: python, beginners
Published: 2020-01-31 19:56:21

In <a href="https://python.org">Python</a>, a dictionary is a key-value mapping. Every value is mapped to one key. A dictionary can have zero or more elements.

The dictionary below has 3 pairs, each pair has one value. 'a' is mapped to 1, 'b' is mapped to 2, 'c' is mapped to 3.

```python
d = {'a': 1, 'b': 2, 'c': 3}
```

You can loop over a <a href="https://pythonspot.com/python-dictionaries/">dictionary</a> using a <a href="https://pythonbasics.org/for-loops/">for loop</a>.


This works differently in Python 3 and Python 2. If you are still using Python 2, I recommend switching over to Python 3.

For Python 3.x:
```python
    for key, value in d.items():
```

For Python 2.x:
```python
    for key, value in d.iteritems():
```

## For dict example

This Python 3 example loops over the dictionary d and outputs the key value pairs from beginning to last. Keep in mind that a dictionary is not required to keep its order.

```python
d = {'a': 1, 'b': 2, 'c': 3}
for key, value in d.items():
    print(key)
    print(value)
```

If you only want the keys, you can use this code:

```python
for key in d:
    print(key)
```

To use the value without the key, just ignore the key value in:

```python
d = {'a': 1, 'b': 2, 'c': 3}
for key, value in d.items():
```

**Related links:**
* <a href="https://docs.python.org/2/tutorial/datastructures.html#dictionaries">Dictionary in Python docs</a>
* <a href="https://pythonspot.com/">Learn Python</a>
What are some books where the reader learns by building a project? 
Published: 2020-01-31 19:46:52

---
title: What are some books where the reader learns by building a project? 
published: true
description: 
tags: 
---
Inspired by this thread on HackerNews which has been incredibly useful to me:

https://news.ycombinator.com/item?id=13660086 

I recently finished this phenomenal book called "Building Enterprise JavaScript Applications":

https://www.packtpub.com/web-development/building-enterprise-javascript-applications

Which takes the reader from zero to building a non-trivial production fullstack application with JavaScript. I highly recommend it to anyone stuck in "Advanced Beginner" land.

Anyone else have some books they would recommend?
Search Go packages from navigation bar
Tags: go, googlechrome, packages
Published: 2020-01-31 19:45:49

---
title: Search Go packages from navigation bar
published: true
description: Google Chrome's search engine management enables you to set up custom shortcuts for pkg.go.dev
tags: Go, Google Chrome, packages
---

![Find the package](https://dev-to-uploads.s3.amazonaws.com/i/0ft4qfyf3itpnm5h2x2z.jpg)

Go team recently announced the new package search system, [pkg.go.dev, will take over the search on godoc.org](https://blog.golang.org/pkg.go.dev-2020).

It is often the case to use browsers for searching Go package on Google and godoc.org, but it seems it's time to create the shortcut for pkg.go.dev as the engineer who uses Go for daily basis. However, typing "pkg.go.dev" in the browser navigation takes some time and we'd like to reduce the typing effort if we can. So, let's do it!

In Google Chrome, there's a setting for search engine, and there's a section titled "Manage search engines", where you can set up arbitrary URLs for querying something.

![Search engine setting](https://dev-to-uploads.s3.amazonaws.com/i/tie3yvkkk2099oqgy8w2.png)

You may already have a bunch of search engines registered, and here you can add another one for pkg.go.dev as the following:

![Add search engine](https://dev-to-uploads.s3.amazonaws.com/i/03qv2uhsuyd4ax0jubu8.png)

In this dialog, you need to put 3 settings, and especially important ones are "Keyword" and "Query URL".

"Query URL" is straightforward. This is the URL template when you query anything with the search engine, and you can specify `%s` as the placeholder for the query parameters or path name. In the case of pkg.go.dev, the value is `https://pkg.go.dev/search?q=%s`.

"Keyword" is what makes your productivity awesome. This is the shortcut name you want to type in the navigation bar of Google Chrome. With the combination of "keyword" and tab key, you can trigger the search engine. For instance, I used `pkg` for the trigger keyword of pkg.go.dev, so if you type `pkg` in the navigation bar and press tab key, then you'll see the following notation on the left side of the navigation bar:

![Keyword triggering](https://dev-to-uploads.s3.amazonaws.com/i/ey9hqvklmlr8bum8i7ou.png)

In that status, now you can type in Go package name you are looking for, such as `go.opentelemetry.io`, then hit enter key. You can just type in a part of package names as well such as `error` and so on.

![Search result](https://dev-to-uploads.s3.amazonaws.com/i/jvwc46j2fnm7lw9n5oq1.png)

Here you go! Now it got much easier to find package from the browser.

Photo credit is by https://www.thewritingreader.com/blog/2017/11/22/prompt-4079-so-many-packages/
Angular 9|8|7 Firebase 5|6 CRUD Operations
Tags: angular987, angular, firebase56, crud
Published: 2020-01-31 19:43:52

---
title: Angular 9|8|7 Firebase 5|6 CRUD Operations
published: true
description: This tutorial is about, how to create CRUD Operations using Angular 7|8|9 and Firebase 5|6 real-time NoSQL cloud database. We’ll be using Angular’s Reactive Forms service for managing the user submitted data in our web application.
tags: Angular 9|8|7, Angular, Firebase 5|6, CRUD 
---

The post [Angular 9|8|7 Firebase 5|6 CRUD Operations](https://www.positronx.io//angular-7-firebase-5-crud-operations-with-reactive-forms/) appeared first on [positronX.io](https://www.positronx.io).

I am going to share with you how to create CRUD Operations using Angular 7|8|9 and Firebase 5|6 real-time NoSQL cloud database. We’ll be using Angular’s Reactive Forms service for managing the user submitted data in our web application.
For the demo purpose, we’ll be creating a basic student record management system in which a school admin can perform following tasks:
 

[Click here to read more](https://www.positronx.io//angular-7-firebase-5-crud-operations-with-reactive-forms/)
Module 6 Project 1
Published: 2020-01-31 19:32:22

<!DOCTYPE html>
<html5>
   <head>    
      <style>
         h1 {color: red}
         p {color: blue}
      </style>
   </head>
   <body>
      <h1>This h1 should be red</h1>
      <p>This paragraph text should be blue, and its contents should be generated via JavaScript.</p>
 <p><span style="color:#000000">#</span><span style="color:#FF0000">FF</span><span style="color:#00FF00">FF</span><span style="color:#0000FF">FF</span></p> 
     
   </body>
</html5>
How to Create Middleware with Parameters in Laravel 6
Tags: laravel, middleware, parameter
Published: 2020-01-31 19:27:43

In this tutorial i will show you step by step how to pass parameter to middleware. In this tutorial we will see how we can pass multiple parameter to middleware also.

For this laravel middleware with parameter tutorial, i will create a user subscription plan. It could be monthly or yearly. Who have this plan who only access this specific page or subscription page.

https://www.codechief.org/article/how-to-create-middleware-with-parameters-in-laravel-6
Conditionals and Loops | Vue Native
Tags: vue, loops
Published: 2020-01-31 19:25:13

In this tutorial i am going to show how to use v-for and v-if for looping and condtion checking in vue js. We will see it with example and i will explain how they work. 

Let's strat our vue js second tutorial. 

https://www.codechief.org/article/conditionals-and-loops-vue-native
Class Abstraction | Abstract class in PHP
Tags: abstraction, php, abstract, class
Published: 2020-01-31 19:24:13

PHP 5 introduces abstract classes and methods. Classes defined as abstract cannot be instantiated, and any class that contains at least one abstract method must also be abstract. Methods defined as abstract simply declare the method's signature - they cannot define the implementation.

https://www.codechief.org/article/class-abstraction-abstract-class-in-php.html
Why PE needs Original First Thunk(OFT)?
Tags: c, cpp, windowsdevelopment, security
Published: 2020-01-31 19:15:52

Let me summarize a lot of things for you here. When you load a Library, for example, Milad.dll and then try to call a function from that like MPrint, dynamic loader of the windows operating system has to resolve the address of the MPrint function and then call it.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/efuai5carmac7tsrip6j.jpeg)

How can OS resolve the address of that function?

Windows go through some really complicated stuff which I want to tell you those steps with a simple tongue. The dynamic loader of windows OS to resolve the address of the function in DLLs has to check Import Name Table (INT), Import Ordinal Table (IOT) and Import Address Table (IAT) table.

These table pointed by AddressOfNames, AddressOfNamesOrdinal and AddressOfFunction member in Export directory a PE structure (DLLs).

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2hw8o28zor7nzgzeak9b.jpeg)

After OS load Milad.dll in address space of target process with help of LoadLibrary, it’s going to fill INT, IOT and IAT table with their RVA in target address space of the process with GetProcAddress and doing some calculation.

There is an array of Import Directory in the process structure that has OriginalFirstThunk, TimeDateStamp, ForwarderChain, Name, FirstThunk which these members point to some important addresses.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/o6r2f1g70polkqrx1332.jpeg)

1. Name in Import Directory (Image_Import_Descriptor) pointed to the name of the DLL which process tries to call, in this example this DLL is Milad.dll.

2. OriginalFirstThunk pointed to Import Name Table which includes Names of functions that exported by the Milad.Dll. Functions in this table have a unique index in which the loader takes that index and goes to the next step and reference to the Import Ordinal Table with that index and takes the value which there is into that index of Import Ordinal Table which It’s another integer value.

3. FirstThunk is another important member that points to IAT. in the previous step dynamic loader takes an integer value via IOT. this value is an index number in which dynamic loader refers to IAT with that value. In this table, there is an address in index value which dynamic loader gets from INT-IOT. After these steps when dynamic loader finds out the correct address of the function, it puts that address to Import Address Table for MPrint function. So the process can call that function with its address.

This is a simple explanation for complicated stuff which loader does to resolve the address of the functions in DLLs via Name, OFT(INT) and FT(IAT) members in Image_Import_Descriptor.
Why We should care about Floating-Point Numbers?
Tags: cpp, security, vscode, c
Published: 2020-01-31 19:09:17

Since computer memory is limited, you cannot store numbers with infinite precision, no matter whether you use binary fractions or decimal ones: at some point, you have to cut off. But how much accuracy is needed? And where is it needed? How many integer digits and how many fraction digits?

However, when you are going to write a program which It is dealing with floating numbers and making a decision based on floating values, you have to care about losing precision. As it is obvious, losing precision is like losing your mind and your decision making logic.

For example, consider the following C++ code. I wrote this code with this assumption that if the reactor temperature reaches a value of around 2.56, the program will stop its activity and send a message to the stdout: Alert: Stop Working.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/c07ti1k8c4tom118uv94.png)

But when I compiled and then run the above code it will show the following result in the console. It is not the result that I expected to see but what is going on?

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bvo90uxw86hvawizsi02.png)

When I set a breakpoint on the nuclearReactorTemp variable and then watch the value of that variable. Amazingly, It has the following value. I set it with 2.56 but in the debug environment you see it lose precision and It has the following value:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/yarvk6yp1iq8k0qeml3x.png)

As I expected, the floating-point variable loses its precision and then program logic completely failed and this is a catastrophic scene in the time of critical software development. So if we want to correct the program, we have to enhance the accuracy of the variable. If we rewrite the program like the following sample, the program will work as we expected.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ns22z3ssciyz44o1b74m.png)

Yeap. This simple example shows you if we didn’t care about floating-point numbers, the logic of our program will fail in the progress and made some catastrophic decisions.

Email: m.kahsari@gmail.com
Twitter: m.kahsari
My Experience Designing for a  Tech Conference, CodeMash
Tags: techtalks, design
Published: 2020-01-31 19:05:24

I just wrote a blog about designing for a tech conference, CodeMash! Whether you're familiar with the conference, interested in design, or have questions about my process, feel free to check this out and let me know if you have any questions!

https://fromflanneltolace.com/design-life/cm2020/
LightMoreLight Problem in c
Tags: replit, c
Published: 2020-01-31 18:45:43

Light More Light Problem implementation in c
```
#include <stdio.h>
#include <math.h>
int main(void) {
     int no;
    int y;
  printf("enter the to find a square root");
  scanf("%u",&no);
   while(1){
        scanf("%u",&no);
        if(no==0) break;
        
        y=sqrt(no);
        
        if(y==y*y) 
        printf("yes\n");
        else 
        printf("no\n");
    }
    
    return 0;
}
```
Keeping track of notes across projects and features
Tags: git, notes, productivity, cli
Published: 2020-01-31 18:41:33

Working as a frontend dev for a large e-commerce company, I find myself switching between different features quite frequently. It's pretty much a given, as soon as I start a new ticket at work or even a new personal project, I press cmd+n in my editor and start taking down any relevant notes I come across. The problem however is as soon as I have to switch to something else, I just end up saving the file to my desktop. I have to hope I don't forget the filename or that it even existed.

Recently I was looking for a better way to keep track of my notes. Sure there's Google drive, native desktop note taking apps, or even git submodules but I was looking for something simpler. I would like to have a persistent file open in my IDE, right next to the files I'm working on, but it couldn't live in the same directory as the current project. And I would need a way to easily switch between notes without opening and closing different files.

I decided to write a CLI as a wrapper around a single git repository. The repo would act like a scratchpad. For every project, feature or idea I would create a new branch with a blank file, treating it as a new page in the scratchpad. I could then create symbolic references to each branch with a semantic name that would make it easier to remember which page to flip to when switching work; just like placing a bookmark.

The source code and full documentation is available at https://github.com/bsawyer/scratchpad

If you have run into a similar problem I hope you find this script useful and would certainly appreciate any feedback.
Trying out CodeSandbox Integration
Tags: javascript, devlog, codesandbox
Published: 2020-01-31 18:40:50

---
title: Trying out CodeSandbox Integration
published: true
description: simple test for codesandbox
tags: javascript, devlog, codesandbox
---

Testing out CodeSandbox integration with a little game I'm working on. I was reading about the feature [here](https://github.com/thepracticaldev/dev.to/pull/1052) and I wanted to try it out.

{% codesandbox tiny-adventure-beta-sfov2 %} 

This is an incomplete game I'm using as a place to try out various concepts.

I'm very excited to be posting a devlog about my progress on my Project Saga effort, which will be a way to make simple web games along the same lines as Twine and Bitsy.
The first JS challenge in 2020: February 1 begins the second round. 
Tags: javascript, react, python, node
Published: 2020-01-31 18:36:15

👉 INTRODUCTION


The first round of 30DaysOJavaScript challenge came to an end.  I was creating and publishing content about JavaScript for 30 days. Its repo reaches more than 120K views, 5K unique visitors and 1.4K stars. It also became one of the trending JavaScript repo on github.


👉  CONTENT

The  30DaysOfJavaScript challenge contains many real life examples,  exercises and mini-projects. It can be used by groups, schools, colleges and universities for teaching material. The content will be updated and published soon. 

👉   GRADUATES’ REMARK

Many people agree that the  30DaysOfJavaScript challenge has improved their problem solving skills and computational thinking skills. It might be hard for a beginner to finish it in 30 days and they recommended to take it in  60 or 100 days. 

👉   UPCOMING CHALLENGES

I will notify on LinkedIn in advance about the upcoming challenges. It includes React, HTML and CSS, React Native, Full Stack, Data Analysis and Machine Learning. In March there will be a possibility to have React challenge.


👉 TO GRADUATES

Your journey to greatness has completed successfully. You reached high level of greatness. Now, you are much greater than ever before. I knew what it takes to reach this and you made it to this point. You are a real hero and an unstoppable. Now, it is time to celebrate your success with a friend or family. I am looking forward to seeing you in another challenge.

👉 ANOTHER ROUND

A new round of JavaScrpt challegne and Python challenge  will start 1 February 2020


💻  30DaysOfJavaScript Github: https://lnkd.in/efqy_df
💻  30DaysOfPython Github: https://lnkd.in/epW6d_U

👥  Join the 30DaysOfJavaScript group: https://lnkd.in/er7kdTE
👥 Join the 30DaysOfPython group:  https://lnkd.in/eE5Qgqd

📅 Start your  monthly resolution with coding.

Good Luck!! ✨
🔥🔥🔥
Discussion Question
Tags: cis114
Published: 2020-01-31 18:30:02


<.form id="registation action="www.example.com/cgi-bin/registration" "method="post">

<./post>
 
The name attribute provides the name of the data field, but the id attribute provides the id for the control element in which the user enters the field value.

<.fieldset><.legend>Contact Information<./legend>

<./fieldset>

<input name="custPassword" type="password">

With an input box for telephone numbers, it is more convenient to have digits (instead of alphabetic characters) prominently displayed on the keyboard.

By either nesting the control element within a label element or by using the for attribute to associate a label with a control element by its id.
React Anti Patterns Part 1
Tags: antipatterns, react, codenewbie
Published: 2020-01-31 18:20:57

This post was originally posted <a href="https://www.grantwatson.app/posts/react-anti-patterns-part-1">here</a>

<p>
    I first started "playing" around in React in 2017, when I got my first job as a developer working for a military base in Georgia.
    I fell in love with the framework almost immediately as I started to get frustrated with it. You see, by this time, I was still 
    in college getting my degree, I had roughly 3 semesters left, and what we were learning in school was no where near what I was working 
    on in the <em>"real world"</em>. Overall, my frustration with React when I first got into was that I was simultaneously learning 3 new (to me)
    languages in school while learning React for work. And at the time, I did not have a firm grasp of the updated JavaScript platform React
    was built on. 
</p>
<p>
    But, I carried on, and now, 3 years later, I am still no expert on the matter of React, but I feel like I have a much better understanding of
    the framework now than I did a few years ago. Hell, this app that you are reading this blog on is fully written in ReactJS. I wanted to take 
    some time to organize my thoughts and set up a series on what <strong>NOT</strong> to do in React, so that I can be a better developer
    in this realm. And hopefully you, the reader, can find this article helpful in your journey to better understand React.
</p>

<h3>General Definition</h3>
<p>
    Before we get too far into the idea of Anti Patterns, let us define what I mean by such:
      <blockquote>Anti-patterns are certain patterns in software development that are considered 
      bad programming practices.</blockquote>
</p>


<h3>Keeping Initial State Clean of Props</h3>
<p>
    From docs:
    <blockquote>Using props to generate state in getInitialState often leads to duplication of “source of truth”, i.e. where the real data is. 
    This is because getInitialState is only invoked when the component is first created.</blockquote>

    The danger is that if the props on the component are changed without the component being ‘refreshed’, the new prop value will never 
    be displayed because the constructor function (or getInitialState) will never update the current state of the component. 
    The initialization of state from props only runs when the component is first created.
</p>


<h3>Have setState() in componentWillMount()</h3>
<p>
    Avoid async initialization in <highlight>componentWillMount()</highlight>

    <highlight>componentWillMount()</highlight> is invoked immediately before mounting occurs. It is called before <highlight>render()</highlight>, therefore setting 
    state in this method will not trigger a re-render. Avoid introducing any side-effects or subscriptions in this method.

    Make async calls for component initialization in <highlight>componentDidMount</highlight> instead of <highlight>componentWillMount</highlight>

</p>
Who's looking for open source contributors? (January 31st edition)
Tags: contributorswanted, opensource
Published: 2020-01-31 17:45:50

After a few month hiatus we are back! Kicking off 2020 with some OSS.

As always, find something to work on or shamelessly promote your project here.

Everyone who posted in previous months is welcome back this month, as always.

Happy Coding!

Photo by [Trent Szmolnik](https://unsplash.com/@ts_imagery?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText)