Tutorial by Examples: c

For any file operations, you will need the filesystem module: const fs = require('fs'); Reading a String fs.readFileSync behaves similarly to fs.readFile, but does not take a callback as it completes synchronously and therefore blocks the main thread. Most node.js developers prefer the asynch...
In this tutorial we're going to learn how to set up the PayPal Android SDK to process a simple payment via either a PayPal payment or a credit card purchase. At the end of this example, you should have a simple button in an application that, when clicked, will forward the user to PayPal to confirm a...
If you need to create a JSONObject and put data in it, consider the following example: // Create a new javax.json.JSONObject instance. JSONObject first = new JSONObject(); first.put("foo", "bar"); first.put("temperature", 21.5); first.put("year", 2016);...
If you need to get data from a JSONObject, consider the following example: String json = "{\"foo\":\"bar\",\"temperature\":21.5,\"year\":2016,\"message\":{\"Hello\":\"world\"},\"months\":[\"January\",\&qu...
Overview Attribute selectors can be used with various types of operators that change the selection criteria accordingly. They select an element using the presence of a given attribute or attribute value. Selector(1)Matched elementSelects elements...CSS Version[attr]<div attr>With attribute a...
Overview SelectorDescriptiondiv spanDescendant selector (all <span>s that are descendants of a <div>)div > spanChild selector (all <span>s that are a direct child of a <div>)a ~ spanGeneral Sibling selector (all <span>s that are siblings after an <a>)a + spanA...
There are two ids you will need from your plivo account. Replace authid and authtoken in this snippet with those values. The src value should also be a valid number assigned to your account. dst can be any number you want, or multiple seperated by <. notification sms { post = https://authid:a...
To send email notifications you need to add the following settings to your config file: #Using a company SMTP server (note only one can be define) smtpHost = mail.example.com:25 emailFrom = [email protected] #Using Gmail with TLS and username/password smtpHost = smtp.gmail.com:587 emailFrom ...
#Post to a slack.com chatroom via their Incoming Webhooks integration notification slack{ post = https://hooks.slack.com/services/abcdefg/abcdefg/abcdefghijklmnopqrstuvwxyz body = {"text": {{.|json}}} } #To customize the icon and user use: # body = {"text": {{.|js...
Alert incidents can be sent to other system using HTTP GET or HTTP POST requests. You can either send the rendered alert directly (using markdown in the template perhaps) or use body = ... {{.|json}} ... and contentType to send the alert data over as part of a JSON object. Another approach is to onl...
The extension method to be called is determined at compile-time based on the reference-type of the variable being accessed. It doesn't matter what the variable's type is at runtime, the same extension method will always be called. open class Super class Sub : Super() fun Super.myExtension()...
A stub is a light weight test double that provides canned responses when methods are called. Where a class under test relies on an interface or base class an alternative 'stub' class can be implemented for testing which conforms to the interface. So, assuming the following interface, public inter...
The terms Mock and Stub can often become confused. Part of the reason for this is that many mocking frameworks also provide support for creating Stubs without the verification step associated with Mocking. Rather than writing a new class to implement a stub as in the "Using a stub to supply c...
Mocks are used when it is necessary to verify the interactions between the system under test and test doubles. Care needs to be taken to avoid creating overly brittle tests, but mocking can be particularly useful when the method to test is simply orchestrating other calls. This test verifies that ...
import shutil source='//192.168.1.2/Daily Reports' destination='D:\\Reports\\Today' shutil.copytree(source, destination) The destination directory must not exist already.
When an API is marked with NS_REFINED_FOR_SWIFT, it will be prefixed with two underscores (__) when imported to Swift: @interface MyClass : NSObject - (NSInteger)indexOfObject:(id)obj NS_REFINED_FOR_SWIFT; @end The generated interface looks like this: public class MyClass : NSObject { publ...
To update a package use the following command: PM> Update-Package EntityFramework where EntityFramework is the name of the package to be updated. Note that update will run for all projects, and so is different from Install-Package EntityFramework which would install to "Default project&q...
PM> Uninstall-Package EntityFramework
PM> Uninstall-Package -ProjectName MyProjectB EntityFramework
Pull properties from an object passed into a function. This pattern simulates named parameters instead of relying on argument position. let user = { name: 'Jill', age: 33, profession: 'Pilot' } function greeting ({name, profession}) { console.log(`Hello, ${name} the ${pr...

Page 46 of 826