Skip to content

Instantly share code, notes, and snippets.

Sang-Kil Park likejazz

Block or report user

Report or block likejazz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@likejazz
likejazz / ping-redis.py
Created Jul 6, 2019
Analyzing Redis PING performance
View ping-redis.py
import time
import redis
for i in range(10):
start_time = time.time()
try:
conn = redis.StrictRedis(
host='xxx',
port=6379,
db=0)
@likejazz
likejazz / watch-connections.sh
Created Jul 6, 2019
Graph n of connections for each hosts
View watch-connections.sh
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 \"\"
}'"
View github-polling.sh
#!/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;
View update-docker.sh
#!/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"`
View add_grid.cu
#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)
View hackerrank-test.py
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()
View print-var-type-cpp17.cpp
#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 Jul 22, 2017
Long Encoded String
View long-encoded-string.cc
#include <iostream>
#include <regex>
using namespace std;
int alphabet[26];
void tokenized(int a, int c) {
alphabet[a - 1] += c;
}
View cardinality-sorting.cc
#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) {
View minimum-moves.cc
#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.
You can’t perform that action at this time.