This file contains 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
Promise.resolve(true) | |
.then(() => { | |
console.log('First then() was called!'); | |
throw new Error('error!!!'); | |
return true; | |
}) | |
.catch((err) => { | |
console.log('First catch() was called'); | |
console.log('Error: ', err); |
This file contains 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
'use strict' | |
const Config = use('Config') | |
/** | |
* JSON-P middleware for AdonisJS 4.1 | |
* https://gist.github.com/Sleavely/da1ac50e1ea614b4171beae7868ec3ed | |
*/ | |
class JsonpDetector { | |
async handle ({ request, response }, next) { |
This file contains 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 _currentTab = new Promise((resolve) => { | |
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => { | |
resolve(tabs[0]) | |
}) | |
}); | |
const _currentWindow = new Promise((resolve) => { | |
chrome.windows.getCurrent((win) => resolve(win)) | |
}); |
This file contains 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
// Require the framework and instantiate it | |
const api = require('lambda-api')() | |
// Define a route | |
api.get('/status', async (req, res) => { | |
return { status: 'ok' } | |
}) | |
api.get('/README.md', async (req, res) => { | |
res.sendFile('./README.md') |
This file contains 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
# put this in your ~/.profile or equivalent | |
JIRA_HOST="foobar.atlassian.net" | |
function jira { | |
# Uppercase the argument | |
TARGET_TICKET=${TARGET_TICKET^^} | |
# Inject dash if its not there | |
TARGET_TICKET=$(echo ${1} | sed -E --expression='s/([A-Z]+)([0-9]+)/\1-\2/g') |
This file contains 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
await API.get('myCloudApi', '/items', { | |
responseType: 'blob', | |
response: true | |
}) | |
.then((response) => { | |
const blob = new Blob([response.data], { type: 'application/octet-stream' }) | |
const filename = response.headers['content-disposition'].split('"')[1] | |
if (typeof window.navigator.msSaveBlob !== 'undefined') { |
This file contains 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 React, { useEffect, useState } from 'react' | |
import { CartProvider } from "use-cart" | |
import { LoadCart, SaveCart } from "./cartStorage" | |
function App() { | |
return ( | |
<CartProvider initialCart={LoadCart()}> | |
<SaveCart /> | |
<RestOfApp> ... </RestOfApp> |
This file contains 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
// Graciously stolen from lodash's stringToPath | |
const charCodeOfDot = '.'.charCodeAt(0) | |
const reEscapeChar = /\\(\\)?/g | |
const rePropName = RegExp( | |
// Match anything that isn't a dot or bracket. | |
'[^.[\\]]+' + '|' + | |
// Or match property names within brackets. | |
'\\[(?:' + | |
// Match a non-string expression. | |
'([^"\'][^[]*)' + '|' + |
This file contains 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
// The original values have been redacted, but their general format remains for display purposes. | |
{ | |
AWS_ACCESS_KEY_ID: 'ASIA5USITABHEEWHMCOL', | |
AWS_DEFAULT_REGION: 'eu-west-1', | |
AWS_EXECUTION_ENV: 'AWS_Lambda_nodejs12.x', | |
AWS_LAMBDA_FUNCTION_MEMORY_SIZE: '128', | |
AWS_LAMBDA_FUNCTION_NAME: 'tmp1337', | |
AWS_LAMBDA_FUNCTION_VERSION: '$LATEST', | |
AWS_LAMBDA_LOG_GROUP_NAME: '/aws/lambda/tmp1337', | |
AWS_LAMBDA_LOG_STREAM_NAME: '2020/01/14/[$LATEST]425d2a3419de4db38f86fc1896cc1cc1', |
This file contains 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 attributes = { | |
// Attribute Keys are always localized | |
'color': { | |
name: { | |
'en-US': 'Color', | |
'sv-SE': 'Färg', | |
}, | |
}, | |
'size': { |