Skip to content

Instantly share code, notes, and snippets.

View primaryobjects's full-sized avatar

Kory Becker primaryobjects

View GitHub Profile
@primaryobjects
primaryobjects / index.js
Last active July 24, 2017 19:25
Dragon Hunt: An example game for Amazon Alexa running with alexa-app.
var alexa = require('alexa-app');
// Define an alexa-app
var app = new alexa.app('dragonhunt');
var dragonTypes = [ 'fire', 'ice', 'undead', 'skeleton', 'golden' ];
app.launch(function(req,res) {
// Generate a random dragon.
var randomType = Math.floor((Math.random() * 5)); // 0 - 5
@primaryobjects
primaryobjects / index.js
Last active July 24, 2017 14:59
Dragon Hunt: An example game for Amazon Alexa running on chatskills.
var chatskills = require('chatskills');
var readlineSync = require('readline-sync');
// Define an alexa-app
var app = chatskills.app('dragonhunt');
var dragonTypes = [ 'fire', 'ice', 'undead', 'skeleton', 'golden' ];
app.launch(function(req,res) {
// Generate a random dragon.
@primaryobjects
primaryobjects / index.js
Created August 24, 2016 14:45
Your first Amazon Alexa skill: Hello World. Running on alexa-app-server.
var alexa = require('alexa-app');
// Create a skill.
var hello = new alexa.app('hello');
// Launch method to run at startup.
hello.launch(function(req,res) {
res.say("Ask me to say hi!");
// Keep session open.
@primaryobjects
primaryobjects / index.js
Last active December 29, 2016 05:16
Your first Amazon Alexa skill: Hello World. Running on chatskills.
var chatskills = require('chatskills');
var readlineSync = require('readline-sync');
// Create a skill.
var hello = chatskills.app('hello');
// Launch method to run at startup.
hello.launch(function(req,res) {
res.say("Ask me to say hi!");
@primaryobjects
primaryobjects / chrome-extension-debug.txt
Created August 22, 2016 14:13
Three ways to debug a Chrome extension.
1. popup.html - Right-click the extension icon in the toolbar and select "Inspect popup".
2. background.html - Right-click the extension icon and select "Manage extensions".
Find your extension in the list and click "background page".
3. content scripts - Content scripts execute within the context of the web page.
To debug them, use the same technique as debugging regular javascript on a page.
Right-click on a web page and select "Inspect".
console.log() and console.debug() statements will print to the debugger console.
@primaryobjects
primaryobjects / app.js
Last active January 16, 2018 22:45
Simple example of a chatbot telling a joke, using AIML. Run "npm install", then "node app".
var readlineSync = require('readline-sync');
var aiml = require('aiml-high');
var interpreter = new aiml();
interpreter.loadFiles(['./joke.aiml']);
// Console client.
var text = ' ';
while (text.length > 0 && text != 'quit') {
text = readlineSync.question('> ');
@primaryobjects
primaryobjects / insWeaveBracket.R
Last active August 14, 2016 01:24
[2016-08-08] Daily Programmer Challenge #278 [Easy/Med] Weave insert Part 1
#
# [2016-08-08] Challenge #278 [Easy/Med] Weave insert Part 1
# https://www.reddit.com/r/dailyprogrammer/comments/4wqzph/20160808_challenge_278_easymed_weave_insert_part_1/
# Demo: http://www.r-fiddle.org/#/fiddle?id=KPCdSZrV&version=1
#
# Kory Becker 8/13/2016
# http://primaryobjects.com
#
ins <- function(option, arr1, arr2) {
@primaryobjects
primaryobjects / index.js
Created August 8, 2016 18:28
Example Amazon Alexa app for Echo. A simple example of creating skills and intents for usage with Amazon AWS Lambda.
var alexa = require('alexa-app');
// Allow this module to be reloaded by hotswap when changed
module.change_code = 1;
var app = new alexa.app('helloWorld');
app.launch(function(req, res) {
var prompt = 'Hello there, what is your name?';
res.say(prompt).reprompt(prompt).shouldEndSession(false);
});
@primaryobjects
primaryobjects / problem.txt
Created August 1, 2016 21:30
Interview problem: Given a list_of_ints, find the highest_product you can get from three of the integers.
Given a list_of_ints, find the highest_product you can get from three of the integers.
The input list_of_ints will always have at least three integers.
@primaryobjects
primaryobjects / problem.txt
Last active August 1, 2016 19:55
Programmer interview question: Product of All Integers Except at Index. Solution in O(n^2) and O(n).
You have an array of integers, and for each index you want to find the product of every integer except the integer at that index.
Write a function getProductsOfAllIntsExceptAtIndex() that takes an array of integers and returns an array of the products.
For example, given:
[1, 7, 3, 4]
your function would return:
[84, 12, 28, 21]