Skip to content

Instantly share code, notes, and snippets.

View jkeefe's full-sized avatar

John Keefe jkeefe

View GitHub Profile
@jkeefe
jkeefe / feature_importance.py
Last active June 24, 2019 02:02
Fast.ai feature importance function for neural nets
# 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 December 16, 2017 21:42 — forked from vlucas/encryption.ts
Stronger Encryption and Decryption in Node.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 November 22, 2017 16:05
Base index.js file for making lambda functions
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 March 7, 2017 22:30
Alexa "color-picker" example form Amazon/Lambda
'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 March 6, 2017 21:50
Example bot.js file for Alexa integration with claudio-bot-builder
// 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 June 28, 2021 17:34
John Keefe’s global git ignore
# John Keefe’s global git ignore
.DS_Store
.AppleDouble
.LSOverride
.env
*.log
scratch.*
@jkeefe
jkeefe / index.html
Created September 6, 2016 03:25
Example index.html file for a lambda-Twilio bot.
// question-bot!
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 / lambda.js
Created September 6, 2016 03:22
Example of a lamba.js file for a Twilio bot
var questionbot = require('./index');
var ApiBuilder = require('claudia-api-builder');
var api = new ApiBuilder();
module.exports = api;
api.post('/question-bot', function(request){
// bulding the reply (repsonse)
// which first sends the request object to sparkbot for processing
return questionbot(request)
@jkeefe
jkeefe / index.html
Created December 10, 2015 15:52
Mapbox GL Earthquake Test2
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Earthquakes Map: Last month</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.1/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.12.1/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }