Skip to content

Instantly share code, notes, and snippets.

View p32929's full-sized avatar

Fayaz Bin Salam p32929

View GitHub Profile
@p32929
p32929 / NoSsr.tsx
Created May 23, 2024 10:31
disable SSR on a component
import dynamic from 'next/dynamic'
import React from 'react'
const NoSsr = props => (
<React.Fragment>{props.children}</React.Fragment>
)
export default dynamic(() => Promise.resolve(NoSsr), {
ssr: false
})
@p32929
p32929 / VisibilityObserver.tsx
Created May 23, 2024 10:29
a component kinda thingie to detect if an element is visible or hidden by css and came to view etc
import React, { useState, useEffect, useRef } from 'react';
interface VisibilityObserverProps {
children: (props: { elementRef: React.RefObject<HTMLDivElement>, isVisible: boolean }) => JSX.Element;
}
const VisibilityObserver: React.FC<VisibilityObserverProps> = ({ children }) => {
const [isVisible, setIsVisible] = useState(false);
const elementRef = useRef<HTMLDivElement>(null);
import 'dart:convert';
dynamic parseJson(String jsonString, String path) {
var json = jsonDecode(jsonString);
List<String> parts = path.split('.');
dynamic element = json;
for (var part in parts) {
if (part.contains('[') && part.contains(']')) {
@p32929
p32929 / Chrome.ts
Last active March 11, 2024 16:35
Playwright utility functions
// v0.0.1
import { Page, BrowserType, BrowserContext, chromium, firefox } from "playwright";
class Constants {
static SHOULD_CRASH_AFTER_URL_RETRY = true
static dbPath = "./data/database.json"
static defaultChromeTimeout = 1000 * 60 * 5
static defaultMaxWaitMs = 1000 * 10
@p32929
p32929 / siin_p32929.json
Last active July 27, 2023 16:43
List of apps to Silently install - p32929
[
{
"title": "Vscode",
"url": "https://code.visualstudio.com/sha/download?build=stable&os=win32-x64-user"
}
]
@p32929
p32929 / GetUser.Decorator.ts
Created December 7, 2022 14:07
GetUser.Decorator.ts
// import { User } from '@interfaces/user.interface';
import { User } from '@interfaces/user.interface';
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
export const GetUser = createParamDecorator(
(data, ctx: ExecutionContext): User => {
const req = ctx.switchToHttp().getRequest();
return req.user;
},
);
@p32929
p32929 / Question.ts
Last active December 4, 2022 09:58
Simple way to ask prompts in a shell/terminal/cmd in nodejs typescript
// @ts-ignore
const readline = require("readline")
export class Question {
static ask(questionTexts: string, callback?: (answer: string) => void): Promise<string> {
return new Promise((resolve) => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
})
@p32929
p32929 / ADB_Backup.md
Last active December 21, 2021 15:23
Adb backup restore APK + Data

List

List all installed apps

adb shell pm list packages -f -3

You might also use grep altogether

 adb shell pm list packages -f -3 | grep "anybooks"
@p32929
p32929 / FayFetch.js
Last active January 23, 2021 12:41
A helper class for easier Node Fetch
Moved to https://www.npmjs.com/package/fayfetch
Thanks to everyone for using it
import 'package:flutter/material.dart';
void main() {
runApp(const StartingPoint());
}
class StartingPoint extends StatelessWidget {
const StartingPoint({Key? key}) : super(key: key);
@override