知乎周源微信_每周源代码29-Ruby和Shoes和第一个Ruby病毒

2023-12-20 11:50

本文主要是介绍知乎周源微信_每周源代码29-Ruby和Shoes和第一个Ruby病毒,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

知乎周源微信

知乎周源微信

I was in Norway last week at the Norwegian Developers Conference, so I'm afraid the Weekly Source Code is the bi-weekly source code this month. It's amazing how international travel can really slow a body down. This trip just obliterated me. I'm slowly coming back to the world of the living, though.

上周我在挪威开发者大会上在挪威,所以恐怕每周源代码是本月的每两周一次源代码。 令人惊讶的是,国际旅行真的可以使身体慢下来。 这次旅行使我丧胆。 不过,我正在慢慢回到生活世界。

I've been getting more and more interested in how folks extend their applications using plugins and things. In my new ongoing quest to read source code to be a better developer, Dear Reader, I present to you twenty-ninth in a infinite number of posts of "The Weekly Source Code."

我对人们如何使用插件和事物扩展其应用程序越来越感兴趣。 在我不断寻求阅读源代码以成为更好的开发人员的过程中,亲爱的读者,我在无限数量的“每周源代码”帖子中向您展示第二十九位

This week's source is a clever "ClickOnce"-style hack for Ruby. It's cool because it brings together a number of technologies into a very clean end-user experience. The intent is to make the running of a Ruby GUI Application effortless, and it works and it's brilliant on several levels. Thanks to Sam Saffron for pointing me to it!

本周的消息来源是针对Ruby的聪明的“ ClickOnce”风格黑客。 之所以酷,是因为它将多种技术融合在一起,形成了非常干净的最终用户体验。 目的是使Ruby GUI应用程序的运行轻松自如,并且可以正常运行,并且在多个级别上都非常出色。 感谢Sam Saffron为我指出这一点!

To start out, it's a hack says the author why the lucky stiff (or "_why" for short), so it's very early and there's bugs. You can check out the code on GitHub: http://github.com/why/shoes/tree/master or clone the whole tree using git via "git clone git://github.com/why/shoes.git"

首先,作者说了一个hack的原因,为什么幸运的僵硬(或简称为“ _why”),所以现在还很早,并且存在错误。 您可以在GitHub上检出代码: http git clone git://github.com/why/shoes.git或通过git通过“ git clone git://github.com/why/shoes.git ”克隆整个树

鞋类(Shoes)

Ruby is a very aesthetically (to me) pleasing and flexible language. Shoes is a GUI Toolkit for making Windowing Applications using Ruby. I mentioned it back in TWSC12. Shoes is legendary for a number of reasons, but above all, it has the greatest API documentation in the history of all software documentation. The main book on Shoes Development called "nobody knows shoes" is fantastic. Even Chris Sells likes it!

在我看来,Ruby是一种非常美观且灵活的语言。 Shoes是用于使用Ruby制作窗口应用程序的GUI工具包。 我在TWSC12中提到了它。 鞋子因许多原因而具有传奇色彩,但最重要的是,它具有所有软件文档历史上最出色的API文档。 关于鞋类开发的主要书籍“没人知道鞋子”真是太棒了。 甚至Chris Sells也喜欢!

Here's part of an example phone book application written in Ruby and Shoes):

这是用Ruby和Shoes编写的示例电话簿应用程序的一部分):

Shoes.app :width => 320, :height => 350 do

stack :margin => 40 do
stack :margin => 10 do
para "Name"
@name = list_box :items => ["Yes, please!", "NO. No thankyou."]
end
stack :margin => 10 do
para "Address"
@address = edit_line
end
stack :margin => 10 do
para "Phone"
@phone = edit_line
end
stack :margin => 10 do
button "Save" do
Shoes.p [@name.text, @address.text, @phone.text]
end
end
end
end

It feels a lot like Tcl/Tk or Rebol. It'll be interesting to see if someone writes a mainstream application that is non-trivial. Shoes works on XP, Vista, MacOSX and Linux. Do note that you'll need to right click and run it as Administrator on Vista as _why hasn't put in an elevation prompt yet. You'll need Admin to do the initial bootstrap install.

感觉很像Tcl / Tk或Rebol。 看看是否有人编写了一个不平凡的主流应用程序会很有趣。 Shoes可以在XP,Vista,MacOSX和Linux上运行。 请注意,由于_why尚未出现在提升提示中,因此您需要右键单击并以管理员身份在Vista上运行它。 您需要Admin来进行初始引导安装。

However, in order to get Shoes to work, before today, you had to install Ruby, then get the Shoes libraries installed, usually via a gem. Then you'd need to run your app via ruby.exe yourapp.rb or a shortcut you'd setup.  The second comment on _why's blog post announcement says it all:

但是,为了使Shoes正常工作,在今天之前,您必须安装Ruby,然后通常通过gem来安装Shoes库。 然后,您需要通过ruby.exe yourapp.rb或您设置的快捷方式运行您的应用程序。 关于_why博客文章公告的第二条评论说明了一切:

"Wow, this is super. We can actually give our apps to other people now :)"

“哇,这太好了。我们实际上可以现在将我们的应用程序提供给其他人:)”

Here's an explanation from _why on how the Shoes "bootstrapper" (my word) works:

这是_why的解释,说明鞋的“ bootstrapper”(我的话)是如何工作的:

If you poke around with a hex editor inside Windows’ PE binary format, you’ll find an .rsrc section at the end of the file which contains the icons and dialog boxes. I insert the Ruby script into this mess.
binj = Binject::EXE.new("blank.exe")
binj.inject("SHOES_FILENAME", "simple-accordion.rb")
File.open("simple-accordion.rb") do |f|binj.inject("SHOES_PAYLOAD", f)
end
binj.save("accordion.exe")
如果您使用Windows PE二进制格式的十六进制编辑器来查看,您将在文件末尾找到一个.rsrc节,其中包含图标和对话框。 我将Ruby脚本插入这个烂摊子。
 binj = Binject::EXE.new("blank.exe")
binj.inject("SHOES_FILENAME", "simple-accordion.rb")
File.open("simple-accordion.rb") do |f|binj.inject("SHOES_PAYLOAD", f)
end
binj.save("accordion.exe")

Fantastic hack. He shoves the Ruby script into a Windows Resource! He does the same thing for DMG (Disk Images) on Mac OSX, so you can create Ruby scripts that are portable to these two platforms.

很棒的骇客。 他将Ruby脚本推送到Windows资源中! 他在Mac OSX上对DMG(磁盘映像)执行相同的操作,因此您可以创建可移植到这两个平台的Ruby脚本。

When it runs, it checks for the existence of Shoes on your system. It's in C:\Program Files (x86)\Common Files\Shoes\. If Shoes (which includes a private copy of Ruby) is not there, it's downloaded and installed, and then your app runs. Bam, one-click cross-platform GUIs.

当它运行时,它将检查系统上是否存在Shoes。 它在C:\ Program Files(x86)\ Common Files \ Shoes \中。 如果不存在Shoes(包括Ruby的私人副本),则将其下载并安装,然后运行您的应用程序。 Bam,一键式跨平台GUI。

I'm not clear what the security ramifications are. Well, I am. I suspect there is no security that isn't already provided by the host operating system. Once you're running, the Ruby script has full control to do whatever it likes, so I suppose someone could write a malicious program just as they could write a malicious .NET app if they liked.

我不清楚安全后果是什么。 好吧,我。 我怀疑主机操作系统没有提供任何安全性。 一旦运行,Ruby脚本就可以完全控制自己喜欢做的​​事情,所以我想有人可以编写恶意程序,就像他们愿意编写恶意.NET应用程序一样。

You can package your apps just by running shoes --package and you'll get this dialog. You can chose to include Shoes and Ruby inside the resulting EXE if you like.

您可以仅通过跑步鞋--package来打包应用程序,然后会出现此对话框。 如果愿意,您可以选择在生成的EXE中包含Shoes和Ruby。

鞋类

Shoes also supports custom "Widgets." For example, here's a custom Speedometer control.

鞋子还支持自定义“小部件”。 例如,这是一个自定义的Speedometer控件。

The code for the entire app, including the custom control is this:

整个应用程序(包括自定义控件)的代码如下:

class Speedometer < Widget
attr_accessor :range, :tick, :position
def initialize opts = {}
@range = opts[:range] || 200
@tick = opts[:tick] || 10
@position = opts[:position] || 0
@cx, @cy = self.left + 110, self.top + 100

nostroke
rect :top => self.top, :left => self.left,
:width => 220, :height => 200
nofill
stroke white
oval :left => @cx - 50, :top => @cy - 50, :radius => 100
(ticks + 1).times do |i|
radial_line 225 + ((270.0 / ticks) * i), 70..80
radial_line 225 + ((270.0 / ticks) * i), 45..49
end
strokewidth 2
oval :left => @cx - 70, :top => @cy - 70, :radius => 140
stroke lightgreen
oval :left => @cx - 5, :top => @cy - 5, :radius => 10
@needle = radial_line 225 + ((270.0 / @range) * @position), 0..90
end
def ticks; @range / @tick end
def radial_line deg, r
pos = ((deg / 360.0) * (2.0 * Math::PI)) - (Math::PI / 2.0)
line (Math.cos(pos) * r.begin) + @cx, (Math.sin(pos) * r.begin) + @cy,
(Math.cos(pos) * r.end) + @cx, (Math.sin(pos) * r.end) + @cy
end
def position= pos
@position = pos
@needle.remove
append do
@needle = radial_line 225 + ((270.0 / @range) * @position), 0..90
end
end
end

Shoes.app do
stack do
para "Enter a number between 0 and 100"
flow do
@p = edit_line
button "OK" do
@s.position = @p.text.to_i
end
end

@s = speedometer :range => 100, :ticks => 10
end
end

It's about 24 megs of libraries on disk when you're done, but you've got multimedia support and a lot of great library support in that space, not to mention a copy of Ruby itself. The download is only 2.5M bare or 6.8M with Video support.

完成后,磁盘上大约有24兆的库,但是在该空间中,您已经获得了多媒体支持和很多强大的库支持,更不用说Ruby本身了。 仅有视频支持,下载仅需250万裸机或6.8M。

I think it'd be great to build a Twitter Client using Shoes. The race is on! Hopefully we'll be able to get a Twitter Client done before some schmuck writes a Ruby Shoes virus. I for one, will be keeping the Ruby Shoes virus I wrote to myself. Well, not really a virus as it's a self propagating annoyance. But still. :)

我认为使用Shoes构建一个Twitter Client非常好。 比赛开始了! 希望我们能够在某些schmuck编写Ruby Shoes病毒之前完成一个Twitter Client。 首先,我将保留我写给自己的Ruby Shoes病毒。 嗯,这不是一种病毒,因为它是一种自我传播的烦恼。 但是还是。 :)

It'll be fun to watch how this evolves. I hope there will be a clean upgrade process. If you want to try running your first Ruby/Shoes app, then run this EXE if you've got Windows or this DMG if you're on a Mac to see a basic demo application, but more importantly, to experience in the installer/bootstrapping process.

看着它如何演变会很有趣。 我希望会有一个干净的升级过程。 如果您想尝试运行第一个Ruby / Shoes应用程序,那么如果您使用的是Windows,请运行此EXE;如果您使用的是Mac,则请运行此DMG ,以查看基本的演示应用程序,但更重要的是,要体验安装程序/引导过程。

Ruby, Ruby, Shoes, 鞋子, Why 为什么

翻译自: https://www.hanselman.com/blog/the-weekly-source-code-29-ruby-and-shoes-and-the-first-ruby-virus

知乎周源微信

这篇关于知乎周源微信_每周源代码29-Ruby和Shoes和第一个Ruby病毒的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/515939

相关文章

W外链微信推广短连接怎么做?

制作微信推广链接的难点分析 一、内容创作难度 制作微信推广链接时,首先需要创作有吸引力的内容。这不仅要求内容本身有趣、有价值,还要能够激起人们的分享欲望。对于许多企业和个人来说,尤其是那些缺乏创意和写作能力的人来说,这是制作微信推广链接的一大难点。 二、精准定位难度 微信用户群体庞大,不同用户的需求和兴趣各异。因此,制作推广链接时需要精准定位目标受众,以便更有效地吸引他们点击并分享链接

好题——hdu2522(小数问题:求1/n的第一个循环节)

好喜欢这题,第一次做小数问题,一开始真心没思路,然后参考了网上的一些资料。 知识点***********************************无限不循环小数即无理数,不能写作两整数之比*****************************(一开始没想到,小学没学好) 此题1/n肯定是一个有限循环小数,了解这些后就能做此题了。 按照除法的机制,用一个函数表示出来就可以了,代码如下

SWAP作物生长模型安装教程、数据制备、敏感性分析、气候变化影响、R模型敏感性分析与贝叶斯优化、Fortran源代码分析、气候数据降尺度与变化影响分析

查看原文>>>全流程SWAP农业模型数据制备、敏感性分析及气候变化影响实践技术应用 SWAP模型是由荷兰瓦赫宁根大学开发的先进农作物模型,它综合考虑了土壤-水分-大气以及植被间的相互作用;是一种描述作物生长过程的一种机理性作物生长模型。它不但运用Richard方程,使其能够精确的模拟土壤中水分的运动,而且耦合了WOFOST作物模型使作物的生长描述更为科学。 本文让更多的科研人员和农业工作者

uniapp设置微信小程序的交互反馈

链接:uni.showToast(OBJECT) | uni-app官网 (dcloud.net.cn) 设置操作成功的弹窗: title是我们弹窗提示的文字 showToast是我们在加载的时候进入就会弹出的提示。 2.设置失败的提示窗口和标签 icon:'error'是设置我们失败的logo 设置的文字上限是7个文字,如果需要设置的提示文字过长就需要设置icon并给

Spring Roo 实站( 一 )部署安装 第一个示例程序

转自:http://blog.csdn.net/jun55xiu/article/details/9380213 一:安装 注:可以参与官网spring-roo: static.springsource.org/spring-roo/reference/html/intro.html#intro-exploring-sampleROO_OPTS http://stati

GitHub每周最火火火项目(9.2-9.8)

项目名称:polarsource / polar 项目介绍:polar 是一个开源项目,它是 Lemon Squeezy 的替代方案,并且具有更具优势的价格。该项目的目标是为开发者提供一种更好的选择,让他们能够在追求自己的热情和兴趣的同时,通过编码获得相应的报酬。通过使用 polar,开发者可以享受到更实惠的价格,同时也能够更自由地发挥自己的创造力和技能。 项目地址:https://github.

使用gradle做第一个java项目

涉及到的任务如下: assemble任务会编译程序中的源代码,并打包生成Jar文件,这个任务不执行单元测试。 Total time: 5.581 secs E:\workspace\Test>gradle assemble :compileJava :processResources UP-TO-DATE :classes :findMainClass :jar :b

vue2实践:第一个非正规的自定义组件-动态表单对话框

前言 vue一个很重要的概念就是组件,作为一个没有经历过前几代前端开发的我来说,不太能理解它所带来的“进步”,但是,将它与后端c++、java类比,我感觉,组件就像是这些语言中的类和对象的概念,通过封装好的组件(类),可以通过挂载的方式,非常方便的调用其提供的功能,而不必重新写一遍实现逻辑。 我们常用的element UI就是由饿了么所提供的组件库,但是在项目开发中,我们可能还需要额外地定义一

Win8下如何快速查找和删除电脑中的病毒

Win8系统如何查找和删除病毒?检查你的电脑是否存在病毒的一种快速方法是使用 Windows Defender. 此恶意软件防护随 Windows 提供,可帮助识别和删除病毒、间谍软件和其他恶意软件。   注意:如果你使用的是 Windows RT,则 Windows Defender 会始终启用,并且不能关闭。   如果你使用的是 Windows 8,则可以根据自己的喜好运行由其他

运营版开源代码 多语言跨境商城 跨境电商平台

默认中英双语 后台带翻译接口 支持133种语言自动翻译 支持多商户联盟 一键部署版本 伪静态+后台登陆后缀 源码下载:https://download.csdn.net/download/m0_66047725/89722389 更多资源下载:关注我。