Tutorial by Examples

Generally you should avoid using the default database role (often postgres) in your application. You should instead create a user with lower levels of privileges. Here we make one called niceusername and give it a password very-strong-password CREATE ROLE niceusername with PASSWORD 'very-strong-pas...
If we want to iterate backwards through a list or vector we can use a reverse_iterator. A reverse iterator is made from a bidirectional, or random access iterator which it keeps as a member which can be accessed through base(). To iterate backwards use rbegin() and rend() as the iterators for the e...
The arc4random_uniform() function is the simplest way to get high-quality random integers. As per the manual: arc4random_uniform(upper_bound) will return a uniformly distributed random number less than upper_bound. arc4random_uniform() is recommended over constructions like ''arc4random() % uppe...
The following code demonstrates usage of arc4random_uniform() to generate a random integer between 3 and 12: uint32_t randomIntegerWithinRange = arc4random_uniform(10) + 3; // A random integer between 3 and 12 This works to create a range because arc4random_uniform(10) returns an integer between...
hash( (1, 2) ) # ok hash( ([], {"hello"}) # not ok, since lists and sets are not hashabe Thus a tuple can be put inside a set or as a key in a dict only if each of its elements can. { (1, 2) } # ok { ([], {"hello"}) ) # not ok
One of the most common use of Sed is text substitution that can be achieved with the s command. In a terminal, type echo "Hello sed" | sed 's/sed/World/' and press Enter: $ echo "Hello sed" | sed 's/sed/World/' Hello World "Hello World" should be output to the ter...
Create an instance of UIScrollView with a CGRect as frame. Swift let scrollview = UIScrollView.init(frame: CGRect(x: 0, y: 0, width: 320, height: 400)) Objective-C UIScrollView *scrollview = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)];
The contentSize property must be set to the size of the scrollable content. This specifies the size of the scrollable area. Scrolling is visible when scrollable area i.e. contentSize is larger than the UIScrollView frame size. With Autolayout: When the scroll view's content is set up using autolay...
When referring to a worksheet, a range or individual cells, it is important to fully qualify the reference. For example: ThisWorkbook.Worksheets("Sheet1").Range(Cells(1, 2), Cells(2, 3)).Copy Is not fully qualified: The Cells references do not have a workbook and worksheet associated ...
C# allows user-defined types to control assignment and casting through the use of the explicit and implicit keywords. The signature of the method takes the form: public static <implicit/explicit> operator <ResultingType>(<SourceType> myType) The method cannot take any more argu...
Turn on: adb shell svc wifi enable Turn off: adb shell svc wifi disable
Command: adb devices Result example: List of devices attached emulator-5554 device PhoneRT45Fr54 offline 123.454.67.45 no device First column - device serial number Second column - connection status Android documentation
Enter these commands in Android device Terminal su setprop service.adb.tcp.port 5555 stop adbd start adbd After this, you can use CMD and ADB to connect using the following command adb connect 192.168.0.101.5555 And you can disable it and return ADB to listening on USB with setprop servi...
Start ADB: adb kill-server Stop ADB: adb start-server
To generate random permutation of 5 numbers: sample(5) # [1] 4 5 3 1 2 To generate random permutation of any vector: sample(10:15) # [1] 11 15 12 10 14 13 One could also use the package pracma randperm(a, k) # Generates one random permutation of k of the elements a, if a is a vector, # ...
'if only one area (not multiple areas): With Range("A3:D20") Debug.Print .Cells(.Cells.CountLarge).Row Debug.Print .Item(.Cells.CountLarge).Row 'using .item is also possible End With 'Debug prints: 20 'with multiple areas (also works if only one area): Dim rngArea As Range,...
Many developers like to customize the font, text, and background color of their IDE's. You can do this in Xcode by opening the app preference pane, either by going to XCODE->Preferences, or by pressing '⌘,' With the preference pane open you can click on the 'Fonts and Colors' tab. From her...
Create an individual Localizable.strings file for each language. The right side would be different for each language. Think of it as a key-value pair: "str" = "str-language"; Access str in Objective-C: //Try to provide description on the localized string to be able to create...
In Python 3.x all classes are new-style classes; when defining a new class python implicitly makes it inherit from object. As such, specifying object in a class definition is a completely optional: Python 3.x3.0 class X: pass class Y(object): pass Both of these classes now contain object in ...
A Simple FXML document outlining an AnchorPane containing a button and a label node: <?xml version="1.0" encoding="UTF-8"?> <?import java.lang.*?> <?import java.util.*?> <?import javafx.scene.*?> <?import javafx.scene.control.*?> <?import ...

Page 192 of 1336