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 / autossh.py
Created August 28, 2015 16:26
get into a machine and exec a list of commands..
#!/usr/bin/python
# Author: devnaga
## ip, username, password, command
# the csv file must look like the following
# ip,username,password,'command1; command2; command3'
# any sspace between the ',' will get you in trouble
import sys
import paramiko
import csv
@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 / nmea_checksum_creator.c
Created September 5, 2016 20:06
NMEA checksum calculator in C
#include <stdio.h>
#include <string.h>
int nmea0183_checksum(char *nmea_data)
{
int crc = 0;
int i;
// the first $ sign and the last two bytes of original CRC + the * sign
for (i = 1; i < strlen(nmea_data) - 3; i ++) {
@devendranaga
devendranaga / nmea_checksum_creator.go
Created September 5, 2016 20:16
nmea checksum calculator in Golang
func nmea0183_checksum(nmea_in string) int {
check_sum:= 0
nmea_data := []byte(nmea_in)
for i:= 1; i < len(nmea_in) - 3; i ++ {
check_sum ^= (int)(nmea_data[i])
}
@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