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.
In a Service Provider register method we can bind an interface to an implementation:
public function register()
{
App::bind( UserRepositoryInterface::class, EloquentUserRepository::class );
}
From now on, everytime the app will need an instance of UserRepositoryInterface, Larave...
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...
Solution 1:
$('#parent').prepend($('#child'));
Solution 2:
$('#child').prependTo($('#parent'));
Both solutions are prepending the element #child (adding at the beginning) to the element #parent.
Before:
<div id="parent">
<span>other content</span>
</di...
Solution 1:
$('#parent').append($('#child'));
Solution 2:
$('#child').appendTo($('#parent'));
Both solutions are appending the element #child (adding at the end) to the element #parent.
Before:
<div id="parent">
<span>other content</span>
</div>
<d...
from pandas_datareader import data
# Only get the adjusted close.
aapl = data.DataReader("AAPL",
start='2015-1-1',
end='2015-12-31',
data_source='yahoo')['Adj Close']
>>> aapl.plot(title='AAPL Adj. C...
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...
# no error, even the subscript is out of range.
julia> sub2ind((3,3), 3, 4)
12
One cannot determine whether a subscript is in the range of an array by comparing its index:
julia> sub2ind((3,3), -1, 2)
2
julia> 0 < sub2ind((3,3), -1, 2) <= 9
true
The default namespace is the namespace corresponding to the absence of any prefix. It can be declared with the special xmlns attribute.
<?xml version="1.0"?>
<foo xmlns="http://www.example.com/my-namespace">
<!-- the element foo is in the namespace
htt...
<?xml version="1.0"?>
<?speech-generator voice="Siri"?>
<root xmlns:vocabulary="http://www.example.com/vocabulary">
<!-- These are the standard greetings -->
<vocabulary:greetings>
<vocabulary:greeting xml:lang="en-US&q...
To cancel a call to requestAnimationFrame, you need the id it returned from when it was last called. This is the parameter you use for cancelAnimationFrame. The following example starts some hypothetical animation then pauses it after one second.
// stores the id returned from each call to reques...
Dim inputCode As Integer = Console.Read()
Console.Read() awaits input from the user and, upon receipt, returns an integer value corresponding with the character code of the entered character. If the input stream is ended in some way before input can be obtained, -1 is returned instead.
Dim inputChar As ConsoleKeyInfo = Console.ReadKey()
Console.ReadKey() awaits input from the user and, upon receipt, returns an object of class ConsoleKeyInfo, which holds information relevant to the character which the user provided as input. For detail regarding the information provided, visit t...
itertools.takewhile enables you to take items from a sequence until a condition first becomes False.
def is_even(x):
return x % 2 == 0
lst = [0, 2, 4, 12, 18, 13, 14, 22, 23, 44]
result = list(itertools.takewhile(is_even, lst))
print(result)
This outputs [0, 2, 4, 12, 18].
Not...
itertools.dropwhile enables you to take items from a sequence after a condition first becomes False.
def is_even(x):
return x % 2 == 0
lst = [0, 2, 4, 12, 18, 13, 14, 22, 23, 44]
result = list(itertools.dropwhile(is_even, lst))
print(result)
This outputs [13, 14, 22, 23, 44].
...
C++11
Deriving a class may be forbidden with final specifier. Let's declare a final class:
class A final {
};
Now any attempt to subclass it will cause a compilation error:
// Compilation error: cannot derive from final class:
class B : public A {
};
Final class may appear anywhere in cl...
Addition + and subtraction - operations can be used to combine delegate instances. The delegate contains a list of the assigned delegates.
using System;
using System.Reflection;
using System.Reflection.Emit;
namespace DelegatesExample {
class MainClass {
private delegate void MyD...
In contrast of a full template specialization partial template specialization allows to introduce template with some of the arguments of existing template fixed. Partial template specialization is only available for template class/structs:
// Common case:
template<typename T, typename U>
st...
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...