Samual Sam has Published 2492 Articles

How to detect if an iOS application is in background or foreground?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

3K+ Views

To detect if an iOS application is in background or foreground we can simply use the UIApplication just like we can use it to detect many other things like battery state, status etc.Let’s see how we can do this in our application. We’ll make use of shared resources of our ... Read More

Get the record of a specific year out of timestamp in MySQL?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

256 Views

You can get year out of timestamp using YEAR() function. The syntax is as follows −SELECT yourColumnName FROM yourTableName WHERE YEAR(yourTimestampColumnName)='yourYearValue’';To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table getYearOut    -> (    -> Id int ... Read More

Garbage Collection in Python

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

817 Views

Python memory management is straight forward. You don’t need to worry about memory management, as memory allocation and deallocation is automatic. one of the mechanisms of memory management is garbage collection. Let’s understand different aspects of garbage collection, Garbage collectionIt is the process by which shared computer memory is cleaned ... Read More

How to request permission programatically to use location services in iPhone/iOS?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

187 Views

To request location services permission in ios with swift we can use the CLLocationManager.We’ll do this with help of a sample project. So, create a new project. First, we need to create a locationManager object, so in your view controller.var locationManager = CLLocationManager()Now, we, first of all, we need to ... Read More

Vertically align numeric values in Java using Formatter

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

396 Views

To vertically align numeric values in Java, use Formatter. For working with Formatter class, import the following package.import java.util.Formatter;Take an array −double arr[] = { 2.5, 4.8, 5.7, 6.5, 9.4, 8.4, 9.5, 10.2, 11.5 };While displaying this double array values, use the %f to set spaces −for (double d : ... Read More

How to give dynamic height to UIlabel programmatically in swift?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

3K+ Views

To give a dynamic height to an UIlabel in swift we can use the frame property of UILabel. We can create a frame using the CGRect which allows us to give different variables like x position, y position, width, and height.Let’s create a label and add it as a subview ... Read More

How to convert wrongly encoded data to UTF-8 in MySQL?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

2K+ Views

You need to use CONVERT() function along with binary keyword. The syntax is as follows −SELECT CONVERT(binary CONVERT(yourColumnName using latin1) USING UTF8) as anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table UtfDemo    -> ... Read More

Space format specifiers in Java

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

1K+ Views

For format specifier, import the following package −import java.util.Formatter;Create a formatter object and set space format specifier −Formatter f = new Formatter(); f.format("% d", -50); System.out.println(f); f = new Formatter(); f.format("% d", 90); System.out.println(f); f = new Formatter(); f.format("%10d", -50); System.out.println(f); f = new Formatter(); f.format("% 10d", 90); System.out.println(f);The following ... Read More

How to create scrollable TextView on iOS App?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

1K+ Views

To create a scrollable TextView in iOS we can do it in two ways, one by creating it using the storyboard and other by creating another textView programmatically.A text view is scrollable by default if it has text more than the height of textView and the scrollable property is disabled.1.Using ... Read More

Basic Slicing and Advanced Indexing in NumPy Python

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:24

413 Views

Indexing of ndarrays can be done using the standard python x[obj] syntax, where x is the array and obj the selection.There are three kinds of indexing available −field accessbasic slicingadvanced indexingWhat kind of indexing will be there depends on obj. In this section, we are going to mainly concentrate on ... Read More

Advertisements