Skip to content

Instantly share code, notes, and snippets.

@ralavay
ralavay / vim-nginx-conf-highlight.sh
Last active April 21, 2024 03:58
Enable syntax highlight for Nginx conf file in Vim
#!/bin/bash
#
# Highligh Nginx config file in Vim
# Download syntax highlight
mkdir -p ~/.vim/syntax/
wget http://www.vim.org/scripts/download_script.php?src_id=19394 -O ~/.vim/syntax/nginx.vim
# Set location of Nginx config file
cat > ~/.vim/filetype.vim <<EOF
@ralavay
ralavay / https-localhost.md
Created June 9, 2018 15:48
Run local development as HTTPS to handle Facebook app login enforce HTTPS

Facebook enforces to use HTTPS for Facebook Login so we can't you http://localhost:port in local anymore.

We will just get this message

Insecure Login Blocked: You can't get an access token or log in to this app from an insecure page. Try re-loading the page as https://

How to run your local development with HTTPS

@ralavay
ralavay / remove-mac-os-adware.sh
Created August 26, 2015 07:36
Remove MAC OS adware
#!/usr/bin/env bash
#
# Stop pop-up adware in MAC OS
# https://support.apple.com/en-us/HT203987
# http://www.thesafemac.com/arg-identification/
# Allow to loop through path with spaces
# http://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
@ralavay
ralavay / json
Created December 30, 2019 07:45
grafana-cert-manager.json
{
"__inputs": [],
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "6.3.4"
},
{
@ralavay
ralavay / cert-check.sh
Last active December 28, 2018 08:17
Show SSL cert expiration date
# Put this into ~/.profile
# Usage:
# cert-check domain.name
# Example:
# cert-check www.google.com
function cert-check() {
yes QUIT | openssl s_client -showcerts -servername $1 -connect $1:443 > /tmp/$1.pem && openssl x509 -inform PEM -in /tmp/$1.pem -text -out certdata | grep -i 'not after'
}
@ralavay
ralavay / termux-init.md
Last active August 19, 2018 13:59
termux-init

Thing to install for Termux

pkg update
pkg install -y \
    bash \
    bash-completion \
    git \
    vim \
 openssh \
@ralavay
ralavay / change_ubuntu_hostname.sh
Created September 24, 2015 02:30
Change Ubuntu hostname
#!/bin/bash
#
# Change hostname for Ubuntu host
OLD_NAME=$(hostname)
echo "- Current hostname is: $OLD_NAME"
read -p "- Please input new hostname: " NEW_NAME
update_ect_hostname() {
sudo hostname $NEW_NAME
@ralavay
ralavay / less_syntax_highlight.sh
Last active December 24, 2015 23:09
Enable syntax highlight via LESS comand
#!/bin/bash
#
# Enable syntax highlight mode in LESS command by using source-highlight
# http://www.gnu.org/software/src-highlite/
sudo apt-get install source-highlight -y
cat >> ~/.bashrc <<EOF
export LESSOPEN="| /usr/share/source-highlight/src-hilite-lesspipe.sh %s"
export LESS=" -R"
@ralavay
ralavay / install_rvm_ruby_ror_in_cent_ubuntu.sh
Last active December 24, 2015 15:49
Install RVM then using it to install Ruby, RoR in CentOS 6.4 and Ubuntu 12.04
#!/bin/bash
#
# This script will install RVM then use it to install RUBY, RAILS.
# Thanks for DigitalOcean awesome guides at:
# https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-centos-6-with-rvm
# https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
# Detect which distro
DISTRO=`cat /etc/issue`
@ralavay
ralavay / install_stardict_ubuntu.sh
Last active December 24, 2015 13:28
Install Stardict in Ubuntu
#!/bin/bash
#
# Installs stardict in Ubuntu 12.04 and enables its systray icon
echo "
This script will add 'ppa:ubuntu-vn/ppa' repo to your update list
then install 'stardict' and 'english<->vietnamese' 'japanese<->vietnamese' dicts
"
sleep 1.5