Skip to content

Instantly share code, notes, and snippets.

View christianhanvey's full-sized avatar

Christian Hanvey christianhanvey

View GitHub Profile
@sindresorhus
sindresorhus / post-merge
Last active May 2, 2024 03:18
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `npm install` if package.json changed and `bower install` if `bower.json` changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
@Flygenring
Flygenring / toResourceField.snippet.php
Last active March 28, 2022 21:47
MODX Snippet to get a field from a resource based on a supplied resource id, meant to be used as an output filter.
<?php
/**
* Gets a field from a resource based on a supplied resource id, meant to be used as an output filter.
*
* Based on a resource ID a field can be retrieved. This can be standard fields as 'pagetitle' or 'alias',
* but a few custom fields are also available; 'siblingNextId', 'childrenFirstId', and 'childrenCount'.
* Only resources that are not marked as 'deleted' or 'hidemenu', and that is marked as 'published' are returned.
* Examples:
* [[*id:toResourceField]] => returns the resource pagetitle
* [[*id:toResourceField=`alias`]] => returns the resource alias
@christianhanvey
christianhanvey / modx-upgrade.sh
Last active November 1, 2017 16:40
A shell script to help automate the upgrade of a MODX Revolution installation
#!/bin/bash
# modx-upgrade.sh
# ---------------
# A shell script to help automate the upgrade of a MODX Revolution installation
# This script is for traditional installations only - not advanced
#
# Instructions:
# 1. Update the config section with your own site specific details
# 2. Upload this file to your server, preferably outside of web root
@silentworks
silentworks / gist:3608022
Created September 3, 2012 09:07
MODX Resource List with Type Ahead

Create a new Template Variable

Go to Input Options Tab

Change Input Type to:

  • Listbox (Multi-Select) - for multiple resource select
  • Listbox (Single-Select) - for Single resource select

In Input Option Values type: @SELECT `pagetitle` AS `name`,`id` FROM `[[+PREFIX]]site_content` WHERE `published` = 1 AND `deleted` = 0

@krismas
krismas / argv.php
Last active August 3, 2019 16:37
A small MODX snippet to extract POST, GET, SESSION & COOKIE values
<?php
/*
* A small MODX snippet to extract POST, GET, SESSION & COOKIE values - (c) 2012-2016 ackwa.fr
*
* @version : 1.0.4
* @see : https://gist.github.com/gists/2853625
* @name : argv.php
* @author : g.noel@ackwa.fr
* @usage : [[!argv?key=`myparam`&default=`1`]] -> return the value
* [[!argv?key=`myparam`&default=`1`&toph=`1`]] -> set [[+argv.myparam]]
@vasilisvg
vasilisvg / more.md
Last active December 4, 2020 04:48
This is my backup script which syncs my server to my dropbox every day.

The script below is triggered every day from my Mac. I use Hazel to move the tar.gz to an external hard disk once it's finished. This happens every day without me noticing. You can exclude folders if you want to. You probably want to exclude giant cache folders.

You should have a similar script.

@JeffreyWay
JeffreyWay / gist:1525217
Created December 27, 2011 21:29
Instant Server for Current Directory
alias server='open http://localhost:8000 && python -m SimpleHTTPServer'
@rosstimson
rosstimson / modx-git-bootstrap.sh
Created December 20, 2011 18:01
Quickly Bootstrap MODX (Revo) from Git Repo
#!/bin/sh
# Request and read in db details from user
echo "Please enter your database hostname
(e.g. localhost) and press [ENTER]:"
read db_host
echo "Please enter your MODX database name and press [ENTER]:"
read db_name
echo "Please enter your MODX database user and press [ENTER]:"
read db_user
@bfncs
bfncs / defaultTemplateByParentTv.plugin.php
Created December 13, 2011 23:55
Default Children Template by Parent TV - modX Revolution Plugin
<?php
/**
* =========================
* defaultTemplateByParentTv
* =========================
*
* Plugin for modX Revolution
* Set default template for children of a ressource
*
* Author:
@oksushi
oksushi / MODCreateSubdocs
Created October 14, 2011 02:40
MODX: Plugin to create sub document on save - apply OnDocFormSave
<?php
if ($mode == 'new') {
$new = $modx->newObject('modDocument');
$new->set('parent',$id);
$new->set('pagetitle','My New Pagetitle');
$new->save();
}