Skip to content

Instantly share code, notes, and snippets.

View arika's full-sized avatar
🍡 ☕️ 🍰 ☕️ ☕️ ☕️ ☕️

akira yamada arika

🍡 ☕️ 🍰 ☕️ ☕️ ☕️ ☕️
View GitHub Profile
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)/, '&#8217;')
- str.gsub!(/^"(?=#{punct_class}\B)/, '&#8221;')
# 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)
@arika
arika / typo_to_jekyll.rb
Created March 28, 2012 13:40
typoからoctopress/jekyllに記事を変換する
# Typoが動作する環境で、rails runnerにより実行する。Type 6.1.0で動作確認した。
# Articleだけ取り出しているが、Pageも似たやり方で取り出せると思う。
# どのように変換するかは運用に合わせて調整すること。
#
# メモ:
# 記事のタイトルからリンクを取り出して本文に置き直しているのは
# もともとtDiaryで運用していたのをTypoに移行したためで、
# うまくないのは分かっていながら放置していたのをここで修正しようとしているため。
# 最初からTypoだった場合や、記事タイトルにリンクを含まない場合は
# このような処理は必要ない。
@arika
arika / popls.rb
Created March 27, 2012 10:59
UNIX USER 2002年2月号のRuby特集の第3章「実践プログラミング〜メール編」で示したサンプルコード
#!/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]
@arika
arika / unzip.rb
Created June 8, 2011 00:14
expand zip-files (with pathname encoding conversion) <http://arika.org/2011/06/07/unzip-rb>
#!/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
@arika
arika / milter-bsfilter.rb
Created April 19, 2011 13:19
milter-bsfilter.rb
# メモ:
# * libmilter-client-ruby1.8_1.6.7-1を前提に作成。
# * ごく簡単に動作確認をした。
# * 実際には使用していない。
require 'tempfile'
require 'milter/client'
load '/usr/bin/bsfilter'
class Bsfilter
attr_accessor :milter
#!/usr/bin/ruby
require 'rubygems'
gem 'capistrano'
require 'capistrano/cli'
class Capdo < Capistrano::CLI
def option_parser
return @option_parser if @option_parser
--- a/lib/plugins/defaults/standard_commands.rb
+++ b/lib/plugins/defaults/standard_commands.rb
@@ -179,7 +179,7 @@ module Termtter::Client
register_hook(:highlight_for_search_query, :point => :pre_coloring) do |text, event|
case event
when SearchEvent
- query = event.query.split(/\s/).map {|q|Regexp.quote(q)}.join("|")
+ query = event.query.split(/\s/).reject {|q|q == 'OR'}.map {|q|Regexp.quote(q)}.join("|")
text.gsub(/(#{query})/i, '<on_magenta><white>\1</white></on_magenta>')
else
@arika
arika / auto_search.rb
Created October 26, 2009 01:27
termtter plugin: searches keywords automatically
# -*- coding: utf-8 -*-
config.plugins.auto_search.set_default(:keywords, [])
module Termtter::Client
public_storage[:auto_search] ||= {
:since_id => nil,
:keyword => {},
}
@arika
arika / capistrano_upstream_helper.rb
Created October 3, 2009 00:33
An experimental helper. It makes Capistrano tasks that can refer its upstream hosts/roles
module UpstreamSupport
module Utils
def initialize(config)
@config = config
end
def to_ary
to_a
end