Skip to content

Instantly share code, notes, and snippets.

/**
* functions.auth.user().onCreate is triggered when
* 1. register via email/password
* 2. first logIn via 3rd party auth providers (Facebook, Google, etc)
* 3. developer creates new account via Firebase Admin SDK
* 4. first logIn as anonymousUser
*
* What this functions does is that when onCreate method is triggered,
* we create `newUser` with necessary information including uid or displayName from given user
* And then save it in our database
# Bellman-Ford implementation from MIT 6006 course lesson #17
import math
import networkx as nx
# utility: Graph
class Graph:
def __init__(self, vertices):
self.V = vertices
self.edges = []
# dijkstra implementation from MIT 6006 course lesson #16
from collections import defaultdict
import math
from heapq import heapify, heappush, heappop
# utility: priority queue
class Pq:
def __init__(self):
self.queue = []
import { pbkdf2, randomBytes } from 'crypto'
const iteration = 199999
const hashLength = 64
const digest = 'sha512'
// promisify native pbkdf2 function
const generateHash = (password: string, salt: string): Promise<string> => {
return new Promise((resolve, reject) => {
pbkdf2(password, salt, iteration, hashLength, digest, (err, key) => {
const axios = require('axios')
const cheerio = require('cheerio')
const {
URL
} = require('url')
const fs = require('fs')
const getSelectors = require('utils/getSelectors')
const sanitizeHtml = require('utils/sanitizeHtml')
const fixImageSource = require('utils/fixImageSource')
@leejh3224
leejh3224 / jquery-ui-datepicker-localization.html
Last active February 28, 2018 04:51
jquery-ui-datepicker-localization
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css" />
</head>
<body>
<div class="wrapper">
@leejh3224
leejh3224 / five-tips-redux-translate.md
Last active January 24, 2018 16:10
five-tips-redux-translate

큰 규모의 프로젝트에서 리덕스를 사용하기 위한 다섯 가지 팁

이 글은 Chris Dopuch의 Five Tips for Working with Redux in Large Applications를 번역한 글입니다.

redux

Redux는 애플리케이션의 훌륭한 상태 관리 도구다. Redux는 단방향 데이터 흐름과 Immutable 한 상태 유지를 통해 상태 변화를 추적하기 쉽게 만들었다. 각각의 상태 변화는 dispatch된 action에 의해서만 발생하고, reducer 함수는 적절하게 변화를 반영하는 새로운 상태를 돌려준다. AppNexus(역자주: Chris Dopuch가 소속된 회사명)의 UI는 많은 양의 데이터와 다양하고 복잡한 유저의 행동에 의해 영향을 받는다. (유저가 광고를 관리하거나 Inventory를 추가하는 등) 복잡한 인터페이스를 개발하면서 우리는 Redux를 manageble 하게 사용하기 위한 몇 가지 팁과 규칙을 발견했다. 다음 팁들은 큰 규모의, 데이터 중심의 애플리케이션을 작업하는 개발자들에게 도움이 될 것이다.

/*
* original version can be found in:
* https://gist.github.com/paullewis/1982121
* sort(some-random-array) will return sorted array
*/
const merge = (left, right) => {
const result = []
while(left.length && right.length) {
/* naver */
passport.use('provider:naver', new NaverStrategy({
clientID: naver.clientID,
clientSecret: naver.clientSecret,
callbackURL: naver.callbackURL,
}, (accessToken, refreshToken, profile, done) => {
User.findOne({ 'social.naver.id': profile.id })
.then(user => {
if (!user) {
const newUser = new User()