Tutorial by Examples: f

angular.module('app', []) .controller('myController', ['$scope', function($scope){ $scope.person = { name: 'John Doe' }; }]); <div ng-app="app" ng-conroller="myController"> <input ng-model="person.name" /> <div ng-repeat="number i...
Be careful, this approach might be considered as a bad design for angular apps, since it requires programmers to remember both where functions are placed in the scope tree, and to be aware of scope inheritance. In many cases it would be preferred to inject a service (Angular practice - using scope ...
_.map is useful for changing a list into a different list in a purely declarative way. Rather than using imperative techniques like a while or for loop in javascript, you can just specify how you want to manipulate an element of a list and Use _.map to make a new list transformed by the functio...
Filtering a list down to only the elements we want to do. Lodash provides a function called _.filter filters elements based on the predicate function you provide. A predicate is a function that takes data in and returns either true or false. Let's look at how we'd get just the even numbers from...
In medical imaging, spectroscopy, image processing, cryptography and other areas of science and engineering it is often the case that one wishes to compute multidimensional Fourier transforms of images. This is quite straightforward in Matlab: (multidimensional) images are just n-dimensional matrice...
A minimal Dockerfile looks like this: FROM alpine CMD ["echo", "Hello StackOverflow!"] This will instruct Docker to build an image based on Alpine (FROM), a minimal distribution for containers, and to run a specific command (CMD) when executing the resulting image. Build an...
To copy files from the build context in a Docker image, use the COPY instruction: COPY localfile.txt containerfile.txt If the filename contains spaces, use the alternate syntax: COPY ["local file", "container file"] The COPY command supports wildcards. It can be used for ...
Group common operations Docker builds images as a collection of layers. Each layer can only add data, even if this data says that a file has been deleted. Every instruction creates a new layer. For example: RUN apt-get -qq update RUN apt-get -qq install some-package Has a couple of downsides: ...
_mycompletion() { local command_name="$1" # not used in this example local current_word="$2" local previous_word="$3" # not used in this example # COMPREPLY is an array which has to be filled with the possible completions # compgen is used to fi...
It is possible to save a Docker container's filesystem contents to a tarball archive file. This is useful in a pinch for moving container filesystems to different hosts, for example if a database container has important changes and it isn't otherwise possible to replicate those changes elsewhere. Pl...
Search engines won't index your products if you have a URL like the following: http://www.yourdomain.com/product.php?id=123 SEO friendly URL would look like http://www.yourdomain.com/123/product-name/. The following code helps achieve this without having to change product.php code. RewriteEng...
3.0 The most simple way is to use sorted(): let words = ["Hello", "Bonjour", "Salute", "Ahola"] let sortedWords = words.sorted() print(sortedWords) // ["Ahola", "Bonjour", "Hello", "Salute"] or sort() var mutable...
Let's swap the implementation of methodOne() and methodTwo() in our TestSwizzling class: class TestSwizzling : NSObject { dynamic func methodOne()->Int{ return 1 } } extension TestSwizzling { //In Objective-C you'd perform the swizzling in load(), //but t...
import fileinput replacements = {'Search1': 'Replace1', 'Search2': 'Replace2'} for line in fileinput.input('filename.txt', inplace=True): for search_for in replacements: replace_with = replacements[search_for] line = line.replace(search_for, replace_with...
Create a stream by selecting the elements from a stream that pass a certain condition is called filtering var newReleases = [ [ "id": 70111470, "title": "Die Hard", "boxart": "http://cdn-0.nflximg.com/images/2891/DieHard.j...
A HAVING clause filters the results of a GROUP BY expression. Note: The following examples are using the Library example database. Examples: Return all authors that wrote more than one book (live example). SELECT a.Id, a.Name, COUNT(*) BooksWritten FROM BooksAuthors ba INNER JOIN Aut...
The Kernel#require method will load files only once (several calls to require will result in the code in that file being evaluated only once). It will search your ruby $LOAD_PATH to find the required file if the parameter is not an absolute path. Extensions like .rb, .so, .o or .dll are optional. Re...
The method Kernel#autoload registers filename to be loaded (using Kernel::require) the first time that module (which may be a String or a symbol) is accessed. autoload :MyModule, '/usr/local/lib/modules/my_module.rb' The method Kernel#autoload? returns filename to be loaded if name is registere...
When files are not available, the require family will throw a LoadError. This is an example which illustrates loading optional modules only if they exist. module TidBits @@unavailableModules = [] [ { name: 'CoreExtend', file: 'core_extend/lib/core_extend' } \ , { name: 'Fs' ...
The Kernel#load method will evaluate the code in the given file. The search path will be constructed as with require. It will re-evaluate that code on every subsequent call unlike require. There is no load_relative. load `somefile`

Page 134 of 457