Skip to content

Instantly share code, notes, and snippets.

@jwatson3d
jwatson3d / referenced_mongo_json.md
Created February 3, 2020 05:09 — forked from bclinkinbeard/referenced_mongo_json.md
Populating referenced collections in MongoDB from JSON files using Node.js and Mongoose

Populating referenced collections in MongoDB from JSON files using Node.js and Mongoose

I recently began working with Node and MongoDB for a small personal project, largely just to learn the technologies. One thing that is fairly simple but that I found far from obvious and lacking in concrete examples was how to populate the part of my database that used referenced collections from the sample JSON data I was starting with. This post attempts to fill that gap using the following code snippets, which are heavily commented inline. You will notice I am using the awesome Mongoose library which makes working with MongoDB very easy.

http.createServer( app ).listen( app.get( 'port' ), function() {

    mongoose.connect( 'mongodb://localhost/{YOUR_DB_NAME}' );

	var db = mongoose.connection;
@jwatson3d
jwatson3d / gitflow-breakdown.md
Created January 5, 2020 22:03 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@jwatson3d
jwatson3d / m2
Created March 30, 2019 12:10 — forked from lhazlewood/m2
Bash script to switch maven configurations by name
#!/usr/bin/env bash
LINK_FILE="$HOME/.m2/settings.xml"
if [ ! -L "$LINK_FILE" ]; then
echo "This program expects $LINK_FILE to be a symbolic link."
exit 1
fi
if [ -z "$1" ]; then
@jwatson3d
jwatson3d / HelloWorld.java
Created December 16, 2017 14:28
Canonical hello world using Java
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
@jwatson3d
jwatson3d / gist:44b3282feac2ef164ed19c8f78d4ffab
Created September 5, 2017 02:38 — forked from romainl/gist:9970697
How to use Tim Pope's Pathogen.

How to use Tim Pope’s Pathogen.

I’ll assume you are on Linux or Mac OSX. For Windows, replace ~/.vim/ with $HOME\vimfiles\ and forward slashes with backward slashes.

The idea.

Vim plugins can be single scripts or collections of specialized scripts that you are supposed to put in “standard” locations under your ~/.vim/ directory. Syntax scripts go into ~/.vim/syntax/, plugin scripts go into ~/.vim/plugin, documentation goes into ~/.vim/doc/ and so on. That design can lead to a messy config where it quickly becomes hard to manage your plugins.

This is not the place to explain the technicalities behind Pathogen but the basic concept is quite straightforward: each plugin lives in its own directory under ~/.vim/bundle/, where each directory simulates the standard structure of your ~/.vim/ directory.

try {
Write-Host -ForegroundColor green "Bootstrapping machine ${remoteHost}"
Write-Host "Setting up package management and installing required packages for Dev."
# Install Choco (if not already installed) + required packages
if ( (Get-Command "choco" -errorAction SilentlyContinue) ) {
Write-Host "Chocolatey already installed. Skipping."
} else {
Write-Host "Installing Chocolatey"
$wc=new-object net.webclient; $wp=[system.net.WebProxy]::GetDefaultProxy(); $wp.UseDefaultCredentials=$true; $wc.Proxy=$wp; iex ($wc.DownloadString('https://chocolatey.org/install.ps1'))
@jwatson3d
jwatson3d / installLogStash.ps1
Last active August 29, 2015 14:19
Installs logstash as documented at http://goo.gl/F5zVvZ
###############################################################################
# installLogStash - based upon instructions documented at http://goo.gl/F5zVvZ
#
# 3 May 2015 J.Watson
# Correct LogStash run.bat (--config should point to folder, not file).
# Put sample config to watch IIS in a separate .\conf folder.
#
# 5 Apr 2015 J.Watson
# Original version.
###############################################################################
@jwatson3d
jwatson3d / installChocolatey98.ps1
Last active August 29, 2015 14:19
Installs Chocolatey 0.9.28 using image from NuGet.org
# Always make sure all variables are defined and all best practices are followed.
Set-StrictMode -version Latest
Add-Type -As System.IO.Compression.FileSystem
function Expand-ZipContents {
<#
.SYNOPSIS
Invokes Windows shell function to expand a zip file.
@jwatson3d
jwatson3d / devwkstn
Last active December 16, 2015 15:03
Developer's Workstation (winwkstn + devtools)
Set-ExplorerOptions -showHidenFilesFoldersDrives -showFileExtensions
::Enable-RemoteDesktop
choco install 7zip
choco install 7zip.commandLine
choco install beyondcompare
choco install notepadplusplus.install
choco install ccleaner
choco install speccy
choco install devbox-rapidee
@jwatson3d
jwatson3d / devtools
Last active August 29, 2015 14:13
Windows Developer Tools
choco install java.jdk -params "path=c:\\java\\jdk"
choco install db-visualizer
choco install nuget.commandLine
choco install git.install
choco install tortoisegit
choco install tortoisesvn
choco install filezilla