Tutorial by Examples: ad

If you want to use @property to implement custom behavior for setting and getting, use this pattern: class Cash(object): def __init__(self, value): self.value = value @property def formatted(self): return '${:.2f}'.format(self.value) @formatted.setter def ...
SELECT your_columns, COUNT(*) OVER() as Ttl_Rows FROM your_data_set idnameTtl_Rows1example52foo53bar54baz55quux5 Instead of using two queries to get a count then the line, you can use an aggregate as a window function and use the full result set as the window. This can be used as a base for fur...
If you want to get the versioned project's data, but you don't need any of the version control capabilities offered by Subversion, you could run svn export <URL> command. Here is an example: $ svn export https://svn.example.com/svn/MyRepo/MyProject/trunk As a result, you will get the proje...
This example shows the usage of the ILGenerator by generating code that makes use of already existing and new created members as well as basic Exception handling. The following code emits a DynamicAssembly that contains an equivalent to this c# code: public static class UnixTimeHelper { priva...
Text prefixed with one to six pound signs (hash symbols, #) becomes a header <h1> through <h6>, according to how many pound signs were used. # This is a first-level (`<h1>`) header ## This is a second-level (`<h2>`) header ### And so on. This is a first-level (<h1&...
A database snapshot is a read-only, static view of a SQL Server database (the source database). It is similar to backup, but it is available as any other database so client can query snapshot database. CREATE DATABASE MyDatabase_morning -- name of the snapshot ON ( NAME=MyDatabase_data, -- l...
If data in a source database becomes damaged or some wrong data is written into database, in some cases, reverting the database to a database snapshot that predates the damage might be an appropriate alternative to restoring the database from a backup. RESTORE DATABASE MYDATABASE FROM DATABASE_SNAP...
docker run docker/whalesay cowsay 'Hello, StackExchange!' This command tells Docker to create a container from the docker/whalesay image and run the command cowsay 'Hello, StackExchange!' in it. It should print a picture of a whale saying Hello, StackExchange! to your terminal. If the entrypoin...
git add -i (or --interactive) will give you an interactive interface where you can edit the index, to prepare what you want to have in the next commit. You can add and remove changes to whole files, add untracked files and remove files from being tracked, but also select subsection of changes to put...
main = do input <- getContents putStr input Input: This is an example sentence. And this one is, too! Output: This is an example sentence. And this one is, too! Note: This program will actually print parts of the output before all of the input has been fully read in. This m...
main = do line <- getLine putStrLn line Input: This is an example. Output: This is an example.
Like in several other parts of the I/O library, functions that implicitly use a standard stream have a counterpart in System.IO that performs the same job, but with an extra parameter at the left, of type Handle, that represents the stream being handled. For instance, getLine :: IO String has a cou...
$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest 693bce725149 6 days ago 967 B postgres 9.5 0f3af79d8673 10 weeks ago 265.7 MB postgres ...
Razor has its own comment syntax which begins with @* and ends with *@. Inline Comment: <h1>Comments can be @*hi!*@ inline</h1> Multi-line Comment: @* Comments can spread over multiple lines *@ HTML Comment You can also use the normal HTML comment syntax starting with &...
This uses the Dropbox .NET SDK to download a file from the Dropbox API at the remote path to the local file "Test", while tracking progress: var response = await client.Files.DownloadAsync(path); ulong fileSize = response.Response.Size; const int bufferSize = 1024 * 1024; var buffer ...
5 Using property descriptors we can make a property read only, and any attempt to change it's value will fail silently, the value will not be changed and no error will be thrown. The writable property in a property descriptor indicates whether that property can be changed or not. var a = { }; ...
This query will return the number of tables in the specified database. USE YourDatabaseName SELECT COUNT(*) from INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' Following is another way this can be done for all user tables with SQL Server 2008+. The reference is here. SELECT COUNT(...
When you start a thread, it will execute until it is finished. Often, at some point, you need to (possibly - the thread may already be done) wait for the thread to finish, because you want to use the result for example. int n; std::thread thread{ calculateSomething, std::ref(n) }; //Doing some...
You cannot pass a reference (or const reference) directly to a thread because std::thread will copy/move them. Instead, use std::reference_wrapper: void foo(int& b) { b = 10; } int a = 1; std::thread thread{ foo, std::ref(a) }; //'a' is now really passed as reference thread.join()...
In C++, threads are created using the std::thread class. A thread is a separate flow of execution; it is analogous to having a helper perform one task while you simultaneously perform another. When all the code in the thread is executed, it terminates. When creating a thread, you need to pass somet...

Page 8 of 114