Skip to content

Instantly share code, notes, and snippets.

View fyrebase's full-sized avatar

Kirk Bentley fyrebase

View GitHub Profile
@fyrebase
fyrebase / History|-1180da83|1NaC.json
Last active June 7, 2022 13:57
Visual Studio Code Settings Sync Gist
{
"global": {
"check_for_updates_on_startup": true,
"show_in_menu_bar": true,
"show_profile_name_in_menu_bar": false
},
"profiles": [
{
"complex_modifications": {
"parameters": {
@fyrebase
fyrebase / .svgo.yml
Created October 1, 2016 10:34
Convert dimensions to viewBox - SVGO Plugin
plugins:
...
- convertDimensions
...
@fyrebase
fyrebase / gist.php
Last active May 11, 2016 10:27
Craft CMS generate asset title before save
<?php
craft()->on('assets.beforeSaveAsset', function(Event $event) {
if ($event->params['isNewAsset']) {
$asset = $event->params['asset'];
$source = $asset->getSource();
if (in_array($source->handle, ['myAssetSource'])) {
$asset->getContent()->title = 'myAssetTitle';
}
@fyrebase
fyrebase / gist.php
Created May 11, 2016 10:23
Craft CMS rename asset and title on asset save
<?php
protected function initSaveAssetEventListeners()
{
craft()->on('assets.saveAsset', function(Event $event) {
if ($event->params['isNewAsset']) {
$asset = $event->params['asset'];
$source = $asset->getSource();
if (in_array($source->handle, ['myAssetSource'])) {
@fyrebase
fyrebase / guide.md
Created December 2, 2015 10:02
Setup individual pools for PHP-FPM and NGINX - http://www.binarytides.com/php-fpm-separate-user-uid-linux/

Php-FPM

Php fpm is the new way to setup php to run with your webserver. Php-fpm is a fastcgi process manager for php that is totally separate from the webserver. The webserver communicates with fpm through a socket and passes the name of the script to execute. So fpm can run with any web server that is fastcgi compatible.

I recently moved from my old shared hosting to linode. Linode provides linux vps hosting at economic prices. However the servers are totally unmanaged are just raw linux machines that have shell access. So through the shell you have to setup everything including the web server, php and the web files.

So this time I decided to go with the combination of nginx and php-fpm. I had multiple sites to setup on this new webserver. Nginx deals with these through separate server blocks (aka vhost in apache). However there was another thing needed. Php on each site should run with its own user and not the nginx common user named www-data.

Running each site with its own uid/gid is more secure and

@fyrebase
fyrebase / image.styl
Last active November 24, 2015 00:48
Distortion free full screen image using Stylus
.img-wrapper
position relative
img
position absolute
left 50%
top 50%
transform translate(-50%,-50%)
display inline-block
max-width 100%
@fyrebase
fyrebase / navigation.twig
Last active April 18, 2018 13:50
Neat way of adding active class to cached navigation in Craft - From http://goo.gl/9LaOuM
{% set navigation %}
{% cache globally for 3 years %}
{% set entries = craft.entries.section('navigation') %}
<ul>
{% nav entry in entries %}
<li>
{# Check for entry type / get related entry #}
{% if entry.type == 'linkedChannelEntry' %}
@fyrebase
fyrebase / index.js
Created November 5, 2015 04:51
Gulp Useref - Log Invalid paths
// Add after pattern is defined. Line #113
var fs = require('fs');
fs.stat(pattern, function(err, stat) {
if(err) console.log('[INVALID PATH] ' + err.path);
});