Skip to content

Instantly share code, notes, and snippets.

View bfgits's full-sized avatar

Simon bfgits

  • Shenzhen
View GitHub Profile
@bfgits
bfgits / bot.rb
Created January 14, 2021 09:05 — forked from dideler/bot.rb
Sending a notification message to Telegram using its HTTP API via cURL
# Use this script to test that your Telegram bot works.
#
# Install the dependency
#
# $ gem install telegram_bot
#
# Run the bot
#
# $ ruby bot.rb
#
@bfgits
bfgits / curl.md
Last active January 12, 2021 07:34 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

git clone https://github.com/certbot/certbot.git
acme.sh --issue --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please -d *.abcd.com
添加完dns txt记录再运行以下命令
acme.sh --renew --yes-I-know-dns-manual-mode-enough-go-ahead-please -d *.abcd.com
参考https://github.com/acmesh-official/acme.sh/wiki/dns-manual-mode
# certbot
@bfgits
bfgits / change_dns_servers
Created November 13, 2020 02:19
How can I configure an Amazon Elastic Compute Cloud (Amazon EC2) instance with static DNS server entries that persist when the instance is rebooted?
Short Description
The default behavior of an Amazon EC2 instance associated with an Amazon Virtual Private Cloud (Amazon VPC) is to request a DNS server address at startup using the Dynamic Host Configuration Protocol (DHCP). The DNS server addresses returned in the DHCP response are written to the local /etc/resolv.conf file. Manual modifications to the resolv.conf file with custom DNS server addresses are lost when the instance is restarted. The method that you use to solve this issue depends on your Linux distribution. For more information on VPCs and DNS servers, see Amazon DNS Server.
Resolution
Important: Before you change your Amazon EC2 instance, create a backup using an Amazon Machine Image (AMI) or an Amazon Elastic Block Store (Amazon EBS) snapshot. Changing networking configuration for an instance might render the instance unreachable.
Amazon Linux, Amazon Linux 2
Use one of the following options to configure your Amazon EC2 instance. If you apply both options, then the DNS servers specified in
@bfgits
bfgits / analyze_aliyun_fee
Last active October 16, 2020 10:01
analyze_aliyun_fee
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@File : analyze_aliyun_fee
@Date : 16/10/2020 2:53 PM
@Desc :
'''
import pandas as pd
@bfgits
bfgits / set ulimit
Created April 16, 2020 09:00
Set Permanently ulimit -n / open files in ubuntu
# available limit
user@ubuntu:~$ ulimit -n
1024
# To increase the available limit to say 65535
user@ubuntu:~$ sudo vim /etc/sysctl.conf
# add the following line to it
fs.file-max = 65535
@bfgits
bfgits / disable-automatic-updates-windows
Created April 16, 2020 03:37
How to disable automatic updates on Server 2016.
How to disable automatic updates on Server 2016.
Open an elevated command prompt window or PowerShell session
Type sconfig and press enter.
Select option 5
Now select “A” for automatically download and install updates, “D” for download only or “M” for Manual updates.
@bfgits
bfgits / node_exporter_setup.md
Created April 13, 2020 09:45 — forked from nwesterhausen/node_exporter_setup.md
node_exporter installation on ubuntu

Installing node_exporter

Steps to install node_exporter

  1. Add user for node_exporter

    sudo useradd --no-create-home --shell /bin/false node_exporter
@bfgits
bfgits / How to install tcpping on Linux.md
Created March 13, 2020 08:01
How to install tcpping on Linux.md

To install tcptraceroute on Debian/Ubuntu:

$ sudo apt-get install tcptraceroute

To install tcptraceroute on CentOS/REHL, first set up RepoForge on your system, and then:

$ sudo yum install tcptraceroute

7.2 JSON处理

JSON(Javascript Object Notation)是一种轻量级的数据交换语言,以文字为基础,具有自我描述性且易于让人阅读。尽管JSON是Javascript的一个子集,但JSON是独立于语言的文本格式,并且采用了类似于C语言家族的一些习惯。JSON与XML最大的不同在于XML是一个完整的标记语言,而JSON不是。JSON由于比XML更小、更快,更易解析,以及浏览器的内建快速解析支持,使得其更适用于网络数据传输领域。目前我们看到很多的开放平台,基本上都是采用了JSON作为他们的数据交互的接口。既然JSON在Web开发中如此重要,那么Go语言对JSON支持的怎么样呢?Go语言的标准库已经非常好的支持了JSON,可以很容易的对JSON数据进行编、解码的工作。

前一小节的运维的例子用json来表示,结果描述如下:

{"servers":[{"serverName":"Shanghai_VPN","serverIP":"127.0.0.1"},{"serverName":"Beijing_VPN","serverIP":"127.0.0.2"}]}

本小节余下的内容将以此JSON数据为基础,来介绍go语言的json包对JSON数据的编、解码。

解析JSON