Skip to content

Instantly share code, notes, and snippets.

View leevigraham's full-sized avatar
🍹

Leevi Graham leevigraham

🍹
View GitHub Profile
@leevigraham
leevigraham / Generate ssl certificates with Subject Alt Names on OSX.md
Last active January 31, 2023 19:54
Generate ssl certificates with Subject Alt Names

Generate ssl certificates with Subject Alt Names on OSX

We're going to generate a key per project which includes multiple fully qualified domains. This key can be checked into the project repo as it's intended for local development but never used on production servers.

Save ssl.conf to your my_project directory.

Open ssl.conf in a text editor.

Edit the domain(s) listed under the [alt_names] section so that they match the local domain name you want to use for your project, e.g.

@leevigraham
leevigraham / Explanation.md
Last active October 19, 2021 10:42
Stimulus + Typescript Types

In stimulusjs you can define a component (known as a controller) like so:

import { Controller } from "stimulus";

export default class extends Controller {
  static targets = ["item"];
  
  function connect() {
 if(this.hasItemTarget) {
<?php
/**
* Custom configuration bootstrap file for ExpressionEngine
*
* Place config.php in your site root
* Add require(realpath(dirname(__FILE__) . '/../../config_bootstrap.php')); to the bottom of system/expressionengine/config/config.php
* Add require(realpath(dirname(__FILE__) . '/../../config_bootstrap.php')); to the bottom of system/expressionengine/config/database.php
* If you have moved your site root you'll need to update the require_once path
*
/**
* EE Affiliate link automations

*
* Original concept and code by: Leevi Graham <http://leevigraham.com>
* Modified by: Brandon Kelly <http://pixelandtonic>
*/
var ee_affiliate_name = 'expressionengineaddons',
external_re = new RegExp('^https?://(?!'+document.location.hostname+')'),
external_ee_re = new RegExp('^(https?://(secure\\.|www\\.)?expressionengine.com'
@leevigraham
leevigraham / example.html
Last active October 18, 2018 11:24
Renderless Flyout.Vue component
<flyout v-cloak>
<div slot-scope="props">
<button
v-on:click="props.toggle()"
v-bind:class="'border-2 p-1 ' + (props.isActive ? 'bg-green': 'bg-red')"
data-reference
>…</button>
<div
v-show="props.isActive"
class="list-reset bg-white border p-4 shadow z-10"
@leevigraham
leevigraham / gist:922bcd86ebd30dd861d0
Last active July 21, 2018 03:59
OSX install Script
# Ask for the administrator password upfront
sudo -v
mkdir -p /Volumes/Sites/Work/Clients
mkdir -p /Volumes/Sites/Work/Internal
mkdir -p /Volumes/Sites/Personal
mkdir -p ~/Downloads/Torrents
xcode-select --install
@leevigraham
leevigraham / AbstractRepository.php
Last active April 18, 2018 22:01
AbstractRepository::filterByCriteria - Parses a nested array and adds expressions to a query builder
<?php
namespace App\Doctrine\ORM\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\QueryBuilder;
abstract class AbstractRepository extends ServiceEntityRepository
{
/**
<template>
<div>
<div ref="trigger">
<slot name="trigger"
v-bind:isActive="isActive"
v-bind:toggle="toggle"
>
<button v-on:click="toggle">Toggle</button>
</slot>
</div>
msg_regexp = new RegExp("<div class=['\"]message['\"]>[\\s\\S]+<\/div>", "m")
ee_ajax_response_marker_reg_exp = new RegExp("<!-- EE_ajax_response(?: -->([\\s\\S]+)<!-- )?End EE_ajax_response -->");
function parse_interstitial_response(str)
{
if((response = str.match(ee_ajax_response_marker_reg_exp)) && (message = response[1].match(msg_regexp)))
{
error = (str.match(/Error<\/title>/)) ? true : false;
link = response[1].match(/href=["'](.*)["']/) || false;
message = message[0].replace(/(class=['"]message)/gi, ( error ? "$1 error" : "$1 success") );
@leevigraham
leevigraham / gist:b48ed5382e497a6497ac
Created November 26, 2014 12:01
Asset renaming with [gulp|grunt]-rev and git history
Given unicorn.css
When we first run gulp-rev the filename is unicorn-098f6bcd.css
If we check this into git then unicorn-098f6bcd.css is added to the index
If we change unicorn.css and run gulp-rev the filename changes to unicorn-xxxxxxxx.css
Committing this to git means unicorn-098f6bcd.css is deleted and unicorn-xxxxxxxx.css is added.
This breaks the file history of the revved file.
You still have a full history of the original unicorn.css which still counts and is super important.