Tutorial by Examples: er

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...
Imagine you have a class manager to manages sending mails (be called MailManager). In this, you have to log mails that are sent. A good solution is to transform the MailManager class into a service and then inject class for creating logs (Monolog for example) into the MailManager creating a service...
Get image from file lib.myImage = IMAGE lib.myImage.file = fileadmin/My-Image.png lib.myImage.file.width = 100 lib.myImage.file.height = 100 Get image from page properties lib.pageImage = IMAGE lib.pageImage { file.import.data = levelmedia: -1, "slide" file.impor...
# get a list of columns cols = list(df) # move the column to head of list using index, pop and insert cols.insert(0, cols.pop(cols.index('listing'))) # use ix to reorder df2 = df.ix[:, cols]
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': ...
In your functions.php you can register new sidebars with this code /** * Registers sidebars * * @param array Array with default or specified array values * @since 1.0.0 */ if ( function_exists( 'register_sidebar' ) ) { register_sidebar( array ( 'name' => e...
It is possible to send a message or data to all avaible connections. This can be achieved by first initializing the server and then using the socket.io object to find all sockets and then emit as you normally would emit to a single socket var io = require('socket.io')(80) // 80 is the HTTP port io...
It is possible to emit a message or data to all users except the one making the request: var io = require('socket.io')(80); io.on('connection', function (socket) { socket.broadcast.emit('user connected'); });
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...
class My_Plugin() { function __construct() { add_action( 'wp_enqueue_scripts', array( $this, 'init_fe_assets' ) ); } public function init_fe_assests() { wp_enqueue_style( 'my-plugin', plugin_dir_url( __FILE__ ) . 'assets/css/frontend/plugin.css', array(), '0.0.1', true ); ...
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 following is an example for setting and reading cookies using the cookie-parser module: var express = require('express'); var cookieParser = require('cookie-parser'); // module for parsing cookies var app = express(); app.use(cookieParser()); app.get('/setcookie', function(req, res){ ...
In Express, you can define unified error handler for handling errors occurred in application. Define then handler at the end of all routes and logic code. Example var express = require('express'); var app = express(); //GET /names/john app.get('/names/:name', function(req, res, next){ if...
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 ...
xdmp:estimate(cts:search(fn:doc(), cts:element-value-query(xs:QName("d"), "fragment-d"))) xdmp:estimate can not be used on XPaths unlike fn:count is used in previous example xdmp:estimate actually gives the number of matching fragments
Once we have visual studio, we need a developer site to deploy apps to SharePoint. Simplest way is to get is > Sign up for a free, one year Office 365 developer account https://profile.microsoft.com/RegSysProfileCenter/wizardnp.aspx?wizid=14b845d0-938c-45af-b061-f798fbb4d170&lcid=1033 Once ...
void DispatchToMainThread(std::function<void()> callback) { // any thread QTimer* timer = new QTimer(); timer->moveToThread(qApp->thread()); timer->setSingleShot(true); QObject::connect(timer, &QTimer::timeout, [=]() { // main thread ...
insert into schema.table (field1, field2) select 'Static Value', foreignField from schema.otherTable;
Our UserProfile class Create a UserProfile model class with the relationship of OneToOne to the default User model: from django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save class UserProfile(models.Model): user = models.OneTo...

Page 272 of 417