This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const puppeteer = require('puppeteer'); | |
(async() => { | |
const browser = await puppeteer.launch(); | |
const page = await browser.newPage(); | |
await page.setRequestInterception(true); | |
page.on('request', request => { | |
if (request.resourceType() === 'image') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// async download | |
const axios = require("axios"), | |
fs = require("fs"), | |
path = require("path"); | |
const SUB_FOLDER = ""; | |
const IMG_NAME = "img.jpg"; | |
/** | |
* this will dl.image |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
// CREATE FOLDER | |
function createFolder(folderName) { | |
if (!fs.existsSync(folderName)) { | |
fs.mkdirSync(folderName, 0766, function (err) { | |
console.log(err); | |
}); | |
} else { | |
console.log("ERROR >> cannot create folder. Folder already exists"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dir | rename-item -NewName {$_.name -replace " ","_"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const winston = require('winston'); | |
var logger = winston.createLogger({ | |
level : 'info', | |
format : winston.format.json(), | |
transports : [ | |
new winston.transports.File({ | |
filename : 'logs/error.log', | |
level : 'error' | |
}), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function stdTimezoneOffset() { | |
var d = new Date(); | |
var jan = new Date(d.getFullYear(), 0, 1); | |
var jul = new Date(d.getFullYear(), 6, 1); | |
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()); | |
} | |
/** | |
* Gets offset of current timezone and calculates if it has daylight timings enabled. | |
* @returns {boolean} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem -Path L:\senthil\ –Recurse | Out-File -filepath all-files-senthil.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//requiring path and fs modules | |
const path = require('path'); | |
const fs = require('fs'); | |
/** | |
* Read contents of files inside a folder. | |
* @param {*} folderName | |
* @param {*} rootDir | |
* | |
* @example : readFolder("data", __dirname) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
const fs = require('fs'); | |
function readFilesFromDir(dir) { | |
var filelist = []; | |
walkSync(dir, filelist); | |
return filelist; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { HttpClient } from '@angular/common/http'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class AuthService { | |
httpClient : HttpClient; | |
constructor(httpClient : HttpClient) { | |
this.httpClient = httpClient; |
OlderNewer