Tutorial by Examples: ci

from scipy.sparse import csr_matrix A = csr_matrix([[1,0,2],[0,3,0]]) >>>A <2x3 sparse matrix of type '<type 'numpy.int64'>' with 3 stored elements in Compressed Sparse Row format> >>> A.todense() matrix([[1, 0, 2], [0, 3, 0]]) >>&g...
Self-referential association is used to associate a model with itself. The most frequent example would be, to manage association between a friend and his follower. ex. rails g model friendship user_id:references friend_id:integer now you can associate models like; class User < ActiveRecord:...
The aar file doesn't contain the transitive dependencies and doesn't have a pom file which describes the dependencies used by the library. It means that, if you are importing a aar file using a flatDir repo you have to specify the dependencies also in your project. You should use a maven repositor...
Creating a custom ImplicitNamingStrategy allows you to tweak how Hibernate will assign names to non-explicitly named Entity attributes, including Foreign Keys, Unique Keys, Identifier Columns, Basic Columns, and more. For example, by default, Hibernate will generate Foreign Keys which are hashed an...
Mongoid allows the classic ActiveRecord associations: One-to-one: has_one / belongs_to One-to-many: has_many / belongs_to Many-to-many: has_and_belongs_to_many To add an association (lets say the User has_many posts), you can add this to your User model file: has_many :posts and this to ...
Mongoid allows Embedded Associations: One-to-one: embeds_one / embedded_in One-to-many: embeds_many / embedded_in To add an association (lets say the User embeds_many addresses), add this to your User file: embeds_many :addresses and this to your Address model file: embedded_in :user ...
XML <Galaxy> <name>Milky Way</name> <CelestialObject name="Earth" type="planet"/> <CelestialObject name="Sun" type="star"/> </Galaxy> XPATH /Galaxy/*[@name] or //*[@name] OUTPUT <CelestialObje...
XML <Galaxy> <name>Milky Way</name> <CelestialObject name="Earth" type="planet"/> <CelestialObject name="Sun" type="star"/> </Galaxy> XPATH /Galaxy/*[@name='Sun'] or //*[@name='Sun'] OUTPUT <C...
Dereferencing happens with the . operator: Object obj = new Object(); String text = obj.toString(); // 'obj' is dereferenced. Dereferencing follows the memory address stored in a reference, to the place in memory where the actual object resides. When an object has been found, the requested meth...
std::ifstream f("file.txt"); if (f) { std::stringstream buffer; buffer << f.rdbuf(); f.close(); // The content of "file.txt" is available in the string `buffer.str()` } The rdbuf() method returns a pointer to a streambuf that can be pushed into buffer...
$ cat ip.txt address range substitution pattern sample Nth line $ sed -n '2p' ip.txt range $ sed '3d' ip.txt address range pattern sample Last line $ sed -n '$p' ip.txt sample
Given two types T and U, &T will coerce (implicitly convert) to &U if and only if T implements Deref<Target=U> This allows us to do things like this: fn foo(a: &[i32]) { // code } fn bar(s: &str) { // code } let v = vec![1, 2, 3]; foo(&v); // &Vec&l...
Environments in R can be explicitly call and named. Variables can be explicitly assigned and call to or from those environments. A commonly created environment is one which encloses package:base or a subenvironment within package:base. e1 <- new.env(parent = baseenv()) e2 <- new.env(parent ...
// Returns the nth number in the Fibonacci sequence function fibonacci(n) { if (n === 1 || n === 0) { return 1; } else { return fibonacci(n - 1) + fibonacci(n - 2); } }
One of the most useful queries for end users of large RDBMS's is a search of an information schema. Such a query allows users to rapidly find database tables containing columns of interest, such as when attempting to relate data from 2 tables indirectly through a third table, without existing knowl...
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...
The method compareTo should be used to compare BigDecimals: BigDecimal a = new BigDecimal(5); a.compareTo(new BigDecimal(0)); // a is greater, returns 1 a.compareTo(new BigDecimal(5)); // a is equal, returns 0 a.compareTo(new BigDecimal(10)); // a is less, returns -1 Commonly you shou...
This function returns the floating-point remainder of the division of x/y. The returned value has the same sign as x. #include <math.h> /* for fmod() */ #include <stdio.h> /* for printf() */ int main(void) { double x = 10.0; double y = 5.1; double modulus = fmod(x,...
To clone a specific branch of a repository, type --branch <branch name> before the repository url: git clone --branch <branch name> <url> [directory] To use the shorthand option for --branch, type -b. This command downloads entire repository and checks out <branch name>. ...
If you've got multiple implementations of the same interface, Spring can autowire them all into a collection object. I'm going to use an example using a Validator pattern1 Foo Class: public class Foo { private String name; private String emailAddress; private String errorMessage;...

Page 13 of 42