Skip to content

Instantly share code, notes, and snippets.

Avatar

John Keefe jkeefe

View GitHub Profile
@jkeefe
jkeefe / lambda.js
Created Jun 17, 2020
Code that actually works as a bridge between Twilio & Dialogflow on AWS Lambda
View lambda.js
// 1. This uses claudiajs & its API Gateway to deploy to lambda & handle api post
// 2. Assumes an existing dialogflow project, google cloud project, and google cloud billing
// 3. Got credentials .json file using steps 1-5 (ONLY) here:
// https://cloud.google.com/docs/authentication/getting-started
// 4. Put that json file in a directory called "sekrets' which I added to .gitignore
// 5. Other helpful options for Google authentication are here:
@jkeefe
jkeefe / fish_tank.ino
Created Mar 22, 2020
Fish tank code (see johnkeefe.net)
View fish_tank.ino
#include <Adafruit_NeoPixel.h>
#define PIN1 6
#define PIN2 3
#define NUM_LEDS 60
#define BRIGHTNESS 250
int blue_every = 12; // make every Xth pixel blue
@jkeefe
jkeefe / sratch.py
Created Mar 20, 2020
pymysql connection setup
View sratch.py
import pandas as pd
import pymysql
host="very.long.endpoint.definition.amazonaws.com"
port=3306
dbname="your_database_name"
user="your_user_name"
password="your_password"
conn = pymysql.connect(host, user=user,port=port,
@jkeefe
jkeefe / feature_importance.py
Last active Jun 24, 2019
Fast.ai feature importance function for neural nets
View feature_importance.py
# Originally shared by Zachary Mueller here:
# https://forums.fast.ai/t/feature-importance-in-deep-learning/42026/16
# ... which he adapted from Miguel Mota Pinto's post here:
# https://medium.com/@mp.music93/neural-networks-feature-importance-with-fastai-5c393cf65815
# Assumes all necessary fast.ai v1.0 libraries are loaded
def feature_importance(learner):
# based on: https://medium.com/@mp.music93/neural-networks-feature-importance-with-fastai-5c393cf65815
data = learner.data.train_ds.x
@jkeefe
jkeefe / encryption.js
Created Dec 16, 2017 — forked from vlucas/encryption.js
Stronger Encryption and Decryption in Node.js
View encryption.js
'use strict';
const crypto = require('crypto');
const ENCRYPTION_KEY = process.env.ENCRYPTION_KEY; // Must be 256 bytes (32 characters)
const IV_LENGTH = 16; // For AES, this is always 16
function encrypt(text) {
let iv = crypto.randomBytes(IV_LENGTH);
let cipher = crypto.createCipheriv('aes-256-cbc', new Buffer(ENCRYPTION_KEY), iv);
@jkeefe
jkeefe / index.js
Created Nov 22, 2017
Base index.js file for making lambda functions
View index.js
var twilio = require('twilio');
var mongodb = require('mongodb');
module.exports = function(request) {
return new Promise(function(fulfill, reject){
// functional code goes in here
});
@jkeefe
jkeefe / bot.js
Created Mar 7, 2017
Alexa "color-picker" example form Amazon/Lambda
View bot.js
'use strict';
/**
* This sample demonstrates a simple skill built with the Amazon Alexa Skills Kit.
* The Intent Schema, Custom Slots, and Sample Utterances for this skill, as well as
* testing instructions are located at http://amzn.to/1LzFrj6
*
* For additional samples, visit the Alexa Skills Kit Getting Started guide at
* http://amzn.to/1LGWsLG
*/
@jkeefe
jkeefe / bot.js
Created Mar 6, 2017
Example bot.js file for Alexa integration with claudio-bot-builder
View bot.js
// from https://claudiajs.com/news/2016/11/22/claudia-bot-builder-2.7.1-alexa-skills.html
// The list of platform names can include:
// facebook, slackSlashCommand, telegram, skype, twilio, kik, groupme, viber, alexa.
const botBuilder = require('claudia-bot-builder');
module.exports = botBuilder(function (message, originalApiRequest) {
return `I got ${message.text}`;
}, { platforms: ['alexa'] });
@jkeefe
jkeefe / .gitignore
Last active May 24, 2020
John Keefe’s global git ignore
View .gitignore
# John Keefe’s global git ignore
.DS_Store
.AppleDouble
.LSOverride
.env
*.log
scratch.*
You can’t perform that action at this time.