Install MongoDB on Windows 10

To install MongoDB on your Windows 10 machine, follow the following steps.

  1. Go to MongoDB website and download the Community version of the package like you see in the image below:
    unnamed-qq-screenshot20160925205425
  2. Once the download finishes, double click on the .msi file to start the installation. Install using the default settings, installing Complete package.
  3. Once installation completes, we need to add MongoDB to the Path in System Variables so that you can use the MongoDB commands in the command prompt. Right click on the Windows icon (the very left icon) on the taskbar and click on ‘System’.
  4. Click on Advanced System Settings on the left hand side and then when the window pops up, click on the Advanced tab and find Environment Variables…unnamed-qq-screenshot20160925205921
  5. Under the System Variables, double click on Path to add a new path for MongoDB:unnamed-qq-screenshot20160925210218
    You can also click on ‘New…’ button to add a new variable.
  6. Once the new window opens, add a new path for MongoDB according to your download path. If you used the default install settings, your install path for MongoDB should be similar to this:
    unnamed-qq-screenshot20160925210240
    3.2 is the version number, so just double check what your version number is before adding it in. Then click OK to save the changes.
  7. Then open your command prompt and type:
    $ mkdir C:\data\db\
    This is where all your database collection information is stored. NOT where your actual database for your app is stored.
  8. Now to connect your path to this directory, type this in the command prompt:
    $ mongod --dbpath <path where you want your database for your app stored>
    For example:
    $ mongod --dbpath C:\Users\Ellen\myfirstapp\contacts

  9. To check if your MongoDB is set up correctly, you can always run
    $ mongod
    You’ll get a response like the following:
    unnamed-qq-screenshot20160925211256

    Source: https://code.msdn.microsoft.com/Mongo-Database-setup-on-6963f46f

Advertisements

Dual Boot Ubuntu and Windows 10

I am on a Toshiba Satellite L55 and wanted to install a Linux operating system alongside my Windows 10 OS.

Here is a great YouTube video that explains how to allow both operating systems to work alongside each other:

I had trouble creating a partition using the Windows 10 Disk Management so I downloaded this EaseUS Partition Manager program to help me set aside a big enough partition manually.

Instead of saving the Ubuntu image .iso file onto a DVD, I used a USB. There are some tutorials online on how to change some settings in your BIOS to be able to boot from a USB drive. On my Toshiba Satellite, I didn’t have to alter anything in my computer BIOS and was able to just press F12 on computer start-up and choose USB as my boot source.

Installing Vagrant, Virtualbox

Vagrant is used to manage your Virtualbox images

Virtualbox is used to create customized development environments. You can create a Linux or Mac environment on a Windows machine with Virtualbox.

Here’s how to get started with Vagrant on Windows.

I installed Vagrant onto my Windows 10 OS first.

Then I installed Virtualbox

Setting up your Virtualbox

I ran the Virtualbox and selected the blue ‘New’ button to create a new virtual machine (which I named Ellen’s Linux). I kept all the values to their defaults and created a 5gb hard disk that is dynamic.

Unnamed QQ Screenshot20151221214033

Go here to download Ubuntu OS. I downloaded the 14.04.3 version.

Then go to your Settings>Display
Click on the CD icon (which should say Empty)
Then click on the CD icon on the right under Attributes>Optical Drive to select the Choose Virtual Optical Disk File
Find your Ubuntu OS .iso file and select it.

Unnamed QQ Screenshot20151221220339

Click the OK button and Run your new virtual machine.

If you get this error in your Virtualbox:

This kernel requires an x86-64 CPU, but only detects an i686 CPU, unable to boot

Go to General> Basic Settings and change the Ubuntu(32-bit) to Ubuntu(64-bit)

Unnamed QQ Screenshot20151221220256.jpg

If you notice your Ubuntu environment running super slow, go to Settings> Display

Check the ‘Enable 3D acceleration’ box in your virtual machine

Unnamed QQ Screenshot20151221220316

Setting up your Vagrant

After installing Vagrant, open your terminal and run this:

$ vagrant box add precise32 http://files.vagrantup.com/precise32.box
$ vagrant init precise32

If you get this error in your terminal:

Vagrant failed to initialize at a very early stage:

The plugins failed to load properly. The error message given is
shown below.

The RubyEncoder loader is not installed. Please visit the http://www.rubyencoder.com/loaders/ RubyEncoder site to download the required loader for 'mingw' and unpack it into 'C:/HashiCorp/Vagrant/embedded/rgloader' directory to run this protected script.

Then go here to download the RubyEncoder (MinGW). Unzip the folder ‘rgloader’ into HashiCorp/Vagrant/embedded/

If you’re prompted, replace any files with the same name.

Create a directory anywhere on your computer and test your Vagrant.
$ mkdir vagrant-test
$ cd vagrant-test
$ vagrant up

Done!

Get into an instance:
$ vagrant ssh

Helpful links:
Ubuntu Vagrant Install and Getting Started/

Getting Started Vagrant Windows

Ubuntu

 

The Command Line

Viking Code School

Web Development Basics

  1. What is the command line?
    A way to communicate with your computer by typing in lines of text.
  2. How do you open it on your computer?
    cmd.exe
  3. What is Bash?
    Bash is a Unix shell and command language
  4. How can you navigate into a particular file directory?
    cd
  5. How can you create a directory?
    mkdir
  6. How can you destroy a directory or file?
    rm test.html
  7. How can you rename a directory or file?
    mv test.html index.html
    test.html being the original file name
    index.html being the new file name
  8. Why are file permissions important?
    To keep your data secure.
  9. How do you view hidden files in a directory?
    ls -a
  10. How do you find information about a particular command?
    <command> –help
  11. What is a “Superuser” and how do you execute commands as this user?
    Execute commands as a superuser using ‘sudo’.
    This permits a user to execute a command as another user.
  12. What is Vim?
    A text editor in your Terminal
  13. How do you quit Vim if you get stuck in it?
    :q!
  14. What is the .bash_profile file and what is it used for?
    Bash will check .bash_profile to get more details of the user like user specific environment and startup programs.
  15. What is the $PATH variable?
    It specifies the directories in which executable programs are located on the machine so that they can be started without knowing the whole path to the file in the command line.
  16. Why might you need to add onto your $PATH variable?
    So that you can list multiple programs and start them without knowing the whole path to the executable file in the command line.
  17. What are alias commands?
    Commands you can save to a shortened string.
    Like if you are tired of typing ‘pwd’ all the time, you can set an ‘alias p = pwd’ so now you just need to type ‘p’.

Vim on Windows 10

I’ve just installed Vim on Windows 10. I’m completely new to Vim so if you have any great resources for learning, please leave a comment!

Vim is a text editor for your Command Prompt (or Terminal).

To install Vim on your Windows machine, you will have to download the executable file here.

To start up Vim, you can open your Command Prompt and type vi

Vim commands:

  • Switch between command mode and insert mode.
    • To switch from command mode to insert mode and insert text at the current cursor position, pressi.
    • To switch from command mode to insert mode and insert text at the beginning of the line, pressI.
    • To switch from command mode to insert mode and insert text at the end of the line, press A.
    • To switch from insert mode back to command mode use Esc.
  • Opening new lines
    • To open a new line after the current one and begin inserting text (switching to insert mode) use o.
    • To open a new line before the current one and begin inserting text (switching to insert mode) useO.
  • Navigating in the source using hjkl
    • Navigate up a line, press k.
    • Navigate down a line, press j.
    • Navigate left a character, press h.
    • Navigate right a character, press l.
  • Save
    • To save current edits use :w (short for write).
  • Exit
    • To exit, type :q (short for quit).
    • To save and exit, type :wq.
    • To force exit without saving, type :q!.
    • To force save and exit, type :wq!.
  • Undo
    • To undo last edit use u.
  • Redo
    • To redo use CTRL + r.
  • Copy and paste
    • To select a block of a text, Ctrl + v to switch to the visual mode, then select a block using the directional keys (hjkl).
    • To copy the selected block, yy (yank line).
    • To paste the selected block, p (paste).
    • To paste before cursor,P.
  • Tab complete
    • To use tab completion, CTRL + p.
  • Move to beginning and end of a file
    • To move to the beginning of the line, 0.
    • To move to the end of the line,$.
  • Substitute/Replace
    • To substitute the character under the cursor, type r followed by the character you will substitute.
    • To switch to replace mode use Shift + r and start typing.
  • Combine operators (like delete) with motions (like end of word)
    • As mentioned, Vim commands are composable. So you can combine operations like delete/change/copy with motions like beginning/end of word/line.
    • To delete to the end of the word, type dw.
    • To delete to the end of the line, type d$.
    • To delete the text within quotes, double quotes, parentheses, brackets use di', di", di(, di{, respectively.
    • To copy to the end of the word, type yw
  • You can type a number before the command to execute it multiple times
    • To delete 4 lines, type 4dd.
  • Repeat last command by typing ..
  • Jump to specific position in a file.
    • To jump to the beginning of a file use gg.
    • To jump to the end of a file use G.
    • To jump to the specific line in a file use 8gg (8 is the line number).
  • Search forward and backward.
  • Match parentheses and brackets.
    • To match the current parentheses or bracket use %.
  • Split horizontally and vertically.
    • To split the screen horizontally use :sp.
    • To split the screen vertically use :vs.
  • Switch between splits.
    • To switch to the next split screen use CTRL + ww.
  • Jump forward and backward.
    • To jump forward a page use CTRL + f.
    • To jump backward a page use CTRL + b.
  • Modify your environment via dotfiles.
    • You can do that after reading this tutorial 🙂 An easy way to edit your .vimrc file is :e $MYVIMRC.
  • Execute a shell command.
    • To execute a shell command simply type :sh followed by the command.

 Here is a cheat sheet for all commands:
vi-vim-cheat-sheet

This getting started guide by SitePoint provided the above information and goes more in-depth.

Vim Tutorial

UNIX Commands in Windows Command Prompt

How to use UNIX commands in Windows 10:

  1. Download and install the latest version of Cygwin. (32-bit) or (64-bit)
  2. Follow the steps in this tutorial if you want detailed instructions about the installation. The installation takes a while, but it’s normal.
  3. After installation finishes, open your Advanced System Settings in the Control Panel.
  4. Click the Advanced tab.
  5. Go to Environment Variables.
    cygwin
  6. In the second table labeled System Variables, find Path and click Edit.

    cygwin UNIX

  7. Scroll to the end of the Variable Value list and enter the path of your \cygwin\bin\ folder. Remember to close the previous path with a semicolon, so your path should look something like this: ;C:\cygwin\bin\

    cygwin

  8. Click OK and close all the windows.
  9. Open your Windows command prompt and type ls -l to test your installation.
  10. Yay! Now you can use UNIX commands within your command prompt.

I installed this today on my Windows 10 OS and had no problems. Feel free to leave a comment if you are getting errors and I’ll try to help.

Solve Error in Windows Command: TZInfo::DataSourceNotFound

How to Resolve TZInfo::DataSourceNotFound Error

If you are using Windows to make Ruby on Rails apps and come across this error in your command prompt when trying to run the Rails server:

C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/tzinfo-1.2.2/lib/tzinfo/data_source.rb:182:in `rescue in create_default_data_source': No source of timezone data could be found. (TZInfo::DataSourceNotFound)
Please refer to http://tzinfo.github.io/datasourcenotfound for help resolving this error.

Add this to the Gemfile in your app:

gem 'tzinfo-data', platforms: [:mingw, :mswin]

Run $bundle install
And then run your Rails server again. $rails server