Skip to content

Instantly share code, notes, and snippets.

@cjnghn
cjnghn / binaryTree.cpp
Last active December 11, 2023 07:44
Tree
#include <iostream>
template <typename Object>
class LinkedBinaryTree {
protected:
struct Node {
Object element;
Node* parent;
Node* left;
Node* right;
@cjnghn
cjnghn / crawl.py
Created October 26, 2023 05:38
crawling examples: aiohttp + paginatoin + detail view
import asyncio
import pandas as pd
from aiohttp import ClientSession
from bs4 import BeautifulSoup
from typing import List, Dict, Optional, Any
ALGOLIA_URL = 'https://w1bghm6ujn-dsn.algolia.net/1/indexes/*/queries'
HEADERS = {
'x-algolia-agent': 'Algolia for JavaScript (3.35.1); Browser; instantsearch.js (3.7.0); Vue (2.6.11); Vue InstantSearch (2.6.0); JS Helper (2.28.0)',
@cjnghn
cjnghn / customerror.h
Created October 12, 2023 00:41
stack implementation
#ifndef CUSTOMERROR_H_
#define CUSTOMERROR_H_
#include <string>
#include <iostream>
class RuntimeException {
public:
RuntimeException(const std::string& err) : error_message_(err) {}
@cjnghn
cjnghn / sol.cpp
Last active September 19, 2023 05:20
코드트리 - 카드 사이클 만들기
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> arr(n);
vector<int> graph(n, 0);
@cjnghn
cjnghn / solve.cpp
Created September 18, 2023 03:47
2주차 학습
#include <iostream>
using namespace std;
int board[105][105];
int dp[105][105];
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
@cjnghn
cjnghn / 정수 사각형 최대 합.cpp
Last active September 10, 2023 04:46
정수 사각형 최대 합.cpp
#include <iostream>
using namespace std;
int board[105][105], dp[105][105];
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
int n;
@cjnghn
cjnghn / session.js
Created September 5, 2023 04:06
메모리 누수가 없는 모든 기능을 갖춘 메모리 저장소 모듈인 MemoryStore의 대안인 memorystore를 사용하는 예제
const session = require('express-session');
const MemoryStore = require('memorystore')(session);
app.use(session({
cookie: {
maxAge: 86400000 // 쿠키 만료 시간 설정
},
store: new MemoryStore({
checkPeriod: 86400000 // 24시간마다 만료된 항목 정리
}),
@cjnghn
cjnghn / compare.py
Last active September 3, 2023 06:21
base64 vs byte
import os
import base64
def compare_file_and_base64_size(file_path):
try:
with open(file_path, "rb") as file:
original_bytes = file.read()
# Encode the bytes to Base64
base64_encoded = base64.b64encode(original_bytes)
@cjnghn
cjnghn / stack.js
Created July 3, 2023 13:36
stack.js
class Node {
constructor(item, next) {
this.item = item;
this.next = next;
}
}
class Stack {
constructor() {
this.top = null;
@cjnghn
cjnghn / trie.cpp
Created June 28, 2023 11:54
trie.cpp
class TrieNode {
public:
bool is_word;
TrieNode* children[26];
TrieNode() {
is_word = false;
for (auto& child : children)
child = nullptr;
}