Signup/Sign In

Answers

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

If you want to keep the row with the lowest id value:

***DELETE n1 FROM names n1, names n2 WHERE n1.id > n2.id AND n1.name = n2.name***

If you want to keep the row with the highest id value:

***DELETE n1 FROM names n1, names n2 WHERE n1.id < n2.id AND n1.name = n2.name***
3 years ago
You can use the concept of multiple queries in the FROM keyword. Let me show you one example:

***SELECT DISTINCT e.id,e.name,d.name,lap.lappy LAPTOP_MAKE,c_loc.cnty COUNTY
FROM (
SELECT c.id cnty,l.name
FROM county c, location l
WHERE c.id=l.county_id AND l.end_Date IS NOT NULL
) c_loc, emp e
INNER JOIN dept d ON e.deptno =d.id
LEFT JOIN
(
SELECT l.id lappy, c.name cmpy
FROM laptop l, company c
WHERE l.make = c.name
) lap ON e.cmpy_id=lap.cmpy***
3 years ago
You could use:

***sorted(d.items(), key=lambda x: x[1])***

This will sort the dictionary by the values of each entry within the dictionary from smallest to largest.

To sort it in descending order just add ***reverse=True:***

sorted(d.items(), key=lambda x: x[1], reverse=True)
Input:

***d = {'one':1,'three':3,'five':5,'two':2,'four':4}
a = sorted(d.items(), key=lambda x: x[1])
print(a)***

Output:

***[('one', 1), ('two', 2), ('three', 3), ('four', 4), ('five', 5)]***
3 years ago
Use Android Query library, very cool indeed.You can change it to use ProgressDialog as you see in other examples, this one will show progress view from your layout and hide it after completion.

***File target = new File(new File(Environment.getExternalStorageDirectory(), "ApplicationName"), "tmp.pdf");
new AQuery(this).progress(R.id.progress_view).download(_competition.qualificationScoreCardsPdf(), target, new AjaxCallback() {
public void callback(String url, File file, AjaxStatus status) {
if (file != null) {
// do something with file
}
}
});***
3 years ago
For me, this works in windows.

***java -cp "/lib/*;" sample***
For linux

***java -cp "/lib/*:" sample***
3 years ago
To my understanding synchronized basically means that the compiler write a monitor.enter and monitor.exit around your method. As such it may be thread safe depending on how it is used (what I mean is you can write an object with synchronized methods that isn't threadsafe depending on what your class does).
3 years ago
An example of direct String usage since 1.7 may be shown as well:

***public static void main(String[] args) {

switch (args[0]) {
case "Monday":
case "Tuesday":
case "Wednesday":
System.out.println("boring");
break;
case "Thursday":
System.out.println("getting better");
case "Friday":
case "Saturday":
case "Sunday":
System.out.println("much better");
break;
}

}***
3 years ago
Yes there is a static nested class in java. When you declare a nested class static, it automatically becomes a stand alone class which can be instantiated without having to instantiate the outer class it belongs to.

Example:

***public class A
{

public static class B
{
}
}***
Because **class B** is declared static you can explicitly instantiate as:

***B b = new B();***
Note if **class B** wasn't declared static to make it stand alone, an instance object call would've looked like this:

***A a= new A();
B b = a.new B();***
3 years ago
I am not sure if it is the best way, but it worked for me.

1) First, I deleted the component folder.
2) Then, I cleared app.module.ts, app.component.ts & app.component.html of the imports and declarations related to the component I wanted to delete.
3) Similarly, I cleared main.ts.
I just saved and refreshed the app and it worked.
3 years ago
Do the following:

npm i bootstrap@next --save
This will add bootstrap 4 to your project.

Next go to your **src/style.scss** or **src/style.css** file (choose whichever you are using) and import bootstrap there:

For style.css

***/* You can add global styles to this file, and also import other style files */
@import "../node_modules/bootstrap/dist/css/bootstrap.min.css";**

For style.scss

***/* You can add global styles to this file, and also import other style files */
@import "../node_modules/bootstrap/scss/bootstrap";***

For scripts you will still have to add the file in the angular-cli.json file like so (In Angular version 6, this edit needs to be done in the file angular.json):

***"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/tether/dist/js/tether.js",
"../node_modules/bootstrap/dist/js/bootstrap.js"
],***
3 years ago
Quick, Simple and Error free method
i.e. You want to create a component in a **app/common** folder as shown in the image given below, then follow these steps

Right-click on the folder in which you want to create component.
Select option **Open in Integrated Terminal** or **Open in Command Prompt**.
In the new terminal (you'll see your selected path), then type **ng g c my-component**.
3 years ago
Pipe date format bug fixed in Angular 2.0.0-rc.2, this Pull Request.

Now we can do the conventional way:

***{{valueDate | date: 'dd/MM/yyyy'}}***
3 years ago