Signup/Sign In

Answers

All questions must be answered. Here are the Answers given by this user in the Forum.

In my case I was putting my .js file before the jQuery script link, putting the .js file after the jQuery script link solved my issue.

***



***
3 years ago
you opened the file in binary mode:
***
with open(fname, 'rb') as f:
***
This means that all data read from the file is returned as **bytes** objects, not **str**. You cannot then use a string in a containment test:

***if 'some-pattern' in tmp: continue***
You'd have to use a **bytes** object to test against **tmp** instead:

***if b'some-pattern' in tmp: continue***
or open the file as a textfile instead by replacing the **'rb'** mode with **'r'**.
3 years ago
In my case, I was sending input elements instead of their values:

***$.post( '',{ registerName: $('#registerName') } )***
Instead of:

***$.post( '',{ registerName: $('#registerName').val() } )***
This froze my Chrome tab to a point it didn't even show me the 'Wait/Kill' dialog for when the page became unresponsive...
3 years ago
To start with, run a bring to refresh all ** origin/** refs to most recent:
***git fetch --all***
Backup your current branch:
***
git checkout -b backup-master
***
Then, you have two options:
***
git reset --hard origin/master*
**
OR If you are on some other branch:
***
git reset --hard origin/
***

*Explanation:*
**git fetch** downloads the latest from remote without trying to merge or rebase anything.

Then the **git reset resets** the master branch to what you just fetched. The **--hard** option changes all the files in your working tree to match the files in **origin/master**
3 years ago
I got this mistake often previously, and I am sure all PHP software engineer got this blunder in any event once previously.

Solution 1

This blunder may have been brought about by the clear spaces before the beginning of the record or after the finish of the file. These clear spaces ought not to be here.
***
echo "your code here";

?>
THERE SHOULD BE NO BLANK SPACES HERE
***
Solution 2:
If this isn't your case, at that point use ob_start to yield buffering:
***
ob_start();

// code

ob_end_flush();
?>
***
3 years ago
As far as I might be concerned, nothing worked until I rolled out this improvement to my pom.xml
***

...

...

maven-compiler-plugin
3.1

true
C:\Program Files\Java\jdk1.7.0_45\bin\javac.exe




***
Different Notes

I could see that m2e was executing in a JRE, not the JDK. Nothing I did changed this, including adding this to the eclipse.ini:
***
-vm
C:\Program Files\Java\jdk1.7.0_45\bin\javaw.exe
***
3 years ago
***
String myString = "1234";
int foo = Integer.parseInt(myString); ***

On the off chance that you take a gander at the Java documentation, you'll see the "get" is that this capacity can toss a **NumberFormatException**, which obviously you need to deal with
***
int foo;
try {
foo = Integer.parseInt(myString);
}
catch (NumberFormatException e)
{
foo = 0;
} ***

(This treatment defaults a deformed number to **0**, however you can accomplish something different on the off chance that you like.)

On the other hand, you can utilize an **Ints** technique from the Guava library, which in mix with Java 8's Optional, makes for an amazing and brief approach to change over a string into an int:
***
import com.google.common.primitives.Ints;

int foo = Optional.ofNullable(myString)
.map(Ints::tryParse)
.orElse(0)
***
3 years ago
Thrown when an application attempts to use null in a case where an object is required. These include:

Calling the instance method of a null object.
Accessing or modifying the field of a null object.
Taking the length of null as if it were an array.
Accessing or modifying the slots of null as if it were an array.
Throwing null as if it were a Throwable value.
Applications should throw instances of this class to indicate other illegal uses of the null object.

It is also the case that if you attempt to use a null reference with synchronized, that will also throw this exception, per the JLS:

SynchronizedStatement:
synchronized ( Expression ) Block
Otherwise, if the value of the Expression is null, a NullPointerException is thrown.
How do I fix it?
So you have a NullPointerException. How do you fix it? Let's take a simple example which throws a NullPointerException:

public class Printer {
private String name;

public void setName(String name) {
this.name = name;
}

public void print() {
printString(name);
}

private void printString(String s) {
System.out.println(s + " (" + s.length() + ")");
}

public static void main(String[] args) {
Printer printer = new Printer();
printer.print();
}
}
Identify the null values

The first step is identifying exactly which values are causing the exception. For this, we need to do some debugging. It's important to learn to read a stacktrace. This will show you where the exception was thrown:

Exception in thread "main" java.lang.NullPointerException
at Printer.printString(Printer.java:13)
at Printer.print(Printer.java:9)
at Printer.main(Printer.java:19)
Here, we see that the exception is thrown on line 13 (in the printString method). Look at the line and check which values are null by adding logging statements or using a debugger. We find out that s is null, and calling the length method on it throws the exception. We can see that the program stops throwing the exception when s.length() is removed from the method.

Trace where these values come from

Next check where this value comes from. By following the callers of the method, we see that s is passed in with printString(name) in the print() method, and this.name is null.

Trace where these values should be set

Where is this.name set? In the setName(String) method. With some more debugging, we can see that this method isn't called at all. If the method was called, make sure to check the order that these methods are called, and the set method isn't called after the print method.

This is enough to give us a solution: add a call to printer.setName() before calling printer.print().
3 years ago
Nobody seems to be explaining the difference between an array and an object.

**[] ** is declaring an array.

**{}** is declaring an object.

An array has all the features of an object with additional features (you can think of an array like a sub-class of an object) where additional methods and capabilities are added in the Array sub-class. In fact, **typeof [] === "object"** to further show you that an array is an object.

The additional features consist of a magic **.length** property that keeps track of the number of items in the array and a whole slew of methods for operating on the array such as


**.push()**, **.pop()**, **.slice()**, **.splice()**, etc... You can see a list of array methods here.

An object gives you the ability to associate a property name with a value as in:

***
var x = {};
x.foo = 3;
x["whatever"] = 10;
console.log(x.foo); // shows 3
console.log(x.whatever); // shows 10 ***
Object properties can be accessed either via the **x.foo** syntax or via the array-like **syntax x["foo"]**. The advantage of the latter syntax is that you can use a variable as the property name like x[myvar] and using the latter syntax, you can use property names that contain characters that Javascript won't allow in the **x.foo syntax**.

A property name can be any string value.

An array is an object so it has all the same capabilities of an object plus a bunch of additional features for managing an ordered, sequential list of numbered indexes starting from 0 and going up to some length. Arrays are typically used for an ordered list of items that are accessed by numerical index. And, because the array is ordered, there are lots of useful features to manage the order of the list **.sort()** or to add or remove things from the list.
3 years ago
The plain HTML way is to put it in a
wherein you specify the *desired target URL* in the action attribute.
***



***
If necessary, set CSS display: inline; on the form to keep it in the flow with the surrounding text. Instead of **** in above example, you can also use
3 years ago
Python 3.7+ or CPython 3.6
Dicts preserve insertion order in Python 3.7+. Same in CPython 3.6, but it's an implementation detail.
***
>>> x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
>>> {k: v for k, v in sorted(x.items(), key=lambda item: item[1])}
{0: 0, 2: 1, 1: 2, 4: 3, 3: 4}
***
or
***
>>> dict(sorted(x.items(), key=lambda item: item[1]))
{0: 0, 2: 1, 1: 2, 4: 3, 3: 4}
***
*Older Python*
It is not possible to sort a dictionary, only to get a representation of a dictionary that is sorted. Dictionaries are inherently orderless, but other types, such as lists and tuples, are not. So you need an ordered data type to represent sorted values, which will be a list—probably a list of tuples.

For instance,
***
import operator
x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
sorted_x = sorted(x.items(), key=operator.itemgetter(1))
sorted_x will be a list of tuples sorted by the second element in each tuple. dict(sorted_x) == x.
***
And for those wishing to sort on keys instead of values:
***
import operator
x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
sorted_x = sorted(x.items(), key=operator.itemgetter(0))
***
In Python3 since unpacking is not allowed we can use
***
x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
sorted_x = sorted(x.items(), key=lambda kv: kv[1])
***
If you want the output as a dict, you can use collections.OrderedDict:

***
import collections
sorted_dict = collections.OrderedDict(sorted_x)
***
3 years ago
Web Developer holds an important position in a company as he/she has to use a language from the client and convert it into a language that a computer understands i.e. HTML.


As you can imagine, web development requires a lot of effort and time along with an intricate understanding of how various components of web development work to stay ahead of your competitors.

At the same time, the mobile Internet has undergone many collateral changes, including responsive web design. Web developers did not pay much attention to responsivity until people shifted from PCs to smartphones. The value of responsivity increased exponentially when sites that were formerly viewed on desktops could now be accessed from compact gadgets.

Experts from Clever-Solution have analyzed the latest trends, distinguished the most viable ones, and estimated the projected time for their realization.


1. Artificial intelligence

The AI customizes the web design according to the user-based information & navigation. Along with this, Custom Web Design Company builds a robust AI-powered website that plays an extensive role and easy auto-generated websites.
AI are web designers’ next best friend, can give designers more such features as

1) AI performs the tedious task quickly and skips your website from scratch.

2) The technology analyses human behavior and then personalizes the content and design of the website to individual visitors.

3) AI helps the designer in making their work simpler and provides better designing tools & software.

4) Enable the functionality that can manage your own website without problems.

2. Internet of Things

The world's technology is revolving around IoT apps. IoT app development has already created a great impact on every sphere of our life. The technology is worldwide popular, accepted by people all over the globe, and achieved remarkable success in all major sectors like smart home systems, education, machinery, security, healthcare, and much more.

3. Virtual Reality

360 Degree video creation is one of the most sought-after skills that is currently cherished by major organizations across the world. The 360-degree videos are responsible for offering an interactive and enhanced UI design that further helps in the growth of a website by driving more engagement.


4. Voice Command

Voice command is another example of the AI and its implementations. A user can now use the voice commands to control and handle every prospect of his smartphone, TV screens, laptops, tablets or more. The technology has eventually enhanced as compared to the past years.
3 years ago