SELECT name, caption as title, year, pages FROM books
UNION
SELECT name, title, year, 0 as pages FROM movies
When combining 2 record sets with different columns then emulate the missing ones with default values.
extern int var;
static int var; /* Undefined behaviour */
C11, §6.2.2, 7 says:
If, within a translation unit, the same identifier appears with both
internal and external linkage, the behavior is undefined.
Note that if an prior declaration of an identifier is visible then it'll have the pri...
Use the yum command to manage packages in Enterprise Linux-based operating systems:
yum install php
This installs a minimal install of PHP including some common features. If you need additional modules, you will need to install them separately. Once again, you can use yum to search for these pac...
Note:
There will be some Objective-c in this example..
We will make a wrapper to C++ in this example, So don't worry to much about it.
First start Xcode and create a project.
And select a Cocoa application
Delete all sources except the Info.plist file.(Your app won't work without it)
Creat...
You can use the header() function to instruct the browser to redirect to a different URL:
$url = 'https://example.org/foo/bar';
if (!headers_sent()) { // check headers - you can not send headers if they already sent
header('Location: ' . $url);
exit; // protects from code being executed afte...
#include <Windows.h>
DWORD WINAPI DoStuff(LPVOID lpParameter)
{
// The new thread will start here
return 0;
}
int main()
{
// Create a new thread which will start at the DoStuff function
HANDLE hThread = CreateThread(
NULL, // Thread attributes
...
Improper Inheritance
Lets say there are 2 classes class Foo and Bar. Foo has two features Do1 and Do2. Bar needs to use Do1 from Foo, but it doesn't need Do2 or needs feature that is equivalent to Do2 but does something completely different.
Bad way: make Do2() on Foo virtual then override it in B...
C# developers get a lot of null reference exceptions to deal with. F# developers don't because they have the Option type. An Option<> type (some prefer Maybe<> as a name) provides a Some and a None return type. It makes it explicit that a method may be about to return a null record.
For...
One of Angular's strength's is client-side form validation.
Dealing with traditional form inputs and having to use interrogative jQuery-style processing can be time-consuming and finicky. Angular allows you to produce professional interactive forms relatively easily.
The ng-model directive provide...
uses
System.Character;
var
S1, S2: string;
begin
S1 := 'Foo';
S2 := ToLower(S1); // Convert the string to lower-case
S1 := ToUpper(S2); // Convert the string to upper-case
The assignment operator = sets thr left hand operand's value to the value of right hand operand, and return that value:
int a = 3; // assigns value 3 to variable a
int b = a = 5; // first assigns value 5 to variable a, then does the same for variable b
Console.WriteLine(a = 3 + 4); // prints ...
To display "Some Text", use the command:
echo Some Text
This will output the string Some Text followed by a new line.
To display the strings On and Off (case insensitive) or the empty string, use a ( instead of white-space:
echo(ON
echo(
echo(off
This will output:
ON
off
...
The echo setting determines whether command echoing is on or off. This is what a sample program looks like with command echoing on (default):
C:\Windows\System32>echo Hello, World!
Hello, World!
C:\Windows\System32>where explorer
C:\Windows\System32\explorer.exe
C:\Windows\System32>...
Angular js directives can be nested or be made interoperable.
In this example, directive Adir exposes to directive Bdir it's controller $scope, since Bdir requires Adir.
angular.module('myApp',[]).directive('Adir', function () {
return {
restrict: 'AE',
controlle...
enum Util {
/* No instances */;
public static int clamp(int min, int max, int i) {
return Math.min(Math.max(i, min), max);
}
// other utility methods...
}
Just as enum can be used for singletons (1 instance classes), it can be used for utility classes (0 instance...
Imagine that we have a class Math.php with logic of calculating of fiobanacci and factorial numbers. Something like this:
<?php
class Math {
public function fibonacci($n) {
if (is_int($n) && $n > 0) {
$elements = array();
$elements[1] = 1;
...
install the required Microsoft.SqlServer.Types assembly; they are not installed by default, and are available from Microsoft here as "Microsoft® System CLR Types for Microsoft® SQL Server® 2012" - note that there are separate installers for x86 and x64.
install Dapper.EntityFramew...
Once the type handlers are registered, everything should work automatically, and you should be able to use these types as either parameters or return values:
string redmond = "POINT (122.1215 47.6740)";
DbGeography point = DbGeography.PointFromText(redmond,
DbGeography.DefaultCoordi...
When using Access you can retrieve data using queries. These queries are built using Structured Query Language (SQL). Understanding SQL is important because it can help build better, more useful queries.
When creating queries in Access, you can switch to "SQL View". An example of a "...
When you wish to combine the results of multiple tables or queries with similar fields together into a single resulting data set without performing any relational joins (i.e. you want to list one dataset immediately after the other), you will use a UNION query. However, it is notable that these quer...