Skip to content

Instantly share code, notes, and snippets.

View JParkinson1991's full-sized avatar

Josh Parkinson JParkinson1991

  • Rural Insurance
  • England
View GitHub Profile
@JParkinson1991
JParkinson1991 / drush_db_export_import.md
Created October 17, 2019 14:16
Drush Database Export/Import Commands

Drush Database Export/Import Commands

# Clear cache
$ drush cc # Drupal 6 & 7
$ drush cr # Drupal 8

# Export Database
$ drush sql-dump > ~/database.sql

Import Database

@JParkinson1991
JParkinson1991 / gitcheatsheet.md
Created December 11, 2019 09:36
GIT Cheetsheet

GIT Cheatsheet

Contents

Interactive Rebase

Useful for altering one or multiple commits. Squashing them into a single commit etc.

@JParkinson1991
JParkinson1991 / cli-versions.md
Last active January 6, 2020 08:35
CLI Version Numbers

CLI Version Numbers

This Gist contains handy snippets for extracting just the version number from various application version strings.

At the time of writing, the majority of these snippets were created for applications installed on a MAC via Homebrew. Please feel free to provide snippets for unsupported setups if required.

Contents

#!/usr/bin/env bash
# For current version see:
# https://github.com/JParkinson1991/bin/blob/master/google-chrome
# Wraps cli usage of google chrome on MacOS
#
# Requirments: Google Chrome
#
# Run in default mode, open/visible browser, environment defined address/port
@JParkinson1991
JParkinson1991 / npm_link.md
Last active April 21, 2020 08:54
Local Package Development via NPM Link
@JParkinson1991
JParkinson1991 / .editorconfig
Created April 23, 2020 10:52
Base File: .editorconfig
# This is the top-most .editorconfig file; do not search in parent directories.
root = true
# Default configuration
[*]
end_of_line = LF
indent_style = space
indent_size = 4
charset = utf-8
trim_trailing_whitespace = true
@JParkinson1991
JParkinson1991 / .gitignore
Created April 23, 2020 10:53
Base File: .gitignore
# ==============================================================================
# Project Ignores
#
# - Place project specific ignore statements in this section.
# ==============================================================================
# ==============================================================================
# Dreamweaver Ignores
#
# - Notes
@JParkinson1991
JParkinson1991 / get_json_value.sh
Last active June 17, 2020 09:10
Bash Functions: GET JSON Values
#!/usr/bin/env bash
# Extracts a json value from a json containing string
#
# Usage:
# get_json_value <key> [occurrence]
#
# Examples:
# echo $string | get_json_value theKey 1
# cat file.json | get_json_value theKey
@JParkinson1991
JParkinson1991 / envsubst-recursive.sh
Last active September 17, 2020 13:17
envsubst-recursive.sh
#!/usr/bin/env bash
# Usage envsubst-recursive.sh [source root]
# Options:
# -a|--append - Set string to append to processed source file names
# -f|--filter - Set the filename filter (only process files matching this filter)
# -o|--output - Set the output directory for substituted file
# -q|--quiet - Enable quiet mode, no script output
# -v|--variables - Set the variable names to replace only. IMPORTANT: Single quote this argument
# Script variable defaults
@JParkinson1991
JParkinson1991 / bash_script_source.sh
Last active January 2, 2021 14:52
Get bash script source directory (follow symlinks etc)
#!/bin/bash
# Taken from answer: https://stackoverflow.com/questions/59895/how-to-get-the-source-directory-of-a-bash-script-from-within-the-script-itself/246128#246128
# Option 1: One Liner
#
# "It will work as long as the last component of the path used to find the script is not a symlink (directory links are OK)"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Option 2: Bulletproof
#