Tutorial by Examples

Android Studio's Live templates can offer quite a few shortcuts for quick logging. To use Live templates, all you need to do is to start typing the template name, and hit TAB or enter to insert the statement. Examples: logi → turns into → android.util.Log.i(TAG, "$METHOD_NAME$: $content$&q...
Caffe can run on multiple cores. One way is to enable multithreading with Caffe to use OpenBLAS instead of the default ATLAS. To do so, you can follow these three steps: sudo apt-get install -y libopenblas-dev Before compiling Caffe, edit Makefile.config, replace BLAS := atlas by BLAS := open A...
What's between \Q and \E is treated as normal characters #!/usr/bin/perl my $str = "hello.it's.me"; my @test = ( "hello.it's.me", "hello/it's!me", ); sub ismatched($) { $_[0] ? "MATCHED!" : "DID NOT MATCH!" } my @match = ( ...
After adding PrimeFaces to your JSF project, you can start using it in your pages using the namespace: xmlns:p="http://primefaces.org/ui" or, for PrimeFaces Mobile: xmlns:p="http://primefaces.org/mobile" This example should render a spinner: <html xmlns="http...
Because the WHERE clause is evaluated before GROUP BY, you cannot use WHERE to pare down results of the grouping (typically an aggregate function, such as COUNT(*)). To meet this need, the HAVING clause can be used. For example, using the following data: DECLARE @orders TABLE(OrderID INT, Name NVA...
It is sometimes required for a process to concurrently write and read the same "data". The ReadWriteLock interface, and its ReentrantReadWriteLock implementation allows for an access pattern that can be described as follow : There can be any number of concurrent readers of the data. If...
using System; using System.Runtime.InteropServices; namespace ComLibrary { [ComVisible(true)] public interface IMainType { int GetInt(); void StartTime(); int StopTime(); } [ComVisible(true)] [ClassInterface(ClassInterfaceType.N...
Services declaration : # src/Acme/YourBundle/Resources/config/services.yml services: my_service: class: Acme\YourBundle\Service\MyService arguments: ["@doctrine", "%some_parameter%", "@another_service"] another_service: class: Ac...
static TestMethod void DmlTest() { List<Contact> allContacts = [SELECT Id FROM Contact]; System.assert(allContacts.isEmpty()); Contact testContact = new Contact(FirstName = 'John', LastName = 'Doe'); insert testContact; allContacts = [SELECT Id FROM Contact]; Sy...
It can be difficult to test functions with poor asymptotic complexity using quickcheck as the random inputs are not usually size bounded. By adding an upper bound on the size of the input we can still test these expensive functions. import Data.List(permutations) import Test.QuickCheck longRunn...
For an instance, if the html source code of an html view or element is wrapped by an iframe like this: <iframe src="../images/eightball.gif" name="imgboxName" id="imgboxId"> <p>iframes example</p> <a href="../images/redball.gif" t...
To switch focus to either main document or first frame of the page. You have to use below syntax. driver.switchTo().defaultContent();
el-get is an open source package management system for GNU Emacs. el-get works with melpa, as well as with many common version control systms. Its documentation includes a simple self-installer for your .emacs: (unless (require 'el-get nil t) (url-retrieve "https://raw.github.com/dim...
Function-like macros are similar to inline functions, these are useful in some cases, such as temporary debug log: #ifdef DEBUG # define LOGFILENAME "/tmp/logfile.log" # define LOG(str) do { \ FILE *fp = fopen(LOGFILENAME, "a"); \ ...
This attribute is applied to the class property. You can use ConcurrencyCheck attribute when you want to use existing columns for concurrency check and not a separate timestamp column for concurrency. using System.ComponentModel.DataAnnotations; public class Author { public int AuthorId { ...
Basically, parfor is recommended in two cases: lots of iterations in your loop (i.e., like 1e10), or if each iteration takes a very long time (e.g., eig(magic(1e4))). In the second case you might want to consider using spmd . The reason parfor is slower than a for loop for short ranges or fast itera...
We can create a Map from a list of tuples like this: Map.fromList [("Alex", 31), ("Bob", 22)] A Map can also be constructed with a single value: > Map.singleton "Alex" 31 fromList [("Alex",31)] There is also the empty function. empty :: Map k a ...
A class decorator is just a function that takes the class as its only argument and returns it after doing something with it: function log<T>(target: T) { // Do something with target console.log(target); // Return target return target; } We can then apply ...
This time we are going to declare a class decorator that will add some metadata to a class when we applied to it: function addMetadata(target: any) { // Add some metadata target.__customMetadata = { someKey: "someValue" }; // Return target ret...
We can wrap a class decorator with another function to allow customization: function addMetadata(metadata: any) { return function log(target: any) { // Add metadata target.__customMetadata = metadata; // Return target return target; ...

Page 623 of 1336