Skip to content

Instantly share code, notes, and snippets.

View toymachiner62's full-sized avatar

Tom Caflisch toymachiner62

View GitHub Profile
let promises = []
let promise1 = new Promise((resolve, reject) => { resolve() })
let promise2 = new Promise((resolve, reject) => { resolve() })
promises.push(promise1, promise2)
Promise.all(promises)
.then(() => {
console.log('in then')
@toymachiner62
toymachiner62 / simple-node-load-test.js
Created June 7, 2017 17:24
Retardedly simple load test for a single GET endpoint
var request = require('request');
var url = '<insert url here>';
var loopCount = 75
for(var i = 0; i < loopCount; i++) {
makeRequest(i);
}
function makeRequest(i) {
@toymachiner62
toymachiner62 / README.md
Last active March 8, 2023 15:38
Git hook which prevents a commit without a having a link to a TFS work item

Usage - This hook prevents a dev from committing code without having a reference to a tfs work item

Installation. Create a folder in your project root called githooks and save the commit-msg file in there.

The githook can then be installed by symlinking them to your .git/hooks dir.

Run these commands from the project root

$ ln -s ../../githooks/pre-commit .git/hooks/
$ ln -s ../../githooks/commit-msg .git/hooks/
@toymachiner62
toymachiner62 / Messages.js
Last active August 29, 2015 14:11
Angular Messages Service
angular.module('myApp').factory('Messages', function($rootScope) {
var success = null;
var error = null;
return {
getSuccess: function() {
return success;
},
@toymachiner62
toymachiner62 / mongoFactory.js
Last active August 29, 2015 14:05
Simple MongoDB connection pool factory.
/**
* Creates and manages the Mongo connection pool
*
* @type {exports}
*/
var constants = require('../js/constants.js');
var Q = require('q');
var MongoClient = require('mongodb').MongoClient;
var dbPromise = null;
@toymachiner62
toymachiner62 / gist:8373682
Created January 11, 2014 17:14
Capistrano deployment example
require 'bundler/capistrano'
require 'rvm/capistrano'
set :application, 'example.com'
role :web, 'example.com'
role :app, 'example.com'
role :db, 'example.com', :primary => true
# set environment
@toymachiner62
toymachiner62 / gist:7518116
Created November 17, 2013 20:51
This is a simple example of Authentication and/or Authorization using html5's sessionStorage with AngularJS.
// Main module declaration
var myapp = angular.module('myapp', []);
// Set some actions to be performed when running the app
myezteam.run(['$location', '$rootScope', function($location, $rootScope) {
// Register listener to watch route changes.
// We use this to make sure a user is logged in when they try to retrieve data
$rootScope.$on( "$routeChangeStart", function(event, next, current) {
@toymachiner62
toymachiner62 / gist:7413916
Created November 11, 2013 14:26
This is a Fantasy Football draft order randomizer. This app that takes an array of names and displays them in a random order every time the page is refreshed.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(function() {
var players = new Array("Tom", "Kraig", "PT", "Chanse", "Young", "Grant", "Paul", "JJ", "Ty", "Jason");
var draftOrder = shuffle(players);