Skip to content

Instantly share code, notes, and snippets.

View reciosonny's full-sized avatar
🎯
Focusing

Sonny R. Recio reciosonny

🎯
Focusing
View GitHub Profile
@reciosonny
reciosonny / configKeys.js
Last active February 20, 2018 01:58
Separating keys for each development stage in Node #nodejs
if (process.env.NODE_ENV === 'production') {
//we are in production
module.exports = require('./prod');
} else {
module.exports = require('./dev');
}
@reciosonny
reciosonny / authRoutes.js
Last active February 19, 2018 11:08
PassportJS authentication setup #passportjs #cookiesession #nodejs
const passport = require("passport");
module.exports = app => {
app.get(
"/auth/google",
//passport gets GoogleStategy as strategy when we specify `google` string
passport.authenticate("google", {
scope: ["profile", "email"] //scope specifies to google what access we want to have inside user's profile. Google has lists of scopes to be used in this array
})
);
@reciosonny
reciosonny / inbox.component.ts
Last active January 28, 2018 04:43
Injecting global events
import { EventHandlerService } from './../../services/event-handler.service';
import { GlobalVariableStore } from './../../global';
import { Component, OnInit, Input, HostListener, EventEmitter, Directive, ElementRef, Inject } from '@angular/core';
import { TodoService } from '../../services/todo.service';
import { Todo } from '../../models/Todo';
import {
trigger,
state,
style,
animate,
@reciosonny
reciosonny / reactRouterStarter_StephenGrider.js
Created December 13, 2017 01:57
React-router starter code #react
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import { BrowserRouter, Route, Switch } from "react-router-dom";
import promise from 'redux-promise';
import PostsIndex from './components/posts_index';
import PostsNew from './components/posts_new';
import reducers from './reducers';
@reciosonny
reciosonny / reduxFormBasicBoilerplate.js
Created December 10, 2017 08:41
Redux-form sample boilerplate code #redux-form
import React, { Component } from "react";
import { Field, reduxForm } from 'redux-form';
import { Link } from 'react-router-dom';
import {connect} from 'react-redux';
import {createPost} from '../actions';
class PostsNew extends Component {
renderField(field) {
const { meta: { touched, error } } = field; //ES6 destructuring
const className = `form-group ${touched && error ? 'has-danger' : ''}`;
@reciosonny
reciosonny / reduxContainerBoilerplate1.js
Last active November 28, 2017 17:02
Redux container boilerplate #redux
import React, { Component } from "react";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import { fetchWeather } from "../actions/index"; //action
//Component becoming a container for redux
class SearchBar extends Component {
constructor(props) {
super(props);
@reciosonny
reciosonny / hero-list-basic.component.ts
Created November 7, 2017 13:54
Angular 4 basic animation #angular #js
import { HeroService } from './../../services/hero.service';
import { Hero } from './../../hero';
import {
Component,
Input
} from '@angular/core';
import {
trigger,
state,
style,
@reciosonny
reciosonny / inputFocusAngular4.ts
Last active October 30, 2017 03:43
Using directive to focus control in angular 4 #angular
import { NgbActiveModal, NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { Input, Component, HostListener, ViewChild, ElementRef, OnInit, Directive, Renderer, AfterViewInit } from '@angular/core';
//reusable modal.
//more on this reusable component: https://ng-bootstrap.github.io/#/components/modal/examples
@Component({
selector: 'modal-quickadd-todo',
template: `
<div class="modal-header">
<div class="row">
<div class="col-lg-8 col-lg-offset-2">
<h1>Start listing!</h1>
<form ng-submit="addTodos()">
<input ng-model="myinput" type="text" name="todo" placeholder="Type your priorities" class="form-control input-lg">
</form></div>
<div class="col-lg-8 col-lg-offset-2">
<uib-tabset type="pills">
<uib-tab heading="Active Tasks">
/**
* mainRoutes Module;
*
* Description
*/
var app = angular.module('mainRoutes', ['ngRoute']);
app.config(function ($routeProvider) {
$routeProvider.when('/', {
controller: 'mainController',