Skip to content

Instantly share code, notes, and snippets.

View ryanirelan's full-sized avatar

Ryan Irelan ryanirelan

View GitHub Profile
$languages = [
'ab' => 'Abkhazian',
'aa' => 'Afar',
'af' => 'Afrikaans',
'ak' => 'Akan',
'sq' => 'Albanian',
'am' => 'Amharic',
'ar' => 'Arabic',
'an' => 'Aragonese',
'hy' => 'Armenian',
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
settings:
bootstrap: _bootstrap.php
params:
<?php
use craft\test\TestSetup;
return TestSetup::createTestCraftObjectConfig();
<?php
use craft\test\TestSetup;
ini_set('date.timezone', 'UTC');
// Use the current installation of Craft
define('CRAFT_STORAGE_PATH', __DIR__ . '/_craft/storage');
define('CRAFT_TEMPLATES_PATH', __DIR__ . '/_craft/templates');
define('CRAFT_CONFIG_PATH', __DIR__ . '/_craft/config');
@ryanirelan
ryanirelan / registration.js
Created February 7, 2019 15:36
Service worker registration code. For livestream at: https://craftquest.io/livestreams/what-are-service-workers
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/sw.js', {
scope: "/"
}).then(function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
// Trim the caches on load
navigator.serviceWorker.controller && navigator.serviceWorker.controller.postMessage({
command: "trimCaches"
@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