Tutorial by Examples: bst

The regsub command is used for regular expression matching and substitution. set mydata {The yellow dog has the blues.} # create a new string; only the first match is replaced. set newdata [regsub {(yellow|blue)} $mydata green] puts $newdata The green dog has the blues. # replace the data in t...
Abstraction levels help determine when to split things up. Abstraction is achieved by implementing functionality with increasingly detailed code. The entry point of a macro should be a small procedure with a high abstraction level that makes it easy to grasp at a glance what's going on: Public Sub...
Bootstrapping Magento by calling: require_once 'app/Mage.php'; Mage::app(); // Your code This is the simplest way but not really the Magento way because we're not using class that extends Mage_Shell_Abstract - the class which when extended provides us with tools to parse command line arguments...
Magento way File resides in shell/custom.php <?php require_once' abstract.php'; class Stackoverflow_Shell_Custom extends Mage_Shell_Abstract { protected $_argname = array(); public function __construct() { parent::__construct(); // Time limit to infinity ...
Single characters can be extracted using array (square brace) syntax as well as curly brace syntax. These two syntaxes will only return a single character from the string. If more than one character is needed, a function will be required, i.e.- substr Strings, like everything in PHP, are 0-indexed....
There’s no API that can rename the blob file on Azure. This code snippet demonstrates how to rename a blob file in Microsoft Azure Blob Storage. StorageCredentials cred = new StorageCredentials("[Your storage account name]", "[Your storage account key]"); CloudBlobContainer c...
The trick is to use a look-behind with the regex \G, which means "end of previous match": String[] parts = str.split("(?<=\\G.{8})"); The regex matches 8 characters after the end of the last match. Since in this case the match is zero-width, we could more simply say "...
Same as the known length example, but insert the length into regex: int length = 5; String[] parts = str.split("(?<=\\G.{" + length + "})");
DateTime + Fixnum (days quantity) DateTime.new(2015,12,30,23,0) + 1 # => #<DateTime: 2015-12-31T23:00:00+00:00 ((2457388j,82800s,0n),+0s,2299161j)> DateTime + Float (days quantity) DateTime.new(2015,12,30,23,0) + 2.5 # => #<DateTime: 2016-01-02T11:00:00+00:00 ((2457390j,39600s,...
An NSPredicate can use substitution variables to allow values to be bound on the fly. Objective-C NSPredicate *template = [NSPredicate predicateWithFormat: @"self BEGINSWITH $letter"]; NSDictionary *variables = @{ @"letter": @"r" }; NSPredicate *beginsWithR = [templ...
The Binary Search Tree (BST) is a hierarchical data structure with a single pointer to the root node. The Node in the BST generally contains "items" (such as numbers or names) for fast look up. Each node has at-most two children (left and right). Every node is organized by some key data f...
Make sure that the NodeJS plugin is enabled Select your run configurations (screen) Select + > Node.js Remote Debug Make sure you enter the port selected above as well as the correct host Once those are configured simply run the debug target as you normally would and it will...
Provide an interface for creating families of related or dependent objects without specifying their concrete classes. In this example demonstrates the creation of different animal worlds for a computer game using different factories. Although the animals created by the Continent factories are diffe...
Substring returns the portion of string specified by the start and length parameters. var_dump(substr("Boo", 1)); // string(2) "oo" If there is a possibility of meeting multi-byte character strings, then it would be safer to use mb_substr. $cake = "cakeæøå"; var_d...
Scenario: You need to resolve a dependency when a method is called, not in the constructor. Solution: Inject an abstract factory into the constructor. When the method is called, it requests the dependency from the abstract factory, which in turn resolves it from the container. (Your class depends o...
Abstract base classes (ABCs) enforce what derived classes implement particular methods from the base class. To understand how this works and why we should use it, let's take a look at an example that Van Rossum would enjoy. Let's say we have a Base class "MontyPython" with two methods (jo...
If you would like to use vim in a manner similar to sed, you may use the -c flag to run an ex command from the command line. This command will run automatically before presenting the file to you. For example, to replace foo with bar: vim file.txt -c "s/foo/bar" This will open up the fi...
The Oracle Java Tutorials summarize Web Start as follows: Java Web Start software provides the power to launch full-featured applications with a single click. Users can download and launch applications, such as a complete spreadsheet program or an Internet chat client, without going through lengt...
There’s no API that can break the locked lease of blob storage in Microsoft Azure . This code snippet demonstrates break the locked lease of blob storage in Microsoft Azure (PowerShell). $key = (Get-AzureRmStorageAccountKey -ResourceGroupName $selectedStorageAccount.ResourceGroupName -name $select...
GNU awk supports a sub-string extraction function to return a fixed length character sequence from a main string. The syntax is *substr(string, start [, length ])* where, string is source string and start marks the start of the sub-string position you want the extraction to be done for an optio...

Page 4 of 5