Skip to content

Instantly share code, notes, and snippets.

View AlexandrKolesnikov's full-sized avatar
🎯
Focusing

Oleksandr Kolesnikov AlexandrKolesnikov

🎯
Focusing
View GitHub Profile
export function assertNever(value: never): never {
throw new Error(`Unexpected value: ${value}`);
}
Use git log --diff-filter=D --summary to get all the commits which have deleted files and the files deleted;
Use git checkout $commit~1 path/to/file.ext to restore the deleted file.
Where $commit is the value of the commit you've found at step 1, e.g. e4cf499627
@AlexandrKolesnikov
AlexandrKolesnikov / useDidUpdate.ts
Last active January 15, 2022 12:20
React Hooks with TypeScript
import {
useEffect, useRef, EffectCallback, DependencyList,
} from 'react';
export const useDidUpdateEffect = (callback: EffectCallback, deps: DependencyList) => {
const didMount = useRef(false);
useEffect(() => {
if (didMount.current) {
callback();
@AlexandrKolesnikov
AlexandrKolesnikov / post-receive
Created September 11, 2018 20:33
Git Basic "post-receive" auto-deploy hook
#!/bin/bash
set -eu
TARGET="/home/YOUR_PROJECT/deploy-folder"
GIT_DIR="/home/YOUR_PROJECT/project.git"
BRANCH="master"
while read oldrev newrev ref
do
# only checking out the master (or whatever branch you would like to deploy)
@AlexandrKolesnikov
AlexandrKolesnikov / post-receive
Created September 11, 2018 20:33
Git Basic "post-receive" auto-deploy hook
#!/bin/bash
set -eu
TARGET="/home/YOUR_PROJECT/deploy-folder"
GIT_DIR="/home/YOUR_PROJECT/project.git"
BRANCH="master"
while read oldrev newrev ref
do
# only checking out the master (or whatever branch you would like to deploy)
@AlexandrKolesnikov
AlexandrKolesnikov / MacOS VMWare Workstation resolution fix.txt
Created August 30, 2018 18:23
MacOS VMWare Workstation resolution fix
If you have an issue, when you can't change resolution of the MacOS installed in the VMWare even after VMWare tools has been installed.
In my case it was not applyable resolution change. I had 1024x768 by default and when I tried to change it to 1600x900, etc. and got
resolution jump and back to 1024x768
You may set any supported by your device custom resoultion.
Just run following command in MacOS Terminal and you will be happy :)
/Library/Application\ Support/VMware\ Tools/vmware-resolutionSet 1920 1080
NOTES:
@AlexandrKolesnikov
AlexandrKolesnikov / .sh
Created March 2, 2018 15:36
Git Command line templates
# This command will parse all your local branched that had been merged instead of master or dev. Then for each branch will be called git branch -d(delete locally)
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
// Delete all local branches, that were merged to master
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
@AlexandrKolesnikov
AlexandrKolesnikov / .bash_profile
Last active April 9, 2017 14:56
.bash_profile
alias ags="git status"
alias aga="git add *"
alias agg="git pull"
alias agp="git push"
alias agc="git commit -m"
alias agnb="git checkout -b"
alias agcb="git checkout"
alias ani="sudo npm i"
alias anc="sudo npm-check”