Skip to content

Instantly share code, notes, and snippets.

View toshia's full-sized avatar

Toshiaki Asai toshia

View GitHub Profile
@toshia
toshia / unkonow.rb
Last active January 20, 2016 12:58
did_you_mean gem、便利
class WC
def unkonow
'うんこなう'
end
end # => :unkonow
WC.new.unkonow # => "うんこなう"
WC.new.unknown
# NoMethodError: undefined method `unknown' for #<WC:0x007fc4420e0f48>
# Did you mean? unkonow
@toshia
toshia / mikutter-webkit-gtk2.rb
Created December 2, 2013 16:06
mikutterにWebkit埋めて表示する
# -*- coding: utf-8 -*-
require "webkit-gtk2"
Plugin.create(:kancolle) do
tab(:kancolle, "艦これ") do
view = WebKitGtk2::WebView.new
view.load_uri("http://www.dmm.com/netgame/feature/kancolle.html")
nativewidget view.show_all
end
@toshia
toshia / basicmod_installer.rb
Created April 6, 2013 11:50
MinecraftForgeとか、minecraft.jarを書き換えるタイプのMODをインストールするスクリプト。Macでしか動作確認してない
#! /usr/bin/ruby
# -*- coding: utf-8 -*-
# how to use
# (in minecraft directory)
# $ ./basicmod_installer.rb /path/to/minecraft-forge.zip [/path/to/another/mods ...]
require "fileutils"
MC_ROOT = File.expand_path(File.dirname(__FILE__))
JAR_NAME = "minecraft.jar"
.DS_Store
/screenshots/
/texturepacks-mp-cache/
/lastlogin
*.log
/saves/MOD Test
*(navel *
/crash-reports/
/IDChecker/
/stats/stats_toshi_a_unsent.dat
UserConfig[]の戻り値は、freezeされてるから、この戻り値自体に破壊的な変更はできない。
UserConfig[:test] << :value # => なんかエラー
freezeされているオブジェクトは、mikutterではmeltで変更可能になるが、その時内部的にはシャローコピーされてしまうので、UserConfig自体には変更できない
UserConfig[:test].melt << :value # => [:value]
# result
UserConfig[:test] # => []
Plugin.create :twihai_achievements do
defachievement(:red_fav,
description: "1つのツイートに5ふぁぼ以上された",
hint: "おもしろツイートで5fav以上もらおう"
) do |achievement|
on_favorite do |service, user, message|
if message.user.is_me? and message.favorited_by.size >= 5
achievement.take! end end end
end
@toshia
toshia / spellchecker.rb
Created February 4, 2013 13:34
時事ネタは時間の無駄である
Plugin.create :spellchecker do
filter_gui_timeline_selected_messages do |timeline, messages|
messages.each { |message|
raise RuntimeError if /[Ff]ile:\/\/\// =~ message.to_s
}
[timeline, messages]
end
end
@toshia
toshia / gobou.rb
Created December 25, 2012 03:09
ごぼう♡
Plugin.create :gobou do
UserConfig[:gobou_sign] ||= "♡"
UserConfig[:gobou_quantity] ||= 1
command(:gobou,
name: 'ごぼう',
condition: lambda{ |opt| !opt.messages.empty? and opt.messages.all? &amp;:repliable? },
visible: true,
role: :timeline) do |opt|
opt.messages.each do |message|
@toshia
toshia / lesser_gobou.rb
Created December 25, 2012 03:05
ごぼう♡
Plugin.create :gobou do
GOBOU_SIGN = "♡"
GOBOU_QUANTITY = 1
command(:gobou,
name: 'ごぼう',
condition: lambda{ |opt| !opt.messages.empty? and opt.messages.all? &:repliable? },
visible: true,
role: :timeline) do |opt|
opt.messages.each do |message|
@toshia
toshia / durun.rb
Created November 30, 2012 08:09
mikutterプラグインでコードゴルフとかくそわろ
d=:durun;Plugin.create(d){e=[];filtershow_filter{|s|s.select{|m|(e&[m.id])[0]}};command(d,name:'封印',condition:->o{o.messages[0]},visible:1,role: :timeline){|o|e << o.messages[0]}}