Skip to content

Instantly share code, notes, and snippets.

View K-Mistele's full-sized avatar
🏴‍☠️

Kyle Mistele K-Mistele

🏴‍☠️
View GitHub Profile
@K-Mistele
K-Mistele / example.py
Created November 11, 2020 22:43
CodeLighthouse Example Code
def broken_function():
not_a_dictionary = 1
not_a_dictionary.append("hello")
broken_function()
@K-Mistele
K-Mistele / application.py
Last active November 12, 2020 16:06
A sample flask app
from flask import Flask
# create your app
app = Flask(__name__)
# create application routes
@app.route("/hello")
def say_hello():
return "Hello!"
@K-Mistele
K-Mistele / application.py
Last active November 12, 2020 16:26
Integrating CodeLighthouse into our example Flask app
from flask import Flask
# importing codelighthouse's SDK
from codelighthouse import CodeLighthouse
# configure the SDK
lighthouse = CodeLighthouse(
organization_name="Your organization name here",
x_api_key="your API key here",
resource_name="Sample Flask App", # the resource name is up to you
@K-Mistele
K-Mistele / application.py
Last active November 12, 2020 16:30
Using the CodeLighthouse error_catcher decorator with multiple users
from flask import Flask
# importing codelighthouse's SDK
from codelighthouse import CodeLighthouse
# configure the SDK
lighthouse = CodeLighthouse(
organization_name="Your organization name here",
x_api_key="your API key here",
resource_name="Sample Flask App", # the resource name is up to you
@K-Mistele
K-Mistele / app.js
Last active December 14, 2020 22:05
Configuring CodeLighthouse's Node.js SDK
// IMPORT CODELIGHTHOUSE
const CodeLighthouse = require('codelighthouse');
// INSTANTIATE THE ERROR CATCHER
const codelighthouse = new CodeLighthouse(
organization_name="your organization name",
api_key="your API Key",
default_email="code owner's email address"
resource_group="serverless-applications",
resource_name="notifications-app"
@K-Mistele
K-Mistele / app.js
Last active December 9, 2020 22:35
CodeLighthouse's Express.js Integration
// NOTE: make sure you've imported and configured codelighthouse first!
const app = express();
// NOTE: this must be the first piece of middleware in the app
app.use(codelighthouse.integrations.express.requestHandler);
// your routes and middleware go here
app.route("/", (request, response, next) => {
// CODE HERE
});
@K-Mistele
K-Mistele / app.js
Created December 9, 2020 22:42
Manually catching exceptions with CodeLighthouse's Node.js SDK
// NOTE: make sure you've imported and configured codelighthouse first!
try {
// your code here
}
catch (err) {
// send the error notification to the user specified in the SDK configuration
codelighthouse.error(err);
// alternatively, you can send it to a user of your choice:
codelighthouse.error(err, "user@your_comapny.com");
@K-Mistele
K-Mistele / example.py
Created December 22, 2020 22:21
An example of the AWS S3 Client I wrote for CodeLighthouse
import s3_bucket as S3
import os
# get your key data from environment variables
AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')
# initialize the package
S3.Bucket.prepare(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
@K-Mistele
K-Mistele / example.py
Created December 22, 2020 22:22
Using the Bucket API
bucket = S3.Bucket('your bucket name')
#example
bucket = S3.Bucket('my-website-data')
@K-Mistele
K-Mistele / example.py
Created December 22, 2020 22:25
Using the Bucket API's Exceptions
try:
bucket = S3.Bucket('my-bucket-name')
data, metadata = bucket.get('some key')
except S3.Exceptions.NoSuchBucket as e:
# some error handling here
pass