Tutorial by Examples: c

var logRepository = new Mock<ILogRepository>(); logRepository.Setup(x => x.Write(It.IsAny<Exception>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>())) .Verifiable(); In this case, we are using t...
use Text::CSV; # Can use Text::CSV which will switch to _XS if installed $sep_char = ","; my $csv = Text::CSV->new({sep_char => $sep_char}); my $line = q{"a quoted, comma", word1, word2}; $csv->parse($line); my @fields = $csv->fields(); print join("\n"...
In our last two examples, numpy assumed that a[0,:] was the first vector, a[1,:] the second, and a[2,:] the third. Numpy.cross has an optional argument axisa that allows us to specify which axis defines the vectors. So, >>> a=np.array([[1,1,1],[0,1,0],[1,0,-1]]) >>> b=np.array([0...
Required JARs on classpath: javax.money:money-api:1.0 (JSR354 money and currency api) org.javamoney:moneta:1.0 (Reference implementation) javax:annotation-api:1.2. (Common annotations used by reference implementation) // Let's create non-ISO currency, such as bitcoin // At first, t...
A natural division is simply to make one topic for each language feature. For instance, Python has: Classes Functions Generators Decorators . . . On the downside, features can be quite complicated and it's easy to come up with many more examples than make sense for a single page. Classes h...
BatchBashDescriptioncommand /?man commandShows the help for commandbitsadminwget or curlDownloads a remote filecertutil -hashfile file_name MD5md5sum file_nameGets the MD5 checksum of file_namecdpwdDisplays the current directorycd directorycd directoryChanges the current directory to the specified o...
BatchBashDescription%variable%$variableA regular variable!variable!$variableA variable inside of a code block when setlocal enabledelayedexpansion is on%errorlevel% or ERRORLEVEL$?Returns the status of the previous command: 0 if successful, 1 (or something else) if not%1, %2, %3, etc.$1, $2, $3, etc...
Using immutable locals: Uses less horizontal space but more vertical space than the "anonymous temporaries" template. Preferable over the "anonymous temporaries" template if the when expression is in a loop--in that case, regex definitions should be placed outside the loop. im...
The static factory method is a variation of the factory method pattern. It is used to create objects without having to call the constructor yourself. When to use the Static Factory Method if you want to give a meaningfull name to the method that generates your object. if you want to avoid over...
Implementing the Behavior This behavior will cause mouse wheel events from an inner ScrollViewer to bubble up to the parent ScrollViewer when the inner one is at either its upper or lower limit. Without this behavior, the events will never make it out of the inner ScrollViewer. public class Bubbl...
When a method is defined to be a macro, the compiler takes the code that is passed as its argument and turns it into an AST. It then invokes the macro implementation with that AST, and it returns a new AST that is then spliced back to its call site. import reflect.macros.blackbox.Context object ...
Macros can trigger compiler warnings and errors through the use of their Context. Say we're a particularly overzealous when it comes to bad code, and we want to mark every instance of technical debt with a compiler info message (let's not think about how bad this idea is). We can use a macro that d...
Some topics are loosely associated examples under a theme, such as C# 6.0 Features and Common pitfalls. On the whole, this style of topic has been discouraged since examples per topic were limited as there's no natural place to stop adding content. It's probably better to move the examples to anoth...
Java code: public class StdioApplication { public static void main(String[] args) { new ClassPathXmlApplicationContext("classpath:spring/integration/stackoverflow/stdio/stdio.xml"); } } Xml config file <?xml version="1.0" encoding="UTF-8"?&...
This example demonstrates how to develop a simple UWP application. On creation of a "Blank App (Universal Windows)" project there are many essential files that are created in your solution. All files in your project can be seen in the Solution Explorer. Some of the crucial files in your...
using System; using System.Speech.Synthesis; using System.Windows; namespace Stackoverflow.SpeechSynthesisExample { public partial class SpeechSynthesisSample : Window { public SpeechSynthesisSample() { InitializeComp...
This example demonstrates how a cross origin http request can be handled using a middleware. CORS Background CORS is an access control method adopted by all major browsers to avert Cross Scripting Vulnerabilities inherent by them. In general browser security, scripts should maintain that all XHR r...
Let's say you need to add a field to every document in a collection. import pymongo client = pymongo.MongoClient('localhost', 27017) db = client.mydb.mycollection for doc in db.find(): db.update( {'_id': doc['_id']}, {'$set': {'newField': 10} }, upsert=False, multi=False...
Conditional predicate will be cleaner and safer by using the NSCompoundPredicate class which provides basic boolean operators for the given predicates. Objective-c AND - Condition NSPredicate *predicate = [NSPredicate predicateWithFormat:@"samplePredicate"]; NSPredicate *anotherPre...
This approach was introduced in JSR 286. In JSR 168,render parameters set in processAction of a portlet were available only in that portlet.With the Public Render Parameters feature, the render parameters set in the processAction of one portlet will be available in render of other portlets also.In ...

Page 671 of 826