Skip to content

Instantly share code, notes, and snippets.

View banjin's full-sized avatar
🏠
Working from home

songhm banjin

🏠
Working from home
View GitHub Profile
@banjin
banjin / vue_validation.js
Created August 11, 2016 10:59 — forked from pulading1988/new_gist_file.js
vue.js写的一个表单验证示例
var mobileRE = /^(((13[0-9]{1})|(14[57]{1})|(15[0-9]{1})|(17[678]{1})|(18[0-9]{1}))+\d{8})$/;
var passwordRE = /^[A-Za-z0-9]{6,20}$/;
var BASE_PATH = '${basePath}';
var j_captchaUrl = '${basePath}/jcaptcha'; // 获取验证码的后端地址
var app = new Vue({
el: '#app',
data: {
mobile: '',
j_captcha: '',
@banjin
banjin / git_toturial
Last active January 25, 2018 03:52 — forked from guweigang/git_toturial
git命令大全
git init # 初始化本地git仓库(创建新仓库)
git config --global user.name "xxx" # 配置用户名
git config --global user.email "xxx@xxx.com" # 配置邮件
git config --global color.ui true # git status等命令自动着色
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global --unset http.proxy # remove proxy configuration on git
git clone git+ssh://git@192.168.53.168/VT.git # clone远程仓库
{
"editor.multiCursorModifier": "ctrlCmd",
"editor.snippetSuggestions": "inline",
"editor.formatOnPaste": true,
"workbench.colorTheme": "Hyper Term Black",
"window.closeWhenEmpty": true,
"editor.renderWhitespace": "all",
"editor.find.seedSearchStringFromSelection": false,
"editor.fontFamily": "operator mono ssm",
"editor.fontSize": 12,
@banjin
banjin / socket 基础
Last active July 18, 2018 09:42
记录 socket 编程
Python Socket 编程详细介绍
Python 提供了两个基本的 socket 模块:
Socket 它提供了标准的BSD Socket API。
SocketServer 它提供了服务器重心,可以简化网络服务器的开发。
下面讲解下 Socket模块功能。
Socket 类型
套接字格式:socket(family, type[,protocal]) 使用给定的套接族,套接字类型,协议编号(默认为0)来创建套接字
@banjin
banjin / kennethreitz.zsh-theme
Created September 15, 2018 03:29 — forked from kennethreitz/kennethreitz.zsh-theme
"kennethreitz" theme for oh-my-zsh. Designed for Operator Mono. Supports virtualenvs & git.
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
PROMPT='$(virtualenv_prompt_info)%{%}%{$fg[green]%}%c \
$(git_prompt_info)\
\
%{$fg[red]%}%(!.#.»)%{$reset_color%} '
PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
RPS1='%{$fg[blue]%}%~%{$reset_color%} ${return_code} '
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[yellow]%}("
@banjin
banjin / wtf Python
Last active November 29, 2018 02:31
记录一些让人懵逼的现象
1. python2
>>> 'a' * 20 is 'aaaaaaaaaaaaaaaaaaaa'
True
>>> 'a' * 29 is 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
False
>>> 'a' * 21 is 'aaaaaaaaaaaaaaaaaaaaa'
False
python3
@banjin
banjin / MySQL_5-7_macOS.md
Created January 12, 2019 14:09 — forked from robhrt7/MySQL_5-7_macOS.md
Install MySQL 5.7 on macOS using Homebrew

This is a fork of original gist https://gist.github.com/nrollr/3f57fc15ded7dddddcc4e82fe137b58e, with slight changes on pointing to 5.7 version branch, instead of 8 (latest default of MySQL in Hombrew).

Install MySQL 5.7 on macOS

This procedure explains how to install MySQL using Homebrew on macOS (Sierra 10.12 and up)

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.
@banjin
banjin / Linux 常用命令
Last active January 18, 2019 01:49
记录一些linux的常用命令
系统
# uname -a # 查看内核/操作系统/CPU信息
# head -n 1 /etc/issue # 查看操作系统版本
# cat /proc/cpuinfo # 查看CPU信息
# hostname # 查看计算机名
# lspci -tv # 列出所有PCI设备
# lsusb -tv # 列出所有USB设备
# lsmod # 列出加载的内核模块
# env # 查看环境变量
@banjin
banjin / zeromq的几种模式
Created January 18, 2019 05:58
记录几种zmq的实现模式
Request-Reply模式:
server端:
#!/usr/bin/env python
# -*- coding=utf-8 -*-
import zmq
import random
@banjin
banjin / nginx ip_hash策略
Last active September 16, 2023 09:39
在工作中经常使用Nginx的IP_hash策略做负载均衡,所以记录一下使用中的疑惑。
当对后端的多台动态应用服务器做负载均衡时,ip_hash指令能够将某个客户端IP的请求通过哈希算法定位到同一台后端服务器上。这样,当来自某个IP的用户在后端Web服务器A上登录后,再访问该站点的其他URL,能够保证其访问的还是后端Web服务器A。
如果不采用ip_hash指令,假设来自某个IP的用户在后端Web服务器A上登录后,再访问该站点的其他URL,有可能被定向到后端Web服务器B,C...上,由于用户登录后SESSION信息是记录在服务器A上的,B,C...上没有,这时就会提示用户来登录
在ip_hash策略中,它选择最初的server的方法是根据请求客户真个IP计算出一个哈希值,再根据哈希值选择后台的服务器。
1)由IP计算哈希值的算法如下, 其中公式中hash初始值为89,iphp->addr[i]表示客户真个IP, 通过三次哈希计算得出一个IP的哈希值:
  for (i = 0; i < 3; i++) {
  hash = (hash * 113 + iphp->addr[i]) % 6271;