teleren/devto huggingface dataset:
Create Object with dynamic property name in javaScript([name]:val)
Tags: javascript
Published: 2021-06-09 10:42:53

# What can you do?
```js
const obj = {
  "name":val
}

// to
const prop = "name";
const obj = {
  [prop]:val
}
```
With new `javaScript`, you can create object by assigning dynamic properties to it.

# Use Case
You have following document in your `MongoDB` collection
```js
{
   name:"Rahul kumar",
   title:"....",
   body:"..",
   tags:[...],
   date:"..",
   createdAt:"...",
   editedAt:"..",
   ....more
}
```
If you know `MongoDB` then you might have modified any attribute of `document`.

In this case, we need to write query like below,
```js
db.collection.update({...filter},{
  $set:{
    attributeName:"value...",
    // like
    title:"....",
  }
});
``` 

If you are not using dynamic property feature, then you might be creating different express routes and different functions to edit name, title, body and so on..

But, do you know you can do this in just single function?

Yeah, here we can use dynamic property names..
```js
function update(attr,data){
db.collection.update({...filter},{
  $set:{
    [attr]:data
  }
});
} 
```
Now, you can pass any string as attribute name and data to edit the value.

There might be more use cases which you can comment below.
## Thanku
Lưu ý khi xây dựng lăng mộ đá
Published: 2021-06-09 10:33:58

Lưu ý khi xây dựng mộ đá
Ngày nay để không phải mất nhiều thời gian lựa chọn vị trí đặt mộ và tiện cho con cháu thăm viếng, người ta thường lập một khu riêng để quy tập tất cả mộ phần trong dòng họ về. Do ảnh hưởng tới phúc phận cả một dòng họ nên khi xây dựng cần hết sức chú ý về mặt phong thủy, từ khâu đầu tiên đến khâu cuối cùng.
Đọc tiếp cùng Đá Mỹ Nghệ Trung Kiên tại: https://damynghetrungkien.vn/mo-da/
#langmoda #moda #damyngheninhbinh #damynghetrungkien
Saving a missing referral
Tags: javascript, analytics, referral, frontend
Published: 2021-06-09 10:29:26

### Problem
After the [GDPR](https://gdpr.eu/), we can no longer enable cookies without user consent. This means that we can no longer save the user's session on their first visit, losing your reference.

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

### How can I save the referral?
We can save the referral using the localStorage property at the first access.

Before saving, we need to check if there is a referral to be saved and if the referral is different from our document.location.origin to avoid saving your website as a referral (This also prevents cases where the user goes to another page of your website).
```javascript
if(document.referrer.length > 0 
&& document.referrer.indexOf(document.location.origin) !== 0){
    localStorage.setItem("referral", document.referrer);
}
```

After that, we can retrieve our referral when it's necessary to call our cookie function.
```javascript
// Get the referral saved on localStorage
var referral = localStorage.getItem("referral");

// Verify if exists
if(referral !== null 
&& typeof referral !== "undefined")
{
    // Define your saved referral into document.referrer
    Object.defineProperty(document, "referrer", {
        get : function(){ return referral; }
    });
}

// After that you can call your cookies function, analytics,  facebook pixel, etc...
callCookies();
```

Hope it's helpful some of you 🙂
Challenges with implementing BankID and Fortnox into your software 
Tags: saas, startup
Published: 2021-06-09 10:09:30

Hello, my college wrote about some challenges that he bumped into when he was implementing BankID and Fortnox functionalities into a software that we're building. Maybe this is something useful and people can plan better after the read. 

Truly appreciate any kind of feedback, good or bad. 

https://jsguru.io/baking-bankid-fortnox-into-homecraft-and-what-we-learned-in-the-process/
How a viral video helped me design my MVP
Tags: microservices, microservicegoverance, devops
Published: 2021-06-09 09:55:52

If you’ve ever worked as product manager or a technologist working within a complex technology ecosystem, you’ve likely had a conversation like this before.

Usually tho, it’s a little less humourless…

{% youtube y8OnoxKotPQ %}

About a year ago, I came across that video. I chuckled along — it’s funny ‘cause it’s true — and promptly forgot about it.

## One year later
As I was building the MVP for [the Slate](https://www.theslate.co/), I came across it again. It stuck me, this is the type of problem I’m trying to help solve.

Highlighting and communicating dependancies between microservices, architectural decisions and product requirements is hard. So I took the video and tried to work out two things.

1. Does [the Slate](https://www.theslate.co/) have all the functionality there that they describe?
2. What would this technology estate even look like if they used the Slate?

##The results
After some tweaking and a missed piece of functionality (“deprecation notices, how could I have forgotten those?!”), I had a result.

* [A service specification for Entropy Khaos Service (EKS) which is being deprecated](https://app.theslate.co/#/example/services/3fa1743e-a084-11eb-892a-4713a7ea79d7)
* [A service specification for Omega Star](https://app.theslate.co/#/example/services/400943fc-a084-11eb-84e8-37f16b167d93), the replacement for EKS
* [An architectural decision that everything should support ISO timestamps](https://app.theslate.co/#/specs/example)
* And of course, [Galatcus](https://app.theslate.co/#/example/services/400943fc-a084-11eb-84e8-37f16b167d93), the all-knowing user service provider aggregator.

## Could the Slate have helped?
Would the Slate have stopped an awkward conversation between a Product Manager and Developer that ended in crying? I’m not sure.

Would the Product Manager have known about how the services interrelate, what the blocker for Birthday Boy is and why? I’d say so.

I know that it’s an exaggerated scenario, but it’s pretty close to the truth as well. It also gave me a nice “demo-able” example for people to see/interact with the service.

Overall, it felt like a worthwhile endeavour. Although I’m sure I’ve missed something, somewhere.
What is the connection between data science and artificial intelligence Is it machine learning
Tags: datascience, machinelearning, algorithms, ai
Published: 2021-06-09 09:44:01

Fundamentally, yes. Data science is the utilization of factual techniques to discover patterns in data. 

Machine learning utilizes a similar math as data science however applies it to algorithms that improve all alone. Artificial intelligence is the general field of "intelligence-reproducing algorithms" of which machine learning is at the main frontier right now. Data science assists with the "co-relation" of data, consolidating numerous data focuses to get significant information from a tremendous measure of data. A machine, with such capacities, will make for a decent starting point for artificial intelligence. On the off chance that you need a detail clarification of Data Science, do look at Intellipaat's blog which will help you in understanding DS. 

You can get an involved project by referring the accompanying [Learn Data Science](https://intellipaat.com/blog/tutorial/data-science-tutorial/) Courses by Intellipaat which will encourage you Data Science from scratch which will help you in mastering in the field of Data Science
How to Make Contentful Work in China?
Tags: contentful, node, javascript, cms
Published: 2021-06-09 09:37:29


---
canonical_url: https://www.21cloudbox.com/solutions/how-to-make-contentful-work-in-china.html
---
Previously, we have an [article](https://launch-in-china.21yunbox.com/solutions/contentful-alternatives-in-china.html) explaining why Contentful doesn’t work in China already, we also provided an alternative solution that helps teams to get Contentful to work in China. In this blog, we are going to give you solutions in detail about how to make Contentful work in China without switching CMS.


<p>&nbsp;</p>

## Getting Contentful to work in China
We have two solutions for you to choose from, both of these solutions offer the best loading time experience to your websites’ readers as well as your content teams.


<p>&nbsp;</p>
### Solution 1: For teams outside of China
If you are outside of China, your website published with Contentful is slow mainly because of two reasons:

<p>&nbsp;</p>
#### 1\. Contentful doesn’t have servers or CDN (Content Delivery Network) nodes in China.
This is obvious, but I still want to put it here because it is just one of the two reasons why your website is slow in China. For longer explaining why servers of Contentful are slow in China, read Does Contentful Work in China? for reference.


<p>&nbsp;</p>
#### 2\. Your website hosting provider doesn’t have servers or CDN nodes in China.
This is another reason why your website is slow in China.

Let’s take a look at how this relates to your website and the Contentful. If we look at the website deployment process at a high level and say you are making a change on an article on your website. Here are what happen behind the scene:

When you press the “Save” or “Publish” button on an article in the dashboard of the Contentful, the Contentful backend trigger a “build and deploy” message onto the hosting providers (the popular ones outside of China are Netlify and Vercel)

...

To read the full content of this post, go to: [https://launch-in-china.21yunbox.com/solutions/how-to-make-contentful-work-in-china.html](https://launch-in-china.21yunbox.com/solutions/how-to-make-contentful-work-in-china.html)
<p>&nbsp;</p>
<p>&nbsp;</p>
Call by Value vs Call by Reference
Tags: python, programming, oop
Published: 2021-06-09 09:32:44

Call by value and Call by reference are the two types of generic methods to pass parameters to a function. 
C++ uses call by value method while Java uses call by reference method.
But what does Python use? does Python use call by value or call by reference to pass parameters to a function? 
**Let's find out ......**

## Example 1
```
def add_num(number):
    number += 1

n = 12

add_num(n)
print(n)                          # 12

```
here it does not change value of n at all. So it seems Python uses call by value method to pass the parameters.
But is it correct?
let's see another example to confirm it...

## Example 2

```
def add_element(num_list):
    num_list.append(5)

my_list = [1,2,3,4]
add_element(my_list)
print(my_list)                             # [1,2,3,4,5]

```
That's Weird!
Example 2 tells us that Python uses call by reference method to pass the parameters.

These are two contradicting examples by themselves !

Don't get confused , let's decode what's actually going on here

## Explanation

first of all remember a simple basic thing about Python i.e everything in Python is an Object.

In the 2nd example when we call the function *add_element* and pass *my_list* as the parameter we are passing the entire object as a parameter and that object gets mapped onto *num_list*. 
So now *num_list* and *my_list* are pointing to the same list i.e [1,2,3,4] so now any changes made to this list whether by *my_list* or by *num_list* will be made in the original list

If you want to confirm this you can use the **id()** function on both *my_list* and *num_list* and can see the same for yourself.

This type of parameter passing method is known as call by object.
In this method you pass the entire object as the parameter and then all the changes made to this object is global

Now you would ask , in example 1 isn't *n* also an Int object? So technically the value of *n* should also change , but it doesn't.
Why?
**let's solve that mystery also**...

let's go to basics again.
In the 2nd example we have used a list object and lists are mutable while in the 1st example we have used an Int object and Int is immutable.
So what actually is happening in example 1 is when we increment the value of *n* since Int is immutable the function creates a new container and stores in it the incremented value of *n* while the original *n* stays the same. 

## Conclusion
So to conclude , Python uses call by object method to pass around the parameters and it depends on the object type whether it uses call by value or call by reference method underneath . 
when you pass the function an immutable object Python uses call by value method . 
when you pass the function a mutable object Python uses call by reference method. 

Hope your confusion is clear


If you still have some doubts feel free to connect with me on **[Twitter](https://twitter.com/DaultaniIshann)**
Learning Journey - first entry.
Tags: a11y, html, css
Published: 2021-06-09 09:21:58

---
title: Learning Journey - first entry.
published: true
description: First post in my learning journey
tags: accessibility, html, css
cover_image: https://storage.googleapis.com/mcp_236blog/uploads/2019/06/4.-BLOG-FEATURED_JOURNEY_PODCAST-4-1920x1000.png
---
I'm front-end dev from Ukraine.
Working in web development more than 5 years. Don't have CS degree and everything I learned was from dev community that's why decided to start simple kind of journal(blog) where going to share my learning experience for my future self and anyone who might find it useful.

Currently decided to improve my knowledge in web accessibility, because thinking that this is important topic and very often ignored or moved to the background in process of development. 

## Skip links
Great technique that is used to improve navigation around the page with assistive technology.

Very often first thing that our DOM contains is navigation or sidebar with a lot of links - thats why users with impairment often frustrated and click through whole navigation before actually get to content. The easiest way to fix that issue is to place as the first thing in the DOM hidden link and bring it back into view when it get focused. After user hit enter on that link focus jumps right to the main content section. 

## Implementation example

```html
<header>
  <a class="skip-link" href='#main'>Skip to content</a>
  <!-- Navigation-->
</header>
 
<!-- Maybe some other stuff... -->
 
<main id="main">
  <!-- Content -->
</main>
```

```css
.skip-to-content-link {
  left: 50%;
  position: absolute;
  transform: translateY(-100%);
}

.skip-to-content-link:focus {
  transform: translateY(0%);
}
```

## Useful links
https://a11y-101.com/development/skip-link
http://web-accessibility.carnegiemuseums.org/code/skip-link/
https://css-tricks.com/how-to-create-a-skip-to-content-link/
Using pre-commit and post-update git hooks
Tags: git, terraform, automation, testing
Published: 2021-06-09 05:42:08

---
title: Using pre-commit and post-update git hooks
published: true
description: Validate, enforce standards, and more, in your projects using git hook features.
tags: git, terraform, automation, testing
//cover_image: https://direct_url_to_image.jpg
---

Adding some additional processing to your git workflow is sometimes useful/cool/interesting, and the functionality provided by [githooks](https://githooks.com/) make this fairly accessible to make use of. I typically make use of very few of these (in place of having things happen on the server-side — tests, etc.-that can be enabled externally or using server-side hooks) on the client-side, and adapt two included in `.git/hooks/` by default, `pre-commit` and `post-update`, for, you guessed it, before commits are made, and after a set of commits are pushed.

In my capacity as an operations engineer, I make use of tools like Terraform often, which has the benefit of including a formatting tool and a validation tool — this is a good example of where a pre-commit hook can be useful — before I create a commit, I can validate the manifest and check formatting/style of the manifests being updated. I can do this by modifying, in my project root, `.git/hooks/pre-commit.sample`, and add something like this to check `.tf` files against these standards:
```bash
modified_files=$(git ls-files -m)
for f in modified_files
do
    if [-e "$f" ] && [[ $f == *.tf ]]; then
        terraform validate $(dirname $f)
        terraform fmt $f -check=true
        git add $f
    fi
done
```
I’ve adapted my approach from [James Turnbull’s pre-commit hook script](https://gist.github.com/jamtur01/a567078b7ba545c3492f7cd32a65450d) to process this slightly differently, but also highlights that these are basically just a scriptable interface to manage git’s behavior.

To enable this hook, copy the file to `.git/hooks/pre-commit` (no `.sample`).

Let’s take a look at a more involved example in my `post-update` script. In my case, I am working on a Mac, so I’d like to make the most of this — maybe introduce some more visual cues for me to follow, so I want to use some Applescript as well.

In `.git/hooks/post-update`, I want to grab the hash and message of the last commit pushed, and the branch I pushed to:
```bash
COMMIT=$(git log -1 HEAD | head -n 1 | awk '{print $1}')
MESSAGE=$(git log --format=%B -n 1 $COMMIT | xargs echo )
BRANCH=$(git branch | grep \* | cut -d ' ' -f2)
```
and to make this useful, I can see a summary of my latest push by adding this call to `osascript`:
```bash
/usr/bin/osascript <<EOF
display dialog "To $BRANCH:\n\n$MESSAGE\n\n\t($COMMIT)\n" with title "Git Push" buttons {"I meant to do that"} default button 1
```
To have a pop-up dialog and just a reminder of what I did, so I stop to check my work one last time before moving on to my next task.
Why should beginners start with Python?
Tags: python, beginners
Published: 2021-06-09 09:02:54

Python is a general purpose programming language. Python is beginner friendly. It allows you to learn the concepts of programming first before getting your hands dirty.

Comparatively, Python is much easier to learn and is much simpler to code. Python is known as a readable programming language and its syntax was designed to be interpret-able and concise, and has inspired many other coding languages.

Python will be the language of the future. Python has all the libraries you can imagine. It is open source and has a vibrant community.

Python programming language is better used for app development, web app or web development, game development, scientific computing, system administration, etc. There are several traits of this programming tool which has provided it with an incredibly successful journey.
Rediriger les fiches produits dans WooCommerce
Tags: php, woocommerce, wordpress, french
Published: 2021-06-09 09:00:39

---
title: Rediriger les fiches produits dans WooCommerce
published: true
description: Dans WooCommerce chaque produit a une page dédiée. Dans le panier, les produits renvoient à celles-ci. Si vous voulez désactiver cette fonctionnalité et afficher une page avec tous vos produits, vous pouvez ajouter ce code à functions.php Ainsi toutes les pages produits redirigeront vers la page 269. Source : How to disable/hide woocommerce single product &#8230; Lire la suite
tags: php, woocommerce, wordpress, french
canonical_url: https://blog.samdha.net/2021/06/08/rediriger-les-fiches-produits-dans-woocommerce/
cover_image: 
---

Dans WooCommerce chaque produit a [une page dédiée](https://docs.woocommerce.com/document/marketing-product-pages-writing/#section-4). Dans le panier, les produits renvoient à celles-ci.

Si vous voulez désactiver cette fonctionnalité et afficher une page avec tous vos produits, vous pouvez ajouter ce code à [functions.php](https://developer.wordpress.org/themes/basics/theme-functions/)

```php
// redirige les pages produits
add_action('wp','prevent_access_to_product_page');
function prevent_access_to_product_page() {
  if ( is_product() ) {
    wp_redirect( get_permalink( 269 ) );
  }
}
```
Ainsi toutes les pages produits redirigeront vers la page 269.

Source : [How to disable/hide woocommerce single product page?](https://stackoverflow.com/q/44197739)

Also on: [Stack Overflow](https://stackoverflow.com/a/67885098/2530962)
How to Design Your Room with Augmented Reality (AR) [Tutorial]
Tags: tutorial, unity3d, augmentedreality, design
Published: 2021-06-09 09:00:28

Interested in interior design? Looking to recreate or design your own room in augmented reality (AR)? This interior design AR app demo created with Unity, AR Foundation, and echoAR is a great place to start. The full demo can also be found on echoAR's [GitHub](https://github.com/echoARxyz/Unity-ARFoundation-echoAR-demo-Interior-Design).

## Register

If you don't have an echoAR API key yet, make sure to register for FREE at [echoAR](https://console.echoar.xyz/#/auth/register).

## Setup

* [Add the 3D model](https://docs.echoar.xyz/quickstart/add-a-3d-model) from the [models](https://github.com/echoARxyz/Unity-ARFoundation-echoAR-demo-Interior-Design/blob/master/models) folder to the console.
* [Add the metadata](https://docs.echoar.xyz/web-console/manage-pages/data-page/how-to-add-data#adding-metadata) found in the [metadata ](https://github.com/echoARxyz/Unity-ARFoundation-echoAR-demo-Interior-Design/blob/master/metadata) folder.


![2.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1623228911899/eyb2f9K1K.png)

## Run
* [Build and run the AR application](https://docs.echoar.xyz/unity/adding-ar-capabilities#4-build-and-run-the-ar-application).


![3.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1623228948923/F-Cz3l9Tt.jpeg)

## Real-time updates
Add/remove/edit models in the console and notice that the interactive models in the AR scene changes automatically.


![4.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1623228966252/KSM_rf_rGG.png)

## Learn more
Refer to our [documentation ](https://docs.echoar.xyz/unity/) to learn more about how to use Unity, AR Foundation, and echoAR.

## Support

Feel free to reach out at support@echoAR.xyz or join our [support channel on Slack](https://join.slack.com/t/echoar/shared_invite/enQtNTg4NjI5NjM3OTc1LWU1M2M2MTNlNTM3NGY1YTUxYmY3ZDNjNTc3YjA5M2QyNGZiOTgzMjVmZWZmZmFjNGJjYTcxZjhhNzk3YjNhNjE).

****

> echoAR (http://www.echoAR.xyz; Techstars '19) is a cloud platform for augmented reality (AR) and virtual reality (VR) that provides tools and server-side infrastructure to help developers & companies quickly build and deploy AR/VR apps and experiences.

![5.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1623229010015/vfWEKa-VC.png)
Here is travel guide
Published: 2021-06-09 08:57:08

Traveltipsguides is a versatile <a href="https://traveltipsguides.com/">travel guide</a>  that offers you information on best places to visit across the world. 
<a href="https://traveltipsguides.com/">travel blog</a> 
<a href="https://travelworldfun.com/">travel guide</a>
<a href="https://yourtravelpoint.com/">Travel advice</a> 
<a href="https://www.missionworldtravel.com">travel tips</a>
How to create a PHP validator.
Tags: programming, php, oop
Published: 2021-06-09 08:56:43

Ok…
When i started with web development the first language i touched was PHP, i started creating simple form data inputs with some fields like:
*Name
*Email
*Phone number
etc.
And yes, they “work” but what happens when the users give us wrong data? and we dont want to use HTML’s validation tags because they are unsafe.
So i’ve decided to create my own Validator (no, not like Laravel validator).
#So… lets start.
For this you must know the basics of:
*OOP
*PHP 7.x
First of all we need a basic form with some fields (create your own or just copy it from below).
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tnh3cg20r8i82lrzbwgl.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mdc6volzfcp0tmms5jqr.png)
#Let’s create our class helper Validator.php

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

Nice! so let’s work on our someAction.php file.

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

Great! we only need to display those errors on login.php file adding some php script.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2pgycbijfp39dihmp1s2.png)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dpjf4zrpsb3d3rlskzv8.png)

And thats how we created our own validator in PHP.
Happy coding!