Skip to content

Instantly share code, notes, and snippets.

View evantahler's full-sized avatar
💭
Programmin'

Evan Tahler evantahler

💭
Programmin'
View GitHub Profile
@evantahler
evantahler / spec_helper.rb
Created July 13, 2015 21:36
Testing Ansibile with Vagrant and RSpec
require 'net/ssh'
require "#{File.dirname(__FILE__)}/utils/gems.rb"
require "#{File.dirname(__FILE__)}/utils/multi_logger.rb"
require "#{File.dirname(__FILE__)}/utils/subprocess.rb"
class SpecHelper
class << self
@@booted = false
@evantahler
evantahler / task.js
Created October 5, 2015 17:29
fancy actionhero task
var async = require('async');
var sendAbandonedCartEmail = function(api, cart, callback){
api.models.find({where: {id: cart.user_id}}).then(function(error, user){ // api.models are loaded via sequelize
if(error){ return next(error); )
if(!user){ return next(new Error('user not found')); )
api.cartHelper.sendAbandonmentEmail(api, user, callback); // api.cartHelper would be dinfined in an initializer
}).catch(callback);
};
@evantahler
evantahler / mongo-config.js
Created November 15, 2015 02:51
ActionHero + Mongo
exports.default = {
mongo: function(api){
return {
enable: true,
host: '1.2.3.4'
port: 27017
db: 'myDatabase'
}
}
}
@evantahler
evantahler / mysql-config.js
Created November 15, 2015 02:53
Actionhero + MySQL
config.mySQL = {
"database" : "v3_development",
"dialect" : "mysql",
"port" : 3306,
"pool" : {
"maxConnections" : 20,
"maxIdleTime" : 30000
},
"replication" : {
"write": {
@evantahler
evantahler / session.js
Created November 15, 2015 02:53
actionhero + simple session
////////////////////////////////////////////////////////////////////////////
// Sessions
module.exports = {
initialize: function(api, next){
api.session = {
prefix: "__session",
sessionExipreTime: 1000 * 60 * 60 // 1 hour
@evantahler
evantahler / tasks-cleanLogFiles.js
Last active December 8, 2016 16:36
ActionHero Example Task: CleanLogFiles
var fs = require('fs');
var maxLogFileSize = '100000';
exports.task = {
name: 'cleanLogFiles',
description: 'I will clean (delete) all log files if they get to big',
frequency: 60 * 60 * 1000,
queue: 'default',
plugins: [],
pluginOptions: {},
@evantahler
evantahler / tasks-pingSocketClients.js
Last active December 8, 2016 16:36
ActionHero Example Task: Ping Socket Clients
exports.task = {
name: 'pingSocketClients',
description: 'I will send a message to all connected socket clients. This will help with TCP keep-alive and send the current server time. Note that this will only ping the clients of one server, and will not work in cluster',
frequency: 5 * 1000,
queue: 'default',
plugins: [],
pluginOptions: {},
run: function(api, params, next){
for(var i in api.connections.connections){
@evantahler
evantahler / tasks-sayHi.js
Last active December 8, 2016 16:35
ActionHero Example Task: Say Hi
exports.task = {
name: 'sayHi',
description: 'I will log to the console every so often',
frequency: 5 * 1000,
queue: 'default',
plugins: [],
pluginOptions: {},
run: function(api, params, next){
api.log("Hello!", "alert");
@evantahler
evantahler / .sequelizerc
Last active December 12, 2015 04:24
sequelize + actionhero + migrations
var path = require('path');
var config = require(__dirname + '/config/sequelize');
var env = 'default';
if(config[process.env.NODE_ENV]){ env = process.env.NODE_ENV; }
config = config[env].sequelize();
config.config = __filename;
config['migrations-path'] = path.resolve('db', 'sequelize', 'migrate');
@evantahler
evantahler / basic.html
Created January 4, 2016 20:04
Evan's basic HTML guide
<!-- Basic Font Stuff -->
<em>words</em>
<strong>words</strong>
<u>underlined!</u>
<p>I am paragraph 1</p>
<p>I am paragraph 2</p>
<!-- headings -->