Skip to content

Instantly share code, notes, and snippets.

View tinytub's full-sized avatar
🎯
Focusing

Zhao Peng tinytub

🎯
Focusing
View GitHub Profile
@tinytub
tinytub / md5-example.go
Created January 8, 2019 07:25 — forked from sergiotapia/md5-example.go
Golang - How to hash a string using MD5.
import (
"crypto/md5"
"encoding/hex"
)
func GetMD5Hash(text string) string {
hasher := md5.New()
hasher.Write([]byte(text))
return hex.EncodeToString(hasher.Sum(nil))
}
- What do Etcd, Consul, and Zookeeper do?
- Service Registration:
- Host, port number, and sometimes authentication credentials, protocols, versions
numbers, and/or environment details.
- Service Discovery:
- Ability for client application to query the central registry to learn of service location.
- Consistent and durable general-purpose K/V store across distributed system.
- Some solutions support this better than others.
- Based on Paxos or some derivative (i.e. Raft) algorithm to quickly converge to a consistent state.
- Centralized locking can be based on this K/V store.
##################################################################
# /etc/elasticsearch/elasticsearch.yml
#
# Base configuration for a write heavy cluster
#
# Cluster / Node Basics
cluster.name: logng
# Node can have abritrary attributes we can use for routing
#!/usr/bin/env python
#from fabric.api import *
from fabric.api import env, cd, put, sudo, settings, task, parallel
from fabric.contrib.files import sed
env.user = 'zhaopeng'
env.password = '******'
PHPDir = '/usr/local/php'
Error in user YAML: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1
---
# Python 简介
@su27 and @menghan
---

What is Python?

Python: 优雅而健壮的编程语言

  • 高级

  • 易学易读易维护

@tinytub
tinytub / vpn.sh
Created June 17, 2013 14:04
array vpn linux 登录脚本
#!/bin/bash
vpn_host=202.108.39.190
user=zhaopeng #用户名
key=123456 #密码中不变的部分
sudo whoami > /dev/null
read -s -p "Enter dynamic digital password: " passwd
echo ""
#vpnc运行必须要有root权限,
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
signin_url = "http://www.v2ex.com/signin"
award_url = "http://www.v2ex.com/mission/daily"
main_url = "http://www.v2ex.com"
#!/usr/bin/env python
import re
import urllib2
import sys
url = "http://music.douban.com"
GetSrc = urllib2.urlopen(url).read()
#r = re.compile(r'data-url=\"(.+?)\".+\)\;\">(.+?)<.+?data-url=\"(.+?)\".+\)\;\">(.+?)<.+?', re.DOTALL)
@tinytub
tinytub / sshgo.py
Created May 9, 2013 08:54
大神写的ssh登录脚本 ~/.ssh_hosts example Home root@192.168.1.106 Work root@comp1 -p 9999 root@comp2 -p 9999 root@comp3 -p 9999 VHost VMWare test@vm1 test@vm2 test@vm3 test@vm4 VirtualBox: test@vbox1 test@vbox2 test@vbox3 test@vbox4 MacOS hi@mymac
#!/usr/bin/env python
import os,sys,re
import curses
import locale
import math
from optparse import OptionParser
locale.setlocale(locale.LC_ALL, '')
@tinytub
tinytub / 1-3-hello-error.py
Created May 8, 2013 09:04
error返回值的例子.
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
define("port", default=8000, help="run on the given port", type=int)
class IndexHandler(tornado.web.RequestHandler):
def get(self):