This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def apply(x, k) | |
ret = [] | |
x.each.with_index{|a, i| ret[i] = k[a-1] } | |
ret | |
end | |
def dim(x) | |
t, i = x, 1 | |
loop do | |
t = apply(t,x) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
helpers do | |
def img(path, l = nil, width=100, height=100) | |
html = "<img src=\"/#{path}\" width=#{width} height=#{height}>" | |
html = "<a href=\"#{l}\">#{html}</a>" if l | |
html | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# rest_tester | |
# Created by 2017, kyontan <[email protected]> | |
# Licenced by CC0 (https://creativecommons.org/publicdomain/zero/1.0/deed.ja) except for module TTy | |
require "optparse" | |
require "shellwords" | |
require "json" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef USBCON | |
#define USBCON | |
#endif | |
#include <Joystick.h> | |
#include <Keyboard.h> | |
#define PIN_LED 17 | |
#define PIN_A 3 | |
#define PIN_B 7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# how to use: | |
# 1. domains ファイルをこのスクリプトを同じディレクトリに配置し、リモートフォローしたいインスタンスのドメインを記載してください | |
# (place `domains` file located same directory as the script file, and write the domain name of instance which you want to remote follow.) | |
# 2. run this script | |
# 3. 発見されたアカウントがあなたのインスタンスに登録されます, ただ、リモートアカウントとして登録されるだけで、実際にフォローなどは行われません | |
# (new accounts might have registered to your insntance, but not yet `followed` by your account (only registered to instance as a remote account)) | |
# 4. なんらかのお好きな方法でフォローしてください | |
# (please follow them by your account yourself, your ways) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun can-place (x y queens) | |
(cond | |
((member t (mapcar #'(lambda (xy) (or (= x (car xy)) (= y (cadr xy)))) queens)) nil) | |
((member t (mapcar #'(lambda (xy) (= 1 (abs (/ (- x (car xy)) (- y (cadr xy)))))) queens)) nil) | |
(t))) | |
; try putting a queen to (x y); | |
; if possible, put it and try putting recursively | |
; otherwise, trying putting a queen in order: (1 1) ~ (max max) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hosts: | |
"example.com": | |
listen: | |
port: 443 | |
ssl: | |
key-file: /etc/h2o/key.pem | |
certificate-file: /etc/h2o/cert.pem | |
http2-casper: ON | |
reproxy: ON | |
paths: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri' | |
require 'json' | |
require 'net/http' | |
module RestClient | |
class << self | |
def get(path) | |
execute :get, path | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
class TM | |
BLANK = :blank | |
MOVE_LEFT = :left | |
MOVE_RIGHT = :right | |
HALT = :halt | |
attr_reader :pos, :state |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.defineProperty(Array.prototype, 'yield_self', { | |
enumerable: false, | |
value: function(f) { return f(this); } | |
}); | |
// > array | |
// [ 1, 2, 3 ] | |
// > array.yield_self(x => x.concat(x)) | |
// [ 1, 2, 3, 1, 2, 3 ] |