Skip to content

Instantly share code, notes, and snippets.

View devendranaga's full-sized avatar
🍈

Dev devendranaga

🍈
  • Bangalore
View GitHub Profile
@devendranaga
devendranaga / pthread_exec.c
Created June 29, 2015 07:35
calling exec in a pthread
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
void *thread_func(void *data)
{
execlp("/bin/ls", "ls", "-l", NULL);
}
int main(void) {
@devendranaga
devendranaga / reset_struct.c
Created July 2, 2015 05:11
reset struct without using memset
#include <stdio.h>
struct test_ {
int a;
char string[20];
};
int main(void) {
struct test_ test_ = {};
@devendranaga
devendranaga / count_sloc.py
Created July 3, 2015 15:38
counts the number of sloc (Github)
#!/usr/bin/python
import sys
import os
if len(sys.argv) != 2:
print sys.argv[0] + " " + "filename"
exit(0)
fd = open(sys.argv[1], "r")
@devendranaga
devendranaga / cpuenable.c
Created July 18, 2015 18:44
take a cpu online / offline in linux (tested on Fedora 22)
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <fcntl.h>
void usage()
{
printf("./cpuenable <online / offline> <cpu number>\n");
exit(1);
@devendranaga
devendranaga / signalfd.c
Created December 27, 2015 13:42
register more than one signal with signalfd for any event
#include <stdio.h>
#include <stdint.h>
#include <signal.h>
#include <unistd.h>
#include <sys/signalfd.h>
#include <sys/select.h>
fd_set allfd;
int maxfd;
int sfd_int;
@devendranaga
devendranaga / timespec_diff.c
Created August 26, 2017 03:33 — forked from diabloneo/timespec_diff.c
Calculate diff of two struct timespec
#include <time.h>
void timespec_diff(struct timespec *start, struct timespec *stop,
struct timespec *result)
{
if ((stop->tv_nsec - start->tv_nsec) < 0) {
result->tv_sec = stop->tv_sec - start->tv_sec - 1;
result->tv_nsec = stop->tv_nsec - start->tv_nsec + 1000000000;
} else {
result->tv_sec = stop->tv_sec - start->tv_sec;

What is V2X

                        **Devendra Naga (devendra.aaru@gmail.com)**

V2X is a vehicle to everything technology that allows the vehicles to be aware of their surroundings such as the other vehicles around it, enviornmental conditions, road conditions and many more.

This is an ongoing WIP document.. stay tuned for more.. i will update as and when i have free of time..

Intro

@devendranaga
devendranaga / csvparser.cpp
Created December 12, 2018 05:14
simple CSV parser Class
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
class csvParse {
public:
csvParse(std::string input, std::vector<std::string> &output);
};
@devendranaga
devendranaga / ActionActor.cpp
Created December 24, 2018 14:56
Action and Actor design class
#include <iostream>
#include <thread>
#include <unistd.h>
template <typename T1, typename T2>
class action {
public:
int registerPeriodicAction(T1 *data, T2 *specificCtx)
{
d = data;
int list_add_tail(void *data)
{
struct linked_list *t;
t = malloc(sizeof(struct linked_list));
if (!t) {
return -1;
}
t->data = data;