How to delete remote branches in Git

 https://www.educative.io/edpresso/how-to-delete-remote-branches-in-git


While working with Git, it is possible that you come across a situation where you want to delete a remote branch. But before jumping into the intricacies of deleting a remote branch, let’s revisit how you would go about deleting a branch in the local repository with Git.

Deleting local branches

  1. First, we print out all the branches (local as well as remote), using the git branch command with -a (all) flag.
  2. To delete the local branch, just run the git branch command again, this time with the -d (delete) flag, followed by the name of the branch you want to delete (test branch in this case).

Note: Comments are the output produced as a result of running these git commands

Note: You can also use the -D flag which is synonymous with --delete --force instead of -d. This will delete the branch regardless of its merge status.

Deleting remote branches

To delete a remote branch, you can’t use the git branch command. Instead, use the git push command with --delete flag, followed by the name of the branch you want to delete. You also need to specify the remote name (origin in this case) after git push.

How to put scroll bar only for modal-body?

 https://stackoverflow.com/questions/25874001/how-to-put-scroll-bar-only-for-modal-body

If you're only supporting IE 9 or higher, you can use this CSS that will smoothly scale to the size of the window. You may need to tweak the "200px" though, depending on the height of your header or footer.

.modal-body{
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

Left & right align modal footer buttons in Bootstrap 4

 https://stackoverflow.com/questions/43042262/left-right-align-modal-footer-buttons-in-bootstrap-4


Now that the modal-footer is "display:flex" in Bootstrap 4, it would be easiest to use the auto-margins. Use mr-auto on the left button.

<div class="modal-footer">
     <button type="button" class="btn btn-primary mr-auto">Save changes</button>
     <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>

Demo

Also see: Left align and right align within div in Bootstrap


Follow-up to comment "What if I need the button on the right to occupy all the space left?" - Use the btn-block class:

<div class="modal-footer">
     <button type="button" class="btn btn-primary text-nowrap">Save changes</button>
     <button type="button" class="btn btn-secondary btn-block ml-1" data-dismiss="modal">Close</button>
</div>

How to access i18n-express dictionary in router? - node.js

 https://html.developreference.com/article/12980051/How+to+access+i18n-express+dictionary+in+router%3F

The req.i18n_texts object has all the values you need.Checkout the source if you want to know more.

app.get('/getLocalizedText', function(req, res, next) {
// to get the value of HELLO_MESSAGE
res.send(req.i18n_texts.HELLO_MESSAGE);
});

label for name or id

 https://www.w3.org/TR/WCAG20-TECHS/H44.html#:~:text=A%20label%20is%20attached%20to,unique%20in%20the%20Web%20page.

label is attached to a specific form control through the use of the for attribute. The value of the for attribute must be the same as the value of the id attribute of the form control. The id attribute may have the same value as the name attribute, but both must be provided, and the id must be unique in the Web page.

multiple URLs to the same route

 https://stackoverflow.com/questions/47338471/express-routing-multiple-urls-to-the-same-route?rq=1


Instead of using an anonymous function as the route's controller, you can give it a name and pass the name to router.get. You can then have several router.gets that points to the same function.

function slugController(req, res, next) {

  if (!req.params.slug) {
    req.params.slug = 'home'
  }

  getData(slug, function(err, data){

    res.render('index', data)

  });

});

router.get("/page-slug-name", slugController);
router.get("/page-slug-name/amp", slugController);
router.get("/", slugController);
router.get("/amp", slugController);

This works best if there only are a couple of routes.

If you have a ton of routes you have to use the regex stuff that's mentioned in the manual. I don't see any pattern in your URLs though, so it's a bit hard to come up with a good solution using regex.

Angular Intercept Check refresh token

 https://medium.com/angular-in-depth/top-10-ways-to-use-interceptors-in-angular-db450f8a62d6


import { Injectable } from "@angular/core";

import {
HttpEvent, HttpInterceptor, HttpHandler,
HttpRequest, HttpErrorResponse
} from "@angular/common/http";
import { throwError, Observable, BehaviorSubject, of } from "rxjs";
import { catchError, filter, take, switchMap } from "rxjs/operators";
@Injectable()
export class AuthInterceptor implements HttpInterceptor {
private AUTH_HEADER = "Authorization";
private token = "secrettoken";
private refreshTokenInProgress = false;
private refreshTokenSubject: BehaviorSubject<any> = new BehaviorSubject<any>(null);
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if (!req.headers.has('Content-Type')) {
req = req.clone({
headers: req.headers.set('Content-Type', 'application/json')
});
}
req = this.addAuthenticationToken(req);
return next.handle(req).pipe(
catchError((error: HttpErrorResponse) => {
if (error && error.status === 401) {
// 401 errors are most likely going to be because we have an expired token that we need to refresh.
if (this.refreshTokenInProgress) {
// If refreshTokenInProgress is true, we will wait until refreshTokenSubject has a non-null value
// which means the new token is ready and we can retry the request again
return this.refreshTokenSubject.pipe(
filter(result => result !== null),
take(1),
switchMap(() => next.handle(this.addAuthenticationToken(req)))
);
} else {
this.refreshTokenInProgress = true;
// Set the refreshTokenSubject to null so that subsequent API calls will wait until the new token has been retrieved
this.refreshTokenSubject.next(null);
return this.refreshAccessToken().pipe(
switchMap((success: boolean) => {
this.refreshTokenSubject.next(success);
return next.handle(this.addAuthenticationToken(req));
}),
// When the call to refreshToken completes we reset the refreshTokenInProgress to false
// for the next time the token needs to be refreshed
finalize(() => this.refreshTokenInProgress = false)
);
}
} else {
return throwError(error);
}
})
);
}
private refreshAccessToken(): Observable<any> {
return of("secret token");
}
private addAuthenticationToken(request: HttpRequest<any>): HttpRequest<any> {
// If we do not have a token yet then we should not set the header.
// Here we could first retrieve the token from where we store it.
if (!this.token) {
return request;
}
// If you are calling an outside domain then do not add the token.
if (!request.url.match(/www.mydomain.com\//)) {
return request;
}
return request.clone({
headers: request.headers.set(this.AUTH_HEADER, "Bearer " + this.token)
});
}
}

StaticImage

  import React , { useEffect , useRef } from "react" import { StaticImage } from "gatsby-plugin-image" impor...