Skip to content

Instantly share code, notes, and snippets.

@knuu
knuu / docker-compose.yml
Created September 29, 2024 23:56
opensearch for local
version: '3'
services:
opensearch:
image: opensearchproject/opensearch:latest
container_name: opensearch
environment:
- discovery.type=single-node
- node.name=opensearch
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
@knuu
knuu / diagram_aws.js
Last active September 8, 2024 08:44
architecture by mermaid.js
const mermaidDefinition = `
architecture-beta
group api(logos:aws-vpc)[VPC]
service server(logos:aws-api-gateway)[Server] in api
service search(logos:aws-open-search)[OpenSearch] in api
service lambda(logos:aws-lambda)[Lambda] in api
service disk(logos:aws-s3)[Storage] in api
@knuu
knuu / main.rs
Last active October 1, 2023 12:30
rust 本 5 章
use std::{collections::HashMap, vec};
type Table = HashMap<String, Vec<String>>;
fn show(table: &Table) {
for (artist, works) in table {
println!("works by {}:", artist);
for work in works {
println!(" {}", work);
}
}
@knuu
knuu / exec.py
Last active July 10, 2023 03:28
Code Interpreter に含まれる module
# 実行されたコード
import pkgutil
# List all available modules
available_modules = [module.name for module in pkgutil.iter_modules()]
available_modules
@knuu
knuu / lightgbm-learning-to-rank.ipynb
Last active January 17, 2025 08:20
LightGBM でかんたん Learning to Rank
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@knuu
knuu / MakingRegularGraph.cpp
Created June 2, 2018 18:56
TCO Round2 Med MakingRegularGraph
struct MakingRegularGraph {
int n;
vector<int> x, y, deg;
set<int> rest;
set<pair<int, int>> edge;
void dfs(vector<int> &ans) {
if (rest.size() == 0) {
return ;
} else if (rest.size() == 1) {
@knuu
knuu / heap.c
Created May 16, 2018 14:18
Heap by C
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "heap.h"
Heap *initHeap(int maxSize) {
Heap *h = malloc(sizeof(Heap));
if (h == NULL) {
return NULL;
@knuu
knuu / exe_2_6.c
Created April 15, 2018 16:04
k&r exercise
#include <stdio.h>
#include <limits.h>
unsigned int getbits(unsigned int x, int p, int n);
unsigned int setbits(unsigned int x, int p, int n, unsigned int y);
void print_bits(unsigned int x);
int main() {
print_bits(setbits((1 << 5) - 1, 3, 3, 10)); // x = 11111, y = 1010 => 10101
@knuu
knuu / mex_query.cpp
Created February 24, 2018 10:52
range mex query problem
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())
const int INF = INT_MAX;
@knuu
knuu / ctf_h.cpp
Created December 10, 2017 12:16
CODE THANKS FESTIVAL 2017 H. Union Sets
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
struct DisjointSet {
vector<int> parent, rank;
DisjointSet(int N) {