Skip to content

Instantly share code, notes, and snippets.

View tvdsluijs's full-sized avatar
👨‍💻
Having fun coding!

Theo van der Sluijs tvdsluijs

👨‍💻
Having fun coding!
View GitHub Profile
@tvdsluijs
tvdsluijs / gist:e6e8e9219c03d86f9eed
Created July 6, 2014 12:00
FLATTR Button in Ghost Theme
<!-- static flattr button -->
<a href="https://flattr.com/submit/auto?user_id=YOURFLATTRUSERNAME&url={{url absolute="true"}}&title={{encode title}}&description={{excerpt}}&language=nl_NL&tags={{tags autolink="false" separator=","}}&hidden=0&category=text">
<img src="https://flattr.com/_img/icons/flattr_logo_16.png" alt="Flattr Button"/>
</a>
<!-- end static flattr button -->
@tvdsluijs
tvdsluijs / simple_mongodb_get_example
Created October 12, 2014 14:57
Get data from MongoDB example
$mongo_host = 'mongodb://10.10.10.10/'; //vul hier jou ip adres in van je MongoDB omgeving
$m = new MongoClient($mongo_host);
$db = $m->blog; //maak connectie met database
$collection = $db->visits; // maak connectie met de tabel / collection
//je kan nu bijvoorbeeld al alle records tellen met
$nr = $collection->count();
echo "<p>aantal records in db : " . $nr . "</p>";
@tvdsluijs
tvdsluijs / gist:4dfb175a33b7913a750c
Last active August 29, 2015 14:13
Mongodb php aggregation $match 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
$ops = array(
array(
'$match' => array("category" => 'socks')
)
@tvdsluijs
tvdsluijs / gist:757c55049bfecfec9971
Created January 9, 2015 18:59
Mongodb php aggregation $match $and 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 and brand
$ops = array(
array(
'$match' =>
array('$and' =>
@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: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 / FLEX_AS3_Password_gen.xlmn
Created August 8, 2012 05:44
Flex AS3 Password Creator / Generator
public function createpw(strHash:String = 'abchefghjkmnpqrstuvwxyz0123456789',lnHash:Number = 5):String
{
var i:Number = 0;
var hash:String = "";
var nLenght:Number = strHash.length;
while (i <= lnHash)
{
var num:Number = Math.round(Math.random()*nLenght);
hash += strHash.charAt(num);
i++;