Skip to content

Instantly share code, notes, and snippets.

Chuangbo Li chuangbo

Block or report user

Report or block chuangbo

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@chuangbo
chuangbo / netdata.2s.py
Created Apr 6, 2016
Bitbar plugin for netdata
View netdata.2s.py
#!/bin/env python
import requests
url = 'http://YOUR_HOST_NAME/api/v1/data'
def netdata(chart):
r = requests.get(url, params={
'chart': chart,
'points': 1,
@chuangbo
chuangbo / importcn.py
Created Apr 3, 2014
Tool for import one domain from dnspod.cn to dnspod.com. Just import records which record_line is 默认
View importcn.py
#!/usr/bin/env python
#-*- coding:utf-8 -*-
"""Tool for import one domain from dnspod.cn to dnspod.com. Just import records which record_line is 默认
usage: %s DOMAIN [DOMAIN2] [DOMAIN3] ...
Modify this script first, enter both cn & com account infomation.
If DOMAIN not exists in your dnspod.com account, will add it first.
"""
import httplib, urllib
View gist:9851133
$ http post https://io.notie.io/ source_id:=186 secret=XXXXXX title=test action=test content=test -v
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate, compress
Content-Length: 97
Content-Type: application/json; charset=utf-8
Host: io.notie.io
User-Agent: HTTPie/0.7.2
{
@chuangbo
chuangbo / word-break-ii.py
Created Feb 13, 2014
Very pythonic version solution of leetcode word break ii http://oj.leetcode.com/problems/word-break-ii/
View word-break-ii.py
# from __future__ import print_function
import functools
def memoize(obj):
cache = obj.cache = {}
@functools.wraps(obj)
def memoizer(*args, **kwargs):
if args not in cache:
@chuangbo
chuangbo / cidr.py
Created Aug 13, 2012
Check if ip in cidr
View cidr.py
#-*- coding:utf-8 -*-
# Author: @chuangbo
# For: @likexian
import socket
import struct
class CIDR:
'''Check if ip in cidr
View test.cpp
#include <iostream>
using namespace std;
int main() {
if ( (10 > 5 > 3) == true) {
cout << "10 > 5 > 3 = true" << endl;
} else {
cout << "10 > 5 > 3 = false" << endl;
}
return 0;
View 40147.md
```
$ dig +trace www.douban.com
; <<>> DiG 9.7.3-P3 <<>> +trace www.douban.com
;; global options: +cmd
. 23374 IN NS j.root-servers.net.
. 23374 IN NS f.root-servers.net.
. 23374 IN NS c.root-servers.net.
. 23374 IN NS h.root-servers.net.
. 23374 IN NS i.root-servers.net.
@chuangbo
chuangbo / README.md
Last active Dec 26, 2019
Python dynamic DNSPod DNS Script
View README.md

替换上你的 API Token,域名ID,记录ID等参数,就可以运行了。 会在后台一直运行,每隔30秒检查一遍IP,如果修改了就更新IP。

获取 API Token 的方式

获得 domain_id 可以用 curl

curl -k https://dnsapi.cn/Domain.List -d "login_token=TOKEN"`
@chuangbo
chuangbo / funcs' decorator
Created Jan 11, 2011
chuangbo's decorator
View funcs' decorator
#!/usr/bin/python
# -*- coding: utf8 -*-
_actions = []
def action(f):
"""Decorator to register an action."""
_actions.append(f)
return f
@chuangbo
chuangbo / .bash_completion
Created Nov 12, 2010
easy to write a bash_completion script file
View .bash_completion
_server.py()
{
local cur prev opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
#
# The first options should be a yaml config
#
You can’t perform that action at this time.