Skip to content

Instantly share code, notes, and snippets.

@alvonx
alvonx / boost-logger-install-commands.txt
Last active September 25, 2023 16:32
install boost.log for c++ logging
Install-Package boost
Install-Package boost_date_time-vc143
Install-Package boost_filesystem-vc143
Install-Package boost_log-vc143
Install-Package boost_system-vc143
Install-Package boost_thread-vc143
Install-Package boost_log_setup-vc143
Install-Package boost_chrono-vc143
Install-Package boost_atomic-vc143
@alvonx
alvonx / system-time-esp.ino
Created September 18, 2023 10:35
get system time esp
#include <time.h>
#include <sys/time.h>
void setup() {
Serial.begin(115200);
delay(5000);
struct timeval tv;
tv.tv_sec = 1611198855;
tv.tv_usec = 0;
@alvonx
alvonx / get_set_env.bat
Created September 13, 2023 19:24
get and set environment variable
@echo off
:: Define the name and value of the environment variable
set "MY_VARIABLE=MY_VALUE"
:: Set the environment variable using setx
setx MY_VARIABLE "%MY_VARIABLE%"
:: Display a message indicating that the variable has been set
echo Environment variable MY_VARIABLE set to %MY_VARIABLE%
@alvonx
alvonx / cpp_curl.cc
Created July 15, 2023 08:44
cURL in C++
#include <iostream>
#include <string>
#include <curl/curl.h>
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
# dynamic_default_configuration
# server block for http and redirect to https nginx proxy
server {
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name SUBDOMAIN_NAME.DOMAIN_NAME; # managed by Certbot
import json
import boto3
def lambda_handler(event, context):
page_name = event['queryStringParameters']['page']
page_start_time = event['queryStringParameters']['starttime']
print(page_name)
print(page_start_time)
import json
import boto3
def lambda_handler(event, context):
page_name = event['queryStringParameters']['page']
cover_name = event['queryStringParameters']['cover']
print(page_name)
ssm_client = boto3.client('ssm')
import json
import boto3
import random
from botocore.vendored import requests
def random_url(plen=10, ucfirst=True, spchar=True):
if plen >= 6 and plen % 2 != 0:
plen = plen+1
elif plen < 8:
return None, 'length too small'
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<!-- Bootstrap CSS -->
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css"
@alvonx
alvonx / onvif-snapshot.py
Last active January 23, 2023 07:14
Save snapshot from ONVIF enabled camera using python
# pip install onvif-zeep
# import package
import requests
from onvif import ONVIFCamera
# create onvif camera object
cam_obj = ONVIFCamera(CAMERA_HOST, CAMERA_PORT, CAMERA_USER, CAMERA_PASS)
# create media service