0%

Here's something encrypted, password is required to continue reading.
Read more »

Cross-Origin Resource Sharing - 跨域问题

1
2
3
4
5
# 1
pip install Django-cors-headers

# 推荐
pip install djangorestframework markdown django-filter pillow django-guardian coreapi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 2
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app01.apps.App01Config',
'rest_framework'
]


# 3
MIDDLEWARE = [
'corsheaers.middleware.CorsMiddleware' # be the first
....
]

# 4
CORS_ORIGIN_ALLOW_ALL = True

A very useful Strava PHP library and it’s very easy to use:

1
2
git clone https://github.com/basvandorst/StravaPHP.git
composer install
Read more »

Internet of Things

Setting up Raspberry Pi

  • [MQTT Official Site]http://www.mqttfx.org

  • Install VNC Server
    Running VNCServer at Startup

  • Command+K
    vnc://172.25.0.121:5901

  • Free MQTT Dasboard
    http://www.mqtt-dashboard.com

  • MQTT Client: MQTTFx
    broker.hivemq.com
    brew install mqttfx

  • Install mosquitto client on rPi
    sudo apt-get mosquitto-client
    sudo apt-get mosquitto # optional

  • In the first terminal run
    $ mosquitto_sub -h 127.0.0.1 -t myTopic

  • In the second terminal run
    $ mosquitto_pub -h 172.0.0.1 -t myTopic -m “Hello, world”

Read more »

记录我自己的 Hexo 配置变动
非常有用的 Hexo 功能扩展

Read more »

Regular Expression

模式匹配

  • 万能字符: “.”
  • 重复操作符:“+”,”?”, “*”
  • 也可指定重复次数: {}
  • 重复操作符默认是贪婪的,它会一直寻找它的边界直到最后一个边界出现为止[1]
  • 给重复操作符添加一个“?” 可以让万能字符匹配尽可能少的次数[2]
  • 字符集: [] 方括号扩起来的字符集,
    • ‘[a-zA-Z0-9]’ 短斜杠标志起点终点
    • ‘[^abc]’ 反选
  • Subpatterns: ()
Read more »

八皇后问题

回溯算法 Backtracking

  • 在递归迭代的过程中
    它不像普通的递归迭代,单向的向深处迭代(每次迭代,N逐渐变小),然后单向返回,比如之前说的“阶乘”和“Fibonacci数列”
  • 在迭代的过程中
    有进有退,它在前向迭代的过程中,如果遇到“死胡同”,比如在第n次迭代时(棋盘的第n行),无论这个皇后放在0-7中的任何一格,都会与之前的那些皇后中的一个产生冲突,那么,算法会退回到前一次迭代(n-1行),并选择其他格。
  • 同样的,如果遍历了n-1行,也不行,算法还会继续回退。
Read more »