Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env perl
use strict;
use warnings;
use 5.014;
use File::Basename qw(basename);
package NoteMu2Feed {
use LWP::UserAgent;
use JSON qw(decode_json);
use XML::Feed;
@emasaka
emasaka / pipeline.rb
Created November 1, 2014 13:09
shell-like pipeline in Ruby DSL (ver. 2)
#!/usr/bin/env ruby
require 'open3'
module PipeOperator
refine Array do
def |(x)
PipeLine.new(self) | x
end
end
(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)
;; 第1回 Scheme コードバトン
;;
;; ■ これは何か?
;; Scheme のコードをバトンのように回していき面白い物ができあがるのを楽しむ遊びです。
;; 次回 Shibuya.lisp で成果を発表します。
;; Scheme 初心者のコードを書くきっかけに、中級者には他人のコードを読む機会になればと思います。
;;
;; ■ 2 つのルール
;;
;; (1)自分がこれだと思える変更をコードに加えて2日以内に次の人にまわしてください。
#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文字として数える
/*
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;
@emasaka
emasaka / hato
Created February 14, 2010 01:33
#!/usr/bin/python
# -*- coding: utf-8 -*-
import curses
import locale
import signal
import unicodedata
HATO = (
u"   _,,_",
#!/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;
#!/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
(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)