Tutorial by Examples: er

To get a list of available serial ports use python -m serial.tools.list_ports at a command prompt or from serial.tools import list_ports list_ports.comports() # Outputs list of available serial ports from the Python shell.
To get started with unit testing PowerShell code using the Pester-module, you need to be familiar with three keywords/commands: Describe: Defines a group of tests. All Pester test files needs at least one Describe-block. It: Defines an individual test. You can have multiple It-blocks inside a De...
string is defined as alias string = immutable(char)[];: so need to use dup to make a mutable char array, before it can be reversed: import std.stdio; import std.string; int main() { string x = "Hello world!"; char[] x_rev = x.dup.reverse; writeln(x_rev); // !dlr...
After running your grammar .g4 file with ANTLR.jar you should have a number of files generated such as : 1.yourGrammarNameListener.py 2.yourGrammarNameParser.py 3.yourGrammarName.tokens ... To use these in a python project include the Python runtime in your workspace so any application you ar...
Frequently you may want to filter structures and other complex data types. Searching an array of structs for entries that contain a particular value is a very common task, and easily achieved in Swift using functional programming features. What's more, the code is extremely succinct. struct Painter...
To easily select a buffer by filename, you can use: :b [part_of_filename]<Tab><Tab><Tab>...<Enter> The first Tab will expand the word to a full filename, and subsequent Tab presses will cycle through the list of possible matches. When multiple matches are available, you ...
<C-^> will switch to and from the previous edited file. On most keyboards <C-^> is CTRL-6. 3<C-^> will switch to buffer number 3. This is very quick, but only if you know the buffer number. You can see the buffer numbers from :ls or from a plugin such as MiniBufExplorer.
THREE.CylinderGeometry build cylinders. Cylinder Continuing from the previous example, the code to create the box could be replaced with the below. //Makes a new cylinder with // - a circle of radius 5 on top (1st parameter) // - a circle of radius 5 on the bottom (2nd parameter) // - a height...
extension String { func matchesPattern(pattern: String) -> Bool { do { let regex = try NSRegularExpression(pattern: pattern, options: NSRegularExpressionOptions(rawValue: 0)) let range: NSRange = NSMakeRange(...
super keyword performs important role in three places Constructor Level Method Level Variable Level Constructor Level super keyword is used to call parent class constructor. This constructor can be default constructor or parameterized constructor. Default constructor : super(); Pa...
Label Tag Helper can be used to render label for a model property. It replaces method Html.LabelFor in previous versions of MVC. Let's say you have a model: public class FormViewModel { public string Name { get; set; } } In the view you can use label HTML element and asp-for tag helper: ...
You may need to render some content in view, which is specific to some environment only. To achieve this goal you can use Environment tag helper: <environment names="Development"> <h1>This is heading for development environment</h1> </environment> <envi...
Often one want to show the result of a command executed by root to other users. The tee command allows easily to write a file with user perms from a command running as root: su -c ifconfig | tee ~/results-of-ifconfig.txt Only ifconfig runs as root.
In the old fashion way for collection null check List<Object> someObjects = methodGetList(); for (Object obj : someObjects) { if (obj == null) { continue; } doSomething(obj); } With the Objects.nonNull method and Java8 Stream API, we can do the above in this way: ...
Consider this example: public class ThreadTest implements Runnable { private boolean stop = false; public void run() { long counter = 0; while (!stop) { counter = counter + 1; } System.out.println("Counted " + counter);...
Suppose you have a long list of elements and you are only interested in every other element of the list. Perhaps you only want to examine the first or last elements, or a specific range of entries in your list. Python has strong indexing built-in capabilities. Here are some examples of how to achie...
An observable is created from the TextChanged event of the TextBox. Also any input is only selected if it's different from the last input and if there was no input within 0.5 seconds. The output in this example is sent to the console. Observable .FromEventPattern(textBoxInput, "TextChan...
import java.awt.EventQueue; import java.awt.GridLayout; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JTextArea; import javax.sw...
If you want to have a table organized in column-store format instead of row store, add INDEX cci CLUSTERED COLUMNSTORE in definition of table: DROP TABLE IF EXISTS Product GO CREATE TABLE Product ( ProductID int, Name nvarchar(50) NOT NULL, Color nvarchar(15), Size nvarchar(5)...
CREATE CLUSTERED COLUMNSTORE INDEX enables you to organize a table in column format: DROP TABLE IF EXISTS Product GO CREATE TABLE Product ( Name nvarchar(50) NOT NULL, Color nvarchar(15), Size nvarchar(5) NULL, Price money NOT NULL, Quantity int ) GO CREATE CLUSTERED C...

Page 253 of 417