Skip to content

Instantly share code, notes, and snippets.

@sbalay
sbalay / express-validator-example.js
Created June 5, 2018 15:35
Express validator example
const { checkSchema } = require('express-validator/check');
exports.validateCalculate = [
checkSchema({
product: {
in: ['query'],
errorMessage: 'product must be an integer',
exists: true,
isInt: { options: { min: 0 } },
toInt: true
@sbalay
sbalay / s3-deploy.sh
Created August 21, 2018 18:03
Script to upload content to S3
#!/bin/bash
# $1 bucket-name
# $2 env
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
@sbalay
sbalay / FormNormalizeAndFormatValues.js
Last active July 11, 2022 05:02
Redux-form example with normalize and format
import React from 'react';
import { reduxForm, Field } from 'redux-form';
import { ScrollView, Text, TouchableOpacity } from 'react-native';
import moment from 'moment';
import MyTextInput from './MyTextInput';
/**
* Automatically adds the dashes required by the specified phone format and limits the input to ten characters
*/
@sbalay
sbalay / index.html
Created June 19, 2017 05:10
Videojs hls example
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>videojs-contrib-hls embed</title>
<!--
Uses the latest versions of video.js and videojs-contrib-hls.
@sbalay
sbalay / MyForm.js
Last active December 14, 2023 15:50
React Native form, meant to be used with redux-form HOC
import React from 'react';
import { reduxForm, Field } from 'redux-form';
import { ScrollView, Text, TouchableOpacity } from 'react-native';
import MyTextInput from './MyTextInput'
function MyForm(props) {
const formStates = ['asyncValidating', 'dirty', 'pristine', 'valid', 'invalid', 'submitting',
'submitSucceeded', 'submitFailed'];