Tutorial by Examples: st

This example serves as a complement to other examples which talk about how to use the lifecycle methods and when the method will be called. This example summarize Which methods (componentWillMount, componentWillReceiveProps, etc) will be called and in which sequence will be different for a componen...
To create a template for the single posts of our custom post type, we need to create a file called single-post_type_name.php where post_type_name is the name of our custom post type. For example, if our custom post type is called “Books”, we need to create a PHP file called single-book.php. Note th...
This is what I do when I'm working with Firebase and I want to use ListView. Use a parent component to retrieve the data from Firebase (Posts.js): Posts.js import PostsList from './PostsList'; class Posts extends Component{ constructor(props) { super(props); this.state =...
The Constructor Dependency Injection requires parameters in the constructor to inject dependencies. So you have to pass the values when you create a new object. public class Example { private readonly ILogging _logging; public Example(ILogging logging) { this._logging = l...
show dbs or db.adminCommand('listDatabases') or db.getMongo().getDBNames()
show collections or show tables or db.getCollectionNames()
Let's assume we have the following struct that defines a City type: type City struct { Name string Temperature int } We can encode/decode City values using the encoding/json package. First of all, we need to use the Go metadata to tell the encoder the correspondence between the...
To simulate paging using REST you can do the following: Use the $skip=n parameter to skip the first n entries according to the $orderby parameter Use the $top=n parameter to return the top n entries according to the $orderby and $skip parameters. var endpointUrl = "/_api/lists('g...
Very often it happens to deal with models which have something like a published field. Such kind of fields are almost always used when retrieving objects, so that you will find yourself to write something like: my_news = News.objects.filter(published=True) too many times. You can use custom mana...
For the layout above your customrow.axml file is as shown below <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_heigh...
Usually to use the converter, we have to define it as resource in the following way: <converters:SomeConverter x:Key="SomeConverter"/> It is possible to skip this step by defining a converter as MarkupExtension and implementing the method ProvideValue. The following example conve...
It is possible to pass multiple bound values as a CommandParameter using MultiBinding with a very simple IMultiValueConverter: namespace MyProject.Converters { public class Converter_MultipleCommandParameters : MarkupExtension, IMultiValueConverter { public object Convert(object...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1">...
Elixir is available in main packages repository. Update the packages list before installing any package: emerge --sync This is one step installation: emerge --ask dev-lang/elixir
Install jekyll on Linux Mint 18 with the following steps: sudo apt install ruby sudo apt install build-essential sudo apt install ruby-dev sudo gem install jekyll
Open a command prompt with Administrator access Install Chocolatey: @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin Close the comm...
A with_items loop in ansible can be used to easily loop over values. - name: Add lines to this file lineinfile: dest=/etc/file line={{ item }} state=present with_items: - Line 1 - Line 2 - Line 3
You can also loop over a variable list. From vars: favorite_snacks: - hotdog - ice cream - chips and then the loop: - name: create directories for storing my snacks file: path=/etc/snacks/{{ item }} state=directory with_items: '{{ favorite_snacks }}' If you are using Ansible ...
You can create nested loops using with_nested. from vars: keys: - key1 - key2 - key3 - key4 then the loop: - name: Distribute SSH keys among multiple users lineinfile: dest=/home/{{ item[0] }}/.ssh/authorized_keys line={{ item[1] }} state=present with_nested: - [ 'calvin...
To decouple and reuse the same error logging code for all your services you need two boilerplate classes and tuck them away in a library somewhere. ErrorhandlerAttribute implementing IServiceBehavior. FaultErrorhandler implementing IErrorhandler which logs all the exceptions. [AttributeUsage(Attr...

Page 241 of 369