Skip to content

Instantly share code, notes, and snippets.

View wagura-maurice's full-sized avatar
🏠
Working from home

Maurice Wagura wagura-maurice

🏠
Working from home
View GitHub Profile
@wagura-maurice
wagura-maurice / gist:e985733d5a6829b03b77ea73738707e9
Created October 15, 2019 13:17
Nginx Redirect Mobile / Smart Phone Traffic To Mobile Version Of the Web Site
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 October 1, 2019 23:39
How to replace a string in multiple files in linux command line

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' {} +

@wagura-maurice
wagura-maurice / postman_install.sh
Last active November 27, 2019 07:41
Installing Postman on Ubuntu 18.04
#!/bin/bash
cd /tmp || exit
echo "Downloading Postman ..."
wget -q https://dl.pstmn.io/download/latest/linux?arch=64 -O postman.tar.gz
tar -xzf postman.tar.gz
rm postman.tar.gz
echo "Installing to opt..."
if [ -d "/opt/Postman" ];then
sudo rm -rf /opt/Postman
@wagura-maurice
wagura-maurice / postman.desktop
Last active November 27, 2019 07:57
Setting up Postman on Ubuntu 18.04
[Desktop Entry]
Encoding=UTF-8
Name=Postman
Exec=postman
Icon=/home/montanabay/Postman/files/Icons/icon.png
Terminal=false
Type=Application
Categories=Development;
sudo wget --mirror --page-requisites --convert-links --adjust-extension --no-if-modified-since --no-check-certificate --user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36" -e robots=off -np https://www.edelman.com
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install postgresql postgresql-contrib
sudo adduser postgres
sudo passwd postgres
usermod -a -G sudo postgres
su - postgres
psql -d template1 -c "ALTER USER postgres WITH PASSWORD 'Rtcv39$$';"
createuser montanabay --pwprompt
___ ___ _ _ _ _____ _
| \/ | | | (_) | | |_ _| |
| . . | __ _| |_ ___ _ __ _ __ _| | | | | |__ ___ _ __ ___ ___
| |\/| |/ _` | __/ _ \ '__| |/ _` | | | | | '_ \ / _ \ '_ ` _ \ / _ \
| | | | (_| | || __/ | | | (_| | | | | | | | | __/ | | | | | __/
\_| |_/\__,_|\__\___|_| |_|\__,_|_| \_/ |_| |_|\___|_| |_| |_|\___|
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
@wagura-maurice
wagura-maurice / phone_numbers.txt
Created May 28, 2019 11:39
Getting all phone numbers out of some text.
<?php
preg_match_all("/\(? (\d{3})? \)? (?(1) [\-\s] ) \d{3}-\d{4}/x",
"Call 555-1212 or 1-800-555-1212", $phones);
?>
https://www.linode.com/docs/databases/postgresql/how-to-install-postgresql-on-ubuntu-16-04/
http://devopspy.com/linux/allow-remote-connections-postgresql/
heroku login
heroku git:clone -a egranary
cd egranary
git remote add egranary git@github.com:alkarimlalani/egranary.git
git fetch egranary master
git reset --hard egranary/master
git push heroku master --force