Skip to content

Instantly share code, notes, and snippets.

Sergey Lyubka cpq

Block or report user

Report or block cpq

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
cpq / print_linked_list.c
Created Sep 7, 2019
Print singly linked list in reverse order
View print_linked_list.c
#include <stdio.h>
struct entry {
int value;
struct entry *next;
static void out(struct entry *e) {
if (e->next != NULL) out(e->next);
printf("%d\n", e->value);
cpq / main.c
Created Sep 4, 2019
ESP-IDF mDash skeleton firmware code
View main.c
// Copyright (c) Cesanta Software Limited
// All rights reserved
#include "main.h"
void app_main() {
// If a device recovered after a crash, do not start firmware logic
// because it could crash again, thus fall into a crash-loop and make
cpq / parser.c
Last active Sep 1, 2019
Simple recursive descent expression parser
View parser.c
// Copyright (c) 2019 Sergey Lyubka
// All rights reserved
#include <stdio.h>
#include <string.h>
enum { TOK_EOF = '#', TOK_NUM = 'N', TOK_IDENT = 'I' };
//#define DEBUG(fmt, ...) printf("%s:" fmt "\n", __func__, __VA_ARGS__)
#define DEBUG(fmt, ...)
View pwa-preact-bulma.html
<!DOCTYPE html>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>mDash Smart Light</title>
<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
<script src=""></script>
cpq / preact.html
Last active Jul 16, 2019
minimal preact app with ES3 syntax
View preact.html
<link rel="stylesheet" href="">
<script src=""></script>
<script src=""></script>
<body> </body>
var h = preact.h;
var App = function(props) {
View ble.ino
#include <mDash.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
#define WIFI_NAME "XX"
#define WIFI_PASS "YY"
#define DEVICE_ID "d1"
View example_mdash_request.js
var https = require('https');
// Same as:
// curl -H 'Content-Type: application-json' -d PARAMS
var mdashRequest = function(apiToken, deviceID, method, params, func) {
return new Promise(function(resolve, reject) {
var received = '';
var strParams = JSON.stringify(params || {});
var url = '' + deviceID + '/rpc/' +
cpq /
Last active May 4, 2019
Symbolizing Arduino backtrace dump for ESP32 (MacOS version)
# Usage:
# sh sketch_Apr25 400d4e36:0x3ffb1e50 0x400d1bce:0x3ffb1e90 0x400d1d96:0x3ffb1ee0 0x400d5a8d:0x3ffb1f30
ELF=$(find /var/folders/ -name $INO.elf 2>/dev/null)
cpq / rest.js
Created Dec 6, 2018
Minimal REST nodejs server
View rest.js
var http = require('http');
var port = 8080;
var server = http.createServer(function(request, response) {
console.log('Requested URI:', request.url);
response.writeHead(200, {'Content-Type': 'application/json'});
response.write(JSON.stringify({a: 1, b: 2}), 'utf-8');
server.listen(parseInt(port, 10));
cpq / mgos_conf_shadow.c
Created Oct 19, 2018
config via shadow
View mgos_conf_shadow.c
#include "mgos.h"
#include "mgos_rpc.h"
#include "mgos_shadow.h"
static void report_state_to_the_shadow(void) {
const struct mgos_conf_entry *schema =
mgos_conf_find_schema_entry("KEY", mgos_config_schema());
struct mbuf mb;
mbuf_init(&mb, 0);
mgos_conf_emit_cb(&mgos_sys_config, NULL, schema, false, &mb, NULL, NULL);
You can’t perform that action at this time.