Skip to content

Instantly share code, notes, and snippets.

@tubo28
tubo28 / main.go
Created December 7, 2020 08:37
HTTP Echo Server
package main
import (
"bytes"
"flag"
"io"
"log"
"net/http"
"net/http/httputil"
"os"
@tubo28
tubo28 / main.rs
Last active March 10, 2018 03:16
A simple reversi AI written in Rust!
//! リバーシのプレイヤープログラム (AI) です.
//! 簡単な評価関数を用いた Alpha-beta 探索アルゴリズムを実装しています.
use std::cmp::max;
use std::io::{stdin, stdout, Write};
use std::collections::BTreeMap;
/// Xor-shift 乱数生成アルゴリズムにより乱数を生成します.
struct Xor128 {
x: u32,
def confirm(message)
loop do
print "#{message} [Y/n] : "
response = gets.chomp
case response
when 'y', 'Y', ''
return true
when 'n', 'N'
return false
end
;;; My fixed version of emacs-crystal-mode on Emacs.
;;; * Removed debug messages by simply replacing all (message "") to ().
;;; * Improved flycheck configuration.
;;; crystal-mode.el --- Major mode for editing Ruby files
;; Copyright (C) 2015 Jason Pellerin
;; Authors: Jason Pellerin
;; URL: https://github.com/jpellerin/emacs-crystal-mode
;; Created: Tue Jun 23 2015
(defun kill-ring-save-whole-if-region-inactive ()
(interactive)
(if (region-active-p)
;; 選択中なら選択範囲をコピー
(kill-ring-save (region-beginning) (region-end))
;; そうでないならバッファ全体をコピー
(kill-ring-save (point-min) (point-max))))
(global-set-key (kbd "M-w") 'kill-ring-save-whole-if-region-inactive)
@tubo28
tubo28 / copy_dir.rs
Created March 2, 2017 13:43
Copying directory recursively (`cp -r $src $dst`) in Rust
fn copy_dir(src: &Path, dst: &Path) -> std::io::Result<()> {
if src.is_dir() {
for entry in try!(fs::read_dir(src)) {
let src = try!(entry).path();
let dst = &dst.join(src.file_name().unwrap());
if src.is_dir() {
fs::create_dir(&dst).unwrap();
try!(copy_dir(&src, &dst));
} else {
fs::copy(&src, &dst).unwrap();
@tubo28
tubo28 / nocapslock.reg
Created January 18, 2017 05:07
Reassign left-ctrl to capslock
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00, 00,00,00,00
@tubo28
tubo28 / internal_ie.cc
Last active December 5, 2016 15:51
Competitive Programming Advent Calendar 2016 https://speakerdeck.com/tubo28/two-types-of-bst
// 内部ノードを持つinsert/eraseベースRBST
#define NDEBUG
#include <algorithm>
#include <cassert>
#include <ctime>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>
#define dump(x) std::cerr << __LINE__ << ":\t" #x " = " << x << std::endl
@tubo28
tubo28 / a.js
Last active August 29, 2015 14:00
AOJの問題文のページを表示した時、その問題を既に解いたことがある場合に問題分の横にマークを表示する。
// ==UserScript==
// @name AOJ solved marker
// @namespace net.tubo028
// @include http://judge.u-aizu.ac.jp/onlinejudge/description.jsp*
// @version 1
// @grant none
// ==/UserScript==
(function(){
var userid = "arsenic28";