Skip to content

Instantly share code, notes, and snippets.

View sutyum's full-sized avatar

Satyam Tiwary sutyum

  • @TechnocultureResearch
  • Boodgaya, India
View GitHub Profile
A::B is a system with 4 tokens: `A#`, `#A`, `B#` and `#B`.
An A::B program is a sequence of tokens. Example:
B# A# #B #A B#
To *compute* a program, we must rewrite neighbor tokens, using the rules:
A# #A ... becomes ... nothing
A# #B ... becomes ... #B A#
@pesterhazy
pesterhazy / building-sync-systems.md
Last active June 28, 2024 11:04
Building an offline realtime sync engine

So you want to write a sync system for a web app with offline and realtime support? Good luck. You might find the following resources useful.

Overview articles

@sutyum
sutyum / SHED_FIFO.c
Created December 13, 2021 07:56
Use FIFO scheduling policy and Core affinity in linux
#define _GNU_SOURCE
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <sched.h>
#include <sys/sysinfo.h>
#include <sys/types.h>
#include <unistd.h>
#include <syslog.h>
@sutyum
sutyum / syslog.c
Last active December 14, 2021 09:32
Logging to Linux Syslog
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/syslog.h>
#define THREAD_COUNT 128
static const char *g_log_header = "[MYLOGS]";
typedef struct {
@badrbouslikhin
badrbouslikhin / rtic-embassy-poc.rs
Created October 24, 2021 22:53
Proof of concept of RTIC + Embassy on a Thingy:52
#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
#![feature(alloc_error_handler)]
#![allow(incomplete_features)]
#![macro_use]
use alloc_cortex_m::CortexMHeap;
use core::alloc::Layout;
use core::mem;
@tiagocoutinho
tiagocoutinho / README.md
Last active December 19, 2023 07:57
Virtual serial line (RS232) on linux with socat and pyserial

Virtual serial line

Virtual serial line on linux with socat, python server & client

Run on terminal 1:

socat -d -d pty,raw,echo=0,link=/tmp/cryocon_simulator pty,raw,echo=0,link=/tmp/cryocon

Run on terminal 2:

@carlosedp
carlosedp / platformio.ini
Last active January 26, 2022 17:24
PlatformIO Renode Integration
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
@syncclk
syncclk / DE10SoCNanoBasicGuide.md
Created March 8, 2020 23:16 — forked from addisonElliott/DE10SoCNanoBasicGuide.md
This is a basic guide for building a program on the DE10 Nano SoC. This walks through using Quartus Prime, Qsys, and EDS from start to finish. The program counts up four LEDs on the HPS

I successfully created a project instantiating the HPS in Qsys. I added a parallel I/O in Qsys to allow the HPS to communicate with the LEDs via the HPS-to-FPGA lightweight bus. From there, I generated a preloader and U-boot along with the SOF file. I also wrote a simple C program that counts from 0-15 and sets the LEDs to that value every second. This encompasses about every step required to be able to communicate between the FPGA and HPS, so this is definitely a first step. I'm going to document what I did and how you guys can get this running.

I did this on Windows since that is my primary OS. Things are different on Linux, so you will have to figure them out if you try to do this on Linux.

File Structure

DE10NanoUART-FPGA

  • Project containing everything necessary to get exactly what I have running
  • HPS_FPGA_LED - Source code and makefile for the C program to blink LEDs
  • hps_isw_handoff - ISW stands for Initial SoftWare so it is the first thing to be ran AFTER the hardcoded bootrom is loa
@oldrev
oldrev / fixedpoint-pid.c
Created July 25, 2019 00:12
Fixed-Point PID Algorithm
// Fixed-Point PID Algorithm
// Ported from: https://gist.github.com/bradley219/5373998
// Author: Li "oldrev" Wei <oldrev@gmail.com>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#define FIXED32_Q (16)
@fay59
fay59 / Quirks of C.md
Last active January 23, 2024 04:24
Quirks of C

Here's a list of mildly interesting things about the C language that I learned mostly by consuming Clang's ASTs. Although surprises are getting sparser, I might continue to update this document over time.

There are many more mildly interesting features of C++, but the language is literally known for being weird, whereas C is usually considered smaller and simpler, so this is (almost) only about C.

1. Combined type and variable/field declaration, inside a struct scope [https://godbolt.org/g/Rh94Go]

struct foo {
   struct bar {
 int x;