Skip to content

Instantly share code, notes, and snippets.

View Morozov-5F's full-sized avatar
🐢

Evgeniy Morozov Morozov-5F

🐢
  • Helsinki, FI
View GitHub Profile
@Morozov-5F
Morozov-5F / split_all_cue.sh
Created March 13, 2022 23:17
Split flac+cue into separate flac files
find "$1" -type f -name "*.flac" -exec split_cue.sh {} \;
@Morozov-5F
Morozov-5F / azure.c
Last active May 2, 2019 01:37
Azure issue
static void
s_azure_client_connection_status_cb(IOTHUB_CLIENT_CONNECTION_STATUS result,
IOTHUB_CLIENT_CONNECTION_STATUS_REASON reason,
void * ctx)
{
const char * connection_result = NULL;
const char * connection_reason = NULL;
if (IOTHUB_CLIENT_CONNECTION_AUTHENTICATED == result)
{
@Morozov-5F
Morozov-5F / application_log.txt
Last active May 2, 2019 01:40
Azure IoT Hub SDK fails to notify about device twin changes (MQTT)
Aug 6 13:35:00 22 azure/azure.c:3543: s_azure_ctx_init: Azure: enabling logging to file /tmp/azure_sdk_log.txt
Aug 6 13:35:00 22 azure/azure.c:3550: s_azure_ctx_init: Azure: Logging setup
Sep 5 08:46:17 37 azure/azure.c:2752: s_azure_main_loop: TELEMETRY: sending a message to Azure
Sep 5 08:46:23 44 azure/azure.c:1312: s_azure_client_connection_status_cb: Azure connection status: ONLINE; reason: OK
Sep 5 08:46:23 44 advanced_diag.c:2113: s_set_azure_status: Setting azure_status to: 2
1> Sep 5 08:46:25 46 azure/azure.c:1669: s_azure_send_twin_properties: TWIN-REPORTED: uploading an update
2> Sep 5 08:46:28 49 azure/azure.c:1617: s_azure_send_reported_twin_props_cb: TWIN-REPORTED: upload successfull
Sep 5 08:46:28 49 azure/azure.c:1161: s_azure_send_confirmation_cb: TELEMETRY: message is delievered
Sep 5 08:46:29 50 azure/azure.c:2752: s_azure_main_loop: TELEMETRY: sending a message to Azure
Sep 5 08:46:30 51 azure/azure.c:1161: s_azure_send_confirmation_cb: TELEMETRY: message is delievered
@Morozov-5F
Morozov-5F / .emacs
Created December 17, 2017 11:35
Lightweight Emacs config
;; Enable package management
(require 'package)
(let* ((no-ssl (and (memq system-type '(windows-nt ms-dos))
(not (gnutls-available-p))))
(url (concat (if no-ssl "http" "https") "://melpa.org/packages/")))
(add-to-list 'package-archives (cons "melpa" url) t))
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)
@Morozov-5F
Morozov-5F / task.bash
Created November 13, 2017 10:50
Last problem
#!/bin/bash
# String with available options (more info: man getopt)
# Colon after argument means that value is required for this argumen
# h -- help
# a -- main args
OPTSTRING="ha:"
VALUE=""
do_work()
@Morozov-5F
Morozov-5F / task.awk
Created November 13, 2017 10:12
Sort process by theis stack depth
#!/usr/bin/gawk -f
# Prepare file list
$1 ~ /[0-9]+/ {
pid = $1
fname = "/proc/" pid "/stack";
stack_level = 0
# Read file and count stack depth
getline_ret = getline < fname
while (getline_ret == 1) {
@Morozov-5F
Morozov-5F / c-ares-test.c
Created August 30, 2017 15:15
DNS resolve using c-ares
#include <ares.h>
#include <stdio.h>
#include <netdb.h>
#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/select.h>
#define HOST_TO_RESOLVE "yandex.ru"
@Morozov-5F
Morozov-5F / connection_status_mgmt.c
Created August 18, 2017 15:11
Azure connection status management
static void
s_azure_client_connection_status_cb(
IOTHUB_CLIENT_CONNECTION_STATUS result,
IOTHUB_CLIENT_CONNECTION_STATUS_REASON reason,
void * ctx)
{
const char * connection_results[] =
{
"ONLINE",
"OFFLINE"
@Morozov-5F
Morozov-5F / azure_sdk_log.log
Created August 18, 2017 15:02
Azure SDK connection loss
Info: IoT Hub SDK for C, version 1.1.21
-> 14:41:52 CONNECT | VER: 4 | KEEPALIVE: 60 | FLAGS: 128 | USERNAME: $host_name/$device_id/api-version=2016-11-14&DeviceClientType=iothubclient%2f1.1.21%20(Linux%3b%20mips) | CLEAN: 0
<- 14:41:52 CONNACK | SESSION_PRESENT: true | RETURN_CODE: 0x0
-> 14:41:52 SUBSCRIBE | PACKET_ID: 2 | TOPIC_NAME: devices/$device_id/messages/devicebound/# | QOS: 1 | TOPIC_NAME: $iothub/twin/res/# | QOS: 0 | TOPIC_NAME: $iothub/twin/PATCH/properties/desired/# | QOS: 0 | TOPIC_NAME: $iothub/methods/POST/# | QOS: 0
-> 14:41:52 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_MOST_ONCE | TOPIC_NAME: $iothub/twin/PATCH/properties/reported/?$rid=3 | PAYLOAD_LEN: 288
-> 14:41:52 PUBLISH | IS_DUP: false | RETAIN: 0 | QOS: DELIVER_AT_LEAST_ONCE | TOPIC_NAME: devices/$device_id/messages/events/name=common.ping | PACKET_ID: 4 | PAYLOAD_LEN: 2
<- 14:41:52 SUBACK | PACKET_ID: 2 | RETURN_CODE: 1 | RETURN_CODE: 0 | RETURN_CODE: 0 | RETURN_CODE: 0
-> 14:41:52 PUBLISH | IS_DUP: false | RETAIN: 0 |
@Morozov-5F
Morozov-5F / azure_sdk_init.c
Created August 18, 2017 14:54
Azure SDK initialization
int keep_alive_interval_sec = 60;
uint32_t azure_message_timeout_msec = 60 * 1000;
boolean azure_log_trace = TRUE;
assert(platform_init() == 0);
/* Initialize a low-level client */
azure_ctx->azct_client = IoTHubClient_LL_CreateFromConnectionString(
connection_string, CAT_AZURE_PROTOCOL);
assert(NULL != azure_ctx->azct_client);