Skip to content

Instantly share code, notes, and snippets.

View changyeon's full-sized avatar

Changyeon Jo changyeon

View GitHub Profile
@changyeon
changyeon / cdf.py
Created July 23, 2020 07:46
CDF and CCDF in Python3
import numpy as np
def cdf(a):
X = np.sort(np.arraya(a))
Y = np.array(range(a.size)) / float(a.size)
return X, Y
def ccdf(a):
X = np.sort(np.array(a))
Y = (np.full(a.shape, fill_value=a.size) - np.array(range(a.size))) / float(a.size)
@changyeon
changyeon / #02 Multi VM.ipynb
Created April 23, 2020 08:01
Cache/2020.01.ATC/#02 Multi VM.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char *buf = NULL, *p = NULL;
unsigned long i, page_size = 4096, offset = 0, buf_size = 1UL << 10UL;
setbuf(stdout, NULL);
@changyeon
changyeon / rss_recorder.py
Created March 26, 2020 03:26
RSS Recorder
#!/usr/bin/env python3
import os
import sys
import time
import signal
import threading
import subprocess
class MemoryMonitor(threading.Thread):
@changyeon
changyeon / vistk.py
Last active December 14, 2021 15:07
Visualization Toolkit
import pathlib
import itertools
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
# 1. Update and the fonts in the parent direcotry
# import os
# import sys
# sys.path.insert(0, os.path.dirname(os.getcwd()))
@changyeon
changyeon / visualize.py
Last active March 20, 2020 07:42
Python Matplotlib
def get_fontproperties(font, fontsize):
if font == 'monaco':
fontproperties = mpl.font_manager.FontProperties(fname='Fonts/Monaco.ttf', size=fontsize)
elif font == 'times':
fontproperties = mpl.font_manager.FontProperties(fname='Fonts/Times New Roman.ttf', size=fontsize)
elif font == 'helvetica':
fontproperties = mpl.font_manager.FontProperties(fname='Fonts/Helvetica.ttf', size=fontsize)
elif font == 'libertine':
fontproperties = mpl.font_manager.FontProperties(fname='Fonts/Libertine.ttf', size=fontsize)
elif font == 'nanum_gothic':
@changyeon
changyeon / hashtable.c
Created November 29, 2019 05:51
Linux kernel hashtable
#include <linux/hashtable.h>
#define CONN_HASH_BITS 4
DEFINE_HASHTABLE(conn_hash, CONN_HASH_BITS);
struct dvs_hash_node {
int val;
struct hlist_node hash_node;
};
@changyeon
changyeon / logging.py
Last active June 7, 2023 02:26
File and stdout logging in Python3
#!/usr/bin/env python3
import socket
import getpass
import logging
class ContextFilter(logging.Filter):
def filter(self, record):
record.hostname = socket.gethostname()
record.user = getpass.getuser()
return True
@changyeon
changyeon / gen_reqs.sh
Created March 25, 2019 08:31
Automatic generation of requirements.txt
pipreqs --force ./
@changyeon
changyeon / Azure VM CPU readings visualization in same group.ipynb
Created February 7, 2019 08:17
Azure VM CPU readings visualization
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.