$ vmstat -n 2 | perl -e 'while(<>){print localtime().": $_"}'
Fri Dec 30 15:34:51 2016: procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
Fri Dec 30 15:34:51 2016: r b swpd free buff cache si so bi bo in cs us sy id wa
Fri Dec 30 15:34:51 2016: 2 0 57216 94916 93012 135552 4 22 601 39 216 593 2 2 94 2
Fri Dec 30 15:34:53 2016: 0 0 57216 94296 93012 135552 0 0 0 0 201 737 1 1 98 0
Fri Dec 30 15:34:55 2016: 0 0 57216 94296 93012 135552 0 0 0 0 176 707 1 1 98 0
Fri Dec 30 15:34:57 2016: 0 0 57216 94296 93012 135552 0 0 0 0 174 656 1 1 98 0
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> //printf(), fprintf(), perror() | |
#include <sys/socket.h> //socket(), connect(), recv() | |
#include <arpa/inet.h> // struct sockaddr_in, struct sockaddr, inet_ntoa(), inet_aton() | |
#include <stdlib.h> //atoi(), exit(), EXIT_FAILURE, EXIT_SUCCESS | |
#include <string.h> //memset() | |
#include <unistd.h> //close(), sleep() | |
#include <linux/tcp.h> //TCP_DEFER_ACCEPT | |
#define MSGSIZE 32 | |
#define MAX_MSGSIZE 1024 |
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> //printf(), fprintf(), perror() | |
#include <sys/socket.h> //socket(), connect(), recv() | |
#include <arpa/inet.h> // struct sockaddr_in, struct sockaddr, inet_ntoa(), inet_aton() | |
#include <stdlib.h> //atoi(), exit(), EXIT_FAILURE, EXIT_SUCCESS | |
#include <string.h> //memset() | |
#include <unistd.h> //close() | |
#include <linux/tcp.h> //TCP_DEFER_ACCEPT | |
#include <time.h> // | |
#define MSGSIZE 32 |
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
#!/bin/bash | |
if [ -z "$*" ]; then | |
echo "cs [OPTIONS] DIR" | |
echo " ORDER BY OPTIONS:" | |
echo " -f : file count" | |
echo " -s : file size" | |
echo " -m : file modification time" | |
echo " -j : total size of files just under a directory" | |
echo " -a : total size of files all under a directory" |
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
from tensorflow.examples.tutorials.mnist import input_data | |
# one_hot is for multiclass classification | |
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) | |
import tensorflow as tf | |
# Input | |
# 784 = 28 x 28 | |
# Mini batch size is not fixed here | |
x = tf.placeholder(tf.float32, [None,784]) |
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
import os | |
import time | |
from amazon.api import AmazonAPI | |
AMAZON_ACCESS_KEY = os.environ['AWSAccessKeyId'] | |
AMAZON_SECRET_KEY = os.environ['AWSSecretKey'] | |
AMAZON_ASSOC_TAG = os.environ['AWSAssocId'] | |
print(AMAZON_ACCESS_KEY[-5:]) | |
print(AMAZON_SECRET_KEY[-5:]) |
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
from random import random | |
import time | |
import sys | |
def findCommon_NNN(A,B,C): | |
if 1000<len(A) or 1000<len(B) or 1000<len(C): | |
print("# This may be huge input for this function with O(N^3). Exit.") | |
return [] |
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 <iostream> | |
#include <sstream> | |
#include <algorithm> | |
#include <vector> | |
#include <map> | |
#include <math.h> | |
//#include <list> # lower_bound does not work | |
#include <openssl/sha.h> | |
#include <assert.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
class Sorter: | |
def __init__(self,data): | |
self.data = data | |
def do_msort(self): | |
print("Original data",self.data) | |
self.run_msort(0,len(self.data)-1) | |
print("Sorted data ",self.data) | |
def run_msort(self,i,j): |
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
class LCD: | |
def __init__(self,s1,s2): | |
self.s1 = s1 | |
self.s2 = s2 | |
print(s1,s2) | |
def solve(self): | |
a = [ [ 0 for y in range(len(self.s2)+1) ] for x in range(len(self.s1)+1) ] | |
for x in range(len(self.s1)): | |
for y in range(len(self.s2)): |