Skip to content

Instantly share code, notes, and snippets.

exports.transferHandler = function transferHandler(event, context) {
context.callbackWaitsForEmptyEventLoop = false;
const time = new Date();
const current_time_unix = moment().unix();
connectToDatabase()
.then(() => {
BookingModel
.find({})
.then((bookings) => {
@sendgrid-gists
sendgrid-gists / tables-billing-plan.html
Last active May 30, 2021 17:14
SendGrid style-guide plan table
<table class="table-wrap is-billing">
<tr>
<th>Base Plan</th>
<td>
<p>Pro 100K</p>
<p class="plan-details">100,000 emails/mo</p>
<button class="btn btn-small btn-secondary">Change Plan</button>
</td>
<td>
$67.96
@DavidWells
DavidWells / aws-lambda-redirect.js
Created June 28, 2018 20:48
How to do a 301 redirect from an AWS lambda function
exports.handler = (event, context, callback) => {
const response = {
statusCode: 301,
headers: {
Location: 'https://google.com',
}
};
return callback(null, response);
}
@indexzero
indexzero / i18n-time-intervals.js
Created June 29, 2017 18:33
Generate a 24 hour range of 30-minute time intervals that are i18n compatible
let items = [];
for (var hour = 0; hour < 24; hour++) {
items.push([hour, 0]);
items.push([hour, 30]);
}
const date = new Date();
const formatter = new Intl.DateTimeFormat('en-US', {
hour: 'numeric',
minute: 'numeric',
@fgilio
fgilio / axios-catch-error.js
Last active April 11, 2024 19:02
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@chrissimpkins
chrissimpkins / gist:5bf5686bae86b8129bee
Last active June 19, 2024 18:05
Atom Editor Cheat Sheet: macOS

Use these rapid keyboard shortcuts to control the GitHub Atom text editor on macOS.

Key to the Keys

  • ⌘ : Command key
  • ⌃ : Control key
  • ⌫ : Delete key
  • ← : Left arrow key
  • → : Right arrow key
  • ↑ : Up arrow key
@brandonmwest
brandonmwest / example.cs
Last active June 27, 2024 04:03
Generating base64-encoded Authorization headers in a variety of languages
httpClient.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue(
"Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", username, password))));