Skip to content

Instantly share code, notes, and snippets.

View garystafford's full-sized avatar
💭
Happily Coding!

Gary A. Stafford garystafford

💭
Happily Coding!
View GitHub Profile
@garystafford
garystafford / nodes.json
Last active August 29, 2015 13:56
For my blog post, 'Create Multi-VM Environment Using Vagrant and JSON' (http://wp.me/p1RD28-14c). JSON-based configuration file used by Vagrant to build (3) VMs. Project git repository located at: https://github.com/garystafford/multi-oracle-dev-vms.
{
"nodes": {
"apps": {
":node": "ApplicationServer-201",
":ip": "192.168.33.21",
":host": "apps.server-201",
"ports": [
{
":host": 2201,
":guest": 22,
@garystafford
garystafford / chef.json
Last active August 29, 2015 13:56
For my blog post, 'Create Multi-VM Environment Using Vagrant and JSON' (http://wp.me/p1RD28-14c). JSON-based chef configuration file used by Vagrant to build (3) VMs. Project git repository located at: https://github.com/garystafford/multi-oracle-dev-vms.
{
"chef": {
":chef_server_url": "https://api.opscode.com/organizations/my-organization",
":client_key_path": "/etc/chef/my-client.pem",
":environment": "my-environment",
":provisioning_path": "/etc/chef",
":validation_client_name": "my-client",
":validation_key_path": "~/.chef/my-client.pem"
}
}
@garystafford
garystafford / meanstack-test-mongodb.sh
Last active August 29, 2015 13:57
From blog post, Retrieving Data with AngularJS and the MEAN Stack: http://wp.me/p1RD28-16F. Install the sample database, collection, and documents.
start mongod # starts mongod in a separate window
mongo # starts interactive MongoDB Shell for remaining commands
# tip: once the mongo shell has started, you can copy and paste
# the commands below into the shell, all at once
use meanstack-test // creates database if it does not exist
db.components.insert({ "component": "mongod",
"description": "core database process" })
db.components.insert({ "component": "mongos",
"description": "controller and query router for sharded clusters" })
@garystafford
garystafford / install-meanstack-data-samples.sh
Last active August 29, 2015 13:57
From blog post, Retrieving Data with AngularJS and the MEAN Stack: http://wp.me/p1RD28-16F. Download, install, and start project: https://github.com/garystafford/meanstack-data-samples
# install meanstack-data-samples project
git clone https://github.com/garystafford/meanstack-data-samples.git
cd meanstack-data-samples
npm install
bower install
mongoimport --db meanstack-$NODE_ENV --collection components components.json --drop # Unix
# mongoimport --db meanstack-%NODE_ENV% --collection components components.json --drop # Windows
grunt test
grunt server
@garystafford
garystafford / install-meanstack-data-samples-env-vars.cmd
Last active August 29, 2015 13:57
From blog post, Retrieving Data with AngularJS and the MEAN Stack: http://wp.me/p1RD28-16F. Installs required environment variables on Windows for project: https://github.com/garystafford/meanstack-data-samples
REM cofirm the path to Chrome, change value if necessary
setx /m NODE_ENV "test"
setx /m PORT "3000"
setx /m CHROME_BIN "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
@garystafford
garystafford / Create_NewLocalUserAndGroup.ps1
Last active August 29, 2015 14:01
Create a new local User with basic options and assign to new group. Used on Windows 2012 Server. Just change variables in head of script.
###############################################################
# Author: Gary A. Stafford
# Revised: 2014-05-29
# Create new local User and Group
###############################################################
###############################################################
# Main variables (Change these!)
@garystafford
garystafford / Configure_Env_Git_Run3x.bat
Last active August 29, 2015 14:01
Prepare new environment with Git install, when machine is located behind a proxy server. Must run this .bat files 3x's due to nested variables.
# Run script 3 times because of the deeply nested variables
# PROXY_USERNAME is the username used to connect to proxy.
# May be different than the existing USERNAME.
# USERNAME is the account you logged into VM with,
# like 'Administrator', which may not have access through proxy
# Primary variables (CHANGE THESE FIRST!)
setx PROXY_HOSTNAME my_domain.com
setx PROXY_USERNAME my_user
setx PROXY_PASSWORD my_password
@garystafford
garystafford / snippet_karma.conf.js
Last active August 29, 2015 14:02
Code snippet for blog post, Retrieving Data with AngularJS and the MEAN Stack: http://wp.me/p1RD28-16F. Set Karma's browser for running tests. See complete project at: https://github.com/garystafford/meanstack-data-samples
// Karma configuration
module.exports = function (config) {
// Determines Karma's browser choice based on environment
var testBrowser = 'Chrome'; // Default browser
if (process.env.NODE_ENV === 'travis') {
testBrowser = 'PhantomJS'; // Must use for headless CI (Travis-CI)
}
console.log("Karma browser: " + testBrowser);
...
@garystafford
garystafford / angular-quiz_setup.sh
Last active August 29, 2015 14:03
Setting up garystafford/angular-quiz Project
# Choice 1: Clone post's existing angular-quiz project from GitHub:
git clone https://github.com/garystafford/angular-quiz.git
# Choice 2: Install generator-angular and build project from scratch
npm install -g generator-angular
mkdir project_name_here && cd $_
yo angular app_name_here
# Use generator-angular's generators to create project components
# Requires yo is installed for running Yeoman generators: npm install -g yo
@garystafford
garystafford / quiz-basic.json
Created July 8, 2014 18:46
Consolidated Snippet of Basic Quiz JSON file
{
"name": "Basic Quiz Example",
"questions": [
{
"_id": 1,
"question": "AngularJS is a declarative programming language.",
"answer": true
},
{
"_id": 2,