Skip to content

Instantly share code, notes, and snippets.

@elfeffe
elfeffe / show-indexes.js
Created February 10, 2020 23:43 — forked from wpottier/show-indexes.js
MongoDB copy indexes
db.getCollectionNames().forEach(function(collection) {
indexes = db[collection].getIndexes();
indexes.forEach(function (c) {
opt = '';
ixkey = JSON.stringify(c.key, null, 1).replace(/(\r\n|\n|\r)/gm,"");
ns = c.ns.substr(c.ns.indexOf(".") + 1, c.ns.length);
for (var key in c) {
if (key != 'key' && key != 'ns' && key != 'v') {
if (opt != '') { opt+= ','}
if (c.hasOwnProperty(key)) {
<?php
namespace App\Libraries\Queue;
use Illuminate\Events\Dispatcher;
use Illuminate\Queue\DatabaseQueue;
use Illuminate\Support\Str;
use Laravel\Horizon\Events\JobDeleted;
use Laravel\Horizon\Events\JobPushed;
use Laravel\Horizon\Events\JobReleased;
@elfeffe
elfeffe / app--code--local--Varien--Autoload.php
Created April 18, 2019 17:17 — forked from lstrojny/app--code--local--Varien--Autoload.php
Replace Magento autoloader with composer based autoloader. Note: you are losing the ability to use the compiler.
<?php
/**
* Classes source autoload
*/
class Varien_Autoload
{
/** @var \Composer\Autoload\ClassLoader */
private static $autoloader;
/** @var self */
@elfeffe
elfeffe / mongobackup.sh
Created October 18, 2016 09:13 — forked from colinmollenhour/mongobackup.sh
Simple daily dump of mongo databases.
#!/bin/bash
cd /media/dumps
name=$(date +%b-%d)
year=$(date +%Y)
[ -d $year ] || mkdir $year || { echo "Could not create directory '$year'"; exit 1; }
mongodump --db t3_mage --out $name &> mongodump.log
if [ $? ]; then
tar -czf snapshots/$year/$name.tgz $name
if [ $(($(date +%d | sed 's/^0*//') % 10)) == 0 ]; then
@elfeffe
elfeffe / mysqlsnapshot.sh
Created October 18, 2016 09:10 — forked from colinmollenhour/mysqlsnapshot.sh
MySQL Snapshot Script
#!/bin/bash
DBNAME=mwe
SNAPSHOT_DAYS=7
ARCHIVE_DAYS=60
mysqldump=/usr/bin/mysqldump
gzip=/bin/gzip
function error() {
echo $1 >> $logfile.tmp
@elfeffe
elfeffe / optimize_media.sh
Created October 18, 2016 09:10 — forked from colinmollenhour/optimize_media.sh
Optimize PNG and JPEG images - incrementally
#!/bin/bash
#
# Optimize all jpg and png files in the cwd
# Run it again to optimize new files since the last run
#
# Example:
# echo "optimize_media.sh > /tmp/optimize.log" | sudo -u www-data bash -s
#
# Colin Mollenhour 2016