text:
Q: Entity Framework - Separate Primary Keys with Nav Props in One-To-One relationship EF is not being friendly to me.  I need to create a one-to-one relationship that have separate primary keys, while retaining the convenience of navigation properties.   But no matter what I try, EF gives me an error unless I remove the navigation property.
Here's a perfect illustration of the problem.  As you can see, I can't merge primary keys.  And I don't want to simulate a 1..* relationship, because the relationship is always 1-1.
public class SingleParent
{
    public Guid ParentID { get; set; }
    public virtual OnlyChild Child { get; set; }
}

public class OnlyChild
{
    public Guid ChildID { get; set; }
    public virtual SingleParent Parent { get; set; }
}

// Parent and Child cannot share a primary key because a pediatrician only treats children.
public class Pediatrician
{
    public Guid PediatricianID { get; set; }
    public virtual List<OnlyChild> Patients;
}

How can I get the navigation properties such that Parent.Child <==> Child.Parent? I would prefer to do this with Data Annotations to be consistent with the rest code.  Any wisdom would be greatly appreciated!

A: If you add a Foreign Key to both entities it should work with both DataAnnotations and with Fluent API.
    public class SingleParent
    {
        public Guid ParentID { get; set; }
        public Guid ChilId { get; set; }

        [ForeignKey("ChildId")]
        public virtual OnlyChild Child { get; set; }
    }

    public class OnlyChild
    {
        public Guid ChildID { get; set; }
        public Guid ParentId { get; set; }

        [ForeignKey("ParentId")]
        public virtual SingleParent Parent { get; set; }
    }

Here is some documentation that explains how to create a one-to-one relation.


text:
Q: Renaming columns after merging data in Pandas I have two Pandas series which I merged using the following code:
HS4_Tariffs_16=pd.concat([df_tariff_HS4_16_PT,df_tariff_HS4_16_MFN],axis=1)

If you are wondering why I used concat in place of merge, the error 'Series' object has no attribute 'merge' showed up when I used merge.
So anyway, I merged the two series using concat which resulted in a dataframe. Thereafter, I reset the index using the code:
HS4_Tariffs_16.reset_index()

Now the real problem cropped up when I tried to rename a column using the code:
HS4_Tariffs_16=HS4_Tariffs_16.rename(columns={'ProductCode':'HSCode'})

Instead of renaming the column, it converted the column to an index. The output was someting like this:
      Preferential tariff for APTA countries    MFN duties (Applied)
ProductCode
101     0.3     0.3
102     0.3     0.3
103     0.3     0.3
104     0.3     0.3
105     0.3     0.3
...     ...     ...
9702    0.1     0.1
9703    0.1     0.1
9704    0.0     0.0
9705    0.1     0.1
9706    0.1     0.1

1224 rows × 2 columns

Could you tell me which part of the code I need to correct if the final result that I want is a dataframe with the column named 'ProductCode' renamed as 'HSCode'.

A: The following might work without having to reset the index. It could be setting it as index as you're renaming the frame as itself when you rename the column and Pandas is weird like that sometimes!
HS4_Tariffs_16.rename(columns={'ProductCode':'HSCode'}, inplace=True)

A: You can use the rename_axis method to change the name of index columns. This avoids changing the data and adding a potentially unnecessary new index column.
HS4_Tariffs_16.rename_axis(index={'ProductCode':'HSCode'}, inplace=True)

You can also do this in one step using round brackets for cleaner code:
HS4_Tariffs_16 = (
    pd.concat([df_tariff_HS4_16_PT, df_tariff_HS4_16_MFN], axis=1)
    .rename_axis(index={'ProductCode':'HSCode'})
)

A: This should work
df=df.rename({'Old_name' : 'New_name'}, axis=1)

In your case

HS4_Tariffs_16= HS4_Tariffs_16.rename({'ProductCode':'HSCode'}, axis=1)

Or you can create a copy with the name you want and remove original then:
df['renamed']=df['oldname'].copy()
df= df.drop('oldname', axis=1)

A: You can try these two possible solutions:
HS4_Tariffs_16 = HS4_Tariffs_16.reset_index().rename(columns={"ProductCode": "HSCode"})

or
HS4_Tariffs_16.reset_index(inplace=True)
HS4_Tariffs_16.rename(columns={"ProductCode": "HSCode"}, inplace=True)

redpajama_set_name: RedPajamaStackExchange


text:
Q: libgdx make android back button act like home button I want the back button of an android device to act like the home button when pressed (pause the app and lose focus)
i have this :
(Gdx.input.setInputProcessor(this); and Gdx.input.setCatchBackKey(true); are called)
@Override
public boolean keyDown(int keycode) {
    if(keycode == Input.Keys.BACK) {
        pause();
    }
    return false;
}

but calling the pause() method isn't enough, what can i call to make it act like the home button ?

A: Gdx.input.setCatchBackKey(true); // This will prevent the app from being paused.

Use Interfacing and call platform specific code by core module
Inside core module
interface PlatformService{

    fun moveToStack()
}

Implement above interface in Android module
@Override
public void moveToStack() {
    this.moveTaskToBack(true);
}

Get reference of your implementation in core module and call implemented method on keyDown back button
 Gdx.input.setInputProcessor(new InputAdapter(){
        @Override
        public boolean keyDown(int keycode) {

            if (keycode==Input.Keys.BACK){
                 platformService.moveToStack();
            }

            return super.keyDown(keycode);
        }
    });

A: call YourActivity.this.moveTaskToBack(true); instead of pause(); method
like:
  @Override
public void onBackPressed() {
    this.moveTaskToBack(true);
}

Add above code in activity where you want to act back button like home button.


text:
Q: Caveats passing argument as constant reference in multi-thread application Is there any disadvantage passing as const and by reference in multithread application?
I did some research but could not find any answer which explains its behavior with threading and it caveats.


text:
Q: Aplication Crash when i press update or delete my application crash every time when i press save button to update data  or delete on movie details, and i can't figure out why.
Here is some info:
I added some data to my database (that part working fine), and i managed to display from database in custom list view. And now, on click event on list view i want to pull data from database, part with fetching data and seting in fields is working fine, but when i want to update or delete, application crash.
Please help.
here is my code:
MainActivity.java
public class MainActivity extends AppCompatActivity {

DBAdapter db;
SimpleCursorAdapter adapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    db = new DBAdapter(this);
    db.open();

    ListView lv = (ListView) findViewById(R.id.listView1);
    int layoutstyle=R.layout.liststyle;
    int[] xml_id = new int[] {
            R.id.txtname,
            R.id.txtnumber,
            R.id.textView2

    };
    String[] column = new String[] {
            "naziv",
            "zanr",
            "rejting"
    };
    Cursor row = db.fetchAllData();
    adapter = new SimpleCursorAdapter(this, layoutstyle,row,column, xml_id, 0);
    lv.setAdapter(adapter);
    //onClick function
    lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterview, View view, int position, long id) {
            Cursor row = (Cursor) adapterview.getItemAtPosition(position);
            String _id = row.getString(row.getColumnIndexOrThrow("_id"));
            String naziv = row.getString(row.getColumnIndexOrThrow("naziv"));
            String zanr = row.getString(row.getColumnIndexOrThrow("zanr"));
            String glumci = row.getString(row.getColumnIndexOrThrow("glumci"));
            Float rejting = row.getFloat(row.getColumnIndexOrThrow("rejting"));
            //go to detailsContact page
            Intent todetais = new Intent(MainActivity.this, DetailsMovie.class);
            todetais.putExtra("ID",_id);
            todetais.putExtra("NAZIV", naziv);
            todetais.putExtra("ZANR",zanr);
            todetais.putExtra("GLUMCI",glumci);
            todetais.putExtra("REJTING",rejting);
            startActivity(todetais);
        }
    });
    //dispay data by filter
    EditText et = (EditText) findViewById(R.id.myFilter);
    et.addTextChangedListener(new TextWatcher() {
        public void afterTextChanged(Editable s) {
        }
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            adapter.getFilter().filter(s.toString());
        }
    });
    adapter.setFilterQueryProvider(new FilterQueryProvider() {
        public Cursor runQuery(CharSequence constraint) {
            return db.fetchdatabyfilter(constraint.toString(),"naziv");
        }
    });
}

public void addContact(View v) {
    Intent addNewContact = new Intent(MainActivity.this, addNewMovie.class);
    startActivity(addNewContact);
}
}

DetailsMovie.java
public class DetailsMovie extends AppCompatActivity {

DBAdapter db;
String id,naziv,zanr,glumci;
Float rejting;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.details_movie);

    Intent intent = getIntent();
    naziv = intent.getStringExtra("NAZIV");
    zanr = intent.getStringExtra("ZANR");
    glumci = intent.getStringExtra("GLUMCI");
    rejting = intent.getFloatExtra("REJTING", 1);

    ((TextView) findViewById(R.id.naziv)).setText(naziv);
    ((TextView) findViewById(R.id.zanr)).setText(zanr);
    ((TextView) findViewById(R.id.glumci)).setText(glumci);
    ((RatingBar) findViewById(R.id.rejting2)).setRating(rejting);
    //calling DbAdapter
    db = new DBAdapter(this);
    db.open();
}
public void Edit(View v){
    //go to EdimMovie page
    Intent edit = new Intent(DetailsMovie.this, EditMovie.class);
    edit.putExtra("ID", id);
    edit.putExtra("NAZIV", naziv);
    edit.putExtra("ZANR", zanr);
    edit.putExtra("GLUMCI", glumci);
    edit.putExtra("REJTING",rejting);
    startActivity(edit);
}
public void Delete(View v){
    db.delete(Integer.parseInt(id));
    Toast.makeText(getApplicationContext(),"Uspešno ste obrisali film", Toast.LENGTH_SHORT).show();

    Intent i = new Intent(this, MainActivity.class);
    startActivity(i);
}
@Override
public void onBackPressed() {
    finish();
    Intent i = new Intent(this, MainActivity.class);
    startActivity(i);
}
}

EditMovie.java
public class EditMovie extends AppCompatActivity {

DBAdapter db;
String id,naziv,zanr,glumci;
Float rejting;
EditText etnaziv,etzanr,etglumci;
RatingBar etrejting;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.store_movie);

    Intent intent = getIntent();
    id = intent.getStringExtra("ID");
    naziv = intent.getStringExtra("NAZIV");
    zanr = intent.getStringExtra("ZANR");
    glumci = intent.getStringExtra("GLUMCI");
    rejting = intent.getFloatExtra("REJTING" ,1);

    ((EditText) findViewById(R.id.naziv)).setText(naziv);
    ((EditText) findViewById(R.id.zanr)).setText(zanr);
    ((EditText) findViewById(R.id.glumci)).setText(glumci);
    ((RatingBar) findViewById(R.id.rejting)).setRating(rejting);
    //calling DbAdapter
    db = new DBAdapter(this);
    db.open();

    //get data from text feld
    etnaziv =(EditText)findViewById(R.id.naziv);
    etzanr =(EditText)findViewById(R.id.zanr);
    etglumci =(EditText)findViewById(R.id.glumci);
    etrejting = (RatingBar) findViewById(R.id.rejting);
}
public void Save(View v){
    naziv = etnaziv.getText().toString();
    zanr = etzanr.getText().toString();
    glumci = etglumci.getText().toString();
    rejting = etrejting.getRating();
    db.update(Integer.parseInt(id),naziv, zanr, glumci, rejting);
    Toast.makeText(getApplicationContext(),"Uspešno ste ažurirali listu", Toast.LENGTH_SHORT).show();
}
@Override
public void onBackPressed() {
    finish();
    Intent i = new Intent(this, MainActivity.class);
    startActivity(i);
}
}

DBAdapter.java
public class DBAdapter {

//define static variable
public static int dbversion =1;
public static String dbname = "FilmoviDb";
public static String dbTable = "filmovi";

private static class DatabaseHelper extends SQLiteOpenHelper {
    public DatabaseHelper(Context context) {
        super(context,dbname,null, dbversion);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("CREATE TABLE IF NOT EXISTS "+dbTable+" (_id INTEGER PRIMARY KEY autoincrement,naziv, zanr, glumci, rejting, UNIQUE(naziv))");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS "+dbTable);
        onCreate(db);
    }
}

//establsh connection with SQLiteDataBase
private final Context c;
private DatabaseHelper dbHelper;
private SQLiteDatabase sqlDb;

public DBAdapter(Context context) {
    this.c = context;
}
public DBAdapter open() throws SQLException {
    dbHelper = new DatabaseHelper(c);
    sqlDb = dbHelper.getWritableDatabase();
    return this;
}

//insert data
public void insert(String text2,String text3,String text4,Float text5) {
    if(!isExist(text2)) {
        sqlDb.execSQL("INSERT INTO filmovi (naziv, zanr, glumci, rejting) VALUES('" + text2 + "','" + text3 + "','" + text4 + "','" + text5 + "')");
    }
}
//check entry already in database or not
public boolean isExist(String num){
    String query = "SELECT naziv FROM filmovi WHERE naziv='"+num+"' LIMIT 1";
    Cursor row = sqlDb.rawQuery(query, null);
    return row.moveToFirst();
}
//edit data
public void update(int id,String text2,String text3,String text4,Float text5) {
    sqlDb.execSQL("UPDATE "+dbTable+" SET naziv='"+text2+"', zanr='"+text3+"', glumci='"+text4+"', rejting='"+text5+"'   WHERE _id=" + id);
}

//delete data
public void delete(int id) {
    sqlDb.execSQL("DELETE FROM "+dbTable+" WHERE _id="+id);
}

//fetch data
public Cursor fetchAllData() {
    String query = "SELECT * FROM "+dbTable;
    Cursor row = sqlDb.rawQuery(query, null);
    if (row != null) {
        row.moveToFirst();
    }
    return row;
}

//fetch data by filter
public Cursor fetchdatabyfilter(String inputText,String filtercolumn) throws SQLException {
    Cursor row = null;
    String query = "SELECT * FROM "+dbTable;
    if (inputText == null  ||  inputText.length () == 0)  {
        row = sqlDb.rawQuery(query, null);
    }else {
        query = "SELECT * FROM "+dbTable+" WHERE "+filtercolumn+" like '%"+inputText+"%'";
        row = sqlDb.rawQuery(query, null);
    }
    if (row != null) {
        row.moveToFirst();
    }
    return row;
}
}

Logcat
08-15 15:55:47.064 9521-9521/com.example.peter.androidprojekat E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.peter.androidprojekat, PID: 9521
java.lang.IllegalStateException: Could not execute method for android:onClick
    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:390)
    at android.view.View.performClick(View.java:5637)
    at android.view.View$PerformClick.run(View.java:22429)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
 Caused by: java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
    at android.view.View.performClick(View.java:5637)
    at android.view.View$PerformClick.run(View.java:22429)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
 Caused by: java.lang.NumberFormatException: null
    at java.lang.Integer.parseInt(Integer.java:483)
    at java.lang.Integer.parseInt(Integer.java:556)
    at com.example.peter.androidprojekat.DetailsMovie.Delete(DetailsMovie.java:47)
    at java.lang.reflect.Method.invoke(Native Method)
    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:385)
    at android.view.View.performClick(View.java:5637)
    at android.view.View$PerformClick.run(View.java:22429)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

A: You are trying to parse the String value to Integer. You need to get value of ID in detail Activity screen, like:
id = intent.getStringExtra("ID");

That's the whole fix.

A: You never set a value to your id variable, that cause a NumberFormatException:
db.delete(Integer.parseInt(id));

A: You are not setting Id from intent in DetailsMovie. So your Id is null hence the exception
You forgot to add this in your DetailsMovie onCreate()
    id = intent.getStringExtra("ID");


text:
Q: Relative maximum and minimum of the modulus of a function Let $$f(z)=(z -1)(z -4)^{2}$$ Find the lines (through $z=2$) on which $|f(z)|$ has a relative maximum, and the ones on which $|f(z)|$ has a relative minimum.
MY ATTEMPT:
"The line z= 2" is the line where z= 2+ ix for any real number x. Then $f(z)=(z−1)(z−4)^{2} =(2−ix−1)(2−ix−4)^{2}=(1−ix)(−2−ix)^{2}$ . Write out $|f(z)|$ as a function of x, find the derivative, set it equal to 0.

A: Here is a hint to get you started.  Please ask if you require clarification.  If you edit your question to include what you have tried so far I would be more willing to give extra help.
You can parameteize any line going through $z=2$ by
$$
z(t) = 2 + te^{i\theta},
$$
where $\theta$ is the (fixed) angle the line makes with the positive real axis and $t$ is allowed to vary over $\mathbb{R}$.  Substitute this into $|f(z)|$ and differentiate with respect to $t$.


text:
Q: Read a file from github I want to read a file from github repository in my ruby script. Say I want to read Gemfile from my repo on github, URL for which would be like: "http://www.github.com/myrepo/blob/master/Gemfile".
I tried using File.readLink("http://www.github.com/myrepo/blob/master/Gemfile") but this gives me error saying "'readlink': No such file or directory @ rb_readlink".
How do I read a file using the github URL?

A: You should try to fetch raw content from github files like:
require 'net/http'

uri = "https://raw.githubusercontent.com/username/myrepo/master/Gemfile"
uri = URI(uri)
file = Net::HTTP.get(uri)

A: With the below code, I was able to read the content of the file.
require 'open-uri'
raw_url = "https://raw.githubusercontent.com/username/myrepo/master/Gemfile"
open(raw_url) {|f|
  f.each_line {|line| p line}
}


text:
Q: Object properties is undefined even with value after copy the object i got a object that have 2 of the properties returning undefined even with a value inside of them, when i access them directly like "modelForm.action" it gives the right value but if a just do console.log(modelForm) returns the name undefined
 this.modelForm = Object.assign({}, this.formSelected)
 console.log(this.modelForm)
 console.log(this.modelForm.action)

//First Log
action: undefined  company_id: 1  created_at: "2022-12-19 19:13:21"  deleted_at: null  description: "ewef"  html: null  id: 7  name: "Form 3"  status: undefined  updated_at: "2022-12-19 19:45:34"
//Second Log
default


text:
Q: Why don't torrent leeching sites leech video files to complete 100%? I downloaded .mp4 file using torrent leeching sites.
After checking the downloaded data with torrent file, it shows only 99.9% (no problem with playback)

It only for videos files, but for zip/exe files etc it's leeching 100%.


text:
Q: Fish Shell Fatal Error : Not A Git Repository I have been using Fish Shell for a while now, however, a day or two ago, this error started appearing on execution of every command within the shell:
fatal: Not a git repository (or any of the parent directories): .git
Here is a screenshot:

Can anyone explain why this is happening and how to resolve it. I was thinking of reinstalling but wondered why this is happening in the first place.
Thanks,


text:
Q: How does a processor fetch cache lines? When a processor pre-fetches a cache-line of data, does it pre-fetch from that address up to the number of bytes or does it pre-fetch from that address up to half the cache line and back wards up to half the cache line?
For example assume cache line is 4 bytes and pre-fetching from address 0x06. Will it fetch bytes at 0x06 0x07 0x08 0x09 or will it pre-fetch from addresses 0x04 0x05 0x06 0x07.
I need this info for a program which I am writing and need to optimize.

A: According to this (which is naturally Intel specific)
"The cache line size is 32 bytes, or 256 bits.
A cache line is filled by a burst of four reads on the processor's 64-bit data bus."
This means 8 bytes are fetched in parallel from main memory, within these 8 bytes there's no first or last, they arrive simultaneously, as the bytes are fetched over a 64 bit wide bus.
As it takes 4 reads to fill a cache line, Intel seems to not specify the order of these 4 reads - which mean you're left with some choices, e.g.

*

*assume that there is no specific order

*assume the address are fetched from lowest to highest, or vice versa.

The first assumption is of course the safest - since the order is as far as I can find undocumented(so it could depend on the model, or other factors)

A: The cache lines have to have an alignment, so if your first read or first transaction that has a miss that causes a cache line fetch, is in the middle of a cache line it will go back and read the whole cache line (so the part before your address and the part after).
In general the cache uses a portion of the address to determine hit/miss.  So if say the cache line was 256 bytes, then the address bits used to determine hit/mist would start at bit 8 and depending on how big the cache was (depth and ways) would determine how many bits to look at.  So using my example if an access at address 0x123 produced a miss, then the cache line from 0x100-0x1FF would be read.
if it were the other way that would be a lot more logic and work and confusion, if you could start a cache line on any byte, it would be harder to determine hit/miss, and/or you would/could have overlapping cache lines (some item of data is in more than one place), that would have to be managed overall making the cache slower.


text:
Q: incorporating -xmlConfigured in maven Does the maven-aspectj-plugin have an option to specify ajc's option -xmlConfigured?
If not, what's the common practice for compiling aspect codes with most recent version of ajc using maven?

A:
Does the maven-aspectj-plugin have an option to specify ajc's option -xmlConfigured?

AFAIK, the maven-aspectj-plugin doesn't have such an option, the -xmlConfigured is just too new.

If not, what's the common practice for compiling aspect codes with most recent version of ajc using maven?

I'm pretty sure patch are appreciated and welcome :)

A: Nowadays AspectJ Maven has the parameter:
http://www.mojohaus.org/aspectj-maven-plugin/compile-mojo.html#xmlConfigured


text:
Q: Where does all of my physical memory go? If I go to task manager, I saw where all they go

Notice show processes from all users are ticked.
Now I have 8GB memory. If you look the above picture, the "greediest" program use at most 300mb of memory. So the the total is at most 2 GB. Yet if I look at the graph, task manager said I am using 7GB.

Note: Before answering, please try this in your computer first. Chance is the same problem is in your computer too all along. I have this issues in all of my computers running windows 7. It seems to be behavior rather than a bug.
The issue is basically this. There is a discrepancy between memory used by processes and memory used total. I just want some explanation. Some says memory commit but I want to see detail to strengthen my faith.

A: Try this instead.
Open Task Manager, change to the 'Performance' tab, click 'Resource Monitor' then change to the 'Memory' tab.
I find this gives more in-depth information on what services, programs, etc. are using memory. See if you can identify the cause.
Do you have Microsoft SQL server installed?

A: First of all, there is a lot of caching going on on all current (and older) windows systems that is not listed as processes in the taskmanager. You don't have any disadvantages of this.
From your tasklist I assume that you have one or several tools running which are sharing an instance of mongo-db. If this is an in-memory database, then this might be the thing that eats up your memory.
You can track this down if you completely restart your system and then start the programs you are normally running, while watching the resource-monitor.

A: The graph is showing the memory used by the system cache in addition to your process memory. System cache does not show up as memory used by processes.
See Microsoft's explanation of File Caching.
Windows is putting your free memory to good use by prefetching data from disk, based on some proprietary heuristics. There is nothing wrong with your system, and your system will actually perform better with this behavior.


text:
Q: I am getting log in stripe but it show no payments in payment option I am working on stripe connection and i am getting the log of data and it 200 means api is hitting but i am not getting payments and its not showing in payment optino of stripe
my code that i am using is
<button id="customButton" class="submit_btn">Make Appointment</button>
                    <script src="https://checkout.stripe.com/checkout.js"></script>
                    <input type="hidden" id="stripeToken" name="stripeToken" />
                    <script>
                       var handler = StripeCheckout.configure({
                            key: 'TOKEN',
                            image: 'https://stripe.com/img/documentation/checkout/marketplace.png',
                            locale: 'auto',
                            token: function(token) {
                                jQuery(function ($) {
                                    console.log("testing12");
                                    $('#stripeToken').val(token.id);

                                });
                            }
                        });
                        jQuery(function ($) {
                            document.getElementById('customButton').addEventListener('click', function (e) {
                                var amount =  0;
                                $('input:checkbox:checked').each(function(){
                                    amount  += isNaN(parseInt($(this).val())) ? 0 : parseInt($(this).val());
                                    $('#total').text(amount);
                                });
                                handler.open({
                                    name: 'Sports Solution',
                                    description: '',
                                    amount: amount
                                });
                                e.preventDefault();
                            });
                        });
                        // Close Checkout on page navigation:
                        window.addEventListener('popstate', function() {
                            handler.close();
                        });

I dont know where i am doing it wrong.


text:
Q: find median in O(log n) The question is how we can find the median of a receiving stream of integer values (e.g. for 12, 14, 252, 243, 15 the median is 15) in O(log N) where N is number of values. Please note that we have a stream of integer values, hence by receiving each value, we have to re-find the median.
Example:
  | Input | median
1 |   12  |   12
2 |   14  |   13 = (12+14)/2
3 |   252 |   14
.
.
.

P.S: An example of using this algorithm could be filtering an image.

A: (I assume that you're after an algorithm that, given n existing numbers and one new number, will take logarithmic time to find the median of the new collection of n+1 numbers, so that the total run time for adding n numbers will be O(n lg n).)
There is probably a named algorithm for this already, but here's my idea: Maintain a red-black tree into which you insert the numbers as they arrive. In each node, in addition to the number itself and the child/parent pointers, you store an integer that tells the number of nodes that exist below this node (including the node itself, for convenience). I'm quite certain that this information can be updated in logarithmic time on each insert operation, even when tree rotations are required. With this information embedded in the tree, locating the median can be done in logarithmic time if you also keep track of the number of nodes in the tree.
(This might be a slightly too high-level description; let me know if you need more details.)

A: Hoare's selection algorithm (aka quickselect) can do this in O(n) average time.
It's basically recursively partitions the data set with a random pivot and checks the appropriate part.
There is also a median of medians algorithm which has guaranteed O(n) worst time complexity, but for the normal usage it's usually an overkill.

A: Okay, with the update to the question so the intent is clear (not just find the median, but re-find the median each time you receive a new number), I think there's a way.
I'd start with a pair of heaps: a max-heap and a min-heap. The min-heap will contain the numbers larger than the median, and the max-heap the numbers smaller than the median. When you receive the first number, that's your median. When you receive the second, you insert the smaller of the two into the max-heap, and the larger of the two into the min-heap. The median is then the average of the smallest on the min-heap, and the largest on the max-heap.
Along with the two heaps, you'll want storage for a single integer that will be the current median when you've received an odd number of inputs. You'll populate that fairly simply: if you receive an input with it currently full, you basically sort those two items (the new number and the old median) and insert the smaller into the heap for the smaller items, and larger into the heap for larger items. Your new median will then be the mean of the bases of those two heaps (and you'll mark the other storage location as empty).
When you receive a new number with that empty, you'll compare the new number to the median. If it's between the numbers as the bases of the heaps, it's the new median, and you're done. Otherwise, extract the number from the base that must hold the median (larger numbers if the new number is larger, smaller if it's smaller) and put that into the median spot, then insert the new number into the heap that came from.
At least if memory serves, the extract/insert into a heap should be O(log N). I believe everything else involved should be constant complexity.


text:
Q: SalesForce: how to get result of post-back request I am writing application (.NET 4.0) that should do post-request to SalesForce to submit data (to https-url, means secured connection should be used).
I've created small test that do request with some parameters (probably not all that are actually required are included). My request seems like successful, but I not sure.
What I receive from server is response that has 4 keys in header:

*

*Is-Processed: true;

*Content-Length: 0;

*Date: ... {"current date/time"};

*Sever: "SFDC".

Question 1:
Can I be sure that my request was correctly processed by sales force? Seems like request is more or less good, but looking into actual SalesForce data I don't see result of my request.
Question 2:
Is there any way to get more feedback from SalesForce about request sent?
Thanks a lot! Any thoughts are welcome!
P.S. Here is a code that I use to submit request:
        HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(strSubmitUrl);
        myRequest.Method = "POST";
        myRequest.ContentType = "application/x-www-form-urlencoded";
        myRequest.ContentLength = aBytesRequest.Length;
        myRequest.AllowAutoRedirect = false;

        string strResult;
        try
        {
            Stream newStream = myRequest.GetRequestStream();
            newStream.Write(aBytesRequest, 0, aBytesRequest.Length);
            newStream.Close();

            WebResponse response = myRequest.GetResponse();
            Stream stream = response.GetResponseStream();
            int iResponseLength = 0;
            if ( response.Headers["DataLength"]!=null)
            {
                int.TryParse(response.Headers["DataLength"], out iResponseLength);
            }
            ...

A: It seems like everything is fine in my code. Probably some configuration was required on SalesForce side to display submitted data.
Also, SalesForce doesn't return any data, only header, with status code 200 and data length 0.


text:
Q: KnockoutObservableArray not getting populated Given the following code, why would LookupEditorVM.lookups end up as 'undefined'?
I've verified that the data is coming back, but maybe I'm misunderstanding how ko.mapping works.
Code:
class LookupEditorVM {
    lookups: KnockoutObservableArray<LookupVM>;

    click(item) {
        this.selected(item)
    }

    constructor(baseURL: string) {
        this.lookups = ko.observableArray<LookupVM>([]);
        $.getJSON(baseURL, (data) => {
            ko.mapping.fromJS(data, {}, this.lookups);
        });

        this.selected = ko.observable(undefined);

    }
}

class LookupVM {
    ID: number;
    Name: string;
    DisplayName: string;
    Description: string;
}

A: See Knockout Binding Context. Because click is on the prototype and is invoked without any explicit this context, invoking it loses which class instance it belonged to.
You can also fix this by using an arrow function in your ViewModel definition for any event handlers that will be invoked this way:
class LookupEditorVM {
    lookups: KnockoutObservableArray<LookupVM>;
    selected: KnockoutObservable<LookupVM>;

    click = (item) => { // <--- Arrow function preserves 'this'
        this.selected(item)
    }

    constructor(baseURL: string) {
        this.lookups = ko.observableArray<LookupVM>([]);
        $.getJSON(baseURL, (data) => {
            ko.mapping.fromJS(data, {}, this.lookups);
        });

        this.selected = ko.observable(undefined);
    }
}


text:
Q: Chrome not retaining scroll position on back button On most (static) websites, browsers will retain the user's previous scroll position when going back to a previous page.
On my site, Firefox, Safari, and Edge all exhibit this behavior, by default. But Chrome does not. Why?
My app is built on tornado and we use jinja2 to render static pages, so I wouldn't expect there to be an issue due to an AJAX-heavy web framework.
I have tried modifying the cache headers to see if it was a caching issue, as suggested here, but no luck. I also don't have the overflow: auto issue suggested in that post.
Here are my response headers:
HTTP/1.1 200 OK
Date: Fri, 09 Nov 2018 18:11:20 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: *
Etag: W/"<etag>"
Cache-Control: private
Content-Encoding: gzip

A: <facepalm>
I was focusing an element on page load that is at the top of the screen, which causes Chrome to scroll to the element. Not sure why Firefox/Safari/Edge behave differently.


text:
Q: Как сделать сортировку List начиная с нужного индекса с определённым колич переменных У Меня есть список:
class Chrom
{
    public Chrom(int x,int y)
    {
        this.x = x;
        this.y = y;
        z = (this.x - 3 * this.y - 3) / (Math.Pow(this.x, 2) + 2 * Math.Pow(this.y, 2)+1);
    }
    public int x, y;
    public double z;
}

List<Chrom> chroms = new List<Chrom>();
for(int i=0;i<16;i+=4)
{
    int CountChrom = chroms.Count-1;
    chroms.Add(new Chrom(chroms[CountChrom-1].x,chroms[CountChrom].y));
    chroms.Add(new Chrom(chroms[CountChrom - 2].x, chroms[CountChrom].y));
    chroms.Add(new Chrom(chroms[CountChrom].x, chroms[CountChrom-1].y));
    chroms.Add(new Chrom(chroms[CountChrom].x, chroms[CountChrom - 2].y));
    chroms.Sort(i, 4, (prop, value) => prop.z.CompareTo(value.z));
}

здесь я каждый раз добавляю 4 новых переменных и я хочу сортировать только 4 новых элемента по возрастанию но не совсем понимаю как написать 3 параметр функции sort

A: Создайте компарер
public class ZComparer : IComparer<Chrom>
{
    public int Compare(Chrom current, Chrom other)
        => current.z.CompareTo(other.z);
}

List<Chrom> chroms = new List<Chrom>();
IComparer<Chrom> comparer = new ZComparer();
for (int i = 0; i < 16; i += 4)
{
    int CountChrom = chroms.Count - 1;
    chroms.Add(new Chrom(chroms[CountChrom - 1].x, chroms[CountChrom].y));
    chroms.Add(new Chrom(chroms[CountChrom - 2].x, chroms[CountChrom].y));
    chroms.Add(new Chrom(chroms[CountChrom].x, chroms[CountChrom - 1].y));
    chroms.Add(new Chrom(chroms[CountChrom].x, chroms[CountChrom - 2].y));
    chroms.Sort(i, 4, comparer);
}


text:
Q: How Google knows the links to my web pages because I want to create a multi-language site but the SEO stands in my way I'm bad at English forgive me and try to understand me
** I try Multi-language ** with a database (mysqli)
** But I'm having trouble with SEO ** I created a table in such database
https://imgbbb.com/image/RgT9r
And I have programmed the class to select the language automatically and change the language and so on
my question is
which language Google will use (when user search for any thing)
An example in register page i will put multi language button

<button><?php Lang::main('RGISTER') ?></button>

How can I put the registration page in the robots file (sitemap) in two languages, namely Arabic and English

A: According to this google support article(Tell Google about localized versions of your page) and this user's question(How can I add meta tag for multi-lingual website?) a right way would be to use a alternate meta link to your multilingual content.
Google article suggest also other useful tips and techniques for this problem.
Tells that the current page is also available in espanjol on this url:
<link rel="alternate" href="http://example.com/es" hreflang="es" />

A: A few essential items to ensure you've addressed when supporting internationalization of a website:

*

*Set the HTML lang attribute, declaring the on-page content's language (...)

*Add link elements in the  with absolute URLs of the alternate versions/translations and ISO 639-1 Language Codes hreflang attribute. Important to also add a self-referencing element for the current page, itself.

Example: Current webpage is in English, yet also have Japanese-translated version of that webpage - declare ... and within  add:
<link rel="alternate" hreflang="en" href="https://example.com/en/" />
<link rel="alternate" hreflang="ja" href="https://example.com/ja/" />

Also add language/locale versions/references in the sitemap.xml file(s) of your website and it's always a good idea to set absolute canonical on each page.
Also have consistency, site-wide, in either ccTLD, subdirectory/subfolder, subdomain, etc.
More reading from Google Search Console support (covers sitemap support).


text:
Q: Cocos2d-x 2.2.5 scene replacing Recently i started to study Cocos2d-x (C++). Problem is following, i do not know what is my problem, when i try to change scenes(when push the but).
void HelloWorld::menuCloseCallback(cocos2d::CCObject* pSender)
{
CCScene *pScene = UzdevumsScene::scene();
CCDirector::sharedDirector()->replaceScene(pScene);
}

Error:
error: undefined reference to 'UzdevumsScene::scene()'

When i use this line, i get nothing more than black screen(when i push the button).
CCScene *UzdevumsScene = CCScene::create();
    CCTransitionPageTurn *HelloWorld = CCTransitionPageTurn::create(1, UzdevumsScene, true);
    CCDirector::sharedDirector()->replaceScene(UzdevumsScene);


text:
Q: How to uninstall Umbraco 7 I installed Umbraco 7.2.2. from the latest nuget package. However, annoyingly I just clicked install from the initial install wizard, as shown below.

Unknowingly it wouldnt ask me for the DB connections. So my question is. Is there a clean way to revert the installation and start again. Or am I just best to delete the project and install the NuGet package again?
Im aware of earlier versions that I could just remove the appsetting value below and it would start the installer again.
<add key="umbracoConfigurationStatus" value="7.2.2" />

EDIT:
This is no longer the case. Removing the value from the above app settings only looks to upgrade the installation.

However I dont want to be left with a bloated Umbraco install with redundant files, like the .sdf DB etc. Or is it the case that the normal install doesnt actually include many additional files than the custom install? And its just the SDF?
The more I write this the more it makes sense to just start again with a fresh project. :)
Keen to hear an opinion regardless.

A: Start with the current site as it is installed now and go to the backoffice (http://yoursite.local/umbraco). Go to the developer section > Packages > Installed Packages > Fanoe. Go to the Uninstall Package tab and confirm the uninstall.
In your web.config set umbracoConfigurationStatus to an empty string:
<add key="umbracoConfigurationStatus" value="" />
And set the connection string to the default empty values:
<remove name="umbracoDbDSN" />
<add name="umbracoDbDSN" connectionString="" providerName="" />

After saving this file, your application pool will recycle and you can delete the umbraco.sdf file from the App_Data folder. In fact you can delete everything in App_Data.
As you said, it would be much easier to delete the current site and just start over, choosing "Customize" during the next install.


text:
Q: How to improve the performance of app with a Google Map in it built with sencha touch and phoneGap? I have built an app which contains a google js map with sencha touch and phoneGap ,
But its performance is not good(At least in my Samsumg Galaxy9000) it takes almost half a minute to load the whole map,
BTW,I have lazy loaded the Google Map Js library
How to improve its performance?

A: Have you tried using the excellent libraries here: github.com/libbybaldwin/GMap-Demo-App
Most of my map issues have gona away since I started using this library.


text:
Q: Building a Wordpress powered bilingual website I am about to develop a bilingual website that will use a global language switch, exactly as  this architectural website, with the FR|EN switch.
Clicking on FR link should ideally lead me to www.mydomain.com/fr/my_content. The same behaviour is expacted with the EN one.
I have read the Wordpress page on the topic, and had a look at a few plugins. I am now looking for human feeback, ideally from someone who would have built something similar, before jumping right into it as the list of alternative is quite long.


text:
Q: Accessing a static property of a child in a parent method Say I have the following code:
class Parent
{

    static string MyField = "ParentField";

    public virtual string DoSomething()
    {
        return MyField;
    }
}

class Child : Parent
{
    static new string MyField = "ChildField";
}

Now I want to be able to do both of the following:
Console.WriteLine(Parent.MyField);
Console.WriteLine(Child.MyField);

These work as expected, but I would also like to do this:
Child c = new Child();
Console.WriteLine(c.DoSomething());

Since DoSomething() is not defined for the Child class, it's the Parent's MyField that gets returned, but what I want is the Child's MyField.
So my question is: Is there any way I can do this?
NOTE: Overriding the method in the Child class is an option, but since I will have lots of Child classes inheriting from the Parent and the method is supposed to do the same in all of them, changing something in this method would bring a lot of trouble.

A: If you find yourself requiring a construct not supported by the language, in this case static virtual members, that is a smell, indicating you might have a faulty design.
Instead of showing us a solution, show us the problem you are trying to solve with that solution. My guess is that there is a totally different design that eliminates the need for this oddity.
Put another way: the answers you've received aren't the ones you want because the question you asked is not really the question you should be asking. I can think of no situation where the proposed design offers benefits that another, more conventional design does not.

A: You have to handle this in Child, too:
class Child
{
    static new string MyField = "ChildField";

    public override string DoSomething()
    {
         return MyField;
    }
}

That being said, using a single virtual property would probably be a cleaner design, since you wouldn't need the "new" keyword to hide the Parent's member field.

A: I don't get why you think you need both "static" and "non-static" environments to call different properties/functions that return the same thing. If you just do this:
class Parent
{
    public virtual string DoSomething()
    {
        return "ParentField";
    }
}

class Child
{
    public override string DoSomething()
    {
         return "ChildField";
    }
}

Then this will work like you want:
Child c = new Child();
Console.WriteLine(c.DoSomething());

And instead of writing this:
Console.WriteLine(Parent.MyField);
Console.WriteLine(Child.MyField);

you just write this:
Console.WriteLine(new Parent().DoSomething());
Console.WriteLine(new Child().DoSomething());

Is there some other constraint on the problem that makes this unacceptable? Is creating new objects of these classes extremely expensive for some reason, for example?

A: Use a static property instead of a static variable.  Then you can override the property in the child class instead of creating a "new" field.

A: Yes, override DoSomething:
class Child
{
    static new string MyField = "ChildField";

    public virtual string DoSomething()
    {
        return MyField;
    }

}

A: There's no inheritance magic on anything static but you could dó this
protected virtual string { get { return "your value"; } }

and use the property inside your method

A: In one response you seem to indicate that the static field is constant. If that is the case, then this should work for you.
class Parent
{
    protected virtual string MyField() { return "ParentField"; }

    public virtual string DoSomething()
    {
        return MyField();
    }
}

class Child : Parent
{
    protected override string MyField() { return "ChildField"; }
}

A: The only way is overriding DoSomething method or else it is not possible. The DoSomething in Parent method essentially translates to:
public virtual string DoSomething()
    {
        return Parent.MyField;
    }

When you "new" a property, it only applies to that type - in this case Child class. If the property is accessed via the 'Parent', it will always return the original property.

A: First, let me say that you really should just make MyField virtual and accept that you need to spawn an instance to get it. However, another way of "solving" the problem would be:
class Parent
{
    public static string MyField = "ParentField";
    protected virtual MyLocalField = MyField;

    public virtual string DoSomething()
    {
        return MyLocalField;
    }
}
class Child : Parent
{
    public static new string MyField = "ChildField";
    protected override MyLocalField = MyField;
}


text:
Q: What is the value of $\dfrac{d z^*}{dz}$? While doing math exercises, I came across the following expression:
$$
\dfrac{d z^*}{dz},
$$
where $\cdot^*$ indicates the conjugate operator and $z \in \mathbb{C}$. The initial guess was to solve it by doing the following:
$$
\dfrac{d z^*}{dz} = \left(\dfrac{d z}{dz}\right)^* = 1^* = 1,
$$
but I am insecure over the first equality. Furthermore, I've found on internet (without demonstration) that
$$
\dfrac{d z^*}{dz} = 0.
$$
Is that right?

A: It depends on what you mean by $\frac{d}{d z}\bar z$. If you want to mean the complex derivative of $\bar z$, that is if
$$
\frac{d}{d z}f(z):=f'(z):=\lim_{w\to 0}\frac{f(z+w)-f(z)}{w}
$$
then $\frac{d}{d z}\bar z$ doesn't exists, as can be checked by the given definition. However its possible that you wanted to mean $\frac{\partial}{\partial z}\bar z$, then in this case you will have that
$$
\begin{align*}
\frac{\partial}{\partial z}\bar z&=\frac1{2}\left(\frac{\partial}{\partial x}-i\frac{\partial}{\partial y}\right)(x-iy)\\
&=\frac1{2}\left(\frac{\partial}{\partial x}x-i\frac{\partial}{\partial x}y-i\frac{\partial}{\partial y}x-\frac{\partial}{\partial y}y\right)\\
&=\frac1{2}\left(1-0-0-1\right)=0
\end{align*}
$$
as $\frac{\partial}{\partial z}:=\frac1{2}\left(\frac{\partial}{\partial x}-i\frac{\partial}{\partial y}\right)$.
To complete a bit more, there is a theorem than says that, if $f$ is holomorphic at $z$ then $f'(z)=\frac{\partial}{\partial z}f(z)$.

A: Note that $* : \mathbb{C} \to \mathbb{C}$ with $*(x, y) = (x, -y)$. The derivative is $$D*(x, y) = \begin{pmatrix}1 & 0 \\ 0 & -1 \\ \end{pmatrix}.$$


text:
Q: Is there benefit to adding a document identifier in MongoDB? I'm using mongodb to store test data. There will be 3 types of documents that will be created test case, test run, and the test data.
Test data will contain keys called testrun_id and testcase_id that will be used as a two way reference for information on test data.
I was wondering if it was worth adding a key in each of type of documents that specifies the type of document it is.
For example:
{
    _id : ObjectID(testdata ID),
    testcase_id : ObjectID(testcase ID),
    testrun_id :  ObjectID(testrun ID),
    docType : "3",
    data1 : 1234,
    data2 : 5678
}
// Another document
{
    _id : ObjectID(testdata ID 2),
    testcase_id : ObjectID(testcase ID),
    testrun_id :  ObjectID(testrun ID),
    docType : "3",
    data1 : 1234,
    data2 : 5678
}

Where docType could be 1 for test case, 2 for test run, and 3 for test data.
I would think this would help grab all specific types of document quicker? Or does MongoDB have a functionality like this already?

A: Document (_id) identifier will be generated by mongodb database driver.
Incase you want to override it, you can send it from your application while creating a document.
It also ensures a unique identifier assigned to every document in a collection and is not null, means it is primary key for the document.
In your case if you have testcase_id as a unique id, you can send it in _id, but make sure it is always unique and not null.
For more information you can see this link:
https://www.mongodb.com/blog/post/generating-globally-unique-identifiers-for-use-with-mongodb


text:
Q: CoCart - Get cart with JWT and cart key is not working in Flutter (but working in postman) I use the plugin CoCart for my Flutter project and I want to merge a guest cart with a logged in user. You can call the endpoint in 2 ways. With a JWT and that's is. Or With a JWT and a cart key. Then it merges the carts together. When I try it it postman, it works (row also gets deleted from database table). When I try it with this code in Flutter, the status code is 200 but it only works for 50%. Some cart items do not get merged (if cart item already exists) and the guest cart key in the database is not deleted.
This is how the code looks like now:

static Future<Cart> getCart() async {
    String? token = await Auth().getToken();
    String? cartKey = "";
    String url = 'https://websitename.com/wp-json/cocart/v2/cart';
    Map<String, String> myHeaders = {
      'Content-Type': 'application/json',
      'Accept': 'application/json',
    };

    if (token != null) {
      myHeaders['Authorization'] = 'Bearer $token';
    }

    cartKey = await Auth().getCartKey();
    if (cartKey != null) {
      String addOn = '?cart_key=${cartKey}';
      url = url + addOn;
    }
    var response = await http.get(
      Uri.parse(url),
      headers: myHeaders,
    );

    if (response.statusCode == 200) {
      return Cart.fromJson(jsonDecode(response.body));
    } else {
      throw Message.fromJson(jsonDecode(response.body));
    }
  }

Does anyone has experience with CoCart? Please help me out. I searched for every website but cannot seem to figure it out.


text:
Q: how to get date in YYYY-MM-DD format in angular 2 I want to get date in the following format: YYYY-MM-DD.
I wrote a date service in Angular2 based on this question:
How do I get the current date in JavaScript?.
I wanted to check if it is a correct implementation or if there exists a better way to achieve the goal.
import { Injectable } from '@angular/core';

@Injectable()
export class DateService {
private currentDate = new Date();

    getCurrentDateInApiFormat(): string{
        let day:any = this.currentDate.getDate();
        let month:any = this.currentDate.getMonth() + 1;
        let year:any = this.currentDate.getFullYear();
        let dateInApiFormat: string;

        if(day<10){
           day = '0' + day.toString();
        }
        if(month<10){
            month = '0' + month.toString();
        }
        dateInApiFormat = day + '-' + month + '-' + year.toString();
        return dateInApiFormat;
    }
}

A: You could simply use the Date Pipe

The time is {{currentDate | date:'yyyy-MM-dd'}}

and in TS
export class App {

 currentDate: number = Date.now();

}

DEMO

A:   // To use date service

   import { Injectable } from '@angular/core';

   @Injectable()

   export class DateService {

      public currentDate = new Date();

       getCurrentDateInApiFormat() {
          const date = currentDate;
          const month = ('0' + (date.getMonth() + 1)).slice(-2);
          const day = ('0' + date.getDate()).slice(-2);

          return [date.getFullYear(), month, day].join('-');
       }
   }

A: The different date format can be achievable through moment.js library.
You can just import/add it. and use the following syntax to convert your timestamp to date string.
moment.tz(this.value, 'GMT').format('yyyy-MM-dd HH:mm:ss');
Here tz is timezone.


text:
Q: API switch triggers StrictMode policy violation say, I'm halfway with Android 2.3.3 and then I find some APIs which I need but are only supported in Android 4.0. Thus, I switch to Android 4.0 by checking a different Project Build Target. Now here comes a StrictMode policy violation, policy=2711, violation=1 which will go away when I switch back. So I think the switch is to blame but is there a way to work around this instead of building a new project?
Updates:
Even if I start a new project  with Android 4.0 but with the same codes, still Strict policy violation

A: StrictMode policy violation, policy=2711, violation=1 seems to be a StrictModeDiskWriteViolation. A disk write violation occurs when you are performing disk writes on the main UI thread. To solve it, you need to move the disk writes off the main thread. In this case it could be that some Android functionality that has changed in 4.0 and now includes disk writes, meaning you need to change your code such that you no longer use that functionality on the main thread in 4.0.
Can you post the full stack trace? That should have details about what is happening.
This link may also be helpful:
http://www.google.com/support/forum/p/Google+Mobile/thread?tid=10b73a621438323f


text:
Q: Compile Python code to statically linked executable with Cython I have a pure Python script that I would like to distribute to systems with unkown Python configuration. Therefore, I would like to compile the Python code to a stand-alone executable.
I run cython --embed ./foo.py without problems giving foo.c. Then, I run
gcc $(python3-config --cflags) $(python3-config --ldflags) ./foo.c

where python3-config --cflags gives
-I/usr/include/python3.5m -I/usr/include/python3.5m  -Wno-unused-result -Wsign-compare -g -fdebug-prefix-map=/build/python3.5-MLq5fN/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security  -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes

and python3-config --ldflags gives
-L/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu -L/usr/lib -lpython3.5m -lpthread -ldl  -lutil -lm  -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions

This way I obtain a dynamically linked executable that runs without a problem. ldd a.out yields
 linux-vdso.so.1 (0x00007ffcd57fd000)
 libpython3.5m.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0 (0x00007fda76823000)
 libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fda76603000)
 libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fda763fb000)
 libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fda761f3000)
 libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fda75eeb000)
 libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fda75b4b000)
 libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fda7591b000)
 libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fda756fb000)
 /lib64/ld-linux-x86-64.so.2 (0x00007fda77103000)

Now, I try to add the option -static to gcc, but this results in an error:
/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in `/usr/lib/gcc/x86_64-linux-gnu/6/../../../x86_64-linux-gnu/libc.a(strcmp.o)' can not be used when making an executable; recompile with -fPIE and relink with -pie
collect2: error: ld returned 1 exit status

I checked that all shared libraries given by ldd are also installed as static libraries.
So, is this some incompatibility with the options given by python3-config?

A: The experienced problems are obviously from the linker (gcc started a linker under the hood, to see it - just start gcc with -v - in verbose mode). So let's start with a short reminder how the linkage process works:
The linker keeps the names of all symbols it needs to resolve. In the beginning it is only the symbol main. What happens, when linker inspects a library?

*

*If it is a static library, the linker looks at every object file in this library, and if this object files defines some looked for symbols, the whole object file is included (which means some symbols becomes resolved, but some further new unresolved symbols can be added). Linker might need to pass multiple times over a static library.

*If it is a shared library, it is viewed by the linker as a library consisting out of a single huge object file (after all, we have to load this library at the run time and don't have to pass multiple times over and over to prune unused symbols): If there is at least one needed symbol the whole library is "linked" (not really the linkage happens at the run-time, this is a kind of a dry-run), if not - the whole library is discarded and never looked again at.
For example if you link with:
gcc -L/path -lpython3.x <other libs> foo.o

you will get a problem, no matter whether python3.x is a shared or a static lib: when the linker sees it, it looks only for the symbol main, but this symbol is not defined in the python-lib, so it the python-lib is discarded and never looked again at. Only when the linker sees the object-file foo.o, it realizes, that the whole Python-Symbols are needed, but now it is already too late.
There is a simple rule to handle this problem: put the object files first! That means:
gcc -L/path  foo.o -lpython3.x <other libs>

Now the linker knows what it needs from the python-lib, when it first sees it.
There are other ways to achieve a similar result.
A) Let the linker to reiterate a group of archives as long as at least one new symbol definition was added per sweep:
gcc -L/path --Wl,-start-group -lpython3.x <other libs> foo.o -Wl,-end-group

Linker-options -Wl,-start-group and -Wl,-end-group says to linker iterate more than once over this group of archives, so the linker has a second chance (or more) to include symbols. This option can lead to longer linkage time.
B) Switching on the option --no-as-needed will lead to a shared library (and only shared library) being linked in, no matter whether in this library defined symbols are needed or not.
gcc -L/path -Wl,-no-as-needed -lpython3.x -Wl,-as-needed <other libs> foo.o

Actually, the default ld-behavior is --no-as-needed, but the gcc-frontend calls ld with option --as-needed, so we can restore the behavior by adding -no-as-needed prior to the python-library and then switch it off again.

Now to your problem of statical linking. I don't think it is advisable to use static versions of all standard libraries (all above glibc), what you should probably do is to link only the python-library statically.
The rules of the linkage are simple: per default the linker tries to open a shared version of the library first and than the static version. I.e. for the library libmylib and paths A and B, i.e.
 -L/A -L/B lmylib

it tries to open libraries in the following order:
A/libmylib.so
A/libmylib.a
B/libmylib.so
B/libmylib.a

Thus if the folder A has only a static version, so this static version is used (no matter whether there is a shared version in folder B).
Because it is quite opaque which library is really used - it depends on the setup of your system, usually one would switch on the logging of the linker via -Wl,-verbose to trouble-shoot.
By using the option -Bstatic one can enforce the usage of the static version of a library:
gcc  foo.o -L/path -Wl,-Bstatic -lpython3.x -Wl,-Bdynamic <other libs>  -Wl,-verbose -o foo

Notable thing:

*

*foo.o is linked before the libraries.

*switch the static-mode off, directly after the python-library, so other libraries are linked dynamically.

And now:
 gcc <cflags> L/paths foo.c -Wl,-Bstatic -lpython3.X -Wl,-Bdynamic <other libs> -o foo -Wl,-verbose
...
attempt to open path/libpython3.6m.a succeeded
...
ldd foo shows no dependency on python-lib
./foo
It works!

And yes, if you link against static glibc (I don't recommend), you will need to delete -Xlinker -export-dynamic from the command line.
The executable compiled without -Xlinker -export-dynamic will not be able to load some of c-extension which depend on this property of the executable to which they are loaded with ldopen.

Possible issues due to implicit -pie option.
Recent versions of gcc build  with pie-option per default. Often/sometimes, older python versions where build with an older gcc-version, thus python-config --cflags would miss the now necessary  -no-pie, as it was not needed back then. In this case the linker will produce an error message like:

relocation R_X86_64_32S against symbol `XXXXX' can not be used when
making a PIE object; recompile with -fPIC

In this case, -no-pie option should be added to  <cflags>.


text:
Q: Only outputs the sequence of array entries from the lowest score up to the largest score range so i am new to coding, and i am having trouble to print out from the lowest to the highest number with their frequency. example if the user inputs                                                     35 5
50 2
41 6
42 3
48 4
42 2                                                                                it should print out                                                                                35: 5
36: 0
37: 0
38: 0
39: 0
40: 0
41: 6
42: 5
43: 0
44: 0
45: 0
46: 0
47: 0
48: 4
49: 0
50: 2                                                                                please guys help!!

A: It will be simpler to do the assignment if to define an array of std::pair. For example
std::pair<unsigned, unsigned> a = {  { 35, 5 }, { 50, 2 }, { 41, 6 },  { 42, 3 }, { 48, 4 }, { 42, 2 } };

and then you can use standard algorithm std::minmax_element
For example
auto p = std::minmax( std::begin( a ), std::end( a ),
                      []( const std::pair<unsigned, unsigned> &lhs, const std::pair<unsigned, unsigned> & rhs )
                      {
                         return ( lhs.first < rhs.first );
                      } );

And then you can use a loop for example as
for ( unsigned i = p.first->first; i <= p.second->first; i++ )
{
    // using std::accumulate or the range based for statement to calcukate the sum of frequencies
}

But as I guess you do not know neither std::pair nor standard algorithms. So you should show what you did yourself so far.:)


text:
Q: When assembly is inside 'C:\Windows\System32' i get 'Unable to find a version of the runtime to run this application' I'm currently writing a screensaver using C# and the express version of VS2010. I've created a nice little screensaver and renamed the resulting assembly to have a *.scr extension.
When i place this on my desktop and double click it (or select configure from the context menu), it runs fine and displays the correct form/screensaver. However, when i install this by placing it into the C:\Windows\System32 folder, i try double clicking on it and get this error:
Unable to find a version of the runtime to run this application
Also it doesn't work from the screensaver control panel. It's listed in the drop-down but it doesn't function.
Any idea what is going on?

A: The problem is that the screensaver was compiled for 32bit cpu. Only 64bit exes are allowed in the %WINDIR%\System32 folder on a 64bit OS. Which in fact, i was using Windows7 64bit.
The correct place to put 32bit screensavers is in %WINDIR%\SysWOW64 or compile using 'AnyCPU' option in Visual Studio then you can install into the %WINDIR%\System32 for all.


text:
Q: Spring MVC - ExceptionHandler I am using Spring Boot 1.5.7.
I have an ExceptionHandler for my exception that returns a ResponseEntity
@ExceptionHandler(MyException.class)
public ResponseEntity<ResponseExceptionEntity> handleException(MyException e) {
    return ResponseEntity
        .status(HttpStatus.BAD_REQUEST)
        .body(new ResponseExceptionEntity(e));
}

This works well in situations where the exception occurs during an api call returning a ResponseEntity / @ResponseBody (JSON/XML response)
I would like to return a ModelAndView in situations where the exception occurs during a request where HTML is returned. In my situation all Controllers are annotated with @Controller and not @RestController

*

*how can I write a ExceptionHandler for both cases (api/html)?

*Or How can I determine what the resolved view is for a controller method?

*Or how can I determine what the return type of the Controller Method
is?

*Or How can I determine what the resolved view is for the controller
method?

I've tried the suggestion in this answer, but it doesn't return a JSON response when the Controller Method is annotated with @ResponseBody.
https://stackoverflow.com/a/32071252/461055

A: Yes, you can write two exception handler to handle api and html request exception. Here is sample code to illustrate the solution.
@ControllerAdvice(annotations = RestController.class)
@Order(1)
class RestExceptionHandler {
    @ExceptionHandler(MyException.class)
    @ResponseBody
    ResponseEntity<ErrorResponse> exceptionHandler() {
        ....
    }
}

@ControllerAdvice(annotations = Controller.class)
@Order(2)
class ExceptionHandler {
    @ExceptionHandler(Exception.class)
    public ModelAndView handleError500(HttpServletRequest request, HttpServletResponse response, Exception ex) {
        ModelAndView mav = new ModelAndView("error");
        mav.addObject("error", "500");
        return mav;
    }
}


text:
Q: How to connect to SQL Server 2000 from .net 4 Here's my connection string...
Data Source=MYMACHINE\SERVER2000; Initial Catalog=MyDatabase; User Id=sa; Password=p;

Here's the error....

A network-related or instance-specific error occurred while
  establishing a connection to SQL Server. The server was not found or
  was not accessible. Verify that the instance name is correct and that
  SQL Server is configured to allow remote connections. (provider: SQL
  Network Interfaces, error: 26 - Error Locating Server/Instance
  Specified)

I can connect fine with Enterprise Manager. Also I have upgraded the SQL Server to Serivce Pack 4.
Any ideas what the issue might be?

A: I'd suggest testing your connection string using a .UDL file. I've answered a similar question here. After creating your connection, you can rename the extension of the file to .txt, open it and then copy and paste the working connection string in.

A: string connectionString=@"Data Source=MYMACHINE\SERVER2000; Initial Catalog=MyDatabase; User Id=sa; Password=p;";
SqlConnection connection=new SqlConnection(connectionString);
SqlCommand command = new SqlCommand("Select * From Table",connection);
SqlDataReader reader= command.ExecuteReader();

GridView1.DataSource=reader;
GridView1.DataBind();

Use this.... this may help you?


text:
Q: Reverse the rotation of UIImageView using CAKeyframeAnimation I'm using the following code to rotate an image infinitely, the rotation is clockwise but I also need it to reverse rotation to counter clockwise every 1-2 rotations and then back to clockwise, how to get this to work?
    /// Image Rotation - CAKeyframeAnimation
func rotate(imageView: UIImageView, rotationSpeed: Double) {

    let animation = CAKeyframeAnimation(keyPath: "transform.rotation.z")

    animation.duration = rotationSpeed
    animation.fillMode = CAMediaTimingFillMode.forwards
    animation.repeatCount = .infinity
    animation.values = [0, Double.pi/2, Double.pi, Double.pi*3/2, Double.pi*2]

    /// Percentage of each key frame
    let moments = [NSNumber(value: 0.0), NSNumber(value: 0.1),
                   NSNumber(value: 0.3), NSNumber(value: 0.8), NSNumber(value: 1.0)]
    animation.keyTimes = moments

    imageView.layer.add(animation, forKey: "rotate")
}

A: Set animation.autoreverses = true, will reverse an animation.

A: for counter clockwise rotation, you can do this:
self.imageView?.transform = CGAffineTransform(rotationAngle: -2*CGFloat.pi)


text:
Q: Antibot with PHP and JQuery Ajax I am building a simple antibot for my email form.
This is a code which makes a problem:
<?php
    session_start();
    $a = rand(1, 10);
    $b = rand(1, 10);
    $antibot = $a + $b;
    $_SESSION["antibot"] = $antibot;
?>

AntiBot: <?php echo $a . ' + ' . $b;?> = 	<input type='text' id='antibot' />

<input type='button' id='sendEmail' value='Send'/>

And my test.php
<?php
    session_start();
    $antibot = $_POST["antibot"];
    $data = array();
    if(isset($_SESSION["antibot"])){
        if($_SESSION["antibot"] == $antibot){
            $data["info"] = "Session is isset and answer is right!";
        }
        else{
            $data["info"] = "Session is isset but answer is NOT right!";
        }
    }
    else{
        $data["info"] = "Session is NOT isset!";
    }
    echo json_encode($data);
?>

I constantly get this info: "Session is isset but answer is NOT right!"
If you can see $_SESSION["antibot"] in test.php is setted but value is "" no matter what I type in input field #antibot!
I do not understand why this is happening, please can someone tell me where the problem is and how can I fix it?

A: I tested this code here:
http://onlinephpfunctions.com/stackoverflow/11981309/
And it seems completely valid.
I had to make some modifications to your javascript:

After that it was working fine. It may just be some problems with cookies in your browser, or an error in your PHP config so sessions wont be stored right. Please check this, your code works OK, as you can see in the demo.


text:
Q: Opera ignoring .live() event handler I have the following jQuery which works in all major browsers except Opera:
jQuery(document).ready(function () {

      jQuery("#GetResults").live("click", function(e){
            e.preventDefault(); //Opera doesn't execute anything here
      });

};

Which is supposed to fire when clicking the following link:
Get Results

Only Opera ignores this.  Any ideas?
Edit:
I've just discovered that if I substitute out .live() for .bind() everything functions as expected.  I can't find any documentation relating to .live() bugs in Opera though, and it does work in jsFiddle which would point at something environmental.  What could be causing this behavour?

A: This needs clarification. The answers above are correct, but nobody clearly explained where your problem comes from.
In fact I think that you could probably reproduce the problem in other browsers too.
That's because of how .live works:
It binds to the event on document and waits for a particular event to bubble up to there. Then it checks if the event.target is what you wanted to handle. *
If you click on a link element it's quite possible that the browser goes to the new page before the event bubbles high enough to trigger your code. In an app with lots of HTML and event handlers all the browsers should have problems. Opera just starts displaying the new page and destroys the previous quicker in this case. It really depends on a particular situation more than on the browser. For example: you probably won't see this happen if you had a high network latency while connecting to the site.
To prevent default action on a a element you have to use .bind like in the old days ;) when a eveloper had to be aware of what he loads with AJAX and bind new events to that in a callback.
* There is more to that and .live is more complicated. I just described what is needed here.

A: What happens when you attach the handler using:
$ (something).bind ("click", function (e) {
    // do something
})

You can also try to attach the handler using .click() method.

A: The following code works as expected in Opera 11.50.
<!doctype html>
<title></title>
Get Results

Either it is a corrected bug, or something more subtle.
Can you check whether the above works on your version of Opera / jQuery?

A: Read this article: http://jupiterjs.com/news/why-you-should-never-use-jquery-live
try use delegate instead

A: Not sure if you want to do it, or if it will work for you. I had similar issues with Opera 9.5 and e.preventDefault() not working, the only solution I found was to just return false...
jQuery(document).ready(function () {

      jQuery("#GetResults").live("click", function(e){
            e.preventDefault();
            return false;
      });

};

A: There are two aspects of an event bubbling worth considering in this case: propagation and the default action.
Propagation refers to the event bubbling.  First the anchor tag gets the click event, then its parent element, then its parent's parent, and so forth, up to the document element.  You can stop an event from propagating at any time by calling e.stopPropagation().
The default action is what the browser will do if nothing is done to prevent it.  The most well-known case is when an anchor with an href is clicked, the browser will try to navigate there.  There are other examples too, though, for example when you click and drag an image, many browsers will create a ghost image you can drop on another application.  In both cases, you can stop the browser from doing the default action at any time by calling e.preventDefault()
As mentioned in other answers to this question, jQuery's .live() feature sets a handler at a high level element (like document) and takes action after events have propagated up.  If a handler in between the anchor and the document calls e.stopPropagaiton() without calling e.preventDefault() it would stop the live handler from responding, while still allowing the browser to navigate (the default action).
I doubt this is what's happening, since it would affect all browsers, but it's one possible explanation.

A: Ensure that document.ready event happens before you click on link.
Try to put all lives in the top of the document.ready wrapper. It may help, if you have a lot of javascript code.


text:
Q: I finished AWS web service and test to enter domain web site and this error message popped up in chrome developer tool this is the architecture used in AWS
how I configured AWS VPC
VPC's private ip range : 172.31.0.0/16
1 public subnet
3 private subnets
how I configured AWS route table
private subnet route table configuration
->172.31.0.0/16 local
->0.0.0.0/0 NAT gateway
-included subnets
→ frontend private subnet / backend private subnet / RDS private subnet
total 3 private subnets included in private route table
public subnet route table
→ 172.31.0.0/16 local
→ 0.0.0.0/0 internet gateway
→ public subnet that contains Application Load Balancer / bastion host ec2 / NAT gateway
total 1 public subnet included in public route table
How I configured Application Load Balancer
internet facing
connected instance : frontend ec2 instance in private subnet
then all the configuration done
I entered domain web site to test it
then I confronted with this error

[Vuetify] [UPGRADE] 'v-content' is deprecated, use 'v-main' instead.
console.ts:34
***found in ***
—> VMain
*** VApp***
*** App***
*** Root***
POST
'http://ec2-xxx-xxx-xxx-xxx.us-west-1.compute.amazonaws.com:8000/Product/item_list'
xhr.js:177
!net::ERR_CONNECTION_REFUSED!
!Uncaught (in promise) Error:Network Error createError.js:16
*** at t.exports (createError.js:16)***
*** at XMLHttpRequest.d.onerror (xhr.js:84) !***
POST
'http://ec2-xxx-xxx-xxx-xxx.us-west-1.compute.amazonaws.com:8000/Bag/bag_count'
xhr.js:177
net::ERR_CONNECTION_REFUSED
Uncaught (in promise) Error: Network Error createError.js:16
*** at t.exports (createError.js:16)***
*** at XMLHttpRequest.d.onerror (xhr.js:84)***

my question is
Q. what is the problem ?
Q. did I configure something wrong?
Q. how can I fix it based on this architecture ?
please advise for me
thank you !


text:
Q: How can I auto-size a div for certain elements, but let others overlap it? I have a website with a modal dialog box containing an input form. The text box at the bottom of the form is set up to use an autocomplete list to suggest options as you type into it. This is provided by a typeahead javascript module.
By default, the typeahead list falls underneath the modal footer:

So I edited the css for the containing dev to set the 'overflow' to 'visible'. This allowed the typeahead to overlap the footer, but the div shrunk, because it no longer had to contain all of the content:

The only way I could think to fix this was to make the height of the div constant, but now I have the problem that the error boxes can push the content into the footer:

My question is: Is there a way that I can set up the div so that it automatically resizes to fit its usual content (the input boxes and the validation boxes), but allows the suggestion list to overlap the footer?
I have attached the HTML here:

    @Html.Partial("OfferDisplay",Model.OfferDisplayModel)

    <form id="rejectionForm" class="form-horizontal" method="POST" data-ajax-pubsubupdate="RenderPresentOfferOptionsForm">
        <input type="hidden" value="@Model.NegotiationSessionId" name="NegotiationSessionId"/>

            @Html.LabelFor(m => m.RejectionReasonId, new { @class = "control-label" })

                @Html.DropDownListFor(m => m.RejectionReasonId, Model.RejectionReasons, new { @class = "input-large" })
                <button type="button" class="btn pull-right btn-validation" tabindex="-1" disabled="disabled"></button>

@Html.ValidationMessageFor(m => m.RejectionReasonId)

            @Html.LabelFor(m => m.TargetPrice, new { @class = "control-label" })

                    @Html.TextBoxFor(m => m.TargetPrice, new { @class = "input-medium", style = "width:162px", @data_val_keypressfilter_regex = UIValidationRegularExpressions.NumberKeyPressFilterRegex })

                <button type="button" class="btn pull-right btn-validation" tabindex="-1" disabled="disabled"></button>

            @Html.LabelFor(m => m.CompetitorNameId, new { @class = "control-label" })

                    <input id="competitorName" type="text" data-provide="typeahead" class="input-large" style="width: 198px"/>

                <button type="button" class="btn pull-right btn-validation" tabindex="-1" disabled="disabled"></button>

        <input id="RejectionFormSubmitButton" type="submit" style="display: none"/>
        <input id="competitorIdField" name="CompetitorNameId" type="hidden"/>
        <input id="showNextOfferInput" type="hidden" value="true" name="ShowNextOffer"/>
    </form>

<form method="POST" data-ajax-pubsubupdate="RenderOverrideConfirmationForm">
    <input type="hidden" value="@Model.NegotiationSessionId" name="NegotiationSessionId" />
    <input type="hidden" value="@Model.SchemeId" name="SchemeId" />
    <button class="btn btn-warning pull-left" type="submit"> @Html.DisplayNameFor(m => m.OverrideButton)</button>

    <input id="cancelButton" class="btn" type="button" value="@Html.DisplayNameFor(m => m.CancelButton)"/>

    @if (Model.OfferDisplayModel.Offer.IsFinalOffer)
    {
        <input id="submitAndCloseButton" class="btn btn-primary" type="button" value="@Html.DisplayNameFor(m => m.SubmitAndCloseButton)"/>
    }
    else
    {
        <input id="rejectAndShowNextOffer" class="btn btn-primary" type="button" value="@Html.DisplayNameFor(m => m.SubmitButton)"/>
    }
</form>

A: You should try to use the "z-index" css property.


text:
Q: how to predict unique list in lists? This is list of tile placements. Each integer stands for an id of a tile. Each time an integer is added to a new list it means that a new tile is placed. When a tile is removed, the last integer is removed from a new list. I want that every time a tile is placed the list to be unique. A list dont have to be unique, when a tile is removed. The code is placing these tiles in a for loop. So for this example, the last list of the lists is wrong, because it wasn't unique when a tile was placed. Is there a way to exclude numbers which will make the new list not unique. So for this example is there a way to exclude the id 18, before it adds to the list.
I know this is a very vague question, but I am new to python and can't make the code of this assignment easier. I hope someone could help me with this vague question
    [[1, 2, 3, 13, 4, 5, 6, 7, 17],
    [1, 2, 3, 13, 4, 5, 6, 7, 17, 8],
    [1, 2, 3, 13, 4, 5, 6, 7, 17, 8, 15],
    [1, 2, 3, 13, 4, 5, 6, 7, 17, 8, 15, 9],
    [1, 2, 3, 13, 4, 5, 6, 7, 17, 8, 15, 9, 10],
    [1, 2, 3, 13, 4, 5, 6, 7, 17, 8, 15, 9, 10, 18],
    [1, 2, 3, 13, 4, 5, 6, 7, 17, 8, 15, 9, 11],
    [1, 2, 3, 13, 4, 5, 6, 7, 17, 8, 15, 9, 11, 18],
    [1, 2, 3, 13, 4, 5, 6, 7, 17, 8, 15, 9, 10],
    [1, 2, 3, 13, 4, 5, 6, 7, 17, 8, 15, 9, 10, 18]]

The lists must be in this order. So for example i have had these lists:
[[1, 2, 3, 13, 4, 5, 6, 7, 17],
[1, 2, 3, 13, 4, 5, 6, 7],
[1, 2, 3, 13, 4, 5, 6, 7, 8],
[1, 2, 3, 13, 4, 5, 6, 7],
[1, 2, 3, 13, 4, 5, 6, 7, 19],
[1, 2, 3, 13, 4, 5, 6, 7]]

I want to exlude the ids 17,8,19
So for [1, 2, 3, 13, 4, 5, 6, 7] the output must look like this ( id ont care if the output is a list or integers)
[17,8,19]

But when i have this list [1, 2, 3, 13, 4, 5, 6] in lists
[[1, 2, 3, 13, 4, 5, 6, 7, 17],
[1, 2, 3, 13, 4, 5, 6],
[1, 2, 3, 13, 4, 5, 6, 7, 8],
[1, 2, 3, 13, 4, 5, 6, 7],
[1, 2, 3, 13, 4, 5, 6, 7, 19],
[1, 2, 3, 13, 4, 5, 6, 7]]

The output is this:
[7]

I hope this will make it more clear.

A: I tried with itertools and collections- pass a list, a list element index and to be added value to the adder function if uniquness is kept the adder will add that passed value otherwise return intact list.compare_func return TRUE if list is unique using all.
import collections,itertools
compare_func = lambda x, y: collections.Counter(x) != collections.Counter(y)
lst = [[1, 2, 3],[1, 2, 3,4]]

def adder(mylist,indx,val):
    mylist[indx].append(val)
    if  all([compare_func(*i) for i in list(itertools.combinations(lst,2))]):
        print "Added item"
    else:
        print "Did not add item"
        mylist[indx].pop()
    return mylist

Now run print adder(lst,0,4)
Output-
Did not add item
[[1, 2, 3], [1, 2, 3, 4]]

But if run
print adder(lst,1,4)
Output-
Added item
[[1, 2, 3], [1, 2, 3, 4, 4]]

EDIT
After OP cleared question i added this portion-
Try using set as below-
import collections,itertools

data = [[1, 2, 3, 13, 4, 5, 6, 7, 17],
        [1, 2, 3, 13, 4, 5, 6, 7],
        [1, 2, 3, 13, 4, 5, 6, 7, 8],
        [1, 2, 3, 13, 4, 5, 6, 7],
        [1, 2, 3, 13, 4, 5, 6, 7, 19],
        [1, 2, 3, 13, 4, 5, 6, 7]]

interscntion = set.intersection(*map(set,data))

d = collections.Counter([i for j in data for i in j if i not in list(interscntion)])
if len(set(it[1] for it in d.most_common()))>1:
    print [max(d.most_common(),key=lambda x:x[1])[0]]
else:
    print [j[0] for j in d.most_common()]

Output-
[8, 17, 19]

A: Here you go:
def tiles(arrOfArrs):
    final = []
    for x in arrOfArrs:
        final += x
    return list(set(final))

A: Keep another list of lists and at each position add the tiles that appear at that index in any of the primary lists.


text:
Q: Are braided commutators primitive elements of a braided Hopf algebra? Let $H$ be a braided Hopf algebra. The multiplication on $H \otimes H$ is defined by $(a \otimes b)(c \otimes d) = a \Psi(b \otimes c) d$, $a,b,c,d \in H$.
Let $H = T(V)$. There is a algebra map $\Delta: T(V) \to T(V) \otimes T(V)$ such that $\Delta(v) = 1 \otimes v + v \otimes 1$. Therefore
\begin{align}
\Delta(xy) = 1 \otimes xy + xy \otimes 1 + x \otimes y + x_{(-1)}.y \otimes x_{(0)}.
\end{align}
Consider the braided commutator in $T(V)$. We have
\begin{align}
x \otimes y - \Psi(x \otimes y) = x \otimes y - x_{(-1)}.y \otimes x_{(0)}.
\end{align}
I want to check that $x \otimes y - \Psi(x \otimes y)$ is a primitive element or not.
We have
\begin{align}
& \Delta( x \otimes y - \Psi(x \otimes y) ) \\
& = 1 \otimes xy + xy \otimes 1 + x \otimes y + x_{(-1)}.y \otimes x_{(0)} - 1 \otimes (x_{(-1)}.y) x_{(0)} \\
& \quad - (x_{(-1)}.y) x_{(0)} \otimes 1 - x_{(-1)}.y \otimes x_{(0)} - ( x_{(-1)}.y )_{(-1)}.x_{(0)} \otimes ( x_{(-1)}.y )_{(0)} \\
& = 1 \otimes xy + xy \otimes 1 + x \otimes y  - 1 \otimes (x_{(-1)}.y) x_{(0)} \\
& \quad - (x_{(-1)}.y) x_{(0)} \otimes 1  - ( x_{(-1)}.y )_{(-1)}.x_{(0)} \otimes ( x_{(-1)}.y )_{(0)}
\end{align}
It seems that $x \otimes y \neq ( x_{(-1)}.y )_{(-1)}.x_{(0)} \otimes ( x_{(-1)}.y )_{(0)}$. Therefore $x \otimes y - \Psi(x \otimes y) $ is not a primitive element of $T(V)$? Thank you very much.

A: Sidenote: In the situation you describe, $V$ has to be a Yetter--Drinfeld module over $H$, i.e. $$h_{(1)}x_{(-1)}\otimes h_{(2)}.x_{(0)}=(h_{(1)}.x)_{(-1)}h_{(2)}\otimes (h_{(1)}.x)_{(0)}$$
has to be satisfied for all $x\in V$.
It is in general not true that braided commutators are primitive elements in a braided Hopf algebra. To examine the expression you derive more closely, we can see that for degree reasons ($x,y$ are degree one elements), the braided commutators are primitive elements in the braided Hopf algebra if and only if
$$x\otimes y=( x_{(-1)}.y )_{(-1)}.x_{(0)} \otimes ( x_{(-1)}.y )_{(0)}.$$
This condition means precisely that $\Psi^2(x\otimes y)=x\otimes y$, which is not true for all elements in a general braided Hopf algebra.
For example, for a diagonal braiding $\Psi(x_i\otimes x_j)=q_{ij}x_{j}\otimes x_i$, this means that $q_{ij}q_{ji}=1$ which is generally not assumed. If there exists a division $I=I_1 \cup I_2$ or the index set $I$ for a diagonal basis of $V$ such that $q_{ij}q_{ji}=1$ for all $i\in I_1$ and $j\in I_2$, then $T(V)$ can be written as a braided tensor product $T(V_1)\underline{\otimes} T(V_2)$ for $V_1$ being the YD-module generated by $x_i$ for $i\in I_1$, and $V_2$ generated by the $x_j$ for $j\in I_2$. (see [AS, 4.2])
So having braided commutators as primitive elements is a special situation.
[AS]: Andruskiewitsch, N. and Schneider, HJ.: Finite quantum groups and Cartan matrices, Adv. in Math. 154 (2000), 1–45.


text:
Q: Spring rule-ref to bean naviagation in eclipse Actually we are using the Spring for the dependency injection for the decorator design pattern.So the beans will be spread across the different XML files. i Need Some tool or plugin in the Eclipse that navigate rule-ref  to the Actual bean location. So analyzing will be easy.

A: Since you are developing a spring based application I would suggest you to use Spring Tools Suite. I have been using it and makes it easier to navigate across the XML files. Just cntrl+click on the ref does the magic.
Make sure the the bean configuration files when viewed in eclipse have this icon.


text:
Q: Referring question of the phrase " in this respect" in the following sentence
For the activity of being aware is one of those, like chess in this
respect, where understanding their point is itself part of their
point.

It's seem like the phrase "in this respect" always refers to something that mentioned before, but I am here to ask that if there any possible for the phrase "in this respect" refers to something mentioned after the phrase, which in my example is "where understanding their point is itself part of their point".
And I have two more question about this sentence. It's obvious that the relative pronoun "where" isn't refers to any exact places, I am wondering that if it is a grammatically error. If it isn't, then how should I understand the use of the word "where" in this sentence?
This is the paragraph where the sentence came from(in case anyone need some context):

Thus we can't just say: whoever is aware must know the basic conditions of failure, in the
sense of having already accepted some formulation of them. But we can say that we must be able
to recognize these as conditions of failure. For the activity of being aware is one of those, like
chess in this respect, where understanding their point is itself part of their point. That is, if I
couldn't recognize that, when all broke down into confusion, awareness had failed, then you
couldn't think of me as aware in the first place. We aren't aware at all unless we can recognize this
difference.

A: I think you are trying to over think this.  "In this respect" is referring to the entire sentence which is talking about  "the activity ... where [something happens]".  The author mentions chess as a comparison/analogy. If you remove the part about chess within the commas, the sentence still makes sense.
One could reword this by simply using "like in chess".  The use of "in this respect" could be said to be superfluous here, since it is obvious from the context.
As to the second part of your question, the pronoun "where" doesn't always refer to a literal physical place, it can also be synonymous with "in which", depending on context.  If you check any good dictionary, you will see the word has multiple definitions. In the OED, the word "where" has at least 28 definitions!


text:
Q: Fibonacci in NASM (using the SASM platform) I'm trying to design an algorithm in NASM which is supposed to compute the nth Fibonacci number. I wrote some code, but, when run, it outputs only 1 and I cannot understand why. My idea was to call Fibonacci for n-1 and for n-2, where the parameter n is stored within AX register, and the result is stored at BX.
%include "io.inc"

section .text
global CMAIN
CMAIN:
    mov ebp, esp; for correct debugging
    xor eax, eax
    xor ebx, ebx
    push word 12
    call fibonacci
    pop word [trash]
    PRINT_UDEC 1, ax
    ret

fibonacci: push ebp
           mov ebp, esp

           mov ax, [ebp + 8];se incarca ax cu parametrul primit prin stiva
           cmp ax, 0
           jne l1
           mov bx, 0
           jmp l3
l1:        cmp ax, 1
           jne l2
           mov bx, 1
           jmp l3
l2:        sub ax, 2;n-2
           push ax
           call fibonacci
           pop dx;resotre the stack
           mov [ebp - 2], bx

           mov ax, [ebp + 8];se incarca bx cu parametrul prinit prin stiva
           sub ax, 1;n-1
           push ax
           call fibonacci
           pop dx;restore the stack
           add bx, [ebp - 2]

l3:        mov esp, ebp
           pop ebp
           ret

section .data
    trash dw 1


text:
Q: Finding a function that solves the condition I have a requirement for a function which can be modeled as following
Function $ y = f(x) $ which satisfies the following conditions.
There are 3 real numbers a,b,c on number line ST a < b < c and
f(x) is a continuous, differentiable curve, in the range x $ \epsilon $(a,c)
$$ (b-a)/(c-b)= 2/3 $$
$$ f(x) > 0, x  \epsilon (a,c) $$
$$ \int_{a}^{b} f(x)  dx  = 7/3 \int_{b}^{c} f(x)  dx$$
I need to find the function f, and values a,b,c.
I tried several knows functions like $ x^{2} $, $ e^{x} $ but none of them seem to satisfy this. Can you help me find this?
PS: Just to be clear, I don't care about the values of f outside (a,c)

A: The constant function $f(x)=\frac{7}{2}$ will do the job.


text:
Q: How to write a class using a scanner to average digits of a number in Java This is the shell I have:
import java.util.*;

//this example demonstrates how to to use a
//while loop to average all of the digits of a number

public class AveragingDigits
{
 public static int countDigits( int num )
 {
  return 0;
 }

 public static double sumDigits( int num )
 {
  return 0.0;
 }

 public static double averageDigits( int num )
 {
  return 0.0;
 }

   public static void main(String args[])
   {
  Scanner kb = new Scanner( System.in );
  System.out.print( "Enter a number :: " );
  int num = kb.nextInt();
  System.out.println("The digit average is " + averageDigits( num) );
 }
}

How would I use this shell to print the average of the digits of a number that I input using the scanner?

A: you will need to do your method like this
public static int countDigits( int num )
{
    return (String.valueOf(num)).length();
}

public static double sumDigits( int num )
{
    double sum=0.0;
    while (num > 0) {
        sum += num % 10;
        num = num / 10;
    }
    return sum;
}

public static double averageDigits( int num )
{
    return sumDigits(num) / countDigits(num);
}

A: I tried to do it with your set up but it can be simpler with just one Calculate Average method.
    public class AveragingDigits
{
 int count=0;
 int sum=0;
 double temp=0;
double average=0;
double total=0;

 public static int countDigits( int num )
 {

 if (num==num)
{
 count++;

 }
 return count;
 }

public static double sumDigits( double num )
{

   temp=num;
total=total+temp;
return total;
 }

 public static double averageDigits( double num )
 {
 total=sumDigits( num );
 count=countDigits(  num );
 return total/count;
 }

 public static void main(String args[])
 {
 Scanner kb = new Scanner( System.in );
System.out.print( "Enter a number :: " );
 int num = kb.nextInt();
 System.out.println("The digit average is " + averageDigits( num) );
  }

}

A: public class Test {

    static String s = "";

    public static void main(String[] args) {
        Scanner kb = new Scanner(System.in);
        System.out.print("Enter a number :: ");
        int num = kb.nextInt();
        System.out.println("The digit average is " + averageDigits(num, 0, 0));
    }

    static double averageDigits(int number, int sum, int count) {
        if (number == 0) {
            if (count == 0) {
                return 0;
            }
            return ((double) sum) / ((double) count);
        } else {
            return averageDigits(number / 10, sum + number % 10, ++count);
        }
    }

Output
Enter a number :: 12345
The digit average is 3.0