teleren/devto huggingface dataset:
PayNow Integration Part 2: Getting Keys
Tags: php, paynow, webdev, payments
Published: 2021-02-14 09:23:54

Gateways or APIs needs a way of identifying their users so they can know:

- who requested what 
- what belongs to who
- who does what 

To do that gateways use what are known as API keys/Integration keys. So in order to use an API or a payment gateway you must get those integration/API keys. 

So lets get Integration keys for PayNow

## Step 1: Creating an account

Go to PayNow and click **Signup**, you be presented with a *big long form*. Enter your details silently 🤣🤣🤣

Once you complete registration, you will be sent a link to finish off registration

So check your email and open the message

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

Follow the link and log in


## Step 2: Setup payment bank account

This stage is intuitive you simply select options and enter details where they are needed

### i. Payment Methods
Select the payment methods you want to accept
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/q3qyz7xofqewjzr2b29e.png)

### ii. Bank Accounts

Here you should enter your bank details. Please crosscheck you details before continuing. 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7tt9mkxh4y7hjbs98uoh.png)

### iii. Charges
Here you select who absorbs the charges

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


Once done click **Finish** and you will be presented by this screen

![image](https://dev-to-uploads.s3.amazonaws.com/i/94jyivkb86qky214ul29.png)
 


## Getting Keys

Now click Receive **Payments** on the navigation then click Other ways to get paid.

![image](https://dev-to-uploads.s3.amazonaws.com/i/4nnc5wqawqmj8j4ni9cg.png)


Scroll down to **3rd Party Shopping Carts & Business Systems Integration** and click **Create or Manage Shopping Carts**.

![image](https://dev-to-uploads.s3.amazonaws.com/i/il9ned66hmc8wmva44g1.png)

Scroll down again to **Advanced Integration** and click **Create Advanced Integration**.

You will be presented with a form like that:

![image](https://dev-to-uploads.s3.amazonaws.com/i/onjh119au9mu3catrdj3.png)

Enter details and click **Save**

Behold!.....The Keys!!!. 🙌🙌🙌

![image](https://dev-to-uploads.s3.amazonaws.com/i/1iaez6d9abkqiq7ovugt.png)
    
So you can view your Integration ID and Integration Key, you can also request account to be live mode and you can create another set of keys.

So ladies and gentlemen this is how you get PayNow keys

![image](https://dev-to-uploads.s3.amazonaws.com/i/1cvrunpr07e1jlrcyh8t.png)
How to install python on your computer
Tags: python, programming
Published: 2021-02-14 08:55:15

Hello, I’m writing this to help you understand how to install python on your computer. 

To install python on your computer, visit [python.org/downloads](https://www.python.org/downloads/)

you will find link to download latest version of python for your operating system

click on the link to download, it will download the python setup file

now open it and press install now

to check if python is installed on your computer 
open terminal and type 
```python --version```

it will show you the latest version of python, means python is successfully installed on your computer 

now start learning python and making wonderful applications 

see video guide here {% youtube JZlWCiTAonA %}



**Thank you**
Setting a foreign key on Active Record Associations
Tags: rails, activerecord, parameters, forms
Published: 2021-02-14 07:51:56

Just a random thing I learned and wanted to document. I was struggling to save a double nested association coming in from a form, and I kept hitting an error that the record at the bottom of the nesting couldnt be created because its parent hadnt been created.

```
class Building
  has_many :floors
end

class Floor
  has_one  :copy_machine, foreign_key: :floor_id
end

class CopyMachine
  belongs_to :floor
end
```

Well after some digging I figured out that since I had defined the foreign key, rails is unable to guess the inverse from the class name, so the parent can't be saved. I don't know why I set that foreign key, since I didn't actually need it since the column was named according to the class. 

I was able to remove it and the error was gone. But if I had needed it to be set, say the foreign key on CopyMachine was "level_id", then the inverse_of key would need to be passed when defining the has_one relationship. This is apparently the case when defining the foreign_key or the class_name parameters.

The paragraph at the bottom of this article helped me figure this out [https://www.viget.com/articles/exploring-the-inverse-of-option-on-rails-model-associations/](https://www.viget.com/articles/exploring-the-inverse-of-option-on-rails-model-associations/).
Map, Reduce, Filter/Select: Ruby vs. JavaScript
Tags: map, reduce, ruby, javascript
Published: 2021-02-14 07:41:13

# Map

```
# Ruby
def addTwoZeros(array)
  array.map { |element| element * 100 }
end 



// JavaScript
const addTwoZeros = array => {
  return array.map((element) => {
    return element * 100
  })
}
```

The above functions/methods take in a list of numbers, add two zeros to the end of each number, and return a new list of transformed numbers. The main idea behind `map` is transforming each member in an array and putting it into a new array. This new array will eventually hold a collection of transformed elements in the same order as the original array. 

In the Ruby implementation, each element of the array goes through `|element|` and undergoes the code to the right of `|element|`. That is, each element goes through the pipes `||` and gets 100 multiplied to it.

In the JavaScript implementation, the `map` function gets another function passed to it. Each element of the array gets passed through the `(element)` of this secondary function. Then the element gets 100 multiplied to it.


# Reduce

```
# Ruby
def getProduct(array)
  array.reduce do |accumulator, element|
    accumulator * element
  end
end 



// JavaScript
const getProduct = array => {
  return array.reduce((accumulator, element) => {
    return accumulator * element
  })
}
```

The above functions/methods take in an array, multiply all the elements together, then return the result. The main idea behind `reduce` is taking a bunch of things and reducing them down to a single value.

In the Ruby implementation, each element of the array goes through the `element` part of `|accumulator, element|` and gets multiplied to `accumulator`. 

In the JavaScript implementation, the `reduce` function gets another function passed to it. Each element of the array gets passed through the `(element)` of this secondary function, then multiplied to `accumulator`. 


# Filter/Select

```
# Ruby
def getOddNums(array)
  array.select { |element| element % 2 != 0 }
end 



// JavaScript
const getOddNums = array => {
  return array.filter((element) => {
    return element % 2 !== 0
  })
}
```

The above functions/methods take in an array and return only the elements that are odd. The main idea behind `filter` / `select` is passing each element to a block; if the element makes the block truthy, the element is added to a new array.

In the Ruby implementation, each element of the array goes through `|element|` and undergoes the code to the right of `|element|`. If the element makes the code to the right of `|element|` truthy, then that element is added to a new array. If the element does not make the code to the right of `|element|` truthy, the element is _not_ added to the new array.

In the JavaScript implementation, the `filter` function gets another function passed to it. Each element of the array gets passed through the `(element)` of this secondary function. If the element makes `element % 2 !== 0` truthy, then that element is added to a new array. If the element does not make `element % 2 !== 0` truthy, the element is _not_ added to the new array.
ForEach Async Woes
Published: 2021-02-14 07:35:01

---
title: "ForEach Async Woes"
draft: false 
summary: Don't use async/await inside List.ForEach in C#, it doesn't work as expected
canonical_url: https://blog.lxalln.com/2019/11/foreach-async-woes/
---

I was investigating a bug last week when I stumbled upon a block of code that looked like this:

```csharp
public async Task Method(List<Animal> collection)
{ 
    // do something async

    collection.ForEach(async v => await _mediator.Send(new Command(v.Id), cancellationToken));
}
```

I wrote this without thinking, I very rarely use List<T>.ForEach() for enumerating through a list, but for some reason I did here. I probably got carried away with the because I can, rather than because I should.

Unfortunately this code is broken, it does not work the way I expected.
Because there is no `await` on the `collection.ForEach...` execution continues on past and the method exits.

Switching to a standard `foreach(...)` loop and awaiting inside in each enumeration will solve this problem.

```csharp
public async Task Method(List<Animal> collection)
{
    // do something async
    
    foreach(var v in collection)
    {
        await _mediator.Send(new Command(v.Id), cancellationToken);
    }
}
```
How to sanitize XML tags in Rails
Tags: rails, ruby, web
Published: 2021-02-14 07:23:18

---
title: How to sanitize XML tags in Rails
published: true
description: Once I noticed that we can sanitize XML-tags using rails-html-sanitizer and loofah gems
tags: rails, ruby, web,
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/4si7g13zmbrp89t5irz7.jpg
---

<!--- and --->

Once I noticed that we can sanitize XML-tags using [rails-html-sanitizer](https://github.com/rails/rails-html-sanitizer) and [loofah](https://github.com/flavorjones/loofah) gems. And I want to share the knowledge.

For example, imagine the task, we have a string that contains some HTML-tags.

```ruby
html_string = <<-STR
<p>
  <span>some text is here</span>
  <a><img src="lala.png" /></a>
</p>
STR
```

We want to sanitize the string, but don't delete `<img>` tag.

```ruby
scrubber = Rails::Html::PermitScrubber.new
scrubber.tags = ['img']
scrubber.attributes = ['src']
html_fragment = Loofah.fragment(html_string)
html_fragment.scrub!(scrubber)

puts html_fragment.to_s
```

Of course, it works perfectly, and our result is here.

```ruby
# some text is here
# <img src="lala.png">
```

Unfortunately, it won't work with tags which name contains symbols `:`, `-`. XML-tags often contain those symbols.

```ruby
xml_string = <<-STR
<item>
  <title>A Life in Russia</title>
  <description>What do you knot about Russia?</description>
  <dc:creator>Sasha Troianovski</dc:creator>
  <media:content height="150" medium="image" url="https://static.worldtimes.com/images/2099/02/13/world/some_photo.jpg" width="151"/>
  <media:credit>Sasha Troianovski for The World Times</media:credit>
  <media:description>Amazing travel to Russia</media:description>
</item>
STR
```

For example, we want to sanitize a new string, but we need to keep <media:content>, <media:credit> and <media:description> tags.

```ruby
scrubber = Rails::Html::PermitScrubber.new
scrubber.tags = ['media:content', 'media:credit', 'media:description']
html_fragment = Loofah.fragment(xml_string)
html_fragment.scrub!(scrubber)

puts html_fragment.to_s
```

Unfortunately, it doesn't work properly, and our result is.

```ruby
# A Life in Russia
# What do you knot about Russia?
# Sasha Troianovski

# Sasha Troianovski for The World Times
# Amazing travel to Russia
```

How to solve the problem? `Loofah` is able to work with XML but we have to tune up a parser and use `.xml_fragment` instead of `.fragment`.

```ruby
scrubber = Rails::Html::PermitScrubber.new
scrubber.tags = ['media:content', 'media:credit', 'media:description']
xml_fragment = Loofah.xml_fragment(xml_string)
xml_fragment.scrub!(scrubber)

puts xml_fragment.to_s
```

And here is our result.

```ruby
# A Life in Russia
# What do you knot about Russia?
# Sasha Troianovski
# <media:content height="150" width="151"/>
# <media:credit>Sasha Troianovski for The World Times</media:credit>
# <media:description>Amazing travel to Russia</media:description>
```

It works perfectly 😊
Mobile Chrome version(88) is sending more data packets per second (PPS) for the first request on WIFI only
Published: 2021-02-14 06:53:14

URLs (if applicable): https://example.com

This site was working fine with all chrome versions, this issue is noticed only with the latest chrome version (88) which got released on 5th FEB 2021

Steps to reproduce:

(1) Enter the URL in mobile chrome browser (version 88) on any Android device (2) Request is not served and after some time the browser shows the "Site is not reachable"

Root cause : we notice that the browser is sending more packets than expected and its is considered as a DDos attack and hence the request is not served.

Note: This is happening only WIFI network and its working fine on mobile data

Expected result:

URL should work as expected with my home screen page

Actual result:

The request was sent with more than 1400 PPS and some time its goes even more than 2000 as well.

Please do let us know, if this kind of issues was noticed by any other users or do you have any possible solution for this issue.

Raised ticket:https://bugs.chromium.org/p/chromium/issues/detail?id=1178222
Project Structure in GO while building microservices
Tags: go, microservices
Published: 2021-02-14 06:22:15

A good foundation can take you a long way. Here's a quick guide to setting up a structured code repository when building a Microservices app in Go!!.  This is just one part of our Microservices series. Check out the rest to get started!  https://gochronicles.com/project-structure/
Sixth-week web dev
Tags: beginners, webdev, html
Published: 2021-02-14 05:24:07

Hi Everyone!! It has been 6 weeks since started doing Javascript. but from this sixth week, I started doing HTML, in the HTML part you can say I have covered all the basic HTML, in the next week now I will go toward HTML advanced then I will go back to my todo list project to do the HTML part of the project. this is the plan I have for next upcoming week.


Thanks for reading!!
What I'm building this week
Published: 2021-02-14 05:12:45

This week I worked on some side projects. One a short tutorial, another was a personal project.
I did Danny Thompson's [joke generator tutorial](https://www.youtube.com/watch?v=6WclW4ThDUU). Fun project that gives a good introduction to APIs. He used the programming joke but I changed mine to use the pun generator. Always modify tutorial. you will learn more if you explore. Plus it helps set you apart from others doing the same project. I may CSS the joke if inspiration hits. Heads up although the API has filters for the jokes. I did see a poor taste one.
The other is a project is a build it to see if I can. It's now at a point I can get it to the intended users to get their thoughts. Group A was able to use it without any trouble, They completed the tasks. Now I need to ask them for a little more feedback. Then present it to group B to see what they think.
1.500 Gamer Mengantre Demi Nintendo 3DS
Tags: gamedev, game, news, newrelic
Published: 2021-02-14 04:52:16

Penjualan perdana Nintendo 3DS di Jepang sukses menuai rasa penasaran publik. Mereka yang mengantre bukan lagi ratusan, namun dilaporkan sudah lebih dari seribu orang.

Kehadiran Nintendo 3DS memang begitu dinanti. Sebab ini merupakan konsol video game pertama yang dilengkapi dengan layar tiga dimensi (3D) yang bisa dinikmati gamer tanpa harus menggunakan kacamata.

CAN READ :  https://flashinfo.jingga.net/update-user-headset-android-tembus-200-juta-pemakai/

Di sebuah toko penjual Nintendo 3DS yang terletak di Akihabara, Jepang, dikatakan sudah dibanjiri para calon konsumen sejak Jumat malam. Mereka rela menginap di depan toko hingga pelataran jalan agar bisa menjadi salah satu pengguna Nintendo 3DS pertama di dunia.

Bahkan dikutip detikINET dari AFP, Sabtu , gamer yang mengantre lantaran penasaran di depan toko tersebut dilaporkan sudah lebih dari 1.500 orang.

“Saya sangat senang sekali, dan tidak sabar untuk segera memainkannya,” ujar Arisa Kubo, gamer yang turut bermalam di depan toko penjual Nintendo 3DS.

Kubo pun menyatakan kepuasannya terhadap konsol terbaru dari Nintendo ini. Alhasil, usahanya yang harus rela mengantre hingga berjam-jam terbayar.

“Kualitas yang dihadirkan sangat meningkat secara dramatis. Layarnya begitu bagus. Nintendo 3DS begitu berbeda dengan DS yang biasa,” imbuh pelajar 19 tahun yang ikut dalam demo pre-sale dari konsol ini ketika bulan lalu.

SOURCE : https://flashinfo.jingga.net
Setup for a Flutter Development
Tags: flutter, beginners, android, ios
Published: 2021-02-14 04:46:12

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

Hola! Amigos,
               so today we will building first flutter app in andriod studio.
what we need for this we need a  andriod studio or visual studio code ,anything from that you make comfortable for development

1. andriod studio <br>
https://developer.android.com/studio

or 
visual studio code 
             https://code.visualstudio.com/

In andriod studio add/instll plugins 
	-flutter 
	-dart
2.flutter  sdk

https://flutter.dev/docs/get-started/install/windows

*download the flutter sdk for 
	-window 10
	-linux
		for linux you can just use a command it will install a sdk of flutter
sudo snap install flutter --classic
and also , you can follow steps of this link
https://flutter.dev/docs/get-started/install/linux

Now, go to downloded flutter sdk extract to andriod folder
C:\Program Files\Android\flutter

after extracting add to the folder path to the environment vairables,then we have to check 
all things are correctly instlled or not to check we have to to cmd 
open cmd as administrator mode

	-C:\Users>flutter 

	-C:\Users>flutter doctor

after doing this painful things start the andriod studio 
	-create a  new flutter project
	-select the flutter appliction for beginners
	- now select the sdk for flutter as we set 


	-C:\Program Files\Android\flutter

after all things go to finish ,all set now 
you can start building apps with a flutter and dart
Adding Bootstrap To Angular 11 Project With CLI
Tags: angular, bootstrap
Published: 2021-02-14 04:33:15

This tutorial will give you an example of angular 11 add bootstrap 4. it's a simple example of angular 11 install bootstrap 4. In this post, you learn to install bootstrap in angular 11.

As we know Bootstrap is the world’s most popular framework for building responsive, and mobile-first websites. I show you how to add bootstrap in angular 11 project
You can easily create your angular app using the below command: [(How To Install Angular And Set Up First Angular Application ?)](https://www.phpcodingstuff.com/blog/how-to-install-angular-and-set-up-first-angular-project.html "(How To Install Angular And Set Up First Angular Application ?)")

![demo-bootstrap.png](https://file.mlog.club/images/2021/02/14/9b72f54d91434344bc24d023e053257d)

**[Adding Bootstrap To Angular 11 Project With CLI](https://www.phpcodingstuff.com/blog/adding-bootstrap-to-angular-11-project-with-cli.html "Adding Bootstrap To Angular 11 Project With CLI")**

```
....
      "styles": [
        "node_modules/bootstrap/dist/css/bootstrap.min.css",
        "src/styles.css"
      ],
      "scripts": [
          "node_modules/jquery/dist/jquery.min.js",
          "node_modules/bootstrap/dist/js/bootstrap.min.js"
      ]
.....
```



Then,

**src/app/app.component.html**


```
<div class="container mt-5">
    <div class="row">
        <div class="col-md-2"></div>
        <div class="col-md-8">
            <div class="jumbotron">
                <h2 class="display-4 text-center" >Welcome To Php Coding Stuff</h2>
                <p class="lead text-center">how to install bootstrap in angular 11.</p>
                <hr class="my-4">
              </div>
        </div>
    </div>
</div>
```

Original source : *[https://www.phpcodingstuff.com/blog/adding-bootstrap-to-angular-11-project-with-cli.html](https://www.phpcodingstuff.com/blog/adding-bootstrap-to-angular-11-project-with-cli.html)*
How to resolve issue Access Denied between S3 and CloudFront
Tags: aws, s3, cloudfront
Published: 2021-02-14 03:56:05

I have setup S3 to store image files and access them through CloudFront. But I have an error **Access Denied** and link CloudFront was redirect to S3 link as below image:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/b6rh4x2dm1p2xjjeu47q.png)

---

The root cause of issue relates to **_“Requests made with the legacy global endpoint go to US East (N. Virginia) by default.”_**

**Refer:** https://docs.aws.amazon.com/AmazonS3/latest/userguide/VirtualHosting.html

---

To fix this issue, we need to back to setup CloudFront before.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7dwh16sc91va5yfpk9h3.png)
Normally, we will select own s3 bucket which contains static files on dropdown list. In this case, endpoint is format as:`<bucket>.s3.amazonaws.com`
This endpoint is global endpoint. We need to change to region endpoint then issue will be fixed. The region endpoint format as: `<bucket>.s3-<region>.amazonaws.com`
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/7opchld0dr4qic1dqc3k.png)
The result as below
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/9m8a7tm3sxn3oxb0gnxc.png)
Why blogging is a great way to start a career in software development?
Tags: beginners, programming, career
Published: 2021-02-14 03:24:00

*Photo by Lukas Blazek from Unsplash* 
![image](https://dev-to-uploads.s3.amazonaws.com/i/wvpq5swr9lk0kdrw1a4r.png)


Even though I'm a new blogger too, I consider that writing can bring many professional benefits for some of us that are just starting a career in the tech field. 

As students or new graduates, we face the challenge of getting a job that is related to our field and aligns with our professional aspirations. Sometimes because we lack professional experience or there is high competition in the area. Either way writing a blog can help us somehow to gain confidence and build a name for ourselves. 

### **Stand out from the competition**
Consider starting a blog on tech topics that matters to you and that might help others. When applying to jobs you'll catch the recruiter's attention easily giving them additional information about you, that demonstrates how self-motivated and different you are from other candidates.

### **Strength your knowledge**
Writing a post takes time and effort, which means that you'll need to plan and think about the topic you want to write about. The good side of it is that in the process you are reviewing and summarizing the information to make it understandable not only for others but for yourself. that's why writing, is a good way to strengthen your knowledge.

### **Networking**
Last but not least, is the ability that it gives you to connect with people. Some people can give you feedback or corrections on your blog posts, that would definitely make you a better professional and developer, and why not...you'll be able to get new friends in the industry.

Hope you get encouraged to start your own blog and share your knowledge with others. Thanks for reading.
Fastest Way to Create APIs!
Tags: showdev, javascript, nestjs, node
Published: 2021-02-14 02:20:34

---
title: Fastest Way to Create APIs!
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/izxug1fuk5y6omub1h14.jpg
published: true
description: In this video I walk you through one of the fastest ways to create a fully working RESTful Node.js CRUD API utilizing the Nestjs framework, TypeORM, Swagger/OpenAPI, and a few other packages!
tags: showdev, javascript, nestjs, node
---

[In this video](https://youtu.be/WZtHM4Ph-K8) I walk you through one of the fastest ways to create a fully working RESTful Node.js CRUD API utilizing the Nestjs framework, TypeORM, Swagger/OpenAPI, and a few other packages! 

Complete with API documentation! Let me know what you think :smile:

{% youtube WZtHM4Ph-K8 %}