Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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 / 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 / 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 / restart-cinnamon-in-linux-mint.txt
Created March 5, 2019 15:24
Several ways to restart Cinnamon in Linux Mint
1. Hit ctrl+alt+esc
2. Hit Alt+F2, type r, and press Enter
3. Switch to another tty, for example tty6, by pressing Ctrl+Alt+F6
Run:
pkill -HUP -f "cinnamon --replace"
Return to tty8 by pressing Ctrl+Alt+F8
@hachesilva
hachesilva / minimal-analytics-snippet.js
Last active January 15, 2019 15:44 — forked from DavidKuennen/minimal-analytics-snippet.js
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@hachesilva
hachesilva / cool-font-combos.scss
Created January 3, 2019 04:09
Cool font combinations I've found
#1 {
// Source: https://www.apres.io/
h1 {
font-family: Merriweather;
weight: 900;
font-size: 68px;
}
h2 {
font-family: Merriweather;