Skip to content

Instantly share code, notes, and snippets.

View mohokh67's full-sized avatar
💭
Working hard, typing slow 😎😎

MoHo mohokh67

💭
Working hard, typing slow 😎😎
View GitHub Profile
@mohokh67
mohokh67 / undo-recent-commits.md
Last active June 1, 2021 16:53
Undo recent commits while keeping the changes
View undo-recent-commits.md

Find the commit hash you want to go back to by git log --oneline and then

git reset <commit_hash>

git reset without a --hard or --soft moves your HEAD to point to the specified commit, without changing any files.

@mohokh67
mohokh67 / git-push-fix.md
Last active December 10, 2020 11:43
Git push the current branch and set the remote as upstream
View git-push-fix.md

If you see the bellow error for the first time when you try to push your new branch which has not been pushed:

git push                 

fatal: The current branch new-branch has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin new-branch
@mohokh67
mohokh67 / timestamp-formatter.md
Created June 1, 2020 14:26
Get YYYY-MM-DD HH-MM-SS in JavaScript
View timestamp-formatter.md
const formatedTimestamp = ()=> {
  const d = new Date()
  const date = d.toISOString().split('T')[0];
  const time = d.toTimeString().split(' ')[0].replace(/:/g, '-');
  return `${date} ${time}`
}
@mohokh67
mohokh67 / git-remove-all-branches-except-master.md
Created January 14, 2020 11:11
Git: Remove all branches except master
View git-remove-all-branches-except-master.md
@mohokh67
mohokh67 / vscode-settings.md
Last active August 9, 2023 04:34
Install italic and customizable font for vscode
View vscode-settings.md
View Terminal alias
alias c='clear'
alias gs='git status'
alias pull='git pull'
alias push='git push'
alias master='git checkout master'
alias commit='git commit -m'
alias ll='ls -la'
alias ls='ls --color=auto'
@mohokh67
mohokh67 / creditCardValidator.js
Last active April 29, 2020 10:56
Credit card validation
View creditCardValidator.js
const validCreditCard = (cardNumber) => {
const newInput = cardNumber.toString();
let first = 0;
let second = 0;
if (newInput.length !== 16) {
return false;
}
for (let i = 15; i >= 0; i--) {
if (i % 2 === 1) {
@mohokh67
mohokh67 / deployToNetlify.md
Last active November 19, 2018 07:29
Deploy single page app with react to Netlify
View deployToNetlify.md
@mohokh67
mohokh67 / deployToNow.md
Last active March 6, 2019 12:49
Deploy single page app with react to zeit/now
View deployToNow.md
@mohokh67
mohokh67 / terminal.md
Last active February 12, 2019 16:05
Customise terminal prompt
View terminal.md