Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Happily Coding!

Gary A. Stafford garystafford

💭
Happily Coding!
View GitHub Profile
@garystafford
garystafford / nodes.json
Last active Aug 29, 2015
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.
View nodes.json
{
"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 Aug 29, 2015
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.
View chef.json
{
"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 Aug 29, 2015
From blog post, Retrieving Data with AngularJS and the MEAN Stack: http://wp.me/p1RD28-16F. Install the sample database, collection, and documents.
View meanstack-test-mongodb.sh
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 Aug 29, 2015
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
View install-meanstack-data-samples.sh
# 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 Aug 29, 2015
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
View install-meanstack-data-samples-env-vars.cmd
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 / Configure_Env_Git_Run3x.bat
Last active Aug 29, 2015
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.
View Configure_Env_Git_Run3x.bat
# 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 / Create_NewLocalUserAndGroup.ps1
Last active Aug 29, 2015
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.
View Create_NewLocalUserAndGroup.ps1
###############################################################
# Author: Gary A. Stafford
# Revised: 2014-05-29
# Create new local User and Group
###############################################################
###############################################################
# Main variables (Change these!)
@garystafford
garystafford / snippet_karma.conf.js
Last active Aug 29, 2015
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
View snippet_karma.conf.js
// 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 Aug 29, 2015
Setting up garystafford/angular-quiz Project
View angular-quiz_setup.sh
# 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 Jul 8, 2014
Consolidated Snippet of Basic Quiz JSON file
View quiz-basic.json
{
"name": "Basic Quiz Example",
"questions": [
{
"_id": 1,
"question": "AngularJS is a declarative programming language.",
"answer": true
},
{
"_id": 2,