Sometime you may require to ping an external website and check whether it’s up and running before you do any processing or fire request on the same.Here we will be seeing how to check whether the external website is up and running.Let’s being by Creating new projectStep 1 − Open Xcode → New Project → Single View Application → Let’s name it “PingMe”Step 2 − Open ViewController.swift and add the function checkIsConnectedToNetwork() and add the following code.func checkIsConnectedToNetwork() { let hostUrl: String = "https://google.com" if let url = URL(string: hostUrl) { var request = URLRequest(url: ... Read More
This example demonstrate about How to start a service from notification in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.package app.tutorialspoint.com.notifyme ; import android.app.AlarmManager ; import android.app.PendingIntent ; import android.content.Intent ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; import java.util.Calendar ; public class MainActivity extends AppCompatActivity { @Override protected void onCreate (Bundle savedInstanceState) { super ... Read More
Python is having special type of methods called magic methods named with preceded and double underscores.if we want to talk about magic method __new__ then obviously will also need to talk about __init__ method. The magic method __new__ will be called when instance is being created.where as __init__ method will be called to initialize instance when you are creating instance.Example Live Democlass X(): _dict = dict() def __new__(self): if 'data' in X._dict: print ("new instance Exists") return X._dict['data'] else: print ("magic method New") return super(X, self).__new__(self) def __init__(self): print ("instantiation") X._dict['data'] = self print ("") a1 = X() ... Read More
Use the setTabPlacement() method to set the tab location. To make it visible in the bottom, use the BOTTOM constant −JTabbedPane tabbedPane = new JTabbedPane(); tabbedPane.setTabPlacement(JTabbedPane.BOTTOM);The following is an example to specify tab location to make it visible in the bottom −package my; import javax.swing.*; import java.awt.*; import java.awt.event.KeyEvent; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Technologies"); JTabbedPane tabbedPane = new JTabbedPane(); JPanel panel1, panel2, panel3, panel4, panel5; panel1 = new JPanel(); panel2 = new JPanel(); ... Read More
You can use pop() for this. Let us first create a collection with documents −> db.persistChangeDemo.insertOne({"Name" : "Larry", "CreditScore": [500, 700, 760, 100]}); { "acknowledged" : true, "insertedId" : ObjectId("5cdfc52cbf3115999ed51203") }Following is the query to display all documents from a collection with the help of find() method −> db.persistChangeDemo.find().pretty();This will produce the following output −{ "_id" : ObjectId("5cdfc52cbf3115999ed51203"), "Name" : "Larry", "CreditScore" : [ 500, 700, 760, 100 ] }Following is the query to pop a value −> myDocument.CreditScore.pop(); 100Let us save ... Read More
In this article, we are going to see how we can print the escape characters in Python. I think you know what escape characters are? Let's see what escape characters for those who don't know are?Escape characters are used for the individual meanings in strings. If we want to include a new line, tab space, etc., in strings, we can use these escape characters. Let's see some examples.Example Live Demo## new line new_line_string = "HiHow are you?" ## it will print 'Hi' in first line and 'How are you?' in next line print(new_line_string)OutputIf you run the above program, it will ... Read More
For this, you can use GROUP BY clause along with IN(). Let us first create a table −mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(100) -> ); Query OK, 0 rows affected (0.87 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Name) values('John'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(Name) values('Chris'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Name) values('David'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(Name) values('Chris'); Query ... Read More
The HTML DOM Input URL autocomplete property sets/returns whether autocomplete is enabled or disabled. If enabled it shows previously typed values.SyntaxFollowing is the syntax −Returning value - on/offinputURLObject.autocompleteSetting autocomplete to valueinputURLObject.autocomplete = valueValuesHere, “value” can be the following −valueDetailsonIt defines that input has autocomplete attribute enabled.offIt defines that input autocomplete attribute is disabled.ExampleLet us see an example of Input URL autocomplete property − Live Demo Input URL autocomplete form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; ... Read More
To create high resolution timer we can use the chrono library. This library has high resolution clock. This can count in nanoseconds.In this program we will see the execution time in nanoseconds. We will take the time value at first, then another time value at the last, then find the difference to get elapsed time. Here we are using blank loop to pause the effect for sometimes.Example#include #include typedef std::chrono::high_resolution_clock Clock; main(){ auto start_time = Clock::now(); for(int i = 0; i
Locking of iOS device cannot be done programmatically without the use of Private API’s. One such private API’s GSEventLockDevice() (private API) from GraphicsServices.framework which might help you achieve your persona but the application would result in rejection from Apple’s App Store.More over there’s no documentation provided by apple for the same.On a final note you cannot achieve this functionality without using the Private API’s and if you are using your application will be rejected by Apple.