Skip to content

Instantly share code, notes, and snippets.

View robertocinetto's full-sized avatar

Roberto Cinetto robertocinetto

View GitHub Profile
@robertocinetto
robertocinetto / command-line-cheatsheet.md
Created June 21, 2023 15:40
Command Line Cheatsheet

OB staging-001 ssh -p 0705 [email protected] OR Use client slug as user to get to that folder

Monitor log file for wp-env from WP container CLI in Docker tail -f wp-content/debug.log —OR— From project root: npm run wp-env run cli bash

# Using ZSH check if a .nvmrc file exists in the current directory and automatically use the correct version of Node.js
# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
@robertocinetto
robertocinetto / Collapse last n commit
Created July 7, 2022 05:06
Collapse last n commits
git reset --soft HEAD~9
@robertocinetto
robertocinetto / CSSConsoleLog.scss
Last active June 22, 2022 16:15
CSS "console.log()" - set of CSS rules to highlight sections and containers in order to debug bad styles
* {
box-sizing: border-box;
background: rgb(0 100 0 / 0.05) !important;
// or
// outline: 3px solid limegreen !important;
}
@robertocinetto
robertocinetto / useLocalStorage.js
Last active June 21, 2022 17:59
useLocalStorage.js - React custom hook that inherits useState functionality and store value on browser local storage. Needs a key to be passed together with the value.
import { useState, useEffect } from "react";
// get already saved value from local storage
function getSavedValue(key, initialValue) {
//retrieve value from local storage
const savedValue = JSON.parse(localStorage.getItem(key));
//check if a value for that key already exists
if (savedValue) return savedValue;
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDu9kcgfuS8pooYzg+aQbWNluOgcltCMDBR3rpQfjR95AiUEYs/XyU9cfGF23ATGvP0HCc+8x2BjfaCe8+Zd+B1ID6eNzZSng8tvkvcf51Pzk0e1Ssi07ihTUfBvg1f6rTR0n6zKbyb4OfQJdqWizAawVYeJWVOMnjaeLF0URwMHAk0GhQZQpX5tO6CG+kciZQIgLcZzQ5JiKeLfgVX94krpW18EqDfId/ovcUnj3gCcLGqVcRBsYzNOWYNh5HDU268t9WY1vT/HZ6IqhFhAFcUYNDCPg6d9azW9sR/l3VH17e9t5wUfEontM/eyeUHZUH3GfvmAae2hBH+X/7BZMr9 [email protected]
@robertocinetto
robertocinetto / rake db tasks
Created October 10, 2014 16:22
A list of all rake db tasks for rails
db:create creates the database for the current env
db:create:all creates the databases for all envs
db:drop drops the database for the current env
db:drop:all drops the databases for all envs
db:migrate runs migrations for the current env that have not run yet
db:migrate:up runs one specific migration
db:migrate:down rolls back one specific migration
db:migrate:status shows current migration status
db:rollback rolls back the last migration
db:forward advances the current schema version to the next one