Skip to content

Instantly share code, notes, and snippets.

View michtio's full-sized avatar
🏠
Working from home

Michael Thomas michtio

🏠
Working from home
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"
@Vestride
Vestride / encoding-video.md
Last active June 5, 2024 14:38
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
@khalwat
khalwat / set-project-perms.sh
Last active January 1, 2020 01:10
Properly set permissions for a Craft CMS install, including ensuring that files are all g-x. Set CHOWN_USER, CHOWN_GROUP, and BASE_DIR to whatever is appropriate, add directories that need to be writeable by the web server to DIRS[], then execute: sudo ./set-project-perms.sh PROJECT_NAME
This is now part of craft-scripts:
https://github.com/nystudio107/craft-scripts
@bgarrant
bgarrant / Multi-level Bootstrap 4 Navbar With Craft 3 (No Plugins).md
Last active July 30, 2019 08:11
Multi-level Bootstrap 4 Navbar With Craft 3 (No Plugins)

Multi-level Bootstrap 4 Navbar With Craft 3 (No Plugins)

You want to setup a Bootstrap 4 Navbar and use native functions in Craft 3 to manage the navigation menu.

This was built for Bootstrap v4.0 and Craft CMS 3.0.0-RC9

Step 1: Install Craft 3

Go to https://github.com/craftcms/docs/blob/v3/en/installation.md and install Craft 3.

Step 2: Download and Install latest Bootstrap 4 build

- pipeline: "Build and deploy to [environment]"
trigger_mode: "MANUAL"
ref_name: "develop"
actions:
- action: "Init Atomic Deployment"
type: "SSH_COMMAND"
working_directory: "${remote_path}/"
login: "${user}"
host: "${host}"
port: "22"
<?php
// Element API endpoint
'news.json' => function() {
return [
'elementType' => Entry::class,
'criteria' => [
'section' => 'news'
'join' => [
[
'LEFT JOIN',
@jakedohm
jakedohm / LoginForm.vue
Last active March 22, 2019 22:57
A Vue component to handle submitting login details with Axios, instead of with a standard HTML form
<template>
<form method="post" accept-charset="UTF-8">
<label for="loginName">Username or email</label>
<input v-model="loginName" id="loginName" type="text" name="loginName" />
<label for="password">Password</label>
<input v-model="password" id="password" type="password" name="password" />
<label>
<input v-model="rememberMe" type="checkbox" name="rememberMe" />
{# Bad: Messy and Hard to Follow #}
{% if link %}
<a href="/recipes/cookies">
{% endif %}
<span>Cookies</span>
{% if link %}
</a>
{% endif %}
{# Good: Clean & Clear #}
{% if article is defined %}
<li>
{{article.id}} - {{article.title}}
</li>
{% endif %}
Some notes here~
{% if relatedArticlesSelect | length == 3 %}
{% set relatedArticles = entry.relatedArticlesSelect.limit(3).all() %}
is the same as
{% set relatedArticlesSelect = entry.relatedArticlesSelect.all() %}
if you know there are only going to be three elements. dot all will fetch all of the elements attached