Skip to content

Instantly share code, notes, and snippets.

View IlanVivanco's full-sized avatar
💡
Coding!

Ilán Vivanco IlanVivanco

💡
Coding!
View GitHub Profile
@IlanVivanco
IlanVivanco / commands.md
Last active November 1, 2021 19:57
Util git scripts

Remove dead branches

Removes merged branches that are already deleted from the remote repository, but they are still on your local machine.

git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d

Add this command as git alias

@IlanVivanco
IlanVivanco / config.md
Last active September 3, 2021 13:48
Xdebug config for Devilbox

Extracted from cytopia/devilbox#718 issue

  • ~/.zshrc or ~/.bashrc
export IP=$(hostname -I)
  • _~/.devilbox/.env
PROJECTS_PATH=~/code
@IlanVivanco
IlanVivanco / devilbox.sh
Last active September 3, 2021 13:53
Utils function for managing Devilbox's virtual hosts
dvb-create-host() {
# Vars
BASE_DIR="~/www/$1/htdocs"
DB_NAME="$1_db"
DB_HOST="mysql"
DB_USER="root"
DB_PASS=""
WP_URL="$1.local"
WP_USER="ilan"
@IlanVivanco
IlanVivanco / cron.yml
Last active May 12, 2021 10:16
Github workflow cron
# .github/workflows/cron.yml
# You must add your YOUR_BUILD_HOOK from your repo > Settings > Secrets
name: Trigger Netlify Build
on:
schedule:
# Run at 0815 daily
- cron: '15 8 * * *'
jobs:
build:
@IlanVivanco
IlanVivanco / phpcs.xml
Last active March 8, 2024 17:09
PHPCS WordPress coding standards config file
<?xml version="1.0"?>
<ruleset name="WordPress Theme Coding Standards"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<description>A custom set of rules to check for a WPized WordPress project</description>
<!-- General PHPCS config. -->
<file>.</file>
<arg value="sp"/>
<arg name="extensions" value="php"/>
@IlanVivanco
IlanVivanco / clean_slack.py
Last active January 27, 2022 08:18
Deletes files older than N days. You can also filter them by size. Forked from https://gist.github.com/jackcarter/d86808449f0d95060a40
# Idea taken from https://gist.github.com/jackcarter/d86808449f0d95060a40
import time
import codecs
import requests
reader = codecs.getreader("utf-8")
# Obtain your's by creating a Slack app on https://api.slack.com/apps?new_app=1 and assign that to your workspace.
# Within this new app, go to "OAuth & Permissions" and in the section "Scopes > User Token Scopes" add the "files:read" and "files:write" Oauth scopes.
# Finally, you can now go to the top of the page and install the app to the workspace. After that you'll get the User OAuth Token that you can use on the script.
@IlanVivanco
IlanVivanco / BulmaModal.js
Last active April 5, 2021 14:21
Basic Javascript example for Bulma modals.
class BulmaModal {
constructor(modalButton) {
const target = modalButton.dataset.target;
if (target) {
this.button = modalButton;
this.modal = document.querySelector(target);
this.html = document.querySelector("html");
this.openEvent();
@IlanVivanco
IlanVivanco / .htaccess
Last active March 20, 2023 17:07
Rewrite local images to remote server.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^camunda\.test$
RewriteRule ^wp-content/uploads/(.*)$ https://camunda.com/wp-content/uploads/$1 [NC,L]
</IfModule>
@IlanVivanco
IlanVivanco / dotenv.sh
Last active April 8, 2021 17:50
Load environment variables from dotenv file in Bash
dotenv () {
set -a
[ -f .env ] && . .env
set +a
}
dotenv
# Create secure key
ssh-keygen -t rsa -b 4096 -C "key_identifier"
# Upload key to server
ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]