Skip to content

Instantly share code, notes, and snippets.

View Dearest's full-sized avatar

Dearest Dearest

View GitHub Profile
@Dearest
Dearest / Hash.rb
Created March 26, 2018 02:52
以别名的方式替换HASH的key
class Hash
# 以别名的方式替换hash的key
def alias_with(*aliases)
deep_dup.alias_with!(*aliases)
end
def alias_with!(*aliases)
tap { |hash|
Hash[*aliases].map { |old_name, new_name|
(old_name.is_a?(Symbol) ? new_name.to_sym : new_name.to_s).tap { |name|
@Dearest
Dearest / Docker connect to remote server.md
Created March 6, 2018 09:10 — forked from kekru/Docker connect to remote server.md
Connect to another host with your docker client, without modifying your local Docker installation

Run commands on remote Docker host

This is how to connect to another host with your docker client, without modifying your local Docker installation or when you don't have a local Docker installation.

Enable Docker Remote API

First be sure to enable the Docker Remote API on the remote host.

This can easily be done with a container.
For HTTP connection use jarkt/docker-remote-api.
For HTTPS connection use whiledo/docker-remote-api-tls.

Enable Docker Remote API with TLS client verification

Docker's Remote API can be secured via TLS and client certificate verification.
First of all you need a few certificates and keys:

  • CA certificate
  • Server certificate
  • Server key
  • Client certificate
  • Client key

Create certificate files

@Dearest
Dearest / groups.py
Created October 13, 2017 09:07 — forked from youfou/ad_urls.json
响应好友请求 / 自动聊天 / 限制频率 / 邀请入群 / 远程群管理 / 新人欢迎消息 / 关键词问答 / 发心跳 / 远程命令 / 远程执行代码
#!/usr/bin/env python3
# coding: utf-8
"""
wxpy 机器人正在使用的代码
** 这些代码无法独立运行,但可用于参考 **
需要安装新内核分支 new-core
pip3 install -U git+https://github.com/youfou/wxpy.git@new-core
@Dearest
Dearest / Postman Pre-request Script.js
Created March 14, 2017 09:54 — forked from PassKit/Postman Pre-request Script.js
Pre-request script for Postman app to help make requests against the PassKit API
var apiKey = "passkit_api_key",
apiSecret = "passkit_api_secret";
var jwtBody = {
"key": apiKey,
"exp": Math.floor(new Date().getTime() / 1000) + 30,
"iat": Math.floor(new Date().getTime() / 1000),
"url": request.url,
"method": request.method
};
@Dearest
Dearest / gist:6399c1bae1299124bc7f238ece7ad18b
Created March 14, 2017 05:56 — forked from hhyyy9/gist:3802833
利用正则表达式判断手机号码格式是否合法
- (BOOL)isMobileNumber:(NSString *)mobileNum
{
/**
* 手机号码
* 移动:134[0-8],135,136,137,138,139,150,151,157,158,159,182,187,188
* 联通:130,131,132,152,155,156,185,186
* 电信:133,1349,153,180,189
*/
NSString * MOBILE = @"^1(3[0-9]|5[0-35-9]|8[025-9])\\d{8}$";
/**
@Dearest
Dearest / Dockerfile
Last active September 1, 2016 09:12
docker_test Dockerfile
FROM ruby:2.3.1
RUN apt-get update && apt-get install -qy nodejs sqlite3 --no-install-recommends && rm -rf /var/lib/apt/lists/*
ENV RAILS_VERSION 5.0.0
RUN gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/
RUN gem install rails --version "$RAILS_VERSION"
RUN gem install bundler
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
EXPOSE 3000
ENV PORT=3000
@Dearest
Dearest / 0x8B1F
Created December 14, 2015 05:26 — forked from zealic/Email
Please use CAPTCHA as additional message
H4sIAAAAAAAAA6VRybKiQBC88xXvPofpBhE4zKEaBRFRG2xAbjQNiGwaLghfPxgx
fzB5qIrKyKglK1WypZrJhraQNVQIZCh5rqcGL/Q01wTiPylKkY6KhZwvC6xwJZXF
nJUCaQoyVCF+loYuVJxiQ+gplnGWqzpeGIbQuIbwcqlLf/4TUsU+6WmAvXnp3fUK
SgoNwFAfPAADvrCSxj+IKGGnDsxfmJzQlwznQHb+b09KYmickXxEFE7Cbt688148
oq5ZeVfH2pRQgmOW/WdXEZbarDxH6iTkcHQ2/tuxPzcpadljLjwoP5i3jZzE2ykJ
hq+wduxwD3HtEApTGqndcejHuZHDlazkkfXKA9JJWWs9s5G8k4pMXAkfs2iaRSVF
xoEii7lr/yJs9vK77ZuzZ5PH4p21tHdqYYcjmaRkXimGHkhA6nNcV26g2lzZPs/x
V4T3iU1nbiivQ3KYJ3fnryu2/+SBc3MjUkhWRVw+0GJlkpANN58FZJO1Bs5Wveve
gUBFXiLCVeSLG1TO3X3To3n1Ri8gR+9EsbQ3iemdiAWr9RHM+u7WtR2Ws4l20843
rmhIGEUXkgGvrXLoaJA9nLV1YFhYrLr4khfU/Y7C6AYIPIX6awr/MP/4L1driBiI