Skip to content

Instantly share code, notes, and snippets.

Avatar

Toshihiro Kamiya tos-kamiya

View GitHub Profile
View gist:10baa672da6c8bce692b6b3c5dbf4b47
// vscodeのlatex-workshopでcluttexを使うための設定
"latex-workshop.latex.recipes": [
{
"name": "cluttex",
"tools": [
"cluttex"
]
},
],
@tos-kamiya
tos-kamiya / jtalk.py
Last active Feb 1, 2021
jtalkを用いた読み上げコマンド
View jtalk.py
#!/usr/bin/env python3
# 参考
# https://qiita.com/kkoba84/items/b828229c374a249965a9
# https://mekou.com/linux-magazine/open-jtalklinux-%E6%97%A5%E6%9C%AC%E8%AA%9E%E9%9F%B3%E5%A3%B0%E5%90%88%E6%88%90%E3%82%A8%E3%83%B3%E3%82%B8%E3%83%B3/
# 準備
# # (1) Open JTalkのセットアップ
# $ sudo apt-get install open-jtalk open-jtalk-mecab-naist-jdic hts-voice-nitech-jp-atr503-m001
# # (2) 音声ファイルのセットアップ
View gist:1804b90ea604046e40337598a5b768d8
[alias]
unstage = reset HEAD
shortlogt = log --reverse --date=short --pretty=format:'[%ad] %h %an : %s %d'
[pull]
ff = only
[user]
email = kamiya@mbj.nifty.com
name = Toshihiro Kamiya
@tos-kamiya
tos-kamiya / format_a0.rs
Last active Mar 15, 2020
Heavily restricted format macro for const str
View format_a0.rs
macro_rules! format_a0 {
{ a0 = $s:expr ; $x:expr }
=>
{ $x };
{ a0 = $s:expr ; $x:expr , a0 }
=>
{ concat!( $x, $s ) };
@tos-kamiya
tos-kamiya / crossbeam_scope_test.rs
Last active Feb 25, 2020
crossbeam scopre test
View crossbeam_scope_test.rs
// https://docs.rs/crossbeam/0.7.3/crossbeam/thread/index.html#structs
// need to add the following dependency to Cargo.toml
//
// [dependencies]
// crossbeam = "0.7"
use crossbeam::thread;
fn main() {
@tos-kamiya
tos-kamiya / cursortest.rs
Last active Feb 25, 2020
Rust's Cursor, Python's StringIO like object
View cursortest.rs
use std::io;
use std::io::{ Write, Seek, BufRead };
fn main() {
let mut buf = io::Cursor::new(Vec::<u8>::new());
writeln!(buf, "{}", "abc").unwrap();
writeln!(buf, "{}", "def").unwrap();
buf.seek(io::SeekFrom::Start(0)).unwrap();
@tos-kamiya
tos-kamiya / memu
Created Nov 6, 2019
Watch real-time system memory usage.
View memu
#!/usr/bin/env python3
import sys
import os
from datetime import datetime
import signal
import time
import docopt
import psutil
@tos-kamiya
tos-kamiya / 0-Cleanly shutdown mprpc server by remote access.md
Last active Nov 4, 2019
Cleanly shutdown mprpc server by remote access
View 0-Cleanly shutdown mprpc server by remote access.md

This example server is able to shutdown by requesting from remote, by calling 'shutdown' method.

$ python3 ./mprpc_server_able_to_shutdown_from_remote.py &
> Hello server is waiting on localhost:7000 ...

$ python3 ./sample_clinet.py
hello
hello
hello
@tos-kamiya
tos-kamiya / 0_comparison_mprpc_vs_xmlrpc.md
Last active Nov 3, 2019
A micro benchmark of two RPC servers, mprpc and xmlrpc
View 0_comparison_mprpc_vs_xmlrpc.md
@tos-kamiya
tos-kamiya / altxmlrpcserver.py
Created Nov 3, 2019
Alternative XMLRPCServer which can shutdown cleanly
View altxmlrpcserver.py
# reference: http://code.activestate.com/recipes/114579-remotely-exit-a-xmlrpc-server-cleanly/
import xmlrpc.server
import socket
import signal
class AltXMLRPCServer(xmlrpc.server.SimpleXMLRPCServer):
def __init__(self, addr):
super().__init__(addr, allow_none=True)