This command is useful if you want to serve a single site in a directory and not the entire directory.
cd ~/Projects/my-blog/
valet link awesome-blog
Valet will create a symbolic link in ~/.valet/Sites which points to your current working directory.
After running the link command, you can acce...
cd ~/Projects
valet park
This command will register your current working directory as a path that Valet should search for sites. Now, any Laravel project you create within your "parked" directory will automatically be served using the http://folder-name.dev convention.
We can bind a class as a Singleton:
public function register()
{
App::singleton('my-database', function()
{
return new Database();
});
}
This way, the first time an instance of 'my-database' will be requested to the service container, a new instance will be created. Al...
Using the Control.Invoke() method you may move the execution of a method or function from a background thread to the thread that the control was created on, which is usually the UI (User Interface) thread. By doing so your code will be queued to run on the control's thread instead, which removes the...
Once a model object has been fetched, it becomes a fully realized instance of the class. As such, any additional methods can be accessed in forms and serializers (like Django Rest Framework).
Using python properties is an elegant way to represent additional values that are not stored in the databa...
While Value Converters can be comprised of either a toView or fromView method, in the below example we will be creating a basic Value Converter which just uses the toView method which accepts the value being sent to the view as the first argument.
to-uppercase.js
export class ToUppercaseValueConve...
A bi-directional value converter utilizes two methods in your Value Converter class: toView and fromView these methods are aptly named to signify which direction the data is flowing.
In our example we will be creating a prepend Value Converter which will make sure that an amount entered in our app ...
A Value Converter can be used alongside other value converters and you can infinitely chain them using the | pipe separator.
${myString | toUppercase | removeCharacters:'&,%,-,+' | limitTo:25}
The above theoretical example firstly applies toUppercase which capitalizes our string. Then it app...
Create project using STS (Spring Starter Project) or Spring Initializr (at https://start.spring.io ).
Add a Web Dependency in your pom.xml:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId&...
1) Use ng-repeat sparingly
Using ng-repeat in views generally results in poor performance, particularly when there are nested ng-repeat's.
This is super slow!
<div ng-repeat="user in userCollection">
<div ng-repeat="details in user">
{{details}}
</div...
$scope.$emit
Using $scope.$emit will fire an event name upwards through the scope hierarchy and notify to the $scope.The event life cycle starts at the scope on which $emit was called.
Working wireframe :
$scope.$broadcast
Using $scope.$broadcast will fire an event down the $scope. We can list...
First define the service (in this case it uses the factory pattern):
.factory('dataService', function() {
var dataObject = {};
var service = {
// define the getter method
get data() {
return dataObject;
},
// define the setter method
...
package
{
import flash.events.Event;
public class CustomEvent extends Event
{
public static const START:String = "START";
public static const STOP:String = "STOP";
public var data:*;
public function CustomEvent(type:Strin...
function isDaylightSavings(d:Date):Boolean {
var months:uint = 12;
var offset:uint = d.timezoneOffset;
var offsetCheck:Number;
while (months--) {
offsetCheck = (new Date(d.getFullYear(), months, 1)).timezoneOffset;
if (offsetCheck != offset)
ret...
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
...
If the right-hand side of the assignment is a matrix, then in each iteration the variable is assigned subsequent columns of this matrix.
some_matrix = [1, 2, 3; 4, 5, 6]; % 2 by 3 matrix
for some_column = some_matrix
display(some_column)
end
(The row vector version is a normal case of thi...
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...