orzFly https://oldblog.orzfly.com His Memories from Here to There, with Fuzzy Ginkgo Sat, 11 Feb 2017 13:57:34 +0000 en-US hourly 1 https://wordpress.org/?v=4.9.5 RGSSRuntime Module 1.0 for RPG Maker XP/VX/VX Ace https://oldblog.orzfly.com/html/rgssruntime.html Wed, 19 Mar 2014 13:06:29 +0000 https://orzfly.com/?p=1285 这个模块是为了在脚本中操作 RGSS 的两个选项:平滑模式和抑制画面抖动(垂直同步)。除了 RGSS100J 无法使用之外,其他任何 RGSS 1~3 版本理论上都能使用。

脚本内容已放在后文,不过脚本中并没有直接设置。使用时,不仅应当引入脚本,还应该调用它的方法。

RGSSRuntime.smooth_mode

读取/设置 RGSS 的平滑模式选项。true 为开启,false 为关闭。在 RGSS 版本不支持的时候,会返回 nil,对其设置将不会产生任何效果。

RGSSRuntime.wait_for_vsync

读取/设置 RGSS 的抑制画面抖动(垂直同步)选项。true 为开启,false 为关闭。在 RGSS 版本不支持的时候,会返回 nil,对其设置将不会产生任何效果。

脚本正文

]]>
《木中加油 2014》 https://oldblog.orzfly.com/html/muduhs-2014-the-video.html https://oldblog.orzfly.com/html/muduhs-2014-the-video.html#comments Fri, 21 Feb 2014 03:20:32 +0000 https://orzfly.com/?p=1266 image

作为木中的一个传统,每一年刚毕业了的同学都会给下一届高三在百日誓师的时候送上一段祝福。于是,这就是 2013 届的我们送给即将毕业的 2014 届。

事先说明,因为事先准备不充分和考虑不周,这次的歌曲远没有以前的好,每个人唱的调子都不一样,而且也真是为难了几个男生。不过,我想,即使歌唱的不好,我们的心情还是可以传达的。

在线观看

歌词

有时候回忆只是一个入口
水深15米 等候新陈更迭的等候
一本一本 传看天下伊周
而我忐忑
师主任会不会站在窗口

那时候梦想就是没有尽头
墨黑色水笔 构筑光明未来的结构
一笔一笔 文字们看着我
他们说大学会有更加美丽的邂逅

新同学最初是不说话呀微微笑
聊得来的是意合情投
一次次相遇 从初次相逢到长久的友谊
哪些人 值得你一直等候

原谅我没能高山流水天涯海角陪你们走
止不住愧疚 却还任性说出请属于我的要求
多少人相信青春不朽 就有多少人不停奋斗
都说友谊会历久弥深 友谊只三年怎么能够

你是我黑夜牵的手
是我疲惫休憩的肩头
是我四季擦身时 暖如春日的回眸
三年的缘分 有你在心头

那一天独自路过学校门口
任记忆悠悠 所有勾起回忆的所有
一处一处 我们曾经幸福
幸福是陪着你 单纯又青涩 往返食堂宿舍教学楼

三年后难免会说再见了挥挥手
挥不去的是别绪离愁
一次一回首 忍住眼泪走向下一个路口
哪些人 让祝福伴你去留

其实我害怕拥抱害怕结束害怕我会远走
坦率地承认 比起分别我更爱彼此一起奋斗
我知道弥足珍贵曾经拥有 我更要不离不弃天长地久
都说青春匆匆留不住 我用一生怀念不强求

涂鸦画满那白色校服
三号门小木屋状元楼
是我熟悉旋律里 灿若荧火的音符
将过往欢乐 一遍遍弹奏

原谅我没能高山流水天涯海角陪你们走
止不住愧疚 却还任性说出请属于我的要求
多少人相信青春不朽 就有多少人不停奋斗
你说这信念能有多久 一生够不够

其实我害怕拥抱害怕结束害怕我会远走
坦率地承认 比起分别我更爱彼此一起奋斗
我知道弥足珍贵曾经拥有 我更要不离不弃天长地久
都说青春匆匆留不住 我用一生怀念不强求

木中之声回荡教学楼
靠在栏杆暖阳的午后
是我青春岁月里 时过境迁的温柔

沿蒹葭回溯 在昊镜上游

工作人员

  • 活动组织:郑敏荣
  • 风景摄影:陆一尘
  • 视频制作:陆一尘, liqunsz
  • 主题曲 ~ 木中友谊之歌 ~
    • 原曲:ここにしか咲かない花
    • 作曲:小渕健太郎
    • 填词:盛嘉逸, 刘鹏铖, 张婷, 陆静涵, 严嘉悦
    • 演唱:李雨婷, 王海宇, 王昕尧, 冯丽, 张天成, 陶聪聪, 倪一舟
    • 混音:陆一尘
  • 3DCG ~ MuduHS in Minecraft ~
    • 模型:陆一尘, 周嘉益, fux2, Soniji Lee, Owen K.
  • 鸣谢
    • 许伟程, 糜予曦, 常昊, 王子亭, 姬文翔, Peter Xin, Windy Whiterock, LBQ, Shiromi Z., Seiran A., Go Misaki
    • URPGs.com, NewCGer.com, YouKaze.com
    • (null), ネコクンプロジェクト

资源下载

诸如音乐和 Minecraft 地图文件,将会在稍后提供下载。

事实上,木中的 Minecraft 地图距离完工还有很长的路要走,这也是为什么这次视频中动画的部分只出现在了末尾,短暂掠过,角度还很局限试图回避尚未建造完毕的地方。我们会继续努力完成它。

]]>
https://oldblog.orzfly.com/html/muduhs-2014-the-video.html/feed 3
我的浏览器地址栏中的 A – Z(2014) https://oldblog.orzfly.com/html/my-browser-address-bar-2014.html https://oldblog.orzfly.com/html/my-browser-address-bar-2014.html#comments Fri, 03 Jan 2014 20:26:34 +0000 https://orzfly.com/?p=1254 前略,天国的 2013 君。最近常用的浏览器是 Google Chrome (Windows & Android) 娘。

  • Appinn.com
  • Bangumi.tv
  • Computingforgood.org/my-stats
  • Digitalocean.com
  • Evernote.com
  • Freehao123.com
  • Git.miv.im
  • Hostker.com
  • Icardyou.com
  • Jd.com
  • K.ripplecn.org
  • Linode.com
  • Mail.google.com/mail/u/0/
  • Name.com/pricing
  • Orzfly.com
  • Pan.baidu.com
  • Qingcloud.com
  • Reader.miv.im
  • Store.steampowered.com
  • Taobao.com
  • Urpgs.com
  • V2ex.com
  • Worldcommunitygrid.org/ms/viewMyMemberPage.do
  • Xiami.com
  • Youtube.com
  • Z.btc123.com

我越来越觉得每过一段时间看一看浏览器地址栏中的 A~Z 是一件多么有意义的事情。你好,2014。

]]>
https://oldblog.orzfly.com/html/my-browser-address-bar-2014.html/feed 1
阿里云服务器文件 swap 无法开机自动加载 https://oldblog.orzfly.com/html/aliyun-swapfile-init.html Thu, 28 Nov 2013 18:27:04 +0000 https://orzfly.com/?p=1241 默认的系统镜像里 /etc/rc.local 有一行 swapoff -a,删掉即可。阿里云你要不要这么贱!

后来他们客服给我了这么个说法:

您好,由于云服务器默认没有设置swap,所以不会自动加载,由于阿里云采用分布式存储,为了保证数据安全,一份数据实际写3份,无法达到传统磁盘io,所以不建议使用swap,避免对io性能造成影响~ 阿里云客户满意中心

]]>
Windows Server 2008/2012 (R2) + NVIDIA Optimus 笔记本显卡 https://oldblog.orzfly.com/html/windows-server-2008-2012-r2-nvidia-optimus.html https://oldblog.orzfly.com/html/windows-server-2008-2012-r2-nvidia-optimus.html#comments Fri, 22 Nov 2013 16:51:50 +0000 https://orzfly.com/?p=1232 NVIDIA Optimus 架构的显卡在 Windows Server 系统上无法正常工作,就算是强制使用也没有反应。其实很简单,我们都知道这驱动需要使用 AppInit_DLL 这东西,然后 Windows Server 系统默认要求这个东西必须签名,而在桌面系统上是不需要签名的,所以 NVIDIA 的驱动的那个 DLL 并没有签名。

所以事实上很简单,改一下注册表呗……

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows]
"RequireSignedAppInit_DLLs"=dword:00000000

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\Windows] 
"RequireSignedAppInit_DLLs"=dword:00000000

我跟你说改完之后连重启都不需要重开下程序就能用了……

为什么要在笔记本上用服务器系统这个问题不需要过多讨论,另外这方法是这里看来的。

]]>
https://oldblog.orzfly.com/html/windows-server-2008-2012-r2-nvidia-optimus.html/feed 2
在 Interactive Ruby (irb) 中清空屏幕 https://oldblog.orzfly.com/html/clear-the-irb-console-screen.html Sat, 19 Oct 2013 15:26:59 +0000 https://orzfly.com/?p=1192 因为强迫症雷达喵的原因,于是有了这两段代码。首先是无空行的版本:

->(a,b,c){x=a.method(b);a.send(c,b){send c,b,&x;false};print"\e[2J\e[H \e[D"}[irb_context,:echo?,:define_singleton_method]

然后是有空行的版本:

->(x){def x.inspect;self;end;x}["\e[H\e[2J"]

好了你们玩儿蛋去。然后以下是对 ruby – How Do You Clear The IRB Console? – Stack Overflow 的部分粗糙翻译。


楼主 John Topley
你们怎么在 IRB 里清屏?


106 票 John Topley
在 Mac OS X 或 Linux 上你可以用 Ctrl + L 来清空屏幕。


29 票 Ben Hoffstein
Windows 里,把这个代码丢在 %userprofile%\.irbrc 里:

def cls
  system('cls')
end


11 票 TW Scannell
在 Ubuntu 11.10 上 clear 差不多就行了,只是你会看到 => true,把一切搞得很乱。

ruby-1.9.2-p290 :007 > system 'clear'
你会得到

=> true
ruby-1.9.2-p290 :007 >


8 票 AShelly
在 *nix 上 `clear` 就行了。
有趣的是,在 Windows 上用 system 'cls' 就行,`cls` 却不行。

]]>
set_trace_func 和骗局 https://oldblog.orzfly.com/html/set_trace_func.html https://oldblog.orzfly.com/html/set_trace_func.html#comments Mon, 02 Sep 2013 20:59:12 +0000 http://orzfly.com/?p=1164
本文是对 http://t-a-w.blogspot.jp/2007/04/settracefunc-smoke-and-mirrors.html 的粗略翻译,如有错误请务必指正。

Ruby 解释器提供了可用于追踪 Ruby 执行的事件钩子。设置钩子用 set_trace_func(some_proc);卸载钩子则用 set_trace_func(nil)。

追踪器恐怕是发明以来最有用的调试工具,远比基于单步和断点的调试器有用。

Ruby 追踪 8 种事件:

  • line – 文件或行改变
  • class – 模块或类定义开始
  • end – 模块或类定义结束
  • call – Ruby 方法调用
  • return – Ruby 方法返回
  • c-call – C 方法调用
  • c-return – C 方法返回
  • raise – 异常抛出

有些事件并不会被追踪,例如设置和读取变量(局部、全局、实例或者类变量)。

set_trace_func proc { |event, file, line, id, binding, classname|
  STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
}

@welcome  = "Hello"
separator = ", "
$object   = "world"
@@excl    = "!"
puts(@welcome + separator + $object + @@excl)

$ ./example-1.rb
    line ./example-1.rb:7                false
    line ./example-1.rb:8                false
    line ./example-1.rb:9                false
    line ./example-1.rb:10               false
    line ./example-1.rb:11               false
  c-call ./example-1.rb:11          +   String
c-return ./example-1.rb:11          +   String
  c-call ./example-1.rb:11          +   String
c-return ./example-1.rb:11          +   String
  c-call ./example-1.rb:11          +   String
c-return ./example-1.rb:11          +   String
  c-call ./example-1.rb:11       puts   Kernel
  c-call ./example-1.rb:11      write       IO
c-return ./example-1.rb:11      write       IO
  c-call ./example-1.rb:11      write       IO
c-return ./example-1.rb:11      write       IO
c-return ./example-1.rb:11       puts   Kernel

例子中,String#+ 运行了三次,IO#write 两次——第二次大概是输出换行符的。

Ruby 中很多东西很神奇并没有被转换为方法调用。这种东西的一种是字符串插值(... #{ code } ...),并没有被转换为 String#+ 或是 Array#join,而是直接由解释器特别的处理。

set_trace_func proc { |event, file, line, id, binding, classname|
  STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
}
@welcome  = "Hello"
$object   = "world"
puts("#{@welcome}, #{$object}\n")

$ ./example-2.rb
    line ./example-2.rb:7                false
    line ./example-2.rb:8                false
    line ./example-2.rb:9                false
  c-call ./example-2.rb:9        puts   Kernel
  c-call ./example-2.rb:9       write       IO
c-return ./example-2.rb:9       write       IO
c-return ./example-2.rb:9        puts   Kernel

同样,创建类并没有被转化为 Class#new,添加方法并没有被转换为 Module#define_method。幸运的是 Ruby 提供了特别的钩子让我们需要捕捉这些事件——当类创建时,其父类的 inherited 方法会被调用;当一个方法被添加时,Ruby 调用其类的 method_added。

set_trace_func proc { |event, file, line, id, binding, classname|
  STDERR.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
} 

class Geolocation
  def initialize(lat, long)
    @lat  = lat
    @long = long
  end
  def to_s
    "<#{@lat}, #{@long}>"
  end
end

$ ./example-3.rb
    line ./example-3.rb:7                false
  c-call ./example-3.rb:7   inherited    Class
c-return ./example-3.rb:7   inherited    Class
   class ./example-3.rb:7                false
    line ./example-3.rb:8                false
  c-call ./example-3.rb:8  method_added   Module
c-return ./example-3.rb:8  method_added   Module
    line ./example-3.rb:12               false
  c-call ./example-3.rb:12 method_added   Module
c-return ./example-3.rb:12 method_added   Module
     end ./example-3.rb:7                false

如果我们想跟踪些有用的东西,是时候改改格式了。如果我们对跟踪执行过程感兴趣,通常来说文件及行号都没什么用,return/c-return/end 则应该用缩进代替。同时,相比类,我们更注重的是接收者(`self)。

$indent = 0
set_trace_func proc { |event, file, line, id, binding, classname|
  if event == "line"
    # 忽略
  elsif %w[return c-return end].include?(event)
    $indent -= 2
  else
    if event == "class"
      STDERR.printf "%*s%s %s\n", $indent, "", event, eval("self", binding)
    else
      STDERR.printf "%*s%s %s.%s\n", $indent, "", event, eval("self", binding), id
    end
    $indent += 2 if %w[call c-call class].include?(event)
  end
}

class Geolocation
  def initialize(lat, long)
    @lat  = lat
    @long = long
  end
  def to_s
    "<#{@lat}, #{@long}>"
  end
end

a = Geolocation.new(51.12, 17.03)
puts a
p a

$ ./example-4.rb  >/dev/null
c-call Object.inherited
class Geolocation
  c-call Geolocation.method_added
  c-call Geolocation.method_added
c-call Geolocation.new
  call <, >.initialize
c-call main.puts
  call <51.12, 17.03>.to_s
    c-call 51.12.to_s
    c-call 17.03.to_s
  c-call #<IO:0xb7c80fc0>.write
  c-call #<IO:0xb7c80fc0>.write
c-call main.p
  c-call <51.12, 17.03>.inspect
    c-call 17.03.inspect
      c-call 17.03.to_s
    c-call 51.12.inspect
      c-call 51.12.to_s
  c-call #<IO:0xb7c80fc0>.write
  c-call #<IO:0xb7c80fc0>.write

这里的输出又有点小怪癖。在 Geolocation#initialize 开始时, Geolocation#to_s 就被追踪器调用,而不是在其有意义之后。这种情况下,我们简单的得到了垃圾 <, >。但是有些对象,在初始化之前被打印是会产生异常的。

require "complex"

$indent = 0
set_trace_func proc { |event, file, line, id, binding, classname|
  if event == "line"
    # 忽略
  elsif %w[return c-return end].include?(event)
    $indent -= 2
  else
    obj = eval("self", binding)
    if event == "class"
      STDERR.printf "%*s%s %s\n", $indent, "", event, obj
    else
      obj = "<#{obj.class}##{obj.object_id}>" if id == :initialize
      STDERR.printf "%*s%s %s.%s\n", $indent, "", event, obj, id
    end
    $indent += 2 if %w[call c-call class].include?(event)
  end
}

a = Complex.new(11.0, -5.0)
b = Complex.new(2.0, 13.5)
c = a * b

$ ./example-5.rb
c-call Complex.new
  call <Complex#-605829048>.initialize
    c-call 11.0.kind_of?
    c-call 11.0.kind_of?
    c-call -5.0.kind_of?
    c-call -5.0.kind_of?
c-call Complex.new
  call <Complex#-605832038>.initialize
    c-call 2.0.kind_of?
    c-call 2.0.kind_of?
    c-call 13.5.kind_of?
    c-call 13.5.kind_of?
call 11.0-5.0i.*
  c-call 2.0+13.5i.kind_of?
  c-call 11.0.*
  c-call -5.0.*
  c-call 22.0.-
  c-call 11.0.*
  c-call -5.0.*
  c-call 148.5.+
  call 11.0-5.0i.Complex
    c-call 138.5.==
    call 89.5.real
    call 138.5.imag
    c-call 89.5.-
    call 89.5.imag
    call 138.5.real
    c-call 0.+
    c-call Complex.new
      call <Complex#-605842188>.initialize
        c-call 89.5.kind_of?
        c-call 89.5.kind_of?
        c-call 138.5.kind_of?
        c-call 138.5.kind_of?

许多难以找到错误的,最终变成了琐碎的自定义追踪器、grep 或是一些一行 Ruby 脚本来美化事实。

骗局

set_trace_func 不仅仅对调试有用,也适合做各种有趣的事情。Binding.of_caller 是用 set_trace_func 实现的,虽然已经不能用了。magic/help 用了 set_trace_func 在 irb 中提供方便的帮助:

irb> help { STDERR.write }
--------------------------------------------------------------- IO#write
     ios.write(string)    => integer
------------------------------------------------------------------------
     Writes the given string to _ios_. The stream must be opened for
     writing. If the argument is not a string, it will be converted to a
     string using +to_s+. Returns the number of bytes written.

        count = $stdout.write( "This is a test\n" )
        puts "That was #{count} bytes of data"

     _produces:_

        This is a test
        That was 15 bytes of data

magic/help 通过设置一个 set_trace_func 钩子工作,执行传送过来的块,然后一遇到感兴趣的事件就停止执行。这意味着 help { rm_rf "/" } 完全是安全的。

我开发 magic/help 时遇到的一个难懂的问题是,方法没有按正确的参数个数调用时,追踪结果不一致。

对于 C 写的方法,就算显式声明了参数个数,Ruby 依然在 ArgumentError.new 前产生 c-call。另一方面,对于 Ruby 写的方法,ArgumentError.new 被调用,然后从函数 return 返回,而不产生 call。

要描述这个问题,我们来跟踪一下 C 方法 STDERR.write:

c-call #<IO:0xb7c98fa8>.write
  c-call ArgumentError.new
    c-call #<ArgumentError: ArgumentError>.initialize
    c-return #<ArgumentError: wrong number of arguments (0 for 1)>.initialize
  c-return ArgumentError.new
  c-call #<ArgumentError: wrong number of arguments (0 for 1)>.backtrace
  c-return #<ArgumentError: wrong number of arguments (0 for 1)>.backtrace
  c-call #<ArgumentError: wrong number of arguments (0 for 1)>.set_backtrace
  c-return #<ArgumentError: wrong number of arguments (0 for 1)>.set_backtrace
  raise #<IO:0xb7c98fa8>.write
c-return #<IO:0xb7c98fa8>.write

与此同时我们跟踪一下 Ruby 方法 FileUtils.remove_entry:

# "call FileUtils.remove_entry" 永远不会产生!
  c-call ArgumentError.new
    c-call #<ArgumentError: ArgumentError>.initialize
    c-return #<ArgumentError: wrong number of arguments (0 for 1)>.initialize
  c-return ArgumentError.new
  c-call #<ArgumentError: wrong number of arguments (0 for 1)>.backtrace
  c-return #<ArgumentError: wrong number of arguments (0 for 1)>.backtrace
  c-call #<ArgumentError: wrong number of arguments (0 for 1)>.set_backtrace
  c-return #<ArgumentError: wrong number of arguments (0 for 1)>.set_backtrace
  raise FileUtils.remove_entry
# "return FileUtils.remove_entry" 确实产生了。
return FileUtils.remove_entry

两种情况下,参数都是在调用方法之前被检查的。IO#write 是定义为一个参数的方法:

rb_define_method(rb_cIO, "write", io_write, 1);

新版的 magic/help 也能处理这个情况了——如果首事件是 c-call 到 ArgumentError.new,magic/help 就等到首个 return 事件(如果有)而不是立刻放弃执行传来的块。快去下载新版,享受神奇的帮助吧。

]]>
https://oldblog.orzfly.com/html/set_trace_func.html/feed 1
在 HomeZZ 的最后一日 https://oldblog.orzfly.com/html/last-day-at-homezz.html https://oldblog.orzfly.com/html/last-day-at-homezz.html#comments Fri, 16 Aug 2013 06:11:26 +0000 http://orzfly.mist.so/?p=1054 ]]> https://oldblog.orzfly.com/html/last-day-at-homezz.html/feed 2 无语的黄昏 – 序曲 https://oldblog.orzfly.com/html/wordless-dusk-overture.html Tue, 25 Jun 2013 05:50:22 +0000 http://orzfly.com/?p=1099 一段很长的时间已经过去,自从上次我在这里留下足迹。一个时代已经过去,自从许久以前的那声呐喊。我甚至认为这是怨念,实际上不过只是矫情而已。

终于在两周前结束了一切,我不知是应宽慰或者反而更加难受。事情不断的重新想起,特别是最近被刻意压制的一些事情。就连过去的论坛上也有因为同样理由离去的人们回来。越来越多的事情不断让我唏嘘不已,例如手机或是电脑上即时通讯工具收到的图片文件夹,几千张图片掠过,我甚至还能想起来是什么时候什么事件什么人儿。

因为一个邪恶以及并不会有任何成效的东西我耽搁了多少事情?!一次次的承诺被推迟以及放弃,甚至还牵扯了他人的梦想。以及不断继续挖坑,伴随着挖坑的快感迎来的是更多的压力。我不止一次感到无力,因为有茫茫多的事情,即使得不到回报,事实上回报也并不是目的。

假期开始之前总是在设想要更加珍惜时间去填坑或者痛痛快快睡一觉,然而事实上总是虽然起早贪黑弄得十分疲倦却依然毫无进展。因为疲倦而不愿动笔,以及因为不知做什么却不去睡觉。我很好的用时差这个理由欺骗自己,可是无论如何又会又什么改变。

帖子的名字来源于过去的一本书,恐怕很少有人知道?甚至豆瓣读书上都找不到。然而我并没有看过这本书,只是喜欢这名字而已。

]]>
长满树的叶子 https://oldblog.orzfly.com/html/treey-leaf.html Sun, 28 Apr 2013 08:05:43 +0000 http://orzfly.com/?p=1057 Letter

躲避,让事情变成这样
什麽,之前其实我有很不想去遗忘的
其实,那有怎样呢,很多都是借口
怕,真的躲不过,即便有什么方法
宁可去逆来顺受,不要再躲不过,却,还躲
(差一点都成年了,差一点就不是后来的青春了)
2013.4.25

FIN

从 Finkgo 到 NekoKun,
从村上春树的猫城到猫的天空之城,
无数的记忆,可是我写不下,因为只有 42。

前些时候我去围观了那颗 Fuzzy Ginkgo,
再也找不到当年那种绿的感觉。
Q.E.D.

]]>