Tutorial by Examples: and

There are many cases when one has created an NSDate from only an hour and minute format, i.e: 08:12 that returns from a server as a String and you initiate an NSDate instance by these values only. The downside for this situation is that your NSDate is almost completely "naked" and what yo...
ANTLR is distributed as a Java Jar file It can be downloaded here. As ANTLR is compiled as a jar file it subsequently requires the Java runtime environment to operate, if you do not have It can be downloaded here. Once the ANTLR JAR file has been downloaded you can run ANTLR from the command line i...
As discussed in the introduction, the gradle wrapper functionality works because a jar is downloaded into the project to be used when the gradlew command is run. However this may not get committed and after the next time the project is checked out, gradlew will fail to run with the error: Error: C...
Create SharedPreferences BuyyaPref SharedPreferences pref = getApplicationContext().getSharedPreferences("BuyyaPref", MODE_PRIVATE); Editor editor = pref.edit(); Storing data as KEY/VALUE pair editor.putBoolean("key_name1", true); // Saving boolean - true/false ...
Let's say you have class with generic methods. And you need to call its functions with reflection. public class Sample { public void GenericMethod<T>() { // ... } public static void StaticMethod<T>() { //... } } Let's say we want to...
\documentclass{report} \begin{document} \title{I want to be a Wombat} \author{Carl Capybara} \maketitle \end{document} This will create a title page with no other content:
// Example of std::vector as an expanding dynamic size array. #include <algorithm> // std::sort #include <iostream> #include <vector> // std::vector using namespace std; int int_from( std::istream& in ) { int x = 0; in >> x; return x; } ...
Once the number of abilities definitions start to grow in number, it becomes more and more difficult to handle the Ability file. The first strategy to handle these issue is to move abilities into meaningful methods, as per this example: class Ability include CanCan::Ability def initialize(...
LISP and Scheme's greatest advantage over other mainstream programming language is their macro system. Unlike the C preprocessor and other macro languages, Scheme macros take parsed code as input and return expanded code as output. This is one of the applications of Scheme's “code is data” phrase, a...
When you implement java.io.Serializable interface to make a class serializable, the compiler looks for a static final field named serialVersionUID of type long. If the class doesn't have this field declared explicitly then the compiler will create one such field and assign it with a value which come...
Converting an integer type to the corresponding promoted type is better than converting it to some other integer type. void f(int x); void f(short x); signed char c = 42; f(c); // calls f(int); promotion to int is better than conversion to short short s = 42; f(s); // calls f(short); exact mat...
Whatever you do to customize Vim, it should NEVER happen outside of $HOME: on Linux, BSD and Cygwin, $HOME is usually /home/username/, on Mac OS X, $HOME is /Users/username/, on Windows, $HOME is usually C:\Users\username\. The canonical location for your vimrc and your vim directory is at ...
Don't forget the bang to allow Vim to overwrite that command next time you reload your vimrc. Custom commands must start with an uppercase character. Examples command! MyCommand call SomeFunction() command! MyOtherCommand command | Command | command See :help user-commands.
Autocommand groups are good for organization but they can be useful for debugging too. Think of them as small namespaces that you can enable/disable at will. Example augroup MyGroup " Clear the autocmds of the current group to prevent them from piling " up each time you rel...
Using the baseline-shift parameter, you can specify super- or subscript. But this is not supported by all major browsers. <svg xmlns="http://www.w3.org/2000/svg"> <text x="10" y="20">x<tspan baseline-shift="super">2</tspan></te...
NSString *someString = @" Objective-C Language \n"; NSString *trimmedString = [someString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; //Output will be - "Objective-C Language" Method stringByTrimmingCharactersInSet returns a new str...
Simple Example (centering a single element) HTML <div class="aligner"> <div class="aligner-item">…</div> </div> CSS .aligner { display: flex; align-items: center; justify-content: center; } .aligner-item { max-width: 50%; /*for d...
A Button directive which accepts an @Input() to specify a click limit until the button gets disabled. The parent component can listen to an event which will be emitted when the click limit is reached via @Output: import { Component, Input, Output, EventEmitter } from '@angular/core'; @Component(...
Creating a custom ImplicitNamingStrategy allows you to tweak how Hibernate will assign names to non-explicitly named Entity attributes, including Foreign Keys, Unique Keys, Identifier Columns, Basic Columns, and more. For example, by default, Hibernate will generate Foreign Keys which are hashed an...
The following code can be entered in a Tcl shell (tclsh), or into a script file and run through a Tcl shell: puts "Hello, world!" It gives the string argument Hello, world! to the command puts. The puts command writes its argument to standard out (your terminal in interactive mode) an...

Page 43 of 153