Skip to content

Instantly share code, notes, and snippets.

const productApiResponses = await Promise.all(
itemNumbers.map(async (itemNumber: string) => {
try {
const productAPIResponse = await productService(
itemNumber,
productConfig,
locale
);
if (!productAPIResponse) return null;
Pre-req's:
Python 3
A project that is git initialized
Windozs setup:
pip install pre-commit
MAC OS setup for pre-commit:
@visualjeff
visualjeff / gist:412f89aecce959fd71513dbc809be3e4
Created January 27, 2021 04:20
Script for processing megaMenu. Save to root of forge project as index.js. Run as "node index.js"
// Note you may need to update the path to our sample data.
let data = require('./src/stories/menus/megaMenu/megamenu.json');
const sortByName = (a, b) => {
return a.name > b.name ? 1 : b.name > a.name ? -1 : 0;
};
// This function should be memoized for performance reasons.
const sortParent = (data) => {
let sortedData = [...data];
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].
import Component from '@glimmer/component';
export default class BlogPost extends Component {
}
@visualjeff
visualjeff / gist:ba6ebac7c80572046f02b879edd24789
Last active July 11, 2019 22:43
Example URL's for different types of Azure Authentication
For non-interactive login:
For a v2 Token:
https://login.microsoftonline.com/<<TENANT_NAME>>.onmicrosoft.com/oauth2/v2.0/authorize?response_type=id_token&scope=openid%20profile&client_id=<<CLIENT_ID>>&redirect_uri=https%3A%2F%2Fjwt.ms&nonce=null
For a v1 Token:
https://login.microsoftonline.com/common/oauth2/authorize?client_id=<<CLIENT ID>>&response_type=id_token&nonce=null
For an interactive login (if you need to set an initial password) for B2C:
@visualjeff
visualjeff / gist:1cda46847ae3b089c2a254461ef9ffe7
Last active May 6, 2019 03:57
Publishing a NPM module from GitHub
First, be sure make sure you've set your git user.name and user.email:
git config --global user.name "FIRST_NAME LAST_NAME"
git config --global user.email [email protected]
Create new local branch to work in:
git checkout -b v1.0.0
Set version number in your project's package.json!!!
import Ember from 'ember';
export default Ember.Component.extend({
});
//You could use faker.js to generate some testData
function chunk(arr, chunkSize) {
const R = [];
for (let i = 0, len = arr.length; i < len; i += chunkSize) {
R.push(arr.slice(i, i + chunkSize));
}
return R;
}
@visualjeff
visualjeff / gist:0ec717c964620b75f050c93ee286a936
Last active August 21, 2018 03:11
Easy way to generate fake user records with faker.js
const faker = require('faker');
const testData = new Array(100).fill({}).map((v, i) => {
return {
name: faker.name.findName(),
address: faker.address.streetAddress(),
city: faker.address.city(),
state: faker.address.stateAbbr(),
postal: faker.address.zipCode(),
email: ''