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 'net/http' | |
require 'cgi/util' | |
require 'json' | |
require 'open-uri' | |
require 'regexp_trie' | |
URL_SHORTTERS_RE = open('http://nagaino.herokuapp.com/hosts.json') do |io| | |
/(?:#{RegexpTrie.union(JSON.load(io)).source})[\w]+/ |
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
--- cowsay.orig 2015-12-01 18:05:41.636619759 +0900 | |
+++ cowsay 2015-12-01 18:11:36.999132910 +0900 | |
@@ -11,6 +11,7 @@ use Text::Wrap qw(wrap fill $columns); | |
use File::Basename; | |
use Getopt::Std; | |
use Cwd; | |
+use Text::CharWidth qw(mbswidth); | |
if (${^UTF8LOCALE}) { | |
binmode STDIN, ':utf8'; |
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 | |
require 'open3' | |
module PipeOperator | |
refine Array do | |
def |(x) | |
PipeLine.new(self) | x | |
end | |
end |
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 | |
module PipeOperator | |
refine Array do | |
def |(x) | |
PipeLine.new(self) | x | |
end | |
end | |
end |
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 5.014; | |
use File::Basename qw(basename); | |
package NoteMu2Feed { | |
use LWP::UserAgent; | |
use JSON qw(decode_json); | |
use XML::Feed; |
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
これはbash-4.2のリリース以降bash-4.3に追加された新機能の簡潔な説明です。 | |
いつもどおり、完全な説明を探している場合はマニュアルページ (doc/bash.1) | |
が適切です。 | |
1. Bashの新機能 | |
a. 補完の動作の`helptopic'は、シェル組み込みコマンドだけでなくすべての | |
ヘルプのトピックに対応します。 | |
b. 組み込みコマンド`help'で、最初に前方一致が行われることはなくなりま |
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 dsl | |
(use-modules (srfi srfi-1)) | |
(define targets '()) | |
(define (showtargets) | |
(string-join (reverse targets) "\n") ) | |
(define-macro (push! place item) | |
`(set! ,place (cons ,item ,place)) ) |
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
(defn encoded-num-seq [n digits] | |
(let [base (.length digits) | |
enc1 (fn [n r] | |
(let [q (quot n base) r2 (str (.charAt digits (rem n base)) r)] | |
(if (zero? q) r2 (recur q r2)) ))] | |
(map #(enc1 % "") (iterate inc n)) )) | |
(defmacro nth [c i & nf] | |
(if (and (list? c) (= (first c) 'encoded-num-seq)) | |
(let [(f a1 a2) c] `(first (~f (+ ~i ~a1) ~a2))) |
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
#!/bin/bash | |
R=36 | |
RATIO=2 | |
for ((y = -R; y <= R; y += RATIO)); do | |
x=$(dc -e "$R 2^${y/-/_} 2^-vp") | |
printf '%*s%*s%*s\n' $((R - x)) x $x '' $x x | |
done |
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
;; LTSV (Labeled Tab-separated Values) parser by Clojure | |
(use '[clojure.string :only [split]]) | |
(defn ltsv-parse-line | |
"Parses one LTSV line. Returns a map." | |
[^String line] | |
(reduce (fn [r s] (let [[k v] (split s #":" 2)] (assoc r k v))) | |
{} (split line #"\t") )) |