Tutorial by Examples

It is possible to query an object about its instance variables using instance_variables, instance_variable_defined?, and instance_variable_get, and modify them using instance_variable_set and remove_instance_variable: class Foo attr_reader :bar def initialize @bar = 42 end end f = F...
The Kernel exposes methods for getting the list of global_variables and local_variables: cats = 42 $demo = "in progress" p global_variables.sort #=> [:$!, :$", :$$, :$&, :$', :$*, :$+, :$,, :$-0, :$-F, :$-I, :$-K, :$-W, :$-a, #=> :$-d, :$-i, :$-l, :$-p, :$-v, :$-w, :$...
Classes and modules have the same methods for introspecting instance variables as any other object. Class and modules also have similar methods for querying the class variables (@@these_things): p Module.methods.grep(/class_variable/) #=> [:class_variables, :class_variable_get, :remove_class_va...
Ruby offers define_method as a private method on modules and classes for defining new instance methods. However, the 'body' of the method must be a Proc or another existing method. One way to create a method from raw string data is to use eval to create a Proc from the code: xml = <<ENDXML ...
Oh-my-zsh is a community-driven framework for managing your zsh configuration. It contains many plugins, which extend functionality, themes, which manage the appearance of the shell and the prompt, and helpful functions that will make your terminal much more powerful and customizable. You can create...
Pre-requirements Check the requirements for each device type you wish to automate and make sure they're installed before attempting to use Appium! iOS Requirements Mac OS X 10.10 or higher, 10.11.1 recommended XCode >= 6.0, 7.1.1 recommended Apple Developer Tools (iPhone simulator SDK, com...
If you want to xcopy files with specific type to a new folder keeping the current folder structure you need only to do this xcopy [SourcePath]*.mp3 [DestinationPath] /sy
It is a common practice to set application variables to an object scope. This keeps them easy to identify and distinguish from variables in other scopes. The Variables scope in a CFC is private to the CFC. When you set variables in this scope, they cannot be seen by pages that invoke the CFC. <...
pie view - (void)drawRect:(CGRect)rect { NSArray *data = @[@30, @15, @5, @17, @3, @10, @20]; // 1. context CGContextRef cxtRef = UIGraphicsGetCurrentContext(); CGPoint center = CGPointMake(150, 150); CGFloat radius = 150; __block CGFloat startAngle = 0; ...
Alert controller has a property which is used to put emphases on an action added in the alert controller. This property can be used to highlight a particular action for user attention.For objective C; @property(nonatomic, strong) UIAlertAction *preferredAction An action which is already added in...
The using of net.sf.jasperreports.export.xls.auto.filter property allow to add autofilter in generated xls file. <columnHeader> <band height="30" splitType="Stretch"> <staticText> <reportElement x="0" y="0" widt...
By Default, powershell would return the output to the calling Entity. Consider Below Example, Get-Process -Name excel This would simply, return the running process which matches the name excel, to the calling entity. In this case, the PowerShell Host. It prints something like, Handles NPM(K...
String Strings are created by wrapping the text with double quotes. Double-quoted strings can evalute variables and special characters. $myString = "Some basic text" $mySecondString = "String with a $variable" To use a double quote inside a string it needs to be escaped usi...
$hash = @{ city = 'Berlin' } $result = 'You should really visit {0}' -f $hash.city Write-Host $result #prints "You should really visit Berlin" Format strings can be used with the -f operator or the static [String]::Format(string format, args) .NET method.
Function Receive-TCPMessage { Param ( [Parameter(Mandatory=$true, Position=0)] [ValidateNotNullOrEmpty()] [int] $Port ) Process { Try { # Set up endpoint and start listening $endpoint = new-object System.Net.IPEndPoint(...
Function Send-TCPMessage { Param ( [Parameter(Mandatory=$true, Position=0)] [ValidateNotNullOrEmpty()] [string] $EndPoint , [Parameter(Mandatory=$true, Position=1)] [int] $Port , ...
Some websites don’t like to be scraped. In these cases you may need to simulate a real user working with a browser. Selenium launches and controls a web browser. from selenium import webdriver browser = webdriver.Firefox() # launch firefox browser browser.get('http://stackoverflow.com/questi...
To get a difference between two Calendars, use getTimeInMillis() method: Calendar c1 = Calendar.getInstance(); Calendar c2 = Calendar.getInstance(); c2.set(Calendar.DATE, c2.get(Calendar.DATE) + 1); System.out.println(c2.getTimeInMillis() - c1.getTimeInMillis()); //outputs 86400000 (24 * 60 * ...
The Abstract Factory Pattern is a creational design pattern that can be used to define specific instances or classes without having to specify the exact object that is being created. function Car() { this.name = "Car"; this.wheels = 4; } function Truck() { this.name = "Truck"; ...
template <class InputIterator, class UnaryPredicate> InputIterator find_if (InputIterator first, InputIterator last, UnaryPredicate pred); Effects Finds the first element in a range for which the predicate function pred returns true. Parameters first => iterator pointing to the begin...

Page 705 of 1336