Skip to content

Instantly share code, notes, and snippets.

View devendranaga's full-sized avatar
🍈

Dev devendranaga

🍈
  • Bangalore
View GitHub Profile
@devendranaga
devendranaga / threadpool.cc
Last active August 28, 2023 15:15
Thread pool with RR scheduling in C++
/**
* @brief - Thread pool implementation within 200 lines.
*
* @author - Devendra Naga (github.com/devendranaga/)
*
* @copyright - 2023-present.
* @license - GPLv2
*/
#include <iostream>
#include <queue>
@devendranaga
devendranaga / gmac.c
Created January 22, 2023 18:26
GMAC openssl example
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <openssl/evp.h>
int main()
{
int ret = 0, unused = 0;
uint8_t key[] = {
@devendranaga
devendranaga / main.cpp
Created January 17, 2023 18:15 — forked from grejdi/main.cpp
Using openssl to encrypt and decrypt a message with public/private key.
using namespace std;
#include <openssl/evp.h>
#include <openssl/pem.h>
#include <iostream>
#include <string>
int main()
{
@devendranaga
devendranaga / htons.rs
Created October 22, 2022 20:06
htons in rust
fn htons(val: &u16) -> u16 {
return ((val & 0x00FF) << 8) | ((val & 0xFF00) >> 8)
}
@devendranaga
devendranaga / rust_memcpy.rs
Created October 4, 2022 14:00
memcpy in rust
fn memcpy(src: &[u8], dst: &mut [u8], len: usize) {
let i: usize = 0;
while i < len {
dst[i] = src[i];
}
}
fn main() {
let buf: [u8; 10] = [1; 10];

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@devendranaga
devendranaga / double_list.c
Created March 12, 2022 16:29
o(1) based double linked list implementation
#include <stdio.h>
#include <stdlib.h>
struct list {
void *data;
struct list *prev, *next;
};
static struct list *head, *last;
@devendranaga
devendranaga / list.c
Created March 12, 2022 16:11
o(1) based linked list implementation
#include <stdio.h>
#include <stdlib.h>
struct list {
void *data;
struct list *next;
};
static struct list *head, *last;
@devendranaga
devendranaga / poly1305-aes.c
Created March 6, 2022 16:48
poly1305-aes authentication
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include <openssl/evp.h>
#include <openssl/err.h>
#include <openssl/params.h>
@devendranaga
devendranaga / safe_queue.cc
Created November 4, 2021 12:30
safe_queue
/**
* @brief - a demo example of Safe Queue
*
* @copyright - 2021-present All rights reserved
*
* @author - Devendra Naga (devendra.aaru@outlook.com)
*
* @license - proprietary license, ask author for more information
*/
#include "safe_queue.h"