Skip to content

Instantly share code, notes, and snippets.

View node_hello_world.js
const http = require('http');
const hostname = '';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
>>> from pyteaser import SummarizeUrl
>>> url = ''
>>> summaries = SummarizeUrl(url)
>>> print summaries
"Twitter's move is the latest response from U.S. Internet firms following disclosures by former spy agency contractor Edward Snowden about widespread, classified U.S. government surveillance programs.",
"Since then, it has become clearer and clearer how important that step was to protecting our users' privacy.",
"The online messaging service, which began scrambling communications in 2011 using traditional HTTPS encryption, said on Friday it has added an advanced layer of protection for HTTPS known as 'forward secrecy'",
View snippet_serverless_summarize.yaml
handler: handler.summarize
- http:
path: summarize
method: post
View example_slack_message_handler.js
// Initialize using signing secret from environment variables
const { createEventAdapter } = require('@slack/events-api');
const slackEvents = createEventAdapter(process.env.SLACK_SIGNING_SECRET);
const port = process.env.PORT || 3000;
// Attach listeners to events by Slack Event "type". See:
slackEvents.on('message', (event) => {
console.log(`Received a message event: user ${event.user} in channel ${} says ${event.text}`);
View snippet_serverless.yaml
handler: handler.sqsEvent
- http:
path: slack_sqs
method: POST
- sqs: "arn:aws:sqs:us-east-1:<identifierhere>:summarizer-slack-to-summarizer"
View sqsEvent_serverless.js
module.exports.sqsEvent = async (event, context, callback) => {
// Read the SQS message we sent to ourselves
const record = event.Records[0];
const thread = record.messageAttributes.Thread.stringValue;
const channel = record.messageAttributes.Channel.stringValue;
const token = record.messageAttributes.Token.stringValue;
let url = record.messageAttributes.URL.stringValue;
View cortex.yaml
- name: summarizer
type: python
cpu: 1
gpu: 1
mem: 1G
View slack_postmessage.js
var postMessage = async function(params) {
var response = await fetch('', {
method: 'POST',
body: params
var data = await response.json()
return data
View slack_serverless_handler.js
var buildReply = async function (msg, token, thread, url) {
var channel =
// Check if URL exists
if (url.length > 0) {
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
region: 'us-east-1'
// Create an SQS service object
View summarizer_serverless_handler.js
module.exports.summarize = async (event, context, callback) => {
var body = event.body
var url = JSON.parse(body).url
let {
} = await utils.getSummaryFromUrl(url)
return {
You can’t perform that action at this time.