Skip to content

Instantly share code, notes, and snippets.

@anhphamt
Last active October 30, 2023 08:42
Show Gist options
  • Save anhphamt/9453ff7108bd71b03a887f5374e4fd2a to your computer and use it in GitHub Desktop.
Save anhphamt/9453ff7108bd71b03a887f5374e4fd2a to your computer and use it in GitHub Desktop.
Some useful commands

Readd keys for remote deploying

ssh-add
ssh-add ~/.ssh/deployer
ssh-add ~/.ssh/clhq_tuananh_rsa

Check subfolders disk size

~/Library/Developer/Xcode
du -sh *

df -h

du -sh -- */ | sort -rh

Forward ngrok to localhost for testing WEBHOOK

ngrok http -host-header=rewrite localhost:3001

Check compile file locally

NODE_ENV=production ./bin/webpack --progress --config config/webpack/production.js

Check Free space

df

Kill process that used port 8000 or 80

lsof -t -i tcp:8000 | xargs kill
lsof -t -i tcp:80 | xargs kill

Export PEM file in correct way https://stackoverflow.com/questions/21250510/generate-pem-file-used-to-setup-apple-push-notification

git reset --hard HEAD

Import MySQL file

mysql -u username -p database_name < file.sql

Sometime we need to clean GIT

git rm --cached -r .
git reset --hard

Switch from HTTPS to GIT

git remote set-url origin [email protected]:anhphamt.la/git-url.git

Empty nginx log files It should be done when logging in with root

cat /dev/null > error.log

VestaCP commands

systemctl restart nginx
apachectl restart

php ini in /etc/php.ini

upload_max_filesize=256M
post_max_size=256M

Find keyword in folder

grep -R hello /home

How to build memcached manually

brew install libevent
brew install autoconf
brew install libmemcached
  • Download the PHP version you are using and past it to:
cd /Applications/MAMP/bin/php/php5.6.7/include/php
  • Configure the source with
/Applications/MAMP/bin/php/php5.6.7/include/php/configure

//go to

cd /Applications/MAMP/bin/php/php5.6.7/bin

//compile memcached

./pecl install memcached

//go back

cd ../

//Add the memcached.so extension to your php.ini file

echo -e "\n[memcached]\nextension=memcached.so" >> conf/php.ini

//start memcached server

memcached -m 24 -p 11211 -d

//restart MAMPP and thats it!

Prestashop permissions command

sudo find . -type f -exec chmod 0644 {} \;
sudo find . -type d -exec chmod 0755 {} \;

JENKIN

ssh -i "Gustavo.pem" [email protected]
sudo -i
cd /var/lib/jenkins/workspace/satterley-prod
/usr/local/bin/eb deploy

HEROKU Setup

https://devcenter.heroku.com/articles/git#tracking-your-app-in-git

Install nokogiri

gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 --use-system-libraries

Install ruby-xml

gem install libxml-ruby -v '3.0.0' -- --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xml2-dir=/usr/local/opt/libxml2 --with-xml2-lib=/usr/local/opt/libxml2/lib --with-xml2-include=/usr/local/opt/libxml2/include

Setup SSL with certbot

sudo certbot -d pav.testbox.com.au --nginx-ctl /etc/nginx/sbin/nginx

Restart PHP 7.3 Mojave

brew services restart [email protected]

Reload Source Bash

source ~/.bashrc

Clean Old Simulator Device

xcrun simctl delete unavailable

Clean Docker Volumns

docker system prune -a --volumes

Migrations

Add migration

php artisan make:migration add_votes_to_users_table --table=users

Add Table

php artisan make:migration create_users_table --create=users

Update Migrate

php artisan migrate

Disable Pagespeed module

Go to homepage folder

~/stack/apache2/conf 

Comment out pagespeed configuration

Comment out the following lines in the installdir/apache2/conf/httpd.conf file:

 Include conf/pagespeed.conf
 Include conf/pagespeed_libraries.conf

Main Documentation

https://docs.bitnami.com/aws/faq/administration/control-services/

sudo /opt/bitnami/ctlscript.sh restart apache

Replace string in multiple files

find ./ -type f -exec sed -i '' -e 's/\<script src\=\"\.\.\/\.\.\/cdn\-cgi\/apps\/head\/rxEP1tpTSauDgm5zPJIYNDhMku4\.js\"\>\<\/script\>//' {} \;

Replace string

find ./ -type f -exec sed -i '' -e 's/string1/string2/' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment