Skip to content

Instantly share code, notes, and snippets.

Avatar

Toshinori Tsuboi komori-n

View GitHub Profile
@komori-n
komori-n / main.rs
Last active Jul 25, 2021
nananiji-bot
View main.rs
use anyhow::Context as _;
use anyhow::Result;
use chrono::{FixedOffset, TimeZone, Utc};
use lambda_runtime::{error::HandlerError, lambda, Context};
use log::info;
use reqwest::{blocking::Client, header::CONTENT_TYPE};
use serde::{Deserialize, Serialize};
const NANANIJI_GENERATOR_URL: &'static str =
"https://xxxxxxxx.execute-api.ap-northeast-1.amazonaws.com/beta/";
View deserialize_null_and_missing_value.rs
// serde = "1.0"
// serde_derive = "1.0"
// serde_json = "1.0"
use serde::{Deserialize, Deserializer};
use serde_derive::Deserialize;
#[derive(Debug, Deserialize)]
struct Hoge {
#[serde(deserialize_with="deserialize_option")]
val: Option<u64>,
View toggl_report.rs
use std::env;
use serde_derive::Deserialize;
use anyhow::Result;
const EMAIL: &'static str = "ikamat.kmr@gmail.com";
const SUMMARY_URL:&'static str = "https://api.track.toggl.com/reports/api/v2/summary";
#[tokio::main]
async fn main() -> Result<()> {
let toggl_token = env::var("TOGGL_TOKEN")?;
View test.cpp
#include "komori/unique_function.hpp"
#include "gtest/gtest.h"
namespace {
constexpr const int kMagicNumber1 = 0x334;
constexpr const int kMagicNumber2 = 0x668;
int func1(void) {
return kMagicNumber1;
View cocoro-pyonpyon2.c
#define A (1)
#define B ((uint8_t)2)
#define STRIP_PRN(x) IDENTITY x
#define IDENTITY(x) x
#define DELETE_BLOCK(x) DELETE_ARG x
#define DELETE_ARG(x)
STRIP_PRN(A)
DELETE_BLOCK(STRIP_PRN(B))
View cocoro-pyonpyon.c
#define A 0
#define B 1
#define CFG_1_MODE A
#define CFG_2_MODE B
#define CFG_3_MODE A
#define EXPAND(i) IMPL_TMP(CFG_##i##_MODE)(i)
#define IMPL_TMP(mode) IMPL_CAT(mode)
#define IMPL_CAT(mode) IMPL_##mode
View event-endian-test.c
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
uint8_t event1(int32_t* param) {
uint8_t data = (uint8_t)*param;
printf("%"PRId8"\n", data);
}
View deepcopy-time.py
from copy import copy, deepcopy
import pickle
import timeit
pickle_copy = lambda l: pickle.loads(pickle.dumps(l, -1))
case = 5
if case == 1:
## case 1: integer list
@komori-n
komori-n / molek-solitaire-solver.py
Created Jun 22, 2020
A MOLEK-SYNTEZ solitaire solver written in python
View molek-solitaire-solver.py
from copy import deepcopy
from random import shuffle
from queue import PriorityQueue
import time
import _pickle as cPickle
class Card():
TEXT2NUM = {
"6": 6, "7": 7, "8": 8, "9": 9, "0": 10,
View shogi_cpsat.py
import itertools
from ortools.sat.python import cp_model
BOARD_SIZE = 9
WIDTH = HEIGHT = BOARD_SIZE
PIECETYPES = ['p', 'n', 's', 'g', 'k', 'l', 'r', 'b', 'q', '_']
# 0:up, 1:down, 2:left, 3:right, 4:upleft, 5:upright, 6:downleft, 7:downright,
# 8:knightleft, 9:knightright
DI = [-1, 1, 0, 0, -1, -1, 1, 1, -2, -2]
DJ = [0, 0, -1, 1, -1, 1, -1, 1, -1, 1]