Skip to content

Instantly share code, notes, and snippets.

View danilostrazzullo's full-sized avatar

Danilo Strazzullo danilostrazzullo

View GitHub Profile

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
@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,
@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 / 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 / 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 / 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 / wp-autopopulate-taxonomy
Created November 18, 2016 17:13 — forked from brenna/wp-autopopulate-taxonomy
WordPress function to auto-populate a taxonomy with a custom post type's entries.
function custom_tax_init(){
//set some options for our new custom taxonomy
$args = array(
'label' => __( 'My Custom Taxonomy' ),
'hierarchical' => true,
'capabilities' => array(
// allow anyone editing posts to assign terms
'assign_terms' => 'edit_posts',
/* but you probably don't want anyone
@danilostrazzullo
danilostrazzullo / namespace_remove_inherited_sidebars.php
Last active July 27, 2016 15:01
Remove Custom Sidebars inheritance for child pages [ if you improve this solution, please, let me know :) ]
<?php
/**
* Remove Custom Sidebars inheritance for child pages
*
* The issue is described at the following link
* @link https://wordpress.org/support/topic/option-to-remove-inheritance
*/
function namespace_remove_inherited_sidebars( $replacements ) {
global $post;
@danilostrazzullo
danilostrazzullo / import-dump.sh
Created May 4, 2016 14:02
Import a large sql dump file to a MySQL database from command line
#!/bin/sh
# Import a large sql dump file to a MySQL database from command line
# https://cmanios.wordpress.com/2013/03/19/import-a-large-sql-dump-file-to-a-mysql-database-from-command-line/
# store start date to a variable
imeron=`date`
echo "Import starting..."
dumpfile="/path/to/dumpfile.sql"
@danilostrazzullo
danilostrazzullo / Vagrantfile
Created April 13, 2016 09:09 — forked from JeffreyWay/Vagrantfile
Quickie vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :private_network, ip: "192.168.33.21"