知乎周源微信_每周源代码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

相关文章

java向微信服务号发送消息的完整步骤实例

《java向微信服务号发送消息的完整步骤实例》:本文主要介绍java向微信服务号发送消息的相关资料,包括申请测试号获取appID/appsecret、关注公众号获取openID、配置消息模板及代码... 目录步骤1. 申请测试系统2. 公众号账号信息3. 关注测试号二维码4. 消息模板接口5. Java测试

Python基于微信OCR引擎实现高效图片文字识别

《Python基于微信OCR引擎实现高效图片文字识别》这篇文章主要为大家详细介绍了一款基于微信OCR引擎的图片文字识别桌面应用开发全过程,可以实现从图片拖拽识别到文字提取,感兴趣的小伙伴可以跟随小编一... 目录一、项目概述1.1 开发背景1.2 技术选型1.3 核心优势二、功能详解2.1 核心功能模块2.

如何基于Python开发一个微信自动化工具

《如何基于Python开发一个微信自动化工具》在当今数字化办公场景中,自动化工具已成为提升工作效率的利器,本文将深入剖析一个基于Python的微信自动化工具开发全过程,有需要的小伙伴可以了解下... 目录概述功能全景1. 核心功能模块2. 特色功能效果展示1. 主界面概览2. 定时任务配置3. 操作日志演示

Redis迷你版微信抢红包实战

《Redis迷你版微信抢红包实战》本文主要介绍了Redis迷你版微信抢红包实战... 目录1 思路分析1.1hCckRX 流程1.2 注意点①拆红包:二倍均值算法②发红包:list③抢红包&记录:hset2 代码实现2.1 拆红包splitRedPacket2.2 发红包sendRedPacket2.3 抢

JDK9到JDK21中值得掌握的29个实用特性分享

《JDK9到JDK21中值得掌握的29个实用特性分享》Java的演进节奏从JDK9开始显著加快,每半年一个新版本的发布节奏为Java带来了大量的新特性,本文整理了29个JDK9到JDK21中值得掌握的... 目录JDK 9 模块化与API增强1. 集合工厂方法:一行代码创建不可变集合2. 私有接口方法:接口

SpringBoot后端实现小程序微信登录功能实现

《SpringBoot后端实现小程序微信登录功能实现》微信小程序登录是开发者通过微信提供的身份验证机制,获取用户唯一标识(openid)和会话密钥(session_key)的过程,这篇文章给大家介绍S... 目录SpringBoot实现微信小程序登录简介SpringBoot后端实现微信登录SpringBoo

Python实现微信自动锁定工具

《Python实现微信自动锁定工具》在数字化办公时代,微信已成为职场沟通的重要工具,但临时离开时忘记锁屏可能导致敏感信息泄露,下面我们就来看看如何使用Python打造一个微信自动锁定工具吧... 目录引言:当微信隐私遇到自动化守护效果展示核心功能全景图技术亮点深度解析1. 无操作检测引擎2. 微信路径智能获

SpringBoot实现微信小程序支付功能

《SpringBoot实现微信小程序支付功能》小程序支付功能已成为众多应用的核心需求之一,本文主要介绍了SpringBoot实现微信小程序支付功能,文中通过示例代码介绍的非常详细,对大家的学习或者工作... 目录一、引言二、准备工作(一)微信支付商户平台配置(二)Spring Boot项目搭建(三)配置文件

微信公众号脚本-获取热搜自动新建草稿并发布文章

《微信公众号脚本-获取热搜自动新建草稿并发布文章》本来想写一个自动化发布微信公众号的小绿书的脚本,但是微信公众号官网没有小绿书的接口,那就写一个获取热搜微信普通文章的脚本吧,:本文主要介绍微信公众... 目录介绍思路前期准备环境要求获取接口token获取热搜获取热搜数据下载热搜图片给图片加上标题文字上传图片

如何用java对接微信小程序下单后的发货接口

《如何用java对接微信小程序下单后的发货接口》:本文主要介绍在微信小程序后台实现发货通知的步骤,包括获取Access_token、使用RestTemplate调用发货接口、处理AccessTok... 目录配置参数 调用代码获取Access_token调用发货的接口类注意点总结配置参数 首先需要获取Ac