Skip to content

Instantly share code, notes, and snippets.

Avatar

Sang-Kil Park likejazz

View GitHub Profile
View hello.ts
import { serve } from "https://deno.land/std@0.95.0/http/server.ts";
const s = serve({ port: 8000 });
console.log("http://localhost:8000/");
for await (const req of s) {
req.respond({ body: "Hello World\n" });
}
@likejazz
likejazz / detect-faces.go
Last active Jan 29, 2021
Detect Faces from the Google Vision API
View detect-faces.go
// References: https://cloud.google.com/vision/docs/detecting-faces#vision_face_detection_gcs-drest
package main
import (
vision "cloud.google.com/go/vision/apiv1"
"fmt"
"golang.org/x/net/context"
"google.golang.org/api/option"
pb "google.golang.org/genproto/googleapis/cloud/vision/v1"
"io"
@likejazz
likejazz / Dockefile
Last active Sep 26, 2020
Apache Hello World Docker
View Dockefile
FROM ubuntu:18.04
# Install dependencies
RUN apt-get update && \
apt-get -y install apache2
# Install apache and write hello world message
RUN echo 'Hello World!' > /var/www/html/index.html
# Configure apache
@likejazz
likejazz / bigquery.py
Last active Sep 26, 2020
Call BigQuery API from Python
View bigquery.py
import google.auth
from google.cloud import bigquery
from google.cloud import bigquery_storage_v1beta1
# Explicitly create a credentials object. This allows you to use the same
# credentials for both the BigQuery and BigQuery Storage clients, avoiding
# unnecessary API calls to fetch duplicate authentication tokens.
def bigquery_auth(project_id: str = 'edith-xxx') -> None:
logging.info('[AUTH] Create a credentials.')
View dockerize.sh
declare TARGET="ec2-XXXX.ap-northeast-2.compute.amazonaws.com"
readonly VERSION=$(date '+%y.%m.%d') # Today's yy.mm.dd ubuntu version style.
readonly IMAGE_NAME=edith/edith-XXXX
readonly ECR_REGISTRY=09960362XXXX.dkr.ecr.ap-northeast-2.amazonaws.com/edith/edith-XXXX
readonly AWS_OTP=$(aws ecr get-login-password --region ap-northeast-2)
# Build
docker build -t ${IMAGE_NAME} .
View lint.py
# %%
import json
datas = []
# Process KorQuAD's training data.
# Counts: 60,407
for i in range(0, 1):
in_file = '/Users/likejazz/Desktop/korquad'
# in_file += '/korquad2.0_train_0' + str(i) + '.json'
@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 \"\"
}'"
@likejazz
likejazz / aws-essential-install.sh
Last active Mar 27, 2020
Minimum installation scripts for Amazon Linux 2
View aws-essential-install.sh
#!/bin/bash
# Set up a clean UTF-8 environment
sudo bash -c 'echo "LANG=en_US.utf-8
LC_ALL=en_US.utf-8" > /etc/environment'
# Set the Timezone to KST
sudo rm /etc/localtime
sudo ln -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime
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;