This file contains hidden or 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
| if ! command -v npx | |
| then | |
| echo "npx is required to be installed for this script" | |
| exit | |
| fi | |
| echo "Creating a new project using create-react-app" | |
| npx create-react-app $1 | |
| cd $1 |
This file contains hidden or 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
| let randomLoop = 8; | |
| let parentContainer = document.getElementsByClassName("scrollRegion"); | |
| const getRandomNumber = (min, max) => { | |
| return Math.floor(Math.random() * (max - min + 1) + min); | |
| }; | |
| function task(index) { | |
| if (index >= randomLoop) return; | |
| let parent = document.getElementsByClassName("scrollRegion")[1]; |
This file contains hidden or 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 express from 'express'; | |
| import csrf from 'csurf'; | |
| import cookieParser from 'cookie-parser'; | |
| const app = express(); | |
| app.use(cookieParser()); | |
| app.use(csrf({ cookie: true })); | |
| app.use((req, res, next) => { |
This file contains hidden or 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 express from 'express'; | |
| import helmet from 'helmet'; | |
| const app = express(); | |
| // Use helmet to set various HTTP headers | |
| app.use(helmet()); | |
| // Set a custom Content Security Policy | |
| app.use(helmet.contentSecurityPolicy({ |
This file contains hidden or 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 { getRepository } from 'typeorm'; | |
| import { User } from './entity/User'; | |
| async function getUser(username: string): Promise<User | undefined> { | |
| const userRepository = getRepository(User); | |
| return await userRepository.findOne({ where: { username } }); | |
| } | |
| // Usage | |
| const user = await getUser(username); |
This file contains hidden or 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 express from 'express'; | |
| import session from 'express-session'; | |
| import crypto from 'crypto'; | |
| const app = express(); | |
| app.use(session({ | |
| secret: 'your-secret-key', | |
| resave: false, | |
| saveUninitialized: true, |
This file contains hidden or 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 { Request, Response, NextFunction } from 'express'; | |
| interface User { | |
| id: string; | |
| roles: string[]; | |
| } | |
| function checkPermission(permission: string) { | |
| return (req: Request, res: Response, next: NextFunction) => { | |
| const user = req.user as User; |
This file contains hidden or 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
| class AppearanceModeProvider { | |
| constructor() { | |
| this.currentMode = 'default'; | |
| } | |
| setMode(mode) { | |
| this.currentMode = mode; | |
| this.applyMode(); | |
| } |
This file contains hidden or 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
| [LicensePlans.WATERFALL]: { | |
| TEMPLATE: [ | |
| ETemplateId.WATERFALL_VERTICAL, | |
| ETemplateId.WATERFALL_HORIZONTAL, | |
| ETemplateId.WATERFALL_SINGLE_MEASURE_HORIZONTAL, | |
| ETemplateId.WATERFALL_SINGLE_MEASURE_VERTICAL, | |
| ETemplateId.COLUMN_WATERFALL_HORIZONTAL, | |
| ETemplateId.COLUMN_WATERFALL_VERTICAL, | |
| ETemplateId.PAIRED_WATERFALL_HORIZONTAL, | |
| ETemplateId.PAIRED_WATERFALL_VERTICAL, |
This file contains hidden or 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
| [ | |
| { | |
| "date": "2000-01-01T00:00:00.000Z", | |
| "industry": "Manufacturing", | |
| "unemployed": 734 | |
| }, | |
| { | |
| "date": "2000-02-01T00:00:00.000Z", | |
| "industry": "Manufacturing", | |
| "unemployed": 694 |