Tutorial by Examples

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
We can use the Service Container as a Dependency Injection Container by binding the creation process of objects with their dependencies in one point of the application Let's suppose that the creation of a PdfCreator needs two objects as dependencies; every time we need to build an instance of PdfCr...
There are multiple ways to create a sequence. You can use functions from the Seq module: // Create an empty generic sequence let emptySeq = Seq.empty // Create an empty int sequence let emptyIntSeq = Seq.empty<int> // Create a sequence with one element let singletonSeq = Seq.s...
TCO is only available in strict mode As always check browser and Javascript implementations for support of any language features, and as with any javascript feature or syntax, it may change in the future. It provides a way to optimise recursive and deeply nested function calls by eliminating the n...
Tail Call Optimisation makes it possible to safely implement recursive loops without concern for call stack overflow or the overhead of a growing frame stack. function indexOf(array, predicate, i = 0) { if (0 <= i && i < array.length) { if (predicate(array[i])) { return...
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 , ...
Syntax is: LEFT ( string-expression , integer ) RIGHT ( string-expression , integer ) SELECT LEFT('Hello',2) --return He SELECT RIGHT('Hello',2) --return lo Oracle SQL doesn't have LEFT and RIGHT functions. They can be emulated with SUBSTR and LENGTH.SUBSTR ( string-expression, 1, intege...
What if you want to rollback the latest migration i.e recent operation, you can use the awesome rollback command. But remember that this command rolls back only the last migration, which may include multiple migration files php artisan migrate:rollback If you are interested in rolling back all o...
Break and continue statements can be followed by an optional label which works like some kind of a goto statement, resumes execution from the label referenced position for(var i = 0; i < 5; i++){ nextLoop2Iteration: for(var j = 0; j < 5; j++){ if(i == j) break nextLoop2Iteration; ...
console.time() can be used to measure how long a task in your code takes to run. Calling console.time([label]) starts a new timer. When console.timeEnd([label]) is called, the elapsed time, in milliseconds, since the original .time() call is calculated and logged. Because of this behavior, you can ...
Log into your AWS Console and click on Lambda under the Services tab. Under Functions you'll be able to Create a Lambda function using the same-labeled button. You'll be shown a screen where you can select a blueprint. These are simply starting points to existing Lambda functions fo...
When using async await in loops, you might encounter some of these problems. If you just try to use await inside forEach, this will throw an Unexpected token error. (async() => { data = [1, 2, 3, 4, 5]; data.forEach(e => { const i = await somePromiseFn(e); console.log(i); }); ...
/// <summary> /// Gets displayName from DataAnnotations attribute /// </summary> /// <typeparam name="TModel"></typeparam> /// <typeparam name="TProperty"></typeparam> /// <param name="htmlHelper"></param> /// <pa...
/// <summary> /// Creates simple button /// </summary> /// <param name="poHelper"></param> /// <param name="psValue"></param> /// <returns></returns> public static MvcHtmlString SubmitButton(this HtmlHelper poHelper, string ps...
Using the collect() helper, you can easily create new collection instances by passing in an array such as: $fruits = collect(['oranges', 'peaches', 'pears']); If you don't want to use helper functions, you can create a new Collection using the class directly: $fruits = new Illuminate\Support\Co...
You can select certain items out of a collection by using the where() method. $data = [ ['name' => 'Taylor', 'coffee_drinker' => true], ['name' => 'Matt', 'coffee_drinker' => true] ]; $matt = collect($data)->where('name', 'Matt'); This bit of code will select all it...
Angular has reputation for having awesome bidirectional data binding. By default, Angular continuously synchronizes values bound between model and view components any time data changes in either the model or view component. This comes with a cost of being a bit slow if used too much. This will hav...
AngularJS has digest loop and all your functions in a view and filters are executed every time the digest cycle is run. The digest loop will be executed whenever the model is updated and it can slow down your app (filter can be hit multiple times, before the page is loaded). You should avoid this: ...
Watchers needed for watch some value and detect that this value is changed. After call $watch() or $watchCollection new watcher add to internal watcher collection in current scope. So, what is watcher? Watcher is a simple function, which is called on every digest cycle, and returns some value. An...

Page 291 of 1336