Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Maurice Wagura wagura-maurice

🏠
Working from home
View GitHub Profile
View ssh-key-permissions.sh
chmod 700 ~/.ssh
chmod 644 ~/.ssh/authorized_keys
chmod 644 ~/.ssh/known_hosts
chmod 644 ~/.ssh/config
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
chmod 600 ~/.ssh/bitbucketkey
chmod 644 ~/.ssh/bitbucketkey.pub
chmod 600 ~/.ssh/deployerkey
chmod 644 ~/.ssh/deployerkey.pub
View ssh-key-add.sh
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa
ssh-add ~/.ssh/bitbucketkey
ssh-add ~/.ssh/deployerkey
ssh-add ~/.ssh/githubkey
ssh-add ~/.ssh/gitlabkey
@wagura-maurice
wagura-maurice / generate-ssh-key.sh
Created May 9, 2020 — forked from grenade/generate-ssh-key.sh
Correct file permissions for ssh keys and config.
View generate-ssh-key.sh
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
@wagura-maurice
wagura-maurice / PostgreSQL 11.txt
Last active May 9, 2020
Install PostgreSQL 11 on Ubuntu 18.04 / Ubuntu 16.04
View PostgreSQL 11.txt
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
RELEASE=$(lsb_release -cs)
echo "deb http://apt.postgresql.org/pub/repos/apt/ ${RELEASE}"-pgdg main | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt update
sudo apt -y install postgresql-11 postgresql-contrib-11
sudo passwd postgres
usermod -a -G sudo postgres
su - postgres
@wagura-maurice
wagura-maurice / phpenv-install.sh
Last active Mar 15, 2020
phpenv install shell
View phpenv-install.sh
#!/usr/bin/env bash
# vim: ai ts=2 sw=2 et sts=2 ft=sh
# Check OS.
# if [[ ! "${OSTYPE}" =~ "^linux" ]] || [[ ! "$(lsb_release -c 2>/dev/null)" =~ "xenial" ]]; then
# (>&2 echo "Error: This script is for Ubuntu 16.04 LTS (xenial) not '${OSTYPE}'.")
# exit 1;
# fi
sudo apt-get update
@wagura-maurice
wagura-maurice / minio.txt
Created Nov 22, 2019
minio-on-ubuntu-16-04
View minio.txt
https://www.digitalocean.com/community/tutorials/how-to-set-up-an-object-storage-server-using-minio-on-ubuntu-16-04
View mysql_dump.txt
mysql_config_editor set --login-path=local --host=localhost --user=root --password
mysqldump --login-path=local --no-data --skip-triggers microfinance > microfinance.sql
mysqldump --login-path=local --no-create-db --no-create-info --skip-triggers microfinance >> microfinance.sql
mysqldump --login-path=local --no-create-db --no-create-info --no-data --routines --triggers --skip-opt microfinance >> microfinance.sql
@wagura-maurice
wagura-maurice / composer_memory.txt
Created Nov 14, 2019
Composer update runs out of memory
View composer_memory.txt
df -h
dd if=/dev/zero of=/swapfile bs=1M count=1024
sudo dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo 'echo "/swapfile none swap defaults 0 0" >> /etc/fstab' | sudo sh
free -m
@wagura-maurice
wagura-maurice / gist:e985733d5a6829b03b77ea73738707e9
Created Oct 15, 2019
Nginx Redirect Mobile / Smart Phone Traffic To Mobile Version Of the Web Site
View gist:e985733d5a6829b03b77ea73738707e9
server {
server_name server_name example-live.com www.example-live.com;
set $mobile_rewrite do_not_perform;
# this regex string is actually much longer to match more mobile devices
if ($http_user_agent ~* "|android|ip(ad|hone|od)|kindle") {
set $mobile_rewrite perform;
}
@wagura-maurice
wagura-maurice / replace_string.md
Created Oct 1, 2019
How to replace a string in multiple files in linux command line
View replace_string.md

Similar to Kaspar's answer but with the g flag to replace all the occurrences on a line.

find ./ -type f -exec sed -i 's/string1/string2/g' {} ;

For global case insensitive:

find ./ -type f -exec sed -i 's/string1/string2/gI' {} ;

In case your string has a forward slash(/) in it, you could change the delimiter to '+'.

find . -type f -exec sed -i 's+http://example.com+https://example.com+g' {} +

You can’t perform that action at this time.