Skip to content

Instantly share code, notes, and snippets.

@mgbaozi
mgbaozi / cloudflare-update-record.sh
Last active February 7, 2024 18:04 — forked from benkulbertis/cloudflare-update-record.sh
Cloudflare API v4 Dynamic DNS Update in Bash (CN)
#!/bin/bash
# CHANGE THESE
auth_email="user@example.com"
auth_key="" # found in cloudflare account settings
zone_name="example.com"
record_name="www.example.com"
# MAYBE CHANGE THESE
# ip=$(curl -s http://ipv4.icanhazip.com)
import produce from 'immer'
export function createReducer(initialState = {}, handlers) {
return (state = initialState, action) =>
produce(state, draft => {
const handler = (action && action.type) ? handlers[action.type] : null
if (!handler) {
return state
}
return handler(draft, action)
// 为内置 Map 类型扩展 getIn 和 setIn 方法
Map.prototype.getIn = function getIn(keys, defaultValue) {
var value = this
for (var key of keys) {
value = this.get(key)
if (!value) {
return defaultValue
}
}
return value