Skip to content

Instantly share code, notes, and snippets.

View devendranaga's full-sized avatar
🍈

Dev devendranaga

🍈
  • <>
View GitHub Profile
@devendranaga
devendranaga / filesys.c
Last active August 29, 2015 14:23
find the file systems that are available in linux (vfs and mountable)
#include <stdio.h>
#include <stdlib.h>
FILE *fp;
char buffer[1000];
struct fstypes {
int vfs;
char *filesystem;
} fs_types[30];
@devendranaga
devendranaga / string_rand.c
Created June 15, 2015 16:14
random string generator in linux
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
char alphabets[] =
{'a', 'A',
'b', 'B',
'c', 'C',
@devendranaga
devendranaga / getsocknames.c
Created June 14, 2015 17:59
get a unix socket name by fd
#include <sys/un.h>
#include <sys/socket.h>
int get_sock_name(int fd, char *name, int name_len)
{
int ret
socklen_t len = sizeof(struct sockaddr_un);
struct sockaddr_un s;
ret = getsockname(fd, (struct sockaddr *)&s, &len);
#!/usr/bin/python
class Lists:
def __init__(self):
self.list = []
def list_head(self):
return self.list[0]
def list_tail(self):
return self.list[len(self.list) - 1]
def list_add_tail(self, elem):
#!/usr/bin/python
import psutil
print "num cpus " + str(psutil.cpu_count(logical=False))
print "num cpu (total) " + str(psutil.cpu_count())
#!/usr/bin/python
# only has seconds resolution
class Profile:
def profile_start(self):
self.start = time.gmtime()
def profile_stop(self):
self.stop = time.gmtime()
def profile_display(self):
@devendranaga
devendranaga / go_template.py
Created June 12, 2015 10:40
A simple template to generate a basic golang program
#!/usr/bin/python
import os
import sys
if len(sys.argv) == 1:
print "./template <filename> <package name> <imports>"
exit(0)
filename=sys.argv[1]