This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::collections::hash_map::DefaultHasher; | |
| use std::collections::HashSet; | |
| use std::hash::{Hash, Hasher}; | |
| /// ブルームフィルタ --- (※1) | |
| struct BloomFilter { | |
| bits: Vec<u64>, // ビット配列 | |
| num_bits: usize, // ビット数 m | |
| num_hashes: usize, // ハッシュの個数 k | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # メイン処理 --- (※1) | |
| main! = |_| { | |
| # 1から100までの各数値にfizz_buzzを適用 --- (※2) | |
| output = | |
| (1..=100) | |
| .iter() # イテレータに変換 | |
| .map(fizz_buzz) # 各数値をfizz_buzzに与えて変換 | |
| |> List.from_iter # リストに変換 | |
| |> Str.join_with("\n") # 改行で連結 | |
| echo!("${output}\n") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import thumby | |
| # 変数を初期化 | |
| counter = 0 | |
| is_down_a = False | |
| is_down_b = False | |
| # フォントの設定 | |
| thumby.display.setFont("/lib/font8x8.bin", 8, 8, 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::collections::BTreeMap; | |
| use std::collections::HashMap; | |
| /// 候補の最大件数 --- (※1) | |
| const MAX_RESULTS: usize = 50; | |
| /// トライ木のノード --- (※2) | |
| #[derive(Default)] | |
| struct Node { | |
| /// 次の1文字 → 子ノード |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import thumby | |
| import random | |
| import time | |
| # 描画フォントの設定 | |
| FW, FH = 5, 7 | |
| thumby.display.setFont("/lib/font5x7.bin", FW, FH, 1) | |
| # FPSを指定 | |
| thumby.display.setFPS(8) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import thumby | |
| import random | |
| # 定数の定義 | |
| DISP_W = thumby.display.width # 72 | |
| DISP_H = thumby.display.height # 40 | |
| # セルのサイズと個数を定義 | |
| CW, CH = 3, 3 | |
| COLS,ROWS = DISP_W // CW, DISP_H // CH |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """ CLIでタスクを管理するプログラム """ | |
| from datetime import datetime, timedelta | |
| import re | |
| import typer | |
| from rich.console import Console | |
| from rich.table import Table | |
| from storage import load_tasks, save_tasks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Excelファイル(xlsx/xls/ods等)をシートごとにCSVへ変換するCLIツール | |
| use calamine::{open_workbook_auto, Data, Range, Reader}; | |
| use std::env; | |
| use std::fs::File; | |
| use std::io::{BufWriter, Write}; | |
| use std::path::Path; | |
| // メイン処理 --- (*1) | |
| fn main() { | |
| // コマンドライン引数を取得する --- (*2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import os | |
| import subprocess | |
| import sys | |
| from urllib.parse import parse_qsl, urlencode, urlsplit, urlunsplit | |
| import requests | |
| from dotenv import load_dotenv | |
| load_dotenv() # .envファイルを読み込む |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import os | |
| import subprocess | |
| import sys | |
| import requests | |
| from dotenv import load_dotenv | |
| load_dotenv() # .envファイルを読み込む | |
| PHOTO_PATH = "photo.jpg" |
NewerOlder