Skip to content

Instantly share code, notes, and snippets.


Fred Carlsen sjelfull

View GitHub Profile
sjelfull / pane.js
Created Sep 25, 2020 — forked from runeb/pane.js
Custom control over Desk pane menu items based on user group membership
View pane.js
import React, {
useEffect, useState
} from 'react'
import DefaultPane from '@sanity/components/lib/panes/DefaultPane'
import client from 'part:@sanity/base/client'
const CustomPane = (props) => {
const [groups, setGroups] = useState([])
useEffect(() => {
View MouseSafeArea.ts
import * as React from "react";
import { useMousePosition } from "~/hooks/useMousePosition";
/** Component to cover the area between the mouse cursor and the sub-menu, to allow moving cursor to lower parts of sub-menu without the sub-menu disappearing. */
export function MouseSafeArea(props: { parentRef: React.RefObject<HTMLDivElement> }) {
const { x = 0, y = 0, height: h = 0, width: w = 0 } = props.parentRef.current?.getBoundingClientRect() || {};
const [mouseX, mouseY] = useMousePosition();
const positions = { x, y, h, w, mouseX, mouseY };
return (
sjelfull /
Created Aug 25, 2020 — forked from holmberd/
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
sjelfull / initialValueTemplates.js
Last active May 5, 2020 — forked from kmelve/initialValueTemplates.js
Initial Value Templates Commynity Digest Example for
View initialValueTemplates.js
import T from '@sanity/base/initial-value-template-builder'
import client from 'part:@sanity/base/client'
const getNextDigestTitle = async () => {
const titles = await client.fetch(`*[
_type == "post" &&
title match "Community Digest*"
sjelfull / staging.yml
Created Apr 8, 2020 — forked from Mosnar/staging.yml
Craft CMS & Webpack on Laravel Forge
View staging.yml
name: Deploy to Staging
branches: [ develop ]
runs-on: ubuntu-latest
sjelfull / k6-webhook-load-testing.js
Created Feb 26, 2020
Load testing a webhook with k6
View k6-webhook-load-testing.js
import http from 'k6/http';
import { check } from "k6";
import { Rate } from "k6/metrics";
export let errorRate = new Rate("errors");
export let options = {
thresholds: {
errors: ["rate<0.1"] // <10% errors
View discord-custom.css
:root {
--channel-nav-item-height: 1.5rem;
--message-max-width: 50rem;
--theme-light-message-color: #23262a;
--avatar-border-radius: 3px;
--server-border-radius: 8px;
--sidebar-width: 180px;
--breakpoint: 1100px;
sjelfull / .htaccess
Created Jan 25, 2019 — forked from ludo237/.htaccess
The ultimate .htaccess file. Please feel free to fork it, edit it and let me know what do you think about it.
View .htaccess
# Apache configuration file
# Note .htaccess files are an overhead, this logic should be in your Apache
# config if possible:
# Techniques in here adapted from all over, including:
# Kroc Camen:
# Sample .htaccess file of CMS MODx:
# This is the free sample of .htaccess from 6GO s.r.l.
# @author Claudio Ludovico Panetta (@Ludo237)
View ElementIndexForRecords.php
* How to create an ElementIndex via custom Record for Craft CMS 3.x
* @copyright Copyright (c) 2018 anubarak
namespace modules\mymodule\elements\db;
use craft\base\Element;
use craft\db\Query;
sjelfull / renaming-craft-plugin-repos-from-craft3-to-craft
Created Oct 26, 2018
Rename Craft plugin repos from `craft3-` to just `craft-`
View renaming-craft-plugin-repos-from-craft3-to-craft
1. Rename the repo to change `craft3-` to `craft-`
2. Pull all changes down, then duplicate `master` naming it `v1`, or `v2` or whatever
3. Push the new versioned branch to remote
4. On Github, click on Settings->Branches and change the default repo
5. On Github click on Branches from the main page, and delete the `master` branch
6. Delete `master` in your local repo
7. Search through your project and change all instances of `craft3-` to `craft-`
8. Update your `docs` URL and `changelogUrl` to point to the new repo/branch
9. Bump the version number in `composer.json` and ``
10. Push all of the changes with your normal gitflow release cycle