Skip to content

Instantly share code, notes, and snippets.

@egorzekov
Last active September 9, 2019 12:44
Show Gist options
  • Save egorzekov/2e48404b95b44bbf0b49fcf7c738928b to your computer and use it in GitHub Desktop.
Save egorzekov/2e48404b95b44bbf0b49fcf7c738928b to your computer and use it in GitHub Desktop.
CLI hints for Front-End developers
# Output file
cat package.json
# Save output to file
cat package.json > new-file.txt
# Copy outpub to clipboard
cat package.json | pbcopy
# Find active process
ps aux | grep nginx
# Show which process uses a port
lsof -i:8080
# Kill a process
kill 125
# Find and remove folders
find . -name node_modules -type d -exec rm -rf {} +
# 01. Unzip archive
# Install 'unzip'
brew install unzip
unzip file.zip -d destination_folder
# 02. Compress PNG
# Install 'unzip'
brew install optipng
# Where (see help for additional details):
# -o5 is 5th lvl of the compression algorithm
# -keep saves backup files
optipng some_image.png -o5 -keep
# Stash with untracked (new) files
git stash -u
git stash --include-untracked
# Reset last commit, leaving the changes staged
git reset --soft HEAD~1
# Remove remote and local tag
git push --delete origin tagName
git tag -d tagName
# Create a branch from old commit
git checkout -b branchName a10dbd28cda
# Disable pager for "git branch" command
git config --global pager.branch false
# Another variant to ignore some file/folder - edit the following file
nano .git/info/exclude
# Change default editor globally
git config --global core.editor nano
# Remember SSH password in keychain
ssh-add -K ~/.ssh/id_rsa
# Add repo (e.g. in case your repo is a fork of it) as a remote
git remote add upstream https://github.com/reactjs/ru.reactjs.org.git
# Update NPM
npm install -g npm
# Update Node.js
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
# or
sudo n 0.8.21
# List global NPM packages
npm list -g --depth=0
# Update global packages
npm update -g
# Sometimes, global package can't be updated using command above.
# There're a couple of issues in NPM repo, most of them are closed as "Cannot reproduce".
# In this case use the following work-around:
npm uninstall -g create-react-app
npm i -g create-react-app
# Show outdated global packages
npm outdated -g
# Open repository of package
npm repo react
# Move dependency from dev to prod
npm i @babel/core --save-prod
# Move dependency from prod to dev
npm install @babel/core --save-dev
# Show current user and DB you're connected to
\c
# List tables
\dt
# List extentions
\dx
# Create initial user
/usr/local/Cellar/postgresql/11.5/bin/createuser -s postgres
# Create super user
CREATE ROLE username SUPERUSER LOGIN;
ALTER ROLE username WITH PASSWORD "username";
# List columns and indexes for a specific table
\d some_table
# Exit
\q
-- Update field of JSONB type
UPDATE drivers
SET data = data || '{“expiration_date”:“11/24/2018"}'
WHERE number = '493092';
-- Select where field is one from set
SELECT id, attribute
FROM review_attributes
WHERE attribute IN ('city', 'state', 'zip');
-- Delete row
DELETE
FROM users
WHERE id = 'Musical';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment