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 / git-push-fix.md
Last active December 10, 2020 11:43
Git push the current branch and set the remote as upstream

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
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

Git

Remove all local branches except master

This example will show how to remove all Git branches in local except master branch

git branch | grep -v "master" | xargs git branch -D
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 / deployToNetlify.md
Last active November 19, 2018 07:29
Deploy single page app with react to Netlify

Deploy single page app with react to Netlify

After installing the main package as we need it for deploy:

npm i netlify-cli -g

Build the app with this command:

npm run build
@mohokh67
mohokh67 / deployToNow.md
Last active March 6, 2019 12:49
Deploy single page app with react to zeit/now

Deploy single page app with react to zeit/now

After installing these two packages as we need them for deploy:

npm i now -g
npm i serve

follow these steps:

@mohokh67
mohokh67 / fix gitignore.md
Last active September 14, 2023 14:09
Fix the .gitignore and untrack files which are already added

Untrack files which are already added in gitignore file

  1. Commit all your changes

  2. Remove everything from the repository cache. Go to your repo directory and run this command.

git rm -r --cached .

It will only clear the cache. Your files and git history will stay.

@mohokh67
mohokh67 / Install PHP 7.1 with Nginx on Ubuntu 17.10.md
Created January 23, 2018 08:09
Install PHP 7.1 with Nginx on Ubuntu 17.10

Install PHP 7.1 with Nginx on Ubuntu 17.10

Follow these steps to inatll php 7.1 and most common modules:

sudo apt-get update
  • Install PHP 7.1
@mohokh67
mohokh67 / Install nginx, php7.1 and setup a virtual host in ubuntu.md
Last active January 23, 2018 08:10
How to install nginx, php7.1 and setup a virtual host in Ubuntu

Install Nginx and add a virtual host

  • First, make sure the Ubuntu Repo. is up to date.
sudo apt-get update
  • Check if Nginx is install in you machine:
nginx -v
@mohokh67
mohokh67 / Install Composer in Ubuntu.md
Last active February 10, 2018 13:05
Install Composer in Ubuntu

How to install composer in Ubuntu

In this short article we are going to install composer php packages manager in Ubuntu 16 and above.

  • Make sure php is installed by typing php -v in terminal. otherwise install PHP with this command:
sudo apt-get update
sudo apt-get install php