Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Picking Records with JavaScript and a Button
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Gordon Diggs
September 11, 2016
Technology
88
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Picking Records with JavaScript and a Button
Gordon Diggs
September 11, 2016
More Decks by Gordon Diggs
See All by Gordon Diggs
John Coltrane: Lessons in Leadership
gordondiggs
2
310
The Customer Gap
gordondiggs
1
120
Kafka Partitioning Algorithm
gordondiggs
0
150
Supbutton
gordondiggs
0
88
Rayons
gordondiggs
0
94
Sous Vide
gordondiggs
0
110
Dev Events & Internal Tools at Paperless Post
gordondiggs
0
130
The Joys and Pains of Working With an Old Codebase
gordondiggs
0
150
The Joys and Pains of Working with an Old Codebase
gordondiggs
1
2.4k
Other Decks in Technology
See All in Technology
Djangoユーザが知っ得なPostgreSQL機能 - 設計の選択肢を増やす / Djang-use-PostgreSQL
soudai
PRO
1
230
AI Engineering Summit Tokyo 2026 AIの前に、やることがある 〜医療データ企業の4フェーズ〜
dtaniwaki
0
2.5k
Amazon Bedrock AgentCore ワークショップ JAWS UG TOHOKU / amazon-bedrock-agentcore-workshop-jawsug-tohoku-2026
gawa
9
620
Claude Code の Sandbox 機能を Anthropic Sandbox Runtime(srt) で試そう!/lets-play-anthropic-sandbox-runtime
tomoki10
1
520
AWSシリコン最前線 〜AI時代のチップ選択を読み解く〜
htokoyo
2
400
2026TECHFRESH畢業分享會 - Lightning Talk - 打造精準高效的 MCP 設計模式與測試實務
line_developers_tw
PRO
0
700
やさしいA2A入門
minorun365
PRO
11
1.7k
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
1.9k
失敗を資産に変えるClaude Code
shinyasaita
0
300
データサイエンスを価値につなげるプロジェクト設計 〜 DS一年目が現場で得た気づき 〜
ysd113
1
150
2026 TECHFRESH 畢業分享會 - 開發日常大解密!從領域驅動到企業級上線
line_developers_tw
PRO
0
690
2026TECHFRESH畢業分享會 - 葬送的通靈師:化系統與用戶雜訊成行動訊號
line_developers_tw
PRO
0
700
Featured
See All Featured
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
420
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
130
エンジニアに許された特別な時間の終わり
watany
107
250k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Tell your own story through comics
letsgokoyo
1
950
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
1
3.6k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
230
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
170
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
330
AI: The stuff that nobody shows you
jnunemaker
PRO
8
700
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
420
Transcript
Picking Records with JavaScript and a Button ManhattanJS 20160914
Picking Records with JavaScript and a Button ManhattanJS 20160914
@GordonDiggs
None
None
None
None
None
Lambda Example Sources • S3 file created or deleted •
SNS event • Updates to a DynamoDB table
None
None
None
Requirements • Get a random record • Send a text
message with that record’s information
const env = require("node-env-file"); env(`${__dirname}/.env`); process.env.NODE_CONFIG_DIR = "/var/task/config"; const twilio
= require("twilio")(process.env.ACCOUNT_SID, process.env.AUTH_TOKEN) , getJSON = require("get-json"); const getRecord = function(callback) { getJSON("https://rayons.info/items/random.json", function(err, item) { if (err) { console.log("got an error: ", err); callback(null); } else { const itemURL = `https://rayons.info/items/${item.id}`; callback(`You should listen to "${item.title}" by ${item.artist}: ${itemURL}`); } }); }; const sendSMS = function(message, callback) { twilio.sendMessage( { body: message, from: process.env.FROM_NUMBER, to: process.env.TO_NUMBER }, function(err, responseData) { console.log("Twilio response:", responseData); if (err) { callback("API request completed with error(s)."); } else { callback("API request sent successfully."); } } ); }; exports.handler = function (event, context) { getRecord(function(message) { if (message) { sendSMS(message, function(status) { context.done(null, status); }); } else { context.done(); } }); };
const env = require("node-env-file"); env(`${__dirname}/.env`); process.env.NODE_CONFIG_DIR = "/var/task/config"; const twilio
= require("twilio")(process.env.ACCOUNT_SID, process.env.AUTH_TOKEN) , getJSON = require("get-json");
const getRecord = function(callback) { getJSON("https://rayons.info/items/random.json", function(err, item) { if
(err) { console.log("got an error: ", err); callback(null); } else { const itemURL = `https://rayons.info/items/${item.id}`; callback(`You should listen to "${item.title}" by ${item.artist}: ${itemURL}`); } }); };
const sendSMS = function(message, callback) { twilio.sendMessage( { body: message,
from: process.env.FROM_NUMBER, to: process.env.TO_NUMBER }, function(err, responseData) { console.log("Twilio response:", responseData); if (err) { callback("API request completed with error(s)."); } else { callback("API request sent successfully."); } } ); };
exports.handler = function (event, context) { getRecord(function(message) { if (message)
{ sendSMS(message, function(status) { context.done(null, status); }); } else { context.done(); } }); };
None
Thank you! • github.com/GordonDiggs/what_should_i_listen_to_lambda • aws.amazon.com/lambda • twitter.com/GordonDiggs • bitly.com/gd-lambda