Tutorial by Examples: codes

The exit construct can be used to pass a return code to the executing environment. #!/usr/bin/php if ($argv[1] === "bad") { exit(1); } else { exit(0); } By default an exit code of 0 will be returned if none is provided, i.e. exit is the same as exit(0). As exit is not a ...
In the event that geolocation fails, your callback function will receive a PositionError object. The object will include an attribute named code that will have a value of 1, 2, or 3. Each of these numbers signifies a different kind of error; the getErrorCode() function below takes the PositionError....
In addition to .done, .fail and .always promise callbacks, which are triggered based on whether the request was successful or not, there is the option to trigger a function when a specific HTTP Status Code is returned from the server. This can be done using the statusCode parameter. $.ajax({ t...
An extension that allows you to use Unicode characters in lieu of certain built-in operators and names. ASCIIUnicodeUse(s)::∷has type->→function types, lambdas, case branches, etc.=>⇒class constraintsforall∀explicit polymorphism<-←do notation*★the type (or kind) of types (e.g., Int :: ★)&g...
If there are sections of code that you are considering removing or want to temporarily disable, you can comment it out with a block comment. /* Block comment around whole function to keep it from getting used. * What's even the purpose of this function? int myUnusedFunction(void) { int i =...
using System.Net; ... string serverResponse; try { // Call a method that performs an HTTP request (per the above examples). serverResponse = PerformHttpRequest(); } catch (WebException ex) { if (ex.Status == WebExceptionStatus.ProtocolError) { HttpWebResponse...
Two popular options are to use: ipython notation: In [11]: df = pd.DataFrame([[1, 2], [3, 4]]) In [12]: df Out[12]: 0 1 0 1 2 1 3 4 Alternatively (this is popular over in the python documentation) and more concisely: df.columns # Out: RangeIndex(start=0, stop=2, step=1) df[0...
You can save your code snippets for use later simply by drag and drop. For eg: if you have an NSLog statement that used for so many places somewhere else in the project, then you can save the NSLog statements to code snippets library. Drag the NSLog statement to code snippet library. Now you c...
Code source View the output here using System; using System.Diagnostics; using System.IO; using PdfSharp; using PdfSharp.Drawing; using PdfSharp.Pdf; using PdfSharp.Pdf.IO; namespace HelloWorld { /// <summary> /// This sample is the obligatory Hello World program. /// &l...
There are three types of code swaps that Instant run enables to support faster debugging and running app from your code in Android Studio. Hot Swap Warm Swap Cold Swap When are each of these swaps triggered? HOT SWAP is triggered when an existing method's implementation is changed. WARM SW...
If you are just starting a new project, it's important to think about how you want to handle code signing. If you are new to code signing, check out the WWDC session that describes the fundamentals of code signing in Xcode. To properly code-sign your app, you have to have the following resources o...
PhpStorm offers default settings for code styling for a large amount of languages based on best practices and common standards. But you can customize the styling for each language on a per-project base within the PhpStorm Settings > Editor > Code Style. Schemes Schemes are collections of ...
Currently there is no one-click-button method to actually enforce any code style guidelines across a team but there are two methods to make sure a certain code style is applied to your product. Import PhpStorm Code Style Schemes The first and more easier solution is to set up a code style scheme o...
PhpStorm already ships with a lot of predefined language schemes that are based on common code style guidelines and standards like PSR-2. There is kind of a hidden feature in the code style settings pages where you can import these standards and set them as your current configuration. To do so simp...
The attribute status_code contains the status code of the response good_req = requests.get('https://api.github.com/events') code_200 = good_req.status_code notfound_req = requests.get('https://api.github.com/not_found') code_404 = notfound_req.status_code requests.codes.__dict__ will provid...
[footag foo="value of 1" attribute-2="value of 2"] In wordpress admin we use pre defined shortcodes by writing the shortcode name inside square brackets and optionally adding attributes to it separating by space.
function footag_func( $atts ) { return "foo = {$atts['foo']}"; } add_shortcode( 'footag', 'footag_func' ); In plugins we can add shortcodes using the add_shortcode function. The shortcode can be used in any Wordpress page or post just by enclosing it in square brackets. [footag...
<?php echo do_shortcode("[footag foo='Hi! I am a foo output']"); ?> To print a shortcode using php use the do_shortcode function and echo the returned value.
The canonical way of writing code inside documentation is with the {@code } construct. If you have multiline code wrap inside <pre></pre>. /** * The Class TestUtils. * <p> * This is an {@code inline("code example")}. * <p> * You should wrap it in pre tags...
When signing personal scripts or when testing code signing it can be useful to create a self-signed code signing certificate. 5.0 Beginning with PowerShell 5.0 you can generate a self-signed code signing certificate by using the New-SelfSignedCertificate-cmdlet: New-SelfSignedCertificate -Friendl...

Page 1 of 2