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 / asyncAwait.js
Last active March 23, 2017 23:43
Actionhero async actions
exports.asyncAwait = {
name: 'asyncAwait',
description: 'I am an asyncAwait action',
run: async function (api, data, next) {
let startTime = new Date().getTime()
let sleep = 1000
let timerPromise = new Promise((resolve, reject) => { setTimeout(resolve, sleep) })
try {

London Style Breakfast Bread Bowls (LSBBB)

Original Inspiration:

http://www.bargehouse.co.uk/kitchen/

Bespoke sourdough loaf filled filled with smoked bacon, Cumberland sausage, slow roasted tomatoes, leeks, oyster mushrooms, spinach, topped with a free range egg and sprinkled with cheese

Shopping List:

sudo: false
language: node_js
node_js:
- "6"
env:
- secure: "xxxxxxxxxx="
after_success:
- |
@evantahler
evantahler / main.yml
Last active March 22, 2025 07:11
CertBot + Ansible
# tasks/main.yml
- name: install certbot dependencies
apt: name={{ item }} state=present
with_items:
- build-essential
- libssl-dev
- libffi-dev
- python-dev
- git
@evantahler
evantahler / handlers_main.yml
Created July 23, 2016 17:26
nginx ansible actionhero
# handlers/main.yml
- name: restart nginx
service: name=nginx state=restarted
- name: reload nginx
service: name=nginx state=reloaded
module.exports = {
loadPriority: 1001, // to be sure connection is defined already
initialize: function(api, next){
api.connection.prototype.responseCode = function(code){
if(this.type !== 'web'){ throw new error('only for web servers'); }
this.rawConnection.responseHttpCode = code;
};
api.connection.prototype.header = function(key, value){
if(this.type !== 'web'){ throw new error('only for web servers'); }
@evantahler
evantahler / bad.js
Last active April 8, 2017 09:04
pg-action.js
exports.randomRow = {
name: 'randomFirstName',
description: 'I will return a random first name from the users table',
outputExample: {},
run: function(api, data, next){
pg.connect(api.config.pg.url, function(error, client, done){
if(error){ return next(error); }
var query = 'select * from usersorer by random() limit 1';
client.query(query, function(error, results){
@evantahler
evantahler / apple-app-site-association.js
Last active May 27, 2016 22:54
apple-app-site-association.js
exports.action = {
name: 'apple-app-site-association',
description: 'I return the wacky payload apple needs',
run: function(api, data, next){
data.connection.sendFile('apple-app-site-association/' + api.env + '.json');
data.toRender = false;
next();
}
};
@evantahler
evantahler / server.js
Last active May 28, 2016 17:59
Exploring a node.js memory leak with sending files and setting the Content-Length header
var fs = require('fs');
var http = require('http');
var file = __dirname + '/index.html';
var connections = {};
var idCouner = 0
var port = 8080;
var handleRequset = function(request, response){
idCouner++
var id = idCouner;
@evantahler
evantahler / in-line-logger.js
Created May 18, 2016 14:56
in-line-logger.js
// middleware to set up the logger for the connection
var middleware = {
name: 'in-line-logger',
global: true,
priority: 1,
preProcessor: function(data, next){
data.log = function(s){
// create a connection ID
if(!data.connectionId){ data.connectionId = uuid.v4(); }
// set up the extra data you want to log