teleren/devto huggingface dataset:
Git Black Arts
Published: 2022-05-16 15:20:58

---
title: Git Black Arts
published: true
description: 
tags: 
//cover_image: https://direct_url_to_image.jpg
canonical_url: 'https://kevwe.com/blog/git-black-arts'
---
Git Black Arts


I hear quite often complaints like "Git is too complicated".

If you're thinking about saving the daily and push to some central repo, it could just be the case.


But maybe not.



Not if you've been doing some serious work with Subversion. Better if you used it with a language like Java, where a shallow dir is not all you need, and you've seen those nightmarish nested directories, all containing an hidden .svn directory with ... important data in it.


Or maybe even if you've been working with CVS, nothing more than a light abstraction on top pf RCS.


Those also were the good tools, the open ones. I don't even want to get started with legacy, proprietary monsters from the past where it was possible that the hashing function would run into conflicts when two different files produced the same hash.



I recall a project @somecompany that was developed for @somecustomer. @somecustomer had it's own CVS server, where they would expect the deliveries. @somecompany had a stong workflow, and strong developers bound to working with Subversion.

The efficient way to work with that particular customer ended up being adding .csv hidden directories to the Subversion server, just like regular source codes... 


https://kevwe.com/blog/git-black-arts
Javascript Closures
Tags: javascript, programming, webdev, frontend
Published: 2022-05-16 15:19:10

#javascript : JavaScript Interview Question for beginners !!!
What is Closure in JavaScript?

To understand closure we need to first understand scope of a function?
What is scope?
What is scope of a function?
or
we can think of scope from other side as well, Is this variable inside scope of this function?

scope -> Where I can access the specific variable in our code?

let outerVariable = 'outer'
function testScope() {
let innerVariable = 'inner';
function displayVariable() {
console.log(outerVariable);
console.log(innerVariable);
}
displayVariable();
}
testScope();

output of above code is:
outer
inner

It's very strange, innerVariable is not inside displayVariable function scope, but still I can access that variable? -> The answer is that in javascript function can access the variables defined in its parent function.

But its again a bit strange outerVariable is defined in global scope, why displayVariable function can have access to global scope? -> The answer is scope chaining. If a function can have access to its parent function scope -> than Its parent has also access to scope of its parent-> and this chain continues until the global scope.

I hope it is bit clear about scope and scope chaining.

Now I will use a term very often used to define closure -> lexical environment:

lexical environment = local memory + lexical environment of its parent

So to understand it we need to see how call stack is dealing with functions -> when execution context of function is created, a reference to its parent function scope is also created -> So as we dive deep into nested functions, this reference is created for each layer


If you understood above discussion
-> I hope its bit clear about local scope and lexical environment,
Now I will move towards closure:

Closure -> A function bind together with its lexical scope is called as closure.

In above example -> displayVariable() function forms a closure

On top of this there are many things we can do using this concept-> we can return a displayVariable() function and use it anywhere else in our code. -> you see beauty of javascript I can have access to innerVariable in above code from anywhere else in my code.

This is just very basic level explanation to help you understand meaning of closures. To understand it for sure first you need to understand following terms:
* scope
* lexical scope
* execution context
* call stack

If you want read more about the topic I will link mdn docs reference in comment section.
My First Impression Trying Python on Browser
Tags: python, webdev, programming, html
Published: 2022-05-16 15:10:15

JavaScript is the de-facto programming language of the browser. We can't write any other programming language inside an HTML. 

But a recent Python package is about to change it.

Now you can write Python scripts inside the HTML. You can:

- use it to manipulate DOM like JS is doing;
- fetch data from external APIs using urllib or requests;
- use your favorite Python packages such as Pandas, Scikit-learn, etc, and;
- build ML models

all inside the browser. 

But the package isn't perfect for production yet. 

In this post, I discuss with examples some of the merits and drawbacks of using Python on a browser. 

[My First Impression Trying Python on Browser](https://towardsdatascience.com/pyscript-tutorial-a8fba77abd1b?sk=a258ae604dcfe2ad414d587abc5fa2b0)
Python 3.11 Is Indeed Faster Than 3.10
Tags: python, programming, algorithms, datascience
Published: 2022-05-16 14:47:11

Python 3.11 is up to 10–60% faster than Python 3.10.

This was the claim on Python 3.11's official changelog page. You can access it from this link.

After reading this, I wanted to try and see if this could be true. 

If so, it's incredible! Python could be so much power if it's faster. 

My tests conclude that Python 3.11 is much faster than 3.10.

Read more here:**[Python 3.11 Is Indeed Faster Than 3.10](https://towardsdatascience.com/python-3-11-is-indeed-faster-than-3-10-1247531e771b?sk=65b4f736a5deb2b7b2eb57b2904dd899)**
Comparing side-by-side with bubble sort and recurrence functions confirms it
SleekwareDB - The Idea
Tags: webdev, opensource, programming, php
Published: 2022-05-16 14:36:34

The idea of building [SleekwareDB](https://github.com/SleekwareDB/sleekwaredb) was motivated by limited resources and environment. When a beginner / professional developer needs to improvise quickly with such a limited situation, then [SleekwareDB](https://github.com/SleekwareDB/sleekwaredb) is here as an easy and inexpensive alternative to data storage.

Maybe when you start to contribute and read the flow of this project, you will feel DeJavu with other similar projects.

This project will feel light because it was rebuilt with limited resources and environment. Compatible with Shared Hosts and VPS servers, because it is built to process data from JSON files as a database collection.

Referring to the fundamentals on which the [SleekwareDB](https://github.com/SleekwareDB/sleekwaredb) project was built:

> [SleekDB](https://sleekdb.github.io/) is a simple flat file like NoSQL database implemented in PHP without any third party dependencies storing data in plain JSON files.

> It's not comparable to databases like Sqlite, MySQL, PostgreSQL and MariaDB because they are relational databases! [SleekDB](https://sleekdb.github.io/) is a NoSQL database and therefore more comparable to e.g. MongoDB.

> It's not designed to handle heavy load IO operations, it's designed to have a simple solution where all we need to manage a database is a few gigabytes of data. You can think of it as a database for low to medium operating load.

> Source: [SleekDB](https://sleekdb.github.io/)

As a promising overview of SleekDB

**⚡ Lightweight & Fast**

Stores data in plain-text utilizing JSON format, no binary conversion needed to store or fetch the data. Default query cache layer.

**🔆 Schema free data storage**

SleekDB does not require any schema, so you can insert any types of data you want.

**🔍 Query on nested properties**

As it supports schema free data, so you can filter and use conditions on nested properties of the JSON documents!

If you write this where clause:

```php
where( 'post.author.role', '=', 'admin' )
```

SleekDB will look for data at:

```json
{
  "post": {
    "author": {
      "role": "admin"
    }
  }
}
```

**✨ Dependency free, only needs PHP to run**

Supports PHP 7+. Requires no third-party plugins or software.

**🚀 Default caching layer**

SleekDB will serve data from cache by default and regenerate cache automatically! Query results will be cached and later reused from a single file instead of traversing all the available files.

And many more...

By utilizing the impressive SleekDB library, I tried to explore to make it a service that can be installed on the server and manage `json` data using the Panel on the Website with ease. Then the data on the server can be accessed using the REST API.
I created my portfolio
Tags: portfolio, showdev, career, productivity
Published: 2022-05-16 14:31:56

### Apologies 
Sorry for posting here after a long time, as I was busy making my some other projects including my blog I will put the links at the end.

In the past few weeks I was working on my portfolio and after 2 weeks I have done my project and here is the link to it :-
[Protfolio](https://spandyportfolio.vercel.app) 

**Built using :-**
**HTML**
**TAILWIND Css**

My portfolio also changes its theme according to the system theme

####Links
Blog :- techwithspandy.tk
Portfolio :- spandyportfolio.vercel.app
WeatherlyApp :- *Coming Soon* .

I am looking forward for your suggestions or queries about my portfolio or any other projects in the comments section.

That's it for today, meet you in the next post. Till then stay safe and do take very good care of yourself .
Tappable Query Scopes - Laravel ( tap() )
Tags: laravel, php, webdev, tutorial
Published: 2022-05-16 14:17:20

Today we will learn about using a new function, which is tap() with Query Scopes, and the most important features that it gives us and benefit from it in allow you to create class based scopes that are invokable, and are called using the tap() method in Laravel 

```php
class MatchingEmail
{
    public function __construct(
        protected readonly string $email,
    ) {}
 
    public function __invoke(Builder $query): void
    {
        $query->where('email', $this->email);
    }
}
 
User::query()->tap(new MatchingEmail('taylor@laravel.com'))->get();
```

So what we have is an invokable class that acts like a callable that we can simply call to extend the query we are building. So in effect the above example could use the below

```php
User::query()->tap(function (Builder $query) {
    $query->where('email', 'taylor@laravel.com');
})->get();
```

we want to call multiple scopes on a query

```php
User::query()
    ->tap(new MatchingEmail('taylor@laravel.com'))
    ->tap(new ActiveUser())
    ->get();

User::query()->filter(
    new MatchingEmail('taylor@laravel.com'),
    new ActiveUser()
)->get();
```

I hope you will visit the source https://www.juststeveking.uk/tappable-query-scopes-in-laravel/ to go deeper and benefit from this article in your future projects.
FizzBuzz program in javascript
Tags: javascript, dsa, algorithms, webdev
Published: 2022-05-16 14:13:16

_In javascript interviews, the most frequently asked question is "FizzBuzz." The goal of asking this question is to see how you approach solving the problem rather than the solution itself._

> The following is an example of a question. Print the numbers 1 to 100 that meet the following conditions:
> - Print "Fizz" if a number is divisible by 3.
> - Print "Buzz" if a number is divisible by 5.
> - Print "FizzBuzz" if the number is divisible by both 3 and 5.
> - else print the number itself.

The solution is straightforward, but the approach is critical.

**A newcomer would do it like this:**

```
function fizzBuzz(){
   for(let i = 1; i <= 100; i++){
     if(i % 3 === 0 && i % 5 === 0){
        console.log('FizzBuzz');
     }else if(i % 3 === 0){
        console.log('Fizz');
     }else if(i % 5 === 0){
        console.log('Buzz');
     }else{
        console.log(i);
     }
   }
}
```

**This is how people with some experience would do it:**

```
 function fizzBuzz(){
   for(let i = 1; i <= 100; i++){
// instead of checking if divisible by both 3 and 5 check with 15.
     if(i % 15 === 0){ 
        console.log('FizzBuzz');
     }else if(i % 3 === 0){
        console.log('Fizz');
     }else if(i % 5 === 0){
        console.log('Buzz');
     }else{
        console.log(i);
     }
   }
}

fizzBuzz()
```

**However, a pro developer🚀 would do it as follows:**

```
function fizzBuzz() {
 for(let i = 1; i <= 100; i++){
  console.log(((i%3  === 0 ?  "fizz": '') + (i% 5 === 0 ? "buzz" : ''))|| i)
 }
}
fizzBuzz()
```

I hope this helps you guys solve it like a pro. Any additional pro solutions are welcome.

Please ❤️ it and share it your with friends or colleagues. Spread the knowledge.

---

Thats all for now. Keep learning and have faith in Javascript❤️
Git branching strategies
Tags: git, github, beginners, codenewbie
Published: 2022-05-16 14:08:40

As an engineer when I was making small project in colleges, I used Git as version-control system. Back then, as a rookie, the way I use to implement this was very crude and the way most of newbies start.

I created the repository on GitHub and started committing my code to `master` branch without any hesitation. But, eventually when I started collaborating with others on projects, I started realising that single branch approach was creating more friction. Many different approaches were tried after this. 

I started creating branches, with developer's names which, merged in `master` branch. Eventually this wore out when I developed my first real-life website for my college robotics club - [_The Robotics Forum_](http://vitpunerobotics.com/). 
One time I had to revert back changes which didn't workout well with this strategy.

Then I adapted a `staging` branch before merging in `master`, but the problem here with now the branches with developer names became difficult to track. Also, it there was no definite purpose of the branch from code perspective i.e. it only had advantages to developers and not the actual code.

The time I started my first job at _HSBC Technology India_ as a '_Trainee Software Engineer_', that is when I saw the complexity. Different environments and parallel development of features were the way.

This is when I read about [Git Flow](https://nvie.com/posts/a-successful-git-branching-model/), a popular branching strategy.

--- 

This workflow dictates that there should be **two permanent branches** in you repository namely `master`, `develop`.
Both these branches should be parallel to each other.

In addition to this there would be three types of supporting branches `hotfix-*`, `release-*` and `feature-*`.

The `feature-*` branches are created from `develop` branch and are merged back to `develop`.

The `release-*` branches are created from `develop` branch and are merged into `develop` and `master`.

The `hotfix-*` branches are created from `master` branch and are merged into `develop` and `master`.

---

There is another famous strategy called `trunk-based development`. You can read more here [https://trunkbaseddevelopment.com/](https://trunkbaseddevelopment.com/)

In the upcoming blogs I would be writing about which merging strategies should be used, which branches should be deployed in different environments, how we can implement an automatic sem-ver maintainer.
Javascript:5 common error messages
Tags: javascript, debugging, webdev
Published: 2022-05-16 14:06:09

#javascript : 5 common error messages

Debugging is a skill to learn. It takes time, it takes practice. It starts by reading error/warning messages.

In JS following 2 messages are not same:
1) undefined
2) uncaught ReferenceError: x is not defined

❌undefined -> During memory creation phase, memory is allocated to each variable. If variable is not initialized, undefined is assigned to that variable.

❌ReferenceError -> uncaught ReferenceError: x is not defined -> It means x is not defined, When JS is in code execution phase and it looks for x in memory but x is not found so it throws this error.

❌TypeError -> Uncaught TypeError: Assignment to constant variable.
const name = 'JavaScript'
name = 'typescript'
Above code throws following error: Uncaught TypeError: Assignment to constant variable.

❌TypeError -> Uncaught TypeError: (intermediate value).disply is not a function

class Main {
 display() {
  console.log("Hello World");
 }
}

new Main().disply(); // it is not a method of Main class
If we are trying to call a method that is not present or callable, then JS will throw a TypeError.

❌SyntaxError -> Uncaught SyntaxError: Missing initializer in const declaration

const javascript
Above code throws following error: Uncaught SyntaxError: Missing initializer in const declaration
How to resize a osd in Ceph
Published: 2022-05-16 13:58:44

---
title: How to resize a osd in Ceph
published: true
description: After a critical failure, we look into resizing an OSD in our ceph environment. Unfortunately, the drive is entire, so resize of the OSD was the only option to start the service.
tags:
cover_image: https://i.ytimg.com/vi/e0J0gft2jEY/maxresdefault.jpg
---

{% youtube e0J0gft2jEY %}

After a critical failure, we look into resizing an OSD in our ceph environment. Unfortunately, the drive is entire, so resize of the OSD was the only option to start the service.
Enable Password Authentication in AWS EC2 Instance
Tags: aws, ec2, ssh, password
Published: 2022-05-16 13:56:26

Password authentication is disabled by default in aws ec2 instance. The only way to access your server is by using ssh with  -i flag and followed by private key attached to the server.

However, there are scenarios when you may need to access the server with just username and password. Take note that this method of accessing your server is not encouraged, as it could open your server to attacks. 

### How to Enable Password Authentication in EC2

First, you have to ssh into your server with your private key to set password for the user and also make some changes to the sshd_config file.

The steps to enable password authentication are highlighted below:

- Login to server

```
ssh -i privatekey username@host_ip
```

- Setup a password for the user using the passwd command

```
sudo passwd username
```

- Open  and modify the `sshd_config` file.

```
sudo vim /etc/ssh/sshd_config
```

```bash
sudo nano /etc/ssh/sshd_config
```

If you prefer to use nano as editor

Changes the PasswordAuthentication line from ‘no’ to ‘yes’

```
PasswordAuthentication yes
```

- Enable root login, Change value from “**prohibit-password**” to “**yes”** (Optional)

```bash
PermitRootLogin yes
```

- Restart the “**sshd**” service using the following command.

```
sudo service sshd restart

or 
sudo systemctl restart ssh
```

That’s all you have to do. Now you can login to the ec2 server using the password you set for the user, without the private key.

When you type the command below, you will be prompted to enter your password!
Music Monday — What are you listening to? (May 16)
Tags: watercooler, discuss, music
Published: 2022-05-16 13:53:25

_cover image credits: [sElf - Runaway (music video)](https://www.youtube.com/watch?v=IwAIwRrs6xs)_

In this weekly series, folks can chime in and drop links to whatever it is they're listening to + browse others suggestions.

If you like talking about music, consider following the org [#music discussions](https://dev.to/music-discussions) for more conversations about music!

{% embed https://dev.to/music-discussions %}

Also noteworthy, my friend @duxtech has a Spanish speaking version of this series [here](https://dev.to/duxtech/series/17890) in case you'd like to chime in there as well. 🙌

***

So, what have y'all been listening to today? _Note: you can embed a link to your song on most platforms using the following syntax `{% embed https://... %}`._

I look forward to listening to y'all's suggestions! 👂 🎶
Pre-rendered Angular Site Flickers
Tags: angular, typescript, javascript
Published: 2022-05-16 13:48:56

I have an Angular 13 website that is pre-rendered. However, when users visit my site the page flickers. Can anyone assist to diagnose the cause and remedy of this problem. Perhaps others using Angular pre-rendering have experienced the same issue.

site: https://rollthecloud.com
repo: https://github.com/rollthecloudinc/RolltheCloud
Coding Challenges
Tags: challenges, coding, programming
Published: 2022-05-16 13:37:42

## Give me an end goal, a reason to do them...

Coding Challenges... Some live by them, some have never heard of them, others could not be bothered. I have a few issues with them...
 
## Introduction 
What is a coding challenge? Well depending on the context, that answer will differ. The ones I'm talking about are the ones found on sites where they set you a task - say: find the substring in a string. You have to solve it, when you do,  you move on to the next one.

Because of my past experiences, I see no value in doing these kinds of challenges, particularly in this way. In my opinion, questions should have a set goal in mind - a unified one. This challenge after challenge for the sake of challenge makes no sense to me.

You spend a lot of time focused on one singular task, solve and most likely never use that solution you have solved.

> **Show A Real World Instance Where I Would Use It Is All I'm Saying**

---

## Why I Don't Like This?
There is no working towards anything. I have solved it yes, then what?

In the years that I have been learning languages (spoken), everything builds up to something.  You learn a concept, you build on that concept. In the end, you can speak the language.

I like sites like [freecodecamp](https://www.freecodecamp.org/) in this regard. They have challenges, yes. But those challenges compound, they build towards something. Making use of the knowledge asked about in those *challenges* to create something.

## Conclusion
Basically, I want to be working to something, something tangible. To be able to say, "I did *a*, *b*, *c* and that helped me make **d**". I want a reason to do these challenges. Not to do the challenges for the sake of it.

I believe in visible results to anything you're doing, not just the knowledge that I can do things.

### How Do You Feel About Coding Challenges?

---
###  Thank you for reading, let's connect!
Thank you for visiting this little corner of mine. Let's connect on [**Twitter**](https://twitter.
Configuring the Client for Testing with Pytest and Django REST
Tags: django, python, testing
Published: 2022-05-16 13:21:41

Django REST framework provides a class called `APIClient` based on the client class from the Django Testing but is very useful when making requests to the API when running tests. 

If you have also worked with `pytest`, you'll find that writing tests are quite fun and very fast. 

How do you use now use the testing client from DRF in your pytest tests when testing the API endpoints? 

You need to add this piece of code to the `conftest.py` file.

```python
import pytest
from rest_framework.test import APIClient

@pytest.fixture
def client():
    return APIClient()
```

And you can call the client in your tests like this. I am using a class structure to run tests.

```python
class TestUserViewSet:
    
    endpoint = '/api/user/'
    
    def test_list(self, client, user):
        client.force_authenticate(user=user)
        response = client.get(self.endpoint)
```
*Article posted using [bloggu.io](https://bloggu.io). Try it for free.*
Most fast function to extract numbers from string!
Tags: javascript, webdev, beginners, tutorial
Published: 2022-05-16 13:06:28

More one tutorial FAST AND FURIOUS

I don't know about you, but I have come across many times in many projects needing a function to extract numbers from some string.

And what always happens? Running to stackoverflow, but you don't need more make this.

Just save this post, and you never more need search about this function.

And the code is it:



![extract numbers function](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ddgt1osvgkljd3f8ridp.png)


explaining the code:

1. In the first we create a function to extract numbers that received a string with a parameter (I make a direct type in the function with if using typescript)

2. We making a if ternary, and where have a text, this validation with regex will replace anywhere character that not be a number for a void space.

3. Returning a result from ternary with just numbers.


.
.
.
.
.
From post in PT-BR
Instagram: @imatheus.max
Post: https://www.instagram.com/p/Cdnj7pMuFCX/