Skip to content

Instantly share code, notes, and snippets.

View danilostrazzullo's full-sized avatar

Danilo Strazzullo danilostrazzullo

View GitHub Profile
@danilostrazzullo
danilostrazzullo / highlight_results.php
Created January 9, 2017 10:49
WP highlight search terms in results
<?php
// Add '<b>' tags to search terms in results
function namespace_highlight_results($text){
if ( is_search() && !is_admin() ){
$sr = get_query_var('s');
$keys = explode(" ",$sr);
$keys = array_filter($keys);
$text = preg_replace('/('.implode('|', $keys) .')/iu', '<b>'.$sr.'</b>', $text);
}
return $text;
@danilostrazzullo
danilostrazzullo / mixins.scss
Last active March 15, 2017 11:03
Useful Sass Mixins
/// Responsive breakpoint manager
/// @access public
/// @param {String} $breakpoint - Breakpoint name
/// @requires $breakpoints
@mixin respond-to($breakpoint) {
$raw-query: map-get($breakpoints, $breakpoint);
@if $raw-query {
$query: if(
type-of($raw-query) == 'string',
@danilostrazzullo
danilostrazzullo / git-commands.md
Last active September 15, 2017 12:05
I can't memorize these Git commands

Changing a remote's URL

git remote set-url origin NEW_REMOTE_URL

Clone single branch from repo

git clone -b BRANCH_NAME --single-branch REPO_URL

@danilostrazzullo
danilostrazzullo / countries.md
Last active October 9, 2018 14:39
ACF World Countries key-value pairs

AFG : Afghanistan
AGO : Angola
ALB : Albania
ARE : United Arab Emirates
ARG : Argentina
ARM : Armenia
ATA : Antarctica
ATF : French Southern and Antarctic Lands
AUS : Australia
AUT : Austria

@danilostrazzullo
danilostrazzullo / parallax-ish.js
Created November 28, 2018 09:29
Parallax-like interaction
// Parallax-like interaction "stolen" from https://www.awwwards.com/PWA-ebook
window.addEventListener('mousemove', move);
function move(){
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
window_width = w.innerWidth||e.clientWidth||g.clientWidth,

Reset mysql root password in Mac OS:

First Stop MySQL:

  1. Go to: 'System Preferences' >> 'MySQL' and stop MySQL

OR,

  1. sudo /usr/local/mysql/support-files/mysql.server start
  2. sudo /usr/local/mysql/support-files/mysql.server stop