Skip to content

Instantly share code, notes, and snippets.

@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: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 / 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');
<?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
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);
}
@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

@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