Tutorial by Examples: ga

A pointer to a const object can be converted to a pointer to non-const object using the const_cast keyword. Here we use const_cast to call a function that is not const-correct. It only accepts a non-const char* argument even though it never writes through the pointer: void bad_strlen(char*); const...
You can open a new split within Vim with the following commands, in normal mode: Horizontally: :split <file name> :new Vertically: :vsplit <file name> :vnew split will open the file in a new split at the top or left of your screen (or current split.) :sp and :vs are convenie...
# make this routine available outside this translation unit .globl string_to_integer string_to_integer: # function prologue push %ebp mov %esp, %ebp push %esi # initialize result (%eax) to zero xor %eax, %eax # fetch pointer to the string mov 8(%ebp), %e...
This demonstrates a non-trivial example of wrapping a C++ dll with Cython. It will cover the following main steps: Create an example DLL with C++ using Visual Studio. Wrap the DLL with Cython so that it may be called in Python. It is assumed that you have Cython installed and can successfully...
The command prompt comes pre-installed on all Windows NT, Windows CE, OS/2 and eComStation operating systems, and exists as cmd.exe, typically located in C:\Windows\system32\cmd.exe On Windows 7 the fastest ways to open the command prompt are: Press Win 𐌎, type "cmd" and then press ...
Any ASCII editor can edit batch files. A list of editors that can syntax highlight batch syntax can be found here. You can also use the default notepad shipped with windows to edit and view a batch file, although it does not offer syntax highlighting. To open notepad: Press Win 𐌎+R, type notepa...
I have the following list: 1. Alon Cohen 2. Elad Yaron 3. Yaron Amrani 4. Yogev Yaron I want to select the first name of the guys with the Yaron surname. Since I don't care about what number it is I'll just put it as whatever digit it is and a matching dot and space after it from the beginni...
foldMap maps each element of the Foldable structure to a Monoid, and then combines them into a single value. foldMap and foldr can be defined in terms of one another, which means that instances of Foldable need only give a definition for one of them. class Foldable t where foldMap :: Monoid m...
import cv2 image_path= #put your image path here #use imread() function to read image data to variable img. img = cv2.imread(image_path) #display image data in a new window with title 'I am an image display window' cv2.imshow('I am an image display window',img) #wait until user hi...
The horizontally justified navigation (menu) bar has some number of items that should be justified. The first (left) item has no left margin within the container, the last (right) item has no right margin within the container. The distance between items is equal, independent on the individual item w...
An existing working copy can be quickly transformed to reflect the contents of a different branch in the same repository. For example, you might have a working copy of the trunk and now need to work on a development branch. Instead of checking out a completely new working copy (which can waste a l...
A Subversion repository can be configured so that certain contents or commands are only accessible to certain users. In order to access this restricted content, you will need to specify a username and password. Your username and password can be specified directly as part of the command: $ svn che...
public class IntStack { private IntStackNode head; // IntStackNode is the inner class of the class IntStack // Each instance of this inner class functions as one link in the // Overall stack that it helps to represent private static class IntStackNode { privat...
:mak[e][!] [arguments] will start the program referred to by the makeprg option. By default, makeprg is set to "make," but can be configured to invoke any appropriate program. All [arguments] (can be several) are passed to makeprg just as if it had been invoked with :!{makeprg} [arguments...
For sending and receiving events we first need an Event object. Event objects are actually simple POJOs. public class ArbitaryEvent{ public static final int TYPE_1 = 1; public static final int TYPE_2 = 2; private int eventType; public ArbitaryEvent(int eventType){ this....
A patch is a file that show the differences between two revisions or between your local repository and the last revision your repository is pointing. To share or save a patch of your local uncommitted changes either for peer review or to apply later, do: svn diff > new-feature.patch To get a...
// Add active class to active navigation link $(document).ready(function () { $('ul.nav.navbar-nav').find('a[href="' + location.pathname + '"]') .closest('li').addClass('active'); });
If you're doing multiple long calculations, you can run them at the same time on different threads on your computer. To do this, we make a new Thread and have it point to a different method. using System.Threading; class MainClass { static void Main() { var thread = new Thread(Seco...
using System.Threading; class MainClass { static void Main() { var thread = new Thread(Secondary); thread.Start("SecondThread"); } static void Secondary(object threadName) { System.Console.WriteLine("Hello World from thread: " + thread...
Sometimes, you want your threads to simultaneously share data. When this happens it is important to be aware of the code and lock any parts that could go wrong. A simple example of two threads counting is shown below. Here is some dangerous (incorrect) code: using System.Threading; class MainCl...

Page 53 of 137