Skip to content

Instantly share code, notes, and snippets.

@mmcachran
mmcachran / gist:5a9a459aea335494fb71
Created June 27, 2012 16:05
Expression Engine 2 Queries
# Fetch Channel Fields
SELECT
fg.group_id,
fg.group_name,
cf.field_id,
cf.field_label,
cf.field_order,
cf.field_name,
cf.field_type
FROM
@mmcachran
mmcachran / annoying.js
Last active August 29, 2015 14:11 — forked from Kilian/annoying.js
/**
* Annoying.js - How to be an asshole to your users
*
* DO NOT EVER, EVER USE THIS.
*
* Copyright (c) 2011 Kilian Valkhof (kilianvalkhof.com)
* Visit https://gist.github.com/767982 for more information and changelogs.
* Visit http://kilianvalkhof.com/2011/javascript/annoying-js-how-to-be-an-asshole/ for the introduction and weblog
* Check out https://gist.github.com/942745 if you want to annoy developer instead of visitors
*
@mmcachran
mmcachran / gist:052a24dd3d1465e58f7a
Last active August 29, 2015 14:21
Get posts by taxonomy
SELECT DISTINCT
post_title,
post_type,
wp_terms.*
FROM wp_posts
LEFT JOIN wp_postmeta
ON(wp_posts.id = wp_postmeta.post_id)
LEFT JOIN wp_term_relationships
ON(wp_posts.id = wp_term_relationships.object_id)
INNER JOIN wp_term_taxonomy
@mmcachran
mmcachran / gist:4104bf7f2917b9617f50
Last active January 12, 2021 13:12
ElasticSearch Notes
== VM for local dev ==
https://github.com/mmcachran/vagrant-elasticsearch-cluster
Add to WP config or in EP settings:
define( 'EP_HOST', 'http://10.0.0.11:9200' );
Indexing your local
wp elasticpress index --setup --network-wide
== To index large multinetwork sites ==
@mmcachran
mmcachran / gist:d5492419516c65212308
Created March 17, 2016 13:43 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter

@mmcachran
mmcachran / mysql_backup.sh
Created August 28, 2020 18:32 — forked from tleish/mysql_backup.sh
Bash Script to backup all MySQL databases
#!/bin/bash
#==============================================================================
#TITLE: mysql_backup.sh
#DESCRIPTION: script for automating the daily mysql backups on development computer
#AUTHOR: tleish
#DATE: 2013-12-20
#VERSION: 0.4
#USAGE: ./mysql_backup.sh
#CRON:
# example cron for daily db backup @ 9:15 am
---
# Page meta info, like heading, footer text and nav links
pageInfo:
title: Dashy
description: Welcome to your new dashboard!
navLinks:
- title: GitHub
path: https://github.com/Lissy93/dashy
- title: Documentation
path: https://dashy.to/docs
@mmcachran
mmcachran / script-template.sh
Created February 10, 2023 17:45 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@mmcachran
mmcachran / npm-scripts-for-docker.md
Created April 10, 2023 17:56 — forked from duluca/npm-scripts-for-docker.md
npm scripts for Docker

These are generic npm scripts that you can copy & paste into your package.json file as-is and get access to convinience scripts to manage your Docker images all in one place.

How to Use

npm i -g mrm-task-npm-docker
npx mrm npm-docker

Contribute

Here's the code repository https://github.com/expertly-simple/mrm-task-npm-docker

@mmcachran
mmcachran / css-units-best-practices.md
Created September 21, 2023 12:40 — forked from basham/css-units-best-practices.md
CSS Units Best Practices

CSS units

Recommendations of unit types per media type:

Media Recommended Occasional use Infrequent use Not recommended
Screen em, rem, % px ch, ex, vw, vh, vmin, vmax cm, mm, in, pt, pc
Print em, rem, % cm, mm, in, pt, pc ch, ex px, vw, vh, vmin, vmax

Relative units

Relative units