Richtamikaola's Profile

215
Points

Questions
41

Answers
48

  • This is bit diff to explain about static key word for all beginners.
    You wil get to know it clearly when you work more with Classes and Objects.

    |*| Static : Static items can be called with Class Name
    If you observe in codes, Some functions are directly called with Class names like

    NamCls.NamFnc();  System.out.println(); 

    This is because NamFnc and println wil be declared using key word static before them.

    |*| Non Static :Non Static items can be called with Class Variable
    If its not static, you need a variable of the class,
    put dot after the class variable and
    then call function.

    NamCls NamObjVar = new NamCls(); NamObjVar.NamFnc(); 

    Below code explains you neatly

    |*| Static and non Static function in class :

    public class NamCls {     public static void main(String[] args)     {         PlsPrnFnc("Tst Txt");          NamCls NamObjVar = new NamCls();         NamObjVar.PrnFnc("Tst Txt");     }      static void PlsPrnFnc(String SrgPsgVal)     {         System.out.println(SrgPsgVal);     }      void PrnFnc(String SrgPsgVal)     {         System.out.println(SrgPsgVal);     } } 

    |*| Static and non Static Class inside a Class :

    public class NamCls {     public static void main(String[] args)     {         NamTicCls NamTicVaj = new NamTicCls();         NamTicVaj.PrnFnc("Tst Txt");          NamCls NamObjVar = new NamCls();         NamNicCls NamNicVar = NamObjVar.new NamNicCls();         NamNicVar.PrnFnc("Tst Txt");     }      static class NamTicCls     {         void PrnFnc(String SrgPsgVal)         {             System.out.println(SrgPsgVal);         }     }      class NamNicCls     {         void PrnFnc(String SrgPsgVal)         {             System.out.println(SrgPsgVal);         }     } } 
    • 686 views
    • 12 answers
    • 0 votes
  • The two most common ways to access properties in JavaScript are with a dot and with square brackets. Both value.x and value[x] access a property on value—but not necessarily the same property. The difference is in how x is interpreted. When using a dot, the part after the dot must be a valid variable name, and it directly names the property. When using square brackets, the expression between the brackets is evaluated to get the property name. Whereas value.x fetches the property of value named “x”, value[x] tries to evaluate the expression x and uses the result as the property name.

    So if you know that the property you are interested in is called “length”, you say value.length. If you want to extract the property named by the value held in the variable i, you say value[i]. And because property names can be any string, if you want to access a property named “2” or “John Doe”, you must use square brackets: value[2] or value["John Doe"]. This is the case even though you know the precise name of the property in advance, because neither “2” nor “John Doe” is a valid variable name and so cannot be accessed through dot notation.

    In case of Arrays

    The elements in an array are stored in properties. Because the names of these properties are numbers and we often need to get their name from a variable, we have to use the bracket syntax to access them. The length property of an array tells us how many elements it contains. This property name is a valid variable name, and we know its name in advance, so to find the length of an array, you typically write array.length because that is easier to write than array["length"].

    • 616 views
    • 13 answers
    • 0 votes
  • Take a look at node-cleanup. It’s a nice package that provides an easy way of cleaning up resources before the node process exits.

    const nodeCleanup = require('node-cleanup');   nodeCleanup((exitCode, signal) => {     // release resources here before node exits }); 
    • 398 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in Java Script.

    your code is fine. you don’t define the variables you want to set text to:

    var user={displayName:'bob'};  let everyHeaderUsername = document.getElementsByClassName("user-header-username");   for (let i = 0; i < everyHeaderUsername.length; ++i) {     everyHeaderUsername[i].textContent = `${user.displayName}`; }
    <div class="user-sign-in">Hi, <span class="user-header-username"></span> </div>

    • 293 views
    • 4 answers
    • 0 votes
  • To create empty data frame you just have to invoke emptyDataFrame function on SparkSession something like below.

    spark.emptyDataFrame 

    Where spark is SparkSession object.

    • 318 views
    • 2 answers
    • 0 votes
  • This process is called geocoding. You can read on how to do it from the documentation. In short, you pass and address and you would get the coordinates.

    • 302 views
    • 1 answers
    • 0 votes
  • Asked on July 15, 2020 in Python.

    One way you could do that is through Pandas and Matplotlib

    import pandas as pd import matplotlib.pyplot as plt  df = pd.read_csv('your_csv_file.csv', sep=';')  x_col  = 'DateTime' y_cols = [col for col in df.columns if col != x_col]  plt.plot(df[x_col], df[y_cols]) plt.show() 
    • 293 views
    • 1 answers
    • 0 votes
  • it’s pretty painless to pop a couple methods in a file that will handle asynchronous data in a serialized order and give a more conventional flavour to your code. For example:

    module.exports = function () {   var self = this;    this.each = async (items, fn) => {     if (items && items.length) {       await Promise.all(         items.map(async (item) => {           await fn(item);         }));     }   };    this.reduce = async (items, fn, initialValue) => {     await self.each(       items, async (item) => {         initialValue = await fn(initialValue, item);       });     return initialValue;   }; }; 

    now, assuming that’s saved at ‘./myAsync.js’ you can do something similar to the below in an adjacent file:

    ... /* your server setup here */ ... var MyAsync = require('./myAsync'); var Cat = require('./models/Cat'); var Doje = require('./models/Doje'); var example = async () => {   var myAsync = new MyAsync();   var doje = await Doje.findOne({ name: 'Doje', noises: [] }).save();   var cleanParams = [];    // FOR EACH EXAMPLE   await myAsync.each(['bork', 'concern', 'heck'],      async (elem) => {       if (elem !== 'heck') {         await doje.update({ $push: { 'noises': elem }});       }     });    var cat = await Cat.findOne({ name: 'Nyan' });    // REDUCE EXAMPLE   var friendsOfNyanCat = await myAsync.reduce(cat.friends,     async (catArray, friendId) => {       var friend = await Friend.findById(friendId);       if (friend.name !== 'Long cat') {         catArray.push(friend.name);       }     }, []);   // Assuming Long Cat was a friend of Nyan Cat...   assert(friendsOfNyanCat.length === (cat.friends.length - 1)); } 
    • 699 views
    • 20 answers
    • 0 votes