I was lucky that able to get 1 month free subscriptions on Qwiklabs and finished some of their quest. Good way to get your hand dirty and know how to use these tools. Sadly that promotion ended 31th July. Kubernets is really changing the way of software deployments. Docker was starting to popular 4-5 years …
This blog haven’t update for a loooog looooooong time, last article is published at mid October last year. Revisit here, partly because LikeCoin starts a campaign for Mining beta 2, which distributes 30,000 LIKE every day. Mining Beta 1 requires medium, despite I join the subscriptions recently (profile: @hang321), last few weeks I was occupied …
I have brought a arduino kit in 2016 but haven’t played with it. Finally have some taste on it. Install sketch – official software from arduino Add “Adafruit unified sensor” & SimpleDHT library in sketch, then create a new file. Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
/* install "Adafruit unified sensor" and simpleDHT library in sketch */ #include <Adafruit_Sensor.h> #include <DHT.h> /* Include the software serial port library */ #include <SoftwareSerial.h> /* to communicate with the Bluetooth module's TXD pin */ #define BT_SERIAL_TX 10 /* to communicate with the Bluetooth module's RXD pin */ #define BT_SERIAL_RX 11 /* Initialise the software serial port */ SoftwareSerial BluetoothSerial(BT_SERIAL_TX, BT_SERIAL_RX); /* what digital pin DHT connected to */ #define DHTPIN 7 // Uncomment whatever type you're using! #define DHTTYPE DHT11 // DHT 11 //#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 //#define DHTTYPE DHT21 // DHT 21 (AM2301) DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); Serial.println("Temperature and Humidity to bluetooth"); dht.begin(); BluetoothSerial.begin(9600); delay(1000); // Should respond with OK BluetoothSerial.print("AT"); waitForResponse(); // Should respond with its version BluetoothSerial.print("AT+VERSION"); waitForResponse(); // Set pin to 1234 BluetoothSerial.print("AT+PIN1234"); waitForResponse(); // Set the name to BLU BluetoothSerial.print("AT+NAMEBLU"); waitForResponse(); Serial.println("Finished setup!"); } void loop() { // Give it time to calibrate delay(10000); float h = dht.readHumidity(); // Read Celsius float t = dht.readTemperature(); // Read Fahrenheit (isFahrenheit = true) float f = dht.readTemperature(true); // Check errors if (isnan(h) || isnan(t) || isnan(f)) { Serial.println("Failed to read from DHT sensor!"); return; } // Compute heat index in Fahrenheit (the default) // float hif = dht.computeHeatIndex(f, h); // Compute heat index in Celsius (isFahreheit = false) // float hic = dht.computeHeatIndex(t, h, false); Serial.println("Humidity: " + String(h) + "%, Temperature: " + String(t) + "^C"); BluetoothSerial.println("Humidity: " + String(h) + "%, Temperature: " + String(t) + "^C"); } // Function to pass BlueTooth output through to serial port output void waitForResponse() { delay(1000); while (BluetoothSerial.available()) { Serial.write(BluetoothSerial.read()); } Serial.write("\n"); } |
Verify code, then connect the Ardunio board, and upload the file. If it …
headless setup according to https://core-electronics.com.au/tutorials/raspberry-pi-zerow-headless-wifi-setup.html unfortunately it does not work for me, there is no IP address assigned in router info page. Connect Pi Zero W with HDMI and USB keyboard. I don’t have mini-USB to USB converter, surprisingly the OTG converter works. $ sudo vim.tiny /etc/wpa_supplicant/wpa_supplicant.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 country=AU # Home Network network={ ssid="SSID1" psk="password1" key_mgmt=WPA-PSK } # Office Network network={ ssid="SSID2" psk="password2" key_mgmt=WPA-PSK } |
Since default locale is en_GB, the keyboard …
Infamous Seagate Barracuda 3TB hard disk suddenly dead. Due to physical/raw disk mapping, DSM on ESXi cannot do S.M.A.R.T. test and ESXi does not alert as well…. Anyway, this time forget about ESXi, just install DSM 6.1. Planning to use docker for other applications in future. For information to install, follow 2 links below https://xpenology.com/forum/topic/7973-tutorial-installmigrate-dsm-52-to-61x-juns-loader/ …
recently migrated wordpress to GCP, using cloud launcher – wordpress by bitnami. That pretty easy, google other tutorials and follow it. e.g. https://console.cloud.google.com/launcher/details/bitnami-launchpad/wordpress http://www.compoundtheory.com/migrating-my-blog-to-google-cloud-platform/ Set up here is some highlighted procedures 1. create compute engine via clound launcher 2. create cloud SQL – db username and password 3. mysqldump old wordpress database 4. load …
more complicated than I thought, VMware Workstation patch and difficult to create ISO image. 1. macOS High Sierra 10.13 Beta 3 If you don’t have mac, you need to spend some time to find the source. check out https://betas.cmacapps.com/ to find a suitable one. Unzip the dmg file by 7zip, InstallESD.img & BaseSystem.dmg located in “macOS …
MySQL PAM Config set up database table and column name for username and password # vim /etc/pam.d/nginx
1 2 3 4 5 6 7 8 9 10 11 12 |
auth required pam_mysql.so user=USERNAME_HERE \ passwd=PASSWORD_HERE \ host=HOSTNAME_HERE \ db=DATABASE_HERE \ table=TABLE_OR_VIEW_NAME_HERE \ usercolumn=USERNAME_COLUMN \ passwdcolumn=PASSWORD_COLUMN \ crypt=0 sqllog=0 # repeat .... with config above account required pam_mysql.so user=USERNAME_HERE \ ........ crypt=0 sqllog=0 # alternatively, to external config file # account required pam_mysql.so config_file=/etc/pam_mysql.conf |
in nginx config (/etc/nginx/nginx or /etc/nginx/conf.d/)
1 2 3 4 |
location /restricted { auth_pam "Restricted Zone" auth_pam_service_name "nginx" } |
Upload module config in nginx config (/etc/nginx/nginx or /etc/nginx/conf.d/)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
location /upload{ auth_pam "Restricted Zone" auth_pam_service_name "nginx" upload_pass /uploadHandler.php; # the location where the files are uploaded upload_store /var/tmp/fuploads; upload_store_access user:rw group:rw all:r; upload_resumable on; upload_state_store /var/tmp/fuploads/state ; # Set specified fields in request body # the field data will be available through the superglobal $_POST[] upload_set_form_field "${upload_field_name}_name" $upload_file_name; upload_set_form_field "${upload_field_name}_content_type" $upload_content_type; upload_set_form_field "${upload_field_name}_path" $upload_tmp_path; upload_cleanup 400 404 499 500-505; } # pass the PHP scripts to FastCGI server location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } |
php file upload handler example can be found on https://github.com/blueimp/jQuery-File-Upload/wiki/Uploading-to-nginx-using-the-nginx-upload-module-with-php_handler and https://github.com/blueimp/jQuery-File-Upload/tree/master/server/php
Recently I was assigned to a task about adding a file upload feature to a existing nginx server on CentOS. Nginx was chosen years ago because it simply handles some static files only. If the file upload was a requirement, using apache is simpler as computation power isn’t a constraint in our case. Background CentOS 7 …
今個Xmas 假期找到原因了, 原來係touch input 既問題. 宜家Streaming DLNA 唔使睇睇下冇聲 (input source switching automatically) http://www.avsforum.com/forum/109-home-theater-box/1481206-help-samsung-ht-e5500-keeps-changing-source-2.html#post23923247