Skip to content

Instantly share code, notes, and snippets.

View sjelfull's full-sized avatar

Fred Carlsen sjelfull

View GitHub Profile
@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;
}
@sjelfull
sjelfull / .htaccess
Created January 25, 2019 09:21 — 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.
# Apache configuration file
# httpd.apache.org/docs/2.2/mod/quickreference.html
# Note .htaccess files are an overhead, this logic should be in your Apache
# config if possible: httpd.apache.org/docs/2.2/howto/htaccess.html
# Techniques in here adapted from all over, including:
# Kroc Camen: camendesign.com/.htaccess
# perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
# Sample .htaccess file of CMS MODx: modxcms.com
# This is the free sample of .htaccess from 6GO s.r.l.
# @author Claudio Ludovico Panetta (@Ludo237)
<?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 / .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/
<?php
class CraftValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
@sjelfull
sjelfull / gist:4f80e0ac461573ab493e229a25be2934
Created June 5, 2017 13:37
Parallel processing in Craft with parallel
#!/bin/bash
LOCAL_PARALLEL_JOBS=$1
PARALLEL_JOBS=${LOCAL_PARALLEL_JOBS:-4}
# parallel creates a subshell, which will use the default $SHELL
# This makes sure php runs paralell with the correct shell
export SHELL=/bin/bash
index() {
echo Indexing $1
<?php
public function createProduct ($locale = null)
{
if ( !$this->productTypes ) {
$this->productTypes = craft()->commerce_productTypes->getAllProductTypes();
}
if ( !$locale ) {
$locale = craft()->i18n->getPrimarySiteLocaleId();
@sjelfull
sjelfull / _lazyFocusImager.twig
Created April 6, 2017 12:51 — forked from hendrikeng/_lazyFocusImager.twig
Twig/Craft macro for lazy responsive images/bgimages with Imager and Focuspoint
{#
// lazyLoaded Image/bgImages, optimized with Imager and Focuspoint
---------------------------------------------------------------------------
https://nystudio107.com/blog/creating-optimized-images-in-craft-cms
https://github.com/aelvan/Imager-Craft
https://github.com/smcyr/Craft-FocusPoint
for the bgImage intrinsic ratio classname creation check:
https://github.com/inuitcss/inuitcss/blob/develop/objects/_objects.ratio.scss