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
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
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
@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
"""
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):
@arrayadd
arrayadd / consistenghash.md
Last active April 27, 2018 10:51
一致性hash 一致在哪里?

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


一些注意点

  • key的哈希及服务集群节点的哈希应该用同一个哈希函数。尽管理论上可以用不同函数,只需要保证这两个hash函数的哈希值范围及均匀性相近就行,但实际中完全没理由这么做,除非想没事找事,脱裤子放屁..
  • 每个节点的可虚拟节点数,及总的虚拟节点数,应该有已被实践过的参考范围,而不应该是越多越好。同时,随着实际节点数的变化,对应的总的虚拟节点数也应该是动态的。而不是线性的。
  • 实际开发中难点还有一处,就是如何有效的发现集群中节点的变化,也就是动态的删除,增加节点。
@malzantot
malzantot / frozenlake_genetic_algorithm.py
Created June 7, 2017 23:06
Solution of the FrozenLake problem using Genetic Algorithm
import numpy as np
import random
import time
import gym
from gym import wrappers
def run_episode(env, policy, episode_len=100):
total_reward = 0
obs = env.reset()
for t in range(episode_len):
import numpy as np
import time
import gym
def run_episode(env, policy, episode_len=100, render=False):
total_reward = 0
obs = env.reset()
for t in range(episode_len):
if render:
@inadarei
inadarei / ipaddressclasses.md
Last active December 28, 2020 17:43
IP Address Classes, CIDRs and Network Masks

Network Classes

IP Addresses identify both a network as well as host on a network. Depending on the class of a network, certain amount of bits in the IP (32 bits overall) are allocated for network adressing and the rest is for: adressing the host on the network.

  1. Class A: first octet is network, last three: host
  2. Class B: first two octets are for network, last two: host
  3. Class C: first three octets are for network, only last octet is for host.

Furthermore, looking at the IP itself, you can tell which class of IP it is, using the following rules:

image

Spring MVC

$ siege -b -c 100 -r 10 http://localhost:8080

Transactions:		        1000 hits
Availability:		      100.00 %
Elapsed time:		       10.55 secs
import gym
import numpy as np
def gen_random_policy():
return (np.random.uniform(-1,1, size=4), np.random.uniform(-1,1))
def policy_to_action(env, policy, obs):
if np.dot(policy[0], obs) + policy[1] > 0:
return 1
else: