Skip to content

Instantly share code, notes, and snippets.

@sbalay
sbalay / MyForm.js
Last active January 26, 2017 20:12
import React from 'react';
import { reduxForm, Field } from 'redux-form';
import { ScrollView, Text } from 'react-native';
import MyTextInput from './MyTextInput';
function MyForm() {
return (
<ScrollView keyboardShouldPersistTaps={'handled'}>
<Text>Email</Text>
@sbalay
sbalay / MyTextInput.js
Last active January 26, 2017 20:12
React Native's TextInput wrapper to be used with redux-form
import React from 'react';
import { TextInput, View, Text } from 'react-native';
/**
* to be wrapped with redux-form Field component
*/
export default function MyTextInput(props) {
const { input, ...inputProps } = props;
return (
@sbalay
sbalay / rc.local
Created September 2, 2016 15:51
Startup script to launch prerender
#!/bin/sh -e
sleep 2
su - ubuntu -c /home/ubuntu/prerender_startup.sh
exit 0
@sbalay
sbalay / prerender_startup.sh
Last active September 2, 2016 15:50
bash script to start prerender
#!/bin/bash
#Starts forever after boot through /etc/rc.local. Set the node version in the following script properly.
/home/<user>/.nvm/versions/node/<node version>/bin/forever start /home/<user>/<path to prerender>/server.js
@sbalay
sbalay / nginx
Last active March 14, 2018 11:16
prerender nginx config
server {
listen 80;
root /home/yourusername/www/mysite;
location / {
try_files $uri @prerender;
}
location @prerender {
@sbalay
sbalay / jsTask.js
Created February 1, 2016 16:05
Js gulp task with environment custom settings
import gulp from 'gulp';
import uglify from 'gulp-uglify';
import eslint from 'gulp-eslint';
import babel from 'gulp-babel';
import concat from 'gulp-concat';
import sourcemaps from 'gulp-sourcemaps';
import gulpif from 'gulp-if';
import globalConfig from './config';
const taskOptions = globalConfig.getConfigKeys();
@sbalay
sbalay / production.js
Created February 1, 2016 16:00
Gulp tasks' settings for production environment
export default {
/**
* concat
* Enables/Disables source files concatenation
*/
concat: true,
/**
* lint
@sbalay
sbalay / development.js
Created February 1, 2016 15:59
Gulp tasks' settings for development environment
export default {
/**
* concat
* Enables/Disables source files concatenation
*/
concat: false,
/**
* lint
@sbalay
sbalay / config.js
Created February 1, 2016 15:56
Config file for gulp tasks able to read environment settings
import { argv } from 'yargs';
export default {
environment: argv.env || 'development',
getConfigKeys () {
let keys;
try {
keys = require(`./${this.environment}`);
} catch (e) {
throw new Error(`No config file found for environment ${this.environment}`);
@sbalay
sbalay / jsTask.js
Created February 1, 2016 15:47
js gulp task modified for qa environment
gulp.task('js', () =>
gulp.src(localConfig.src)
.pipe(gulpif(globalConfig.development(), eslint()))
.pipe(gulpif(globalConfig.development(), eslint.format()))
.pipe(gulpif(globalConfig.development(), sourcemaps.init()))
.pipe(babel())
.pipe(gulpif(globalConfig.production() || globalConfig.qa(), concat(localConfig.buildFileName)))
.pipe(gulpif(globalConfig.production(), uglify()))
.pipe(gulpif(globalConfig.development(), sourcemaps.write()))
.pipe(gulp.dest(localConfig.dest))