Tutorial by Examples: c

When working with existing model that is quite big and is being regenerated quite often in cases where abstraction needed it might be costly to manually go around redecorating model with interfaces. In such cases one might want to add some dynamic behavior to model generation. Following example wil...
:s/foo/bar/c Marks the first instance of foo on the line and asks for confirmation for substitution with bar :%s/foo/bar/gc Marks consecutively every match of foo in the file and asks for confirmation for substitution with bar
It's possible to pass Java objects to Nashorn engine to be processed in Java code. At the same time, there are some JavaScript (and Nashorn) specific constructions, and it's not always clear how they work with java objects. Below there is a table which describes behaviour of native Java objects ins...
User-defined method objects may be created when getting an attribute of a class (perhaps via an instance of that class), if that attribute is a user-defined function object, an unbound user-defined method object, or a class method object. class A(object): # func: A user-defined function object...
try (Realm realm = Realm.getDefaultInstance()) { realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm realm) { //whatever Transaction that has to be done } }); //No need to close realm in try-wit...
ggplot(data = diamonds, aes(x = cut, fill =color)) + geom_bar(stat = "count", position = "dodge") it is possible to obtain an horizontal bar chart simply adding coord_flip() aesthetic to the ggplot object: ggplot(data = diamonds, aes(x = cut, fill =color)) + geom_ba...
angular .module('MyApp', []) .constant('VERSION', 1.0); Your constant is now declared and can be injected in a controller, a service, a factory, a provider, and even in a config method: angular .module('MyApp') .controller('FooterController', function(VERSION) { this.version = V...
There is no revolution here, but angular constant can be useful specially when your application and/or team starts to grow ... or if you simply love writing beautiful code! Refactor code. Example with event's names. If you use a lot of events in your application, you have event's names a lit...
Start a Script Block as background job: $job = Start-Job -ScriptBlock {Get-Process} Start a script as background job: $job = Start-Job -FilePath "C:\YourFolder\Script.ps1" Start a job using Invoke-Command on a remote machine: $job = Invoke-Command -ComputerName "ComputerName&...
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...
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...
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...

Page 331 of 826