Skip to content

Instantly share code, notes, and snippets.

View naveen1337's full-sized avatar

Naveen 1337 naveen1337

View GitHub Profile
@naveen1337
naveen1337 / react_render_count_custom_hook.ts
Created March 3, 2023 13:12
react_render_count_custom_hook
export function useRenderCount(componentId: string) {
const renderCount = useRef(1);
console.log(`${componentId} renders ${renderCount.current++}`);
return renderCount;
}
@naveen1337
naveen1337 / react_native_image_picker_custom_hook.ts
Created March 3, 2023 13:11
react_native_image_picker_custom_hook
export function useImageUpload() {
const [image, setImage] = useState<any>(null);
async function openLibrary() {
ImagePicker.openPicker({
width: 300,
height: 400,
cropping: true,
includeBase64: false,
})
.then(image => {
@naveen1337
naveen1337 / react_native_date_picker_custom_hook.ts
Created March 3, 2023 13:08
react_native_date_picker_custom_hook
export function useDateTimePicker() {
const [date, setDate] = useState(new Date())
const [open, setOpen] = useState(false)
const parsedDate = formatDate(date,false)
function updateDT(obj: any) {
if(obj.type === "open"){
setOpen(true)
}
if(obj.type === "dismissed"){
@naveen1337
naveen1337 / python_locust_init.py
Created February 6, 2023 05:05
Python load testing with Locust
from locust import HttpUser, task
import json
token = 'TOKEN HERE'
class LoadTestApi(HttpUser):
# @task
#def getUserById(self):
# self.client.get(
# url="api/v1/user/get_user_by_id",
@naveen1337
naveen1337 / svg_insta_style_spinner.tsx
Last active February 6, 2023 05:06
svg_insta_style_spinner
export default function Spinner(props) {
return (
<svg
className="text-gray-500"
viewBox="0 0 2400 2400"
width={24}
height={24}
{...props}
>
<g