Skip to content

Instantly share code, notes, and snippets.

@khalwat
khalwat / load-balancer-app.php
Created February 26, 2018 17:25
Keep hashed directories consistent in a load balanced server environment with Craft CMS 3
<?php
/**
* Yii Application Config
*
* Edit this file at your own risk!
*
* The array returned by this file will get merged with
* vendor/craftcms/cms/src/config/app/main.php and [web|console].php, when
* Craft's bootstrap script is defining the configuration for the entire
* application.
@sheastrickland
sheastrickland / EnableIpSecurityOverride.ps1
Created November 5, 2015 05:26
Powershell DSC for allowing override for system.webserver.security.ipSecurity in applicationHost.config
Script EnableIpSecurityOverride
{
#Allows override for system.webserver.security.ipSecurity in applicationHost.config
DependsOn = "[Script]PreviousStepGoesHere"
SetScript = {
$current = Get-WebConfiguration /system.webServer/security/ipSecurity -Metadata | select -ExpandProperty metadata | select -ExpandProperty effectiveOverrideMode
$expected = "Allow"
$incorrect = $current -ne $expected
if ($incorrect) {
try
@halberom
halberom / extras.py
Last active November 8, 2023 16:23
ansible - example of merging lists of dicts
# ansible_plugins/filter_plugins/extras.py
def merge_dicts(value, dict1):
# return a merged dict
result = {}
result = value
result.update(dict1)
return result
def merge_lists_of_dicts(list1, list2):
# return a merged list
@vmsp
vmsp / awk_oneliners
Created June 27, 2015 22:45
Handy One-Line Scripts for Awk
HANDY ONE-LINE SCRIPTS FOR AWK 30 April 2008
Compiled by Eric Pement - eric [at] pement.org version 0.27
Latest version of this file (in English) is usually at:
http://www.pement.org/awk/awk1line.txt
This file will also be available in other languages:
Chinese - http://ximix.org/translation/awk1line_zh-CN.txt
USAGE:
@vmsp
vmsp / sed_oneliners
Created June 27, 2015 22:44
Useful One-Line Scripts For Sed
-------------------------------------------------------------------------
USEFUL ONE-LINE SCRIPTS FOR SED (Unix stream editor) Dec. 29, 2005
Compiled by Eric Pement - pemente[at]northpark[dot]edu version 5.5
Latest version of this file (in English) is usually at:
http://sed.sourceforge.net/sed1line.txt
http://www.pement.org/sed/sed1line.txt
This file will also available in other languages:
Chinese - http://sed.sourceforge.net/sed1line_zh-CN.html
{% set field = content.getField('file') %}
{% set uri = 'content/download/' ~ content.contentInfo.id ~ '/' ~ field.id ~ "/file/" ~ field.value.fileName|escape( 'url' ) %}
{% set uri = path( 'ez_legacy', {'module_uri': uri} ) %}
@shaharke
shaharke / ec2_protect.yml
Created March 15, 2014 17:12
Protecting your production EC2 instanced from termination with Ansible
---
- hosts: all
tasks:
- name: Gather EC2 facts
action: ec2_facts
- name: Turning on termination protection
local_action: command aws ec2 modify-instance-attribute --region {{ ansible_ec2_placement_region }} --instance-id {{ ansible_ec2_instance_id }} --attribute disableApiTermination --value true
@booleanbetrayal
booleanbetrayal / Gruntfile.js
Last active November 9, 2023 18:59
Example GruntJS configuration for a replacement to the Sprockets Rails asset pipeline
'use strict';
module.exports = function(grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// configurable paths
var paths = {