- Be a Vim user.
- Install UltiSnips.
- Add the code below to
$YOUR_VIM_FOLDER/UltiSnips/javascript.snippets
.
snippet ii "magic import" b
import `!p
import { crc32 } from 'common/components/Features/Experiment/crc32'; | |
import { Config } from 'common/api/models/Config'; | |
const sortBy = require('lodash.sortby'); | |
export interface Experiments { | |
[name: string]: Variant[]; | |
} | |
export interface Variant { | |
name: string; |
import { SessionContext } from "blitz" | |
import db from "db" | |
import { authenticateUser, hashPassword } from "app/auth/auth-utils" | |
import * as z from "zod" | |
// -------------------------------------------- | |
// PROTECT UTIL | |
type Ctx = { session: SessionContext } | |
type ProtectArgs<T> = { schema: T; authorize?: boolean } |
import { ApolloServer, gql } from 'apollo-server-micro'; | |
const typeDefs = gql` | |
type Query { | |
sayHello: String | |
} | |
`; | |
const resolvers = { | |
Query: { |
// @flow | |
import * as React from "react"; | |
const DEFAULT_PIXEL_RATIO = 1; | |
function processPixelRatio(input: ?number): number { | |
return input ?? DEFAULT_PIXEL_RATIO; | |
} | |
// matchMedia feature detection |
#! /usr/bin/env node | |
'use strict'; | |
const program = require('commander'); | |
const fs = require('fs'); | |
const { spawn } = require('child_process'); | |
program | |
.version('1.0.0') | |
.option('-e, --environment <environment>', 'Environment to deploy to') |
import { createCipheriv, createDecipheriv, randomBytes } from "crypto"; | |
const ENCRYPTION_KEY: string = process.env.ENCRYPTION_KEY || ""; // Must be 256 bits (32 characters) | |
const IV_LENGTH: number = 16; // For AES, this is always 16 | |
/** | |
* Will generate valid encryption keys for use | |
* Not used in the code below, but generate one and store it in ENV for your own purposes | |
*/ | |
export function keyGen() { |
import React from 'react'; | |
import { shallow } from 'enzyme'; | |
import MyComponent from '../src/my-component'; | |
const wrapper = shallow(<MyComponent/>); | |
describe('(Component) MyComponent', () => { | |
it('renders without exploding', () => { | |
expect(wrapper).to.have.length(1); | |
}); |
// load as early as possible | |
if(process.env.NOW){ | |
require('dotenv').config({path:'./.envnow', silent:true}); | |
}else{ | |
require('dotenv').config({silent:true}); | |
} | |
// now you can deploy with: | |
//$cp .env .envnow && now && rm -r .envnow |