Skip to content

Instantly share code, notes, and snippets.

View atultherajput's full-sized avatar

Atul Krishna atultherajput

View GitHub Profile
@atultherajput
atultherajput / python_path_util.py
Created February 27, 2019 11:14
Get absolute path by giving relative path in python
#!/usr/bin/env python
import os
def current_dir():
abspath = os.path.abspath(__file__)
print('abspath: ' + abspath)
dirname = os.path.dirname(abspath)
print('dirname: ' + dirname)
@atultherajput
atultherajput / http-jwt-interceptor.ts
Created January 17, 2019 13:25
JWT refresh token in Angular 6 Interceptor with Ngrx
import { Injectable } from '@angular/core';
import {
HttpRequest,
HttpHandler,
HttpEvent,
HttpInterceptor
} from '@angular/common/http';
import { Observable, BehaviorSubject } from 'rxjs';
import { filter, take, switchMap } from 'rxjs/operators';
import { SigninModuleState } from '../../signin/store/models/signin.model';
@atultherajput
atultherajput / jwt-util.ts
Created January 17, 2019 13:19
JWT utility library for Angular 6
import { Injectable } from '@angular/core';
@Injectable()
export class JWTUtil {
constructor() { }
decodeToken(accessToken: string) {
let base64Url = accessToken.split('.')[1];
let base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/');
@atultherajput
atultherajput / upload.component.html
Last active November 26, 2018 10:28
File Upload with ngForm in angular 6
<form name="createForm" role="form" novalidate (ngSubmit)="upload()" #createForm="ngForm">
<div class="container">
<h3 class="mt-3">Upload File</h3>
<hr>
<div class="row">
<div class="col-md-4">
<input type="file" #fileUpload class="form-control" name="fileUpload" [(ngModel)]="inputFile"
(change)="handleFileInput(fileUpload.files)" placeholder="Select File">
</div>
</div>
@atultherajput
atultherajput / id.py
Created December 10, 2017 14:42
Convert Facebook username to Profile id.
import requests
from bs4 import BeautifulSoup
user = input('Enter user name: ')
url = 'https://www.facebook.com/'+ user
resp = requests.get(url)
soup = BeautifulSoup(resp.text, 'lxml')
mylink = soup.find_all('meta')
id = mylink[7].attrs['content'][13:]
print(id)

Keybase proof

I hereby claim:

  • I am atultherajput on github.
  • I am atultherajput (https://keybase.io/atultherajput) on keybase.
  • I have a public key whose fingerprint is CE9E 78E1 EB57 4DB2 887B 56DA E5E8 F848 7920 EEE4

To claim this, I am signing this object: