Draw To requires Core Text framework to be added in the Build Phase
[NSString* textToDraw = @"Welcome to the world Of IOS";
CFStringRef stringRef = (__bridge CFStringRef)textToDraw;
CFAttributedStringRef currentText = CFAttributedStringCreate(NULL, stringRef, NULL);
...
Extension methods enable you to simplify your interface definitions by only including core required functionality in the interface itself and allowing you to define convenience methods and overloads as extension methods. Interfaces with fewer methods are easier to implement in new classes. Keeping o...
Run command below to install nginx.
sudo apt-get install nginx
By default, Nginx automatically starts when it is installed. You can access the default Nginx landing page to confirm that the software is running properly by visiting your server's domain name or public IP address in your web browse...
wikipedia definition:
Command pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or trigger an event at a later time
UML diagram from dofactory:
Basic components and workflow:
Command declares an interface for abst...
You can test if a string matches several regular expressions using a switch statement.
Example
case "Ruby is #1!"
when /\APython/
puts "Boooo."
when /\ARuby/
puts "You are right."
else
puts "Sorry, I didn't understand that."
end
This w...
If-statements can be expressions:
val str = if (condition) "Condition met!" else "Condition not met!"
Note that the else-branch is not optional if the if-statement is used as an expression.
This can also been done with a multi-line variant with curly brackets and multiple el...
Like if, when can also be used as an expression:
val greeting = when (x) {
"English" -> "How are you?"
"German" -> "Wie geht es dir?"
else -> "I don't know that language yet :("
}
print(greeting)
To be used as an express...
To get the next element you can use the .next() method.
<ul>
<li>Mark</li>
<li class="anna">Anna</li>
<li>Paul</li>
</ul>
If you are standing on the "Anna" element and you want to get the next element, "Paul...
1. Fix your contexts:
Try using the appropriate context: For example since a Toast can be seen in many activities instead of in just one, use getApplicationContext() for toasts, and since services can keep running even though an activity has ended start a service with:
Intent myService = new Inten...
If you know that a value is of a specific type, you can explicitly cast it to that type in order to use it in a context where that type is needed.
object value = -1;
int number = (int) value;
Console.WriteLine(Math.Abs(number));
If we tried passing value directly to Math.Abs(), we would get a ...
If you aren't sure whether a value is of the type you think it is, you can safely cast it using the as operator. If the value is not of that type, the resulting value will be null.
object value = "-1";
int? number = value as int?;
if(number != null)
{
Console.WriteLine(Math.Abs(nu...
Explicit casting operators can be used to perform conversions of numeric types, even though they don't extend or implement one another.
double value = -1.1;
int number = (int) value;
Note that in cases where the destination type has less precision than the original type, precision will be lost....
data(AirPassengers)
class(AirPassengers)
1 "ts"
In the spirit of Exploratory Data Analysis (EDA) a good first step is to look at a plot of your time-series data:
plot(AirPassengers) # plot the raw data
abline(reg=lm(AirPassengers~time(AirPassengers))) # fit a trend line
For...
You can iterate on the object returned by groupby(). The iterator contains (Category, DataFrame) tuples.
# Same example data as in the previous example.
import numpy as np
import pandas as pd
np.random.seed(0)
df = pd.DataFrame({'Age': np.random.randint(20, 70, 100),
'Sex':...
You can also use the IEx (Interactive Elixir) shell to evaluate expressions and execute code.
If you are on Linux or Mac, just type iex on your bash and press enter:
$ iex
If you are on a Windows machine, type:
C:\ iex.bat
Then you will enter into the IEx REPL (Read, Evaluate, Print, Loop),...
Let's say we need to add a button for each piece of loadedData array (for instance, each button should be a slider showing the data; for the sake of simplicity, we'll just alert a message). One may try something like this:
for(var i = 0; i < loadedData.length; i++)
jQuery("#container&q...