Skip to content

Instantly share code, notes, and snippets.

View carun's full-sized avatar

Arun carun

  • NEC
  • Folsom, California
  • 04:04 (UTC -07:00)
View GitHub Profile

Keybase proof

I hereby claim:

  • I am carun on github.
  • I am arunc (https://keybase.io/arunc) on keybase.
  • I have a public key ASBAhjwdEEN8dCM_ElHf4ihfEgB8Hs4EwIo7bg2IFjgdhAo

To claim this, I am signing this object:

@carun
carun / interfaces.d
Created April 22, 2019 22:40
Print macaddress
/* net/if.h -- declarations for inquiring about network interfaces
Copyright (C) 1997-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
@carun
carun / gist:09e332dea6b6c99cc3d678e6d261e321
Created July 16, 2018 09:28 — forked from luckydev/gist:b2a6ebe793aeacf50ff15331fb3b519d
Increate max no of open files limit in Ubuntu 16.04 for Nginx
# maximum capability of system
user@ubuntu:~$ cat /proc/sys/fs/file-max
708444
# available limit
user@ubuntu:~$ ulimit -n
1024
# To increase the available limit to say 200000
user@ubuntu:~$ sudo vim /etc/sysctl.conf
@carun
carun / memcpyd-output.log
Created June 14, 2018 05:59
memcpyd output for Mike Franklin
Intel(R) Core(TM) i7-6770HQ CPU @ 2.60GHz
16 GB RAM
---
dmd memcpyd.d
./memcpyd
size memcpyC memcpyD
1 38096 26341
2 40524 27605
import std.stdio; [59/187]
// import std.math;
import core.stdc.stdio;
import core.stdc.math;
enum pi = 3.141592653589793;
enum solar_mass = (4 * pi * pi);
enum days_per_year = 365.24;
struct Planet {
@carun
carun / API.md
Created December 9, 2016 01:22 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@carun
carun / multithreaded-bind.c
Last active November 21, 2019 22:07
Sample code to illustrate multiple threads binding on the same port using SO_REUSEPORT option introduced in kernel 3.9. Here is the LWN article on the same https://lwn.net/Articles/542629/
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdbool.h>
#include <arpa/inet.h>
#include <pthread.h>
void* do_work(void *arg)
{
@carun
carun / Inkpot.xml
Created July 8, 2013 11:57
Inkpot color scheme with dark background for QtCreator.
<?xml version="1.0" encoding="UTF-8"?>
<style-scheme version="1.0" name="Inkpot (Dark)">
<style name="Text" foreground="#cfcfcf" background="#141414"/>
<style name="Link" foreground="#409090"/>
<style name="Selection" foreground="#ffffff" background="#4e4e8f"/>
<style name="LineNumber" foreground="#5f5fff" background="#2e2e2e"/>
<style name="SearchResult" foreground="#000000" background="#ffef0b"/>
<style name="SearchScope" foreground="#000000" background="#f8fafc"/>
<style name="Parentheses" foreground="#ffff00" background="#4e4e8f"/>
<style name="CurrentLine" foreground="#000000" background="#2d2d32"/>
@carun
carun / gist:4117631
Created November 20, 2012 12:24
Multithreaded application to process files in a directory
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
#include <pthread.h>
#define NAME_MAX (256)
/* #define MAX_THREADS (99) */
@carun
carun / gist:4117614
Created November 20, 2012 12:20
Explode in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char **explode(char *string, char separator, int *arraySize)
{
int start = 0, i, k = 0, count = 2;
char **strarr;
for (i = 0; string[i] != '\0'; i++){
/* Number of elements in the array */