Skip to content

Instantly share code, notes, and snippets.

View raczben's full-sized avatar

Benedek Racz raczben

View GitHub Profile
@pusateri
pusateri / recvmsg.c
Created September 30, 2018 20:47
Example recvmsg() code for Linux and Unix
void
recv_cb(evutil_socket_t fd, short event, void *arg)
{
struct msghdr msg;
struct iovec iov[1];
ssize_t len;
int flags = 0;
struct cmsghdr *cmptr;
sockaddr_union_t sau;
struct unp_in_pktinfo {
@nfaggian
nfaggian / pool.py
Last active July 30, 2021 17:12
Multiprocessing example
from __future__ import print_function
import multiprocessing
import ctypes
import numpy as np
def shared_array(shape):
"""
Form a shared memory numpy array.
@89465127
89465127 / argparse_files.py
Last active August 27, 2022 14:24
Get a list of filenames using argparse (updated to use default formatter)
import argparse
import os
import glob
def main():
#Does not currently have support to read files from folders recursively
parser = argparse.ArgumentParser(description='Read in a file or set of files, and return the result.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('path', nargs='+', help='Path of a file or a folder of files.')
parser.add_argument('-e', '--extension', default='', help='File extension to filter by.')
args = parser.parse_args()
@austinmarton
austinmarton / recvRawEth.c
Created June 3, 2012 07:55
Receive raw Ethernet frames in Linux
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <linux/ip.h>