Skip to content

Instantly share code, notes, and snippets.

View mayth's full-sized avatar

Mei Akizuru mayth

View GitHub Profile
@mayth
mayth / Dockerfile
Last active December 14, 2023 18:49
Script for installing Adoptium Temurin JDK
ARG base_image=centos:7
FROM $base_image
ARG jdk_version=8
ARG jdk_arch=x64
ARG jdk_platform=linux
ARG sbt_version=1.9.8
# setup java
ADD ./install_jdk.sh .
@mayth
mayth / scan.rb
Created April 23, 2018 17:30
オープンクラス最高! 一番好きなクラスです!
class Array
def scan(init, &op)
res = Array.new(self.length)
m = init
self.each_with_index do |x, i|
acc = op.call(m, x)
res[i] = acc
end
res
end
@mayth
mayth / ap.html
Last active August 29, 2015 14:25
Clustering with JavaScript (k-means and Affinity Propagation) (NOTE: jQuery required!)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Affinity Propagation clustering</title>
<script src="./jquery-2.1.3.min.js"></script>
<script>
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
@mayth
mayth / mission1.fs
Created December 4, 2014 21:22
paiza Online Hackathon 4 Lite : Answers with F#
// https://paiza.jp/poh/enkoi-second/e144f4da
open System
let readLines (reader : IO.TextReader) =
seq {
let eof = ref false
while not !eof do
match reader.ReadLine() with
| null -> eof := true
| str -> yield str
@mayth
mayth / Slice.fs
Created December 4, 2014 19:21
Slice array
let slice n arr =
let len = int (ceil ((float (Array.length arr)) / (float n)))
Array.init len (fun i -> arr.[(i * n)..(i * n + (n - 1))])
// test code
[<EntryPoint>]
let main args =
let arr = [|1; 2; 3; 10; 20; 30; 100; 200; 300|]
let result = slice 3 arr
printfn "%A" result
@mayth
mayth / gochiusa2.css
Created November 10, 2014 11:42
あぁ^〜心がぴょんぴょんするんじゃぁ^〜(あぁ^〜Canvas使わずにぴょんぴょんするんじゃぁ^〜)
#pyonpyon-container {
position: relative;
width: 100px;
height: 120px;
}
#kokoro {
position: absolute;
left: 0;
top: 0;
@mayth
mayth / gochiusa.html
Created November 10, 2014 02:14
あぁ^〜心がぴょんぴょんするんじゃぁ^〜
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>あぁ^〜心がぴょんぴょんするんじゃぁ^〜</title>
<script src="gochiusa.js"></script>
</head>
<body>
<canvas id="gochiusa" width="640" height="480">
あぁ^〜心ぴょんぴょんするには最新のブラウザが必要なんじゃぁ^〜
@mayth
mayth / apcluster.rb
Created August 4, 2014 08:27
Affinity Propagation with Ruby. To run: `ruby apcluster.rb small_toyproblem.txt`.With `small_toyproblem.txt`, the expected content of the exemplars array is '[3, 3, 3, 3, 5]'.
# Provides the implementation of Affinity Propagation
class AffinityPropagation
DEFAULT_DAMPFACT = 0.9
DEFAULT_CONVERGENCE_ITERATION = 10
DEFAULT_MAX_ITERATION = 2000
attr_reader :preference, :min_similarity, :max_similarity, :med_similarity
def initialize(
dampfact = DEFAULT_DAMPFACT,
@mayth
mayth / amida.rb
Created July 20, 2014 08:04
amida solver (SECCON 2014 Online Preliminary)
def read_problem(io)
problem = ''
loop {
ch = io.getc
break if !ch || ch == '?'
problem << ch
}
io.getc
problem
end
@mayth
mayth / amida_problem.txt
Last active August 29, 2015 14:04
problem samples of amida (Programming 300 SECCON 2014 Online Preliminary)
1 2 3 4 5 6 7 8
|-| |-| | | |-|
| | | | | |-| |
| | | | | | |-|
|-| | |-| | | |
| | |-| |-| |-|
|-| | |-| | | |
| |-| | |-| |-|
|-| |-| | | | |
| | | | |-| | |