Skip to content

Instantly share code, notes, and snippets.

@gboone
gboone / maybe_flush.php
Last active December 21, 2015 10:49
Tired of hitting the Save Permalinks button every time you register a post type in WordPress? Try this function: it grabs the cached rewrite rules, checks for a target (could be anything, but let's say it's a post type with an archive) and flushes the rules if the rewrite rule isn't present.
<?php
function maybe_flush_rewrite_rules($target) {
$rules = get_option( 'rewrite_rules' );
if ( $rules[ $target . '/?$' ] != 'index.php?post_type=' . $target ) {
flush_rewrite_rules( $hard = true );
}
}
@gboone
gboone / wp-cli-notes.md
Created March 4, 2014 22:55
WP-CLI notes
  • Will install a plugin from a url: wp plugin install https://github.com/gboone/simple-open-graph/archive/master.zip --activate
  • GitHub will make a different zip file for every branch, tag, or even commit, observe! https://github.com/gboone/open-graph-control/archive/4c4611a9c35f269d5d5dab7b6a8fc6697e0a5341.zip
  • Thus wp plugin install https://github.com/gboone/open-graph-control/archive/4c4611a9c35f269d5d5dab7b6a8fc6697e0a5341.zip --activate will install and activate the plugin at that specific commit

Keybase proof

I hereby claim:

  • I am gboone on github.
  • I am gboone (https://keybase.io/gboone) on keybase.
  • I have a public key whose fingerprint is 0372 5539 C7B7 085F AD02 9FEE 7838 1DF8 B3E3 537A

To claim this, I am signing this object:

@gboone
gboone / download_from_yml.rb
Created November 14, 2014 17:54
Download files from a yaml file
##
# Where yaml file looks like:
# ---
# directory:
# - url
# directory2:
# - url
# ---
# Script will create the directories if they need creating
# and download the resource at each url into that directory
@gboone
gboone / yomyoffice.py
Created November 27, 2014 14:50
YOMYOFFICECLOSED
import requests
import os
url = 'http://www.opm.gov/json/operatingstatus.json'
yourl = 'https://api.justyo.co/yoall/'
yokey = os.environ['YO_KEY']
status = requests.get(url)
openclosed = status.json()['Icon']
if openclosed == u'Closed':
requests.post(yourl, data={'api_token': yokey, 'username': 'YOMYOFFICECLOSED', 'link': status.json()['StatusWebPage']});
@gboone
gboone / .vimrc
Created January 7, 2015 21:38
.vimrc
syntax on
set columns=80
set ruler
set wrapmargin=5
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set backspace=2
@gboone
gboone / danger-alias
Created March 16, 2015 19:35
Dangerous git aliases
alias.yolo="commit -am && git push -f"
@gboone
gboone / pre-commit.imgoptim
Last active August 29, 2015 14:17
A commit hook to run imageoptim on all images in your assets/ directory
#!/bin/sh
#
# A pre-commit hook that runs Image Optim against all images in the /assets
# directory. Requires you have Image Optim installed and will fail silently if
# you don't have it installed to /Applications/. Image optim will skip any
# images already optimized but this may take time, especially if you've never
# run it before or have many images. Rename this pre-commit and move to your
# project's .git/hooks/ directory
#
# /Applications/ImageOptim.app/Contents/MacOS/ImageOptim *.png
@gboone
gboone / gist:588fb6d644e10cffc1e9
Created April 8, 2015 19:15
Notes on GitHub for Mac

Features I wish GitHub for Mac had:

  • A view showing the folder structure
  • Ability to edit markdown files w/in application (or Atom integration)
  • Ability to send someone a link to a pull request to merge it
  • Ability to comment on pull requests/issues
  • Stash visualization
  • "Open in GitHub for Mac" makes almost no sense when it eventually opens in vim
  • Doesn't tell you about merge conflicts, just leaves them in the files.
@gboone
gboone / draft-format
Created May 11, 2015 14:53
18F Blog Draft format
## Audience:
## Goal of the Post:
## Imagery ideas:
## Description:
## Who needs to clear?