Skip to content

Instantly share code, notes, and snippets.

@dev-jonghoonpark
dev-jonghoonpark / Dijkstra.py
Last active September 5, 2023 05:06
python dijkstra
class Dijkstra:
# 초기화
# S는 방문한 노드가 아직 없으므로 공집합 상태이다.
# D는 아직 확인되지 않은 거리는 전부 초기값을 무한으로 잡는다.
# Q는 방문하지 않은 노드들의 집합이므로, 초기화할 때는 모든 노드들의 집합이 된다.
S = set()
d = {}
Q = set()
@classmethod
public class AccountManager {
private ConcurrentHashMap<Integer, Account> accounts = new ConcurrentHashMap<>();
private volatile boolean shutdown = false;
private BlockingQueue<TransferTask> pending = new LinkedBlockingQueue<>();
private BlockingQueue<TransferTask> forDeposit = new LinkedBlockingQueue<>();
private BlockingQueue<TransferTask> failed = new LinkedBlockingQueue<>();
private Thread withdrawals;
private Thread deposits;
@dev-jonghoonpark
dev-jonghoonpark / a
Created August 8, 2023 12:30
files in gist
a
@dev-jonghoonpark
dev-jonghoonpark / Account Class With Atomic Integer
Last active August 6, 2023 17:10
6장 JDK 동시성(concurrency) 라이브러리
private static AtomicInteger nextAccountId = new AtomicInteger();
private final int accountId;
private double balance;
public Account(int openingBalance) {
balance = openingBalance;
accountId = nextAccountId.getAndIncrement();
}
@dev-jonghoonpark
dev-jonghoonpark / index.py
Created August 1, 2023 17:14
서버에서 google sheet api 사용하기 (with python)
from __future__ import print_function
from google.oauth2 import service_account
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
# If modifying these scopes, delete the file token.json.
SCOPES = ['https://www.googleapis.com/auth/spreadsheets.readonly']
@dev-jonghoonpark
dev-jonghoonpark / index.py
Last active July 23, 2023 16:40
dcinside crawling with playwright python
import re
import time
import json
import pathlib
import nest_asyncio
nest_asyncio.apply()
import asyncio
from playwright.async_api import async_playwright, expect
@dev-jonghoonpark
dev-jonghoonpark / 1. CRM 시스템의 초기 구현
Last active August 8, 2023 03:36
단위 테스트 - 7장 가치 있는 단위 테스트를 위한 리팩터링
public class User
{
public int UserId { get; private set;}
public string Email { get; private set; }
public UserType Type { get; private set; }
public void ChangeEmail(int userId, string newEmail)
{
object[] data = Database.GetUserById(userId);
UserId = userId,
@dev-jonghoonpark
dev-jonghoonpark / 1. AuditManager
Last active July 14, 2023 16:25
단위 테스트 - 6장 단위 테스트 스타일
public class AuditManager
{
private readonly int _maxEntriesPerFile;
private readonly string _directoryName;
public AuditManager(int maxEntriesPerFile, string directoryName)
{
_maxEntriesPerFile = maxEntriesPerFile;
_directoryName = directoryName;
}
@dev-jonghoonpark
dev-jonghoonpark / README.MD
Created April 9, 2023 23:58
크롬북에서 카카오톡 사용하기 (use kakaotalk in chromebook)

크롬북에서 카카오톡 사용하기 (use kakaotalk in chromebook)

출처는 https://blog.naver.com/adutm/222575088447 입니다. 예전부터 크롬북에서 카카오톡을 사용하는 법이 없을까 고민을 많이 했었는데 블로그 주인 분께서 잘 정리해주셔서 잘 적용 하였고 데이터가 사라질까 싶은 마음에 다시 재정리 해두는 자료입니다.

1. 개발자 모드 활성화 하기

(이건 검색해보면 많이 나와서 스킵)

https://blog.naver.com/adutm/222571735389
모르겠다면 출처 작성자님의 글 참고

@dev-jonghoonpark
dev-jonghoonpark / dci.js
Created February 7, 2023 09:14
use dci (describe, context, it) pattern in playwright (playwright 에서 dci 패턴 사용하기)
import { test, expect } from '@playwright/test';
function describe(title, callback) {
return test.describe(title, callback)
}
function context(title, callback) {
return test.describe(title, callback)
}