Skip to content

Instantly share code, notes, and snippets.

View sairajchouhan's full-sized avatar

Sairaj sairajchouhan

View GitHub Profile

Multiple GitHub accounts (Work vs Personal)

This setup uses some tricks to ensure that the right email/name/ssh-key is used for the right repos without having to think about it ever again.

  • First generate two SSH keys, ~/.ssh/id_ed25519 and ~/.ssh/id_ed25519_work
  • Add one key to your personal account and the other to your work account

.ssh/config

@sairajchouhan
sairajchouhan / script.js
Created August 17, 2023 08:43
script to pin some repos in the sidebar of home page of Github
const repo_list = [
"contentstack/UI-React",
"contentstack/visual-editor",
"contentstack/schema-form",
"contentstack/UI-E2E",
"contentstack/venus-components",
];
document.addEventListener("DOMContentLoaded", () => {
setTimeout(() => {
@sairajchouhan
sairajchouhan / cbugger.lua
Last active September 22, 2023 09:52
lua script to insert logs in javascript for neovim
M = {}
local num = 0;
M.setup = function()
vim.api.nvim_set_keymap('n', '<leader>cl', ':Cbugger<CR>', { noremap = true, silent = true })
vim.api.nvim_create_user_command("Cbugger", function()
local cursor = vim.api.nvim_win_get_cursor(0);
local final_str = "console.log(`" .. num .. ": ";
version: '3.9'
services:
db:
image: postgres:latest
container_name: minibyte_postgres_dev
restart: always
ports:
- 5432:5432
environment:
- POSTGRES_USER=minibyte
import { useState } from "react"
const useModal = (initial = false, duration = 300) => {
const [isOpen, setIsOpen] = useState(initial)
const closeModal = () => {
return new Promise((res) => {
setIsOpen(false)
setTimeout(() => {
res(true)
@sairajchouhan
sairajchouhan / useTwWindowSize.ts
Created February 6, 2022 13:12
I use this buddy in every tailwind project so thought to put it here so that I don't have to bang my head writing the same hook again and again
import { useEffect, useState } from 'react'
export type ScreenSize = 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '_'
export const getScreenSize = (width: number) => {
let screenSize: ScreenSize = '_'
if (width < 768 && width >= 640) {
screenSize = 'sm'
}
@sairajchouhan
sairajchouhan / useImageUpload.tsx
Created October 18, 2021 15:38
React hook for image file upload
import { useEffect, useState } from 'react'
// fill the array with the image type you want to allow
const allowedImageTypes = ['image/jpeg', 'image/png']
export const useFileUpload = () => {
const [selectedFile, setSelectedFile] = useState<Blob | null>(null)
const [previewUrl, setPreviewUrl] = useState<string | null>(null)
const [error, setError] = useState<string | null>(null)
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"lib": [
"dom",
"es6",
"es2017",
"esnext.asynciterable"
],