This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <ctype.h> | |
struct hash_struct { | |
struct hash_struct **pprev; | |
struct hash_struct *next; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"strings" | |
) | |
func frequencyHash(word string) string { | |
frequencyTable := [26]int{} | |
for _, b := range word { | |
ascii := int(b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"container/list" | |
"fmt" | |
"strconv" | |
"strings" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import collections | |
import networkx | |
class KindPort(object): | |
delimiter = "/" | |
def __init__(self, kind, name, port): | |
self.kind = kind | |
self.name = name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* An example using vmsplice to move user space buffers to pipe before using | |
* splice syscall which avoids copying to/from user space buffers to kernel space | |
* and uses the pipe buffers allocated in kernel space as an intermediate to directly xfer from one file to another | |
* | |
* gcc -o splice splice.c -g | |
*/ | |
#define _GNU_SOURCE | |
#include <stdio.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_features_targets(df, target_correlation_map, | |
num_features = 2, correlation_method = 'pearson', correlation_barrier = 0.6): | |
from itertools import combinations | |
targets = list(df.columns.values) | |
target_map = {} | |
#construct a target map using the correlation matrix | |
for features in combinations(targets, num_features + 1): | |
#target is first one, remaining are feature combinations | |
target = features[0] | |
if target not in target_map: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You are given a list of numbers and a starting position. | |
# Your goal is to find a sequence of jumps from the starting position to the end of the list. | |
# A valid jump at any position must be between zero and the value at that position in the list, i.e. list[pos], inclusive. | |
# You must return a list of valid jumps in sequence that lead to the end of the list, or null if no such sequence exists. | |
# The list can have negative numbers as well that needs to be handled | |
# The goal is to find minimum number of jumps to reach the end of the list that can also include negative numbers. | |
import sys | |
from collections import defaultdict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/karthick18/nanoclient/nanoproxy/nanotcpproxy" | |
"github.com/karthick18/nanoclient/nanoproxy/virtualconn" | |
"net" | |
"time" | |
"fmt" | |
"log" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## LD_PRELOAD=$PATH/libhookmmap.so $PROG | |
CC := gcc | |
SRCS := hook_mmap.c | |
OBJS := $(SRCS:%.c=%.o) | |
TARGETS = libhookmmap.so | |
DEBUG_FLAGS = -g | |
CFLAGS = -Wall -fPIC -shared | |
LD_LIBS = -ldl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Test glibc overlapping memcpy. | |
* glibc resorts to a downward direction memcpy for anything exceeding ~200 bytes. | |
* No clue for the so-called optimization that breaks apps resorting to memcpy | |
* for overlapping boundaries instead of using memmove. | |
* This is only specific to x86_64/64 bit as for 32 bits, it always uses a forward memcpy. | |
* | |
* Try this -- | |
* gcc -o memcp memcp.c -DHAVE_MEMCPY | |
* ./memcp |
NewerOlder