Skip to content

Instantly share code, notes, and snippets.

View sdymj84's full-sized avatar

Minjun Youn sdymj84

View GitHub Profile
@sdymj84
sdymj84 / form-template1.html
Created July 11, 2018 21:29
Chase Credit Card applying form
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: arial, sans-serif;
@sdymj84
sdymj84 / How to sync Firestore in React
Last active January 30, 2019 02:33
[React] firestoreConnect - HOC that manages attaching and detaching listeners for you as the component mounts and unmounts.
// Component
import { compose } from 'redux'
import { connect } from 'react-redux'
import { firestoreConnect } from 'react-redux-firebase'
const mapStateToProps = (state, ownProps) => {
return {
projects: state.firestore.ordered.projects
}
@sdymj84
sdymj84 / firebase.functions.index.js
Created November 21, 2018 22:54
Firebase Cloud functions basic examples
const functions = require('firebase-functions');
const admin = require('firebase-admin')
admin.initializeApp(functions.config().firebase)
exports.helloWorld = functions.https.onRequest((request, response) => {
response.send("Hello Minjun!");
});
// Both of below lines return firestore database object
// admin.firestore() in cloud function
@sdymj84
sdymj84 / Components get data from redux store using dummy data
Last active January 30, 2019 02:24
Components get data from redux store using dummy data
const mapStateToProps = (state) => {
return {
test: state.country
}
}
export default connect(mapStateToProps)(Home)
@sdymj84
sdymj84 / 1. Child 에서 선택한 select 값을 Child 내의 state에 저장을 하고
Last active January 28, 2019 03:04
[Blog] React 에서 Child Component 에서 Parent Component 로 select 태그 옵션 전달하기!
class ChildComp extends React.Component {
state = {
favFlaver: "",
}
// 2. 요 handleChange 에서 선택된 옵션값을 가져오고 setState!
handleChange(event) {
this.setState({ favFlaver: event.target.value });
}
@sdymj84
sdymj84 / [React] Router Guard
Last active January 30, 2019 02:19
Components that needs to be blocked
import { Redirect } from 'react-router-dom'
// in function or class's render() :
const uid = this.props.uid
if (!uid) {
return <Redirect to='/' />
}
// below component class or function
const mapStateToProps = (state) => {
@sdymj84
sdymj84 / [React] Update values in nested object in array in state
Last active October 12, 2021 09:46
[React] Update values in nested object in array in state
state = {
vehicles: [{
year: "",
make: "",
model: "",
color: "",
licensePlate: "",
state: "",
}],
}
@sdymj84
sdymj84 / serverless.yml
Created April 2, 2019 19:22
Serverless framework global secondary index example
service: apt-api
# Use the serverless-webpack plugin to transpile ES6
plugins:
- serverless-webpack
- serverless-offline
custom:
# Our stage is based on what is passed in when running serverless
# commands. Or fallsback to what we have set in the provider section.
@sdymj84
sdymj84 / qsort.js
Last active December 20, 2019 17:53
[JS] QuickSort Algorithm with random array
function qsort(array) {
if (array.length <= 1) {
return array;
}
const left = [];
const right = [];
const pivot = array.pop();
for (let i = 0; i < array.length; i++) {