Skip to content

Instantly share code, notes, and snippets.

View CodeVachon's full-sized avatar
:octocat:
Busy Coding...

Christopher Vachon CodeVachon

:octocat:
Busy Coding...
View GitHub Profile
@CodeVachon
CodeVachon / Sublime Project
Created August 1, 2014 20:54
A Sublime Profile File Template
{
"folders":
[
{
"follow_symlinks": true,
"path": "/path/to/working/dir",
"folder_exclude_patterns": [".*","node_modules"],
"file_exclude_patterns": [".DS_Store","Thumbs.db"]
}
],
@CodeVachon
CodeVachon / .bash_profile
Last active August 31, 2015 16:28
My .bash_profile file
# Git Auto Complete
# install these in home (~) directory.
# https://github.com/git/git/blob/8976500cbbb13270398d3b3e07a17b8cc7bff43f/contrib/completion/git-completion.bash
# https://github.com/git/git/blob/8976500cbbb13270398d3b3e07a17b8cc7bff43f/contrib/completion/git-prompt.sh
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
if [ -f ~/.git-prompt.sh ]; then
source ~/.git-prompt.sh
@CodeVachon
CodeVachon / gist:db629606a4ad31af212b
Created March 4, 2015 00:15
AngularJS $resource .get modify data
//
// Note that Articles is a $resource pointing to a express RESTful API
//
angular.module('App')
.controller('ArticlesEditController', ["$scope", "$routeParams", "$location", "Articles",
function($scope, $routeParams, $location, Articles) {
$scope.article = Articles.get({id: $routeParams.id},function(_data) {
_data.publish_date = new Date(_data.publish_date);
});
@CodeVachon
CodeVachon / app.js
Last active August 29, 2015 14:19
Showdown Gist
//
// Main Angular Application
//
angular.module('MyApp', ['markdown'])
.config(function(markdownProvider) {
markdownProvider.config({
extensions: ['table','gist']
});
});
@CodeVachon
CodeVachon / middleware-test.js
Last active May 23, 2021 09:29
express middleware mocha test
var middleware = require('middleware'), // the Middleware you want to test
httpMocks = require('node-mocks-http'), // quickly sets up REQUEST and RESPONSE to be passed into Express Middleware
request = {}, // define REQUEST
response = {} // define RESPONSE
;
describe('Middleware test', function(){
context('Valid arguments are passed', function() {
beforeEach(function(done) {
/*
@CodeVachon
CodeVachon / app.js
Created June 9, 2015 17:44
Activity Board Step 1
var
express = require('express'),
app = express(),
server = require('http').Server(app),
io = require('socket.io')(server)
;
app.use( express.static(__dirname + '/public') );
server.listen(3030, function(){
@CodeVachon
CodeVachon / app.js
Created June 9, 2015 17:58
Activity Board Step 2
// ...
io.on('connection', function(socket){
console.log('a user connected');
socket.on('disconnect', function(){
console.log('user disconnected');
});
socket.on('add activity', function(activityName){
@CodeVachon
CodeVachon / app.js
Last active August 29, 2015 14:24
Promise Module
var express = require('express'),
app = express(),
port = process.env.PORT || 3030,
myModule = require('./myModule')
;
app.get('/', function(request, response, next) {
myModule("Hello World").done(function(result) {
response.json(result);
}).fail(function(error) {
@CodeVachon
CodeVachon / app.js
Last active August 29, 2015 14:24
Callback Module
var express = require('express'),
app = express(),
port = process.env.PORT || 3030,
myModule = require('./myModule')
;
app.use(express.static(__dirname + '/public'));
app.get('/', function(request, response, next) {
myModule("Hello World", function(error, result) {
@CodeVachon
CodeVachon / get_document.js
Last active August 29, 2015 14:27
When To Use a Promise
// ASSUME JQUERY
var document_cache = [];
function getDocument(documentId) {
var _deferred = new $.Deferred()
_document_sent = false; // Note that this could be removed by using `_deferred.state()`
;
// Iterate over the document_cache array