This file contains 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
Wikiに書こうとしたけど、オフトピな気がしたので。 | |
課題出すやつは、ターミナルからコマンドを叩いて課題を提出するためのRubyスクリプトです。ブラウザでファイル選ぶのめんどいとか、ターミナルから出るのがめんどいとかあればどうぞ。 | |
動かすにはRubyが動いて、ThorとMechanizeというライブラリが入った環境が必要です。rubygemsが使える環境で、 | |
#highlight(sh){ | |
gem install thor mechanize | |
} | |
をターミナルで実行すればいけると思います。Ruby1.9系、Ruby1.8系で多分動きますが、動かなかったらどこかにコメントください。サーバーに迷惑かもしれないので、あんまり極端な回数実行しないでください。同様に、サーバーの仕様が変わって使えなくなった気がするときは、あんまり繰り返し実行しないでください。 |
This file contains 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
import Data.Maybe (fromMaybe) | |
data TwoThreeSet a = Empty | One a | Tree (TwoThreeTree a) | |
emptyMap :: TwoThreeSet a | |
emptyMap = Empty | |
search :: Ord a => TwoThreeSet a -> a -> Bool | |
search Empty _ = False | |
search (One x) y | x == y = True |
This file contains 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
(define (position-of-highest-bit-32 n) | |
(let ((m n) (v 0)) | |
(set! m (ash n -16)) | |
(if (not (= m 0)) | |
(begin (set! v (+ v 16)) | |
(set! n m))) | |
(set! m (ash n -8)) | |
(if (not (= m 0)) | |
(begin (set! v (+ v 8)) | |
(set! n m))) |
This file contains 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 python2.7 | |
import xml.etree.ElementTree as ET | |
from datetime import datetime, tzinfo, timedelta | |
import time | |
import cookielib | |
import urllib | |
import urllib2 | |
import sys | |
import os.path |
This file contains 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 'serialport' | |
sio = SerialPort.new("/dev/ttyUSB0", 9600, 8, 1, 0) | |
INSTS = { | |
fadd: { | |
op: 0x42, | |
in: [4, 4], | |
out: [4] | |
} |
This file contains 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
(define (fib-pathological n) | |
(define (go m prev tag acc) | |
(cond | |
((= m (+ n 1)) | |
acc) | |
((< m 2) | |
(if (even? tag) | |
(go (+ m 1) m (quotient tag 2) (+ acc 1)) | |
(go (+ m 2) m (quotient tag 2) (+ acc 1)))) | |
((= prev (- m 2)) |
This file contains 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
w, h = 200.0, 200.0 | |
vertexes = [[130.0,80.0], [50.0,50.0], [60.0,140.0]] | |
def ext(a,b) 11*a-10*b end | |
lines = vertexes.combination(2).map do |(x1,y1),(x2,y2)| | |
[[ext(x1,x2),ext(y1,y2)],[ext(x2,x1),ext(y2,y1)]] | |
end | |
ratios = [[1,0,0].permutation, [1,1,0].permutation, [4,-1,0].permutation, [3,3,-2].permutation, [5,-1,-1].permutation, [[1,1,1]]].map(&:to_a).flatten(1).uniq |
This file contains 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
--- suda-bug.c 2014-07-15 03:32:15.950329411 +0900 | |
+++ suda.c 2014-07-15 03:32:22.298329432 +0900 | |
@@ -80,15 +80,19 @@ | |
case 0: | |
amask_reg = _mm256_set_pd(one, one, one, one); | |
rmask_reg = _mm256_set_pd(0, one, one, one); | |
+ break; | |
case 1: | |
amask_reg = _mm256_set_pd(0, 0, 0, one); | |
rmask_reg = _mm256_set_pd(one, one, one, 0); |
This file contains 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
let rec f : 'c. unit -> ((unit -> 'a -> 'b) -> 'c) -> 'c = fun () k -> k g | |
and g () k = f () (fun l -> l () k);; | |
f () (fun x -> x) |
This file contains 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
|||||||||||||||||||||||||||||||||||||| | |
||||||||-→ |
OlderNewer