teleren/devto huggingface dataset:
Replacing a Dynamic Regex Match with the Same Number of Spaces
Tags: javascript
Published: 2019-07-05 19:57:55

---
title: Replacing a Dynamic Regex Match with the Same Number of Spaces
published: true
tags: 
canonical_url: https://www.raymondcamden.com/2019/07/05/replacing-a-dynamic-regex-match-with-the-same-number-of-spaces
cover_image: https://static.raymondcamden.com/images/banners/html.jpg
---

This post is 100% thanks to my friend [Peter Cooper](https://twitter.com/peterc). I couldn’t find any solutions online (or I may have Googled poorly) so I wanted to write this up in case other folks have the same problem. Imagine you have a string of HTML and you want to remove the tags. An easy solution would be something like this:

```
let s = `
<p>
This is Ray and I'm <i>very</i> cool. I sometimes am <b><i>super</i></b> cool!
</p>
<code>
this is bad code!
and lots and lots
</code>
<ul>
<li>more</li>
<li>more</li>
</ul>
`.trim();

// replace all html
s = s.replace(/<.*?>/g,'');
console.log(s);

```

This works perfectly well, but my situation was a bit different. I needed to pass the result of this to a tool that reported on misspellings. When it did, it would report on line numbers and columns. With my initial solution, the string no longer had text in the same spaces as it did before. It was close, but in a large file the differences became worse towards the end.

So my question how - given a regex that is dynamic in size (`<.*?>`), was there a way to replace with space characters of the same length?

When I searched for a solution, my focus was on a regex expression of some sort that could help. Turned out the answer was simple. As Peter pointed out, the [replace](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_function_as_a_parameter) function lets you specify a substring for the replacement or a function. This function is passed the matched string (along with other arguments) so you can easily check the length and return the right number of spaces. Here’s an example:

```
s = s.replace(/<.*?>/g,function(match) {
  return " ".repeat(match.length);
});

```

Peter’s solution was actually a bit more concise. I love arrow functions, but when teaching, I still like to show the “old” way first. I still remember when arrow function syntax confused the heck out of me:

```
s = s.replace(/<.*?>/g, _=> ' '.repeat(_.length) );

```

You can test this in the CodePen below.

{% codepen https://codepen.io/cfjedimaster/pen/mZGEVo %}


Anyway, that’s it, and I hope this helps! Also take this as my one millionth time reminding my readers that the [MDN Web Docs](https://developer.mozilla.org/en-US/) are the best damn resource on the Internet.

_Header photo by [Florian Olivo](https://unsplash.com/@rxspawn?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText) on Unsplash_
OverTheWire Bandit Level 0 walk-through
Tags: security, infosec, ctf, beginners
Published: 2019-07-04 22:46:09

Challenge page => https://overthewire.org/wargames/bandit/bandit0.html

This being the first challenge is the most simplest one.

Both the username and password are provided. Therefore all you have to do is execute the ssh command with the provided values

---

Hint 1: Required params are username, hostname and port. By default the port is 22, so you don't need to specify it usually. But in this case, a different port has been provided. Check the man page for ssh to see what is the option to specify port number.

---

Hint 2: Still stuck? Its ok! Here's the command and what the result of a successful login will look like.

![bandit0 login](https://thepracticaldev.s3.amazonaws.com/i/6hudvwglmxs5nbo73tt2.png)

And that's it. You've completed your first challenge! Onto greater things!
Raspberry Pi 4 and Kali
Published: 2023-08-21 21:15:21

---
title: Raspberry Pi 4 and Kali
published: true
date: 2019-07-05 00:00:00 UTC
tags: 
canonical_url: https://www.kali.org/blog/raspberry-pi-4-and-kali/
---

We love the Raspberry Pi, and judging by the response we got to a [late night tweet](https://twitter.com/kalilinux/status/1144895236025585665) we sent out last weekend a lot of you love the Pi too!

Because of that, when the [Pi 4 dropped](https://www.raspberrypi.org/blog/raspberry-pi-4-on-sale-now-from-35/) we wanted to get Kali supported on it right away.

## What’s new on the Raspberry Pi 4?

The Raspberry Pi 4 is actually a pretty amazing little machine. The Pi has always been known for its low cost and easy accessibility, but with the 4 we can actually throw real performance onto that list as well.

With the Raspberry Pi 4 we have a completely upgraded, re-engineered device that includes:

- A more powerful CPU
- Options for 1, 2, or 4 GB of RAM
- USB-C power supply
- USB 2 & USB 3
- Gigabit ethernet
- 2 micro HDMI ports

And now you can add to that list full Kali Linux support complete with on-board wifi monitor mode & frame injection support!

[![](https://www.kali.org/blog/raspberry-pi-4-and-kali/images/kali-pi4.png)](https://www.kali.org/blog/raspberry-pi-4-and-kali/images/kali-pi4.png)

To say we are excited about this is an understatement, and we hope many of you are just as excited!

## Try it out!

You can download Kali Linux for the Raspberry Pi 4 on the [Kali ARM download page](https://www.kali.org/get-kali/#kali-arm). Currently we only have 32Bit support for it, but expect 64Bit in the near future. The installation instructions are not any different than the Pi2, so feel free to [follow our docs](https://www.kali.org/docs/arm/raspberry-pi-2/) on getting it setup if you don’t know how.

Once you have it running feel free to let us know how its working for you [on our forums](https://forums.kali.org/forumdisplay.php?7-Kali-Linux-ARM-Architecture). Stay tuned for more Pi updates as we work with the 4 and find new and interesting things to do with it!
Arrow functions don’t have the local variable arguments as do other functions.
Tags: javascript, arguments, arrowfunctions
Published: 2019-07-04 23:47:43

---
title: Arrow functions don’t have the local variable arguments as do other functions.
published: true
description: 
tags: javascript, js, arguments, Arrow functions
---
Arrow functions don’t have the local variable `arguments`.
```
const arrowFunction = () => { return [...arguments]; }

arrowFunction(1, 2, 3) => ReferenceError: arguments is not defined
```

Normal functions have the local variable `arguments`.
```
const normalFunction = function () { return [...arguments]; }

normalFunction(1, 2, 3) => Array(3) [ 1, 2, 3 ]
```

You can still, however, get arguments in Arrow functions.
```
const arrowFunction = (...args) => { return args; }

arrowFunction(1, 2, 3) => Array(3) [ 1, 2, 3 ]
```
OverTheWire Bandit Level 0 Level 1 walk-through
Tags: security, infosec, ctf, beginners
Published: 2019-07-04 23:09:00

Challenge page => https://overthewire.org/wargames/bandit/bandit1.html

A piece of info to keep in mind to avoid any confusion.

When a Bandit Level is called Level X -> Level Y, it means you need to use the credentials for Level X aka banditX **which you already possess**, to acquire the password for Level Y aka the user banditY.

In our case, we have the credentials for bandit0, so we need to get the password for bandit1 using this.

Now that it's all cleared up, let's read the instructions.

>The password for the next level is stored in a file called readme located in the home directory. Use this password to log into bandit1 using SSH. Whenever you find a password for a level, use SSH (on port 2220) to log into that level and continue the game.

**PAY PARTICULAR ATTENTION TO THE BELOW SECTION**
>Commands you may need to solve this level
>ls, cd, cat, file, du, find


In many cases, when you are left scratching your heads over what to do next, the list of commands is where the designers leave a subtle clue. So never ignore it.

Hint 1: You need to login as bandit0 and then get the password stored in the file named "readme". Which command do you think is best to display the contents of the file?

---

Hint2: This is an easy challenge. Try googling it, or even better [ducking it!](https://duck.com)

---

Pretty sure you figured it out :). Even so, here's the solution

![bandit1](https://thepracticaldev.s3.amazonaws.com/i/lodvkitffmt1fmm4dpfb.png)
New "State of the Web" video: BigQuery!
Tags: bigquery, webdev
Published: 2019-07-04 23:08:15

---
title: New "State of the Web" video: BigQuery!
published: true
description: Video about BigQuery and how it powers web transparency datasets.
tags: bigquery, webdev
cover_image: https://thepracticaldev.s3.amazonaws.com/i/v4fc7a3ccv7a7l2ctg7g.jpg
---

When we pull stats about the state of the web, like the percent of websites adopting HTTPS or the median amount of image bytes per page, these figures come from web transparency datasets on BigQuery like the HTTP Archive and Chrome UX Report. In this video, I chat with Felipe Hoffa (BigQuery Developer Advocate) about the capabilities of BigQuery and how to get started with it.

{% youtube dmD9_mN94eM %}
Angular + Strapi
Tags: angular, strapi
Published: 2019-07-04 20:40:29

---
title: Angular + Strapi
published: true
description: Starter Angular + Strapi
tags: angular, strapi
---

Hi guys, I recently set up a starter for angular and strapi in a single repository, with a configuration to deploy Angular on Netlify and Strapi 
 on Heroku. The SGBD is PostgreSQL

Here the link ==> https://github.com/LouisAugry/angular-strapi-starter

Enjoy ✌️😉
Youtube Video: ASP.NET Core Web API (Rest API) with Entity Framework Core, SQL Server and Visual Studio Code
Tags: aspnet, aspnetcore, efcore, sqlserver
Published: 2019-07-04 19:13:57

---
title:  Youtube Video: ASP.NET Core Web API (Rest API) with Entity Framework Core, SQL Server and Visual Studio Code
published: true
description: How to create asp.net core rest(Web API) with EntityFramework Core, SQL Server and Visual studio code
tags: aspnet, aspnetcore, efcore,sqlserver
---

In today's work back end code(Server-side) code is limited to creating APIs as Front end framework like Angular, React and Vue is ruling the world. ASP.NET Core a new cross-platform technology from Microsoft and I love it. It's just awesome. 

There are tons of videos for creating Rest API but there was no video which can help you created same thing cross-platform. So I've created this video with Visual Studio Code and Technologies like ASP.NET Core, Entity Framework Core and SQL Server. Yes, SQL Server can also now runs on Linux on docker. 


## Technology used in this video:

Here are technologies which have been used:

- ASP.NET Core 2.2
- Entity Framework Core 2.2 with migrations. How to create a database from code.
- SQL Server as database. You can use any database with techniques and just need to change the provider. Yes, you can use MariaDB, MySQL, and PostgreSQL with same
- Visual Studio Code- This is an awesome editor. If you have not heard about you are missing something. Please learn and read about it.

## What you can expect from the video:

- ASP.NET Core Structure and How to create APIs with controllers
- How to setup Entity Framework Core with SQL Server. 
- How to create migration with Entity Framework core and create tables from your model entities.





 Hope you like this video. 

{% youtube HU-TZfGO-Do%}

You can find the complete source code of this video at - https://github.com/JalpeshVadgama/aspnetcoreefwebapi

If you like this video and wanted to see a similar kind of video then, please subscribe to my youtube channel at - http://bit.ly/codewithjv
Shall We Begin? >:-)
Tags: security, infosec, ctf, beginners
Published: 2019-07-04 18:43:32

I am going to be writing a series of posts detailing the methods used by me to go through the [Overthewire Bandit Wargames](https://overthewire.org/wargames/bandit/).

##Pre-requisites for Bandit Wargames

1. ###Being able to ssh into the Bandit machines

    If you have a Linux/MacOS machine, the default ssh client should suffice. 

     If you have a Windows machine, most people would recommend installing [PuTTy](https://putty.org/). But I wouldn't. Going through these CTFs will involve a lot of work on the Linux command line. Therefore I'd recommend installing either VirtualBox or VMWare, and then installing Ubuntu and getting familiar with it.

     There are plenty of tutorials on getting an Ubuntu VM up and running. Google it and try it out. Its worth it. Once you get a VM up and running, you'll be patting yourself on the back.

     After installing your VM, go through a Linux command line crash course. I guarantee that it will come in handy during the Wargames.


2. ###Linking to Wechall

    For me, the most fun part of the CTFs is to track my progress and know my "score". For this I use [Wechall](https://www.wechall.net/about_wechall)

    [Shameless Plug aka My Profile on Wechall](https://www.wechall.net/profile/kkaosninja) :D

    The steps to link Wechall are here => http://overthewire.org/information/wechall.html

    Wechall will come in handy, as they have links to a lot of other CTF sites as well, allowing you to show off your progress on all of them. 

3. ###Patience

    There will be a *LOT* of frustration involved, as it's a lot harder to get the flags on the later Bandit machines. But believe me when I say this, you will enjoy every bit of the challenge, and all the stuff you learned along the way.

    For each walk-through, I'm not going to post the solution straightaway. I will try to provide hints to encourage you to derive the solution on your own.

    This style is inspired by the similar walkthrough series written by [The Bresleveloper](https://bresleveloper.blogspot.com/2018/05/overthewire-bandit-walkthrough-just.html).

    No one is perfect, so yes sometimes after you are stuck, you may look at the solution. But only do this after you are confident that you have tried your best and are stuck.

    Remember => *The objective is to learn, not to compare yourself to others*


And that is it for the pre-requisites. Now. let us begin.
Is it possible to suffer from code withdrawal?
Published: 2019-07-04 17:58:40

I ask this because as I sit in another industrial mechanic theory class I'm zoning out thinking about all the programming I could be learning now.

I kind of feel weak and stressed that I'm not at a terminal right now. Especially after I'll be going straight to work after my classes and that means I'll be away longer.

The keyboard is calling and I'm not there, does anyone have advice for this type of experience?

Thanks in advance
Write Node server with ES6 Classes
Tags: discuss, node, express, javascript
Published: 2019-07-04 17:57:05

---
title: Write Node server with ES6 Classes
published: true
description: Such a node server is written with ECMAScript 2015 (ES6)
tags: discuss, node, express, javascript
---

I'm learning Node.js and all back-end stuff and I see there's one way to implement a server by import the module and declare the path and the app and so on.

I wrote a simple server using ES6 classes and it looks like this:

{% gist https://gist.github.com/Yuribenjamin/1732193007c44260fa0e43ac2f636c1c %}

When I log the response it seems typical to the regular server, check the repository below you can clone and run it.
I need answers about what is the advantages and the difference.

{% github https://github.com/Yuribenjamin/node-server-class %}
Miui 10 problem of camera2api fix
Tags: camera2api
Published: 2020-01-16 11:53:35

---
title: Miui 10 problem of camera2api fix
published: true
date: 2019-07-04 17:44:00 UTC
tags: camera2api
canonical_url: https://altechnep.blogspot.com/2019/07/miui-10-problem-of-camera2api-fix.html
---

Since after the upgrade of miui 9 into miui 10 I faced a problem to make persist.camera.HAL3.enabled=1 
it didn't work out this time as it used to in earlier roms, after researching numerious post and threads I found out this is either a error or it missed out feature for the camera2api function. 
Various post claim various methods bt nothing could work successfully as this one. If you know about magisk tool this would be a great module to do the work for you.
Especially the module I am posting here is for RED mi 4a (Rolex) go visit this [git repo](https://github.com/AzimsTech/Camera2API-MIUI10-Fix-Redmi4A/blob/master/README.md) and download the module and flash from twrp or you can do it from magisk manager app. There you go with successfull camera2api enabled.


p.s: This module works systemlessly so you ain't need to manually enable whatsoever. You can mail me if you need for other devices too I can do the search and check the authenticity of work so you can enjoy what you've been looking for. \_x\_ ![](http://feeds.feedburner.com/~r/blogspot/sTChm/~4/EibNaLkqvAs)
Twitter kicked me off
Tags: twitter, help, crap
Published: 2019-07-04 17:22:50

---
title: Twitter kicked me off
published: true
description: Under 13 when I made it? Now 22.
tags: #twitter #help #crap
---
Apparently I was underage when I made my account but I am 22 now and can't remember when my account was made. It has literally been almost 10 years since I turned 13. I want to fight for my account back. Is anyone willing to help me out with advice or action? My account was @PandaKay1996 

All I am asking for is advice or to reach out for me. I know I have not earned much in this wonderful place, I just don't want to be cut off because of something 10 years ago and on a social media site of all things. I didn't break the law.
Should You Always Engage Yourself?
Tags: productivity
Published: 2019-07-04 16:28:52

I guess "Deep Work" is applicable to a lot of domains in our lives but I find out even more important in programming. 

I'm currently beginning in this field and like every "self-taught" person, I had to find some stuff to learn. Well. I made some research, typed that cliche phrase: "How to learn code?" and press ENTER...

I got a rush of excitement dude! So many things! I thought I would easily become a genius. But the reality isn't that.

I quickly understood that I can't learn all the stuff out there. So I started to search the best "ressources" (but always free ressources, which seems a bit contrary to the previous goal but I'm a teenager, I don't have money to invest like I want).

After some days, I didn't really focus myself on any sort of ressource because I was still looking for the best "ressources". 

That's a real issue for me. I tend to always hesitating between: "Should I deep dive in this?" or "No dude, that's not worse it".

I've read [The Attention Diet](https://markmanson.net/attention-diet) and I love that idea of consuming long-term content. Most of the time, we need to hardly focus on something for a certain amount of time. That's probably essential to create value and skills. 

But I struggle with the fact that at some moments, you just need specific information in order to reach a goal. You don't want to understand a topic from A to Z and engage time and energy for just one information.

That's why I ended up on this thoughts: 
→ Either the information you're looking for answer to a precise question (e.g "What's the git command to create a branch?" : git branch <nameOfTheBranch>
→ Or your question need a broad set of information to answer (e.g "How to do a website?" : erghhhhh...)

In fact you would say : "Sure. But you can decompose that question in smaller questions."
And I would respond : "Ok. But how can you find all the specific enough questions that, regrouped, permit to answer the initial question?"

When you don't know something, you don't know it. That's all.

So, I guess, we need to make this difference.

##Conclusion:  

- When the question you want to answer is specific enough, type in Google and get your answer in order to continue pursuing your goal.

- When the question is large, pick 5 minutes max (set a clock if needed) to choose the "long-form content" on your topic that seems the best for you and then, deep dive in it without distractions.



That's it for this article. I hope my thoughts will "resonate" with yours and please, give me a feedback. I'm really exciting about this topic so feel free to give your opinions.

(I hope also that my english was not too bad. If some phrases sound horrible, I'm  deeply sorry and I would really enjoy getting some tips ;) ) 

Thanks for your time and attention.
VB Script To Keep Unlock Your Windows Machine
Tags: vbscript
Published: 2019-07-04 15:58:17

---
title: VB Script To Keep Unlock Your Windows Machine
published: true
description: VB Script To Keep Unlock Your Windows Machine
tags: #vbscript
---

Source : <a href="https://www.skptricks.com/2019/07/vb-script-to-keep-unlock-your-windows-machine.html" >VB Script To Keep Unlock Your Windows Machine </a>

This tutorial explains how to keep your windows machine unlock using vbscript .This is common problem that we encounter that we have automate our suite and run the same at any given time.

<img src="https://1.bp.blogspot.com/-UCxJiy9tXD0/XR17S42TI0I/AAAAAAAADDU/UXzP3N06-0IBjVHFTOZwuh6RvkbsaquHACLcBGAs/s400/vb-script-to-keep-unlock-your-windows-machine.jpg" />


<a href="https://www.skptricks.com/2019/07/vb-script-to-keep-unlock-your-windows-machine.html" > Click here to read more... </a>
Are there hardware components whose specs say they’re compatible with Linux?
Tags: linux, hardware
Published: 2019-07-04 15:53:40

I want to build my personal Linux computer from scratch. I love custom configurations and admire people who spend time to select each component carefully: CPU, SSD, case, RAM, GPU. I like Linux because I used Ubuntu at University to write C source code and Ubuntu provides the GCC compiler out of the box. It was so easy to write code, and this led me to think the Linux OSs family is designed for developers first of all. What slows down me is the fact that computer hardware doesn’t provide a full Linux compatibility. So far I was not able to find a component whose specs precisely said: “It’s compatible with Linux”. They only said: “Compatibility with Linux is not guaranteed”. I don’t like it. Of course, the web is full of people who write reviews about their hardware components’ compatibility with Linux, and I often read something like: “I had no problems, Linux seems to be fully supported”. “Seems”. Unfortunately, I am a perfectionist and “seems” is a verb I don’t like, because we can’t be sure this is true and I care about optimal performance. So I’m here to ask you: have you ever found a component whose specs say it’s compatible with Linux? If so, can you write the link of these specs on comments? In general, what do you think about this issue?
Two CSS properties Walk Into a Bar...
Tags: css, jokes
Published: 2019-07-04 15:52:33

---
title: Two CSS properties Walk Into a Bar...
published: true
description: When two CSS variable Walk Into a Bar what will happen?
tags: css, jokes
---

Two CSS properties walk into a bar.

A barstool in a completely different bar falls over.

{% twitter 493790680397803521 %}
How do you argue about Internet Explorer?
Tags: discuss, react
Published: 2019-07-04 15:26:21

...to your customers?

We know, that some styles and functionality doesn't work on Internet Explorer. And yes, there are some workarounds and polyfills, but not for all versions. 😣

How do you argue about Internet Explorer to customers, if your Webapp, e.g. a React app, is not working with it? 🤔