Skip to content

Instantly share code, notes, and snippets.

View shsunmoonlee's full-sized avatar

Seunghun Sunmoon Lee shsunmoonlee

View GitHub Profile
// users-model.js - A mongoose model
//
// See http://mongoosejs.com/docs/models.html
// for more of what you can do here.
module.exports = function (app) {
const mongooseClient = app.get('mongooseClient');
const user = new mongooseClient.Schema({
email: {type: String, unique: true},
username: String,
roles: [String],
@shsunmoonlee
shsunmoonlee / users.hooks.js
Created October 17, 2018 16:41
feathers social login tutorial
const { authenticate } = require('@feathersjs/authentication').hooks;
const { hashPassword, protect } = require('@feathersjs/authentication-local').hooks;
const gravatar = require('../../hooks/gravatar');
function customizeSocialProfile(){
return function(hook){
// console.log('===Hook', hook);
console.log("===hook.data", hook.data)
@shsunmoonlee
shsunmoonlee / authentication.js
Created October 17, 2018 16:44
feathers tutorial
const authentication = require('@feathersjs/authentication');
const jwt = require('@feathersjs/authentication-jwt');
const local = require('@feathersjs/authentication-local');
const oauth2 = require('@feathersjs/authentication-oauth2');
const Verifier = require('@feathersjs/authentication-oauth2').Verifier;
const GoogleStrategy = require('passport-google-oauth20').Strategy;
const FacebookStrategy = require('passport-facebook').Strategy;
// const makeHandler = require('./oauth-handler');
const EmailFirstOAuth2Verifier = require('./verifier');
@shsunmoonlee
shsunmoonlee / call-apply-bind.js
Created October 18, 2018 07:53
call apply bind and their usages in react guide
class Toggle extends React.Component {
constructor(props) {
super(props);
this.state = {isToggleOn: true};
// This binding is necessary to make `this` work in the callback
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
@shsunmoonlee
shsunmoonlee / react-bind.js
Created October 18, 2018 07:55
React bind example
class Toggle extends React.Component {
constructor(props) {
super(props);
this.state = {isToggleOn: true};
// This binding is necessary to make `this` work in the callback
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
@shsunmoonlee
shsunmoonlee / call.js
Created October 18, 2018 08:15
call.js
1. Call
function Product(name, price) {
this.name = name;
this.price = price;
}
function Food(name, price) {
Product.call(this, name, price);
this.category = 'food';
}
@shsunmoonlee
shsunmoonlee / apply.js
Created October 18, 2018 08:15
apply.js
2. Apply
var numbers = [5, 6, 2, 3, 7];
var max = Math.max.apply(null, numbers);
console.log(max);
// expected output: 7
var min = Math.min.apply(null, numbers);
@shsunmoonlee
shsunmoonlee / bind.js
Created October 18, 2018 08:16
bind.js
3. Bind
this.x = 9; // this refers to global "window" object here in the browser
var module = {
x: 81,
getX: function() { return this.x; }
};
module.getX(); // 81
@shsunmoonlee
shsunmoonlee / spark-ar-firebase.js
Last active October 15, 2019 10:21
Spark AR Firebase sharing the state tutorial.
// -- Firebase
const Firebase = (function () {
// -- Modules
const D = require("Diagnostics");
const N = require("Networking");
// -- Public
@shsunmoonlee
shsunmoonlee / enzyme-error.js
Created December 13, 2018 12:59
enzyme question error
// containers/app/index.test.js
import App from './index.js'
import { Provider } from 'react-redux'
import { push, ConnectedRouter } from 'react-router-redux';
import { ApolloProvider } from 'react-apollo';
import { shallow, mount } from 'enzyme';
import store from '../../store.js'
// import configureStore from '../../../configureStore';
// import createHistory from 'history/createBrowserHistory';