Skip to content

Instantly share code, notes, and snippets.

View likejazz's full-sized avatar

Sang Park likejazz

View GitHub Profile
@likejazz
likejazz / watch-connections.sh
Created July 6, 2019 06:53
Graph n of connections for each hosts
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 \"\"
}'"
@likejazz
likejazz / aws-deeplearning-essential-install.sh
Last active February 28, 2024 05:26
Essential installation script for Amazon Linux 2023
#!/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
#!/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;
#!/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"`
#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)
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()
#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);
}
@likejazz
likejazz / long-encoded-string.cc
Last active March 31, 2024 13:38
Long Encoded String
#include <iostream>
#include <regex>
using namespace std;
int alphabet[26];
void tokenized(int a, int c) {
alphabet[a - 1] += c;
}
@likejazz
likejazz / cardinality-sorting.cc
Last active August 5, 2017 17:01
Cardinality Sorting
#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) {
@likejazz
likejazz / minimum-moves.cc
Last active July 22, 2017 10:35
Minimum Moves
#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.