Skip to content

Instantly share code, notes, and snippets.

@keaston
keaston / epoll_rcvlowat.c
Created August 29, 2018 06:00
Test interaction of SO_RCVLOWAT and epoll_wait() on a TCP socket.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/epoll.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
@keaston
keaston / popen-pth.c
Created April 21, 2017 12:30
SO #43530786
#include <stdio.h>
#include <pthread.h>
void *thr(void *arg)
{
char *cmd = arg;
FILE *fp;
printf("Starting thread for: %s\n", cmd);
fp = popen(cmd, "r");
@keaston
keaston / DuplicateFinder.java
Last active March 6, 2016 23:34 — forked from kedarmhaswade/DuplicateFinder.java
Trying out an SO solution ...
/** Trying out the solution to:
* http://stackoverflow.com/questions/5739024/finding-duplicates-in-on-time-and-o1-space
* Created by kmhaswade on 3/5/16.
* Updated by keaston 2016-03-07
*/
public class DuplicateFinder {
public static void main(String[] args) throws IOException {
int[] a = new int[]{3, 0, 1, 3, 2};
int n = a.length;
for (int i = 0; i <= n-1; i++) {