[Weekly Report] 2018.04.05 - 04.18

[Weekly Report] 2018.04.05 - 04.18




  1. My dormitory doesn't have static public IP address so I tend to use Dynamic DNS (DDNS) method. Even though my D-Link Access Point (AP) provides free DDNS service, but I want to use my own domain name. First I change my domain name server from freenom to Cloudflare, then install ddclient for automatically update my IP address to Cloudflare. But no matter how I changed the arguments of the configuration file for hours, it still didn't work. Then I tended to use Cloudflare API and read the official document, it succeeded in ten minutes. Here is my sample DNS-update code, you can also use requests library instead of curl :

    '''This program will get record from Cloudflare and compare my current IP address'''
    import json
    from os import popen, system

    getCMD = 'curl -X GET "https://api.cloudflare.com/client/v4/zones/{ZONE-ID}/dns_records?type=A&name={YOUR-FULL-DOMAIN-NAME}" \
    -H "X-Auth-Email: {YOUR-EMAIL}" \
    -H "X-Auth-Key: {YOUR-API-KEY}" \
    -H "Content-Type: application/json"'

    oldIP = json.loads(popen(getCMD).read())['result'][0]['content']
    print('oldIP: ' + oldIP)
    currentIP = popen('curl http://icanhazip.com/').read()[:-1]
    print('currentIP: ' + currentIP)

    if currentIP != oldIP:
    updateCMD = 'curl -X PUT "https://api.cloudflare.com/client/v4/zones/{ZONE-ID}/dns_records/{YOUR-DOMAIN-NAME-RECORD-ID}" \
    -H "X-Auth-Email: {YOUR-EMAIL}" \
    -H "X-Auth-Key: {YOUR-API-KEY}" \
    -H "Content-Type: application/json" \
    --data \'{"type":"A","name":"{YOUR-FULL-DOMAIN-NAME}","content":"'+ currentIP +'","ttl":120,"proxied":false}\''
    system(updateCMD)
    print("Update!")
    else:
    print("Noupdate!")

  2. Suhosin is an advanced protection system for PHP installations. There are two parts of protection, PHP core patch and extension, they can be installed separately but patch only up to PHP version 5.3.9 and seems not to be maintained anymore. Suhosin extension can do encryption of cookies and sessions, whitelist or blacklist, if you worry about this extension will block some functions or users which you don’t want to, there is a simulation mode that will log the triggered events but not block those actions. Now (today is April 17th, 2018), the latest PHP version via apt installation method is 7.0, but Suhosin’s PHP 7 version is still in pre-alpha.

  3. My terminal of Ubuntu desktop cannot be opened for use, and I didn’t have any other terminal installed on my PC. First I booted into single user mode and try to use apt command, it didn’t work, then I logged into desktop and use Ctrl + Alt + F1 to use console mode and execute gnome-terminal, it showed Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Error calling StartServiceByName for org.gnome.Terminal: GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.gnome.Terminal exited with status 1. This is locale setting problem, so I used LC_ALL=en_US.UTF-8 to solve it.

  4. The reason using htm instead of html is because the 16-bit DOS system only supports 3 bytes filename extension, and so typically some people still use 3 characters to their filename extension now.

  5. Hadoop is a collection of software utilities to solve massive amount of data in processing, analyzing with network and lots of computer. The video in this article explains clearly.

  6. Asynchronous Lint Engine (ALE) can check syntax while editing files, which needs the asynchronous feature in Vim 8, and I follow this setting. I’ve uploaded my setting to GitHub.

留言

這個網誌中的熱門文章

自架網路相簿:Lychee V.S. Piwigo

LINE Notify 初嚐心得