Tutorial by Examples: f

Create an interface decorated with a ServiceContract attribute and member functions decorated with the OperationContract attribute. namespace Service { [ServiceContract] interface IExample { [OperationContract] string Echo(string s); } } Create a concrete...
$(window).load() was deprecated in jQuery version 1.8 (and completely removed from jQuery 3.0) and as such should not be used anymore. The reasons for the deprecation are noted on the jQuery page about this event Caveats of the load event when used with images A common challenge developers attem...
Two ways to replace: by regex or by exact match. Note: the original String object will be unchanged, the return value holds the changed String. Exact match Replace single character with another single character: String replace(char oldChar, char newChar) Returns a new string resulting from...
You can create a UIColor from a hexadecimal number or string, e.g. 0xff00cc, "#FFFFFF" Swift Int Value extension UIColor { convenience init(hex: Int, alpha: CGFloat = 1.0) { let r = CGFloat((hex >> 16) & 0xff) / 255 let g = CGFloat((hex >> 08) &amp...
When you need to iterate over the list of jQuery elements. Consider this DOM structure: <div class="container"> <div class="red one">RED 1 Info</div> <div class="red two">RED 2 Info</div> <div class="red three"...
Filters allows you to apply a function to a variable. This function may take 0 or 1 argument. Here is the syntax: {{ variable|filter_name }} {{ variable|filter_name:argument }} Filters can be chained so this is perfectly valid: {{ variable|filter_name:argument|another_filter }} If transla...
Validates value as float, and converts to float on success. var_dump(filter_var(1, FILTER_VALIDATE_FLOAT)); var_dump(filter_var(1.0, FILTER_VALIDATE_FLOAT)); var_dump(filter_var(1.0000, FILTER_VALIDATE_FLOAT)); var_dump(filter_var(1.00001, FILTER_VALIDATE_FLOAT)); var_dump(filter_var('1', FILTE...
Declare your interface with Retrofit2 annotations: public interface BackendApiClient { @Multipart @POST("/uploadFile") Call<RestApiDefaultResponse> uploadPhoto(@Part("file\"; filename=\"photo.jpg\" ") RequestBody photo); } Where RestApiDef...
After launching Visual Studio 2015, go to File → New → Project. In the New Project dialog box, browse in the templates tree to Visual C# → Windows → Universal and select Blank App (Universal Windows). Next, we need to fill the form to describe the Application: Name: this is the name of the appli...
Interfaces should be named with nouns or noun phrases, or adjectives that describe behaviour. For example IComponent uses a descriptive noun, ICustomAttributeProvider uses a noun phrase and IPersistable uses an adjective. Interface names should be prefixed with the letter I, to indicate that the ty...
Asynchronously var fs = require('fs'); fs.stat('path/to/file', function(err) { if (!err) { console.log('file or directory exists'); } else if (err.code === 'ENOENT') { console.log('file or directory does not exist'); } }); Synchronously here, we must wr...
There may be situations where you have setup a pool of MySQL connections, but you have a number of queries you would like to run in sequence: SELECT 1; SELECT 2; You could just run then using pool.query as seen elsewhere, however if you only have one free connection in the pool you must wait un...
Callback-based: db.notification.email.find({subject: 'promisify callback'}, (error, result) => { if (error) { console.log(error); } // normal code here }); This uses bluebird's promisifyAll method to promisify what is conventionally callback-based code like above. blueb...
A view is most useful when it can be used to pull in data from more than one table. CREATE VIEW myview AS SELECT a.*, b.extra_data FROM main_table a LEFT OUTER JOIN other_table b ON a.id = b.id In mysql views are not materialized. If you now perform the simple query SELECT * FROM myview, my...
The default event for the Page object is Load event. Similarly, every control has a default event. For example, default event for the button control is the Click event. The default event handler could be created in Visual Studio, just by double clicking the control in design view. The following tab...
Loading the library (ql:quickload "fiveam") Define a test case (fiveam:test sum-1 (fiveam:is (= 3 (+ 1 2)))) ;; We'll also add a failing test case (fiveam:test sum2 (fiveam:is (= 4 (+ 1 2)))) Run tests (fiveam:run!) which reports Running test suite NIL Running test...
There are two common conventions for private fields: camelCase and _camelCaseWithLeadingUnderscore. Camel case public class Rational { private readonly int numerator; private readonly int denominator; public Rational(int numerator, int denominator) { // "this&q...
Remove all characters except digits, +- and optionally .,eE. var_dump(filter_var(1, FILTER_SANITIZE_NUMBER_FLOAT)); var_dump(filter_var(1.0, FILTER_SANITIZE_NUMBER_FLOAT)); var_dump(filter_var(1.0000, FILTER_SANITIZE_NUMBER_FLOAT)); var_dump(filter_var(1.00001, FILTER_SANITIZE_NUMBER_FLOAT)); v...
You've made a stash and wish to checkout only some of the files in that stash. git checkout stash@{0} -- myfile.txt
Consider the following example assuming that you have a ';'-delimited CSV to load into your database. 1;max;male;manager;12-7-1985 2;jack;male;executive;21-8-1990 . . . 1000000;marta;female;accountant;15-6-1992 Create the table for insertion. CREATE TABLE `employee` ( `id` INT NOT NULL , ...

Page 94 of 457