Skip to content

Instantly share code, notes, and snippets.

View enricodeleo's full-sized avatar

Enrico Deleo enricodeleo

View GitHub Profile
@enricodeleo
enricodeleo / taxonomies.php
Last active December 1, 2022 16:21
Get and list all the taxonomies attached to a custom post type in Wordpress
<?php
$taxonomy_objects = get_object_taxonomies( 'cpt', 'objects' ); // <--- change cpt with the custom post type
$out = array();
foreach ( $taxonomy_objects as $taxonomy_slug => $taxonomy ){
$terms = get_terms( $taxonomy_slug, 'hide_empty=0' );
if ( !empty( $terms ) ) {
$out[] = "<strong>" . $taxonomy->label . "</strong>\n<ul>";
foreach ( $terms as $term ) {
$out[] =
" <li>"
@enricodeleo
enricodeleo / my.cnf
Created March 1, 2014 14:15
MySQL optimized my.cnf for Magento store on 1GB ram VPS
[mysqld]
# GENERAL #
user = mysql
default-storage-engine = InnoDB
socket = /var/lib/mysql/mysql.sock
pid-file = /var/lib/mysql/mysql.pid
# MyISAM #
key-buffer-size = 32M
@enricodeleo
enricodeleo / ios-chrome-devtools.md
Created June 22, 2021 16:55 — forked from james2doyle/ios-chrome-devtools.md
Enable remote debugging on the iOS simulator using Chrome Dev Tools

Install the tools:

brew install ios-webkit-debug-proxy

Run the simulator. And choose an iOS 10 device. The chrome remote debugging doesn't work with iOS 11 yet.

Enable the inspector

@enricodeleo
enricodeleo / sdxc-reload.sh
Created June 22, 2015 07:13
Reload SD Card reader on OS X
sudo kextunload /System/Library/Extensions/AppleStorageDrivers.kext/Contents/PlugIns/AppleUSBCardReader.kext;
sudo kextload /System/Library/Extensions/AppleStorageDrivers.kext/Contents/PlugIns/AppleUSBCardReader.kext
@enricodeleo
enricodeleo / margin-padding.sass
Last active November 17, 2017 21:06
Loop that generates margin and padding class helpers
// loop that generates margin ad padding helper classes
// the output is like .margin-5, .margin-top-5, margin-right-5 etc...
$properties: (margin, padding);
$sides: (top, right, bottom, left);
@each $prop in $properties {
@for $i from 1 through 14 {
.#{$prop}-#{$i*5} {
#{$prop}: #{$i*5}px !important;
}
@each $side in $sides {
@enricodeleo
enricodeleo / destructuring.js
Created May 19, 2017 03:36 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@enricodeleo
enricodeleo / .htaccess
Created November 7, 2016 21:23
Compressing + caching with htaccess
# Deflate
<IfModule mod_filter.c>
#Add deflate
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/javascript" \
"application/json" \
"application/ld+json" \
"application/manifest+json" \
"application/rdf+xml" \
@enricodeleo
enricodeleo / wp-query-ref.php
Created July 10, 2016 08:09 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@enricodeleo
enricodeleo / angular-jst.js
Created June 17, 2016 00:33
Angular 1.x module that takes advantage of JST for templating
angular
.module('angularJst', [])
.config([
'$provide',
function($provide) {
$provide.decorator('$templateCache', function($delegate, $sniffer) {
var originalGet = $delegate.get;
$delegate.get = function(key) {
var value;
@enricodeleo
enricodeleo / countWatchers.js
Created June 15, 2016 15:32
Count Angularjs 1.x watchers
(function countWatchers()
{
var root = angular.element(document.getElementsByTagName('body')).injector().get('$rootScope');
var count = root.$$watchers ? root.$$watchers.length : 0; // include the current scope
var pendingChildHeads = [root.$$childHead];
var currentScope;
while (pendingChildHeads.length)
{
currentScope = pendingChildHeads.shift();