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
# -*- coding: utf-8 -*- | |
require 'uri' | |
require 'open-uri' | |
require 'nokogiri' | |
module Termtter | |
class AsinSearch | |
URLBASE = "https://www.amazon.co.jp/s/ref=nb_sb_noss?__mk_ja_JP=#{URI.escape('カタカナ')}&url=search-alias%3Dstripbooks&field-keywords=" |
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
(defun trie-add (trie key-str val) | |
(if (= (length key-str) 0) | |
trie | |
(let ((lst (split-string key-str "" t))) | |
(rplacd (last lst) val) | |
(trie-add::merge trie lst) ))) | |
(defun trie-add::merge (trie lst) | |
(cond ((null lst) trie) | |
((null trie) lst) |
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
;; 第1回 Scheme コードバトン | |
;; | |
;; ■ これは何か? | |
;; Scheme のコードをバトンのように回していき面白い物ができあがるのを楽しむ遊びです。 | |
;; 次回 Shibuya.lisp で成果を発表します。 | |
;; Scheme 初心者のコードを書くきっかけに、中級者には他人のコードを読む機会になればと思います。 | |
;; | |
;; ■ 2 つのルール | |
;; | |
;; (1)自分がこれだと思える変更をコードに加えて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
#cc_zen1 = 0x00000000; // 全角文字を1文字として数える | |
#cc_zen2 = 0x00000001; // 全角文字を2文字として数える | |
#cc_han1 = 0x00000000; // 半角文字を1文字として数える | |
#cc_zensp1 = 0x00000000; // 全角空白を1文字として数える | |
#cc_zensp2 = 0x00000100; // 全角空白を2文字として数える | |
#cc_zensp0 = 0x00000200; // 全角空白を数えない | |
#cc_hansp1 = 0x00000000; // 半角空白を1文字として数える |
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
/* | |
Based on: | |
http://lastoneofthezodiac.blog38.fc2.com/blog-entry-5613.html | |
Needs sha_256.js <http://point-at-infinity.org/jssha256/> like following: | |
<script type="text/javascript" src="./jssha256.js"></script> | |
*/ | |
function pad0(n, len, radix) { | |
radix = radix || 10; |
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/python | |
# -*- coding: utf-8 -*- | |
import curses | |
import locale | |
import signal | |
import unicodedata | |
HATO = ( | |
u" _,,_", |
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 perl | |
use strict; | |
use warnings; | |
use utf8; | |
use feature qw( say ); | |
use Encode; | |
use List::Util; | |
use List::MoreUtils qw( uniq firstidx ); | |
use WWW::Mechanize; | |
use HTML::TreeBuilder::XPath; |
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 ruby | |
# works on Ruby 1.9.2 (maybe on Ruby 1.9.1, too) | |
class Loc | |
def initialize(x, y) | |
@x = x | |
@y = y | |
end | |
attr_reader :x, :y |
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 (traverse-tree tree func) | |
(if (pair? tree) | |
(begin | |
(traverse-tree (car tree) func) | |
(traverse-tree (cdr tree) func) ) | |
(or (null? tree) (func tree)) )) | |
(define sample-list '((3 (5 (7)) 11))) | |
(traverse-tree sample-list print) |
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 (traverse-tree tree func) | |
(define (spin cns prev) | |
(let ((next (car cns))) | |
(set-car! cns (cdr cns)) | |
(set-cdr! cns prev) | |
next )) | |
(let ((marker (gensym))) | |
(let loop ((cns tree) (prev marker)) | |
(let ((next (spin cns prev))) | |
(cond ((pair? next) |
OlderNewer