Skip to content

Instantly share code, notes, and snippets.

View akr4's full-sized avatar

UEDA Akira akr4

  • Tokyo, Japan
View GitHub Profile

Keybase proof

I hereby claim:

  • I am akr4 on github.
  • I am akr4 (https://keybase.io/akr4) on keybase.
  • I have a public key ASDy2rbkgMGELpnY2TMrZiXjH5F5N1ezWt1HMB2K-0f-igo

To claim this, I am signing this object:

@akr4
akr4 / list_node.rs
Last active September 15, 2019 02:52
list! macro for ListNode on leetcode
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>,
}
impl ListNode {
#[inline]
fn new(val: i32) -> Self {
ListNode { next: None, val }
@akr4
akr4 / tree.rs
Last active September 22, 2019 23:10
tree! macro which generates tree on leetcode
use std::cell::RefCell;
#[cfg(test)]
use std::collections::LinkedList;
use std::rc::Rc;
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
@akr4
akr4 / gist:f8ccd4e7a475e99d30772ffb9ee1a078
Last active August 19, 2022 05:15
SQLite 複数接続使用時の挙動テスト
use sqlx::sqlite::SqlitePoolOptions;
use anyhow::Result;
use sqlx::{Row, SqlitePool};
fn main() {}
#[tokio::test]
async fn test() -> Result<()> {
const LOOP_COUNT: usize = 10;
let db_dir = tempfile::tempdir()?;
@akr4
akr4 / multiple_writes.rs
Last active September 14, 2022 08:24
SQLite "database is locked" reproducer
//! A reproducer of the 'database is locked' error.
//! https://www2.sqlite.org/cvstrac/wiki?p=DatabaseIsLocked
//!
//! The error happens like this:
//! ```
//! thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Database(SqliteError { code: 5, message: "database is locked" })', src/bin/multiple.rs:35:22
//! ```
//! The code is "5", while the wiki page says it is 6.
//!
//! ```toml