teleren/devto huggingface dataset:
[JAVASCRIPT] Primitive vs. Reference Data Types
Published: 2022-07-19 00:16:49

## In javascript, there are two different data type: primitive and reference

| Primitive Types | Reference Types       |
| --------------- | --------------------- |
| Number          | Object                |
| String          | Array                 |
| Boolean         | Function              |
| Null            | Map                   |
| Undefined       | Set                   |
| BigInt(ES6)     | WeakMap, WeakSet(ES6) |
| Symbol(ES6)     |                       |

### Array, function, map, set, WeekMap, WeakSet are also objects.

## Both types of variables have declaration and assignment.

```
<!-- Primitive Type -->
let name = "kevin";
let age = 20;

vs

<!-- Reference Type -->
let name = {name: "kevin", age: "20"};
```

### Both types of variables are stored in memory at the declaration by using 'let'.

### However, assignment works differently for the two variables.

![memory diagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j6stp8kb0ogjvfpbwe2y.png) 

### When variables are declared, their values are stored in either a 'stack' or a 'heap'. These memory types will not be covered in this article.

> As you can see, the primitive types of variables, "Kevin" and 20 are stored in the stack as values when the reference variable of the object is stored as an address.

## Key differences of the two types

- Primitive variables store primitive values
- Reference variables store an address
- The primitive's value is copied
- The reference's address is copied
- Primitive values are compared
- Reference addresses are compared
- The primitive value is returned
- The reference's address is returned

### As you can see, data is categorized into two different types and the computer store them differently. It is important to understand and identify each type because it is common to face many issues related to the differences in these types.

### I hope that you found this article helpful. Feel free to contact me for any questions or comments.
Day 100: Impressive! I'm Really proud
Published: 2022-07-19 00:11:16

Hi!
Today marks the 100th day since I started this challenge whew! can you believe it? I can't I actually haven't done anything else consistently for a whole hundred days. I remember when I started back in April I struggled a lot with consistency and I wanted something that will keep me focused so I started this simple challenge and the rules were actually simple: posting something/anything daily here on dev.to. what started as a silly challenge turned out to be a great motivation for me to learn and I started writing tutorial articles and doing a lot of research and got comfortable reading documentations and learned a lot along the way and now I'm day 100 into this and still counting which is insane for me and I'm so proud.

Today I finally worked on the time management system and decided to use Notion as my task/time management, I had some concerns doubting that it may be too advanced for me but after using it for a few hours trying things out and I realized that it's so powerful and  really like it so I will be using it

Signing off...
#JulyOT 19: Powering Azure Sphere C Development with DevX
Tags: julyot, iot, embedded, devrel
Published: 2022-07-20 02:02:15

---
title: #JulyOT 19: Powering Azure Sphere C Development with DevX
published: true
date: 2022-07-19 00:00:00 UTC
tags: julyot,iot,embedded,devx
canonical_url: https://JulyOT.dev/blog/julyot-day19-embedded
series: JulyOT 2022
cover_image: https://JulyOT.dev/assets/images/JulyOT-banner-19-sphere-devx-206c53b6b1641bb4fb181453bf7eb0f2.png
---

_Azure Sphere is a unique highly secure IoT platform. You focus on your solution, Azure Sphere deals with security, identity, certificates, reporting, tracking emerging attack vectors, mitigating, updating the platform, and application distribution to protect your solutions, customers, and reputations._

I started my Azure Sphere journey 2 years ago. I’d done plenty of embedded development, but I quickly realized there was a lot to learn about Azure Sphere. If this sounds like your journey, then do check out the “[Combining Azure Sphere IoT security with Azure RTOS real-time capabilities](https://techcommunity.microsoft.com/t5/internet-of-things/combining-azure-sphere-iot-security-with-azure-rtos-real-time/ba-p/1992869)” article. There are links to the Azure Sphere developer Learning paths for IoT Hub and IoT Central.

## Azure Sphere DevX[​](#azure-sphere-devx "Direct link to heading")

Azure Sphere DevX is an Open-Source community-driven library that is based on the GitHub Azure Sphere samples and from real-life experiences building Azure Sphere applications. Community contributions are very welcome.

The DevX library accelerates your development and will help to improve your developer experience building Azure Sphere applications. The DevX library addresses many common Azure Sphere scenarios, it will help reduce the amount of code you write and improve readability and long-term application maintenance.

The DevX library addresses many common Azure Sphere scenarios including the following:

1. Azure IoT Messaging: Implements connection management and simplifies sending messages along with application and content properties metadata.
2. Azure IoT Hub Device Twins: Handles Device Twin JSON serialization and deserialization along with a type system to validate data types received and sent.
3. Direct methods: Simplifies in-bound direct methods message processing and passes direct method payload to the associated direct method handler.
4. Intercore messaging: Provides a context model to simplify the passing of messages between high-level and real-time application cores.
5. Event timers: Simplified API for all common Event Timer scenarios.
6. Deferred updates: You focus on when you want application and OS updates to occur rather than how to defer updates.
7. Async events: Async events enable you to marshal calls from one thread to another for event-driven applications.

{% youtube rfXwEa-gMG8 %}

## Get Started[​](#get-started "Direct link to heading")

Visit the [Azure Sphere DevX library Wiki](https://github.com/Azure-Sphere-DevX/AzureSphereDevX.Examples/wiki) to learn more.
Day 595 : Changes
Tags: hiphop, coding, code, lifelongdev
Published: 2022-07-18 23:21:36

_liner notes_:
- Saturday : So, I was leaving the van to get ready for the station and when I opened the sliding door, there was a white frog hanging out in the door spacing. I quickly shut the door and was basically trapped because I was pretty sure there were frogs in the other doors as well. haha I slowly opened the driver's door and there weren't any frogs. Needless to say, I left for the station much later than I thought. haha Got to the station, set up and had a good time. The recording of this week's show is at https://kNOwBETTERHIPHOP.com

![Radio show episode image of a white frog on a light green branch with the words July 16th 2022 988](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uh13upv7669xc006jlbu.jpg)

- Sunday : Did my https://untilit.works cyphers and actually got some work done on my side project. Ended the night watching some episodes of "The Rising of the Shield Hero".

- Professional : Had a surprising a lot meetings today. Normally it's just a couple, but there was some big news and we got together to talk about it and asked questions. Spoke with the team about a demo I was building. Then did some more editing on some videos I recorded that got reviewed. Just a couple of small things and the program I used to put it together makes it pretty easy to make changes.

- Personal : I'm thinking this week, I'll get the proof of concept for the front end of my side project worked out.

![View of a river with small waterfalls surrounded by trees in Lynn Camp Prong, TN, USA](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2gembbrr9cv0l5997krb.jpg)

Not sure how much stuff I'm going to get done. I think I slept bad and my neck has been killing me. May just call it a night early and watch some anime and relax.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube 583RC5eouZM %}
📢 Grype 0.42.0 is out... and hello grype-contribs 👶
Tags: docker, productivity, devops, security
Published: 2022-07-18 23:20:40

## ❔ About

[`Grype`](https://github.com/anchore/grype) recently released a very interesting version : [`v0.42.0`](https://github.com/anchore/grype/releases/tag/v0.42.0), which includes a very (very) interesting feature (and resource within the issue itself) : 

> Templates for Grype output. HTML template `Issue #724` : 

{% github https://github.com/anchore/grype/issues/724 %}

☝️ This post is dedicated to this feature and to a contribution project I did create for our needs.

## 🗞️ Always stay aware of `Grype` updates

Find below how I stay up-to-date with [`Grype`](https://github.com/anchore/grype) :

{% youtube https://youtu.be/hEHzWiT9e1k %}

## 💡 The "grype-contribs" idea

I wanted to summarize at a single place a community driven set of resources and practices around `Grype` as it is now part of our culture at [`opt-nc`](https://dev.to/optnc).

In this first version I wanted to 

- 📊 Perform **nice looking charts** in the terminal
- 📜 Be able to **export nice looking scan reports**

👉 Let's see what we got it this very early versions.

## 🍿 Demo time

{% youtube C2-i_fc5fKk %}


## 🔖 `grype-contribs` repo

{% github opt-nc/grype-contribs %}

## 📑 Resources

- [`grype-contribs`](https://github.com/opt-nc/grype-contribs)
- [`grype`](https://github.com/anchore/grype)
- [`termgraph`](https://github.com/mkaz/termgraph)
A quick recap of F4 Thailand: Boys Over Flowers
Published: 2022-07-18 22:49:23

Gorya is a naked young woman who works in a flower shop. She finishes a test and is admitted to a noble and extravagant school attended by the rich, run by a first-class club known as F4, made up of four rich, handsome, and broke young men.

Gorya is the one who in particular stands up to his harassing ways, leaving all the youngsters stunned, especially Thyme, the leader of the group. Immediately affected by Gorya, Thyme earnestly seeks her out, but she cares very little for him in her initial feelings [doramasvip](https://doramasvip.video/) .

At that moment, she succumbs to her beloved partner Ren, but Ren is in love with his young love, Mira. In all the chaos of the school, Gorya cannot resist the temptation to end up succumbing to Thyme in light of her liberality to her and her family and her adjustment of character.
Waffleweb: A New WSGI-Compatible Python Web Framework.
Tags: python, showdev, opensource, webdev
Published: 2022-07-18 21:27:13

Waffleweb is a new Python web framework. It is WSGI-Compatible and highly customizable. Since it is in alpha, developments and changes are common.

It is lightweight and highly extensible. It is pretty basic, but it has everything you need to make personal websites, APIs, social platforms and much much more

I have been working it for a while now, and I plan to continue developing it.

You can find it at the Waffleweb [GitHub](https://github.com/Berserkware/waffleweb).

## Installation

You can install Waffleweb with [pip](https://pip.pypa.io/en/stable/).

```
pip install waffleweb
```

## A Simple Example

```
from waffleweb import app
from waffleweb.response import HTTPResponse, render

@app.route('/index')
def index(request):
    return HTTPResponse(request, 'index')

@app.route('/article/<id:int>/<name:str>')
def articleView(request, id, name):
    return render(request, 'articleView.html', context=findArticle(id, name))

app.run()
```

As you can see it is extremely easy to set up a simple website.

## Other Links

 - Documentation- https://waffleweb.readthedocs.io
 - Changes - https://berserkware.github.io/waffleweb/changes
 - Source Code - https://github.com/Berserkware/waffleweb
 - Website - https://berserkware.github.io/waffleweb
 - Discord - https://discord.gg/U6HjwhkcGr


If you like the project, please consider starring it on GitHub to show support. Thanks!
Magnifying Glass for Text and more!
Tags: codepen, javascript, showdev, webdev
Published: 2022-07-18 20:57:17

After discovering the backdrop-filter property - specifically "blur()" function - I thought it would be cool if there was also a "scale()" option. 

Unfortunately, I couldn't find anything of the sort. The closest thing I could find to scaling the element behind another element was [this W3 tutorial](https://www.w3schools.com/howto/howto_js_image_magnifier_glass.asp). 

But what about text?

**And thus the magnifying glass was born:**

{% codepen https://codepen.io/eitanwaxman/pen/rNdjaQO %}


**Open issues:**

- Magic numbers - spent a while trying to math it, but still haven't arrived at the formula that works well for different sizes and scales. 
- linear-gradient of the lens doesn't show above images. 

Although this is mostly just for fun, I think this has some real use cases for those who are hard of seeing - there is something to be said for magnification in context (and not just making the entire page bigger).

Maybe a browser extension?

Cheers
HOW TO RECOVER YOUR LOSS CRYPTOCURRENCY BACK
Tags: news, github, blockchain, crypto
Published: 2022-07-18 20:46:03

Millions of cryptocurrency investors have been scammed out of massive sums of real money. In 2018, losses from cryptocurrency-related crimes amounted to US$1.7 billion. The criminals use both old-fashioned and new-technology tactics to swindle their marks in schemes based on digital currencies exchanged through online databases called blockchains.
From researching blockchain, cryptocurrency and cybercrime, I can see that some cryptocurrency fraudsters rely on tried-and-true Ponzi schemes that use income from new participants to pay out returns to earlier investors.
Fast-talking swindlers
Some cryptocurrency fraudsters appeal to people’s greed, promising big returns. For example, an unknown group of entrepreneurs runs the scam bot iCenter, which is a Ponzi scheme for Bitcoin and Litecoin. It doesn’t provide information on investment strategies, but somehow promises investors 1.2% daily returns.
The iCenter scheme operates through a group chat on Telegram. It starts with a small group of scammers who are in on the racket. They get a referral code that they share with others, in blogs and on social media, hoping to get them to join the chat. Once there, the newcomers see encouraging and exciting messages from the original scammers. Some newcomers decide to invest, at which point they are assigned an individual bitcoin wallet, into which they can deposit bitcoins. They agree to wait some period of time – 99 or 120 days – to receive a significant return.
During that time, the newcomers often use social media to share their own referral codes with friends and contacts, bringing more people into the group chat and into the investment scheme. There’s no actual investment of the funds in any legitimate business. Instead, when new people join, the person who recruited them gets a percentage of the new funds, and the cycle continues, paying out to earlier participants from each round of newer investors.
Some members work especially hard to bring in new funds, posting tutorial videos and pictures of themselves holding large
amounts of money as enticements to join the scam.

Professional money recovery?
Apparently, there are services you can hire that specialize in this. Some of them seem to imply they don't charge unless they are successful. You might want to spend some time browsing Google search results such as these. I know nothing about these.
Obviously, be very careful since some of these may be tricky (but legitimate) or even fully fraudulent. Some of these may be cynically built on the theory that someone who has fallen for a scam should be easy to scam a second time. But if you can find a service that looks good like prudentrecovery and you figure out some way to validate it as a trustworthy (maybe get someone to help you with that), it might be worth trying out.
In my opinion  prudentrecovery these services are, theoretically, not necessarily fraudulent. (How's that for a recommendation?
I once tried not to use date-fns
Tags: javascript, frontend, testing
Published: 2022-07-18 20:27:36

In one of my team's Pull Requests I noticed date-fns being added as dependency for our components library for one usage: transform a timestamp to "MM/yy" string, as it represented a debit card's expiration date.
Inspired by [You don't (may not) need lodash/underscore](https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore), I thought to myself - can't we just implement a 2-digit month and 2-digit year formatting? It looks simple, right?

Inspecting native Date's [documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date), we have `getMonth` - returns 0-indexed integer representing the month of the year. First gotcha here, you have to increment value for human-readable month. As for the year, we have `getFullYear`, which is pretty self explanatory.

Let us write a function - not necessarily for reusing it, but more so we can easily test it. And let's write the dumbest one, and improve it test by test ;)

```javascript
function expiration(date) {
  return `${date.getMonth() + 1}/${date.getFullYear() % 100}`;
}
```

that would work wonderfully for something like

```javascript
it('should return 11/22 for nov 2022 expiration', () => {
  expect(expiration(new Date(2022, 10)).toEqual('11/22');
});
```

but would of course fail for one-digit months

```javascript
it('should return 03/23 for March 2022 expiration', () => {
  expect(expiration(new Date(2023, 2)).toEqual('03/23');
});

// Expected "3/23" to equal "03/23"
```

We can address that by a fun trick: simply pad a heading `0` whatever the result is, and then retain the last two chars, using negative argument for `substr`

```javascript
function expiration(date) {
  return `0${date.getMonth() + 1}`.substr(-2) + 
         `/${date.getFullYear() % 100}`;
}
```

Seems finished? What's missing?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
You got it. What if the remainder in date.getFullYear() % 100 is one digit?

```javascript
it('should return 03/00 for March 2100 expiration', () => {
  expect(expiration(new Date(2100, 2)).toEqual('03/00');
});

// Expected "03/0" to equal "03/00"
```

which leads us to 

```javascript
function expiration(date) {
  return `0${date.getMonth() + 1}`.substr(-2) +
         "/" +
         `0${date.getFullYear() % 100}`.substr(-2);
}
```


Phew! Now the only thing left to figure out: What is 00? 2000 or 2100?

How far have you gone implementing features that are available in libs like `date-fns`, `lodash`?
Is it worth the hassle (and the risks!) considering tree shaking* is doing a neat job in packaging optimal production JavaScript?

Last and not least, let me know if you'd write it differently. Have I missed a corner case? Hope you enjoyed my test-driven approach, although it's closer to a "test-before" rather than a "test-driven-development". 

*provided you are using modularization of both your code and your dependencies (i.e. using es-modules or other implementations), and that the bundler is capable of exploiting the modularization in order to trim unused code
Laravel Backend for Headless CMS
Tags: laravel, php, cms, headless
Published: 2022-07-18 20:12:14

How do you construct with [Laravel](https://laravel.com) the backend of a headless CMS?

# What is Headless CMS

A headless CMS (Content Management System) has a web interface only for creating content but no web interface for showing content to the audience. 

The advantage of a headless CMS is that you do not impose a particular way of content display. So you are free to construct your SPA (Single Page Application) to display content.

After years of using different CMS, we expect that creating content and displaying content through a CMS, whether headless or not, has to support certain activities. 

# Writing 

Pieces of content, such as articles, are written and rewritten over hours or days. An author seldom publishes a piece of content in the same session in which he/she started to compose it.

Consequently, the backend of a CMS has to store and update drafts before publishing content. 

# Approval 

An enterprise-grade CMS requires a flow of approval for each piece of content. So an article is written, reviewed, and then approved. 

The backend of a CMS has to implement such an approval workflow.  

# Comments 

Once the content is displayed, we expect readers to comment on each piece of content and to comment on comments. 

So the backend of a CMS has to store threads of comments.

# Laravel Packages to Do the Job

One should consider that pieces of content can come from different types of models in the same CMS, such as articles, posts, and pages.

We would use the following packages:

* [Laravel Drafts](https://github.com/oddvalue/laravel-drafts) - do manage drafts and revisions
* [Laravel Comments](https://github.com/ryangjchandler/laravel-comments) - store comments on models
* [Approval](https://github.com/cjmellor/approval) - approve a model before it is persisted
VSCode-ObjectScript on GitHub
Tags: tutorial, beginners, vscode, github
Published: 2022-07-18 19:20:39

Not so while ago GitHub introduced, ability to very quickly run VSCode in the browser for any repository hosted there. Press the `.` key on any repository or pull request, or swap `.com` with `.dev` in the URL, to go directly to a VS Code environment in your browser.

![github dev](https://user-images.githubusercontent.com/856858/130119109-4769f2d7-9027-4bc4-a38c-10f297499e8f.gif) 

This VSCode is a light version of the Desktop version but works entirely in Browser. And due to this, it has a limitation for extensions which was allowed to work this way. And let me introduce the new version 1.2.1 of VSCode-ObjectScript extension which now supports running in Browser mode.

<!--break-->


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y44isbjsi7lo2s77p1pk.png)

What you will need to do, is to open any repository in this new environment, go to extensions, search and install VSCode-ObjectScript extension. Installed once it will be available for any repository, you will open next.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zlz6soc1tdkym7jblml5.png)

It's the same extension but has just basic functionality for now. Just syntax highlighting. For sure it does not have access to running IRIS, but some more features, which could be available offline, may appear in the future.

### Without GitHub

There is one more option, if you wish to run VSCode in browser, but not tied to any GitHub repo, and just open some of your local folder. It's <https://vscode.dev>. VSCode-ObjectScript extension became available there as well.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a5firtbmywcacyfv6i0n.gif)