Skip to content

Instantly share code, notes, and snippets.

View kampersanda's full-sized avatar
🙋
I'm fine, thank you. And you?

Shunsuke Kanda kampersanda

🙋
I'm fine, thank you. And you?
View GitHub Profile
@kampersanda
kampersanda / walker_alias.py
Last active June 2, 2023 07:58
Walker's Alias Method in Python
import collections
import random
class WalkerAlias:
"""
https://qiita.com/kaityo256/items/1656597198cbfeb7328c
"""
def __init__(self, weights: list[float]):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kampersanda
kampersanda / main.rs
Last active October 29, 2021 09:13
simple-sort
fn main() {
let mut v = make_randoms(10000);
simple_sort(&mut v);
if varify(&v) {
println!("Sorted");
} else {
println!("Unsorted");
}
}
@kampersanda
kampersanda / Makefile
Last active July 21, 2021 18:41
後ろ向きにファイル読み込み
read_backward:read_backward.cpp
c++ -O3 -o read_backward read_backward.cpp -std=c++17 -Wall -Wextra -pedantic
clean:
rm -r -f read_backward
@kampersanda
kampersanda / clean_comments.py
Last active May 1, 2021 05:56 — forked from ChunMinChang/remove_c_style_comments.py
Python: Remove C/C++ style comments #parser
#!/usr/bin/env python3
import os
from argparse import ArgumentParser
from remove_c_style_comments import *
from glob import glob
def clean_comment(cpp_files, output_dir):
for cpp_file in cpp_files:
@kampersanda
kampersanda / gitclone.py
Created January 21, 2020 11:34
Git clone script with making directories
#!/usr/bin/env python3
import os
import sys
import subprocess
from argparse import ArgumentParser
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument('path')
@kampersanda
kampersanda / main.go
Last active February 9, 2020 10:31
Extract keywords from AOL-query dataset
package main
import (
"bufio"
"fmt"
"os"
"path/filepath"
"sort"
"strings"
)