Skip to content

Instantly share code, notes, and snippets.

View rpowis's full-sized avatar
🤖
beep boop

Rory Powis rpowis

🤖
beep boop
View GitHub Profile
#!/bin/bash
SOLERIZED='{
"Ansi 0 Color" = {
"Blue Component" = 0.19370138645172119;
"Green Component" = 0.15575926005840302;
"Red Component" = 0.0;
};
"Ansi 1 Color" = {
"Blue Component" = 0.14145714044570923;
@rpowis
rpowis / rpowis.zsh-theme
Last active December 15, 2017 11:19
rpowis ohmyzsh theme
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
function get_pwd() {
print -D $PWD
}
function put_spacing() {
@rpowis
rpowis / force-download-remote-file.php
Last active October 5, 2021 22:44
Check for remote file and force the user to download if it exists.
$file = 'http://www.example.com/path/to/file.ext';
$headers = array_change_key_case(get_headers($file, TRUE));
$filesize = $headers['content-length'][1];
if ( $headers[0] != 'HTTP/1.1 404 Not Found' ) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
@rpowis
rpowis / pre-commit-db-export
Last active December 15, 2015 03:59
Export DB to temp file on git commit. If the export fails delete the temp file, otherwise overwrite the tracked file.
#!/bin/sh
#
# A hook script to export your database on every commit.
#
# The export is saved to a temp file. If the export
# fails, the file is trashed. Otherwise it overwrites the tracked file.
#
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
@rpowis
rpowis / prepare-commit-msg
Created April 25, 2013 18:55
prepare-commit-msg git hook that adds the branch name to the end of the commit message
#!/bin/sh
#
# This hook will append the current branch name to
# the commit message if it's not already there.
ref=$(git symbolic-ref HEAD 2> /dev/null)
branch=${ref#refs/heads/}
if [[ "$branch" != "master" ]]; then
grep -qa "$branch" "$1" || echo "\n[Branch: $branch]" >> "$1"
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@rpowis
rpowis / post-merge
Last active April 7, 2017 17:49
Git hook to fix permissions on mediatemple dv after a git pull
#!/usr/bin/env bash
#
# How to use this file:
#
# 1. Clone/copy this gist into the .git/hooks directory
# 2. Enter the website's domain and server's admin username in the variables
# 3. Make the file executable using: $ chmod +x post-merge
#
@rpowis
rpowis / .htaccess
Created August 29, 2013 15:30
Hash URL rewrite in .htaccess From `/articles/fragment` to `/articles.html#fragment`
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !articles\.html [NC]
RewriteCond %{REQUEST_URI} ^/articles/([^/]+)/? [NC]
RewriteRule .* /articles.html#%1 [R,NE,L]
@rpowis
rpowis / cli-tricks.sh
Created September 12, 2013 09:14
Command line tricks and one-liners
#
# This is a list of useful commands and one-liners to make
# life on the command line easier
#
# Create complex directory structures
$ mkdir -p project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat/a}
# Option -C to unpack a .tar archive file to a location
$ tar xvf -C tmp/a/b/c newarc.tar.gz
@rpowis
rpowis / git-tricks
Created October 8, 2013 12:55
Git tricks
# Apply a patch from another (unrelated) local repository
$ git --git-dir=../some_other_repo/.git format-patch -k -1 --stdout <commit SHA> | git am -3 -k
# Checout an empty branch to do something radically different (i.e. gh-pages)
$ git checkout --orphan <new_empty_branch>
# Find the root of the project
$ git rev-parse --show-toplevel
# Change to the root of the project