Tutorial by Examples: di

Instance variables are unique for each instance, while class variables are shared by all instances. class C: x = 2 # class variable def __init__(self, y): self.y = y # instance variable C.x # 2 C.y # AttributeError: type object 'C' has no attribute 'y' c1 = C(3) c1....
public class TrustLoader { public static void main(String args[]) { try { //Gets the inputstream of a a trust store file under ssl/rpgrenadesClient.jks //This path refers to the ssl folder in the jar file, in a jar file in the same directory ...
A Swift String is made of Unicode code points. It can be decomposed and encoded in several different ways. let str = "ที่👌①!" Decomposing Strings A string's characters are Unicode extended grapheme clusters: Array(str.characters) // ["ที่", "👌", "①", ...
Per paragraph 6.5/5 of both C99 and C11, evaluation of an expression produces undefined behavior if the result is not a representable value of the expression's type. For arithmetic types, that's called an overflow. Unsigned integer arithmetic does not overflow because paragraph 6.2.5/9 applies, ca...
Given the following input: aaaaaAlazyZgreeedyAlaaazyZaaaaa We will use two patterns: one greedy: A.*Z, and one lazy: A.*?Z. These patterns yield the following matches: A.*Z yields 1 match: AlazyZgreeedyAlaaazyZ (examples: Regex101, Rubular) A.*?Z yields 2 matches: AlazyZ and AlaaazyZ (exampl...
For Alerts since iOS 8, you would use a UIAlertController but for versions before, you would have used a UIAlertView, which is now deprecated. 8.0 var alert = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create(otherTitle, UIAlertActionStyl...
We can make an AJAX request to Stack Exchange's API to retrieve a list of the top JavaScript questions for the month, then present them as a list of links. If the request fails or the returns an API error, our promise error handling displays the error instead. 6 View live results on HyperWeb. c...
Use the --number flag to print line numbers before each line. Alternatively, -n does the same thing. $ cat --number file 1 line 1 2 line 2 3 4 line 4 5 line 5 To skip empty lines when counting lines, use the --number-nonblank, or simply -b. $ cat -b file 1 line 1 2 line ...
This is how to send an SMS text message from a US number using Twilio's Node.js SDK. First you need to install the Node.js client using: npm install twilio Then, you have to create an account on their website. Once you have an account, you'll need the account SID and auth token that you can fi...
Consider the below list comprehension: >>> def f(x): ... import time ... time.sleep(.1) # Simulate expensive function ... return x**2 >>> [f(x) for x in range(1000) if f(x) > 10] [16, 25, 36, ...] This results in two calls to f(x) for 1,000 values of...
Browse to File > New > Project to bring you up the New Project dialog. Navigate to Visual C# > iOS > iPhone and select Single View App: Give your app a Name and press OK to create your project. Select the Mac Agent icon from the toolbar, as illustrated below: Select the Mac tha...
Cascading and specificity are used together to determine the final value of a CSS styling property. They also define the mechanisms for resolving conflicts in CSS rule sets. CSS Loading order Styles are read from the following sources, in this order: User Agent stylesheet (The styles supplied b...
require Exporter; This will ensure that the Exporter module is loaded at runtime if it hasn't already been imported. (See also: perldoc -f require.) N.B.: Most users should use modules rather than require them. Unlike use, require does not call the module's import method and is executed at runti...
To conditionally include a block of code, the preprocessor has several directives (e.g #if, #ifdef, #else, #endif, etc). /* Defines a conditional `printf` macro, which only prints if `DEBUG` * has been defined */ #ifdef DEBUG #define DLOG(x) (printf(x)) #else #define DLOG(x) #endif Norm...
If the preprocessor encounters an #error directive, compilation is halted and the diagnostic message included is printed. #define DEBUG #ifdef DEBUG #error "Debug Builds Not Supported" #endif int main(void) { return 0; } Possible output: $ gcc error.c error.c: error: #e...
Indexes can have several characteristics that can be set either at creation, or by altering existing indexes. CREATE CLUSTERED INDEX ix_clust_employee_id ON Employees(EmployeeId, Email); The above SQL statement creates a new clustered index on Employees. Clustered indexes are indexes that dict...
Composer generates a vendor/autoload.php file. You might simply include this file and you will get autoloading for free. require __DIR__ . '/vendor/autoload.php'; This makes working with third-party dependencies very easy. You can also add your own code to the Autoloader by adding an autoload ...
object HelloWorld extends App { println("Hello, world!") } Live demo By extending the App trait, you can avoid defining an explicit main method. The entire body of the HelloWorld object is treated as "the main method". 2.11.0 Delayed Initialization Per the official d...
Conditional comments can be used to customize code for different versions of Microsoft Internet Explorer. For example, different HTML classes, script tags, or stylesheets can be provided. Conditional comments are supported in Internet Explorer versions 5 through 9. Older and newer Internet Explorer ...
An if statement checks whether a Bool condition is true: let num = 10 if num == 10 { // Code inside this block only executes if the condition was true. print("num is 10") } let condition = num == 10 // condition's type is Bool if condition { print("num is 10&...

Page 9 of 164