Skip to content

Instantly share code, notes, and snippets.

View andrewtamura's full-sized avatar

Andrew Tamura andrewtamura

View GitHub Profile
@andrewtamura
andrewtamura / serverContext.js
Last active June 28, 2016 07:59
Set EC2 instance ID as Sentry Tag
var AWS = require('aws-sdk');
var Raven = require('./raven');
var meta = new AWS.MetadataService();
meta.request("/latest/meta-data/instance-id", function(err, data){
Raven.setTagsContext({
EC2InstanceId: data
});
});
@andrewtamura
andrewtamura / multipleCodepaths.js
Last active June 28, 2016 07:58
Multiple code paths with culprit
var raven = require('./raven');
function foo() {
try {
thowsException();
} catch (err) {
raven.captureException(err, {
culprit: 'Error from thowsException in foo'
});
}
@andrewtamura
andrewtamura / multipleCodepaths.js
Created June 25, 2016 06:03
The same error from multiple code paths
var raven = require('./raven.js');
function foo() {
try {
thowsException();
} catch (err) {
raven.captureException(err);
}
}
@andrewtamura
andrewtamura / raven.js
Last active May 10, 2017 18:26
raven wrapper with monkey patch for local logging
var Raven = require('raven');
// Configure the Raven client from the Sentry DSN. For local development, keep this environment variable unset to prevent
// Raven from sending events to sentry
var ravenClient = new Raven.Client(configOptions);
var originalCaptureException = ravenClient.captureException;
// Monkey patch the captureException function for easier development flow.
ravenClient.captureException = function() {
@andrewtamura
andrewtamura / raven.js
Last active June 25, 2016 04:30
raven wrapper
var Raven = require('raven');
// Configure the Raven client from the Sentry DSN. For local development, keep this environment variable unset to prevent
// Raven from sending events to sentry
var ravenClient = new Raven.Client();
// Return the configured Raven client
module.exports = ravenClient;
var sync = require('synchronize');
sync.fiber(function() {
try {
sync.await(func1(sync.defer()));
console.log('hits');
} catch (e) {
console.log('exception');
}
});
@andrewtamura
andrewtamura / index.js
Last active May 5, 2016 11:42
Lambda function: Modulus Webhook to Slack incoming webhook
var request = require('request');
var util = require('util');
var slackWebhookUrl = '<YOUR_SLACK_WEBHOOK_API_URL>';
exports.handler = function(event, context) {
var data = convertModulusWebhook(event);
var options = {
method: 'post',
body: data,
var input = 'This is my string 🙉';
function reverse(input) {
var output = ''
for (var i=0; i<input.length; i++) {
output = input[i] + output;
}
return output;
}
var foo = '🙉';
foo.length // what is this string's length?