Skip to content

Instantly share code, notes, and snippets.

View tutv's full-sized avatar
🎯
Focusing

Tu Tran tutv

🎯
Focusing
View GitHub Profile
@tutv
tutv / disable_webrtc_puppeteer.js
Created August 31, 2022 08:19
How to disable webrtc for puppeteer
await page.evaluateOnNewDocument(
`navigator.mediaDevices.getUserMedia = navigator.webkitGetUserMedia = navigator.mozGetUserMedia = navigator.getUserMedia = webkitRTCPeerConnection = RTCPeerConnection = MediaStreamTrack = undefined;`
)
.idea/
.gitlab-ci.yml
.release-it.json
test/
src/
nodemon.json
{
"watch": [
"src"
],
"ext": "ts",
"exec": "tsc"
}
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"declaration": true,
"outDir": "./dist",
"strict": true
},
"include": [
"src"
require('dotenv').config()
@tutv
tutv / app.js
Created November 1, 2020 17:18
dotenv
const path = require('path')
const env = process.env.NODE_ENV === 'production' ? 'production.env' : '.env'
require('dotenv').config({
path: path.join(__dirname, env)
})
@tutv
tutv / pure.js
Created September 29, 2019 07:31
Simple export to csv
const {Parser} = require('json2csv')
const data = [
{
name: 'Max',
url: 'https://github.com/tutv'
},
{
name: 'Min',
url: 'https://github.com/m'
const fs = require('fs')
const path = require('path')
const {exec} = require('child_process')
const uuid = require('uuid/v4')
const _readFile = async (file = '') => {
return new Promise((resolve, reject) => {
fs.readFile(file, 'utf8', (error, data) => {
if (error) return reject(error)
const isExistPackage = await _isExist(packageJson)
if (!isExistPackage) {
throw new Error('package.json not found.')
}
const packageContent = await _readFile(packageJson)
const json = await _parseJSON(packageContent)
const {main} = json
if (!main) {
throw new Error(`package.json doesn't have 'main' property.`)
{
"txn_type":"subscr_signup",
"subscr_id":"xxx",
"last_name":"xxx",
"residence_country":"VN",
"mc_currency":"USD",
"item_name":"Standard - Unlimited",
"business":"xxx",
"amount3":"49.50",
"recurring":"1",