Tutorial by Examples

This snippet is an helper function to enumerate all files older than a specified age, it's useful - for example - when you have to delete old log files or old cached data. static IEnumerable<string> EnumerateAllFilesOlderThan( TimeSpan maximumAge, ...
Having example type like this: public TestClass { public static string StaticPublicField = "StaticPublicFieldValue"; } We can retrieve value of StaticPublicField: var fieldExpr = Expression.Field(null, typeof(TestClass), "StaticPublicField"); var labmda = Expression....
Autostash is a very useful configuration option when using rebase for local changes. Oftentimes, you may need to bring in commits from the upstream branch, but are not ready to commit just yet. However, Git does not allow a rebase to start if the working directory is not clean. Autostash to the res...
echo off cls sqlcmd.exe -S "your server name" -U "sql user name" -P "sql password" -d "name of databse" -Q "here you may write your query/stored procedure" Batch files like these can be used to automate tasks, for example to make backups of ...
Basic Error Handling By default, Express will look for an 'error' view in the /views directory to render. Simply create the 'error' view and place it in the views directory to handle errors. Errors are written with the error message, status and stack trace, for example: views/error.pug html bo...
It's a good practice to run NodeJS apps controlled by process managers. Process manager helps to keep application alive forever, restart on failure, reload without downtime and simplifies administrating. Most powerful of them (like PM2) have a built-in load balancer. PM2 also enables you to manage ...
It is obvious to assume that the percentage value of margin to margin-left and margin-right would be relative to its parent element. .parent { width : 500px; height: 300px; } .child { width : 100px; height: 100px; margin-left: 10%; /* (parentWidth * 10/100) => 50px ...
The canonical way of writing code inside documentation is with the {@code } construct. If you have multiline code wrap inside <pre></pre>. /** * The Class TestUtils. * <p> * This is an {@code inline("code example")}. * <p> * You should wrap it in pre tags...
Detailed instructions on getting aspectj set up or installed.
To use opacity in all versions of IE, the order is: .transparent-element { /* for IE 8 & 9 */ -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=60)"; // IE8 /* works in IE 8 & 9 too, but also 5, 6, 7 */ filter: alpha(opacity=60); // IE 5-7 /* Modern Browse...
Newtonsoft's Json.NET allows you to bind json dynamically (using ExpandoObject / Dynamic objects) without the need to create the type explicitly. Serialization dynamic jsonObject = new ExpandoObject(); jsonObject.Title = "Merchent of Venice"; jsonObject.Author = "William Shakes...
This command has several related yet distinct forms. del v If v is a variable, the command del v removes the variable from its scope. For example: x = 5 print(x) # out: 5 del x print(x) # NameError: name 'f' is not defined Note that del is a binding occurence, which means that unless expl...
If you want to log exceptions you can and should make use of the logging.exception(msg) method: >>> import logging >>> logging.basicConfig() >>> try: ... raise Exception('foo') ... except: ... logging.exception('bar') ... ERROR:root:bar Traceback (most rec...
The flip flop operator .. is used between two conditions in a conditional statement: (1..5).select do |e| e if (e == 2) .. (e == 4) end # => [2, 3, 4] The condition evaluates to false until the first part becomes true. Then it evaluates to true until the second part becomes true. After t...
This simple example shows how to start multiple threads in Java. Note that the threads are not guaranteed to execute in order, and the execution ordering may vary for each run. public class HelloMultithreading { public static void main(String[] args) { for (int i = 0; i < 10; i...
Prerequisites JDK 7 or Higher (Recommended: JDK 8+) Adding Bukkit as a Dependency The simplest method to add the Bukkit API to your project is to download the Bukkit.jar directly from the Spigot Repository and add it to your project's classpath. Legacy versions of Bukkit can be found at the...
We can create a better mapper classes with extension methods, Suppose if i have some DTO classes like public class UserDTO { public AddressDTO Address { get; set; } } public class AddressDTO { public string Name { get; set; } } and i need to map to corresponding v...
cts:search( fn:doc(), cts:word-query("marklogic"))
This can be done in the following two ways - cts:search( fn:collection("first-collection"), cts:word-query("marklogic")) In this, the scope is changed from all the documents to documents in collection "first-collection" only. In the second approach, use ...
This query returns all the documents with element "company" and its value as "marklogic" cts:element-value-query(xs:QName('company'), 'marklogic'))

Page 753 of 1336