In the PP file for writing puppet, many of the regular expressions for Ruby are used and are commonly used as follows:
Regular expression:
[Codesyntax lang= "Ruby"]
{}: The number of repetitions (such as {4} indicates that the preceding
Basisinserts a record into a sorted table to get an ordered table with an additional record. And the most important point is that it moves the record larger than the current element back, to empty out the position of "own" the insertion. The record
Hook methods are similar to event-driven devices that can perform a specific callback function after a particular event occurs, which is the hook method (more descriptive: The hook method can hook a particular event like a hook). , the Before\after
Single-piece method
Ruby allows you to add a method to a single object, a method that only takes effect on a single object, called a single piece method
Sample code
str = "Just a regular string"
def str.title?
Self.upcase = = Self
Some time ago to see a lot of people write the next sister script, I also write a
Module Commonhelper
require ' Nokogiri '
require ' Open-uri '
def down_load_xmz
site_url = ' http:// Www.xxx.com "for
index_page in 1..141
The Observer pattern (sometimes referred to as the Publish/subscribe model) is one of the software design patterns.In this pattern, a target object manages all the observer objects that are dependent on it and actively notifies it when its state
1. Establish an HTTP connection (send request parameters by Get method)
Require "Open-uri"
#如果有GET请求参数直接写在URI地址中
uri = ' Http://uri '
html_response = nil
open (URI) do |http|
Html_response = Http.read
end
puts Html_response
What is the appearance mode?
The appearance pattern provides a unified interface for a set of different interfaces in a subsystem. The façade defines the upper interface, making subsystems easier to use by reducing complexity and hiding
The following procedure has kept me in the middle of a long time, the concept of private in Ruby is really strange ...
Class Test Private
def test_print
puts ' test '
end
class Test2 here Plus self cannot invoke, private method '
JQUERY_UJS is a very important component for rails, and it is included in the default components of rails.
The jquery ujs contains some very handy features, such as confirmation dialog boxes, triggering Ajax, automatic Disable form submission
Numeric type (number)integral Type (integer)The integer type is divided into two, if within 31 digits (four bytes), that is the Fixnum instance. If more than, that is the Bignum instance.Integers range from-230 to 230-1 or-262 to 262-1. Integers in
Do not call the model layer directly from the view.Do not construct complex formats in the view, and output them to a method or model of the view helper.Use partial templates and layouts to reduce duplicate code.
Join the client side validation to
Avoid the metaprogramming of infinite loops.
Do not confuse the core class when writing a function library (do not use monkey patch).
code block forms are best used in string interpolation forms.When you use a string interpolation form, always
If you just need to find the text of the string, do not use regular expressions: string[' text '
For simple structures, you can query directly using the string[/re/] approach.
Match = string[/regexp/] # Get content of matched regexp
Use a consistent structure in the class definition.
Class Person
# Extend and include the Go
extend Somemodule
include Anothermodule
# constants are 5/>some_constant =
# Afterwards we have attribute macros
Write it out of the interpretation document code and let this part rest. It's not about playing.Use English to write notes.Use a space to separate annotations from symbols.Note more than one word should be capitalized and punctuation should be used.
There are several ways to create string objects, most commonly using string literals (literals), a sequence of characters between a set of single or double quotes. The difference between the two forms is that when you construct a literal, Ruby
Ruby web performance response time and rubyweb Response Time
You can calculate the loading time of a single web page.
Require 'watir-webdriver 'require 'watir-webdriver-performance 'B = watir: Browser. new: chromeb. goto "http: // 172.17.3.54: 230/
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.