Tutorial by Examples: f

add_action( 'init', function() { // do something here } ); Using a function block to hook a set of instructions. With the init hook, the set of instructions will be executed right after wordpress has finished loading the necessary components.
function my_init_function() { // do something here } add_action( 'init', 'my_init_function' ); Using the name of the function to hook a set of instructions. With the init hook, the set of instructions will be executed right after wordpress has finished loading the necessary components. ...
if (a > b) { trace("You win!"); } else if (a == b) { trace("It's a draw!"); } else { trace("You lose!"); } // Assigning the evaluated expression to a variable var message = if (a > b) { "You win!"; } else if (a == b) { &...
A loop is a control flow structure to definitely or indefinitely run a set of statement written only once in code, until a certain condition is met or the process is terminated. Condition loops These loops are repeated based on the state of their conditions. For loops For loops are usually run...
If different users need different datetime format then you may need to parse your incoming date string to actual date according to the format. In this case this snippet may help you. public class DateTimeBinder : DefaultModelBinder { public override object BindModel(ControllerContext control...
In this example you'll learn how to share a file with other apps. We'll use a pdf file in this example although the code works with every other format as well. The roadmap: Specify the directories in which the files you want to share are placed To share files we'll use a FileProvider, a class all...
This example shows how to use the Firebase Cloud Messaging(FCM) platform. FCM is a successor of Google Cloud Messaging(GCM). It does not require C2D_MESSAGE permissions from the app users. Steps to integrate FCM are as follows. Create sample hello world project in Android Studio Your Android...
Scala's implementation of type classes is rather verbose. One way to reduce the verbosity is to introduce so-called "Operation Classes". These classes will automatically wrap a variable/value when they are imported to extend functionality. To illustrate this, let us first create a simple ...
An element containing a single child, with some framing options. Frame have a default Xamarin.Forms.Layout.Padding of 20. XAML <Frame> <Label Text="I've been framed!" HorizontalOptions="Center" VerticalOptions="Center" /> </Frame> Code var ...
Authentication can be set for an specific APIView endpoint, by using the authentication_classes variable: from rest_framework.authentication import SessionAuthentication, BasicAuthentication from rest_framework.permissions import IsAuthenticated from rest_framework.response import Response ...
Font Awesome is an extremely simple yet powerful library to use, with 634 icons available in just a few words. How does it work? Font Awesome uses Unicode characters stored in a ../fonts directory to change any i.fa elements to the respective unicode character, as such displaying the icon as text....
Rewrite Class File: Namespace/ModuleName/etc/di.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> <preference for="Ma...
constructor(fb: FormBuilder) { this.form = fb.group({ firstInput: ['', Validators.compose([Validators.required, CustomValidators.cannotContainSpace]), CustomValidators.shouldBeUnique], secondInput: ['', Validators.required] }); } Here we use the FormBuilder to crea...
$skuList = array('SKU-1', 'SKU-2',...,'SKU-n); $_productCollection = Mage::getModel('catalog/product') ->getCollection() ->addAttributeToFilter('sku', array('in' => $skuList)); OR $_productCollection = Mage::getResourceModel('catalog/product_collection') ->addAttributeToFilter('s...
using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var foo = new ClassWithDependency(); foo.DoSomething(); var bar = new InjectedDependency(); foo.Dependency = bar; ...
using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { var dep = new DefaultDependency(); var foo = new ClassWithDependency(dep); foo.DoSomething(); var bar = new Injected...
Data with header, separated by semicolons instead of commas file: table.csv index;name;occupation 1;Alice;Saleswoman 2;Bob;Engineer 3;Charlie;Janitor code: import pandas as pd pd.read_csv('table.csv', sep=';', index_col=0) output: name occupation index 1 Alice Sale...
To view the first or last few records of a dataframe, you can use the methods head and tail To return the first n rows use DataFrame.head([n]) df.head(n) To return the last n rows use DataFrame.tail([n]) df.tail(n) Without the argument n, these functions return 5 rows. Note that the slice ...
WordPress shortcodes were introduced in 2.5 Here is come example of shortcode [button] to use shortcode direct into theme you have to use do_shortcode() <?php echo do_shortcode('[button]'); ?> To customize the button, we could simply add something like: [button type="twitter&qu...

Page 291 of 457