Skip to content

Instantly share code, notes, and snippets.

View jrobinsonc's full-sized avatar
😁
Having fun

Jose Robinson jrobinsonc

😁
Having fun
View GitHub Profile
@jrobinsonc
jrobinsonc / hidewpadminbar.php
Last active February 12, 2020 17:11
WordPress Plugin: Hide WP Admin Bar
<?php
/*
Plugin Name: Hide WP Admin Bar
Plugin URI: https://gist.github.com/jrobinsonc/fd229cef8df0e38205c0b96f2e455d16
Description: Hides the WordPress admin bar by clicking on the logo of the admin bar.
Author: Jose Robinsosn
Version: 1.0
Author URI: https://joserobinson.com
*/
@jrobinsonc
jrobinsonc / get_the_url.php
Last active February 10, 2020 22:10
Wordpress helper: Get the slug - Get the slug of a post or page.
<?php
function get_current_url() {
global $wp;
return home_url( $wp->request );
}
```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"