Tutorial by Examples: ecto

public void iterateAndFilter() throws IOException { Path dir = Paths.get("C:/foo/bar"); PathMatcher imageFileMatcher = FileSystems.getDefault().getPathMatcher( "regex:.*(?i:jpg|jpeg|png|gif|bmp|jpe|jfif)"); try (Direc...
Current file You can get the name of the current PHP file (with the absolute path) using the __FILE__ magic constant. This is most often used as a logging/debugging technique. echo "We are in the file:" , __FILE__ , "\n"; Current directory To get the absolute path to the di...
You can destructure nested vectors: (def my-vec [[1 2] [3 4]]) (let [[[a b][c d]] my-vec] (println a b c d)) ;; 1 2 3 4
use lib 'includes'; use MySuperCoolModule; use lib 'includes'; adds the relative directory includes/ as another module search path in @INC. So assume that you have a module file MySyperCoolModule.pm inside includes/, which contains: package MySuperCoolModule; If you want, you can group as ma...
The right-hand side of the assignment in a for loop can be any row vector. The left-hand side of the assignment can be any valid variable name. The for loop assigns a different element of this vector to the variable each run. other_row_vector = [4, 3, 5, 1, 2]; for any_name = other_row_vector ...
A std::vector can be useful for returning a dynamic number of variables of the same type. The following example uses int as data type, but a std::vector can hold any type that is trivially copyable: #include <vector> #include <iostream> // the following function returns all integers...
BeautifulSoup has a limited support for CSS selectors, but covers most commonly used ones. Use select() method to find multiple elements and select_one() to find a single element. Basic example: from bs4 import BeautifulSoup data = """ <ul> <li class="item&quo...
In case your project needs to be based on a specific Symfony version, use the optional second argument of the new command: # use the most recent version in any Symfony branch $ symfony new my_project_name 2.8 $ symfony new my_project_name 3.1 # use a specific Symfony version $ symfony new my_...
Using the default constructor T variable = Activator.CreateInstance(typeof(T)); Using parameterized constructor T variable = Activator.CreateInstance(typeof(T), arg1, arg2);
First, import the libraries that work with files: from os import listdir from os.path import isfile, join, exists A helper function to read only files from a directory: def get_files(path): for file in listdir(path): full_path = join(path, file) if isfile(full_path): ...
Vector based graphics are represented by a plethora of data that must be computed by the CPU (vector points, arcs, colors, etc). Anything other than simple shapes with minimal points and straight lines will consume vast amounts of CPU resource. There is a "Cache as Bitmap" flag that can b...
Using the Vector.<T> type and the for each loop is more performant than a conventional array and for loop: Good: var list:Vector.<Sprite> = new <Sprite>[]; for each(var sprite:Sprite in list) { sprite.x += 1; } Bad: var list:Array = []; for (var i:int = 0; i < ...
The <algorithm> header provides a number of useful functions for working with sorted vectors. An important prerequisite for working with sorted vectors is that the stored values are comparable with <. An unsorted vector can be sorted by using the function std::sort(): std::vector<int&...
You can select elements with different selectors : by tag : "div" by class : ".class" by id : "#id" by attribute : "[color=blue]" multiple selectors (OR): "div1, div2, class1" multiple selectors (AND): "div1 div2 class1"
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...
begin returns an iterator to the first element in the sequence container. end returns an iterator to the first element past the end. If the vector object is const, both begin and end return a const_iterator. If you want a const_iterator to be returned even if your vector is not const, you can use ...
5.2 Objects in lua are garbage collected. Sometimes, you need to free some resource, want to print a message or do something else when an object is destroyed (collected). For this, you can use the __gc metamethod, which gets called with the object as argument when the object is destroyed. You could...
Support vector machines is a family of algorithms attempting to pass a (possibly high-dimension) hyperplane between two labelled sets of points, such that the distance of the points from the plane is optimal in some sense. SVMs can be used for classification or regression (corresponding to sklearn.s...
One of the uses of recursion is to navigate through a hierarchical data structure, like a file system directory tree, without knowing how many levels the tree has or the number of objects on each level. In this example, you will see how to use recursion on a directory tree to find all sub-directorie...
Using a custom inspector allows you to change the way a script is drawn in the Inspector. Sometimes you want to add extra information in the inspector for your script that isn't possible to do with a custom property drawer. Below is a simple example of a custom object that with using a custom inspe...

Page 4 of 13