teleren/devto huggingface dataset:
How to check if a string is a valid SHA256 hash in JavaScript?
Tags: javascript
Published: 2021-05-11 00:00:00

---
  title: How to check if a string is a valid SHA256 hash in JavaScript?
  published: true
  tags: JavaScript
  date: Tue May 11 2021 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/check-if-string-is-valid-sha256-hash-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-16426122a199377c88e5831e3ba32012.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/check-if-string-is-valid-sha256-hash-javascript)
  
To check if a string is a valid SHA256 hash in JavaScript, we can use a regex expression to match for the 64 consecutive hexadecimal digits which are characters from `a-f` and numbers from `0-9`.

### TL;DR

```js
// Regular expression to check if string is a SHA256 hash
const regexExp = /^[a-f0-9]{64}$/gi;

// String with SHA256 hash
const str = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad";

regexExp.test(str); // true
```

This is the regex expression for matching almost all the test cases for a valid SHA256 hash in JavaScript.

```js
// Regular expression to check if string is a SHA256 hash
const regexExp = /^[a-f0-9]{64}$/gi;
```

This will match all the 64 hexadecimal digits which have characters in the range from `a` till `f` and numbers from `0` till `9`.

Now let's write a string with SHA256 hash like this,

```js
// Regular expression to check if string is a SHA256 hash
const regexExp = /^[a-f0-9]{64}$/gi;

// String with SHA256 hash
const str = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad";
```

Now to test the string, we can use the `test()` method available in the regular expression we defined. It can be done like this,

```js
// Regular expression to check if string is a SHA256 hash
const regexExp = /^[a-f0-9]{64}$/gi;

// String with SHA256 hash
const str = "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad";

regexExp.test(str); // true
```

- The `test()` method will accept a `string` type as an argument to test for a match.
- The method will return boolean `true` if there is a match using the regular expression and `false` if not.

See the above example live in [JSBin](https://jsbin.com/repezudaju/2/edit?js,console).

If you want this as a utility function which you can reuse, here it is,

```js
/* Check if string is a valid SHA256 Hash */
function checkIfValidSHA256(str) {
  // Regular expression to check if string is a SHA256 hash
  const regexExp = /^[a-f0-9]{64}$/gi;

  return regexExp.test(str);
}

// Use the function
checkIfValidSHA256(
  "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
); // true
checkIfValidSHA256("hello98123!"); // false
```

That's all! 😃

### Feel free to share if you found this useful 😃.

---
List of Cheat Sheet Compilations
Tags: productivity, webdev
Published: 2021-05-10 23:46:04


### 1. [The ultimate Cheat sheets compilation (200+) - 🔥🎁 / Roadmap to dev 🚀](https://dev.to/worldindev/the-ultimate-compilation-of-cheat-sheets-100-268g#2a).

### 2. [The ultimate Cheat sheets compilation (200+) - 🔥Roadmap to dev 🚀 - 2 ](https://dev.to/worldindev/the-ultimate-compilation-of-cheat-sheets-2-53he).

### 3. [Terminal Cheat Sheet 🔥 - The most useful terminal commands 🚀](https://dev.to/worldindev/the-most-useful-terminal-commands-how-to-work-with-directories-51l8).

### 4. [The Ultimate Web Developer Resources List 🔥Awesome 200+ Resources](https://dev.to/kiranrajvjd/the-ultimate-web-developer-resources-list-200-resources-2gf5).

### 5. [Lista de Recursos para Web Designers](https://github.com/nicolesaidy/awesome-web-design)
Starting Your New React App with Redux? Consider a Simpler Approach Using the Context API
Tags: api, reactnative, redux
Published: 2021-05-10 22:56:28

### Traditionally, starting a new React application means adding Redux for state management. Let's talk about the Context API as an alternative.

If you're bootstrapping a new [React](https://reactjs.org/) application today, ingrained habits might lead you to pick [Redux](https://redux.js.org/). After all, you **need** to manage the state. _Should you start with Redux, though?_ That has become a valid question. The latest versions of React have improved their offerings for state handling massively. In this post, I want to talk about a simpler approach, using the Context API instead.

## Let's Reminisce: Why Did We Embrace Redux?

A structured approach to state transitions in frontend applications wasn't always the norm. I remember trying to update multiple places in an application back when we were still using jQuery. That wasn't a pleasant experience.

![A change in the application triggers a cascade of updates that is very hard to track](https://images.ctfassets.net/23aumh6u8s0i/7qFbGf6yM0yMZer22wTT00/16ba7438ca2858714830a8b2b23b0070/a-change-triggers-a-cascade-of-updates-and-changes-to-an-application.png)

A change in one place leads to an update somewhere else. Now we need to patch that code as well. But then, there is a third area of the page that depends on the first two. At this point, the logic is convoluted and complex, and the snowball is just getting started.

Compared to that, Redux was eye-opening:

- The complete state of the User Interface (UI) is represented as an object.
- Any action that can modify the state is an object that contains data.
- Pure functions (reducers) ingest those actions and morph the state.
- Through selectors, we shape the data in the state for easy consumption for our components.

It seems self-evident now. But it was magical at the time.

![How changes flow through an application using Redux](https://images.ctfassets.net/23aumh6u8s0i/165hsFXreQt9XPGGSLQ1ju/14550278099b9c50d693cb0e4c096baa/change-flow-through-an-application-using-redux.png)

All the reasons that brought us here still apply. But the context has changed.

[Read more...](https://auth0.com/blog/starting-you-new-react-application-with-redux/?utm_source=content_synd&utm_medium=sc&utm_campaign=redux)
Why I'm glad I chose Tech!
Tags: firstpost, career, technology, wecoded
Published: 2021-05-10 22:47:06

Hi Everyone!  This is my first blog post here!

I've been asked repeatedly why I chose to learn Software Engineering. I wasn't seeking out this particular journey per se, but I was in a rut. One day I was scrolling through Twitter and I saw a post about this opportunity to learn computer programming at the Flatiron School.  I could take the course online while still being able to work my 9-5 job. So I signed up immediately.

Through my journey with the Flatiron bootcamp, I began to see the world in a different way. There are so many parts of our lives that are enhanced through technology. For example, we no longer need a camera, video camera, library, tape recorder or even a television. We have cellphones that run on software programs that we use in place of those things! So many things are run by software. Vehicles, refrigerators, washer and dryers, traffic lights, thermostats and so much more are all run by software programs!

What I have come to realize is that there is a great deal of opportunity in the technology field. Job opportunities are everywhere! For a lot of people this means an increase in pay allowing them new freedoms. Combining the tech field with other fields can be fun. You could have a tech job for an Art museum if you also have a love for the Arts, for example. Tech is everywhere!  Check out the Flatiron School and you can get started on an amazingly diverse new career!
Day 363 : Regular
Tags: hiphop, code, coding, lifelongdev
Published: 2021-05-10 22:25:41

_liner notes_:
- Saturday : It seems like I have been putting together the show later and later. haha I used to have at least a couple of weeks worth of tracks ready to go. Pretty much spent the day getting the show ready. Did the show. Had a really good time and then worked on uploading the recording putting together the playlist. The recording of this week's show is at https://kNOwBETTERHIPHOP.com

![Radio show episode image of 2 photos one with 2 women sitting with bags in front of them labeled People's Free Food Program and another with school children sitting at a table eating with 2 adults standing  with the words May 8th 2021 Classic](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8hxxblued31e4txetrhb.jpg)

- Sunday : Pretty chill and productive day. Worked on my side project, did some laundry, and even exported some screen recordings I did for work last week. It takes forever on my work laptop, so I just set it up and let it crank through them. Watched "Yasuke", "Fear the Walking Dead" and "Gangs of London". Oh and I've also been looking into land in South Carolina.

- Professional : Had a good day to start of my week. Got to talk about Web Components. Received some good feedback on the video I made from the template I created last week. Looked through some code for a blog post I'll be writing. Had a good meeting with my manager. Pretty good day.

- Personal : So, I've been for land to purchase on Zillow. I've been mostly looking around North Carolina, but I came across some listings in South Carolina. Didn't know that they have mountains, midlands and coastal areas all in one state. The area in North Carolina I was looking at seemed really mountainous. we'll see.

![View of the green field mountain side of the Caucasus Mountains at sunset](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aomn1qcfpro14wooddk0.jpg)

Going to go through some tracks for the radio show and start putting together the playlist so I'm not doing it the day of the show anymore. Need to really start doing a little bit each day. Going to work on my side project and watch an episode of "Yasuke". Really want to get a regular schedule going.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube DQXeaDNtGE4 %}
DotNet on a Raspberry Pi
Published: 2021-05-10 21:55:34

---
title: DotNet on a Raspberry Pi
published: true 
description: DotNet on a Raspberry Pi
tags: 
canonical_url: https://www.funkysi1701.com/posts/dotnet-on-a-raspberry-pi-3ldn
//cover_image: https://direct_url_to_image.jpg
---
I have had a Raspberry Pi for a few years and recently I connected it up again, I plugged in the camera and everything worked.

To start off you can view photos from the camera with the raspistill command. With a bit of clever scripting and the crontab I got the Pi taking pictures every 60 seconds. Even managed to take a nice picture of a robin.

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

However scripting isn't really programming, and I would like to write a bit more code. Dotnet can run everywhere these days and it made sense to see if it would run on a Raspberry Pi.

@pete_codes has written a nice guide to getting started with dotnet on a Raspberry Pi https://www.petecodes.co.uk/install-and-use-microsoft-dot-net-5-with-the-raspberry-pi/ This guide and the nuget package https://www.nuget.org/packages/Unosquare.Raspberry.IO/ was all I needed to get started taking pictures with my Pi.

My initial goal is to take some wildlife pictures, stick my camera to a window and take pictures of what flies/crawls/jumps past the window.

The code I have written so far is available on github https://github.com/funkysi1701/RaspberryPiDotNet 

So far the code takes a picture, uploads this file to Azure Blob Storage (so as not to fill up the Pi with too many image files) and deletes the image locally.

Run a dotnet publish -c Release and then cron can run dotnet RaspberryPiDotNet.dll (with full paths to the relevant files)

I then use crontab to execute the code every 60 seconds.

My code has an appsetting.json file which has a couple of settings that need completing for my code to work.

Storage: This is the connection string for Azure Blob Storage
LocalPath: This is the path to where the camera will save its photos to, something like /home/pi/ is all you need but feel free to specify what you need.

Once the photos are in blob storage I plan to display them somewhere, add options to delete what I don't want, maybe do something timelapsey.  

I also don't have a proper release pipeline and this grates on me a bit. I have been doing a mixture of writing code in VS and pushing that to github and then doing git pull on the Pi, and also writing code directly on the Pi. (VS Code can connect via SSH which is pretty cool!)
Feeling rusty, looking for recommendations
Tags: rusty, help, hosting, advice
Published: 2021-05-10 21:45:04

I've not used my web dev skills in a while, and I'm feeling very rusty. Lately, I've been focusing on a new position at [QuillBot](https://quillbot.com/), where I'm writing, creating content, and doing a host of diverse and sundry things. I love it, and using those AI-based tools has really upped my productivity on the content side. It's also got me very interested in machine learning and devrel, as well, but I haven't had any time for even small web dev projects.

My mom is launching her small business in GA soon, and I'm going to help her with her site--she doesn't need anything crazy. I know I can do it. But, since I'm rusty, I wanted to ask:

1) What resources you guys could recommend for me to brush up on general web dev basics? 

2) What are your favorite hosting platforms? 

This is my first post here, and I'm looking forward to diving back in :)
The VS code dark theme I've been waiting for
Published: 2021-05-10 21:44:49


![One for all — A VS Code theme 🚀](https://cdn-images-1.medium.com/max/2000/0*QRBOGYO-lO6JhQDC.png)

I was browsing through the Visual Studio Code marketplace, looking for a dark theme.

I’ve been through that conundrum before though I’ve always settled on One dark pro. Sure, it’s nice and pretty eye pleasing but i need something with more consistent colors.

## So I made a VS Code theme, well actually two.

These are the things i wanted from One dark pro:-

* Consistent colors.

* Getting rid of that very distracting orange color in the status bar when debugging.

* An option to a slightly more darker shade if i felt like it.

* Slightly darker but more lighter blues

* Minimal colors across the editor

I’ve switched lot of themes, A LOT. To the point where i was just installing the same themes again and again. That felt very unproductive :(

Introducing **[One for all theme](https://marketplace.visualstudio.com/items?itemName=100lvlmaster.one-for-all)** -

![theme logo](https://cdn-images-1.medium.com/max/2000/0*d_JyfUj7zOCTxDg6)

A VS code theme with :-

* Consistent colors

* Two themes :- Traditional One dark pro dark and a slightly darker theme

* Status bar matches the editor theme

* Minimal theme across the editor

**One for all**

![Code snippet — One for all](https://cdn-images-1.medium.com/max/2000/0*yK5byuqZz4jUitpj.png)

![Editor — One for all](https://cdn-images-1.medium.com/max/2880/0*ZyTv-C-XHonqReF3.png)

![Settings — One for all](https://cdn-images-1.medium.com/max/2880/0*4CXNx7aaVqxI6IJW.png)

![Markdown — One for all](https://cdn-images-1.medium.com/max/2880/0*wY9pIE3p9JgjG9Fq.png)

**One for all darker**

![Code snippet — One for all darker](https://cdn-images-1.medium.com/max/2000/0*qTC786oSywe1y5gs.png)

![Editor — One for all darker](https://cdn-images-1.medium.com/max/2880/0*ZUttDno7u07HMFAs.png)

![Settings — One for all darker](https://cdn-images-1.medium.com/max/2880/0*F1D39QOtpeamEK7v.png)

![Markdown — One for all darker](https://cdn-images-1.medium.com/max/2880/0*B2VidnXu9OmYSb9P.png)

And yes. One for all is a reference to mha.
![midoriya.gif](https://media.giphy.com/media/9Y1wF3wx1Dex8w9wxL/giphy.gif)
I initially made the theme to help my eyes, but if there’s someone like me out there. Thanks for reading. Please do check the theme out if you’re interested.

[**One for all - Visual Studio Marketplace**](https://marketplace.visualstudio.com/items?itemName=100lvlmaster.one-for-all)

Find me at:

[https://navinko.netlify.app/](https://navinko.netlify.app/)
Remap caps lock as ctrl in Lubuntu
Published: 2021-05-10 20:59:54

Do this for current session:

```
setxkbmap -layout us -option ctrl:nocaps
```

Make it permanent:
```
$ sudo vi /etc/default/keyboard
```

Change `XKBOPTIONS` to
```
XKBOPTIONS="ctrl:nocaps"
```

http://www.noah.org/wiki/CapsLock_Remap_Howto
🆔 Identity, Unlocked... Explained: Season 2, Ep 7
Tags: security, identity
Published: 2021-05-10 21:20:18

#### 🛡 Identity protocols for internet browsers with Sam Goto (Google Chrome) and George Fletcher (Verizon)

## <br>

## The Overview

<br>

In this episode of Identity, Unlocked, principal architect at Auth0 and podcast host Vittorio Bertocci speaks with Sam Goto, software engineer working on Google Chrome, and George Fletcher, Identity Standards architect at Verizon, on the ever-changing world of identity protocols for internet browsers.

Sam focuses on working with browsers to create better functionality in their foundation protocol by determining the good and bad uses of low-level primitives, such as third-party cookies, iFrames, and pop-ups. In particular, Sam highlights how such primitives are being used by trackers and ad services to track users, often without their knowledge or consent- and how that is prompting browser vendors to put new limits to prevent abuses. There is a precedent for this: Sam gives the example of how over time, web apps increasingly abused low-level primitives such as pop-ups- and how browsers eventually put restrictions on them to give a better user experience. Browser vendors are now attempting to do the same to prevent unwanted tracking; however, those interventions are disrupting legitimate scenarios too- identity protocols being one of the most important ones, and the very reason we are having this conversation on Identity, Unlocked. Sam then talks about how browsers are looking to fix these problems by building higher level primitives to replace the low-level ones, but that even these high-level primitives face challenges.

George explains the many problems the modifications to browsers can cause for Identity and OpenID Connect. George also goes into detail about the protocols being implemented between browsers, relying on parties and IdPs for what happens if an IdP goes down, as well as the RP classification and decentralized identity.

Vittorio, Sam, and George go in depth on the state of browser changes and identity protocol today and what’s in store for their futures.

[Read more...](https://auth0.com/blog/identity-unlocked-explained-season-2-ep-7/?utm_source=content_synd&utm_medium=sc&utm_campaign=identity_unlocked)
XSS Attacks Types on Web
Tags: security, webdev, cybersecurity
Published: 2021-05-10 21:03:19

Know how each Cross-Site Scripting Attack behaves is crucial to start to think about how vulnerabilities in our web apps allow malicious codes to be executed using the browser to take sensible data from users.

That's what this article is about. 

---

🔓 **Reflected XSS**

📌 This attack XSS use URL parameters or data submitted via POST in forms to inject malicious code on that server request that persists some data for later execution in the browser. Third-party Browser extensions could even be an access point to inject such a malicious code.

---

🔓 **Stored XSS**

📌 This attack XSS happens when malicious code is persisted by the attacker directly in the server-side of the web app and is executed by the user (victim) when she accesses the infected application.

---

🔓 **DOM XSS**

📌 This attack XSS happens when the application manipulates the DOM incorrectly, opening breaches to malicious scripts sent by URL parameters to inject malicious code.

--- 

🔓 **The question is... How to defend against attacks XSS?**

📌 There's no formula - A system security is always dependent on that system context, keep this in mind, but there are practices against well-known XSS attacks to stay updated about XSS attacks. 

👉 Start reading about [Content Security Policy](https://content-security-policy.com/), [Mozilla Observatory](https://observatory.mozilla.org/), [OWASP recommendations](https://owasp.org/www-community/xss-filter-evasion-cheatsheet), and [signing up my newsletter](https://www.getrevue.co/profile/obetomuniz). As a web security lover, I always talk about it.
Don't give up on your dream job
Tags: career, motivation
Published: 2021-05-10 20:51:17

## Let's get real – the job hunt is *not* easy.

Pursuing your dream job can be especially difficult if you don't have a college degree, no real-world experience, and you're trying to make a career switch while juggling learning and other daily life commitments.

The truth is... breaking into tech takes fierce determination and hard work. You likely won't get a job offer on the first, second... or even the third try... but does this mean you shouldn't pursue your dream job? Absolutely not!

> ## “You miss 100% of the shots you don’t take." 
– Wayne Gretzky

Set yourself up for the long game with all the tools, resources, and support you need. While there's no one-size-fits-all formula for success – there are some recommended practices to help you stand out in the hiring process.

📝 Keep a spreadsheet or project file of all the companies and roles currently hiring that you want to pursue
💼 Build an up-to-date LinkedIn profile + resume
✨ Display a portfolio of your projects online
💬 Network with folx in tech on social
🛠 Contribute to open-source projects on GitHub
💻 Practice for the Technical Interview
📚 Keep learning and getting better

Wherever you are in the process - know that if you keep pursuing your dream job, you will eventually land it. Don't give up. 💙

---

## ⬇️ Check out these resources

Start building your roadmap to success – here are some resources to help you along the way.

+ [How to get your first job, without a college degree (Part 1) by Ryan Carson](http://trhou.se/Job-in-Tech-Pt1)
+ [How to get your first job, without a college degree (Part 2) by Ryan Carson](http://trhou.se/Job-in-Tech-Pt2)
+ [How to Land Your Dream Job – Interview Series](https://teamtreehouse.com/library/how-to-land-your-dream-job)
+ [Hour with a Tech Recruiter – Interview Series](https://teamtreehouse.com/library/hour-with-a-tech-recruiter)
+ [Technical Interviewing – 21st Century Skills Course](https://teamtreehouse.com/library/technical-interviewing)