Skip to content

Instantly share code, notes, and snippets.

@hachesilva
hachesilva / sticky.txt
Created November 15, 2019 03:32
Sticky footer fexbox
Source: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/
The HTML
<body class="Site">
<header>…</header>
<main class="Site-content">…</main>
<footer>…</footer>
</body>
The CSS
@hachesilva
hachesilva / apache-allow-file-extension-in-server.txt
Created April 16, 2020 14:52
Allow a certain file extension in Apache server
add this in the site's .htaccess file:
RewriteCond %{REQUEST_URI} !\.ts
@hachesilva
hachesilva / autocommit-every-minute.sh
Created April 17, 2020 01:18
Commit to a repo every 60 seconds
#!/bin/bash
# sleep is in seconds, to use minutes, hours, or days append m h or d like so: 10m, 3h, 4d
function commit() {
TIMESTAMP=$(date +%c)
git pull
git add .
git commit -m "Auto update $TIMESTAMP"
git push origin master
}
while true
@hachesilva
hachesilva / XDebug-vscode-vagrant-bundle-setup.md
Last active May 4, 2020 09:18 — forked from sveggiani/instructions.md
[Configure XDebug, Visual Studio Code for a Vagrant VM] #debug #vm #vscode

Configure XDebug, Visual Studio Code for a Vagrant VM

1. Assumptions

  • Project (Drupal) is served on /var/www/html in the Vagrant box
  • Local project files location: c:\Users\username\Work\projects\my-project\repo\html
  • Guest machine IP is 10.0.2.2 (if this doesn't work, run route -nee in the VM and look for the gateway address)

2. Configuration

@hachesilva
hachesilva / acme.sh-ssl-install.sh
Created June 8, 2020 07:12
Install SSL cert from cPanel terminal
# INSTALL
curl https://get.acme.sh | sh
# USE
acme.sh --issue -d MYDOMAIN -d www.MYDOMAIN -w /home/USERNAME/public_html/
acme.sh --install-cert -d MYDOMAIN -d www.MYDOMAIN
acme.sh --deploy -d MYDOMAIN -d www.MYDOMAIN --deploy-hook cpanel_uapi
# Source: https://github.com/acmesh-official/acme.sh
# Source: https://massingham.net/using-lets-encrypt-certificates-on-namecheap-shared-hosting-with-automatic-updates/
@hachesilva
hachesilva / functions.php
Created July 23, 2020 19:54
Woocommerce add markup to shipping rate
<?php
function markup_shipping_rates($rates, $packages)
{
$percentage = 5;
$cartTotal = WC()->cart->get_totals()['cart_contents_total'];
$additionalFee = ($percentage * $cartTotal) / 100;
if (isset($rates['enviashipping:1'])) {
@hachesilva
hachesilva / anyconnect.sh
Last active August 10, 2020 20:17
Route WSL1 network to use anyconnect VPN
#!/bin/bash
# Source: https://github.com/microsoft/WSL/issues/1350
tmp=`mktemp`
powershell="/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe"
trap ctrlC INT
removeTempFiles() {
rm -f $tmp
@hachesilva
hachesilva / wsl-install-redis.sh
Created December 26, 2020 18:43
Install redis on WSL / ubuntu
# Source: https://anggo.ro/note/installing-redis-in-ubuntu-wsl/
# Update and upgrade Ubuntu
sudo apt update && apt upgrade
# Install Redis
sudo apt install redis-server
# Update redis.conf file
sudo nano /etc/redis/redis.conf
# Source: https://gist.github.com/juanique/4092969#gistcomment-3078760
function git_add_ssh_key () {
read -p "Enter github email : " email
echo "Using email $email"
if [ ! -f ~/.ssh/id_rsa ]; then
ssh-keygen -t rsa -b 4096 -C "$email"
ssh-add ~/.ssh/id_rsa
fi
pub=`cat ~/.ssh/id_rsa.pub`
read -p "Enter github username: " githubuser
@hachesilva
hachesilva / notifyme.sh
Created January 6, 2021 22:09
Notifyme me when a terminal command is done
# Source: https://news.ycombinator.com/item?id=25381535
# Usage: $ LONG-COMMAND; notifyme
function notifyme() {
MSG=${1:-'Terminal is done'}
TITLE=${2:-"Done!"}
osascript -e "display notification \"${MSG}\" with title \"${TITLE}\""
}