Skip to content

Instantly share code, notes, and snippets.

View mozmorris's full-sized avatar

Moz Morris mozmorris

View GitHub Profile
@mozmorris
mozmorris / com.mozmorris.StaticRoutes.plist
Created March 3, 2014 23:14
Create static routes on login (doesn't work unfortunately)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.mozmorris.StaticRoutes</string>
<true/>
<key>ProgramArguments</key>
<array>
<string>sh</string>
@mozmorris
mozmorris / fix.md
Created February 2, 2013 10:19
Fix RubyGems on CentOS after installation with Vagrant & Chef

Depending on the box used for the VM, the version of RubyGems might need updating. On the first attempt trying to install the Sinatra gem, I received the following message:

WARNING: RubyGems 1.2+ index not found for: http://rubygems.org/

Well 1.2 is out of date, let's fix that:

$ sudo gem update --system

On the second attempt, I got this error:

@mozmorris
mozmorris / expires.php
Created February 11, 2013 16:15
CakePHP "Expires" behavior. Works with 1.2. I don't think any changes are required to get it working with 2.0. Ensure you've added `expiry_date` (DATE) column to your model table.
<?php
class ExpiresBehavior extends ModelBehavior {
protected $_defaults = array(
'field' => 'expiry_date'
);
/**
* Setup this behavior with the specified configuration settings.
@mozmorris
mozmorris / redirect_to_child.php
Last active December 16, 2015 10:48
Redirect to first child WordPress template
<?php
/*
Template Name: Redirect to First Child
*/
$children = get_pages( "child_of=" . $post->ID . "&sort_column=menu_order" );
if ($children) {
wp_redirect( get_permalink( $children[0]->ID ) );
}
@mozmorris
mozmorris / ExtendedFormAuthenticate.php
Created January 5, 2012 15:15
ExtendedFormAuthenticate class that overrides CakePhp's FormAuthenticate class
<?php
App::uses('FormAuthenticate', 'Controller/Component/Auth');
class ExtendedFormAuthenticate extends FormAuthenticate
{
public function authenicate(CakeRequest $request, CakeResponse $response) {
$userModel = $this->settings['userModel'];
list($plugin, $model) = pluginSplit($userModel);
$fields = $this->settings['fields'];
@mozmorris
mozmorris / composer.json
Last active July 8, 2016 06:51
example php app using php's built-in server (npm run backend)
{
"name": "MozMorris/phpapp",
"require": {
"slim/views": "~0.1.3",
"twig/twig": "~1.0"
}
}
@mozmorris
mozmorris / actions.js
Created September 15, 2016 15:57
Example of generating request (fetch, success, failure) flux actions
const REQUEST = 'REQUEST';
const SUCCESS = 'SUCCESS';
const FAILURE = 'FAILURE';
/**
* Returns request constants (request, success, failure) for a given action
* @param {String} action The request action (e.g. GET_CUSTOMER)
* @return {object} Object containing the contstants
*/
function constantsCreator(action) {
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->