Skip to content

Instantly share code, notes, and snippets.

View nelreina's full-sized avatar
💭

Nelreina nelreina

💭
View GitHub Profile
@nelreina
nelreina / boot.js
Created October 10, 2016 13:01 — forked from jdx/boot.js
zero-downtime node.js app runner
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
@nelreina
nelreina / publish.sh
Last active September 23, 2016 08:55
Rsync Copy files from computer to server
rsync -avzh ./${fromFolder}/ ${user}@${host}:/${folder}
@nelreina
nelreina / utils.js
Created September 14, 2016 21:09
Get Grid Row Columns/ React Utility function to for splitting data in row components
import React from 'react';
export const getGridRowColumns = (data, columns, Component, props ) => {
let retRows = [];
const rowCount = Math.ceil(data.length/ columns);
for (let i = 0; i < rowCount; i++) {
let rowData = [];
for (let x = 0; x < columns; x++) {
rowData.push( data[x + (i * columns)])
}
@nelreina
nelreina / snippets.cson
Last active May 18, 2017 12:02
Atom snippets
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
@nelreina
nelreina / index.js
Last active March 29, 2018 12:34
Redux Store Setup
import React from 'react';
import { render } from 'react-dom';
import App from './App';
import 'babel-polyfill';
import { Provider } from 'react-redux';
import store from './store';
render(
<Provider store={store}>
<App />
</Provider>,
@nelreina
nelreina / react-server.js
Last active October 1, 2016 12:37
A static server with proxy to /api. Good for serving react apps
const express = require('express');
const path = require('path');
const request = require('request');
const app = express();
const port = process.env.PORT || 4000;
const baseUrl = process.env.BASE_URL || '/registration';
const apiPort = process.env. API_PORT || 9000;
@nelreina
nelreina / .eslintrc-no-react
Last active November 27, 2016 16:23
Eslint no React
{
"extends": [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
@nelreina
nelreina / .editorconfig
Last active January 22, 2017 02:36
Editor Config
# editorconfig.org
root = true
[*]
indent_style = tab
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
var passport = require('passport');
var basicStrategy = require('passport-http').BasicStrategy;
passport.use(new basicStrategy(basicAuth));
passport.serializeUser(function(user, done) {
done(null, user.id);
});
passport.deserializeUser(function(id, done) {