Skip to content

Instantly share code, notes, and snippets.

View jrobinsonc's full-sized avatar
🎯
Focusing

Jose Robinson jrobinsonc

🎯
Focusing
View GitHub Profile
```shell
grep DB_NAME wp-config.php | awk -F "'" '{print $4}'
grep DB_USER wp-config.php | awk -F "'" '{print $4}'
grep DB_PASSWORD wp-config.php | awk -F "'" '{print $4}'
```
DROP FUNCTION `quit_accents`;
CREATE FUNCTION `quit_accents`(str longtext)
RETURNS longtext CHARSET utf8
BEGIN
DECLARE result LONGTEXT;
SET result = str;
SET result = REPLACE(result, 'á', 'a');
SET result = REPLACE(result, 'é', 'e');
const fetch = options =>
new Promise((resolve, reject) => {
require('https').get(options, function(response) {
let body = '';
if (response.statusCode !== 200) {
reject(
new Error(`Request failed. Status code: ${response.statusCode}`),
);
#!/usr/bin/env sh
set -e
[ -d wp-admin ] || wp core download
[ -f wp-config.php ] || wp config create \
--dbhost="$WP_DB_HOST" \
--dbname="$WP_DB_NAME" \
--dbuser="$WP_DB_USER" \
@jrobinsonc
jrobinsonc / React-ErrorBoundary.md
Created February 24, 2019 04:17
React ErrorBoundary

File ErrorBoundary.js.

class ErrorBoundary extends React.Component {
  state = { hasError: false };

  static getDerivedStateFromError(error) {
    return { hasError: true };
  }
@jrobinsonc
jrobinsonc / README.md
Last active February 5, 2019 18:44
jquery.handleScroll

jQuery HandleScroll Plugin

Usage

Pretty simple:

jQuery(function($) {
  $( window ).handleScroll(function() {
 // going up
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@jrobinsonc
jrobinsonc / ask.sh
Created January 2, 2019 20:00
Bash General-Purpose Yes/No Prompt Function ("ask")
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
ask() {
# https://gist.github.com/davejamesmiller/1965569
local prompt default reply
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
@jrobinsonc
jrobinsonc / README.md
Last active January 12, 2019 23:16
Class to download packages from a SatisPress installation.

SatisPress Downloader

Usage

$downloader = new \Jrdev\SatisPressDownloader('https://domain.tld/satispress/packages.json', [
    // 'auth' => ['user', 'pass'], // Basic auth, if required.
    // 'baseDir' => __DIR__, // Base directory to create the sub-directories `cache` and `packages`.
    // 'versions' => 1, // How many versions of each package should be downloaded: 1 = the latest, 2 = the two latest versions, etc.
]);

OpenSSL

Verify Certificate Signing Request (.CSR) Contents:

openssl req -noout -text -in test.com.csr

Generate CSR