Tutorial by Examples: c

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...
Sample test dataset CSV file stored at the location c:\Users\yc03ak1\Desktop\testing.csv _id city loc pop state 1 A [10.0, 20.0] 2222 PQE 2 B [10.1, 20.1] 22122 RW 3 C [10.2, 20.0] 255222 RWE 4 D [10.3, 20.3] 226622 SFDS 5 E [10...
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...
SQLite already has extensive documentation, which should not be duplicated here.
# 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]
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...
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...
When it comes to validate some rules which are not generic data validation e.g ensuring a field is required or some range of values but they are specific to your business logic then you can create your own Custom Validator. To create a custom validation attribute, you just need to inherit Validation...
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...
Step 1: Install Node.js The build pipeline you will be building is based in Node.js so you must ensure in the first instance that you have this installed. For instructions on how to install Node.js you can checkout the SO docs for that here Step 2: Initialise your project as an node module Open y...
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'); });
Java Config The configuration class needs only to be a class that is on the classpath of your application and visible to your applications main class. class MyApp { public static void main(String[] args) throws Exception { AnnotationConfigApplicationContext appContext = ...
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...

Page 536 of 826