9.正则表达式
正则表达式以/开始/结束
+:一个或多个
*:0个或多个
\s:一个空格(空格,TAB,换行等等)
\d:一个数字
\w:字母
.:任何字符
1)/Perl|Python/
2)/P(erl|ython)/
3)/ab*c/ /ab+c/
/\d\d:\d\d:\d\d/ # 时间例如 12:34:56
/Perl.*Python/ # Perl, zero or more other chars, then Python
/Perl\s+Python/ # Perl, one or more spaces, then Python
/Ruby (Perl|Python)/ # Ruby, a space, and either Perl or Python
10.继承和方法
ruby是单继承,但是可以使用Mixins来实现多继承。
语法:
class KaraokeSong < Song
方法调用是先找子类。再找父类,直到继承连结束。如果都没有找到,会抛出异常。
11.属性
可以对实例变量创建类似JAVA的get和set方法
例如,类似set方法:
class Song
attr_writer :duration
end
类似get方法:
class Song
attr_reader :name, :artist, :duration
end
12.类变量(Class Variables)
what is Class Variables:为所有对象(实例)共享。类似JAVA的static变量
相关推荐
华硕笔记本键盘失灵恢复方法全解析
华硕笔记本键盘失灵问题可能由多种原因导致,但大多数问题都可以通过上述方法得到解决。在尝试恢复键盘功能时,请务必按照步骤操作,并注意备份重要数据。如果问题依然存在,请寻求专业维修人员的帮助。希望本文能够帮助大家快速解决华硕笔记本键盘失灵的问题!
Ruby完全自学手册
Ruby,一种简单快捷的面向对象(面向对象程序设计)脚本语言,在20世纪90年代由日本人松本行弘(Yukihiro Matsumoto)开发,遵守GPL协议和Ruby License。它的灵感与特性来自于 Perl、Smalltalk、Eiffel、Ada以及 Lisp 语言。由 Ruby 语言本身还发展出了JRuby(Java平台)、IronRuby(.NET平台)等其他平台的 Ruby 语言替...
工业界实战:小红书推荐系统中的AB测试策略解析——分层、Holdout与反转实验
本文深入解析了小红书推荐系统在工业界实践中采用的AB测试核心策略。重点阐述了分层实验如何解决多实验并行与干扰问题,Holdout机制如何作为评估黄金标准提供稳定基准,以及反转实验如何作为全量上线后的终极安全网进行风险控制。这些策略共同构成了科学、严谨的线上评估体系,是保障推荐系统迭代效果与决策质量的关键。
【编程语言】Ruby完全自学手册
Ruby,一种简单快捷的面向对象(面向对象程序设计)脚本语言,在20世纪90年代由日本人松本行弘(Yukihiro Matsumoto)开发,遵守GPL协议和Ruby License。它的灵感与特性来自于 Perl、Smalltalk、Eiffel、Ada以及 Lisp 语言。由 Ruby 语言本身还发展出了JRuby(Java平台)、IronRuby(.NET平台)等其他平台的 Ruby 语言替...
Polardb训练营-本地部署 PolarDB-X
PolarDB-X是阿里巴巴自主设计研发的高性能云原生分布式数据库产品,为用户提供高吞吐、大存储、低延时、易扩展和超高可用的云时代数据库服务。云原生+MySQL生态PolarDB-X已作为标准云产品在世界范围内的13个地区提供服务。依托云资源和容器化部署能力,PolarDB-X可以在数分钟内完成集群创建和变配,整个过程中用...
从理论到代码:蒙特卡洛法在光学散射模拟中的应用全解析(Matlab 2014a版)
本文详细解析了蒙特卡洛法在光学散射模拟中的应用,从数学原理到Matlab 2014a实现。通过模拟光子随机游走过程,精确描述光在浑浊介质中的传输特性,提供完整的源码实现和性能优化技巧,适用于生物医学光学、大气遥感等领域。
关于在自学Ruby 中的一点笔记
ruby基础教程目录页面: 25 目录 39 正文开始 与方法有关的知识 方法名以小写开始,可以以?/!/= 这三种特殊符合结尾 ? 通常表示查询的方法名以?结尾,一般返回true/false值,当然,根据ruby的原则,除false和nil以外的值都转化为true. ...
华为OD机试真题2026双机位C卷 C语言 实现【主次关联成环警告】
在ICT运维领域,现网运维工程师面向对设备上报的众多告警,往往需要筛选出最主要的告警优先处理,次等级的告警或许为同一个根因导致的告警,处理优先级会放后或者不处理,这样就诞生出主次关联告警的概念。给定一系列告警的主次关联关系,判断是否存在如下情况:
Ruby自学手册!
Ruby ,一种简单快捷的面向对象(面向对象程序设计)脚本语言,在 20 世纪 90 年代由日本人松本行弘 (Yukihiro Matsumoto) 开发,遵守 G...
飞牛NAS系统盘占用过高排查与解决全记录(已有效解决)
📢NAS弹出系统盘占用过高预警?别慌!亲测解决全流程来啦~ 精准定位根源+安全迁移数据,附详细实操步骤,帮同款困扰的你高效释空间、少走弯路!
YOLOv13改进策略【Neck】| GSConv+Slim Neck:混合深度可分离卷积和标准卷积的轻量化网络设计
实时检测器架构的轻量级设计GsConv。
自学 ruby on ralils 那的那些坑《一》
我学ruby 看的是这本书,大家有兴趣可以参考看一下: 我最开始学ruby 的时候想偷懒,一开始采用的是AWS 的cloud9,(其介绍在我上面推荐的那本书里面也有介绍)但是因为这个是外网,访问特别慢,每次打开都需要好久,好吧,我承认让我放弃它的根本原因是因为我当时遇到了一个配置问题,搞不定。现在我采用的是虚拟机学的。 首先,那就是装yarn node.jsgem ruby ra...
【微服务】SpringBoot 整合 FastExcel 实现导入导出操作详解
SpringBoot 整合 FastExcel 实现导入导出操作详解
Ruby完全自学手册(图文教程)
Ruby 简介 Ruby,一种为简单快捷面向对象编程(面向对象程序设计)而创的脚本语言,由日本人松本行弘(まつもとゆきひろ,英译:Yukihiro Matsumoto,外号matz)开发,遵守GPL协议和Ruby License。Ruby的作者认为Ruby > (Smalltalk + Perl) / 2,表示Ruby是一个语法像Smalltalk一样完全面向对象、脚本执行、又有Perl强...
IEM模型,地表粗糙度模拟
利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟
深度学习工具包 DeepLearningToolbox
深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[](https://bitdeli.com/free "Bitdeli Badge")
简单了解Ruby与自学教程
Ruby,一种简单快捷的面向对象(面向对象程序设计)脚本语言,在20世纪90年代由日本人松本行弘(Yukihiro Matsumoto)开发,遵守GPL协议和Ruby License。它的灵感与特性来自于Perl、Smalltalk、Eiffel、Ada以及Lisp语言。由 Ruby 语...
WINCC7.3破解文件
WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!
《Ruby完全自学手册》
一直以为Ruby只是一个脚本语言,今天看到《Ruby完全自学手册》这本书的目录才发现,原来Ruby已经强大到这种地步了,真是误解Ruby了。
C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片
基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正
Ruby自学该怎么看书?
本文按照入门中级到深入的顺序,分享了12本学习 Ruby 的书籍。
电脑入门完全自学手册_「编程语言」Ruby完全自学手册
Ruby,一种简单快捷的面向对象(面向对象程序设计)脚本语言,在20世纪90年代由日本人松本行弘(Yukihiro Matsumoto)开发,遵守GPL协议和Ruby License。它的灵感与特性来自于 Perl、Smalltalk、Eiffel、Ada以及 Lisp 语言。由 Ruby 语言本身还发展出了JRuby(Java平台)、IronRuby(.NET平台)等其他平台的 Ruby 语言替...
51单片机编码自学_这是9个月的自学式编码看起来像什么
51单片机编码自学by Stephen Mayeux 斯蒂芬·马约(Stephen Mayeux) 这是9个月的自学式编码看起来像什么 (Here’s What 9 Months of Self-Taught Coding Looks Like) 只是划伤表面 (Just Scratching the Surface) Today marks 9 months since I embarke...
Ruby学习笔记一之概要
这个暑假回家没事干闲的蛋疼,正好手头有一本《七周七语言》,然后就开始从Ruby学起,到scala结束。中间的Io和prolog就被华丽丽的跳过了,因为prolog语法太奇葩,Io有没什么好的资料可以看,尽管我觉的Io应该会是一个强大的工具,而且语法超级简单。对象模型比起JavaScript好的不是一点两点,clone关键字真是为原型式编程量身打造的,new就显得不伦不类了,尤其是我从Java开始的。恩,废话就少提,下面我学习Ruby的各个部分。其中Ruby风格这一部分是开放的,因为我暂时还没有形成自己的风格
推荐项目:《Ruby编程基础范例》 —— 深入理解现代Ruby之道
推荐项目:《Ruby编程基础范例》 —— 深入理解现代Ruby之道 项目介绍 在编程的世界里,Ruby以其优雅和简洁著称,而ruby.fundamental项目正是为那些渴望深入了解并掌握Ruby现代编程原则与模式的开发者量身打造的一份宝藏。这个由Khusnetdinov维护的开源仓库,汇集了丰富的示例代码与详细描述,旨在帮助开发人员避免“陷阱”,领略Ruby语言的精髓。 项目技术分析 核心特性解...
65% 的程序员竟都是自学成才?_为啥学技术都自学
此外,对于想要将 JavaScript 融入日常的教学,它的可行性也具有很大的挑战。事实上,在美国报道的十大 CS 项目中,将 JavaScript 明确纳入到核心课程中的高校几乎为零,当然这在中国诸多高校中也不例外,因此想要掌握该门编程语言的学生必须依靠实践、个人项目或指导来学习。但据调查报告显示,在超过一万名的开发者中,有 37.7% 的人表示是通过学校和个人相结合的方式来学习编码,27.4% 的开发者表示是完全通过自学的方式学会了编程,相比之下,仅有 31.9% 的人仅通过学校教学的途径学习编程。
在网站改版中用正则表达式排查附件中的身份证号与手机号:误报、漏报与工程取舍
本文探讨在网站改版中利用正则表达式批量排查4200个附件中的身份证号与手机号。针对格式多样、人工核对耗时(约210小时)的难题,提出“先归一化后匹配”的工程策略,设计兼顾准确率与召回率的正则模式,并强调扫描件需OCR支持、Excel数字格式需文本化以避免漏检。通过构建“检测—定位—人工确认—处置留痕”闭环链路,实现从210小时到25分钟的效率跃升。文中警示误报漏报风险及落地四坑,明确适用边界:仅限固定格式敏感信息,不可替代业务判断。
4228



被折叠的 条评论
为什么被折叠?



