Tutorial by Examples: dp

Simple usage Dapper fully supports stored procs: var user = conn.Query<User>("spGetUser", new { Id = 1 }, commandType: CommandType.StoredProcedure) .SingleOrDefault(); Input, Output and Return parameters If you want something more fancy...
See RFC 2030 for details on the SNTP protocol. using System; using System.Globalization; using System.Linq; using System.Net; using System.Net.Sockets; class SntpClient { const int SntpPort = 123; static DateTime BaseDate = new DateTime(1900, 1, 1); static void Main(string[...
Create a property with getter and/or setter and initialize all in one line: public string Foobar { get; set; } = "xyz";
public class MyActivity extends Activity { private static final String PREFS_FILE = "NameOfYourPrefrenceFile"; // PREFS_MODE defines which apps can access the file private static final int PREFS_MODE = Context.MODE_PRIVATE; // you can use live template "key"...
A common Executor used is the ThreadPoolExecutor, which takes care of Thread handling. You can configure the minimal amount of Threads the executor always has to maintain when there's not much to do (it's called core size) and a maximal Thread size to which the Pool can grow, if there is more work t...
One use of SharedPreferences is to implement a "Settings" screen in your app, where the user can set their preferences / options. Like this: A PreferenceScreen saves user preferences in SharedPreferences. To create a PreferenceScreen, you need a few things: An XML file to define the av...
echo and print are language constructs, not functions. This means that they don't require parentheses around the argument like a function does (although one can always add parentheses around almost any PHP expression and thus echo("test") won't do any harm either). They output the string r...
Exponentiation can be used by using the builtin pow-function or the ** operator: 2 ** 3 # 8 pow(2, 3) # 8 For most (all in Python 2.x) arithmetic operations the result's type will be that of the wider operand. This is not true for **; the following cases are exceptions from this rule: B...
Lazy stored properties have values that are not calculated until first accessed. This is useful for memory saving when the variable's calculation is computationally expensive. You declare a lazy property with lazy: lazy var veryExpensiveVariable = expensiveMethod() Often it is assigned to a retu...
Different from stored properties, computed properties are built with a getter and a setter, performing necessary code when accessed and set. Computed properties must define a type: var pi = 3.14 class Circle { var radius = 0.0 var circumference: Double { get { ret...
- (void)methodWithBlock:(returnType (^)(paramType1, paramType2, ...))name;
WordPress [WP] is an open source Content Management System for building apps, websites, and blogs. WP is written in PHP and uses MySQL as the data store for the user content and configuration. It has a rich ecosystem of plugins and themes and enjoys a vibrant open source community, good documentatio...
<script src= "http://player.twitch.tv/js/embed/v1.js"></script> <div id="{PLAYER_DIV_ID}"></div> <script type="text/javascript"> var options = { width: 854, height: 480, channel: "{CHANNEL}" ...
One use case for assertion is precondition and postcondition. This can be very useful to maintain invariant and design by contract. For a example a length is always zero or positive so this function must return a zero or positive value. #include <stdio.h> /* Uncomment to disable `assert()`...
> mysqldump -u username -p [other options] Enter password: If you need to specify the password on the command line (e.g. in a script), you can add it after the -p option without a space: > mysqldump -u username -ppassword [other options] If you password contains spaces or special chara...
In this tutorial we're going to learn how to set up the PayPal Android SDK to process a simple payment via either a PayPal payment or a credit card purchase. At the end of this example, you should have a simple button in an application that, when clicked, will forward the user to PayPal to confirm a...
Reflection is often used as part of software testing, such as for the runtime creation/instantiation of mock objects. It's also great for inspecting the state of an object at any given point in time. Here's an example of using Reflection in a unit test to verify a protected class member contains the...
The following queries will return a list of all Stored Procedures in the database, with basic information about each Stored Procedure: SQL Server 2005 SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_TYPE = 'PROCEDURE' The ROUTINE_NAME, ROUTINE_SCHEMA and ROUTINE_DEFINITION columns are...
// Java: String phrase = persons .stream() .filter(p -> p.age >= 18) .map(p -> p.name) .collect(Collectors.joining(" and ", "In Germany ", " are of legal age.")); System.out.println(phrase); // In Germany Max and Peter a...
import re precompiled_pattern = re.compile(r"(\d+)") matches = precompiled_pattern.search("The answer is 41!") matches.group(1) # Out: 41 matches = precompiled_pattern.search("Or was it 42?") matches.group(1) # Out: 42 Compiling a pattern allows it to be r...

Page 1 of 21