Skip to content

Instantly share code, notes, and snippets.

View jhyland87's full-sized avatar

J jhyland87

View GitHub Profile
@jhyland87
jhyland87 / foo.js
Last active February 9, 2016 00:21
Example of a mongoose model
'use strict'
module.exports = Mongoose => {
const Schema = Mongoose.Schema
const fooSchema = new Schema({
name: {
type: Schema.Types.String,
trim: true,
select: true,
'use strict'
const _ = require( '../' )
const Code = require('code')
const Lab = require('lab')
const lab = exports.lab = Lab.script()
const suite = lab.suite
const it = lab.test
const before = lab.before
@jhyland87
jhyland87 / index.js
Created February 26, 2016 17:42
Loading Mongoose model files
'use strict'
import path from 'path'
import fs from 'fs'
import _ from 'moar-lodash'
import * as appRoot from 'app-root-path'
const log = appRoot.require('./dist/lib/utils/logger')({ model: 'Index (loader)' })
module.exports = ( Mongoose ) => {
@jhyland87
jhyland87 / hapi_plugin.js
Last active March 13, 2016 16:32
HapiJS Custom plugin error
// File: real-plugin-src.js
module.exports = ( plugin, options, next ) => {
// Do stuff...
next()
}
module.exports.attributes = {
pkg: {
name: "test-plugin",
@jhyland87
jhyland87 / logger.js
Created March 17, 2016 16:43
Logging library using winston
'use strict'
import _ from 'moar-lodash'
import path from 'path'
import * as appRoot from 'app-root-path'
import * as Winston from 'winston-color'
const config = appRoot.require('./dist/lib/config').logs
const _internals = {}
'use strict'
// Tools
const _ = require( 'lodash' )
const appRoot = require( 'app-root-path' )
const Util = require( 'util' )
// Unit test related
const Code = require( 'code' )
const Lab = require( 'lab' )
'use strict'
// Tools
const _ = require( 'lodash' )
const appRoot = require( 'app-root-path' )
const Util = require( 'util' )
// Unit test related
const Code = require( 'code' )
const Lab = require( 'lab' )
@jhyland87
jhyland87 / prompt.sh
Last active September 29, 2022 00:41
Awesome profile.d bash script for a useful PS1
#!/bin/bash
# Create /etc/profile.d/prompt.sh and add the content of this gist to it.
#
# Prompt example:
# (2)[Fri May 06 10:00:30| 0:003]{4}root@ip-172-31-1-226:~(0)#
# Format is:
# (sessions on server)[date time| Last command exec time]{sessions on server}username@hostname:working_directory(exit code of last cmd)#
#
# Example Output (of $[prompt[0]}): http://d.pr/i/19B87
#
@jhyland87
jhyland87 / create_my-cnf.sh
Created May 11, 2016 18:45
Bash script to create /etc/my.cnf for mysql master replicator
cp /etc/my.cnf{,.orig} && \
echo "#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]
#
# include all files from the config directory
#
@jhyland87
jhyland87 / system-summary.sh
Created May 13, 2016 20:25
System Summary Script
#!/bin/bash
# Summary: Script to quickly show a summary of the servers stats, showing any possible issues (mainly regarding to resource utilization)
# Author: Justin Hyland
# Created: 05/11/16
# Screenshot: http://d.pr/i/2nTm
# Settings and thresholds
# These are set at odd limits just for testing
disk_thresh=10 # Percent
cpu_thresh='0.02'