Skip to content

Instantly share code, notes, and snippets.

Express and Sequelize

Install

$ mkdir myapp
$ cd myapp
$ npm init #follow instructions - wizard app
$ git init
$ npm i express
@jmporchet
jmporchet / .eslintrc.js
Created January 22, 2018 09:58
react meteor .eslint
module.exports = {
"extends": "airbnb",
"plugins": [
"react",
"jsx-a11y",
"import"
],
"rules": {
"no-underscore-dangle": 0,
"react/forbid-prop-types": 0,
@jmporchet
jmporchet / cloudSettings
Last active November 21, 2019 22:04
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-11-21T22:04:21.419Z","extensionVersion":"v3.4.3"}
import { AsyncStorage } from 'react-native';
class AsyncStorageService {
static async get(key) {
const data = await AsyncStorage.getItem(key);
return JSON.parse(data);
}
static set(key, value) {
return AsyncStorage.setItem(key, JSON.stringify(value));
@jmporchet
jmporchet / EditPlanDetails.test.js
Created April 1, 2019 16:57
How to test componentDidUpdate with react-native-testing-library
import React from 'react';
import { render, fireEvent } from 'react-native-testing-library';
import { _EditPlanDetails as EditPlanDetails } from '../Settings/EditPlanDetails';
// Scrollviews are bugged in the current Expo/RN release and won't render in tests https://github.com/expo/expo/issues/2806#issuecomment-465373231
jest.mock('ScrollView', () => require.requireMock('ScrollViewMock'));
describe('EditPlanDetails', () => {
const props = {
subscription: {
@jmporchet
jmporchet / cloneTest.js
Last active April 4, 2019 13:50
Spread operator vs lodash's cloneDeep()
// This is an illustration of when NOT to use the spread operator to copy variables.
// Check https://codesandbox.io/s/6w749171mz for a working copy of the code
import { cloneDeep } from "lodash";
import {
getDrinkNutrientsFromResult,
mapRecipesToNutrients
} from "../nutrition";
describe("helper methods", () => {
@jmporchet
jmporchet / foodSaga.js
Created April 17, 2019 08:37
The correct way to make several network requests in one saga with yield
import { takeEvery, call, put, all, select } from 'redux-saga/effects';
import * as ActionTypes from '../actions';
import { networkService } from '../services/networkService';
export function* getAutocompleteInfo(action) {
const token = yield select(state => state.user.token);
const autocompleteSuggestions = yield call(
networkService.requestAutocompleteInfo,
action.query,
token
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/jean-marieporchet/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
@jmporchet
jmporchet / Component.stories.tsx
Created January 15, 2021 14:47
Add storybook addon-redux to an existing project with redux-sagas and connected-react-router
import React from 'react';
import { Story, Meta } from '@storybook/react/types-6-0';
import { Provider } from 'react-redux';
import addons from '@storybook/addons';
import withRedux from 'addon-redux/withRedux';
import { MyComponent } from '../components/MyComponent/MyComponent';
import store from '../store';
import { RootState } from '../types';
@jmporchet
jmporchet / index.html
Last active January 22, 2021 21:55
How to hide HTML elements if there's not enough space to display them integrally
<html>
<body>
<style type="text/css">
.container {
width: 300px;
height: 200px;
display: flex;
/* put the undesirable elements on a second column */
flex-flow: column wrap;
/* hide that second column */