Skip to content

Instantly share code, notes, and snippets.

View ryanirelan's full-sized avatar

Ryan Irelan ryanirelan

View GitHub Profile
@ryanirelan
ryanirelan / sw.js
Created February 7, 2019 15:34
Service worker for pre-caching pages for offline use. From CraftQuest livestream: https://craftquest.io/livestreams/what-are-service-workers
// borrowed mightily from Fillament Group - https://www.filamentgroup.com/lab/modernizing-delivery.html
/*jshint esversion: 6 */
/*jshint strict:false */
/*global self:true */
/*global caches:true */
/*global Response:true */
/*global Request:true */
(function(){
@ryanirelan
ryanirelan / app.php
Last active October 22, 2023 19:46
app.php configuration for using Redis and Craft CMS 3
<?php
/**
* Yii Application Config
*
* Edit this file at your own risk!
*
* The array returned by this file will get merged with
* vendor/craftcms/cms/src/config/app.php and app.[web|console].php, when
* Craft's bootstrap script is defining the configuration for the entire
* application.
{# Using the example code from the docs #}
{% set searchQuery = craft.app.request.getParam('q') %}
{% set entries = craft.entries()
.search(searchQuery)
.orderBy('score')
.all() %}
{# You can do something like this where you just output the Section name #}
{% for entry in entries %}
<h4>{{ entry.section }}</h4>
# The environment Craft is currently running in ('dev', 'staging', 'production', etc.)
ENVIRONMENT="dev"
# The secure key Craft will use for hashing and encrypting data
SECURITY_KEY=""
# The database driver that will used ('mysql' or 'pgsql')
DB_DRIVER="mysql"
# The database server name or IP address (usually this is 'localhost' or '127.0.0.1')
@ryanirelan
ryanirelan / .gitconfig
Created April 20, 2016 19:20
git-alias
[alias]
zip = archive --format=zip -o latest.zip HEAD
yesterday = log --before={`date \"+%Y-%m-01\"`} --after={`date -v-1m \"+%Y-%m-01\"`}
st = status
b = branch
p = pull
lg = log
type = cat-file
r = remote
unstage = reset
@ryanirelan
ryanirelan / gist:3320348
Created August 11, 2012 03:25 — forked from ckimrie/gist:3312619
Example extension that allows you to modify the final ExpressionEngine CP output
<?php
/**
* Modifying the final CP Output
*
* This extension demonstrates how you can access and modify the final ExpressionEngine
* CP output. It is not a hack, but it is a new technique that to my knowledge has not
* been used before in an EE addon.
*
* This has not been road tested and its side effects are unknown, so use this at your own risk.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteRule ^(.*)$ /index.php?$1 [L]
#!/bin/bash
# File: exp_permissions.sh
# Description: Sets permssions on a ExpressionEngine 2 install
#
# Copyright 2010 George Ornbo (Shape Shed)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# !/bin/bash
# Set up an new github repository
GITHUB_USERNAME="timkelty"
# from github instructions page after creating a repo
mkdir "$1"
cd "$1"
git init
touch README
#!/bin/sh
cd ~/work
for dir in `find . -type d -maxdepth 1 -mindepth 1`; do cd $dir; git pull origin master; cd -; done