Skip to content

Instantly share code, notes, and snippets.

View lovejavaee's full-sized avatar
👋
Java | C++ | Python | ML | DL

Jeff M lovejavaee

👋
Java | C++ | Python | ML | DL
View GitHub Profile
@arrayadd
arrayadd / consistenghash.md
Last active April 27, 2018 10:51
一致性hash 一致在哪里?

关于一致性哈希算法的介绍,网上挺多的,图文并茂,易懂详细,例如:一致性哈希算法与Java实现


一些注意点

  • key的哈希及服务集群节点的哈希应该用同一个哈希函数。尽管理论上可以用不同函数,只需要保证这两个hash函数的哈希值范围及均匀性相近就行,但实际中完全没理由这么做,除非想没事找事,脱裤子放屁..
  • 每个节点的可虚拟节点数,及总的虚拟节点数,应该有已被实践过的参考范围,而不应该是越多越好。同时,随着实际节点数的变化,对应的总的虚拟节点数也应该是动态的。而不是线性的。
  • 实际开发中难点还有一处,就是如何有效的发现集群中节点的变化,也就是动态的删除,增加节点。
"""
Solving FrozenLake8x8 environment using Policy iteration.
Author : Moustafa Alzantot (malzantot@ucla.edu)
"""
import numpy as np
import gym
from gym import wrappers
def run_episode(env, policy, gamma = 1.0, render = False):
@malzantot
malzantot / mountaincar_qlearning.py
Last active October 20, 2022 04:00
Solution of MountainCar OpenAI Gym problem using Q-Learning.
"""
Q-Learning example using OpenAI gym MountainCar enviornment
Author: Moustafa Alzantot (malzantot@ucla.edu)
"""
import numpy as np
import gym
from gym import wrappers
Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.
_____________________________________
## General rules
1. Follow standard conventions.
2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
3. Boy scout rule. Leave the campground cleaner than you found it.
4. Always find root cause. Always look for the root cause of a problem.
## Design rules
set ignorecase
set smartcase
set scrolloff=3 " 3 lines above/below cursor when scrolling
" Emulated Plugins
set surround
" set easymotion
set NERDTree
" Copy to system clipboard as well