Skip to content

Instantly share code, notes, and snippets.

View dhvcc's full-sized avatar

Alexey dhvcc

View GitHub Profile
@dhvcc
dhvcc / defer-nvm.zsh
Created October 13, 2021 11:34
Defer nvm initialization to improve shell load time [ZSH]
# Defer initialization of nvm until nvm, node or a node-dependent command is
# run. Ensure this block is only run once if .bashrc gets sourced multiple times
# by checking whether __init_nvm is a function.
if [ -s "$HOME/.nvm/nvm.sh" ] && [ ! "$(whence -w __init_nvm)" = function ]; then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
__node_commands=('nvm' 'node' 'npm' 'yarn' 'gulp' 'grunt' 'webpack')
function __init_nvm() {
for i in "${__node_commands[@]}"; do unalias $i; done
. "$NVM_DIR"/nvm.sh
@dhvcc
dhvcc / SwipableTabs.tsx
Last active February 23, 2021 14:54
SwipableTabs component using MaterialUI
import * as React from 'react';
import {HTMLAttributes} from 'react';
import {
AppBar,
createStyles,
makeStyles,
Tab,
Tabs,
Theme,
useTheme,
@dhvcc
dhvcc / signals.py
Created September 26, 2020 09:01
Allauth pre social login signal handler to avoid sign up (and verify e-mail) if account exists
from allauth.account.utils import perform_login
from allauth.exceptions import ImmediateHttpResponse
from allauth.socialaccount.signals import pre_social_login
from allauth.utils import get_user_model
from django.dispatch import receiver
from django.shortcuts import redirect
from django.conf import settings