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
# encoding: utf-8 | |
# | |
# Groongaの類似文書検索機能を使って類似記事を抽出する。 | |
require 'tmpdir' | |
require 'groonga' | |
module Jekyll | |
class Site | |
alias process_without_groonga process |
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 | |
# encoding: utf-8 | |
require 'mini_magick' | |
require 'origami' | |
include Origami | |
def fixup!(pdf) | |
pdf.root_objects.each do |obj| | |
next unless obj.is_a?(Graphics::ImageXObject) |
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 lib/jekyll/site.rb of jekyll 0.11.0 | |
module Jekyll | |
class Site | |
class PostList < Array | |
def sort | |
self.class.new(super) | |
end | |
def next(obj) | |
setup_index_cache |
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 lib/jekyll/site.rb of jekyll 0.11.0 | |
module Jekyll | |
class Site | |
class PostList < Array | |
def index(obj) | |
unless @hash | |
@hash = {} | |
each_with_index do |post, idx| | |
@hash[post.object_id] = idx | |
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
# modified lib/liquid/variable.rb of liquid 2.2.2 | |
module Liquid | |
class Variable | |
def initialize(markup) | |
@markup = markup | |
@name = nil | |
@filters = [] | |
if match = markup.match(/\s*(#{QuotedFragment})(.*)/o) | |
@name = match[1] | |
if match[2].match(/#{FilterSeparator}\s*(.*)/o) |
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
diff --git a/plugins/rubypants.rb b/plugins/rubypants.rb | |
index e4f4502..1790821 100644 | |
--- a/plugins/rubypants.rb | |
+++ b/plugins/rubypants.rb | |
@@ -401,8 +401,8 @@ class RubyPants < String | |
# Special case if the very first character is a quote followed by | |
# punctuation at a non-word-break. Close the quotes by brute | |
# force: | |
- str.gsub!(/^'(?=#{punct_class}\B)/, '’') | |
- str.gsub!(/^"(?=#{punct_class}\B)/, '”') |
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
# Typoが動作する環境で、rails runnerにより実行する。Type 6.1.0で動作確認した。 | |
# Articleだけ取り出しているが、Pageも似たやり方で取り出せると思う。 | |
# どのように変換するかは運用に合わせて調整すること。 | |
# | |
# メモ: | |
# 記事のタイトルからリンクを取り出して本文に置き直しているのは | |
# もともとtDiaryで運用していたのをTypoに移行したためで、 | |
# うまくないのは分かっていながら放置していたのをここで修正しようとしているため。 | |
# 最初からTypoだった場合や、記事タイトルにリンクを含まない場合は | |
# このような処理は必要ない。 |
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/ruby | |
require 'net/pop' | |
def rc_parse(io) | |
r = [] | |
io.each {|line| | |
line.strip! | |
if /^(?:(.*)@)?(\S+)\s+(.*)$/ =~ line | |
r << if $1 | |
[$1, $2, $3] |
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/ruby1.9.1 | |
# encoding: UTF-8 | |
=begin | |
Copyright (c) 2011, akira yamada | |
All rights reserved. | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions | |
are met: | |
1. Redistributions of source code must retain the above copyright |
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
# メモ: | |
# * libmilter-client-ruby1.8_1.6.7-1を前提に作成。 | |
# * ごく簡単に動作確認をした。 | |
# * 実際には使用していない。 | |
require 'tempfile' | |
require 'milter/client' | |
load '/usr/bin/bsfilter' | |
class Bsfilter | |
attr_accessor :milter |