Skip to content

Instantly share code, notes, and snippets.

View marciejones's full-sized avatar

Marcie Jones marciejones

View GitHub Profile
@marciejones
marciejones / prefill-url.js
Last active June 19, 2017 14:07 — forked from cvan/prefill-url.js
prefill `input[type=url]` field with "http://" upon focus using an angular directive
// Prefill URL field with 'http://' upon focus.
<label class="item item-input" ng-if="vm.website === undefined || !vm.api && !vm.account">
<input id="website" name="website" type="url" placeholder="What is your choir/chorus website?"
ng-model="vm.website" required http-prefix>
var app = angular.module('APPNAME');
app.directive('httpPrefix', function() {
return {
@marciejones
marciejones / referenced_mongo_json.md
Last active January 18, 2023 10:09 — forked from bclinkinbeard/referenced_mongo_json.md
Initializing MongoDB collections from JSON files using Node.js and Mongoose

Initializing MongoDB collections 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;