Skip to content

Instantly share code, notes, and snippets.

View jrobinsonc's full-sized avatar
😁
coding for fun

Jose Robinson jrobinsonc

😁
coding for fun
View GitHub Profile
@jrobinsonc
jrobinsonc / random-password.php
Last active December 12, 2020 17:08
Generate random passwords.
<?php
/**
* Generate random password
*
* @see <https://gist.github.com/jrobinsonc/ef4245a6e915a038f108e12980ac24bc>
* @param int $len Number of characters the password should have.
* @param string $types Types of characters the password should have.
* Options are: l for lowercase, u for uppercase, d for digital, s for special.
* @return string
#!/bin/bash
# Usage
# ./slack <channel> <message>
# ./slack @jrobinson "Test message for a user"
# ./slack #general "Test message for a channel"
CHANNEL=$1
MSG=$2
#!/bin/bash
# Usage
# ./logzio <type> <message>
# ./logzio info "My Message"
LOG=$2
TYPE=$1
ENV=PRO # Useful to identify which env is sending the log
rsync -va --exclude="node_modules/" --exclude=".git/" --exclude=".dev/" --delete /from-dir/ /to-dir
@jrobinsonc
jrobinsonc / sw-await.js
Last active May 7, 2020 12:22 — forked from bakoushin/sw-await.js
Service Worker: Promises vs Async/Await
const version = 1;
const appPrefix = 'myApp-';
const staticCacheName = appPrefix + 'static-v' + version;
const imagesCacheName = appPrefix + 'content-imgs';
var allCaches = [
staticCacheName,
imagesCacheName
];
self.addEventListener('message', event => {

Drupal Drush Cheatsheet

Generate snapshot of the database

drush sql-dump > db.sql

Import database

<?php
# Tested on Drupal 7
$user = user_load(1);
$user->mail = 'asdf@asdf.com';
$user->pass = '123';
user_save((object) array('uid' => $user->uid), (array) $user);
<?php
if ( false === ( $special_query_results = get_transient( 'special_query_results' ) ) ) {
// It wasn't there, so regenerate the data and save the transient
$special_query_results = new WP_Query( 'cat=5&order=random&tag=tech' );
set_transient( 'special_query_results', $special_query_results );
}
var_dump($special_query_results);
@jrobinsonc
jrobinsonc / get_current_url.php
Created March 2, 2020 14:49
Wordpress helper: Get current URL
<?php
/**
* Returns the current url.
*
* @return string
*/
function get_current_url() {
global $wp;