Monday

Variables in swift : syntax with example



In all types of programming languages a variable is a container which holds the value
while the swift program is executed. A variable is assigned with a datatype.
Variable is a name of memory location. 


Swift 6 has a specific type:
  • Character
  • Int or UInt
  • Float 
  • Double
  • Bool
  • String


Variable declaration:


Syntax : var variable_name = <initial_value>


Example : var int a = 10
print(a); 


Result : 10


Swift 4 also allows to define various other types of variables, which we will cover in another post 
such as Optional, Array, Dictionaries, Structures, and Classes.

Thursday

Cloud Firestore for applications and web

Cloud Firestore

Cloud Firestore is a NoSQL document database built for automatic scaling, high performance, and ease of application development. While the Cloud Firestore interface has many of the same features as traditional databases, as a NoSQL database it differs from them in the way it describes relationships between data objects.

Firebase database was enough for basic applications. But it was not powerful enough to handle complex requirements. That is why Cloud Firestore is introduced. Here are some major changes.

  • The basic file structure is improved.

  • Offline support for the web client.

  • Supports more advanced querying.

  • Write and transaction operations are atomic.

  • Reliability and performance improvements

  • Scaling will be automatic.

  • Will be more secure.


In Realtime database of Firebase, it provides only the following features
  • Stores data as one large JSON tree.

  • Simple data is very easy to store.

  • Complex, hierarchical data is harder to organize at scale.

But in Firestone completely different data structure has been followed.
  • Stores data in documents organized in collections.
  • Simple data is easy to store in documents, which are very similar to JSON.

  • Complex, hierarchical data is easier to organize at scale, using subcollections within documents.

  • Requires less denormalization and data flattening.

Wednesday

Java Generics



Generics were added by JDK 5. By using generics you can define an algorithm once, and you can apply it on any kind of datatype without any additional effort.
At very high level, generics are nothing but parameterized types. Generics helps us to create a single class, which can be useful to operate on multiple data types. A class, interface or a method that operates on a parameterized type is called generics class, interface or method. Generics adds type safty. Remember that generics only works on objects, not primitive types.
Example-

package com.netparam.generics;

public class MySimpleGenerics {

    public static void main(String a[]){
         
        //we are going to create SimpleGeneric object with String as type parameter
        SimpleGeneric<String> sgs = new SimpleGeneric<String>("NETPARAM");
        sgs.printType();
        //we are going to create SimpleGeneric object with Boolean as type parameter
        SimpleGeneric<Boolean> sgb = new SimpleGeneric<Boolean>(Boolean.TRUE);
        sgb.printType();
    }
}

/**
 * Here T is a type parameter, and it will be replaced with
 * actual type when the object got created.
 */
class SimpleGeneric<T>{
     
    //declaration of object type T
    private T objReff = null;
     
    //constructor to accept type parameter T
    public SimpleGeneric(T param){
        this.objReff = param;
    }
     
    public T getObjReff(){
        return this.objReff;
    }
     
    //this method prints the holding parameter type
    public void printType(){
        System.out.println("Type: "+objReff.getClass().getName());
    }
}


Output-
Type java.lang.String
Type java.lang.Boolean


Monday

Java Console Class


System class
The System class provides facilities such as the standard input, output and error streams. It also provides means to access properties associated with the Java runtime system and various environment properties such as version, path, vendor and so on. Fields of this class are in, out and err which represent the standard input, output and error respectively.
Java Console Class
The Java Console class is be used to get input from console. Console class comes under Java.io.Console class
Let's see the code to get the instance of Console class.
Console c=System.console();  
Console Example
import java.io.Console;  
class ReadStringTest{    
public static void main(String args[]){    
Console c=System.console();    
System.out.println("Enter your name: ");    
String n=c.readLine();    
System.out.println("Welcome  to "+n);    
}    
}  
Output
Enter your name: Information Tech
Welcome to Information Tech


Sunday

DatagramSocket



The java.net.DatagramSocket class has three constructors:
 public DatagramSocket() throws SocketException
 public DatagramSocket(int port) throws SocketException
 public DatagramSocket(int port, InetAddress laddr) throws SocketException
The first is used for datagram sockets that are primarily intended to act as clients; that is sockets that will send datagrams before receiving any.
The secned two that specify the port and optionally the IP address of the socket, are primarily intended for servers that must run on a well-known port.
The LocalPortScanner developed earlier only found TCP ports. The following program detects UDP ports in use.
import java.net.*;
import java.io.IOException;


public class NetparamScanner {

  public static void main(String[] args) {

    boolean rootaccess = false;
    for (int port = 1; port < 1024; port += 50) {
      try {
        ServerSocket ss = new ServerSocket(port);
        // if successful
        rootaccess = true;
        ss.close();
        break;
      }
      catch (IOException ex) {
      }
    }
   
    int startport = 1;
    if (!rootaccess) startport = 1024;
    int stopport = 65535;
   
    for (int port = startport; port <= stopport; port++) {
      try {
        DatagramSocket ds = new DatagramSocket(port);
        ds.close();
      }
      catch (IOException ex) {
        System.out.println("UDP Port " + port + " is occupied.");
      }
   
    }

  }

}
Since UDP is connectionless it is not possible to write a remote UDP port scanner. The only way you know whether or not a UDP server is listening on a remote port is if it sends something back to you.


DatagramPacket in Java



The DatagramPacket class is a wrapper for an array of bytes from which data will be sent or into which data will be received. It also contains the address and port to which the packet will be sent.
 public DatagramPacket(byte[] data, int length)
 public DatagramPacket(byte[] data, int length, InetAddress host, int port)
You construct a DatagramPacket object by passing an array of bytes and the number of those bytes to send to the DatagramPacket() constructor like this:
 String s = "My first UDP Packet"
  byte[] b = s.getBytes();
  DatagramPacket dp = new DatagramPacket(b, b.length);
Normally you'll also pass in the host and port to which you want to send the packet:
try {
  InetAddress metalab = new InetAddress("netparam.com");
  int chargen = 19;
  String s = "My second UDP Packet"
  byte[] b = s.getBytes();
  DatagramPacket dp = new DatagramPacket(b, b.length, metalab, chargen);
}
catch (UnknownHostException ex) {
  System.err.println(ex);
}
The byte array that's passed to the constructor is stored by reference, not by value. If you cahnge it's contents elsewhere, the contents of the DatagramPacket change as well.
DatagramPackets themselves are not immutable.
You can change the data, the length of the data, the port, or the address at any time with these four methods:
 public void setAddress(InetAddress host)
 public void setPort(int port)
 public void setData(byte buffer[])
 public void setLength(int length)
You can retrieve these items with these four get methods:
 public InetAddress getAddress()
 public int getPort()
 public byte[] getData()
 public int getLength()
These methods are primarily useful when you're receiving datagrams.


इन स्मार्टफोन से निकलता है सबसे ज्यादा रेडिएशन: रिपोर्ट



भारत में आए दिन नए-नए स्मार्टफोन लॉन्च हो रहे हैं। ग्राहकों में बजट स्मार्टफोन की काफी डिमांड है, ऐसे में जब भी ग्राहक नया बजट फोन खरीदते हैं तो उनका ध्यान केवल हैंडसेट के स्पेसिफिकेशन पर जाता है। इस बात से हम सभी वाकिफ हैं कि फोन से निकलने वाला रेडिएशन कितना खतरनाक होता है।

जर्मन फेडलर ऑफिस ऑफ रेडिएशन प्रोटेक्शन द्वारा की गई रिसर्च के आकंड़े चौंकाने वाले हैं। हाल ही में जारी हुई लिस्ट में उन हैंडसेट के नाम शुमार हैं जिनसे सबसे ज्यादा रेडिएशन निकलता है।

जर्मन फेडलर ऑफिस ऑफ रेडिएशन द्वारा दिए डेटा के आधार पर इस लिस्ट को Statista द्वारा संगृहित किया गया है। लिस्ट में उन 16 स्मार्टफोन के नाम हैं जिनसे सबसे अधिक रेडिशन निकलता है और इस लिस्ट में सबसे ऊपर शाओमी और वनप्लस ब्रांड के फोन हैं। सैमसंग फोन के नाम उस लिस्ट में है जिनसे कम रेडिशन निकलता है। सैमसंग गैलेक्सी नोट 8 का स्पेसिफिक अब्जॉर्प्शन रेट (एसएआर) 0.17 वाट प्रति किलोग्राम है।

सबसे पहले बात सबसे ज्यादा रेडिशन करने वाले स्मार्टफोन की। Statista द्वारा पब्लिश लिस्ट में शाओमी एमआई ए 1 सबसे टॉप पर है, इसका स्पेसिफिक अब्जॉर्प्शन रेट (एसएआर) 1.74 वाट प्रति किलोग्राम है। वनप्लस 5टी दूसरे नंबर पर आता है इसका स्पेसिफिक अब्जॉर्प्शन रेट 1.68 वाट प्रति किलोग्राम है। एमआई मैक्स 3 तीसरे नंबर पर है और इसका स्पेसिफिक अब्जॉर्प्शन रेट 1.58 वाट प्रति किलोग्राम है।



यहां पढ़ें खबर- https://vigyancode.blogspot.com/p/new.html

New smartphones are being launched in India on the day of visit. Customers have a lot of demand for budget smartphones, so whenever they buy a new budget phone, their focus is only on specification of the handset. We are all aware of how dangerous the radiation emitted from the phone is.

Research reports by the German Fideller Office of Radiation Protection are shocking. In the recently released list, the names of those handsets come from which the maximum radiation emits.

Based on the data provided by the German Fideller Office of Radiation, this list has been collected by Statista. The list contains the names of the 16 smartphones from which the highest number of radiation comes out, and the top of this list is the phones of the MI and OnePlus brands. The name of the Samsung phone is in the list from which the low radiation emits. The Samsung Galaxy Note 8's specific billionarosation rate (SAR) is 0.17 watts per kilogram.

First of all, the most reducing smartphones In the public list by Statista, Mi A1 is at the top, its specific billionaration rate (SAR) is 1.74 watts per kilogram. OnePlus 5T comes second, its specific billionaration rate is 1.68 watt per kilogram. Mi Max 3 is at number three and its specific billionaration rate is 1.58 watts per kilogram.

read full story: https://vigyancode.blogspot.com/p/new.html