Skip to content

Instantly share code, notes, and snippets.

@pryley
pryley / phpv
Created February 8, 2017 03:27
Switch PHP versions for Laravel Valet
#!/bin/bash
# Check that homebrew is installed
if [[ "" == "$(command -v brew)" ]]; then
echo "switch-php requires homebrew to manage installed versions of PHP."
exit 1
fi
# Check if command was ran as root.
if [[ $(id -u) -eq 0 ]]; then

Keybase proof

I hereby claim:

  • I am pryley on github.
  • I am pryley (https://keybase.io/pryley) on keybase.
  • I have a public key ASCIgelMI6dpyCg15fHavShFYmjSZ3ERl3GebPxokuGHOwo

To claim this, I am signing this object:

@pryley
pryley / delete-from-repo.md
Created May 6, 2016 17:09 — forked from scy/delete-from-repo.md
How to delete a file from a Git repository, but not other users' working copies

How to delete a file from a Git repository, but not other users' working copies

Suppose you have, by mistake, added your IDE's project folder (you know, these .idea folders with all kinds of local paths and configuration data and settings in it) to the Git repository of your project. (We're talking about a whole folder here, but the same rules apply to individual files as well.)

Of course, you only realize that two days after the fact and have already pushed it, and your colleagues have already pulled it. They use the same IDE as you do, so whenever they change a setting or fix paths, they can either

  • commit that, causing nasty merge conflicts for you and others or
  • ignore the changes and carry around a modified file until the end of time without ever committing it.

Why .gitignore won't help

<?php
/**
* Plugin Name: print__r()
* Description: print_r() alternative
* Version: 1.0.0
* Author: Paul Ryley
* Author URI: http://geminilabs.io
*/
/**
@pryley
pryley / deploy.rb
Created February 6, 2016 22:40
Capistrano global WP deploy config
set :application, 'myapp'
set :repo_url, "git@bitbucket.org:geminilabs/#{fetch(:application)}.git"
SSHKit.config.command_map[:composer] = '/srv/users/serverpilot/bin/composer'
set :wpcli, '/srv/users/serverpilot/bin/wp'
# Branch options
# Prompts for the branch name (defaults to current branch)
#ask :branch, -> { `git rev-parse --abbrev-ref HEAD`.chomp }
#!/bin/bash
THEPATH=${1%/}
THESIZE=$2
if [ -z $THEPATH ];
then THEPATH="/"
fi
[[ -n "$2" ]] || { echo -en "\n usage: getsize [path] [size (the min size in Mb)]\n example: getsize ~/Downloads 13\n\n"; exit 0 ; }
@pryley
pryley / UltimateMembersMods
Created May 4, 2015 22:45
This Wordpress plugin adds custom features and modifications to the Ultimate Member plugin family.
<?php
/**
* Plugin Name: Ultimate Member Modifications
* Plugin URI: http://geminilabs.io
* Description: This plugin adds custom features and modifications to the Ultimate Member plugin family.
* Version: 1.0.0
* Author: Gemini Labs
* Author URI: http://geminilabs.io
* License: MIT License
*/
module.exports = function( grunt )
{
'use strict';
grunt.initConfig( {
clean: {
dist: [
'public/assets/css/*',
]
},
@pryley
pryley / Simple Custom Post Order - hook
Last active August 29, 2015 13:56
This adds a hook to the `Simple Custom Post Order` plugin `update_menu_order()` function.
function update_menu_order() {
global $wpdb;
parse_str( $_POST['order'], $data );
if ( is_array( $data ) ) {
$id_arr = array( );
foreach ( $data as $key => $values ) {
@pryley
pryley / gist:7746379
Last active December 29, 2015 23:59
Frontend google analytics snippet
<?php
try {
if( $access_token ) {
// Set access token
$client->setAccessToken( $access_token );
// Assign variables
$slug_array = $filter_path_array = $filter_array = $data = array();