Skip to content

Instantly share code, notes, and snippets.

View nelreina's full-sized avatar
💭

Nelreina nelreina

💭
View GitHub Profile
@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 / 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 / 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 / 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 / publish.sh
Last active September 23, 2016 08:55
Rsync Copy files from computer to server
rsync -avzh ./${fromFolder}/ ${user}@${host}:/${folder}
@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 / hot-reload.js
Created December 3, 2016 04:30
create-react-app hot reload script goes in index.js
if (module.hot) {
module.hot.accept('./App', _ => {
const App = require('./App').default;
ReactDOM.render(
<App />,
document.getElementById('root')
);
})
}
import { combineReducers } from 'redux';
export default combineReducers({
default: (state ={}, action) => state
})
"Require Node Module": {
"prefix": "creq",
"body": ["const ${1:module} = require('${1:module}');"],
"description": "Require Node Module"
},
"Require Local File Node Module": {
"prefix": "cfreq",
"body": ["const ${2:module} = require('.${1:file}');"],
"description": "Require Node Module"
},
@nelreina
nelreina / run-x-times.sql
Created August 23, 2017 19:23
run-insert-statement-x-number-of-times
create procedure insert_into_b
@numInserts int
as
begin
while @numInserts > 0
begin
insert into b (id)
select id from a
set @numInserts = @numInserts - 1
end