Skip to content

Instantly share code, notes, and snippets.

View hyounggyu's full-sized avatar

김형규(Kim, Hyounggyu) hyounggyu

View GitHub Profile
@hyounggyu
hyounggyu / dump_yaml.py
Last active October 3, 2023 03:43
[PyYAML] dump with data type
import yaml
data = {}
yaml.safe_dump(
data,
sys.stdout,
default_flow_style=False,
default_style='"',
sort_keys=True,
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import org.apache.spark.ml.classification.LogisticRegression
import org.apache.spark.ml.feature.VectorAssembler
import org.apache.spark.sql.SparkSession
object LogiReg extends App {
val spark = SparkSession
.builder()
.master("local[*]")
.appName("LogiReg")
.getOrCreate()
@hyounggyu
hyounggyu / delete_docker_images.sh
Created September 8, 2017 10:33
Remove all images and containers
#!/bin/bash
# https://techoverflow.net/2013/10/22/docker-remove-all-images-and-containers/
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@hyounggyu
hyounggyu / du.py
Created August 1, 2017 01:10
Disk usage using Python
import os
import time
start_time = time.time()
total_size = 0
for dirpath, _, _ in os.walk("."):
with os.scandir(dirpath) as it:
for entry in it:
if entry.is_file(follow_symlinks=False):
total_size += entry.stat().st_size
@hyounggyu
hyounggyu / du.go
Created August 1, 2017 01:06
Disk usage using Go
package main
import (
"fmt"
"os"
"path/filepath"
"log"
)
func main() {
import time
import psutil
tstamp = int(time.time())
d = {
"cpu_percent": psutil.cpu_percent(interval=1),
"disk_root_percent": psutil.disk_usage('/').percent,
"vmem_percent": psutil.virtual_memory().percent,
"swap_percent": psutil.swap_memory().percent,
import json
import zmq
import psutil
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://*:5556")
while True:
import json
import zmq
import psutil
context = zmq.Context()
socket = context.socket(zmq.PUB)
socket.bind("tcp://*:5556")
while True:
@hyounggyu
hyounggyu / AirConditioner.c
Last active November 3, 2016 01:38
AirConditioner.c
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <modbus.h>
const int START_REG = 36;
int main(int argc, char *argv[])