Skip to content

Instantly share code, notes, and snippets.

View collingo's full-sized avatar

Nick Collings collingo

View GitHub Profile
@collingo
collingo / example.json
Created May 6, 2020 11:03
CloudWatch alarm message example
{
"AlarmName": "cpuUtilTest",
"AlarmDescription": "testing alarms for cpu utilization",
"AWSAccountId": "08931xxxxxx",
"NewStateValue": "ALARM",
"OldStateValue": "OK",
"NewStateReason": "Threshold Crossed: 1 datapoint (5.199) was greater than or equal to the threshold (5.0).",
"StateChangeTime": "2012-08-05T22:31:25.524+0000",
"Region": "US - N. Virginia",
"Trigger": {

Keybase proof

I hereby claim:

  • I am collingo on github.
  • I am nickcollings (https://keybase.io/nickcollings) on keybase.
  • I have a public key ASDJT7MiibfkLE9iG8ir_3QcEWI8LWr9vfpekldkYFYh8Ao

To claim this, I am signing this object:

@collingo
collingo / index.js
Last active July 3, 2017 10:01
GraphCool schema mocking
const fs = require('fs')
const path = require('path')
const casual = require('casual')
const { makeExecutableSchema, addMockFunctionsToSchema } = require('graphql-tools')
const { graphql } = require('graphql')
fs.readFile(path.join(__dirname, './schema.graphql'), (error, schemaBuffer) => {
const schemaString = schemaBuffer.toString()
const schema = makeExecutableSchema({
typeDefs: schemaString
// simple path observing
function O(original, parentsWatcher, path) {
this.original = original;
this.path = path;
this.parentsWatcher = parentsWatcher;
Object.observe(this.original, function(changes) {
changes.forEach(function(change) {
if((change.type === 'add' || change.type === 'update') && typeof this.original[change.name] === "object") {
@collingo
collingo / simpleUMD.js
Last active August 29, 2015 13:56
Simple UMD
// resuable shortcut for module definition that works in Node (cjs) and the browser (Requirejs)
// (to save boilerplate may consider making umd function a global var - I know, I know!)
var umd = function (root, dependencies, factory) {
var requiredDependencies = [];
if (typeof define === 'function' && define.amd) {
define(dependencies, factory);
} else if (typeof exports === 'object') {
for (var i = dependencies.length - 1; i >= 0; i--) {
dependencies[i] = require(dependencies[i]);
}
@collingo
collingo / style.scss
Last active December 26, 2015 07:39
Example mapping of preprocessed CSS to semantic HTML
nav#primary {
ul {
li {
a {
&:hover {
}
}
// context
&.home {
@collingo
collingo / writeJsonToFile.js
Last active February 2, 2024 13:22
Save pretty printed json to file in node
var outputLocation = require('path').resolve(__dirname, 'file.json');
require('fs').writeFile(outputLocation, JSON.stringify(data, null, 4), function(err) {
if(err) {
console.log(err);
} else {
console.log("JSON saved to "+outputLocation);
}
});
@collingo
collingo / modelsSolution.js
Created February 26, 2013 11:06
Backbone Month, Week 1, Models - completed code
var Todo = Backbone.Model.extend({
defaults: {
completed: false,
priority: 0
},
initialize: function() {
this.on('change', function() {
window.changed = true;
});
@collingo
collingo / viewsSolution.js
Created February 26, 2013 11:04
Backbone Month, Week 3, Views - completed code
var TodoListView = Backbone.View.extend({
tagName: "ul",
id: "todolist",
initialize: function() {
_.bindAll(this, "appendTodo");
},
render: function() {
this.$el.empty();
this.collection.each(this.appendTodo);
return this;
@collingo
collingo / file1.js
Created March 11, 2012 20:44
Touch screen InactivityTimer
function InactivityTimer() {
this.timer = 0;
this.threshold = 5000;
window.addEventListener('click', this.resetTimer.bind(this), true); // binding to capture phase
this.startTimer.call(this);
}
InactivityTimer.prototype = {
startTimer: function() {