Tutorial by Examples: sin

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...
When the command-line syntax for an application is simple, it is reasonable to do the command argument processing entirely in custom code. In this example, we will present a series of simple case studies. In each case, the code will produce error messages if the arguments are unacceptable, and the...
Django REST Framework provides a basic token-based authentication mechanism which needs to be configured as an application in Django before being usable, so that tokens are created in the database, and their lifecycle handled. Add Token-based authentication to settings.py INSTALLED_APPS = ( ...
The most interesting package for managing real tokens is django-rest-knox which supports multiple tokens per user (and cancelling each token independently), as well as having support for token expiration and several other security mechanisms. django-rest-knox depends on cryptography. You can find m...
A simple example of Vehicle hierarchy can be taken for single table inheritance strategy. Abstract Vehicle class: package com.thejavageek.jpa.entities; import javax.persistence.DiscriminatorColumn; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persi...
Static initialization is suitable for most situations. When your application must delay the instantiation, use a non-default constructor or perform other tasks before the instantiation, and work in a multithreaded environment, you need a different solution. Cases do exist, however, in which you cann...
const MongoDB = require('mongodb'); MongoDB.connect('mongodb://localhost:27017/databaseName') .then(function(database) { const collection = database.collection('collectionName'); return collection.insert({key: 'value'}); }) .then(function(result) { co...
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....
<div class="container content"> <div class="row"> <!--Main Content--> <div class="col-lg-9 col-lg-push-3"> Main Content </div> <!--Sidebar--> <div class=&quot...
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...
The simplest shortcode is the self-closing one. We’re going to create a simple link to our Twitter account, and then add it in a blog post. All the code goes in functions.php, which is located in /wp-content/themes/your-theme/. If you don’t have one, just create it and put the code in it. <?php...
Creating a self-closing shortcode with parameters <?php function button_shortcode( $type ) { extract( shortcode_atts( array( 'type' => 'value' ), $type ) ); // check what type user entered switch ($type) { case 'twitter': ...
enclosing shortcode The enclosing shortcode allows you to embed content within your shortcode, just like BBCode if you’ve ever used that. <?php function button_shortcode( $attr, $content = null ) { return '<a href="http://twitter.com/filipstefansson" class="twitter-button&qu...
By default, WordPress does not support shortcodes within Sidebar Widgets. It only expands the shortcodes within the content of a Post, Page, or custom post type. To add shortcode support to sidebar widgets, you can install a plugin, or use the below code: add_filter( 'widget_text', 'shortcode_unaut...
In the example we will start tomcat 7 using maven plugin, optionally add user/password protection for REST end point. Also adding feature of building war. Add below section in plugin section of pom for tomcat <plugin> <groupId>org.apache.tomcat.maven</g...
jHipster allows you to bootstrap a Spring Boot web application with a REST API back-end and a AngularJS and Twitter Bootstrap front-end. More on jHipster here: jHipster Documentation Install brew: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/inst...
Example from phptherightway.com <?php class Singleton { /** * @var Singleton The reference to *Singleton* instance of this class */ private static $instance; /** * Returns the *Singleton* instance of this class. * * @return Singleton The *Sing...
Note: The singleton is a design pattern. But it also considered an anti-pattern. The use of a singleton should be considered carefully before use. There are usually better alternatives. The main problem with a singleton is the same as the problem with global variables. They introduce external glo...
The XML document, I will be using throughout the examples is - <a> <b>test-value</b> <d>fragment-d</d> <c-root> <d>fragment-d</d> <e>fragment-e</e> </c-root> </a> The following queries ...

Page 105 of 161