Pixel Everywhere

There are only 10 types of people in this world. Those who know binary and those who don't.

Running MongoDB on Windows — July 9, 2015

Running MongoDB on Windows

This was only tested on Windows 7.

  1. Download and install from MongoDB website https://www.mongodb.org/downloads
  2. Select appropriate MSI or ZIP either for 32 or 64 bit system
  3. Once installed, locate the installation directory usually on C:\Program Files (x86)\MongoDB
  4. Create 2 folders and a file namely:
    1. log
    2. data
    3. mongo.config
  5. Next, Open the mongo.config file and type these 3 lines:
    • dbpath=C:\Program Files (x86)\MongoDB\data
    • logpath=C:\Program Files (x86)\MongoDB\log\mongo.log
    • diaglog=3
  6. Open command prompt as Administrator
  7. Go to the bin folder inside the installation directory cd C:\Program Files (x86)\MongoDB\Server\3.0\bin
  8. Type mongod.exe ––config=”C:\Program Files (x86)\MongoDB\mongo.config”
  9. Open another command prompt as Administrator , go again to the bin directory and type mongo
  10. In the Mongo Shell, type db. It should display a word test

* It’s up to you to put the paths in your environment variables

Other Items:

  • MongoDB can also be run by going to a NodeJS app’s bin directory using mongod.exe –dbpath path\to\my\nodejs\app\bin. Open another command prompt and type mongo
  • There are 2 default ports:
    • 27017
    • 28017 is used for accessing through the browser like http://localhost:28017 when starting mongo server using mongod.exe ––config=”C:\Program Files (x86)\MongoDB\mongo.config” ––rest
  • There’s no rename method for DBs. Use these instead:
    1. db.copyDatabase(‘fromDbName’, ‘toDbName’, ‘localhost’) to duplicate existing database
    2. use fromDbName switch to the the existing database to be deleted
    3. db.dropDatabase() to delete the used database
    4. use toDbName to switch to the newly created database
  • To dump a database along with its collections, there is only export to BSON option. The JSON option is per collection only. So use BSON instead: C:\Program Files (x86)\MongoDB\Server\3.0\bin>mongodump /d mynodejsapp /o mynodejsapp.json. The output will be contained in a mynodejsapp folder inside C:\Program Files (x86)\MongoDB\Server\3.0\bin
PHP CLI Single Line Display — July 4, 2015

PHP CLI Single Line Display

Tested only on Windows 7 using a PHP command line:

php -f myfile.php

  $exit = false;
    echo 'Enter a value: ';
    $cmd = trim(fgets(STDIN));
    if($cmd == 'q' || empty($cmd)){
      $exit = true;
      $dots = '.';
      echo "Loading";
      for($a = 1; $a <= $cmd; $a++){
        $s = "\t" . $dots . "$a%\r";
        echo $s;
        $dots .= '.';
      echo "\n";
Useful CLI Commands — June 16, 2015

Useful CLI Commands

There are infinite commands out there but it’s a good to write a small amount of them. My world usually revolves around these commands when inside a project folder:


  • Installing: $ curl -sS https://getcomposer.org/installer | php
  • Using: $ composer install[, require, remove, search] [package]
  • Updating: $ composer update (after deleting or updating lock file)
  • Creating $ composer init
  • For any PHAR or JSON issues, re-install Cygwin


  • File: $ php phpDocumentor.phar  -f path/to/an/additional/file -t path/to/my/api/docs
  • Directory: $ php phpDocumentor.phar -d path/to/my/project -t path/to/my/api/docs


  • $  curl -X DELETE  –data “id=1” -H “Accept:application/json” http://localhost/project/user


  • $ git add .
  • $ git commit -m ‘Message.’ -a
  • $ git tag -a -m ‘Major release.’
  • $ git push origin master
  • $ git push origin –tags


  • $ taskkill /IM node.exe (if an app/server is stuck, use this command)
  • $ npm ls -g –depth=0 (remove depth to list all dependencies)
WordPress.Org Plugins I Usually Need — June 15, 2015

WordPress.Org Plugins I Usually Need

These are my personal choices and the ones I normally use when creating new projects. Of course, there are other items like PayPal, Facebook Comments, eCommerce and such. But these items are a bit tricky to find and remember:

  1. Custom Post Type – to create different post types such as posts, pages, ads, etc.
  2. Advanced Custom fields – to create different form fields per page
  3. Duplicator – used for replicating everything from localhost all the way to an online hosting server
  4. Nav Menu Roles – allows freedom to determine which menu items are shown based on user log sessions
  5. User Role Editor – provides a way to create new user types, roles and permissions
  6. Pie Register – provides generic pages for user pages such as login, register, forgot password
  7. Role Scoper