Skip to content

Instantly share code, notes, and snippets.

View dot
#!/bin/bash
git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME $@
View AssetsController.php
<?php
namespace modules\appmodule\controllers;
use Craft;
use craft\elements\Asset;
use craft\web\Controller;
use spicyweb\embeddedassets\Plugin as EmbeddedAssets;
use yii\web\Response;
View extractCssFiles.php
<?php
function extractCssFiles(array $manifest, string $manifestKey): array
{
$entry = $manifest[$manifestKey] ?? null;
if (!$entry) {
return [];
}
View EventsController.php
$filteredBody = array_filter(Craft::$app->getRequest()->getBodyParams());
Craft::$app->getRequest()->setBodyParams($filteredBody);
View vcl_backend_response
# Allow caching for anything but private
if (!beresp.http.cache-control ~ "(?i)private") {
unset beresp.http.set-cookie;
}
View fn-signatures.php
<?php
// Type juggle keys as string or array
// -------------------------------------
public function getFoo(mixed $keyOrKeys)
{
}
// Variable args
View UgcUpload.jsx
import {hot} from 'react-hot-loader/root';
import React, {useState} from 'react';
import Uppy from '@uppy/core';
import XHRUpload from '@uppy/xhr-upload';
import {DragDrop, StatusBar, ProgressBar} from '@uppy/react';
import '@uppy/core/dist/style.css';
import '@uppy/status-bar/dist/style.css';
import '@uppy/progress-bar/dist/style.css';
import '@uppy/drag-drop/dist/style.css';
import {ReactSortable} from 'react-sortablejs';
View ElementTransformer.php
<?php
namespace modules\appmodule\transformers;
use craft\base\ElementInterface;
use League\Fractal\TransformerAbstract;
use modules\appmodule\AppModule;
use Tightenco\Collect\Support\Collection;
class ElementTransformer extends TransformerAbstract
View prose.css
/* See: node_modules/@tailwindcss/typography/dist/typography.css */
@layer components {
@responsive {
.prose {
color: theme("colors.gray.copy");
max-width: 65ch;
}
.prose [class~="lead"] {
color: theme("colors.gray.copy");
View tailwind.config.js
const defaultTheme = require('tailwindcss/defaultTheme')
const prefixedColors = Object.fromEntries(Object.entries(defaultTheme.colors).map(([k, v]) => [`tw-${k}`, v]));
module.exports = {
theme: {
extend: {
colors: {
...prefixedColors,
red: '#ff0000',
// your colors here…