Skip to content

Instantly share code, notes, and snippets.

// Maybe https://stackoverflow.com/questions/67274905/c-c-resolving-docker-compose-services-to-same-ip can help
// https://man7.org/linux/man-pages/man3/getaddrinfo.3.html
template <class F>
bool getaddr(const char* host, const char* service, F&& f)
{
addrinfo hints{};
addrinfo* result;
//hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
hints.ai_family = PF_INET; /* Allow IPv4 or IPv6 */
#include <iostream>
#include <string>
// think of 'nibbles' parameter as a kind of hexidecimal version of decimal places
std::string int_to_hex(unsigned long value, int nibbles)
{
static const char converter[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
// stack allocate C style string, just enough to fit 'nibbles' amount
import QtQuick
import QtQuick.Layouts
//import PGQT_43 // EXPERIMENTAL, made no difference except to inform that DataObject can be explicitly stated
ListView {
required model
delegate: Rectangle {
id: testDel
@malachib
malachib / PyQt5+EGLFS.md
Last active May 17, 2022 01:06
PyQt5 + Raspberry Pi + EGLFS notes

Debian

Modules you probably need:

sudo apt-get install qt5-default qml-module-qtquick-controls qml-module-qtquick-controls2

Also recommended:

sudo apt-get install qml-module-qtlocation qml-module-qtpositioning

@malachib
malachib / ToDo.cshtml
Created June 4, 2018 23:43
Updated for Blazor 0.3.0
@page "/todo"
@using Blazor1.Shared
@inject HttpClient Http
<h1>ToDo List</h1>
<div>
<div class="row">
<div class="col-sm-1">
<p>Item:</p>
@malachib
malachib / gist:5be56dfe2475759dd5bc087f80d26929
Created October 8, 2017 18:36
Convert modulus to a C friendly format
#!/bin/bash
# Converts to a more C friendly format
echo -n '#define MODULUS "\x' > modulus.h
sed s/:/'\\'x/g <modulus.txt >> modulus.h
/**
* @file
* netif API (to be used from TCPIP thread)
*/
/*
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
@malachib
malachib / gist:3ff06a8a629ad863246b6e01a5d1510d
Created December 31, 2016 20:06
Unexpected corruption
struct netconn *conn = netconn_new_with_proto_and_callback(NETCONN_UDP, 0, NULL);
char buf[512];
if(!conn)
{
cerr << "Failed to allocate socket";
abort();
}
netconn_bind(conn, IP_ADDR_ANY, 5000);
@malachib
malachib / gist:151e3702d38d96e6683e2eded8f021d8
Created December 21, 2016 12:07
igmp_joingroup code... fails with a -6
bool UDP_Multicast_init(void)
{
//bool IGMP_joined;
struct ip_addr ipgroup;
struct udp_pcb *g_udppcb;
char msg[] = "gaurav";
struct pbuf* p;
p = pbuf_alloc(PBUF_TRANSPORT,sizeof(msg),PBUF_RAM);
memcpy (p->payload, msg, sizeof(msg));
var paths = {
js: webroot + "js/**/*.js",
minJs: webroot + "js/**/*.min.js",
css: webroot + "css/**/*.css",
minCss: webroot + "css/**/*.min.css",
concatJsDest: webroot + "js/site.min.js",
concatCssDest: webroot + "css/site.min.css",
// added by Mal
npmSrc: "./node_modules/",
//paths.npmLibs = paths.webroot + "lib/npmlibs/"; // for some reason this didn't work further down in the code