Tutorial by Examples: c

One of the nicest features of flexbox is to allow optimally fitting containers to their parent element. Live demo. HTML: <div class="flex-container"> <div class="flex-item">1</div> <div class="flex-item">2</div> <div class=&q...
Having a global allows for better DRYness, you need only put values that are different into AssemblyInfo.cs for projects that have variance. This use assumes your product has more than one visual studio project. GlobalAssemblyInfo.cs using System.Reflection; using System.Runtime.InteropServices...
Explicite selection A plotting style is usually selected using the with keyword, like plot x with points This allows to use different plotting styles for every plot: plot x with points, 2*x with lines Typing help with in the gnuplot command window gives a list of all available plotting styl...
ActiveRecord with includes ensures that all of the specified associations are loaded using the minimum possible number of queries. So when querying a table for data with an associated table, both tables are loaded into memory. @authors = Author.includes(:books).where(books: { bestseller: true } ) ...
Given a class as follows: class Cube attr_reader :height, :width, :depth def initialize(args) @height = args[:height] || args[:y] || 1 @width = args[:width] || args[:x] || 1 @depth = args[:depth] || args[:z] || 1 end def volume height * width * depth end ...
To build a Rails application that will be an API server, you can start with a more limited subset of Rails in Rails 5. To generate a new Rails API app: rails new my_api --api What --api does is to remove functionality that is not needed when building an API. This includes sessions, cookies, ass...
Sometimes you may need to validate record only under certain conditions. class User < ApplicationRecord validates :name, presence: true, if: :admin? def admin? conditional here that returns boolean value end end If you conditional is really small, you can use a Proc: class ...
In PHP, there are two versions of logical AND and OR operators. OperatorTrue if$a and $bBoth $a and $b are true$a && $bBoth $a and $b are true$a or $bEither $a or $b is true$a || $bEither $a or $b is true Note that the && and || opererators have higher precedence than and and or. S...
In cryptography, encryption is the process of encoding messages or information in such a way that only authorized parties can access it. Source: Encryption - Wikipedia
Imagine that we have a separate Google spreadsheet, and we need to get the B2 cell value to cell D5 on your current sheet. function copyValueandPaste() { var source = SpreadsheetApp.openById('spread sheet id is here'); //Separate spreadsheet book var sourcesheet = source.getSheetByName...
As with docopt, with [docopt_dispatch] you craft your --help in the __doc__ variable of your entry-point module. There, you call dispatch with the doc string as argument, so it can run the parser over it. That being done, instead of handling manually the arguments (which usually ends up in a high c...
Functions that are O(n) increase the number of operations linearly, as the input gets very large. A simple example of a function that is O(n) would be the linear search algorithm, which runs once for the size of the input. The following pseudo-code would be O(n), because it will always be bounded ...
Consider the following naive method for adding two positive numbers using recursion: public static int add(int a, int b) { if (a == 0) { return b; } else { return add(a - 1, b + 1); // TAIL CALL } } This is algorithmically correct, but it has a major problem. ...
Manually open and close a file. # Using new method f = File.new("test.txt", "r") # reading f = File.new("test.txt", "w") # writing f = File.new("test.txt", "a") # appending # Using open method f = open("test.txt", "r&...
If you're just getting started with Chef, we recommend starting off with our Learn Chef tutorial at http://learn.chef.io/. If you have questions during or after that, check out or discussion forum/mailing list at https://discourse.chef.io/ or our public Slack team at https://community-slack.chef.io...
We request that the Chef community not use this StackOverflow documentation feature. Docs managed via wiki (or community editing in general) tend to rot very quickly and are of poor quality. We've all experienced the sense of dread when searching for an answer on Google and getting back a half-unrea...
General syntax: DATEADD (datepart , number , datetime_expr) To add a time measure, the number must be positive. To subtract a time measure, the number must be negative. Examples DECLARE @now DATETIME2 = GETDATE(); SELECT @now; --2016-07-21 14:39:46.4170000 SELECT DAT...
These are the datepart values available to date & time functions: datepartAbbreviationsyearyy, yyyyquarterqq, qmonthmm, mdayofyeardy, ydaydd, dweekwk, wwweekdaydw, whourhhminutemi, nsecondss, smillisecondmsmicrosecondmcsnanosecondns NOTE: Use of abbreviations is generally discouraged as they c...
General syntax: DATEDIFF (datepart, datetime_expr1, datetime_expr2) It will return a positive number if datetime_expr is in the past relative to datetime_expr2, and a negative number otherwise. Examples DECLARE @now DATETIME2 = GETDATE(); DECLARE @oneYearAgo DATETIME2 = DATEADD(YEAR, -1, @now...

Page 361 of 826