Skip to content

Instantly share code, notes, and snippets.

View tvdsluijs's full-sized avatar

Theo van der Sluijs tvdsluijs

View GitHub Profile
@tvdsluijs
tvdsluijs / gist:3019b478325b3ed0e0d2
Created January 9, 2015 19:04
Mongodb php aggregation $match $or $and combined usage
$m = new MongoClient(); // connect to local mongodb
$db = $m->products; //select 'mongo database' named products
$clothing_col = $db->clothing; //create a collection from the 'table' clothing
//create the aggregation
//create the Match on clothing-category = shoes or brand = nike AND size 37
$ops = array(
array(
'$match' => array('$or' => array(array("category" => 'shoes'),
array("brand" => 'nike')),
@tvdsluijs
tvdsluijs / gist:0383dc774f69537bf379
Created January 9, 2015 19:08
Mongodb php aggregation $match $and $in usage
$m = new MongoClient(); // connect to local mongodb
$db = $m->products; //select 'mongo database' named products
$clothing_col = $db->clothing; //create a collection from the 'table' clothing
$brands = array('nike', 'puma');
//create the aggregation
//create the Match on clothing-category = shoes or brand = array
$ops = array(
array(
'$match' => array('$and' => array(
@tvdsluijs
tvdsluijs / gist:9ec4951bc2a04727b450
Created January 9, 2015 19:21
Mongodb php aggregation $match $gte usage
$m = new MongoClient(); // connect to local mongodb
$db = $m->products; //select 'mongo database' named products
$clothing_col = $db->clothing; //create a collection from the 'table' clothing
$brands = array('nike', 'puma');
//create the aggregation
//create the Match on pricing bigger or equals 75
$ops = array(
array(
'$match' => array('price' => array('$gte' => '75'))
@tvdsluijs
tvdsluijs / gist:7e1589b042b55d39ea94
Created January 9, 2015 19:51
Mongodb php aggregation $match between dates $gte $tle
$today = strtotime(date('Y-m-d 00:00:00'));
$yesterday = strtotime(date('Y-m-d 00:00:00', (time() - 24 * SECONDS_PER_HOUR)));
$m = new MongoClient(); // connect to local mongodb
$db = $m->orders; //select 'mongo database' named orders
$items_col = $db->items; //create a collection from the 'table' ordered items
@tvdsluijs
tvdsluijs / gist:0a540e0960b7578b8e9d
Created January 18, 2015 09:22
ZendFramework Blogger Import script
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
@tvdsluijs
tvdsluijs / gist:9047bf8e99367ebd90c2
Created January 18, 2015 09:23
Ghost2Blogger script
<?php
/**
* Created by PhpStorm.
* User: theovandersluijs
* Date: 14/01/15
* Time: 21:18
*/
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once '../Zend/blogger.php'; //don't forget you need this file also!
@tvdsluijs
tvdsluijs / gist:bbb5fe7710c7013c6baa
Created February 9, 2015 10:22
MongoDB Backup bash script
#!/bin/bash
#Force file syncronization and lock writes
mongo admin --eval "printjson(db.fsyncLock())"
MONGODUMP_PATH="/usr/bin/mongodump" #this should be the path to mongodump
MONGO_HOST="localhost" #different when not on same server
MONGO_PORT="27017" #could be different
MONGO_DATABASE="[dbname]" #name of your db
@tvdsluijs
tvdsluijs / mongodb_backup_tar_s3.sh
Created August 11, 2015 10:00
Better MongoDB backup script and move to S3 Bucket
#!/bin/bash
#add right params at [PARAM]
export LC_ALL=C
BAK="/opt/backup"
TIMESTAMP=`date +%F-%H%M`
S3_BUCKET_NAME=[BUCKET_NAME]
S3_BUCKET_PATH=[BUCKET_PATH]
@tvdsluijs
tvdsluijs / wordpresslinks.php
Last active March 27, 2016 06:35
So you want a list of links on your site from posts from another wordpress blog? Use this little script!
@tvdsluijs
tvdsluijs / DutchDate.html
Created July 7, 2018 09:28
Short code to show the Dutch date in Jekyll Liquid on Github
<!--
Add this to your _config.yml
months:
- Januari
- Februari
- Maart
- April
- Mei
- Juni
- July