First simple Example:
You have a ticket automat which gives exchange in coins with values 1, 2, 5, 10 and 20. The dispension of the exchange can be seen as a series of coin drops until the right value is dispensed. We say a dispension is optimal when its coin count is minimal for its value.
Let M ...
Matrix chain multiplication is an optimization problem that can be solved using dynamic programming. Given a sequence of matrices, the goal is to find the most efficient way to multiply these matrices. The problem is not actually to perform the multiplications, but merely to decide the sequence of t...
In order to create a scheduler,the entry needs to be created in
liferay-portlet.xml
provding scheduler class and trigger value for timing of scheduler triggering
<portlet-name>GetSetGo</portlet-name>
<icon>/icon.png</icon>
<scheduler-entry>
...
Part I : Setup the Mac machine to use shenzhen
Go to terminal
Install Shenzhen
sudo gem install shenzhen
sudo gem install nomad-cli
Download XCode command line utility
xcode-select --install
Popup shows up with the below text
The xcode-select command requires the command line d...
Ruby 2.3.0 added the safe navigation operator, &.. This operator is intended to shorten the paradigm of object && object.property && object.property.method in conditional statements.
For example, you have a House object with an address property, and you want to find the street_n...
If you want to get the properties of the file (like the name or the size) you can do it before using the File Reader. If we have the following html piece of code:
<input type="file" id="newFile">
You can access the properties directly like this:
document.getElementById...
Create a vector source
var vectorSource = new ol.source.Vector({});
Initiate Map Object and add vector Layer to the map and Source as the vectorSource
var map = new ol.Map({
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
}),
new ol.layer.Vector({
...
Quite often there is a need to glimpse the chosen color palette. One elegant solution is the following self defined function:
color_glimpse <- function(colors_string){
n <- length(colors_string)
hist(1:n,breaks=0:n,col=colors_string)
}
An example of use
color_glimpse(...
Function colors() lists all the color names that are recognized by R. There is a nice PDF where one can actually see those colors.
colorRampPalette creates a function that interpolate a set of given colors to create new color palettes. This output function takes n (number) as input and produces a...
When you have a huge JSON database, adding a value event listener doesn't make sense. It will return the huge JSON and parsing it would be time consuming. In such cases we can use pagination and fetch part of data and display or process it. Kind of like lazy loading or like fetching old chats when u...
In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0], 'C': ['a', 'b', 'c'],
'D': [True, False, True]})
In [2]: df
Out[2]:
A B C D
0 1 1.0 a True
1 2 2.0 b False
2 3 3.0 c True
Getting a python list from a series:
In [3]: df['...
Magento is a very popular eCommerce application. It offers a great deal of customization and abilities from initial install. Here are a few suggestions for optimizing a Magento installation.
Enabling Output Compression
In your .htaccess file for Magento you will find a section of text starting wit...
Merge JS and CSS Files
This particular tweak will reduce the number of HTTP requests on your eCommerce site.
[box type=”alert” border=”full”]Note: This can sometimes break some applications. After performing the following steps, please ensure that the site still performs as it did before enabling ...
The task is to find the length of the longest subsequence in a given array of integers such that all elements of the subsequence are sorted in ascending order. For example, the length of the longest increasing subsequence(LIS) for {15, 27, 14, 38, 26, 55, 46, 65, 85} is 6 and the longest increasing ...
Joda-Time is a robust alternative to the Java date and time classes.
Prior to Java SE 8, the standard Java date and time classes like java.util.Calendar are difficult to use and prone to errors. Joda-Time emerged as the de-facto standard library for date and time manipulation in many open-source-pr...
Using the library archive
Download the JAR and add it to the classpath for your Java project
Using a build tool
If you are using a build tool like Maven or Gradle:
Maven
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
...
Adding the aurelia-configuration to a cli application sometimes produces a build error. This is caused by a missing dependency so we simply add the dependency to the build bundle.
Try the following:
npm install deep-extend --save
npm install aurelia-configuration --save
Now add the followi...
The official site of angular-ui-bootstrap is here.
Follow the below instructions in order.
The list of files that are to be downloaded is in this link
Include all references in this order.
angular.js
angular-animate.js
ui-bootstrap-tpls-2.2.0.js (Reference to UI Bootstrap )
angular-sanitiz...
It's also possible to add multiple object types to a Static Dispatch function.
fn mammal_speak<T: Person + Dog>(mammal: &T) {
println!("{0}", mammal.speak());
}
fn main() {
let person = Person {};
let dog = Dog {};
mammal_speak(&person);
mammal...
A LocalDate is a date without a timezone. Consider using them when you are only concerned with the year, month, and day of month and are not interested in an exact time. For example, when we write our date of birth (such as 1960-01-01) we don't care about the timezone in which it happened.