Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
Migrate to cenzblog.github.io
@20191218
Javascript Object
Implicit objects
var n = 5;
var myArray = [1,2,3]
vs
Explicit objects
using new
var today = new date();
alert(today.getFullYear());
var myAry = new Array(100);
digging in TG
telegram:
get Info of bot: https://api.telegram.org/bot/getme
SendMessage: http://api.telegram.org/bot/sendMessage?chat_id=&text=HelloFromESP8266
ReceiveMessage: https://api.telegram.org/bot/getUpdates
reply a message: /sendmessage?chat_id=1234567&text=yoyo&reply_to_message_id=454
sendphoto: –> get the file id first!!!
/sendphoto?chat_id=1234567&photo=AgADBQADxagxG6PpUVdHAwvYecQlGt2C-TIABAEAAwIAA20AA4XvAgABFgQ
Sendphoto with URL:
/sendphoto?chat_id=1234567&photo=https://www.canva.com/learn/wp-content/uploads/2018/11/best-free-stock-photos-tb-2640×1485.jpg
https://stackoverflow.com/questions/33126743/how-do-i-add-my-bot-to-a-channel
sendMessage?chat_id=@test&text=Testing%20if%20this%20works
Pointer and Address
int myVar = 8; // variable myVar store value
&myVar; //address of myVar
int *myPtr;
myPtr = &myVar; // pointer myPtr store address of myVar
*myPtr; //value of the address pointed by myPtr
myVar | &myVar |
*myPtr | myPtr |
value => 23 | address => 0x1234 |
Dynamic array
int size; cin >> size;
int * pz = new int [size]; // dynamic binding, size set at run time
…
delete [] pz; // free memory when finished
1 | 2 |
void swapr(int & a, int & b) // use references { int temp; temp = a; // use a, b for values of variables a = b; b = temp; } |
swapr(wallet1, wallet2); // pass variables |
void swapp(int * p, int * q) // use pointers { int temp; temp = *p; // use *p, *q for values of variables *p = *q; *q = temp; } |
swapp(&wallet1, &wallet2); // pass addresses of variables |
void swapv(int a, int b) // try using values { int temp; temp = a; // use a, b for values of variables a = b; b = temp; } |
swapv(wallet1, wallet2); // pass values of variables |
C++ — String Object vs C-Style String
Two way to manipulate string.
std::string
String Object | C-Style Sting |
#include “string” | #include “cstring” / “string.h” |
string myStr = “Hello World”; | char myCharr[20] = “Hello World”; |
str1 = str2; | strcpy(charr1, charr2); |
str1 += str2; | strcat(charr1, charr2); |
str.size() | strlen(charr) |
getline(cin, str); | cin.getline(charr, 20); //20 – max len |
Advance C/C++ lang topics
// Here we can see that more than one variables
// are being used without reporting any error.
// That is because they are declared in the
// different namespaces and scopes.
#include <iostream>
using namespace std;
// Variable created inside namespace
namespace first
{
int val = 500;
}
// Global variable
int val = 100;
int main()
{
// Local variable
int val = 200;
// These variables can be accessed from
// outside the namespace using the scope
// operator ::
cout << first::val << ‘\n’;
return 0;
}
C++[] –> namespace is like a named-scope, so you can use it kind of like everywhere
CNU library
https://www.gnu.org/software/libc/manual/html_node/Getopt.html
More about C/C++ library
https://www.tutorialspoint.com/c_standard_library/index.htm
https://www.tutorialspoint.com/cpp_standard_library/index.htm
WSL (Windows Subsystem Linux)
on Windows 10: install via store
on Powershell: enter the command
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
To run linux command on cmd::::
wsl ls -la
wsl xxxxxxx
To run windows command on WSL:::::
cmd.exe /C dir
or
PING.exe , ipconfig.exe
(( this depended on if the command has file extension or a bat file.
Basic thing, telegram on NodeMCU
Example used: HTTPSRequest
/*
HTTP over TLS (HTTPS) example sketch
This example demonstrates how to use
WiFiClientSecure class to access HTTPS API.
We fetch and display the status of
esp8266/Arduino project continuous integration
build.
Limitations:
only RSA certificates
no support of Perfect Forward Secrecy (PFS)
TLSv1.2 is supported since version 2.4.0-rc1
Created by Ivan Grokhotkov, 2015.
This example is in public domain.
*/
telegram:
get Info of bot: https://api.telegram.org/bot<YOUR-BOT-TOKEN>/getme
SendMessage: http://api.telegram.org/bot<YOUR-BOT-TOKEN>/sendMessage?chat_id=<YOUR-CHATID>&text=HelloFromESP8266
ReceiveMessage: https://api.telegram.org/bot<YOUR-BOT-TOKEN>/getUpdates
On the NodeMCU: Since it is HTTPS –> I cannot find a way to used it with AT COMMAND
Programming to NodeMCU:
HTTPSRequest:
–>fingerprint[] –> inside the Chrome –> certificate –> detail –> thumb print
GPRS A9 Module AT Command list
https://wiki.ai-thinker.com/gprs
//
AT+CGDCONT=1,”IP”,”cmhk”<\r><\n>
AT+CGATT=1<\r><\n>
AT+CGACT=1,1<\r><\n>
//
AT+CDNSGIP=”erp.hkite.com”<\r><\n>
Test the DNS, and check with terminal
host -a erp.hkite.com
//Base station location
+CREG: 2,1,”00A0″,”0D37″<\r><\n>
<\r><\n>
OK<\r><\n>
MCC:454 -> HK//http://www.gpsspg.com/bs/mcc.htm
MNC: 12 -> CMHK//http://www.gpsspg.com/bs/mnc.htm
LAC: 160 -> 0xA0
CI:3383 -> 0xD37
Google Cloud AutoML test
Overview:
screenshot:
https://docs.google.com/presentation/d/1KCSoR_aG-yn_vPBYFlLTzQdBAlBcdQgRYp5zdgH5IFA/edit?usp=sharing
Cloud AutoML Vision Object Detection
https://cloud.google.com/vision/automl/object-detection/docs/?_ga=2.244268482.-671499862.1555384491
With my training data: https://cloud.google.com/vision/automl/object-detection/docs/prepare