问:
Fragments Overlapping views
I am working on fragments, but there is a problem when i switch from one fragment to other view overlap eachother.

I am using following code to switch fragments.

```<code>getSupportFragmentManager()
            .beginTransaction()
            .add(R.id.mainContainer, new SecondsFragment())
            .addToBackStack(null)
            .commit();
</code>```

I know that using add() will only add newer fragment over the previous one. I dont want to use replace because it reloads everything when i return to that fragment using onBackPress() e-g i have REST API calls in first fragment when i open second fragment using replace() function and return to first fragment it will again call that REST API, which is not good for UX.

If i use add() to load second fragment, the view of second fragment overlaps view of first fragment, and returning to first fragment not call that REST API (my desired behaviour).

I also know that by setting background of fragments xml parent view, this issue can be resolved but then it will also cause accidental clicks on first fragments views again bad for UX, i also read in SO by setting parent view clickable to true will resolve this issue too, but as other developers said it is just a hack not a proper solution.

I am expecting users like commonsware to address this question.

Any suggestions/comments are highly welcome.

Thanks in Advance.

答:
You can instance first fragment and set it as active fragment. When you select second fragment, hide active fragment (fragment 1), and set second fragment as active.

Ex.

```<code>    fragment1 = Fragment1.newInstance();
    active = fragment1;

    getFragmentManager()
   .beginTransaction()
   .add(R.id.fragment_container, fragment1, "1")
   .commit();
</code>```

When you select your second fragment, you can do something like this:

```<code> if (isFirstTimeLoading) {
    fragment2 = Fragment2.newInstance();
    getFragmentManager()
   .beginTransaction()
   .add(R.id.fragment_container, fragment2)
   .hide(active)
   .commit();

    active = fragment2;
    isFirstTimeLoading = false;
 } else {
    getFragmentManager()
   .beginTransaction()
   .hide(active)
   .show(fragment2)
   .commit();

    active = fragment2;
 }
</code>```

Title: Fragments Overlapping views

Body:
I am working on fragments, but there is a problem when i switch from one fragment to other view overlap eachother.

I am using following code to switch fragments.

getSupportFragmentManager()
            .beginTransaction()
            .add(R.id.mainContainer, new SecondsFragment())
            .addToBackStack(null)
            .commit();

I know that using add() will only add newer fragment over the previous one. I dont want to use replace because it reloads everything when i return to that fragment using onBackPress() e-g i have REST API calls in first fragment when i open second fragment using replace() function and return to first fragment it will again call that REST API, which is not good for UX.

If i use add() to load second fragment, the view of second fragment overlaps view of first fragment, and returning to first fragment not call that REST API (my desired behaviour).

I also know that by setting background of fragments xml parent view, this issue can be resolved but then it will also cause accidental clicks on first fragments views again bad for UX, i also read in SO by setting parent view clickable to true will resolve this issue too, but as other developers said it is just a hack not a proper solution.

I am expecting users like commonsware to address this question.

Any suggestions/comments are highly welcome.

Thanks in Advance.

Body:
You can instance first fragment and set it as active fragment. When you select second fragment, hide active fragment (fragment 1), and set second fragment as active.

Ex.

    fragment1 = Fragment1.newInstance();
    active = fragment1;

    getFragmentManager()
   .beginTransaction()
   .add(R.id.fragment_container, fragment1, "1")
   .commit();

When you select your second fragment, you can do something like this:

 if (isFirstTimeLoading) {
    fragment2 = Fragment2.newInstance();
    getFragmentManager()
   .beginTransaction()
   .add(R.id.fragment_container, fragment2)
   .hide(active)
   .commit();

    active = fragment2;
    isFirstTimeLoading = false;
 } else {
    getFragmentManager()
   .beginTransaction()
   .hide(active)
   .show(fragment2)
   .commit();

    active = fragment2;
 }


来源: stackexchange

问:
ColdFusion CFLOCATION doesn't work with special characters
Some SEO audit tools reports same URL with different case as being duplicate content. In order to avoid this, I try to always use the lowercase version but some links were indexed with a different case, so what I am doing is to read the current URL and compare it with the lowercase version. If it's different I am doing a 301 redirect - using CFLOCATION tag to the lowercase version. So far so good with this exception...

I had to use the picture because even here I couldn't copy-paste the URL just like you see it above. Instead the paste will make it look like this:

https://gr.mynetmoto.com/shop.cfm/M%CE%BF%CF%84%CE%BF%CF%83%CF%85%CE%BA%CE%BB%CE%AD%CF%84%CE%B1-%CE%BB%CE%AC%CF%83%CF%84%CE%B9%CF%87%CE%B1.html

I am using this code to do the 301 redirect:

```<code><cflocation url="#VARIABLES.correct_url#" statuscode="301" addtoken="no">
</code>```

For the above URL's it doesn't work. Any ideas? I have tried to encode/decode the string, but no luck.

答:
The right way to fix this problem seems to be the replacement of CFLOCATION tag with CFHEADER

```<code><cfheader charset="utf-8" name="location" value="#VARIABLES.correct_url#">
<cfheader statuscode="301">
</code>```

Thank you for your help @Ageax

ContentLicense: CC BY-SA 3.0

Body:
Some SEO audit tools reports same URL with different case as being duplicate content. In order to avoid this, I try to always use the lowercase version but some links were indexed with a different case, so what I am doing is to read the current URL and compare it with the lowercase version. If it's different I am doing a 301 redirect - using CFLOCATION tag to the lowercase version. So far so good with this exception...

I had to use the picture because even here I couldn't copy-paste the URL just like you see it above. Instead the paste will make it look like this:

https://gr.mynetmoto.com/shop.cfm/M%CE%BF%CF%84%CE%BF%CF%83%CF%85%CE%BA%CE%BB%CE%AD%CF%84%CE%B1-%CE%BB%CE%AC%CF%83%CF%84%CE%B9%CF%87%CE%B1.html

I am using this code to do the 301 redirect:

<cflocation url="#VARIABLES.correct_url#" statuscode="301" addtoken="no">

For the above URL's it doesn't work. Any ideas? I have tried to encode/decode the string, but no luck.

Body:
The right way to fix this problem seems to be the replacement of CFLOCATION tag with CFHEADER

<cfheader charset="utf-8" name="location" value="#VARIABLES.correct_url#">
<cfheader statuscode="301">

Thank you for your help @Ageax


问:
I need to add a tinyint value in the result of a SELECT
It's 2 days that i'm torned with this task and i can't really find a solution since i'm not an expert of MySQL. So basically i have this query

```<code>sql.Append("select distinct ");
sql.Append(@"{0}.field1,
             {0}.field2,
             {0}.field3,
             {0}.field4,
             {0}.field5,
             ---
             ---
             false as customField1,
             false as customField2,
             {1}.name as customfield3
             from {0} join {1} on {0}.field2check = {1}.id where field2check = ?condition");
</code>```

this is the text of a select that i'm building in my c# class. This query is then completed and feeded to the database, that give me in response a table that is stored in a DataTable. My problem is that this fields

```<code>false as customField1,
false as customField2,
{1}.name as customfield3
</code>```

are actually obtained after the evaluation of a condition and must return a tinyint(1) to be interpreted as boolean in my c# code, since the bool type don't exist in my sql. If i write directly 0 or 1, this value is casted as BIGINT that is interpreted as Int32 in c#.

I know that i can create a custom function to be stored in my db like

```<code>CREATE FUNCTION myDb.x_cast_to_tinyint(number bigint) RETURNS tinyint(1)
return number;
</code>```

But this is forbidden in my case (my boss simply don't want to save function in db). Now i was looking to create a temporary table to store the result of this query, but the problem is that i have no clue on how to do that. Something like

```<code>create temporary table myDB.res (customfield1 tinyint(1).... ) as (put the select here)
</code>```

The problems here are 2. First i don't know how to define all the columns of this table, cause it should have the same structure of an existing table plus 3 custom columns. Even if i successfully create this table, how long does it last?. Can i query this table to select * from it?

I am open also to other solutions. If you need other details let me know

EDIT : forgot to mention this. The c# part should remain untouched. I thought to make a converter for those specific column of my datatable but also this solution received a big no in response (and i'm in part good with it, case my c# code should only represent the data, and shouldn't know anything about the structure of the database)

答:
You could try something like this, although I think it's more complex than adding a function:

```<code>CREATE TEMPORARY TABLE myTempTable LIKE theFirstTable;
ALTER TABLE myTempTable
    ADD COLUMN customField1 TINYINT(1),
    ADD COLUMN customField2 TINYINT(1),
    ADD COLUMN customField3 TINYINT(1);
INSERT INTO myTempTable
    SELECT o.*, customField1, customField2, customField3
    FROM originalTable o...
</code>```

Obviously, you have to customize this approach to your needs, but the advantage is that temporary table will last until the connection is closed or you explicitly drop it.

Body:
It's 2 days that i'm torned with this task and i can't really find a solution since i'm not an expert of MySQL. So basically i have this query

sql.Append("select distinct ");
sql.Append(@"{0}.field1,
             {0}.field2,
             {0}.field3,
             {0}.field4,
             {0}.field5,
             ---
             ---
             false as customField1,
             false as customField2,
             {1}.name as customfield3
             from {0} join {1} on {0}.field2check = {1}.id where field2check = ?condition");

this is the text of a select that i'm building in my c# class. This query is then completed and feeded to the database, that give me in response a table that is stored in a DataTable. My problem is that this fields

false as customField1,
false as customField2,
{1}.name as customfield3

are actually obtained after the evaluation of a condition and must return a tinyint(1) to be interpreted as boolean in my c# code, since the bool type don't exist in my sql. If i write directly 0 or 1, this value is casted as BIGINT that is interpreted as Int32 in c#.

I know that i can create a custom function to be stored in my db like

CREATE FUNCTION myDb.x_cast_to_tinyint(number bigint) RETURNS tinyint(1)
return number;

But this is forbidden in my case (my boss simply don't want to save function in db). Now i was looking to create a temporary table to store the result of this query, but the problem is that i have no clue on how to do that. Something like

create temporary table myDB.res (customfield1 tinyint(1).... ) as (put the select here)

The problems here are 2. First i don't know how to define all the columns of this table, cause it should have the same structure of an existing table plus 3 custom columns. Even if i successfully create this table, how long does it last?. Can i query this table to select * from it?

I am open also to other solutions. If you need other details let me know

EDIT : forgot to mention this. The c# part should remain untouched. I thought to make a converter for those specific column of my datatable but also this solution received a big no in response (and i'm in part good with it, case my c# code should only represent the data, and shouldn't know anything about the structure of the database)

Body:
You could try something like this, although I think it's more complex than adding a function:

CREATE TEMPORARY TABLE myTempTable LIKE theFirstTable;
ALTER TABLE myTempTable
    ADD COLUMN customField1 TINYINT(1),
    ADD COLUMN customField2 TINYINT(1),
    ADD COLUMN customField3 TINYINT(1);
INSERT INTO myTempTable
    SELECT o.*, customField1, customField2, customField3
    FROM originalTable o...

Obviously, you have to customize this approach to your needs, but the advantage is that temporary table will last until the connection is closed or you explicitly drop it.


问:
Filter Stored Procedure Results using Linq
I have this code that get date from server using SP with EF

```<code>  List<sp_PlacementSearchResult_Result> listResults = new List<sp_PlacementSearchResult_Result>();
  var query = Context.sp_PlacementSearchResult(request.HasamaFormId, request.DepartmentId, request.InstitutionNum, request.IsSigned).AsQueryable();
</code>```

This is working, now i'd like to add some filter to the result like this:

```<code> if (role.PermissionId.Equals((int)Permission.Institution))
        {
            query = query.Where(form => PropRole.InstitutionNum.Contains((int)form.OrganizationOrInstitutionNum));
        }
</code>```

at the end of the function when i try to do

```<code> listResults = query.ToList();
</code>```

I get error, "Nullable object must have a value."

  The ToList() fail only if it's get into the if statement.

P.S:
At first i have done this query with EF without SP like this:

```<code>  var query = Context.APP_AuthorityHasamaForm.AsQueryable();
</code>```

And in that way i have no problem doing the ToList() even if it get into the if statement

Thanx

Edit: this is all the function:

```<code>  IEnumerable<sp_PlacementSearchResult_Result> IAuthorityHasamaFormRepository.GetByRequestFromSP(PlacementRequest request, APP_Role role, PropertiesRole PropRole)
    {
        List<sp_PlacementSearchResult_Result> listResults = new List<sp_PlacementSearchResult_Result>();

        request.HasamaFormId = (request.HasamaFormId > 0) ? request.HasamaFormId : null;
        request.InstitutionNum = (request.InstitutionNum > 0) ? request.InstitutionNum : null;

        if (request.StartDate.HasValue)
        {
            request.StartDate = new DateTime(request.StartDate.Value.Year, request.StartDate.Value.Month, request.StartDate.Value.Day, 00, 00, 00);

        }

        if (request.EndDate.HasValue)
        {
            request.EndDate = new DateTime(request.EndDate.Value.Year, request.EndDate.Value.Month, request.EndDate.Value.Day, 00, 00, 00);

        }

        var query = Context.sp_PlacementSearchResult(request.HasamaFormId, request.DepartmentId, request.InstitutionNum, request.IsSigned, request.IdentityIdSign,
            request.StartDate, request.EndDate, request.AuthorityNum, request.CertificateNum, null).AsQueryable();

        if (role.PermissionId.Equals((int)Permission.Department))
        {
            query = query.Where(form => PropRole.DepartmentId.Contains(form.DepartmentId));
        }

        if (role.PermissionId.Equals((int)Permission.Institution))
        {
            query = query.Where(form => PropRole.InstitutionNum.Contains((int)form.OrganizationOrInstitutionNum));
        }

        try
        {
            listResults = query.ToList();
            return listResults;
        }
        catch (Exception e)
        {

            throw;
        }

         listResults = query.ToList();

        return listResults;
    }
</code>```

答:
You do not specify which is a nullable type on your mode. Then there are some possibilities. For sample, the statment bellow:

```<code> query = query.Where(form => PropRole.InstitutionNum.Contains((int)form.OrganizationOrInstitutionNum));
</code>```

if form.OrganizationOrInstitutionNum is null, the cast to int will fail. Try this:

```<code>query = query.Where(form => form.OrganizationOrInstitutionNum.HasValue && PropRole.InstitutionNum.Contains((int)form.OrganizationOrInstitutionNum.Value));
</code>```

Maybe you can be save to cast it.

Body:
I have this code that get date from server using SP with EF

  List<sp_PlacementSearchResult_Result> listResults = new List<sp_PlacementSearchResult_Result>();
  var query = Context.sp_PlacementSearchResult(request.HasamaFormId, request.DepartmentId, request.InstitutionNum, request.IsSigned).AsQueryable();

This is working, now i'd like to add some filter to the result like this:

 if (role.PermissionId.Equals((int)Permission.Institution))
        {
            query = query.Where(form => PropRole.InstitutionNum.Contains((int)form.OrganizationOrInstitutionNum));
        }

at the end of the function when i try to do

 listResults = query.ToList();

I get error, "Nullable object must have a value."

  The ToList() fail only if it's get into the if statement.

P.S:
At first i have done this query with EF without SP like this:

  var query = Context.APP_AuthorityHasamaForm.AsQueryable();

And in that way i have no problem doing the ToList() even if it get into the if statement

Thanx

Edit: this is all the function:

  IEnumerable<sp_PlacementSearchResult_Result> IAuthorityHasamaFormRepository.GetByRequestFromSP(PlacementRequest request, APP_Role role, PropertiesRole PropRole)
    {
        List<sp_PlacementSearchResult_Result> listResults = new List<sp_PlacementSearchResult_Result>();

        request.HasamaFormId = (request.HasamaFormId > 0) ? request.HasamaFormId : null;
        request.InstitutionNum = (request.InstitutionNum > 0) ? request.InstitutionNum : null;

        if (request.StartDate.HasValue)
        {
            request.StartDate = new DateTime(request.StartDate.Value.Year, request.StartDate.Value.Month, request.StartDate.Value.Day, 00, 00, 00);

        }

        if (request.EndDate.HasValue)
        {
            request.EndDate = new DateTime(request.EndDate.Value.Year, request.EndDate.Value.Month, request.EndDate.Value.Day, 00, 00, 00);

        }

        var query = Context.sp_PlacementSearchResult(request.HasamaFormId, request.DepartmentId, request.InstitutionNum, request.IsSigned, request.IdentityIdSign,
            request.StartDate, request.EndDate, request.AuthorityNum, request.CertificateNum, null).AsQueryable();

        if (role.PermissionId.Equals((int)Permission.Department))
        {
            query = query.Where(form => PropRole.DepartmentId.Contains(form.DepartmentId));
        }

        if (role.PermissionId.Equals((int)Permission.Institution))
        {
            query = query.Where(form => PropRole.InstitutionNum.Contains((int)form.OrganizationOrInstitutionNum));
        }

        try
        {
            listResults = query.ToList();
            return listResults;
        }
        catch (Exception e)
        {

            throw;
        }

         listResults = query.ToList();

        return listResults;
    }

Body:
You do not specify which is a nullable type on your mode. Then there are some possibilities. For sample, the statment bellow:

 query = query.Where(form => PropRole.InstitutionNum.Contains((int)form.OrganizationOrInstitutionNum));

if form.OrganizationOrInstitutionNum is null, the cast to int will fail. Try this:

query = query.Where(form => form.OrganizationOrInstitutionNum.HasValue && PropRole.InstitutionNum.Contains((int)form.OrganizationOrInstitutionNum.Value));

Maybe you can be save to cast it.


问:
CRUD operations on many to many relationship using entity framework core 2.0 code first
I have many to many relationship between computer and User. Unfortunately, there are not many examples of CRUD operations on many-to-many relationships. Most importantly adding and deleting. I tried like computer.ComputerUser.Add(), it works but deleting is confusing for me. I don't even know if I am doing it correctly. Your insights will be helpful. Thank you</p>

```<code>// a computer can have one or more Users registered to access
public class Computer
{

    [Key]
    public Guid ComputerId { get; set; }
    public string MachineName { get; set; }
    public DateTime Updated { get; set; }
    public bool IsActive { get; set; } = true;
    public virtual ICollection<ComputerUser> ComputerUser { get; set; }

    public Computer()
    {
        this.ComputerUser = new HashSet<ComputerUser>();
    }
}
// an user can have access to one or more computers
public class User
{
   [Key]
   public Guid   GatekeeperUserId { get; set; }
   public  string Name { get; set; }
   public virtual ICollection<ComputerUser> ComputerUser { get; set; }

    public GatekeeperUser()
    {
        this.ComputerUser= new HashSet<ComputerUser>();
    }
}

// Joining table
    [Key]
    public Guid ComputerId { get; set; }
    public  Computer Computer { get; set; }
    [Key]
    public Guid  UserId { get; set; }
    public  User User { get; set; }
</code>```

答:
You probably have Id of Computer or User which you want to remove from many-to-many relation.
You can call:

```<code>private DeleteComputerUser(User user, Guid computerId)
{
    var computerUser = _dbContext.ComputerUser.SingleOrDefault(computerUser=>
        computerUser.UserId == user.GatekeeperUserId
        && computerUser.ComputerId ==  computerId);
    if (computerUser  != null)
    {
        _dbContext.ComputerUser.Remove(computerUser);
        _dbContext.SaveChanges();
    }
}
</code>```

Now relation between user and computer with specific id is gone.

Body:
I have many to many relationship between computer and User. Unfortunately, there are not many examples of CRUD operations on many-to-many relationships. Most importantly adding and deleting. I tried like computer.ComputerUser.Add(), it works but deleting is confusing for me. I don't even know if I am doing it correctly. Your insights will be helpful. Thank you

// a computer can have one or more Users registered to access
public class Computer
{

    [Key]
    public Guid ComputerId { get; set; }
    public string MachineName { get; set; }
    public DateTime Updated { get; set; }
    public bool IsActive { get; set; } = true;
    public virtual ICollection<ComputerUser> ComputerUser { get; set; }

    public Computer()
    {
        this.ComputerUser = new HashSet<ComputerUser>();
    }
}
// an user can have access to one or more computers
public class User
{
   [Key]
   public Guid   GatekeeperUserId { get; set; }
   public  string Name { get; set; }
   public virtual ICollection<ComputerUser> ComputerUser { get; set; }

    public GatekeeperUser()
    {
        this.ComputerUser= new HashSet<ComputerUser>();
    }
}

// Joining table
    [Key]
    public Guid ComputerId { get; set; }
    public  Computer Computer { get; set; }
    [Key]
    public Guid  UserId { get; set; }
    public  User User { get; set; }

Body:
You probably have Id of Computer or User which you want to remove from many-to-many relation.
You can call:

private DeleteComputerUser(User user, Guid computerId)
{
    var computerUser = _dbContext.ComputerUser.SingleOrDefault(computerUser=>
        computerUser.UserId == user.GatekeeperUserId
        && computerUser.ComputerId ==  computerId);
    if (computerUser  != null)
    {
        _dbContext.ComputerUser.Remove(computerUser);
        _dbContext.SaveChanges();
    }
}

Now relation between user and computer with specific id is gone.


问:
How do I use single quotes as part of a string in SQL
I have a where clause that uses a string,

```<code>Where
    pm.Alias = 'Toys'R'Us France'
</code>```

However part of the string uses single quotation marks, 'R'

How do i wrap up the whole string to pass through into my Where clause

I cannot use:

```<code>Where
    pm.Alias = 'Toys''R''Us France'
</code>```

As i need the whole string encased, as i will use this in Excel to pass this as a paramter into my query

答:
in SQL, if you want to have Single Quotes inside a string, then you should specify it as 2 consecutive single quotes for every single quote in your string. So

```<code>Where
    pm.Alias = 'Toys'R'Us France'
</code>```

should be written as

```<code>Where
    pm.Alias = 'Toys''R''Us France'
</code>```

Body:
I have a where clause that uses a string,

Where
    pm.Alias = 'Toys'R'Us France'

However part of the string uses single quotation marks, 'R'

How do i wrap up the whole string to pass through into my Where clause

I cannot use:

Where
    pm.Alias = 'Toys''R''Us France'

As i need the whole string encased, as i will use this in Excel to pass this as a paramter into my query

Body:
in SQL, if you want to have Single Quotes inside a string, then you should specify it as 2 consecutive single quotes for every single quote in your string. So

Where
    pm.Alias = 'Toys'R'Us France'

should be written as

Where
    pm.Alias = 'Toys''R''Us France'


问:
Kodi on Android: Edit advancedsettings.xml
I want to change my buffering settings.

According to http://kodi.wiki/view/Advancedsettings.xml the tags I am looking for is <advancedsettings><cache><memorysize> and <advancedsettings><cache><readfactor>.

So I am looking for a way to edit the Advancedsettings.xml file. If my installation had been on a normal GNU/Linux box that would have been no problems at all, but my installation is on Android.

I am wondering if there is an addon that will give me a normal editor to edit a file on the KODI system.

I tried the 'Easy Advanced Settings' addon, but it edits the wrong tags (pre-v17?), and a general editor would give more power and be future proof if more tags change.

答: Best way is to use a file browser on your device, they usually also have text file editors included. Really depends on which app store you have access to. Or you can ADB it over, but that's usually even more of a hassle.</p>


问:
Django ModelForm has no model class specified
I am trying to use ModelForm:

```<code>from django.db import models
from django.forms import ModelForm

class Car(models.Model):
    carnumber = models.CharField(max_length=5)

    def __unicode__(self):
        return self.carnumber

class PickForm(ModelForm):
    class Meta:
        Model = Car`
</code>```

I have checked this and I cannot find my error.  When I call the view in a browser, it gives me the following error:

```<code>ModelForm has no model class specified
</code>```

I have tested the view that calls the model with simple "foo bar" code at the same URL, but when I try this code, I get the class error above.

答:
You missed the basic step of registering your model to the admin. Please do that and that should work for you.

In the admin.py file of your app add these lines:

```<code>from yourapp.models import yourmodel
admin.site.register(yourmodel)
</code>```

Here yourapp and yourmodel needs to be replaced with the correct names for your app and model.

Body:
I am trying to use ModelForm:

from django.db import models
from django.forms import ModelForm

class Car(models.Model):
    carnumber = models.CharField(max_length=5)

    def __unicode__(self):
        return self.carnumber

class PickForm(ModelForm):
    class Meta:
        Model = Car`

I have checked this and I cannot find my error.  When I call the view in a browser, it gives me the following error:

ModelForm has no model class specified

I have tested the view that calls the model with simple "foo bar" code at the same URL, but when I try this code, I get the class error above.

Body:
You missed the basic step of registering your model to the admin. Please do that and that should work for you.

In the admin.py file of your app add these lines:

from yourapp.models import yourmodel
admin.site.register(yourmodel)

Here yourapp and yourmodel needs to be replaced with the correct names for your app and model.


问:
How do I use Key-Value Coding in Swfit 4.0?
I never used Swift4 before, and dont know how to use KVC in it.

I try to create model with Dictionary, here the code:

```<code>class Person : NSObject {
    var name: String = ""
    var age: Int = 0

    init(dict: [String : Any]) {
        super.init()
        self.setValuesForKeys(dict)
    }
}

let dict: [String : Any] = ["name" : "Leon", "age" : 18]
let p = Person(dict: dict)
print(p.name, p.age)
</code>```

There I get two question:

1. Why dont I using AnyObject? "Leon"and18 was infer to String and Int, does it using in KVC?

2. @objc var name: String = "" , this form is worked, but I can not understand it.

Thanks for all helps.

答:
your code

var name: String = ""
var age: Int = 0

you can write the same code like this, when you are sure about its type.

var name = ""
 var age  = 0

Any is generally used for all types(function types and optional types), while AnyObject is used for Class types.

@objc have different meaning, when you use @objc in your swift class, that code is available in objective-c. You should use @objc attribute to specify same as objective-c class, in result older archives can be replaced by new swift class.

ContentLicense: CC BY-SA 4.0

Body:
I never used Swift4 before, and dont know how to use KVC in it.

I try to create model with Dictionary, here the code:

class Person : NSObject {
    var name: String = ""
    var age: Int = 0

    init(dict: [String : Any]) {
        super.init()
        self.setValuesForKeys(dict)
    }
}

let dict: [String : Any] = ["name" : "Leon", "age" : 18]
let p = Person(dict: dict)
print(p.name, p.age)

There I get two question:

1. Why dont I using AnyObject? "Leon"and18 was infer to String and Int, does it using in KVC?

2. @objc var name: String = "" , this form is worked, but I can not understand it.

Thanks for all helps.


问:
Can I run a Laravel Route on Linux Cron Job/ Crontab?
I have an API route that updates my Database,

this is the structure of the route that I want to execute via cronjob,

```<code> @extends ('layout')

    @section ('content')

        <script>
                /*--------------------------------------*/
                /* Start Get Employees Data and Update */
                /*------------------------------------*/
                getDataFs();

              function getDataFs()
              {
                    var _token = $("input[name='_token']").val();
                    $.ajax({
                        url: 'https:/api/', /* API Url of JSON Data from Hosts */
                        type: 'GET',
                        dataType: 'json',
                        xhrFields: {
                            withCredentials: true
                        },
                        success: function(response){
                            console.log(response);
                            for(i=0; i < response.length; i++)
                            {
                                $.ajax({
                                    url: '/api/update_list',
                                    headers: {
                                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                                    },
                                    type: 'POST',
                                    dataType: 'json',
                                    data: { 'employee_data': response[i], '_token': _token },
                                    success: function(response){
                                        console.log(response);
                                    }
                                })
                            }
                        }
                    });
                }
                /*--------------------------------------*/
                /* End Get Employees Data and Update   */
                /*------------------------------------*/
        </script>
    @endsection
</code>```

Inside my API route I have an ajax request that gets data from another api,

I know it is possible to run php using sh script or a perl script and adding that .sh or .pl script on the created cronjob,

What I want to know is that is it possible to run a laravel route inside a shell script/perl script on linux?

/usr/bin/php myscript.php to /usr/bin/php laravel/route

If So, can you give me a working sample script with path to my laravel route,

答:
You need install php-cli if you have not installed it yet.
Then just run your php script like this

```<code>* * * * * * php -f /path/to/php/script.php > /somewhere/log/output.txt
</code>```

If you don't need to log

```<code>* * * * * * php -f /path/to/php/script.php > /dev/null 2>&1
</code>```

Done

Body:
I have an API route that updates my Database,

this is the structure of the route that I want to execute via cronjob,

 @extends ('layout')

    @section ('content')

    @endsection

Inside my API route I have an ajax request that gets data from another api,

I know it is possible to run php using sh script or a perl script and adding that .sh or .pl script on the created cronjob,

What I want to know is that is it possible to run a laravel route inside a shell script/perl script on linux?

/usr/bin/php myscript.php to /usr/bin/php laravel/route

If So, can you give me a working sample script with path to my laravel route,

Body:
You need install php-cli if you have not installed it yet.
Then just run your php script like this

* * * * * * php -f /path/to/php/script.php > /somewhere/log/output.txt

If you don't need to log

* * * * * * php -f /path/to/php/script.php > /dev/null 2>&1

Done


问:
@page :first not working in css
With the print button, I am printing the HTML page with some header and footer having @media print rule.

I want header different for the first page and same on other pages. For this I am trying @page :first rule.

body,
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: "Raleway", sans-serif
}

body,
html {
  height: 100%;
  line-height: 1.8;
}

@media screen {
  header.onlyprint,
  header.onlyprintf,
  footer.onlyprint {
    display: none;
    /* Hide from screen */
  }
}

.p {
  display: none;
}

@media print {
  #myHeader {
    font-size: 30px;
  }
  .p {
    display: initial;
  }
  .np {
    display: none;
  }
  a[href]:after {
    display: none;
  }
  header.onlyprint {
    position: fixed;
    /* Display only on print page (each) */
    top: 0;
    /* Because it's header */
    text-align: center;
    width: 100%;
  }
  footer.onlyprint {
    position: fixed;
    bottom: 0;
    /* Because it's footer */
    text-align: center;
    width: 100%
  }
  @page :first {
    header.onlyprint {
      display: none;
    }
    header.onlyprintf {
      position: relative;
      /* Display only on print page (each) */
      top: 0;
      /* Because it's header */
      text-align: center;
      width: 100%;
    }
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><body>
  <button class="btn btn-large btn-success np" onClick="window.print()" style="position: fixed; top: 75px; left: 50%;">Print</button>
  <header class="onlyprint">Header</header>
  <footer class="onlyprint">Footer</footer>
  <header class="onlyprintf">First Page Header</header>
  Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text
  Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some
  Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br
  />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text
  Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some
  Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br
  />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text
  Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br />Some Text Here<br /></code>```

答:
From the MDN documentation:

Note: You can't change all CSS properties with this pseudo-class. You can only change the margins, orphans, widows, and page breaks of the document. Furthermore, you may only use absolute-length units when defining the margins. All other properties will be ignored.

I'm not aware of any way to change the rendering of a specific element based upon the page it appears on.

This is likely due to the ability to change if it is on the first page or not.

i.e. If you give an element margin-top: 50cm if it is on the first page, then it is no longer on the first page, so margin-top: 50cm is no longer applied, which means it is on the first page so margin-top: 50cm does apply and loop forever.

CSS tries to make it impossible to express that type of logic error.

Title: @page :first not working in css

Body:
With the print button, I am printing the HTML page with some header and footer having @media print rule.

I want header different for the first page and same on other pages. For this I am trying @page :first rule.

body,
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: "Raleway", sans-serif
}

body,
html {
  height: 100%;
  line-height: 1.8;
}

@media screen {
  header.onlyprint,
  header.onlyprintf,
  footer.onlyprint {
    display: none;
    /* Hide from screen */
  }
}

.p {
  display: none;
}

@media print {
  #myHeader {
    font-size: 30px;
  }
  .p {
    display: initial;
  }
  .np {
    display: none;
  }
  a[href]:after {
    display: none;
  }
  header.onlyprint {
    position: fixed;
    /* Display only on print page (each) */
    top: 0;
    /* Because it's header */
    text-align: center;
    width: 100%;
  }
  footer.onlyprint {
    position: fixed;
    bottom: 0;
    /* Because it's footer */
    text-align: center;
    width: 100%
  }
  @page :first {
    header.onlyprint {
      display: none;
    }
    header.onlyprintf {
      position: relative;
      /* Display only on print page (each) */
      top: 0;
      /* Because it's header */
      text-align: center;
      width: 100%;
    }
  }
}

  <button class="btn btn-large btn-success np" onClick="window.print()" style="position: fixed; top: 75px; left: 50%;">Print</button>
  Header
  Footer
  First Page Header
  Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text
  Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some
  Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text
  Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some
  Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text
  Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here
Some Text Here


问:
C++ - How can I avoid this header from appearing twice?
At: http://www.learncpp.com/cpp-tutorial/110-a-first-look-at-the-preprocessor/

Under Header guards, there are those code snippets:

add.h:

```<code>#include "mymath.h"
int add(int x, int y);
</code>```

subtract.h:

```<code>#include "mymath.h"
int subtract(int x, int y);
</code>```

main.cpp:

```<code>#include "add.h"
#include "subtract.h"
</code>```

How can I avoid #include "mymath.h" from appearing twice in main.cpp?

Thanks.

答:
use #pragma once if you using MS VC++ or the standard way

inside mymath.h

```<code>#ifndef MYMATH_H
#define MYMATH_H

[code here]

#endif // MYMATH_H
</code>```

ContentLicense: CC BY-SA 2.5

Body:
At: http://www.learncpp.com/cpp-tutorial/110-a-first-look-at-the-preprocessor/

Under Header guards, there are those code snippets:

add.h:

#include "mymath.h"
int add(int x, int y);

subtract.h:

#include "mymath.h"
int subtract(int x, int y);

main.cpp:

#include "add.h"
#include "subtract.h"

How can I avoid #include "mymath.h" from appearing twice in main.cpp?

Thanks.

Body:
use #pragma once if you using MS VC++ or the standard way

inside mymath.h

#ifndef MYMATH_H
#define MYMATH_H

[code here]

#endif // MYMATH_H


问:
jQuery is not defined error in karma tests
I am using jQuery in my angular 5 app which works perfectly but I have an issue with karma tests.

```<code>import { ElementRef } from '@angular/core';
declare var jQuery: any;

export class Item {

constructor(private element: ElementRef) {
    this.init();
}

private init() {
    this.$item = jQuery(this.element.nativeElement);
...
</code>```

error

ReferenceError: jQuery is not defined.

package.json

```<code>"dependencies": {
  "jquery": "3.1.1"
}
</code>```

I have added jquery to my karma.conf but that didn't help.

```<code>files: [
        'node_modules/core-js/client/shim.js',
        'node_modules/systemjs/dist/system.src.js',
        'node_modules/zone.js/dist/zone.js',
        'node_modules/zone.js/dist/proxy.js',
        'node_modules/zone.js/dist/sync-test.js',
        'node_modules/zone.js/dist/jasmine-patch.js',
        'node_modules/zone.js/dist/async-test.js',
        'node_modules/zone.js/dist/fake-async-test.js',
        'node_modules/tslib/tslib.js',
        'node_modules/jquery/dist/jquery.js',

        {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
        {pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
        {pattern: '../karma-test-shim.js', included: true, watched: true},
        {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
        {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false},
        {pattern: 'node_modules/@ng-idle/core/bundles/core.umd.js', included: false, watched: false},
        {pattern: 'node_modules/bowser/bowser.js', included: false, watched: false},
        {pattern: 'node_modules/bootstrap/dist/js/bootstrap.js', included: false, watched: false},
        {pattern: 'node_modules/tslib/tslib.js', included: false, watched: false},
        {pattern: 'node_modules/jquery/dist/jquery.js', included: false, watched: false}
    ],
    proxies: {
        "/node_modules/": "../../node_modules/"
    },
    autoWatch: true,
    browsers: ['PhantomJS', 'Chrome', 'HeadlessChrome'],
    singleRun: false
});
};
</code>```

can you someone please help?

Thanks in advance.

答:
Looks like you have added jquery in twice:

```<code>files: [
        .....
        'node_modules/jquery/dist/jquery.js',

        .....
        {pattern: 'node_modules/jquery/dist/jquery.js', included: false, watched: false}
    ],
</code>```

The second time you have added it you have explicitly stated that you don't want to include it. I think you just need to remove this second line.

Body:
I am using jQuery in my angular 5 app which works perfectly but I have an issue with karma tests.

import { ElementRef } from '@angular/core';
declare var jQuery: any;

export class Item {

constructor(private element: ElementRef) {
    this.init();
}

private init() {
    this.$item = jQuery(this.element.nativeElement);
...

error

ReferenceError: jQuery is not defined.

package.json

"dependencies": {
  "jquery": "3.1.1"
}

I have added jquery to my karma.conf but that didn't help.

files: [
        'node_modules/core-js/client/shim.js',
        'node_modules/systemjs/dist/system.src.js',
        'node_modules/zone.js/dist/zone.js',
        'node_modules/zone.js/dist/proxy.js',
        'node_modules/zone.js/dist/sync-test.js',
        'node_modules/zone.js/dist/jasmine-patch.js',
        'node_modules/zone.js/dist/async-test.js',
        'node_modules/zone.js/dist/fake-async-test.js',
        'node_modules/tslib/tslib.js',
        'node_modules/jquery/dist/jquery.js',

        {pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
        {pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
        {pattern: '../karma-test-shim.js', included: true, watched: true},
        {pattern: 'node_modules/@angular/**/*.js', included: false, watched: false},
        {pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: false},
        {pattern: 'node_modules/@ng-idle/core/bundles/core.umd.js', included: false, watched: false},
        {pattern: 'node_modules/bowser/bowser.js', included: false, watched: false},
        {pattern: 'node_modules/bootstrap/dist/js/bootstrap.js', included: false, watched: false},
        {pattern: 'node_modules/tslib/tslib.js', included: false, watched: false},
        {pattern: 'node_modules/jquery/dist/jquery.js', included: false, watched: false}
    ],
    proxies: {
        "/node_modules/": "../../node_modules/"
    },
    autoWatch: true,
    browsers: ['PhantomJS', 'Chrome', 'HeadlessChrome'],
    singleRun: false
});
};

can you someone please help?

Thanks in advance.

Body:
Looks like you have added jquery in twice:

files: [
        .....
        'node_modules/jquery/dist/jquery.js',

        .....
        {pattern: 'node_modules/jquery/dist/jquery.js', included: false, watched: false}
    ],

The second time you have added it you have explicitly stated that you don't want to include it. I think you just need to remove this second line.


问:
Program will print largest number and smallest number
I have some trouble when I try to code a program.

```<code>double max = 0, min = 0;
int i;
double array[] = new double[10];
Scanner input = new Scanner(System.in);
for (i = 0; i < 10; i++) {
    System.out.println("Give the " + (i + 1) + " number");
    array[i] = input.nextDouble();
}
for (i = 0; i < 10; i++) {
    if (array[i] > max) {
        max = array[i];
    }
    for (i = 0; i < 10; i++) {
        if (array[i] < min) {
            min = array[i];
        }
    }
}
System.out.println("The Max is :" + max);
System.out.println("The Min is :" + min);
</code>```

When I type 10 numbers that include one largest number and one smallest number,
the result is
The Max is : largest number
The Min is : 0.0

Always the Smallest I get the 0.0 whatever I type. No 2 I will type, No 4 I will type as a smallest number (always on separate launch), every time I get 0.0.

答:
Your initial value for minimum is zero, and I assume your data has nothing that is less than zero.

Try setting your min initial value to Double.MAX_VALUE

Body:
I have some trouble when I try to code a program.

double max = 0, min = 0;
int i;
double array[] = new double[10];
Scanner input = new Scanner(System.in);
for (i = 0; i < 10; i++) {
    System.out.println("Give the " + (i + 1) + " number");
    array[i] = input.nextDouble();
}
for (i = 0; i < 10; i++) {
    if (array[i] > max) {
        max = array[i];
    }
    for (i = 0; i < 10; i++) {
        if (array[i] < min) {
            min = array[i];
        }
    }
}
System.out.println("The Max is :" + max);
System.out.println("The Min is :" + min);

When I type 10 numbers that include one largest number and one smallest number,
the result is
The Max is : largest number
The Min is : 0.0

Always the Smallest I get the 0.0 whatever I type. No 2 I will type, No 4 I will type as a smallest number (always on separate launch), every time I get 0.0.


问:
Dose mongodb has RDBMS capabilities?
Is it possible to use Monogodb like mysql, Sql etc.?
Dose it support index primary key, foreign key in collations?

答:
There is an excellent documentation on the comparison between Mongodb and MySQL
Take a look here

Primary key in MongoDB is basically the _id field. You can set any value you want. If you don't initialize it, then it is automatically generated for you with an ObjectId

Regarding your question on primary and foreign key there are also excellent documentations.

One-to-One Relationships

One-to-Many with Embedded Documents

One-to-Many with Document references

Title: Dose mongodb has RDBMS capabilities?


问:
Bootstrap Simple Navigation bar not working in my page
I have a Simple Bootstrap navigation bar in my page, but it is not working. the JavaScript and CSS Files are working properly. i checked it. when i copy the navigation code from  to  and pasts it in a new file, then it is working fine, but not working in my actual file . and looks something like This
and I am expecting some thing like This

My Page Source Code is here  .....

```<code><!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Information Panel for Students</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link href="../include/css/bootstrap.css" rel="stylesheet" type="text/css">
    <link href="../include/css/footer.css" rel="stylesheet" type="text/css">
</head>

<body>
<div class="container">

<!--    header start from here -->

    <header>
      <nav class="navbar navbar-default">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a href="index.php" class="navbar-brand">Department Dashboard</a>
        </div>
        <!-- Collection of nav links and other content for toggling -->
        <div id="navbarCollapse" class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
            <li class="active"><a href="index.php">Home</a></li>
            <li><a href="update_password.php">Update Password</a></li>
            </ul>
          <ul class="nav navbar-nav navbar-right">
            <li><a href="logout.php">Logout</a></li>
            </ul>
        </div>
        </nav>
  </header>

    <h3>Teachers:</h3>
  <div class="row">
    <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512541379-5412-5a278cc30963e-NOKIA_RM-1030_206834512-206835569_000.JPG" width="180" height="220"/><br>Person Name : Shaida Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512541601-6654-5a278da1bf564-NOKIA_X2-02_215986488-215987862_000.JPG" width="180" height="220"/><br>Person Name : Nausheen Fayaz<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512541663-4311-5a278ddfa5374-NOKIA_X2-02_215461832-215462529_000.JPG" width="180" height="220"/><br>Person Name : Javed Chaudry<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512541718-9653-5a278e1617035-NOKIA_RM-1030_206827192-206828288_000.JPG" width="180" height="220"/><br>Person Name : Khan Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512563517-6727-5a27e33d9dc39-NOKIA_E5-00_202194584-202196971_000.JPG" width="180" height="220"/><br>Person Name : Farsil Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512563572-2715-5a27e374a3c1d-NOKIA_RM-1030_202261216-202265107_000.JPG" width="180" height="220"/><br>Person Name : Ek Aur Teacher Ke Data<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512216690-8783-5a229872e2564-NOKIA_5233_244851632-244851959_000.JPG" width="180" height="220"/><br>Person Name : Azhar Rauf<br>Current Place : Class Room<br>Status Date : 02-12-2017<br>Status Time : 05:15:21 PM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512217027-6925-5a2299c3d363f-NOKIA_E5-00_202038176-202041197_000.JPG" width="180" height="220"/><br>Person Name : Fatima Zuhra<br>Current Place : Class Room<br>Status Date : 02-12-2017<br>Status Time : 05:19:28 PM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512217504-2845-5a229ba0c8635-NOKIA_E5-00_202201816-202204433_000.JPG" width="180" height="220"/><br>Person Name : Khan Lala<br>Current Place : Class Room<br>Status Date : 02-12-2017<br>Status Time : 05:33:17 PM<br><br></div>  </div>

    <h3>Chairman:</h3>
    <div class="row">
      <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../chairman/images/resized_1512141619-1363-5a2173335d788-NOKIA_5233_244851632-244851959_000.JPG" width="180" height="220"/><br>Person Name : Shah Khusro<br>Current Place : Chairman Office<br>Status Date : 01-12-2017<br>Status Time : 08:26:40 PM<br><br></div>    </div>

    <h3>Clerks:</h3>
    <div class="row">
      <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512562768-5527-5a27e0506acd1-HUAWEI_HUAWEI_611272384-611272979_000.JPG" width="180" height="220"/><br>Person Name : Demo Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512562854-8274-5a27e0a675bb8-HUAWEI_CHM-U01_183017224-183021314_000.JPG" width="180" height="220"/><br>Person Name : Galaxy Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512563316-1142-5a27e2744dc95-NOKIA_5233_244851632-244851959_000.JPG" width="180" height="220"/><br>Person Name : Asdf Adf<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512563366-8649-5a27e2a6bb78c-NOKIA_E5-00_202083984-202086713_000.JPG" width="180" height="220"/><br>Person Name : Sdfasd Adfdsf<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512563389-3596-5a27e2bdc3ff7-NOKIA_E5-00_202186392-202189391_000.JPG" width="180" height="220"/><br>Person Name : Sdf Fsd<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512563480-2752-5a27e3185f05f-NOKIA_RM-1030_194996488-194998710_000.JPG" width="180" height="220"/><br>Person Name : Dfasdf Sdalfksd<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512145551-9397-5a21828fc4953-NOKIA_E5-00_202038176-202041197_000.JPG" width="180" height="220"/><br>Person Name : Faris Khan<br>Current Place : Clerk Office<br>Status Date : 02-12-2017<br>Status Time : 09:46:40 AM<br><br></div>    </div>

    <h3>Lab Staff:</h3>
    <div class="row">
      <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../lab_staff/images/resized_1512218344-7079-5a229ee8b9e5a-NOKIA_RM-1030_206846160-206847834_000.JPG" width="180" height="220"/><br>Person Name : Samin Jan<br>Current Place : Laboratory<br>Status Date : 02-12-2017<br>Status Time : 05:39:47 PM<br><br></div>    </div>

    <h3>PN Staff:</h3>
    <div class="row">
      <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../pn/images/resized_1512145738-2830-5a21834a6d1d7-NOKIA_E5-00_202048056-202051887_000.JPG" width="180" height="220"/><br>Person Name : Penis Khan<br>Current Place : Outside<br>Status Date : 02-12-2017<br>Status Time : 06:09:47 PM<br><br></div>    </div>
    <footer>
        <div class="container">
            <div class="row">
                <div class="col-sm-4">
                    <div class="footer-block">
                        <ul class="list-inline footer-menu">
                            <li><a href="">Term of Use</a></li>
                            <li><a href="">Privacy Policy</a></li>
                        </ul>
                    </div>
                </div>
                <div class="col-sm-4">
                  <div class="footer-block text-center">
                    <p class="copyright">
                        © 2018 Department Dashboard.<br>
                        All rights reserved.<br>
                        Developed By:<br>
                        Shaida Muhammad Sherpao
                      </p>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="footer-block">
                        <ul class="list-inline pull-right social-icon">
                            <li><a href="https://facebook.com/sh3rpao"><i class="fa fa-facebook"></i></a></li>
                            <li><a href="https://twitter.com/shaidasherpao"><i class="fa fa-twitter"></i></a></li>
                            <li><a href="https://pk.linkedin.com/in/shaida-muhammad-sherpao-a3388a103"><i class="fa fa-linkedin"></i></a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </footer>
</div>
<script src="../include/js/jquery-1.11.3.min.js"></script>
<script src="../include/js/bootstrap.js"></script>
</body>
</html>
</code>```

答:
Your Code is working good.Try This

<!doctype html>

<meta charset="utf-8">
<title>Information Panel for Students</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

          <button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
            Toggle navigation

          </button>
          Department Dashboard

Home

Update Password

Logout

Teachers:

Person Name : Shaida Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Nausheen Fayaz
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Javed Chaudry
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Khan Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Farsil Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Ek Aur Teacher Ke Data
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Azhar Rauf
Current Place : Class Room
Status Date : 02-12-2017
Status Time : 05:15:21 PM

Person Name : Fatima Zuhra
Current Place : Class Room
Status Date : 02-12-2017
Status Time : 05:19:28 PM

Person Name : Khan Lala
Current Place : Class Room
Status Date : 02-12-2017
Status Time : 05:33:17 PM

Chairman:

Person Name : Shah Khusro
Current Place : Chairman Office
Status Date : 01-12-2017
Status Time : 08:26:40 PM

Clerks:

Person Name : Demo Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Galaxy Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Asdf Adf
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Sdfasd Adfdsf
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Sdf Fsd
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Dfasdf Sdalfksd
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Faris Khan
Current Place : Clerk Office
Status Date : 02-12-2017
Status Time : 09:46:40 AM

Lab Staff:

Person Name : Samin Jan
Current Place : Laboratory
Status Date : 02-12-2017
Status Time : 05:39:47 PM

PN Staff:

Person Name : Penis Khan
Current Place : Outside
Status Date : 02-12-2017
Status Time : 06:09:47 PM

Term of Use

Privacy Policy

                        © 2018 Department Dashboard.

                        All rights reserved.

                        Developed By:

                        Shaida Muhammad Sherpao

```

Body:
I have a Simple Bootstrap navigation bar in my page, but it is not working. the JavaScript and CSS Files are working properly. i checked it. when i copy the navigation code from  to  and pasts it in a new file, then it is working fine, but not working in my actual file . and looks something like This
and I am expecting some thing like This

My Page Source Code is here  .....

<!doctype html>

<meta charset="utf-8">
<title>Information Panel for Students</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link href="../include/css/bootstrap.css" rel="stylesheet" type="text/css">
    <link href="../include/css/footer.css" rel="stylesheet" type="text/css">

          <button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
            Toggle navigation

          </button>
          Department Dashboard

Home

Update Password

Logout

Teachers:

Person Name : Shaida Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Nausheen Fayaz
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Javed Chaudry
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Khan Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Farsil Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Ek Aur Teacher Ke Data
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Azhar Rauf
Current Place : Class Room
Status Date : 02-12-2017
Status Time : 05:15:21 PM

Person Name : Fatima Zuhra
Current Place : Class Room
Status Date : 02-12-2017
Status Time : 05:19:28 PM

Person Name : Khan Lala
Current Place : Class Room
Status Date : 02-12-2017
Status Time : 05:33:17 PM

Chairman:

Person Name : Shah Khusro
Current Place : Chairman Office
Status Date : 01-12-2017
Status Time : 08:26:40 PM

Clerks:

Person Name : Demo Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Galaxy Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Asdf Adf
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Sdfasd Adfdsf
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Sdf Fsd
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Dfasdf Sdalfksd
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Faris Khan
Current Place : Clerk Office
Status Date : 02-12-2017
Status Time : 09:46:40 AM

Lab Staff:

Person Name : Samin Jan
Current Place : Laboratory
Status Date : 02-12-2017
Status Time : 05:39:47 PM

PN Staff:

Person Name : Penis Khan
Current Place : Outside
Status Date : 02-12-2017
Status Time : 06:09:47 PM

Term of Use

Privacy Policy

                        © 2018 Department Dashboard.

                        All rights reserved.

                        Developed By:

                        Shaida Muhammad Sherpao

Body:
Your Code is working good.Try This

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Information Panel for Students</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- jQuery library -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

</head>

<body>
<div class="container">

<!--    header start from here -->

    <header>
      <nav class="navbar navbar-default">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a href="index.php" class="navbar-brand">Department Dashboard</a>
        </div>
        <!-- Collection of nav links and other content for toggling -->
        <div id="navbarCollapse" class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
            <li class="active"><a href="index.php">Home</a></li>
            <li><a href="update_password.php">Update Password</a></li>
            </ul>
          <ul class="nav navbar-nav navbar-right">
            <li><a href="logout.php">Logout</a></li>
            </ul>
        </div>
        </nav>
  </header>

    <h3>Teachers:</h3>
  <div class="row">
    <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512541379-5412-5a278cc30963e-NOKIA_RM-1030_206834512-206835569_000.JPG" width="180" height="220"/><br>Person Name : Shaida Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512541601-6654-5a278da1bf564-NOKIA_X2-02_215986488-215987862_000.JPG" width="180" height="220"/><br>Person Name : Nausheen Fayaz<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512541663-4311-5a278ddfa5374-NOKIA_X2-02_215461832-215462529_000.JPG" width="180" height="220"/><br>Person Name : Javed Chaudry<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512541718-9653-5a278e1617035-NOKIA_RM-1030_206827192-206828288_000.JPG" width="180" height="220"/><br>Person Name : Khan Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512563517-6727-5a27e33d9dc39-NOKIA_E5-00_202194584-202196971_000.JPG" width="180" height="220"/><br>Person Name : Farsil Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512563572-2715-5a27e374a3c1d-NOKIA_RM-1030_202261216-202265107_000.JPG" width="180" height="220"/><br>Person Name : Ek Aur Teacher Ke Data<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512216690-8783-5a229872e2564-NOKIA_5233_244851632-244851959_000.JPG" width="180" height="220"/><br>Person Name : Azhar Rauf<br>Current Place : Class Room<br>Status Date : 02-12-2017<br>Status Time : 05:15:21 PM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512217027-6925-5a2299c3d363f-NOKIA_E5-00_202038176-202041197_000.JPG" width="180" height="220"/><br>Person Name : Fatima Zuhra<br>Current Place : Class Room<br>Status Date : 02-12-2017<br>Status Time : 05:19:28 PM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512217504-2845-5a229ba0c8635-NOKIA_E5-00_202201816-202204433_000.JPG" width="180" height="220"/><br>Person Name : Khan Lala<br>Current Place : Class Room<br>Status Date : 02-12-2017<br>Status Time : 05:33:17 PM<br><br></div>  </div>

    <h3>Chairman:</h3>
    <div class="row">
      <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../chairman/images/resized_1512141619-1363-5a2173335d788-NOKIA_5233_244851632-244851959_000.JPG" width="180" height="220"/><br>Person Name : Shah Khusro<br>Current Place : Chairman Office<br>Status Date : 01-12-2017<br>Status Time : 08:26:40 PM<br><br></div>    </div>

    <h3>Clerks:</h3>
    <div class="row">
      <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512562768-5527-5a27e0506acd1-HUAWEI_HUAWEI_611272384-611272979_000.JPG" width="180" height="220"/><br>Person Name : Demo Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512562854-8274-5a27e0a675bb8-HUAWEI_CHM-U01_183017224-183021314_000.JPG" width="180" height="220"/><br>Person Name : Galaxy Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512563316-1142-5a27e2744dc95-NOKIA_5233_244851632-244851959_000.JPG" width="180" height="220"/><br>Person Name : Asdf Adf<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512563366-8649-5a27e2a6bb78c-NOKIA_E5-00_202083984-202086713_000.JPG" width="180" height="220"/><br>Person Name : Sdfasd Adfdsf<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512563389-3596-5a27e2bdc3ff7-NOKIA_E5-00_202186392-202189391_000.JPG" width="180" height="220"/><br>Person Name : Sdf Fsd<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512563480-2752-5a27e3185f05f-NOKIA_RM-1030_194996488-194998710_000.JPG" width="180" height="220"/><br>Person Name : Dfasdf Sdalfksd<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512145551-9397-5a21828fc4953-NOKIA_E5-00_202038176-202041197_000.JPG" width="180" height="220"/><br>Person Name : Faris Khan<br>Current Place : Clerk Office<br>Status Date : 02-12-2017<br>Status Time : 09:46:40 AM<br><br></div>    </div>

    <h3>Lab Staff:</h3>
    <div class="row">
      <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../lab_staff/images/resized_1512218344-7079-5a229ee8b9e5a-NOKIA_RM-1030_206846160-206847834_000.JPG" width="180" height="220"/><br>Person Name : Samin Jan<br>Current Place : Laboratory<br>Status Date : 02-12-2017<br>Status Time : 05:39:47 PM<br><br></div>    </div>

    <h3>PN Staff:</h3>
    <div class="row">
      <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../pn/images/resized_1512145738-2830-5a21834a6d1d7-NOKIA_E5-00_202048056-202051887_000.JPG" width="180" height="220"/><br>Person Name : Penis Khan<br>Current Place : Outside<br>Status Date : 02-12-2017<br>Status Time : 06:09:47 PM<br><br></div>    </div>
    <footer>
        <div class="container">
            <div class="row">
                <div class="col-sm-4">
                    <div class="footer-block">
                        <ul class="list-inline footer-menu">
                            <li><a href="">Term of Use</a></li>
                            <li><a href="">Privacy Policy</a></li>
                        </ul>
                    </div>
                </div>
                <div class="col-sm-4">
                  <div class="footer-block text-center">
                    <p class="copyright">
                        © 2018 Department Dashboard.<br>
                        All rights reserved.<br>
                        Developed By:<br>
                        Shaida Muhammad Sherpao
                      </p>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="footer-block">
                        <ul class="list-inline pull-right social-icon">
                            <li><a href="https://facebook.com/sh3rpao"><i class="fa fa-facebook"></i></a></li>
                            <li><a href="https://twitter.com/shaidasherpao"><i class="fa fa-twitter"></i></a></li>
                            <li><a href="https://pk.linkedin.com/in/shaida-muhammad-sherpao-a3388a103"><i class="fa fa-linkedin"></i></a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </footer>
</div>
</body>
</html>


问:
Which IntelliJ config files should I save in my dotfiles?
I would like to keep my IntelliJ config files in my dotfiles repo but my ~/.IntelliJIdea2016.1 folder weights > 1.3G :(

~/.IntelliJIdea2016.1/config/ still weights > 215M...

~/.IntelliJIdea2016.1/config/plugins/ contains lots of binaries... not the best candidates for dotfiles :(

Anyone tried to save IntelliJ config without Export/Import settings menu option?

答:
No need to store IntelliJ config file, just use
IDE Settings Sync plugin.

See this post: Better Synchronization of your Settings Across Devices


问:
MongoDB - $push if array length < n, while update_one
That's a small part of my update query using pymongo in python. I want to $push ip variable to an array only if its length is less than 10. I know that I can solve this problem firstly finding this user (find_one) and checking array's length but it's not an efficient solution. How to handle this problem using mongo?

I read that $cond works only in aggregation so I can't figure anything else.

Part of my script:

```<code>self.db[coll_name].update_one(
             {
                 'summary.userId': user_id
             },
             {'$push':
                 {
                     'summary.ip': ip
                 },
             }
             upsert=True
        )
</code>```

What my brain wants to do:

```<code>self.db[coll_name].update_one(
             {
                 'summary.userId': user_id
             },
             {
                 "$cond": {"if": {"$size": {"$summary.ip": {"$ne": 10}}},
                         "then": {"$push": ip},
                         "else": pass
             }},
             upsert=True
        )
</code>```

I'm trying to limit myself to pymongo but answers using MongoDB with JS are more than welcome.

EDIT: Sorry for the inconvenience.

I want to be able to update other fields event if the condition wasn't met.

```<code>self.db[coll_name].update_one(
                 {
                     'summary.userId': user_id
                 },
                 {'$push':
                     {
                         'summary.ip': ip
                     },

                 '$addToSet':
                     {
                         'summary.something_list': something
                     },
                 }
                 upsert=True
            )
</code>```

If I filter by the length of ip array, I won't add something if ip list eq 9, which I have to do.

答:
```<code>var limit =10;
var query = {};
query["arrayName."+limit]={$exists:false}
model.update(query,{$push:{arrayName:value}})
</code>```

<p>the second option I prefer is to have a length field in model and increment or decrement it in push or pull respectively({$push:{arrayName:val},$inc:{length:1}}  or {$pull:{arrayName:val},$inc:{length:-1}}) so you can query simply like </p>

```<code>model.update({length:{$lt:10}},{$push:{arrayName:value}})
</code>```

Body:
That's a small part of my update query using pymongo in python. I want to $push ip variable to an array only if its length is less than 10. I know that I can solve this problem firstly finding this user (find_one) and checking array's length but it's not an efficient solution. How to handle this problem using mongo?

I read that $cond works only in aggregation so I can't figure anything else.

Part of my script:

self.db[coll_name].update_one(
             {
                 'summary.userId': user_id
             },
             {'$push':
                 {
                     'summary.ip': ip
                 },
             }
             upsert=True
        )

What my brain wants to do:

self.db[coll_name].update_one(
             {
                 'summary.userId': user_id
             },
             {
                 "$cond": {"if": {"$size": {"$summary.ip": {"$ne": 10}}},
                         "then": {"$push": ip},
                         "else": pass
             }},
             upsert=True
        )

I'm trying to limit myself to pymongo but answers using MongoDB with JS are more than welcome.

EDIT: Sorry for the inconvenience.

I want to be able to update other fields event if the condition wasn't met.

self.db[coll_name].update_one(
                 {
                     'summary.userId': user_id
                 },
                 {'$push':
                     {
                         'summary.ip': ip
                     },

                 '$addToSet':
                     {
                         'summary.something_list': something
                     },
                 }
                 upsert=True
            )

If I filter by the length of ip array, I won't add something if ip list eq 9, which I have to do.

Body:
var limit =10;
var query = {};
query["arrayName."+limit]={$exists:false}
model.update(query,{$push:{arrayName:value}})

the second option I prefer is to have a length field in model and increment or decrement it in push or pull respectively({$push:{arrayName:val},$inc:{length:1}}  or {$pull:{arrayName:val},$inc:{length:-1}}) so you can query simply like

model.update({length:{$lt:10}},{$push:{arrayName:value}})


问:
Help with a foreach loop
In my website I am trying to display all the applicants to jobs that a user has posted, basically I want the out put to simimlar too,

Job Title 1

  Aplicant Name 1

  Aplicant Name 2

  Applicant Name 3

Job Title 2

  Applicant Name 4
  Application Name 5

Basically I want the applications to be gathered under the jobs they applied for, however the out put I am current getting is,

Job Title 1

  Application Name 1

Job Title 1

  Applicant Name 2

The code I am using to do this foreach loop is as follows

```<code><?php foreach($applications as $a) : ?>
        <h3><?php echo $a['jobtitle']; ?></h3>
    <li>
        <img src="/media/uploads/candidates/<?php echo preg_replace('/(.gif|.jpg|.png)/', '_thumb$1', $a['profile_image']);?>" width="90" height="60"/>
        <p><?php echo $a['name']; ?></p>
    </li>
    <?php endforeach; ?>
</code>```

答:
We need the data structure to properly answer, but I'm assuming you need a nested foreach...</p>

```<code><? foreach($jobs as $j): ?>

# list jobs

    <? foreach($applicants as $a): ?>
        <? if ($j['jobtitle'] == $a['jobtitle']): ?>

        # list applicants

        <? endif; ?>
    <? endforeach; ?>

<? endforeach; ?>
</code>```

Title: Help with a foreach loop

Body:
In my website I am trying to display all the applicants to jobs that a user has posted, basically I want the out put to simimlar too,

Job Title 1

  Aplicant Name 1

  Aplicant Name 2

  Applicant Name 3

Job Title 2

  Applicant Name 4
  Application Name 5

Basically I want the applications to be gathered under the jobs they applied for, however the out put I am current getting is,

Job Title 1

  Application Name 1

Job Title 1

  Applicant Name 2

The code I am using to do this foreach loop is as follows

<?php foreach($applications as $a) : ?>

<?php echo $a['jobtitle']; ?>

        <img src="/media/uploads/candidates/<?php echo preg_replace('/(.gif|.jpg|.png)/', '_thumb$1', $a['profile_image']);?>" width="90" height="60"/>

<?php echo $a['name']; ?>

    <?php endforeach; ?>

Body:
We need the data structure to properly answer, but I'm assuming you need a nested foreach...

<? foreach($jobs as $j): ?>

# list jobs

    <? foreach($applicants as $a): ?>
        <? if ($j['jobtitle'] == $a['jobtitle']): ?>

        # list applicants

        <? endif; ?>
    <? endforeach; ?>

<? endforeach; ?>


问:
Async Await Performance in Web Applications
So far I think I've grasped the concepts of how async await can make your application more responsive but I'm hung up on two points:

Layer Considerations
Does async await have to go from the repository layer, all the way up to the MVC or WCF tier to get the performance benefits or can I just do async operations on my repository methods that are taking a long time?

"await" usage If I can just work at the repository level there's one part I don't understand. Using this (low-tier) approach, will the thread be able to service incoming client requests while waiting on the io bound code to finish?

I put together a sample console application, in my mind, while the long running task is continuing, another user could make a request to my web application. Using my little library (to ease integration and exception handling), would their request be serviced by the pending thread or does the voidTask.Wait(); cause the thread to block?

```<code>public class AsyncTest
{
    public void RunTest()
    {
        try
        {
            using (var task = new RunTask(LongRunningTask))
            {
                Console.WriteLine("Echo two things:");

                for (int i = 0; i < 2; i++)
                {
                    var input = Console.ReadLine();
                    Console.WriteLine(string.Format("Echoing \"{0}\"", input));
                }
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("Error, hm, what happened??");
            Console.WriteLine();
            Console.WriteLine(e.Message);
            Console.WriteLine(e.StackTrace);
        }
    }

    public void LongRunningTask()
    {
        var totals = 0;

        for (int i = 0; i < 30; i++)
        {
            Thread.Sleep(1000);
            totals += 5;

            if (i == 25)
                throw new ArgumentException("I can't handle this! Errorr!!@!@");

            Console.WriteLine(string.Format("LongRunningTask Step {0}...", (i + 1)));
        }
    }
}

public class RunTask : IDisposable
{
    public delegate void IOBoundOperations();
    private Task voidTask;

    public RunTask(IOBoundOperations task)
    {
        voidTask = Execute(task);
    }

    async public Task Execute(IOBoundOperations task)
    {
        await Task.Run(() =>
        {
            task();
        });
    }

    public void Dispose()
    {
        try
        {
            voidTask.Wait();
        }
        catch
        {
            throw new AsyncException("Failed to run task asynchronously: " +
                voidTask.Exception.InnerException.Message, voidTask.Exception.InnerException);
        }
    }
}
</code>```

I put in the wait, because I'll need it for tasks that will return data to the calling code that it may depend on. I also did it because I noticed the process won't complete until the thread is done executing my asynchronous stuff as well.

I can find lots of information on async/await and it's benefits, just nothing on this on this one particular aspect.

答:
Using async/await can be very handy with all I/O related actions. An example
action is SaveAnalytics() what takes 100ms. if this is done synchronous the thread is blocked for that 100ms. if this is done asynchronous the thread is released immediately before all data of SaveAnalytics() is saved to file/database/whatever. when this saving is done another thread is used to return flow to client.

so what are the advantages of this? threads are expensive! if a highly scalable application is needed in lets say the cloud you can win a lot with making all your I/O related calls aynchronous.

if your web application is under heavy load you won't get the "503" message what means "Server to busy", what also means there are no threads available in the threadpool to hand out to client (they can all be busy with synchronous wait).

Its possible the user will notice nothing of this because they push the "Save" button and see a message that the "Analytics" are saved. Under water it all happens asynchronous.

So to recap, it all about the scalability of your application. If your application is not used heavily then its not worth to make all your methods asynchronous.

Body:
So far I think I've grasped the concepts of how async await can make your application more responsive but I'm hung up on two points:

Layer Considerations
Does async await have to go from the repository layer, all the way up to the MVC or WCF tier to get the performance benefits or can I just do async operations on my repository methods that are taking a long time?

"await" usage If I can just work at the repository level there's one part I don't understand. Using this (low-tier) approach, will the thread be able to service incoming client requests while waiting on the io bound code to finish?

I put together a sample console application, in my mind, while the long running task is continuing, another user could make a request to my web application. Using my little library (to ease integration and exception handling), would their request be serviced by the pending thread or does the voidTask.Wait(); cause the thread to block?

public class AsyncTest
{
    public void RunTest()
    {
        try
        {
            using (var task = new RunTask(LongRunningTask))
            {
                Console.WriteLine("Echo two things:");

                for (int i = 0; i < 2; i++)
                {
                    var input = Console.ReadLine();
                    Console.WriteLine(string.Format("Echoing \"{0}\"", input));
                }
            }
        }
        catch (Exception e)
        {
            Console.WriteLine("Error, hm, what happened??");
            Console.WriteLine();
            Console.WriteLine(e.Message);
            Console.WriteLine(e.StackTrace);
        }
    }

    public void LongRunningTask()
    {
        var totals = 0;

        for (int i = 0; i < 30; i++)
        {
            Thread.Sleep(1000);
            totals += 5;

            if (i == 25)
                throw new ArgumentException("I can't handle this! Errorr!!@!@");

            Console.WriteLine(string.Format("LongRunningTask Step {0}...", (i + 1)));
        }
    }
}

public class RunTask : IDisposable
{
    public delegate void IOBoundOperations();
    private Task voidTask;

    public RunTask(IOBoundOperations task)
    {
        voidTask = Execute(task);
    }

    async public Task Execute(IOBoundOperations task)
    {
        await Task.Run(() =>
        {
            task();
        });
    }

    public void Dispose()
    {
        try
        {
            voidTask.Wait();
        }
        catch
        {
            throw new AsyncException("Failed to run task asynchronously: " +
                voidTask.Exception.InnerException.Message, voidTask.Exception.InnerException);
        }
    }
}

I put in the wait, because I'll need it for tasks that will return data to the calling code that it may depend on. I also did it because I noticed the process won't complete until the thread is done executing my asynchronous stuff as well.

I can find lots of information on async/await and it's benefits, just nothing on this on this one particular aspect.


问:
VHDL programming, where is the mistake?
I'm trying to write a program on Quartus to synthethize a 74hc138 decoder

```<code>LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
use ieee.STD_LOGIC_ARITH.ALL;
use ieee.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_SIGNED;

ENTITY demux IS
PORT (
a: IN INTEGER RANGE 0 TO 4; --bus 3 bits
e: IN BIT_VECTOR (2 DOWNTO 0 ); --bus de 3 bits
y: OUT BIT_VECTOR(7 DOWNTO 0);
v: IN BIT_VECTOR(2 DOWNTO 0)
);
END demux;

ARCHITECTURE Archi of demux IS
BEGIN
PROCESS (a)
BEGIN
if v /= '001' THEN y <= '11111111 ; THE PROBLEM IS HERE
ELSE
CASE  a is
    when 0 => y <= y(0);
    when 1 => y <= y(1);
    when 2 => y <= y(2);
    when 3 => y <= y(3);
    when 4 => y <= y(4);
    when 5 => y <= y(5);
    when 6 => y <= y(6);
    when 7 => y <= y(7);
END CASE;
END IF;
END PROCESS;
END Archi; -->
</code>```

Error (10500): VHDL syntax error at demux.vhd(20) near text "'";  expecting "(", or an identifier, or  unary operator

I want to have the output only if the condition on v is true !

答:
This

```<code>if v /= '001' THEN y <= '11111111 ;
</code>```

should be this

```<code>if v /= "001" THEN y <= "11111111";
</code>```

(i) The literal for a bit_vector is a string. Strings in VHDL require double quotes.

(ii) You were missing any kind of quote in the second literal.

Also:

(a) Why are you using bit_vector? You have included the std_logic_1164 package, but then don't use it. You should use std_logic (etc) for synthsisable code (so then you would need the std_logic_1164 package).

(b) Don't include packages you're not using: ie

```<code>use ieee.STD_LOGIC_ARITH.ALL;
use ieee.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_SIGNED;
</code>```

(c) Don't use the above packages for new code anyway, use ieee.NUMERIC_STD.all.

Title: VHDL programming, where is the mistake?

Body:
I'm trying to write a program on Quartus to synthethize a 74hc138 decoder

LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
use ieee.STD_LOGIC_ARITH.ALL;
use ieee.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_SIGNED;

ENTITY demux IS
PORT (
a: IN INTEGER RANGE 0 TO 4; --bus 3 bits
e: IN BIT_VECTOR (2 DOWNTO 0 ); --bus de 3 bits
y: OUT BIT_VECTOR(7 DOWNTO 0);
v: IN BIT_VECTOR(2 DOWNTO 0)
);
END demux;

ARCHITECTURE Archi of demux IS
BEGIN
PROCESS (a)
BEGIN
if v /= '001' THEN y <= '11111111 ; THE PROBLEM IS HERE
ELSE
CASE  a is
    when 0 => y <= y(0);
    when 1 => y <= y(1);
    when 2 => y <= y(2);
    when 3 => y <= y(3);
    when 4 => y <= y(4);
    when 5 => y <= y(5);
    when 6 => y <= y(6);
    when 7 => y <= y(7);
END CASE;
END IF;
END PROCESS;
END Archi; -->

Error (10500): VHDL syntax error at demux.vhd(20) near text "'";  expecting "(", or an identifier, or  unary operator

I want to have the output only if the condition on v is true !

Body:
This

if v /= '001' THEN y <= '11111111 ;

should be this

if v /= "001" THEN y <= "11111111";

(i) The literal for a bit_vector is a string. Strings in VHDL require double quotes.

(ii) You were missing any kind of quote in the second literal.

Also:

(a) Why are you using bit_vector? You have included the std_logic_1164 package, but then don't use it. You should use std_logic (etc) for synthsisable code (so then you would need the std_logic_1164 package).

(b) Don't include packages you're not using: ie

use ieee.STD_LOGIC_ARITH.ALL;
use ieee.STD_LOGIC_UNSIGNED.ALL;
use IEEE.STD_LOGIC_SIGNED;

(c) Don't use the above packages for new code anyway, use ieee.NUMERIC_STD.all.


问:
how to download a file by using urlsession with requestbody
i need to request the server with the url and request body but the response will be a zip file i need to download the zip file and use it so i used the following method but i need to know how to save the file and reuse it
but getting the following error

Task <11E36FDA-1408-474D-B576-A222DEBA53B2>.<3> finished with error - code: -1005

```<code>     func performSyncRequest()
{
    let documentsUrl =  FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first
    let url = syncUrl.prepareSyncURL()
    var urlrequest = URLRequest(url: url)
    urlrequest.httpMethod = "POST"
    urlrequest.addValue("application/json", forHTTPHeaderField: "Content-Type")
    let requestBody = syncUrl.prepareRequestBody()
    guard let httpBody = try? JSONSerialization.data(withJSONObject: requestBody, options: []) else { return }
    urlrequest.httpBody = httpBody
    do {
        let convertedString = String(data: httpBody, encoding: String.Encoding.utf8)
        print("Sync Request Body: \(convertedString!)")
    }

    let downloadTask = URLSession.shared.downloadTask(with: urlrequest, completionHandler: { url,response,error in
        if error == nil {
            //some code

            do {
                try FileManager.default.copyItem(at:url!, to: self.documentsUrl!)
                print(self.documentsUrl!)
            } catch (let writeError) {
                print("error writing file \(self.documentsUrl!) : \(writeError)")
            }

        }
    })

    downloadTask.resume()
</code>```

}

答:
here the issue is while trying to download zip file their is no content length header so inorder to solve the issue i used the following code and it is working well</p>

```<code> urlrequest.addValue("", forHTTPHeaderField: "Accept-Encoding")
</code>```

Body:
i need to request the server with the url and request body but the response will be a zip file i need to download the zip file and use it so i used the following method but i need to know how to save the file and reuse it
but getting the following error

Task <11E36FDA-1408-474D-B576-A222DEBA53B2>.<3> finished with error - code: -1005

     func performSyncRequest()
{
    let documentsUrl =  FileManager.default.urls(for: .libraryDirectory, in: .userDomainMask).first
    let url = syncUrl.prepareSyncURL()
    var urlrequest = URLRequest(url: url)
    urlrequest.httpMethod = "POST"
    urlrequest.addValue("application/json", forHTTPHeaderField: "Content-Type")
    let requestBody = syncUrl.prepareRequestBody()
    guard let httpBody = try? JSONSerialization.data(withJSONObject: requestBody, options: []) else { return }
    urlrequest.httpBody = httpBody
    do {
        let convertedString = String(data: httpBody, encoding: String.Encoding.utf8)
        print("Sync Request Body: \(convertedString!)")
    }

    let downloadTask = URLSession.shared.downloadTask(with: urlrequest, completionHandler: { url,response,error in
        if error == nil {
            //some code

            do {
                try FileManager.default.copyItem(at:url!, to: self.documentsUrl!)
                print(self.documentsUrl!)
            } catch (let writeError) {
                print("error writing file \(self.documentsUrl!) : \(writeError)")
            }

        }
    })

    downloadTask.resume()

}

Body:
here the issue is while trying to download zip file their is no content length header so inorder to solve the issue i used the following code and it is working well

 urlrequest.addValue("", forHTTPHeaderField: "Accept-Encoding")