Laravel's events allows to implement the Observer pattern. This can be used to send a welcome email to a user whenever they register on your application.
New events and listeners can be generated using the artisan command line utility after registering the event and their particular listener in App...
Both #save and #destroy come wrapped in a transaction that ensures that whatever you do in validations or callbacks will happen under its protected cover. So you can use validations to check for values that the transaction depends on or you can raise exceptions in the callbacks to rollback, includin...
Create a file named launch-server.yaml, that will be our playbook.
The first part of the playbook is a list of hosts that your playbook will run on, we only have one, localhost.
- hosts: localhost
Then we need to define a list of tasks to perform in this playbook. We will only have one that lau...
Nesting is probably most often used to create more specific selectors, but it can also be used simply for code organization. Using the @at-root directive, you can ‘jump out’ of where you nest it in your Sass, bringing you back at the top level. Doing this allows you to keep styles grouped without cr...
The following will prompt a user for input, and then store that input as a string (text) in a variable. The variable is then used to give a message to the user.
#!/usr/bin/env bash
echo "Who are you?"
read name
echo "Hello, $name."
The command read here reads one line of ...
In Sinatra, routing is how your app responds to requests, by the path of the request (e.g. /welcome) and by the HTTP verb used (e.g. GET or POST). The way a request is written is as follows:
<http-verb> <path> do
<code block to execute when this route is requested>
end
He...
To print a test field (TestField) from a test feature class (TestFC) in a test file geodatabase (Test.gdb) located in a temporary folder (C:\Temp):
with arcpy.da.SearchCursor(r"C:\Temp\Test.gdb\TestFC",["TestField"]) as cursor:
for row in cursor:
print row[0]
void main()
{
import std.stdio : writeln;
int[] arr = [1, 3, 4];
int i = 0;
assert(arr.length > 0, "Array must contain at least one element");
do
{
arr[i++] *= 2;
} while (i < arr.length);
writeln(arr); // [2, 6, 8]
}
If an arithmetic operation that yields a floating point type produces a value that is not in the range of representable values of the result type, the behavior is undefined according to the C++ standard, but may be defined by other standards the machine might conform to, such as IEEE 754.
float x =...
When either a signed or unsigned integer is converted to a signed integer type, and its value is not representable in the destination type, the value produced is implementation-defined. Example:
// Suppose that on this implementation, the range of signed char is -128 to +127 and
// the range of un...
GetHashCode has major performance effects on Dictionary<> and HashTable.
Good GetHashCode Methods
should have an even distribution
every integer should have a roughly equal chance of returning for a random instance
if your method returns the same integer (e.g. the constant '999') for e...
Add this line at the beginning of your view.
<?php
use yii\widgets\Pjax;
?>
Add the following two lines around the content that needs partial updating.
<?php Pjax::begin(['id'=>'id-pjax']); ?>
Content that needs to be updated
<?php Pjax::end(); ?>
reload pjax
$.pjax...
/*add this code to your function.php file
now your api will include transaction_id
*/
add_action( 'woocommerce_api_order_response', 'my_woocommerce_api_order', 10, 2);
function my_woocommerce_api_order( $data ) {
//you can do anything with the $data here lets add the transaction id
...
public class OnSwipeListener implements View.OnTouchListener {
private final GestureDetector gestureDetector;
public OnSwipeListener(Context context) {
gestureDetector = new GestureDetector(context, new GestureListener());
}
@Override
public boolean onTouch(Vi...
Create a new console application with one line in the Main method: Console.WriteLine("Hello World")
Remember the path to the .csproj file and replace it in the example.
Create a new Console Application and install the Microsoft.CodeAnalysis NuGet package and try the following code:
cons...
Create a new console application with one line in the Main method: Console.WriteLine("Hello World")
Remember the path to the .vbproj file and replace it in the example.
Create a new Console Application and install the Microsoft.CodeAnalysis NuGet package and try the following code:
Cons...
you can custom class below one
private final String PROTOCOL_CONTENT_TYPE = String.format("application/json; charset=%s", PROTOCOL_CHARSET);
public BooleanRequest(int method, String url, String requestBody, Response.Listener<Boolean> listener, Response.ErrorListener errorList...