Tutorial by Examples: c

public async Task SetProductInactiveAsync(int productId) { using (IDbConnection con = new SqlConnection("myConnectionString")) { await con.ExecuteAsync("SetProductInactive", new { id = productId }, commandType: CommandType.StoredProcedure); ...
This will be a relatively comprehensive tutorial of how to write a command line tool to print the weather from the zip code provided to the command line tool. The first step is to write the program in ruby to do this action. Let's start by writing a method weather(zip_code) (This method requires the...
Some functions in R produce a side effect (i.e. saving, printing, plotting, etc) and do not always return a meaningful or desired value. %T>% (tee operator) allows you to forward a value into a side-effect-producing function while keeping the original lhs value intact. In other words: the tee op...
What is Dagger 2 ? The website describes itself as: Dagger is a fully static, compile-time dependency injection framework The library makes it easy to model dependency graphs as well as to reuse objects. Since reflection is only used at compile time as part of the annotation processing Dagger...
Define a module (the model of dependencies and their graph): @Module public class CoffeeModule{ @Provides public CoffeeMaker provideCoffeeMaker(){ return new CoffeeMaker(); } @Provides public Coffee provideCoffee(CoffeeMaker coffeeMaker){ return new ...
It is often useful to build matrices out of smaller matrices. Horizontal Concatenation Matrices (and vectors, which are treated as column vectors) can be horizontally concatenated using the hcat function. julia> hcat([1 2; 3 4], [5 6 7; 8 9 10], [11, 12]) 2×6 Array{Int64,2}: 1 2 5 6 7 ...
Fast Development process Decoupling Unit test writing Fast Development process When using dependency injection node developer can faster their development proceess because after DI there is less code conflict and easy to manage all module. Decoupling Modules becomes less couple then it i...
This example is how to turn an image into a Base64 string (i.e. a string you can use directly in a src attribute of an img tag). This example specifically uses the Imagick library (there are others available, such as GD as well). <?php /** * This loads in the file, image.jpg for manipulation....
Create simple CRUD Operation Using Serverless Framework Install Serverless framework globally npm install serverless -g Create simple Lambda Service serverless create --template aws-nodejs --path myService Go to the myService Directory it should contain serverless.yml handler.js even...
Generators are fast coded and in many cases a slim alternative to heavy iterator-implementations. With the fast implementation comes a little lack of control when a generator should stop generating or if it should generate something else. However this can be achieved with the usage of the send() fu...
In the following example we will be creating a table called Membership using the AWS Java SDK for DynamoDB. The table will consist of items that represent team assignments. The table will be partitioned by TeamID. Each team will have multiple members, identified by the MemberID (as a sort key). AWS...
There are several considerations when implementing Regular Expressions in Swift. let letters = "abcdefg" let pattern = "[a,b,c]" let regEx = try NSRegularExpression(pattern: pattern, options: []) let nsString = letters as NSString let matches = regEx.matches(in: letters, opt...
Patterns can be used to replace part of an input string. The example below replaces the cent symbol with the dollar symbol. var money = "¢¥€£$¥€£¢" let pattern = "¢" do { let regEx = try NSRegularExpression (pattern: pattern, options: []) let nsString = money as NSS...
To match special characters Double Backslash should be used \. becomes \\. Characters you'll have to escape include (){}[]/\+*$>.|^? The below example get three kinds of opening brackets let specials = "(){}[]" let pattern = "(\\(|\\{|\\[)" do { let regEx = try N...
Switches can switch on tuples: public typealias mdyTuple = (month: Int, day: Int, year: Int) let fredsBirthday = (month: 4, day: 3, year: 1973) switch theMDY { //You can match on a literal tuple: case (fredsBirthday): message = "\(date) \(prefix) the day Fred was born"...
Create a simple servlet: package web.example; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse...
Player player; //The player you want to award your achievement with Achievement achievement; //The achievement you want to award your player player.awardAchievement(achievement); //Awarding the achievement Checking if player has achievement: Player player; Achievement achievement...
First, you need to install pry-byebug gem. Run this command: $ gem install pry-byebug Add this line at the top of your .rb file: require 'pry-byebug' Then insert this line wherever you want a breakpoint: binding.pry A hello.rb example: require 'pry-byebug' def hello_world puts &qu...
Prerequisites: Install Firefox Install Selenium IDE addon (https://addons.mozilla.org/fr/firefox/addon/selenium-ide/) Open the plugin. A button displaying a red circle must be shown. If it's pressed, it means you can start your scenario. The plugin is recording everything you do within this F...
public class BucketSort { public static void SortBucket(ref int[] input) { int minValue = input[0]; int maxValue = input[0]; int k = 0; for (int i = input.Length - 1; i >= 1; i--) { if (input[i] > maxValue) maxValue = input...

Page 630 of 826