Skip to content

Instantly share code, notes, and snippets.

View sjelfull's full-sized avatar

Fred Carlsen sjelfull

View GitHub Profile
@sjelfull
sjelfull / php-pools.md
Created August 25, 2020 21:13 — forked from holmberd/php-pools.md
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
sjelfull / initialValueTemplates.js
Last active May 5, 2020 14:58 — forked from kmelve/initialValueTemplates.js
Initial Value Templates Commynity Digest Example for Sanity.io
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*"
].title
`)
@sjelfull
sjelfull / staging.yml
Created April 8, 2020 15:44 — forked from Mosnar/staging.yml
Craft CMS & Webpack on Laravel Forge
name: Deploy to Staging
on:
push:
branches: [ develop ]
jobs:
build:
runs-on: ubuntu-latest
steps:
@sjelfull
sjelfull / Installing Imagick with PHP 7.md
Last active March 28, 2020 05:37
Installing Imagick with PHP 7

1. Download the phpseven branch of the imagick repository

git clone https://github.com/mkoppanen/imagick.git imagick

2. phpize for target PHP version

cd imagick && /path/to/php7/bin/phpize && ./configure && make && make install

3. Enable the extension for your PHP version

@sjelfull
sjelfull / k6-webhook-load-testing.js
Created February 26, 2020 11:24
Load testing a webhook with k6
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
}
};
@sjelfull
sjelfull / discord-custom.css
Created February 13, 2019 15:07 — forked from dennisfrank/discord-custom.css
Custom Discord styles
: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;
}
<?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
sjelfull / renaming-craft-plugin-repos-from-craft3-to-craft
Created October 26, 2018 16:03
Rename Craft plugin repos from `craft3-` to just `craft-`
1. Rename the GitHub.com 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 `CHANGELOG.md`
10. Push all of the changes with your normal gitflow release cycle
@sjelfull
sjelfull / Pushover+UptimeRobot.php
Created November 29, 2016 14:54
Use Pushover and a webhook from Uptime Robot to send notifications to your phone
<?php
require __DIR__ . '/vendor/autoload.php';
use Sly\PushOver\Model\Push;
use Sly\PushOver\PushManager;
if (!isset($_GET['key']) || $_GET['key'] !== 'KEY') {
die('No key');
}
$monitorFriendlyName = $_GET['monitorFriendlyName'];
@sjelfull
sjelfull / .htaccess
Created June 5, 2018 13:43 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/