Skip to content

Instantly share code, notes, and snippets.

const assertValidEmail = (value, errorMessage) => {
const pattern = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (!pattern.test(value)) {
throw new Error(errorMessage || translator('error.email.malformatted', { email: value}));
}
};
const assertAvailableEmail = async (value) => {
return fetch('/validate_email', {
@sauldeleon
sauldeleon / 1.SomeComponent.stories.js
Last active September 5, 2020 12:36
Storybook meets axios meets redux meets thunk
/**
This is my workarround to create a React Story for a component which internally dispatch multiple thunk actions
and also retrieve info from some server. This works also on making an story in which its main component wraps another redux
connected components.
*/
/**
BEHAVIOUR EXPLANATION
This component depends on an ID (fetchingDataId) which is stored in the parent component which contains many SomeComponents, so I need to mock the store before SomeComponent's story loads
Then, when a single SomeComponent loads, it renders two connected subcomponents which I dont have control from Storybook. And I want the story to render both components at the same time.
@HyperBrain
HyperBrain / lifecycle-cheat-sheet.md
Last active March 20, 2024 00:17
Serverless Lifecycle Cheat Sheet

Serverless plugin author's cheat sheet

This cheat sheet provides a detailed overview of the exposed lifecycle events and available commands (and entrypoints) of the Serverless framework, that can be hooked by plugins (internal and external ones). The document is structured by the commands invoked by the user.

Lifecycle events are shown as the globally available outer events (all providers) and sub lifecycle events that are provider specific in the called order. Currently only the AWS provider is shown. If you have information about the other provider,

anonymous
anonymous / app.dockerfile
Created January 2, 2017 11:02
FROM php:7.0.4-fpm
RUN apt-get update && apt-get install -y libmcrypt-dev \
mysql-client libmagickwand-dev --no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& docker-php-ext-install mcrypt pdo_mysql
NAME=$(git branch | grep '*' | sed 's/* //')
DESCRIPTION=$(git config branch."$NAME".description)
TEXT=$(cat "$1" | sed '/^#.*/d')
if [ -n "$TEXT" ]
then
echo "$NAME"': '$(cat "$1" | sed '/^#.*/d') > "$1"
if [ -n "$DESCRIPTION" ]
then
echo "" >> "$1"
@sam-artuso
sam-artuso / setting-up-babel-nodemon.md
Last active November 3, 2023 08:52
Setting up Babel and nodemon

Setting up Babel and nodemon

Inital set-up

Set up project:

mkdir project
cd project
npm init -y
@developit
developit / README.md
Last active March 21, 2022 21:32
Webpack Starter Template

Webpack Starter Template

This is a basic Webpack project template for a web app written in ES6 & LESS.

This assumes you have a directory structure as follows:

package.json
webpack.config.js
src/
@gokulkrishh
gokulkrishh / media-query.css
Last active April 26, 2024 10:32
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
/* CSS */
@tomaskikutis
tomaskikutis / app.tsx
Created September 20, 2015 19:01
react typescript browserify
// npm install browserify -g
// npm install tsd -g
// npm install react tsify
// tsd install react
// browserify app.tsx -p [tsify --jsx=react] -o bundle.js
/// <reference path="typings/react/react.d.ts" />
import React = require("react");
interface HelloWorldComponentProps extends React.Props<any> {