Skip to content

Instantly share code, notes, and snippets.

View scottsb's full-sized avatar

Scott Buchanan scottsb

View GitHub Profile
@erikhansen
erikhansen / sync_prod_to_stage.sh
Last active November 11, 2022 23:31
Magento 2 script to push DB and `pub/media` changes from prod>stage
#!/bin/bash
# stop on errors
set -e
# turn on debugging if you're running into issues
#set -x
# Static variables
ENVIRONMENT=$1
RED='\033[0;31m'
NC='\033[0m' # No Color
@rkrzr
rkrzr / auto_tags.py
Last active April 10, 2024 11:14
Automatically generate ansible tags of the same name for each role in a playbook
"""
This module implements an Ansible plugin that is triggered at the start of a playbook.
The plugin dynamically generates a tag for each role. Each tag has the same name as its role.
The advantage of this is that it saves you some boilerplate, because you don't have to wrap
all tasks of a role in an additional block and assign a tag to that.
Additionally, it works automatically when you add new roles to your playbook.
Usage is exactly the same as without this plugin:
@erikhansen
erikhansen / generate_sanitize_queries.sql
Last active October 24, 2019 19:22
Sanitize customer emails from Magento database. UPDATE: Use this instead: https://github.com/elgentos/masquerade
/*
Run the following query to get a set of queries that will purge all tables of email addresses. The queries that are output from
this should be manually reviewed to remove queries for any unnecessary tables and can then be run manually or via a Magerun "db:query"
to include it as a part of a scripted cloning process.
IMPORTANT: Make sure to update the @db_name variable
What the resulting query will do:
-- Replace the emails in Magento with dummy emails (unless email is one of the whitelisted domains) in order to prevent emails erroneously being sent to customers.
-- Make all emails with @example.com and use and MD5 of the original domain of the email as the tag for the email. This is important in case we have two emails with the
-- same "local part" but different "domain part". For example, bob.smith@yahoo.com would become bob.smith+c9d12f@example.com
var http = require ('https');
var querystring = require ('querystring');
exports.handler = function(event, context) {
console.log(event);
var message = JSON.parse(event.Message);
var color = 'warning';
switch(message.NewStateValue) {
case "OK":
color = 'good';
@gwillem
gwillem / magento-nginx.conf
Last active July 29, 2023 10:13
Battle-tested Nginx configuration for Magento (source: www.hypernode.com)
# This is an annotated subset of the Nginx configuration from our Magento production platform @ www.hypernode.com
# See https://www.byte.nl/blog/magento-cacheleak-issue
# !!!! If you are a Hypernode customer, do not use this config as it will result in duplicate statements. !!!!!
user app;
worker_processes 4;
pid /var/run/nginx.pid;
events {
@cjonstrup
cjonstrup / Laravel\app\commands\ViewsCommand.php
Last active August 1, 2019 21:17
Clear Laravel 4.* app/storage/views artisan views:clear
<?php
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
class ViewsCommand extends Command {
/**
* The console command name.
*
* @var string
@marcusphi
marcusphi / ansible_conditionals_examples.yaml
Created October 2, 2013 09:48
Ansible 1.3 Conditional Execution -- Very complete example with comments -- I find the conditional expressions to be ridiculously hard to get right in Ansible. I don't have a good model of what's going on under the surface so I often get it wrong. What makes it even harder is that there has been at least three different variants over the course …
---
# This has been tested with ansible 1.3 with these commands:
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=false"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts isFirstRun=true"
# ansible-playbook -i hosts ansible_conditionals_examples.yaml --extra-vars="hosts=myhosts"
# NB: The type of the variable is crucial!
- name: Ansible Conditionals Examples
hosts: $hosts
vars_files:
@marmot401
marmot401 / outlook2011_attachment_remover.scpt
Created August 1, 2013 02:15
modified apple script, https://gist.github.com/cweirup/3058303 7/31/13 updated the script so that running the script on multiple emails does not cause the attachment list to grow.
-- AppleScript to remove attachment from selected messages in Outlook 2011
-- Incorporates code from these sources:
-- http://dice.neko-san.net/2012/03/strip-attachments-from-outlook-2011-using-applescript/
-- http://stackoverflow.com/questions/9617029/how-to-get-the-a-file-url-in-osx-with-applescript-or-a-shell-script (for path2url function)
-- https://gist.github.com/cweirup/3058303
-- 7/31/13 updated the script so that running the script on multiple emails does not cause the attachment list to grow. Moved "repeat with theMessage in selectedMessages" to a better place
on path2url(thepath)
-- Needed to properly URL encode the path
return do shell script "python -c \"import urllib, sys; print (urllib.quote(sys.argv[1]))\" " & quoted form of thepath
@timsweb
timsweb / pre-commit
Created July 9, 2013 11:12
Git hook to prevent committing xdebug_break() functions. Save as .git/hooks/pre-commit then chmod +x it. Submodules also have their own hooks folder: ".git/modules/submodule/path/here/hooks".
#!/bin/sh
if git-rev-parse --verify HEAD >/dev/null 2>&1; then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
for FILE in `git diff --cached --name-only` ; do
# Check if the file contains 'debugger'