Skip to content

Instantly share code, notes, and snippets.

@snez
snez / gist:7890664
Last active April 19, 2017 18:40
30-Day Rolling MySQL Database Backups
#!/bin/bash
export d=`date +%d`
export BACKUP_DIR="/home/user/backups/$d"
export USERNAME="username"
export PASSWORD="password"
export HOST="localhost"
mkdir -p $BACKUP_DIR
for DB in db1 db2 db3
@snez
snez / gist:ce1248661aefc15cb8d0
Last active August 29, 2015 14:02
MeanJS migrations with mongo-migrate

MeanJS migrations with mongo-migrate

MeanJS uses the connect-mongo module instead of mongodb, so you will have to add mongodb to your project as a dependency.

$ npm install mongodb --save

Install mongo-migrate

$ npm install mongo-migrate --save

var conn = new Mongo();
db = conn.getDB(<DB_NAME>);
var cursor = db.<COLLECTION>.find();
var items = [];
items = cursor.toArray();
var dbstruc = {};
for (var i = 0; i < items.length; ++i) {
var target = items[i];
getKP(target,dbstruc);
}
<?php
// SETUP:
// 1. Customize all the settings (stripe api key, email settings, email text)
// 2. Put this code somewhere where it's accessible by a URL on your server.
// 3. Add the URL of that location to the settings at https://manage.stripe.com/#account/webhooks
// 4. Have fun!
// set your secret key: remember to change this to your live secret key in production
// see your keys here https://manage.stripe.com/account
@snez
snez / meta.client.service.js
Last active February 24, 2017 23:36
MeanJS and Single Page Applications meta tags SEO
'use strict';
/*
This service can be used in MeanJS to add support for dynamic meta tag content depending on the
view that is rendered by ui-router. The same code can be reused in other SPAs with minor adjustments.
Usage: Copy this file in public/modules/core/services/ of MeanJS. Then inject the $meta service
into a controller and use any of the following statements to set the view's meta tag content.
$meta.setTitle('view title');
@snez
snez / gist:a6d5f4872fe87f29dd6d
Created March 6, 2015 14:04
Getting a docker container IP based on their exposed port from the shell
ps uax | grep "container-port 3306" | egrep -o '172[^ ]+'
@snez
snez / .gitignore
Created December 4, 2015 09:59
Magento .gitignore
/var/cache
/var/report
/var/log
/var/session
/var/backups
/var/locks
/media
/errors/local.xml
.DS_Store
.sass-cache
@snez
snez / gist:803a1e5912fcfd02f4fbe427d20aa8f0
Created November 21, 2016 08:48
IWD OPC 1.0.2 patch for Magento 2.1.x
diff --git a/vendor/magento/module-ui/view/base/web/js/core/renderer/layout.js b/vendor/magento/module-ui/view/base/web/js/core/renderer/layout.js
index 9dbd57b..16ee902 100644
--- a/vendor/magento/module-ui/view/base/web/js/core/renderer/layout.js
+++ b/vendor/magento/module-ui/view/base/web/js/core/renderer/layout.js
@@ -75,7 +75,7 @@ define([
return false;
}
- if (cached) {
+ if (cached && JSON.stringify(nodes)) {
@snez
snez / gist:9c7bca0199dddf07dca21d40c5d3fc2d
Last active August 20, 2017 18:04
Stripe.js patch for Lotusbreath OSC 4.1.1
diff --git a/skin/frontend/base/default/lotusbreath/onestepcheckout/js/osc.js b/skin/frontend/base/default/lotusbreath/onestepcheckout/js/osc.js
index 303bff9..ecc940a 100644
--- a/skin/frontend/base/default/lotusbreath/onestepcheckout/js/osc.js
+++ b/skin/frontend/base/default/lotusbreath/onestepcheckout/js/osc.js
@@ -276,6 +276,23 @@
);
},
+ cryozonicPlaceOrder: function()
+ {
@snez
snez / gist:e5c6d797264b5f7bd6cdcf5cc5aba045
Last active December 30, 2017 11:44
Stripe.js patch for MageStore OneStepCheckout 3.2.0
diff --git a/app/design/frontend/base/default/template/onestepcheckout/onestepcheckout.phtml b/app/design/frontend/base/default/template/onestepcheckout/onestepcheckout.phtml
index e7971e7..6902b59 100755
--- a/app/design/frontend/base/default/template/onestepcheckout/onestepcheckout.phtml
+++ b/app/design/frontend/base/default/template/onestepcheckout/onestepcheckout.phtml
@@ -693,7 +693,17 @@
var options = document.getElementsByName('payment[method]');
for (var i = 0; i < options.length; i++) {
if ($(options[i].id).checked) {
- if (options[i].id.indexOf("tco") != -1) {
+ if (options[i].id.indexOf("cryozonic_stripe") != -1) {