Tutorial by Examples

Customizing the Shell prompt Default command prompt can be changed to look different and short. In case the current directory is long default command prompt becomes too large. Using PS1 becomes useful in these cases. A short and customized command pretty and elegant. In the table below PS1 has be...
git log --graph --pretty=format:'%C(red)%h%Creset -%C(yellow)%d%Creset %s %C(green)(%cr) %C(yellow)<%an>%Creset' The format option allows you to specify your own log output format: ParameterDetails%C(color_name)option colors the output that comes after it%h or %Habbreviates commit hash (us...
#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 ...
The easiest option to draw a circle, is - obviously - the rectangle function. %// radius r = 2; %// center c = [3 3]; pos = [c-r 2*r 2*r]; rectangle('Position',pos,'Curvature',[1 1]) axis equal but the curvature of the rectangle has to be set to 1! The position vector defines the rect...
Firstly, one can use quiver, where one doesn't have to deal with unhandy normalized figure units by use of annotation drawArrow = @(x,y) quiver( x(1),y(1),x(2)-x(1),y(2)-y(1),0 ) x1 = [10 30]; y1 = [10 30]; drawArrow(x1,y1); hold on x2 = [25 15]; y2 = [15 25]; drawArrow(x2,y2) ...
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
2009 uses Character; var C1, C2: Char; begin C1 := 'F'; C2 := ToLower(C1); // Convert the char to lower-case C1 := ToUpper(C2); // Convert the char to upper-case The uses clause should be System.Character if version is XE2 or above.
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&gt...
Sometimes you may need additional features from a directive. Instead of rewriting (copy) the directive, you can modify how the directive behaves. The decorator will be executed during $inject phase. To do so, provde a .config to your module. The directive is called myDirective, so you have to con...
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 "...

Page 534 of 1336