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
watch -n 5 "ss -an \ | |
| grep -v 'LISTEN' | grep -v 'State' \ | |
| awk '{print \$1\" \"\$5}' | awk -F: '{print \$1}' \ | |
| sort | uniq -c | sort -k3 \ | |
| awk '{ printf(\"%10s %15s %5s\t\",\$2,\$3,\$1); \ | |
for (i = 0; i < \$1; i++) { \ | |
printf(\"*\") \ | |
}; \ | |
print \"\" | |
}'" |
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 | |
############################################ | |
# Initialization Script for Amazon Linux 2 | |
############################################ | |
# Run "sudo yum update" to apply all updates. | |
sudo yum update -y | |
# Set the Timezone to KST |
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/sh | |
# This is a simple bash script that will poll github for changes to your repo, | |
# if found pull them down, and then rebuild and restart a API server. | |
while true | |
do | |
# move into your git repo where your API server src is | |
cd /home/deploy/workspace/go/src/github.daumkakao.com/iris/api | |
git fetch; |
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 bash | |
set -e | |
IMAGE="URL" | |
CID=$(sudo docker ps | grep $IMAGE | awk '{print $1}') | |
sudo docker pull $IMAGE | |
for im in $CID | |
do | |
LATEST=`sudo docker inspect --format "{{.Id}}" $IMAGE` | |
RUNNING=`sudo docker inspect --format "{{.Image}}" $im` | |
NAME=`sudo docker inspect --format '{{.Name}}' $im | sed "s/\///g"` |
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 <math.h> | |
#include <stdio.h> | |
// Kernel function to add the elements of two arrays | |
__global__ | |
void add(int n, float *x, float *y) { | |
int index = blockIdx.x * blockDim.x + threadIdx.x; | |
int stride = blockDim.x * gridDim.x; | |
for (int i = index; i < n; i += stride) |
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 sys | |
import time | |
def generate(in_data, out_data): | |
for i in range(len(in_data)): | |
print('Generating:', i + 1, file=sys.stderr) | |
sys.stdout = open('testcase/input%02d.txt' % (i + 1), 'w') | |
print(in_data[i]) | |
sys.stdout.close() |
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> | |
template<class T> | |
constexpr | |
std::string_view | |
type_name() { | |
using namespace std; | |
string_view p = __PRETTY_FUNCTION__; | |
return string_view(p.data() + 34, p.size() - 34 - 1); | |
} |
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 <regex> | |
using namespace std; | |
int alphabet[26]; | |
void tokenized(int a, int c) { | |
alphabet[a - 1] += c; | |
} |
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> | |
using namespace std; | |
// a utility function that returns total set bits | |
// count in an integer | |
// http://www.geeksforgeeks.org/sort-array-according-count-set-bits/ | |
int countBits(int a) { | |
int count = 0; | |
while (a) { |
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> | |
using namespace std; | |
int diff = 0; | |
// C++ get each digit in integer | |
// https://stackoverflow.com/a/4615187/3513266 | |
void calc_each_moves(int a, int m) { | |
// the variable `a` is used as a reference. |