This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
spaceships = {...} | |
key_list = list(spaceships.keys()) | |
def get_random_ship(): | |
id = random.choice(key_list) | |
return spaceships[id] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
spaceships = {...} | |
def get_random_ship(): | |
key_list = list(spaceships.keys()) | |
# Pick a random key from key list | |
id = random.choice(key_list) | |
return spaceships[id] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
spaceships = {...} | |
def get_random_ship(): | |
# Generate a random spaceship id | |
id = random.randint(0, 100000000) | |
return spaceships[id] # KeyError ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HTTPError implements ClientError interface. | |
type HTTPError struct { | |
Cause error `json:"-"` | |
Detail string `json:"detail"` | |
Status int `json:"-"` | |
} | |
func (e *HTTPError) Error() string { | |
if e.Cause == nil { | |
return e.Detail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ClientError is an error whose details to be shared with client. | |
type ClientError interface { | |
Error() string | |
// ResponseBody returns response body. | |
ResponseBody() ([]byte, error) | |
// ResponseHeaders returns http status code and headers. | |
ResponseHeaders() (int, map[string]string) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/json" | |
"io/ioutil" | |
"log" | |
"net/http" | |
) | |
type loginSchema struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.handler = async (event) => { | |
// Convert translate lambda output to sendMail lambda input. | |
event.sendMailInput.message = event.translateOutput.text; | |
return event; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AWS = require('aws-sdk'); | |
const stepFunctions = new AWS.StepFunctions({}); | |
exports.handler = async (event) => { | |
const notes = await getNotes(user.id); // Fetch user notes from database. | |
const sfnInput = { // Prepare Step Functions input | |
translateInput: { // translate Task will use this input. | |
text: notes, | |
language: event.translateTo | |
}, |
NewerOlder