Skip to content

Instantly share code, notes, and snippets.

View davidhellmann's full-sized avatar
🤔
Focusing

David Hellmann davidhellmann

🤔
Focusing
View GitHub Profile
@jpcaparas
jpcaparas / nginx.conf
Last active October 23, 2024 12:32
Make a node application work with PM2 & Laravel Forge
# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/<your-site>/before/*;
map $sent_http_content_type $expires {
"text/html" epoch;
"text/html; charset=utf-8" epoch;
default off;
}
server {
export const initLazyloading = (selector: string): void => {
let images = document.querySelectorAll(selector)
if ('IntersectionObserver' in window) {
// Create new observer object
let lazyImageObserver = new IntersectionObserver(function(entries, observer) {
// Loop through IntersectionObserverEntry objects
entries.forEach(function(entry) {
// Do these if the target intersects with the root
if (entry.isIntersecting) {
@daltonrooney
daltonrooney / contentModule.gql
Last active May 15, 2023 23:24
Craft CMS GraphQL matrix shared fragment example
import gql from 'graphql-tag'
import { print } from 'graphql/language/printer'
import richTextFragment from './contentModules/richText.gql'
import logoBlockFragment from './contentModules/logoBlock.gql'
import embedBlockFragment from './contentModules/embedBlock.gql'
import videoBlockFragment from './contentModules/videoBlock.gql'
import imageCollageFragment from './contentModules/imageCollage.gql'
import imageGridFragment from './contentModules/imageGrid.gql'
import slideshowBlockFragment from './contentModules/slideshowBlock.gql'
import singleImageFragment from './contentModules/singleImage.gql'
@KatieMFritz
KatieMFritz / craft3-ax.md
Last active September 26, 2024 18:30
Craft 3 plugins for author experience

Craft 3 plugins for better author experience

Annotated Notes: For admin notes with automatic timestamps.

Control Panel Body Classes: Add body classes to various Control Panel screens for easier styling (in combination with Control Panel CSS).

Control Panel CSS: To make style tweaks to the control panel. See web/cp.css for styles.

Control Panel Nav: Custom navigation menus for each user type, for easier navigation.

@dgrigg
dgrigg / webpack.config.js
Created May 30, 2019 18:19
Webpack + Twig setup
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WebpackNotifierPlugin = require('webpack-notifier');
const TailwindCss = require('tailwindcss');
const AutoPrefixer = require('autoprefixer');
const path = require('path');
{% macro truncate(text, limit, append) %}
{# settings #}
{% set suffix = append|default('...') %}
{% set punctuation = ['.',',','-',':',';'] %}
{# logic #}
{% set array = text|split(' ') %}
{% set arrayTruncated = array|slice(0, limit) %}
{% set string = arrayTruncated|join(' ') %}
{% if limit and array|length > limit %}
{% for mark in punctuation %}
@afonsograca
afonsograca / colorSorting.js
Created April 25, 2018 00:50
Color sorting in JavaScript
//Sorting Hex Color:
var scheme = [
"#4C4C4C","#1F2029","#35404E","#282938","#00A0BE","#C67C48","#32CF72", "#4155D1","#B86838","#D81196","#149C92","#786DC4","#DB2C38","#83C057", "#A4A4A4","#55747C","#FFFFFF"
];
var Color = function Color(hexVal) { //define a Color class for the color objects
this.hex = hexVal;
};
@dennisfrank
dennisfrank / Buddy-craft3-atomic-deployment-pipeline.yml
Last active July 31, 2019 18:09
Buddy.works Craft 3 Atomic Deployment Pipeline
- pipeline: "Build and deploy to [environment]"
trigger_mode: "ON_EVERY_PUSH"
ref_name: "develop"
actions:
- action: "Init: Atomic Deployment"
type: "SSH_COMMAND"
working_directory: "${remote_path}/"
login: "${user}"
host: "${host}"
port: "22"
@martinherweg
martinherweg / DepartmentFile.json
Last active November 13, 2017 13:12
Create new Sections based on a Base JSON
{
"sections": [
{
"name": "A New Section",
"handle": "a_new_section_handle"
}
]
}
import qs from 'qs';
import Axios from 'axios';
Axios.defaults.baseURL = Craft.baseUrl;
Axios.defaults.headers.common['Accept'] = 'application/json';
Axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
Axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
Axios.interceptors.request.use(config => {
if (config.data instanceof FormData) {