Skip to content

Instantly share code, notes, and snippets.

View dinhkhanh's full-sized avatar

Tran Dinh Khanh dinhkhanh

View GitHub Profile
class AdsManager {
constructor() {
let supportedAPIs = FBInstant.getSupportedAPIs();
this.canShowInterstitialAds = supportedAPIs.includes('getInterstitialAdAsync');
this.canShowRewardedVideoAds = supportedAPIs.includes('getRewardedVideoAsync');
if (!this.canShowInterstitialAds) {
Sentry.captureMessage(window.platform + ' can\'t show interstitital ads');
}
if (!this.canShowRewardedVideoAds) {
Sentry.captureMessage(window.platform + ' can\'t show rewarded video ads');
@dinhkhanh
dinhkhanh / Disable MDM, DEP notification on Big Sur.md
Created October 31, 2020 13:22
Disable MDM, DEP notification on Big Sur

Disable MDM, DEP notification on Big Sur

Step 1. Disable SIP. Boot into Recovery Mode. Open Terminal, type this and hit Enter

csrutil disable

Step 2. Reboot into Recovery Mode again. Open Terminal, using these commands

@dinhkhanh
dinhkhanh / script.py
Created September 29, 2021 23:57
Get Google Search Results
import undetected_chromedriver.v2 as uc
from selenium.webdriver.common.by import By
import re
opts = uc.ChromeOptions()
# opts.add_argument('--headless')
# opts.add_argument('--disable-gpu')
driver = uc.Chrome(options=opts)
keywords = ['Kể', 'từ', 'khi', 'dẫn', 'dắt', 'các', 'đội', 'tuyển', 'Việt', 'Nam', 'cuối', 'năm', '2017,', 'HLV', 'Park', 'chưa', 'từng', 'thua', 'các', 'đối', 'thủ', 'Đông', 'Nam', 'Á.', 'Ông', 'đặc', 'biệt', 'có', 'duyên', 'với', 'Malaysia', 'và', 'Indonesia.', 'Tại', 'vòng', 'loại', 'thứ', 'hai', 'World', 'Cup', '2022,', 'đội', 'tuyển', 'cùng', 'bảng', 'G', 'với', 'hai', 'đối', 'thủ', 'này', 'và', 'toàn', 'thắng', 'cả', 'bốn', 'trận.', 'Điểm', 'bất', 'lợi', 'với', 'Việt', 'Nam', 'là', 'cùng', 'lúc', 'thi', 'đấu', 'nhiều', 'mặt', 'trận.', 'Bên', 'cạnh', 'AFF', 'Cup', '2020,', 'đội', 'tuyển', 'còn', 'phải', 'đã', 'vòng', 'loại', 'thứ', 'ba', 'World', 'Cup', '2022', '-', 'khu', 'vực', 'châu', 'Á.', 'Điều', 'này', 'khiến', 'HLV', 'Park', 'phải', 'tính', 'toán', 'về', 'bài', 'toán', 'lực',

Folder Structure

Please note

While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.

Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.

@dinhkhanh
dinhkhanh / proximity-prefetch.tsx
Created April 6, 2025 07:43 — forked from pontusab/proximity-prefetch.tsx
Next.js Proximity Prefetch (PPF)
"use client";
import { useRouter } from "next/navigation";
import type { ReactNode } from "react";
import { useCallback, useEffect, useState } from "react";
interface ProximityPrefetchProps {
children: ReactNode;
threshold?: number;
predictionInterval?: number;