This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //// Usage | |
| var queue = createMessageQueue({ messagesPerMinute: 60 }) | |
| queue.on('message', function(msg) { | |
| console.log('message: ' + JSON.stringify(msg, null, 2)) | |
| }) | |
| queue.enqueue({ to: 'avian', from: 'sjs', body: 'cool story bro' }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cd $HOME | |
| FileName='go1.13.4.linux-armv6l.tar.gz' | |
| wget https://dl.google.com/go/$FileName | |
| sudo tar -C /usr/local -xvf $FileName | |
| cat >> ~/.bashrc << 'EOF' | |
| export GOPATH=$HOME/go | |
| export PATH=/usr/local/go/bin:$PATH:$GOPATH/bin | |
| EOF | |
| source ~/.bashrc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl -i -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET https://dynamicdns.park-your-domain.com/update?host=@&domain=[domain]&password=[update-password]&ip=[local-ip] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int ret, len; | |
| mbedtls_net_context listen_fd, client_fd; | |
| unsigned char buf[1024]; | |
| const char *pers = "ssl_server"; | |
| int port = 443 | |
| mbedtls_entropy_context entropy; | |
| mbedtls_ctr_drbg_context ctr_drbg; | |
| mbedtls_ssl_context ssl; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <ESP8266WiFi.h> | |
| #define WIFI_SSID "MY SSID" | |
| #define WIFI_PASSWORD "MY PASS" | |
| bool isConnected() { | |
| return (WiFi.status() == WL_CONNECTED); | |
| } | |
| void connectToWiFi(int max_tries = 20, int pause = 500) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Script to build nginx with lua support. | |
| # XXX: The result might work, but it was not thoroughly tested. Use it at your | |
| # own risk. If you really need nginx with LUA in production, you should use | |
| # OpenResty instead. | |
| NGINX_VERSION='1.20.2' | |
| NGX_DEVEL_KIT_VERSION='0.3.1' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Script to build nginx with lua support. | |
| NGINX_VERSION='1.18.0' | |
| NGX_DEVEL_KIT_VERSION='0.3.1' | |
| LUA_NGINX_MODULE_VERSION='0.10.16rc5' | |
| STREAM_LUA_NGINX_MODULE_VERSION='0.0.8rc3' | |
| # we use openresty's version of luajit here. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev libjemalloc-dev libatomic-ops-dev | |
| sudo apt-get install zlib1g-dev libxslt-dev libgd-dev libgeoip-dev | |
| # build lua | |
| git clone https://github.com/openresty/luajit2 | |
| make && make install | |
| export LUAJIT_LIB=/usr/lib64; | |
| export LUAJIT_INC=/usr/include/luajit-2.1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void setup() { | |
| Serial.begin(115200); | |
| } | |
| void loop() { | |
| char buf[50]; | |
| int64_t upTimeUS = esp_timer_get_time(); // in microseconds | |
| int64_t seconds = upTimeUS/1000000; | |
| uint32_t days = (uint32_t)seconds/86400; | |
| uint32_t hr=(uint32_t)seconds % 86400 / 3600; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| String encrypt(String plain_data){ | |
| int i; | |
| // PKCS#7 Padding (Encryption), Block Size : 16 | |
| int len = plain_data.length(); | |
| int n_blocks = len / 16 + 1; | |
| uint8_t n_padding = n_blocks * 16 - len; | |
| uint8_t data[n_blocks*16]; | |
| memcpy(data, plain_data.c_str(), len); | |
| for(i = len; i < n_blocks * 16; i++){ | |
| data[i] = n_padding; |