Skip to content

Instantly share code, notes, and snippets.

View muratamuu's full-sized avatar

muratamuu muratamuu

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@muratamuu
muratamuu / async-timer.md
Last active February 15, 2024 10:21
Rust で非同期タイマー処理

tokio の例

準備

[dependencies]
tokio = { version = "1.23.0", features = ["time", "macros", "rt-multi-thread"] }

または

@muratamuu
muratamuu / keycloak-api.md
Last active December 24, 2022 00:49
Keycloak APIを使ってユーザを作成する方法
@muratamuu
muratamuu / socket-sample.cpp
Last active December 24, 2022 00:53
select()中に別スレッドからsocketをcloseした場合のテスト
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <arpa/inet.h>
#include <errno.h>
#include <thread>
#include <unistd.h>
static void client(int s);
@muratamuu
muratamuu / PrologSameGame.pl
Last active September 22, 2015 14:50
Prologでさめがめを解く
%% SameGame solver by Prolog
%% +-+-+-+ +-+-+-+ +-+-+-+ +-+-+-+
%% |g|b|r| | | |r| | | | | | | | |
%% +-+-+-+ +-+-+-+ +-+-+-+ +-+-+-+
%% |g|g|r| -> | |b|r| -> | |r| | -> | | | |
%% +-+^+-+ +-+-+-+ +-+-+-+ +-+-+-+
%% |r|b|b| |r|b|b| |r|r| | | | | |
%% +-+-+-+ +-+-+^+ +^+-+-+ +-+-+-+
@muratamuu
muratamuu / HaskellTetris.hs
Last active August 29, 2015 14:14
Haskellでテトリス
module Tetris (main) where
import Graphics.UI.Gtk
import Graphics.UI.Gtk.Gdk.GC
import Control.Monad.Trans (liftIO)
import Control.Monad (forM_, when)
import Data.Text (unpack)
import Data.IORef
import System.Random (randomR, getStdRandom)
-- ゲーム状態を表す型
@muratamuu
muratamuu / Tetris.hs
Created December 6, 2014 12:59
Haskellでテトリスのボード画面表示まで
module Tetris (main) where
import Graphics.UI.Gtk
import Graphics.UI.Gtk.Gdk.GC
import Control.Monad.Trans (liftIO)
import Control.Monad (forM_)
-- テトリスのブロックを表す型 (EはEmpty, Gはボード周囲の番兵用)
data Block = I | O | S | Z | J | L | T | E | G deriving (Show, Eq)
-- ボードを表す型
@muratamuu
muratamuu / SnakeGame.ml
Last active August 29, 2015 14:02
Snake Game by OCaml
(* Snake Game by OCaml *)
(* see) http://newral.info/publics/index/79 *)
(* column No.19 - No.23 *)
let cls () = print_string "\x1B[2J";;
let set_pos (x,y) =
print_string ("\x1b[" ^ string_of_int y ^ ";" ^ string_of_int x ^ "H");;
let show_board () =
@muratamuu
muratamuu / eightqueens.clj
Last active August 29, 2015 14:02
8-Queens solver program
;; 8-Queens solver program
;; see) http://newral.info/publics/index/79
;; colum No.14 - No.18
(def board-size 8)
(defn on-board? [[row col]]
(and (>= row 1) (<= row board-size) (>= col 1) (<= col board-size)))
(defn unique-row? [[row _] queens]
@muratamuu
muratamuu / eularProblem3_2.erl
Created May 9, 2014 13:09
Probject Eularの Problem3のプログラム②(Erlang版)
-module(eularProblem3).
-export([answer/0]).
%% Answer of Eular Problem 3 "Largest prime factor"
answer() -> largePrimeFactorOf(600851475143).
largePrimeFactorOf(X) -> largePrimeFactorOf(X, 2).
largePrimeFactorOf(X, P) ->