text:
Q: assign a javascript variable from c# I have some javascrtipt eg:
<script type="text/javascript">
flashvars.myval  = "blah"; //get this from c# ..etc
</script>

i need to assign the variable from c#
how can i do that?
can i call a c# method?
im using regular asp.net.
the javascript is on the aspx page.

A: You need to provide more info. Assuming that's on a page, some options are:

*

*trigger a postback and have the server send a script with the response to execute after everything is loaded (using RegisterStartupScript)

*do an ajax request to get the data from the server, and set the variable or do anything on the callback

*if its always sent from the server on web forms do something like (or call a property on the page):
var somevar = '<%=SomePageMethodThatReturnsTheValue()%>';

*if its always sent from the server on asp.net mvc do something like (or ViewData["SomeValue"] if its an untyped view):
var somevar = '<%=Model.MyProperty%>';

After the edit: what u want its option 3. Something like:
<script type="text/javascript">
flashvars.myval  = '<%= SomeMethodInThePageThatReturnsTheValue() %>'; //get this from c# ..etc
</script>

the code can also be a property that you set on load: <%= SomeProperty %>.

A: You might want to have a look at something like Script#.

A: Is this script a separate file or is it on the aspx page?
If so something like this could work:
.get({ 'userID': '<%=UserID%>', rest of JSON});

UserID is a C# property.

A: It depends what technology you are using.
If you are using ASP MVC, pass the data into the view (whatever way suits you) and then use the <%= syntax
i.e
flashvars.myval = <%=ViewData["MyVal"]%>

A: The answer I'm going to give is going to make a lot of assumptions, but given the lack of detail in your post, they seem fair. First of all, I assume you are running this code in a web page, and secondly I'm going to assume that you have access to code running in a web server. If both assumptions are correct, you could use AJAX to call code on the server, and populate this value with the output.
If you are using jQuery, you might want to look here for more information on the javascript code, and here for details on the C# side.


text:
Q: Upgraded to newer Firefox, addon was disabled, want to re-enable it After upgrading to the newer Firefox, a useful addon was disabled (marked incompatible).
In my case I went up to Firefox 11.0, but now my beloved Tab Utilities Lite 1.1.3 is obsolete.
Can I do anything to make it work again in this version of Firefox which has marked it incompatible and disabled it for me? Or should I hope that the addon is upgraded to the next version?

A: There's a way to enable incomparable addons in about:config. It might not work, but it's worth a shot: http://www.mydigitallife.info/how-to-install-or-force-enable-incompatible-add-ons-in-firefox-4-beta/

A: From a comment on the link you posted:

I'm sorry. It will be available by this weekend. You may use 1.2pre18 for now. https://addons.mozilla.org/firefox/addon/tab-utilities/versions/1.2pre18

So, there is an experimental version that works with Firefox 11.0, and an updated version is to follow.

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to use XML and XSL in a single document I have been battling to get my XML / XSL transformation to work. I have got two seperate files which work, so the XSL is not the problem I now want to combine these into a single file. The reason for this is that I have an app that will output the single file and make it available online or offline. When a user opens the file, they will see the formatted file that will make sense to them.
What do I have to change in the stylesheet below to get this? Note that the XSLT creates and indented bulleted list.
Many thanks in advance
Mike
<?xml-stylesheet type="text/xml" href="#style1"?>
<!DOCTYPE document SYSTEM "document.dtd">
<document>

    <xsl:stylesheet id="style1"
                    version="1.0"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:fo="http://www.w3.org/1999/XSL/Format">

      <xsl:output method="html" indent="yes"/>
      <xsl:strip-space elements="*"/>

      <xsl:template match="element">

          <xsl:value-of select="@text"/>
          <xsl:if test="element">

              <xsl:apply-templates select="element"/>

          </xsl:if>

      </xsl:template>

    </xsl:stylesheet>

    <element text="Wedding Plan" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#804040">
      <element text="Honeymoon" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000">
        <element text="Luggage bags" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000">
          <element text="Borrow or Buy?" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000" />
        </element>
      </element>
      <element text="Speech" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000">
        <element text="Points on tablet" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000" />
        <element text="Thanks" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000">
          <element text="Flowers" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000">
            <element text="Candice" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000" />
          </element>
          <element text="Venue" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000">
            <element text="Paddy Ann" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000">
              <element text="Table settings" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000" />
            </element>
          </element>
        </element>
        <element text="Introduction" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000">
          <element text="Short skirt - short enough to cover the basics" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000" />
        </element>
        <element text="Humour" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000">
          <element text="medical cabinet turned me into a toad, had to wait for kiss from princess" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000" />
          <element text="Sweetie pie does not refer to veronika!" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000" />
        </element>
      </element>
      <element text="Requirements" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000">
        <element text="Dad" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000">
          <element text="ID Book" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#000000" />
        </element>
      </element>
    </element>
</document>

A: Move the XSLT out of the  and add a proper DOCTYPE definition.
<?xml-stylesheet type="text/xml" href="#style1"?>
<!DOCTYPE document [ <!ATTLIST xsl:stylesheet id ID #REQUIRED> ]>
<document>
  <xsl:stylesheet id="style1"
                    version="1.0"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                    xmlns:fo="http://www.w3.org/1999/XSL/Format">

      <xsl:output method="html" indent="yes"/>
      <xsl:strip-space elements="*"/>

      <xsl:template match="element">

          <xsl:value-of select="@text"/>
          <xsl:if test="element">

              <xsl:apply-templates select="element"/>

          </xsl:if>

      </xsl:template>

    </xsl:stylesheet>

    <element text="Wedding Plan" checked="false" bold="false" bcolour="#FFFFFF" fcolour="#804040">
    ...
    </element>
</document>

This is the list that you should get:


text:
Q: How to make search results include subdocument using .find() in Node js with MongoDB Good Day,
For context, I am using node js, express and MongoDB in my project.
I have this code:
router.get('/test3', async (req, res) => {
    const cookies = req.cookies;
    // eslint-disable-next-line dot-notation
    const to = cookies['to'];
    console.log.apply(to);

    SearchDb.findOne({"to": to}, (err, item) => {

        console.log(item);
    });

    res.json("see cnsole");
});

and it returns something like this on the terminal
School

{
 _id: new ObjectId("619be4e74c6a2504334f4a4d"),
 from: 'Home',
 to: 'School',
 step: [
   {
     _id: new ObjectId("61a733c0a7614d6ba7f91561"),
     start: 'Home',
     vehicle: 'Taxi',
     end: 'School',
     cost: 100,
     ave_time: 20
   }
 ]
}

However, I don't really want to use .findOne(), I want to use .find() in case there are multiple search results, when I replace .findOne with .find() though, this is what shows on the terminal
School

{
 _id: new ObjectId("619be4e74c6a2504334f4a4d"),
 from: 'Home',
 to: 'School',
 step: [ [Object] ]
}

The subdocument "step" now returns [ [Object] ], which makes it hard to do things like item.step.length since it will now return undefined.
What should be done to make .find() show the whole document including the subdocuments just like .findOne?

A: @Bsn try this here I'm sending your result on front try POSTMAN for get or browser in console you are getting [object] but in your actual result you will get whole array of an object :)
router.get("/test3", async (req, res) => {
  const cookies = req.cookies;
  // eslint-disable-next-line dot-notation
  const to = cookies["to"];
  console.log.apply(to);

  try {
    SearchDb.find((err, item) => {
      res.json(item);
    });
  } catch (err) {
    res.json(err);
  }
});


text:
Q: Can't Add Value to ListView I have the following code on my SMSReceiverActivity.java:
package com.example.smsTest;

import java.util.ArrayList;
import java.util.List;

import android.app.ListActivity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class SMSReceiverActivity extends ListActivity {
    private SQLiteAdapter mySQLiteAdapter;

    private List<String> bodyarr = new ArrayList<String>();
    private ArrayAdapter<Message> arrayAdpt;

    private BroadcastReceiver mIntentReceiver;
    ListView listview;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_smsreceiver);

        mySQLiteAdapter = new SQLiteAdapter(this);
        mySQLiteAdapter.openToRead();

        List<Message> bodyarr = mySQLiteAdapter.getAllMessages();

        listview=this.getListView();

        arrayAdpt = new ArrayAdapter<Message>(SMSReceiverActivity.this,
                android.R.layout.simple_list_item_1, bodyarr);
        listview.setAdapter(arrayAdpt);
    }

    @Override
    protected void onResume() {
        super.onResume();

        IntentFilter intentFilter = new IntentFilter("SmsMessage.intent.MAIN");
        mIntentReceiver = new BroadcastReceiver() {
            @Override
            public void onReceive(Context context, Intent intent) {
                String msg = intent.getStringExtra("get_msg");

                //Process the sms format and extract body & phoneNumber
                msg = msg.replace("\n", "");
                String body = msg.substring(msg.lastIndexOf(":")+1, msg.length());
                String pNumber = msg.substring(0,msg.lastIndexOf(":"));

                bodyarr.add(body);
                arrayAdpt.notifyDataSetChanged();

                /*
                 *  Create/Open a SQLite database
                 *  and fill with dummy content
                 *  and close it
                 */
                mySQLiteAdapter = new SQLiteAdapter(SMSReceiverActivity.this);
                mySQLiteAdapter.openToWrite();
                //mySQLiteAdapter.deleteAll();

                mySQLiteAdapter.insert(body);

                mySQLiteAdapter.close();
            }
    };

    this.registerReceiver(mIntentReceiver, intentFilter);
    }

    @Override
    protected void onPause() {
        super.onPause();
        this.unregisterReceiver(this.mIntentReceiver);
    }

}

And this is the code of SQLiteAdapter.java:
package com.example.smsTest;

import java.util.ArrayList;
import java.util.List;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;

public class SQLiteAdapter {

    public static final String MYDATABASE_NAME = "MY_DATABASE";
    public static final String MYDATABASE_TABLE = "MY_TABLE";
    public static final int MYDATABASE_VERSION = 1;
    public static final String KEY_ID = "_id";
    public static final String KEY_CONTENT = "Content";

    //create table MY_DATABASE (ID integer primary key, Content text not null);
    private static final String SCRIPT_CREATE_DATABASE =
    "create table " + MYDATABASE_TABLE + " ("
    + KEY_ID + " integer primary key autoincrement, "
    + KEY_CONTENT + " text not null);";

    private SQLiteHelper sqLiteHelper;
    private SQLiteDatabase sqLiteDatabase;

    private Context context;

    public SQLiteAdapter(Context c){
        context = c;
    }

    public SQLiteAdapter openToRead() throws android.database.SQLException {
        sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME, null, MYDATABASE_VERSION);
        sqLiteDatabase = sqLiteHelper.getReadableDatabase();
        return this;
    }

    public SQLiteAdapter openToWrite() throws android.database.SQLException {
        sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME, null, MYDATABASE_VERSION);
        sqLiteDatabase = sqLiteHelper.getWritableDatabase();
        return this;
    }

    public void close(){
        sqLiteHelper.close();
    }

    public long insert(String content){

        ContentValues contentValues = new ContentValues();
        contentValues.put(KEY_CONTENT, content);
        return sqLiteDatabase.insert(MYDATABASE_TABLE, null, contentValues);
    }

    public int deleteAll(){
        return sqLiteDatabase.delete(MYDATABASE_TABLE, null, null);
    }

    public Cursor queueAll(){
        String[] columns = new String[]{KEY_ID, KEY_CONTENT};
        Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE, columns,
        null, null, null, null, null);

        return cursor;
    }

    public List<Message> getAllMessages() {
        String[] columns = new String[]{KEY_ID, KEY_CONTENT};
        List<Message> messages = new ArrayList<Message>();

        Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE,
                columns, null, null, null, null, null);

        cursor.moveToFirst();
        while (!cursor.isAfterLast()) {
            Message message = cursorToMessage(cursor);
          messages.add(message);
          cursor.moveToNext();
        }
        // Make sure to close the cursor
        cursor.close();
        return messages;
      }

    public class SQLiteHelper extends SQLiteOpenHelper {

        public SQLiteHelper(Context context, String name,
        CursorFactory factory, int version) {
            super(context, name, factory, version);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            // TODO Auto-generated method stub
            db.execSQL(SCRIPT_CREATE_DATABASE);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            // TODO Auto-generated method stub

        }

    }

      private Message cursorToMessage(Cursor cursor) {
          Message message = new Message();
          message.setId(cursor.getLong(0));
          message.setMessage(cursor.getString(1));
          return message;
      }

}

And here's the Message.java code:
package com.example.smsTest;

public class Message {
      private long id;
      private String message;

      public long getId() {
        return id;
      }

      public void setId(long id) {
        this.id = id;
      }

      public String getMessage() {
        return message;
      }

      public void setMessage(String message) {
        this.message = message;
      }

      // Will be used by the ArrayAdapter in the ListView
      @Override
      public String toString() {
        return message;
      }
}

The problem is the value of String body = msg.substring(msg.lastIndexOf(":")+1, msg.length()); is not updating to the listview when this code fire bodyarr.add(body);                arrayAdpt.notifyDataSetChanged();. This code can be found in SMSReceiverActivity class.
This is working before I added a sqlite code.

A: The List inside your Adapter holds objects of Message type, and the type of the field inside your Activity is List<String>. You're passing a List<Message> to the Adapter in onCreate(), and then onReceive() you're adding a String to the List<String>. So first, those two lists have incompatible types, so you won't be able to pass a List<String> to the Adapter. And second, by calling bodyarr.add(body) you're adding an item to the Activity's list of Strings, which doesn't affect the Adapter in any way. So you should probably start with fixing the type incompatibility, and then don't forget to call adapter.setItems(bodyarr) after you add something in this list to update the data inside the Adapter. Then calling adapter.notifyDataSetChanged() will do the job. Hope this helps.


text:
Q: Are consecutive relationships necessary when doing multiple Joins Is there a difference in the results or a difference in performance between these two statements/examples:
Example 1 (Consecutive INNER Relationship)
    SELECT ID FROM TABLE T
    INNER JOIN TABLE2 T2 ON T.ID = T2.ID
    INNER JOIN TABLE3 T3 ON T2.ID = T3.ID

Example 2 (Non-Consecutive INNER Relationship)
    SELECT ID FROM TABLE T
    INNER JOIN TABLE2 T2 ON T.ID = T2.ID
    INNER JOIN TABLE3 T3 ON T.ID = T3.ID

or between these 2 statements/examples:
Example 1 (Consecutive LEFT Relationship)
    SELECT ID FROM TABLE T
    INNER JOIN TABLE2 T2 ON T.ID = T2.ID
    LEFT JOIN TABLE3 T3 ON T2.ID = T3.ID

Example 2 (Non-Consecutive LEFT Relationship)
    SELECT ID FROM TABLE T
    INNER JOIN TABLE2 T2 ON T.ID = T2.ID
    LEFT JOIN TABLE3 T3 ON T.ID = T3.ID

The only difference is the second Join is on the Table whereas the first example is on Table2.  I'm pretty sure they return the same thing, but I'm just looking for more experienced answers here. Thanks.

A: There is no difference in results. The statements are functionally equivalent.
The difference in performance depends on the specific database and version, and on the data.
My experience is that in a simple case like this there is typically no difference in performance between the two queries. The SQL2008 optimizer will run the join in whatever order makes sense according to statistics (size of tables, availability of indexes), regardless which way you write this query.


text:
Q: Is it possible to change (html and body) background color using semantic-ui When my ejs file is linked to a semantic ui, the second .css link doesn't work. Is it possible to change html and body background color using semantic-ui?
I linked these two css files:
<link rel="stylesheet" type="text/css" href="semantic.min.css">
<link rel="stylesheet" type="text/css" href="homepage.css">

In homepage.css, when I type html {background-color:pink} this doesn't have any effect. What am I missing?

A: Not exactly what your asking for but could be a workaround.
If you were to edit site.variables which is usally located at: semantic/src/site/globals/site.variables
And add an entry @pageBackground: #5CDB95; and change the #5CDB95 to a colour of your choice, that will then be the default background colour of all pages where you include semantic ui.
After your entry dont forget to run gulp build-css
Hope this is of some help... Not sure why your css isnt overriding sematic ui, I know it sounds stupid but check you have included the <html> tags in your file.


text:
Q: What are some great web sites that are the best for the User Interface? I am looking for nice looking sites that are good in terms of look and feel as well as usability.

A: Someone had to say it: Stack Overflow!
Seriously - it may not be immediately beautiful to look at, but for what it is, and for its target audience and how they use it, it's a great example of both visual design and interaction design.
The layout, the use of colour, the sensible use of AJAX, the lack of fancy graphics, all give a good experience IMHO.
It's also a good example of how to incorporate advertising in an effective but unobtrusive way.

A: Google.
It gets out of the way as much as possible and lets you focus on doing what you came there to do.

A: I think this is question is much like Share good examples of Web-GUIs question that was post in the site sometime ago. probably it will help you.

A: Zen Garden - beauty but especially showing you what different things can be done with pure accessible HTML. So having Usability in mind as well.

A: I don't know what kind/segment of site you want. But I`ll mention one that is kind of site to create site that helped me to create fast and beautiful things.
www.snappages.com is a example of nice/easy/friendly/pretty/dummyFriendly/niceExamples/easyToCreatePrettyThings/easyToMaintain/etc...
I really think that is a 'must know place'
Cheers :)

A: I think gmail is an example of a very usable UI.

A: I've always found that other people's great web sites are more of an inspiration than a practical help.  Every site has particular needs.  For example, this site is good for what it does, but it really isn't a site I need to build; likewise for this one and this one.
I think it is valuable to develop a philosophy/aesthetic for this, or at least be conversant with those who think a lot about design and accessibility.  Here are two sites with some serious discussion along these lines, along with some coding howto:

*

*http://stopdesign.com/

*http://www.456bereastreet.com/
But even these reflect my personal taste.  There are people in my family who really like Club Penguin.  And I hear some folks can tolerate MySpace.


text:
Q: how do I create list of list for N number which needs to be checked as factor I want to have list of list for number say 20 as below output
list of the list of factors up to 20
[[1],[1,2],[1,2,3],[1,2,4],[1,5],[1,2,3,6].........[1,2,4,5,10,20]].
Unable to get function on it

A: Use the sympy library.
>>> from sympy import divisors
>>> [divisors(i) for i in range(1,21)]
[[1], [1, 2], [1, 3], [1, 2, 4], [1, 5], [1, 2, 3, 6], [1, 7], [1, 2, 4, 8], [1, 3, 9], [1, 2, 5, 10], [1, 11], [1, 2, 3, 4, 6, 12], [1, 13], [1, 2, 7, 14], [1, 3, 5, 15], [1, 2, 4, 8, 16], [1, 17], [1, 2, 3, 6, 9, 18], [1, 19], [1, 2, 4, 5, 10, 20]]


text:
Q: syntax error near if: sql query I have used if condition on sql select query. When I use if condition I'm getting a syntax error
     select a.QM_ID,a.QM_QCM_ID,a.QM_Question,a.QM_Type,a.QM_Parent_Id,c.AM_Answer, c.AM_Comments
from question_master a INNER JOIN Assessment_master c
on (c.AM_QM_ID = a.QM_ID AND c.AM_HNM_ID = '%d' AND AND c.AM_HM_ID = '%d' and c.AM_ASM_Local_Id = '%@') where a.QM_Parent_Id = '0' and a.QM_Status = 'A' and a.QM_QCM_ID = '%@' and a.QM_QRM_Id = '%@'
case when(AM_Comments is  null) THEN
union
select b.QM_ID,b.QM_QCM_ID,b.QM_Question,b.QM_Type,b.QM_Parent_Id,null,null
from question_master b INNER JOIN Assessment_master d
on ((d.AM_QM_ID = b.QM_Parent_Id OR d.AM_QM_ID = b.QM_ID) AND d.AM_HNM_ID = '%d' AND d.AM_HM_ID = '%d' and d.AM_ASM_Local_Id = '%@') where b.QM_Parent_Id != '0' and b.QM_Status = 'A' and b.QM_QCM_ID = '%@' and b.QM_QRM_Id = '%@'

A: you are using if in select statement there is no command like if for select statement in sqLite.
you can use Case instead of If.
EXP: select case when length(a) > 4 then a else '' end as b
from anyTable

A: select a.QM_ID,a.QM_QCM_ID,a.QM_Question,a.QM_Type,a.QM_Parent_Id,c.AM_Answer, c.AM_Comments
from question_master a
     INNER JOIN Assessment_master c
         on (c.AM_QM_ID = a.QM_ID
         AND c.AM_HNM_ID LIKE '%d' AND c.AM_HM_ID LIKE '%d'
         and c.AM_ASM_Local_Id LIKE '%@')
     where a.QM_Parent_Id = '0'
         and a.QM_Status = 'A'
         and a.QM_QCM_ID LIKE '%@'
         and a.QM_QRM_Id LIKE '%@' AND
         AM_Comments is  null
union
    select b.QM_ID,b.QM_QCM_ID,b.QM_Question,b.QM_Type,b.QM_Parent_Id,null,null
    from question_master b
    INNER JOIN Assessment_master d
    on ((d.AM_QM_ID = b.QM_Parent_Id OR d.AM_QM_ID = b.QM_ID)
       AND d.AM_HNM_ID LIKE '%d'
       AND d.AM_HM_ID LIKE '%d'
       and d.AM_ASM_Local_Id LIKE '%@')
     where b.QM_Parent_Id != '0'
       and b.QM_Status = 'A'
       and b.QM_QCM_ID LIKE '%@'
       and b.QM_QRM_Id LIKE '%@'


text:
Q: Issues Compiling Paho MQTT statically in Windows 64 bit Using the Cmake GUI Ive added the entry to build statically.
Everything works fine whenever I have Code Generation -> Runtime Library set to Multi-threaded DLL (even though options were set to build as static). The samples build fine and work.
In my actual project, which needs to use static lib, it obviously throws linker error 2038 with mismatched RuntimeLibrary.
How can I force paho MQTT to build statically? I'm using visual studio 14 2015 with c++.


text:
Q: Why wont it accept my return value? My code should accept leapyears and run it through the argument to verify if it is a leap year and ignore not leap years by using the argument method at the top but the return value returns an error. so does the printLeap value.
I'm at this over 4 hours and I cannot do it xD. I dont know how to make it ignore the value if it's not a leap year. I'm only new to java and especially new to return values, yes this is homework but the tags don't show the home-work option I tried with and without a dash.
I tried using a double value return ( I, J ) but it returns a result 0 if J is not a leap year. I also tried making it through using a purely if else if else statement but again the same issue... any advice or assistance is greatly appreciated
Here is my ammended code==
import javax.swing.JOptionPane;
public class SimpleMath {
public static int printLeap(int r, int k){
    if((r % 4 == 0) && (r % 100 != 0) || (r % 400 == 0)){
    return r;
    }
    else if ((r % 4 != 0) && (r % 100 == 0) || (r % 400 != 0));
    return k;
}

public static void main(String[] args) {

    while (true) { //while the statement is true (so it continues indefinitely until the break occurs).

        String year = JOptionPane.showInputDialog("Enter input year, when done type End");

        if ("End".equals(year)){ //if the user types End then the loop will break. it allows a string to be input for an int value

            break;
        }   {
              int r = Integer.parseInt(year);

 int k = 0;
int i = printLeap(r, k);
if (i == 0) {
    System.out.println("");
}
else
    System.out.println("This is a leap year:  " + i);

}
}
}

}

A: Ignoring non-leap years requires an if statement. I suggest:
            int r = Integer.parseInt(year);
            if (printLeap(r)) {
                System.out.println("This is a leap year:  " + r);
            }

You don't need the curly braces around these statements.
The above in turn requires that printLeap (you can probably think of a better name) returns a boolean. That is actually quite simple:
private static boolean printLeap(int i) {
    return i % 4 == 0 && i % 100 == 0;
}

As an aside, there is an error in your formula for a leap year that I have not corrected. See if you can figure out for yourself.


text:
Q: How we can create multiple forms on Magento product page? By default Magento provides facility of custom options in product page but we can create only one form for a product.
How we can create two or more custom options forms on product page?

A: You can do this using xml.
 Open local xml of your theme, and add it under the <catalog_product_view> reference as shown below.
<catalog_product_view>
    <reference name="content">
        <reference name="product.info">
          <block type="catalog/product_view_description" name="product.modelstats" as="modelstats" template="PATH TO TEMPLATE FOR THE TAB 1">
                <action method="addToParentGroup"><group>detailed_info</group></action>
                <action method="setTitle" translate="value"><value>TAB NO 1</value></action>
            </block>
            <block type="catalog/product_view_description" name="product.contact" as="stelly.contact" template="PATH TO TEMPLATE FOR THE TAB 2">
                <action method="addToParentGroup"><group>detailed_info</group></action>
                <action method="setTitle" translate="value"><value>TAB NO 2</value></action>

            </block>

        </reference>
    </reference>
</catalog_product_view>

Clear Cache, then try.


text:
Q: adding new line in the description of the dialog in wix localization string element I'm new to WiX, and using WiX v3.0.
I'm using the WixUI_Advanced dialogs. I customized InstallDirDlg description by adding a .wxl (WiX localization) file.
However, I cannot add a newline in the description.
I tried following to get a new line,
1. <String Id="InstallDirDlgDescription">Hello\nHai</String>

2. <String Id="InstallDirDlgDescription">Hello
   Hai</String>

3. <String Id="InstallDirDlgDescription">Hello</String>
   <String Id="InstallDirDlgDescription" Overridable="yes">Hai</String>

4. <String Id="InstallDirDlgDescription">Hello
Hai</String>

But, none of those options work. Any suggestions.

A: It appears you've found a bug in the .wxl handling in the WiX toolset. I would expect option number 4 or the following to work:
<String Id="InstallDirDlgDescription"><![CDATA[Hello
Hai]]></String>

At this point, you'll probably be best served opening a WiX toolset bug. You might even consider enlisting in the code and trying to root cause the issue to help get the bug fixed. Seems like it should work.


text:
Q: Selenium C# - How to identify the window after close de modal? After close the modal window, how to go back to the previus page?
I need to run a comand, but isn't identify my currente page.

A: You can use the following solution to go back to the previous page after closing the modal window (works with Coordinates, for example):
IJavaScriptExecutor js = driver as IJavaScriptExecutor;
System.Threading.Thread.Sleep(5000);
js.ExecuteScript("window.scrollBy(0,950)");


text:
Q: Python: re.sub, attempting to sub: "001 : Unknown, testing" with "Flows\Temporary\001 : Unknown, testing" gives bad escape \T at position 5 import re

actual_string = "001 : Unknown, testing"

pattern_sub = r"Flows\Temporary\001 : Unknown"
pattern_to_sub = "001 : Unknown"
actual_string = re.sub(pattern_to_sub, pattern_sub, actual_string)
print(actual_string)

Error: line 1024, in parse_template
raise s.error('bad escape %s' % this, len(this))
re.error: bad escape \T at position 5
Expected Outcome: Flows\Temporary\001 : Unknown, testing

A: Need to use re.escape
Below example works for me:
cat re_issue.py
#!/usr/bin/python3.9
import re

actual_string = "001 : Unknown, testing"

pattern_sub = r"Flows\Temporary\001 : Unknown"
pattern_to_sub = "001 : Unknown"
actual_string = re.sub(pattern_to_sub, re.escape(pattern_sub), actual_string)
print(actual_string)

re_issue.py
Flows\Temporary\001\ :\ Unknown, testing

In order to get expected output, additional work should be done:
cat re_issue1.py
#!/usr/bin/python3.9
import re

actual_string = "001 : Unknown, testing"

pattern_sub = r"Flows\Temporary\001:Unknown"
pattern_to_sub = "001 : Unknown"
actual_string1 = re.sub(pattern_to_sub, re.escape(pattern_sub), actual_string)
pattern_sub1 = " : "
pattern_to_sub1 = ":"
actual_string2 = re.sub(pattern_to_sub1, pattern_sub1, actual_string1)
print(actual_string2)

re_issue1.py
Flows\Temporary\001 : Unknown, testing


text:
Q: How to run Skype after installing it using AUR package on Arch Linux I have installed Skype using the AUR package following these steps:
wget https://aur.archlinux.org/cgit/aur.git/snapshot/skypeforlinux-bin.tar.gz
tar zxf skypeforlinux-bin.tar.gz
cd skypeforlinux-bin
makepkg -s

And the output was:
==> Making package: skypeforlinux-bin 8.6.76.56247-1 (Fri Sep  8 10:11:48 -03 2017)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found skypeforlinux_8.6.76.56247_amd64.deb
==> Validating source files with sha256sums...
    skypeforlinux_8.6.76.56247_amd64.deb ... Passed
==> Extracting sources...
  -> Extracting skypeforlinux_8.6.76.56247_amd64.deb with bsdtar
==> Removing existing $pkgdir/ directory...
==> Entering fakeroot environment...
==> Starting package()...
==> Tidying install...
  -> Removing libtool files...
  -> Purging unwanted files...
  -> Removing static library files...
  -> Stripping unneeded symbols from binaries and libraries...
  -> Compressing man and info pages...
==> Checking for packaging issue...
==> Creating package "skypeforlinux-bin"...
  -> Generating .PKGINFO file...
  -> Generating .BUILDINFO file...
  -> Generating .MTREE file...
  -> Compressing package...
==> Leaving fakeroot environment.
==> Finished making: skypeforlinux-bin 8.6.76.56247-1 (Fri Sep  8 10:13:39 -03 2017)

Now, how can I run Skype? because I've tried searching for the command skype or similar, but nothing appeared.
Could you help me?
Thanks a lot!

A: You have built the package (makepkg -s), but you haven't installed it, so obviously you cannot run it.
pacman -Q skypeforlinux-bin will confirm that it is not installed.
The makepkg output also makes this evident:

==> Finished making: skypeforlinux-bin 8.6.76.56247-1 (Fri Sep  8 10:13:39 -03 2017)

As the wiki page on the AUR makes clear, you need to pass makepkg -i to install your built package.
At this point, you can either rebuild, or simpler providing you still have the built package, just use pacman:
sudo pacman -U $package_name.pkg.tar.xz


text:
Q: What is the "reverse" path in the case of a piecewise defined curve?
Consider a curve $\gamma(t): [a,b] \to \mathbb{R}^n$. The curve
  $$-\gamma(t)=\gamma(a+b-t) \,\,\,\,\,\,\,\,\,\,\,\,\,\, t \in [a,b]$$
is called the "reverse" curve (or path) of $\gamma(t)$.

This definition is clear, but how is the "reverse" path defined in the following case?
Take two regular curves $\gamma_1:[a,b] \to \mathbb{R}^n$ and $\gamma_2:[c,d] \to \mathbb{R}^n$ with $\gamma_1(b)=\gamma_2(c)$ and define $\gamma:[a,d] \to \mathbb{R}^n$ as
$$\gamma(t)=\begin{cases} \gamma_1(t) & t\in [a,b] \\ \gamma_2(t) &t \in [c,d] \end{cases}$$
Now, what is $-\gamma(t)$?
I think there are two possibilities:

*

*$$-\gamma(t)=\begin{cases} \gamma_1(a+b-t) & t\in [a,b] \\ \gamma_2(a+b-t) &t \in [c,d] \end{cases}$$

*$$-\gamma(t)=\begin{cases} \gamma_1(a+b-t) & t\in [a,b] \\ \gamma_2(c+d-t) &t \in [c,d] \end{cases}$$

A: You want to map $a$ to $\gamma_2 (d)$, $b$ and $c$ to $\gamma_2 (c) = \gamma_1 (b)$ and $d$ to $\gamma_1 (a)$. Looking for a linear map $\varphi(t) = At + B$ taking $a$ and $b$ to $d$ and respectively $c$ we find $\begin{cases} Aa + B = d \\ Ab + B = c \end{cases}$, whence $A = \frac {d-c} {a-b}$ and $B = \frac {ac-bd} {a-b}$, so that $\varphi (t) = \frac {d-c} {a-b}t + \frac {ac-bd} {a-b}$.
The reverted curve is then $-\gamma : [a,b] \cup [c,d] \to \Bbb R^n$ given by
$$-\gamma (t) = \begin{cases} \gamma_2 \big( \varphi (t) \big), & t \in [a,b] \\
\gamma_1 \big( \varphi^{-1} (t) \big), & t \in [c,d] \end{cases} .$$

A: A picture would really help here - the intuitive idea behind this is a bit like how, when looking at compositions of functions (or even group elements), $(fg)^{-1}=g^{-1}f^{-1}$.
Here, you're dealing with a concatenation of paths, which is an analog of composition (well, almost) in this setting. You're travelling along $\gamma_1$ first, and then along $\gamma_2$. With this in mind, to reverse your path, you should retrace your steps along $\gamma_2$, and then along $\gamma_1$.
Once such way of doing this would be:
$$-\gamma (t) = \begin{cases} \gamma_2 (a+d-t), & t \in [a,a+d-c] \\
\gamma_1 (a+d-t), & t \in [d-b+a,d] \end{cases} .$$


text:
Q: "After parsing a value an unexpected character was encountered" on RavenDB 3.0 I'm running RavenDB 3.0 as a Windows Service on my machine.
There's a collection in the database with 610 documents, and whenever I query it to get them all
_session.Query<StockKeepingUnit>().Take(1024).ToList();

I get the following error:
"After parsing a value an unexpected character was encountered: B. Path 'Results[342].ManufacturerDescription'."

"exceptionType":"Raven.Imports.Newtonsoft.Json.JsonReaderException"

And the following stack trace:
"stackTrace":"   at

Raven.Imports.Newtonsoft.Json.JsonTextReader.ParsePostValue() in c:\\Builds\\RavenDB-Stable-3.0\\Imports\\Newtonsoft.Json\\Src\\Newtonsoft.Json\\JsonTextReader.cs:line 762
   at Raven.Imports.Newtonsoft.Json.JsonTextReader.ReadInternal() in c:\\Builds\\RavenDB-Stable-3.0\\Imports\\Newtonsoft.Json\\Src\\Newtonsoft.Json\\JsonTextReader.cs:line 392
   at Raven.Imports.Newtonsoft.Json.JsonTextReader.Read() in c:\\Builds\\RavenDB-Stable-3.0\\Imports\\Newtonsoft.Json\\Src\\Newtonsoft.Json\\JsonTextReader.cs:line 304
   at Raven.Json.Linq.RavenJObject.Load(JsonReader reader) in c:\\Builds\\RavenDB-Stable-3.0\\Raven.Abstractions\\Json\\Linq\\RavenJObject.cs:line 251
   at Raven.Json.Linq.RavenJArray.Load(JsonReader reader) in c:\\Builds\\RavenDB-Stable-3.0\\Raven.Abstractions\\Json\\Linq\\RavenJArray.cs:line 139
   at Raven.Json.Linq.RavenJObject.Load(JsonReader reader) in c:\\Builds\\RavenDB-Stable-3.0\\Raven.Abstractions\\Json\\Linq\\RavenJObject.cs:line 225
   at Raven.Json.Linq.RavenJToken.ReadFrom(JsonReader reader) in c:\\Builds\\RavenDB-Stable-3.0\\Raven.Abstractions\\Json\\Linq\\RavenJToken.cs:line 171
   at Raven.Json.Linq.RavenJToken.Load(JsonReader reader) in c:\\Builds\\RavenDB-Stable-3.0\\Raven.Abstractions\\Json\\Linq\\RavenJToken.cs:line 262
   at Raven.Json.Linq.RavenJToken.TryLoad(Stream stream) in c:\\Builds\\RavenDB-Stable-3.0\\Raven.Abstractions\\Json\\Linq\\RavenJToken.cs:line 238
   at Raven.Client.Connection.HttpJsonRequest.<ReadJsonInternalAsync>d__48.MoveNext() in c:\\Builds\\RavenDB-Stable-3.0\\Raven.Client.Lightweight\\Connection\\Implementation\\HttpJsonRequest.cs:line 459

When I try the same query on the live database, hosted on Azure, the query succeeds.
The local database is a direct import from the one on Azure, so no differences there.
What's interesting is that if I delete the whole database and re-import it, the error remains the the "unexpected character" and the property where it's found change:
    "After parsing a value an unexpected character was encountered: v. Path 'Results[342].OriginalRetailPrice'."

I'm at a loss as to where to even begin. Any ideas?


text:
Q: Should the removeAt() function remove the removing node's pointer? I'm a beginner in coding and recently studying linked list on JavaScript.
I am confused that while removing node, should I also change the removing node's pointer to null?
RemoveAt(index) method is a custom method for removing the node at a specific index.
Example as below:
// remove node
removeAt(index){
    // check if index is qualified
    if(index < 0 || index > this.length) return null;
    let current = this.head,
        prev = null,
        idx = 0;
    // if first node
    if(index===0){
        // point the head to next node
        this.head = current.next;
    }else{
        // else find the index
        while(idx++ < index){
            prev = current; // set prev node as current
            current = current.next; // and move current to the next node
        }
        // index finded, link prev.next & current.next
        prev.next = current.next;
    }
    this.length--;
}

Most of the linked list examples I saw in JS omitted this. I am wondering will it waste more memory?

A: You don't need to assign null to current. It is a variable that is local to the function, so as soon as the function exits, there is no more reference to the removed node, and it can be garbage collected.
If outside of the function's context you happen to have another reference to the node that is removed, then the node will not be garbage collected. Assigning null to current will not change that situation.
Some coders may want to isolate the node however:
current.next = null;

This way, if there is somewhere still a reference to that node, there is no risk of walking from that node into the list, which may be undesired. On the other hand, it really is a code smell if outside of the function there is still a reference to the node that is removed, and it would get really smelly if that reference is still used to traverse along its next property. So if the overall code is doing the right thing, you don't really need to do current.next = null either.

A:
...while removing node, should I also change the removed node's pointer to null? ... I am wondering will it waste more memory?

It's not necessary for memory management, no. (I think there's an argument for doing it for other reasons, but not memory management.) If you remove node A without clearing its pointer to node B, and nothing else refers to node A, then it's eligible for garbage collection. (And if you also remove B, the fact A still refers to it won't keep it in memory if nothing else has a reference to them; they'll both be eligible for garbage collection.)

A: Not necessary to do that, as it is you are freeing that part of memory by deleting the node, it doesn't matter what are contents of that freed node's data part or next part


text:
Q: Modal is getting the last value from my table I created a modal with bootstrap, in react, but when it opens, it takes the last value from my table(sql). Does anyone know why he does this, and how I fix it
this is my code with the table and modal
When I open my MODAL the information there is wrong, it is taking the last item in my table.
this classific is each field of my table
                 return (
                   <React.Fragment key={classific.ID}>

                                 {classific.ID}

                             {classific.DS_Classificacao}

                             {classific.Status === true ? 'Ativo' : 'Inativo'}

                           <button
                             onClick={e => EditForm(classific.ID, e)}
                             className="text-gray-400 hover:text-gray-100  mx-2"
                           >
                             Close panel
                             <PencilIcon
                               className="h-6 w-6"
                               aria-hidden="true"
                               onClick={handleShowE}
                             />
                           </button>

                           <button className="text-gray-400 hover:text-gray-100  ml-2">
                             Close panel
                             <TrashIcon
                               className="h-6 w-6"
                               aria-hidden="true"
                      **Here is where I press for my modal to open**
                               onClick={handleShowD}
                            />
                           </button>

**The information inside the modal is wrong**
                     <Modal
                       show={showD}
                       onHide={handleCloseD}
                       backdrop="static"
                       keyboard={false}
                     >
                       <Modal.Header>
                         <Modal.Title>
                           Deletar {classific.DS_Classificacao}
                         </Modal.Title>
                       </Modal.Header>
                       <Modal.Body>
                         Tem certeza que deseja deletar
                          {classific.DS_Classificacao} ? Essa ação é
                         irreversivel.
                       </Modal.Body>
                       <Modal.Footer>
                         <button
                           type="button"
                           className="inline-flex items-center px-2.5 py-1.5 border border-gray-300 shadow-sm text-xs font-medium rounded text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
                           onClick={handleCloseD}
                         >
                           Cancelar
                         </button>

                         <button
                           type="button"
                           className="inline-flex items-center px-2.5 py-1.5 border border-gray-300 shadow-sm text-xs font-medium rounded text-red-700 bg-red hover:bg-red-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500"
                           onClick={e => deleteForm(classific.ID, e)}
                         >
                           Deletar
                         </button>
                       </Modal.Footer>
                     </Modal>
                     <Modal
                       show={showE}
                       onHide={handleCloseE}
                       backdrop="static"
                       keyboard={false}
                     >
                       <Modal.Header>
                         <Modal.Title>Editar Classificação</Modal.Title>
                       </Modal.Header>
                       <Modal.Body>
                         {/* <ModalEdit id={classific.ID}></ModalEdit> */}
                       </Modal.Body>
                       <Modal.Footer>
                         <button
                           type="button"
                           className="inline-flex items-center px-2.5 py-1.5 border border-transparent text-xs font-medium rounded shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
                           onClick={handleCloseE}
                         >
                           Cancelar
                         </button>
                       </Modal.Footer>
                     </Modal>
                   </React.Fragment>
                 )
               })}```


text:
Q: c# - Get a string line from a text file and show the text in a label I'm studying C# and creating this program to learn a bit more.
My program catchs the information that you have input and save it into a text file. In this part, is alright, but I'm having issues on load the file and show the information inside it.
Example, in the program I have the text boxes for user input his family information:
Dad text box:
Mom text box:
Brother text box:
The text box input is something like:
Dad text box: MyDad
Mom text box: MyMom
Brother text box: MyBrother
When the creation process of file starts, I have in the file the output that I want:
MyDad
MyMom
MyBrother
Okay, now I need to load these informations from the file and write it in another labels, like:
Your Dad is: according to example, I want "MyDad" shown here
Your Mother is: according to example, I want "MyMother" shown here
Your Brother is: according to example, I want "MyBrother" shown here
In the click event of the button to show the informations of the file I have this to check if the file was created and, if was, read it:
string path = @"C:\Users\Hypister\Desktop\Family.txt";
if (File.Exists(path))
            {
                using (StreamReader sr = File.OpenText(path))
                {
                    //Here I need the function to get the lines and show it in respective labels.
                }
            }
            else
            {
                MessageBox.Show("The file doesn't exists. Data cannot be loaded.");
            }

But I cannot get the line for Dad, Mother and Brother from the file to show.
I hope someone can answer this and help me to gain more knowledge.
Thanks all in advance!

A: I coded an example for you a good C# file reference is http://msdn.microsoft.com/en-us/library/ezwyzy7b.aspx for future reference.
there 3 textboxes 3 labels and a button all default names
here is the source code hope it helps :)
  private void button1_Click(object sender, EventArgs e)
    {
        List<string> family = new List<string>();
        family.Add(textBox1.Text);
        family.Add(textBox2.Text);
        family.Add(textBox3.Text);

        family.ToArray();

        using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\OEM\Desktop\stackoverflow\test.txt"))
        {
            foreach (string line in family)
            {
                    file.WriteLine(line);
            }
        }

        string[] familyout = System.IO.File.ReadAllLines(@"C:\Users\OEM\Desktop\stackoverflow\test.txt");

        /*  this works just fine unless you have alot of labels, the code not commented out below this works better
        label1.Text = familyout[0];
        label2.Text = familyout[1];
        label3.Text = familyout[2];
        */

        int i = 0;

        foreach (Control lbl in this.Controls)
        {
            if (lbl is Label)
            {
                lbl.Text = familyout[i];
                i++;
            }
        }
    }


text:
Q: Problem of links when create friendly links with htaccess When I use this code which make a friendly ULRs:
RewriteRule ^(.*).html$ index.php?ps=$1 [NC,L]

all work just fine.
but when I try to add a "category name" to the URL like this:
RewriteRule ^(.*)/(.*).html$ index.php?pc=$1ps=$2 [NC,L]

It's work fine actually but the problem I had is on the website which all links become start with (the category's directory), its suppose to be like this: http://localhost/mysite/title.html
but they look like this: http://localhost/mysite/category/title.html
I mean links in source code not in the bar Address, including css and images Source links. which lead to an disaster on the style and nonfunctional links.


text:
Q: How to assign posted values to a variable in cakephp? I likes to assign posted values to a variable,
In view i wrote the code,
<?php echo $this->Form->create('Register'); ?>
<fieldset>
    <?php echo $this->Form->input('username');
    echo $this->Form->input('password');
    echo $this->Form->input('Confirm password');
?>
</fieldset>

Form->end(__('Submit'));
and in controller,
if($this->request->is('post')){
    //print_r($this->data);
    $uname = $this->request->data('username');
    echo "uname".$uname;
    exit;
}

The problem is that i didnt get the value on $uname.

A: Make sure your debug is enabled. Use this - pr($this->request->data); to see what's in that variable. The CakePHP form naming data usually looks something like this
$this->request->data['Formname']['fieldname']

In your case it should be
$this->request->data['Register']['username']

A: please try using this code
$this->params['form']['YOUR_VARIABLE_NAME']

or
$this->data['FORMNAME']['YOUR_VARIABLE_NAME']


text:
Q: Buying Mercenaries in Dawn Of Heroes Just started the game and I was wondering if hiring Mercenaries were worth it or if the story provides me with better alternatives.

A: The more mercenaries you get, the more amount of strategies you will be able to do. Despite of the gold farming (that is a bit boring), totally worth it imo.


text:
Q: How to not "hide" Page when App Bar is open in Windows Store Apps? I'm building a windows store apps, I'm using windows 8 and VS 2012.
I think my question is pretty simple but I can't find an answer anywhere..
I've added an AppBar at the bottom of my page and that's the code
  <Page.BottomAppBar>
    <AppBar x:Name="bottomAppBar" Padding="10,0,10,0">
        <Grid>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                <Button Style="{StaticResource EditAppBarButtonStyle}" Click="Button_Click"/>
                <Button Style="{StaticResource RemoveAppBarButtonStyle}" Click="Button_Click"/>
                <Button Style="{StaticResource AddAppBarButtonStyle}" Click="Button_Click"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Style="{StaticResource RefreshAppBarButtonStyle}" Click="Button_Click"/>
                <Button Style="{StaticResource HelpAppBarButtonStyle}" Click="Button_Click"/>
            </StackPanel>
        </Grid>
    </AppBar>
</Page.BottomAppBar>

Now the problem is that when the AppBar is Open the Page is "obscured" until I click again on the Page.
Is it possible to not obscured the page while AppBar is open?
Any help would be very appreciated.
thank you

A: first remove the padding of appbar and your container has fix margin as well as height and width . try with below and not forgot to set property of image as content....
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Mode="Default" Opacity="1.0">
    <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
    <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
    <shell:ApplicationBar.MenuItems>
        <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
        <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
    </shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>


text:
Q: Two packages have the same class name inside the same namespace. How to specifically use each class? The Microsoft.Azure.Cosmos (v3.29.1.0) and Micosoft.Azure.Documents (v2.10.3.0) has the same class called UnixDateTimeConverter within the same namespace Microsoft.Azure.Documents. My project needs to use both packages, and I cannot rename both. How can I specifically use the class of Microsoft.Azure.Documents package? ( cause that of Micosoft.Azure.Documents has public access modifier which can be called anywhere)
Micosoft.Azure.Cosmos package
Micosoft.Azure.Documents package
Update:Specifying the problem occurs in a CosmosModel/Student.cs file
namespace DataAccess.CosmosModel{
public class Student{
public string id { get; set; }
public string Email { get; set; }
public bool IsEmailConfirmed { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime DateOfBirth { get; set; }
public string PhoneNumber { get; set; }
public string CountryCode { get; set; }

[Newtonsoft.Json.JsonConverter(typeof(Microsoft.Azure.Documents.UnixDateTimeConverter))]
[Newtonsoft.Json.JsonProperty(PropertyName = "_ts")]
 public virtual DateTime Timestamp { get; set; }

A: the key is that they are not in same namespace and you can choose which one you would like to use in your using section of code for instance
using UnixDateTimeConverter = Microsoft.Azure.Cosmos.UnixDateTimeConverter;

this would instruct to use this implementation and not the older, but it is typically only necessary when you are using both namespaces to begin with, so just as often we can remove one of the using statements.
Update 1 (one more to follow):
When issue is to serialize to and from Azure Cosmos, you can choose to let the driver handle your conversion
[BsonDateTimeOptions]
public DateTime UpdatedUTCZero { get; set; } = DateTime.UtcNow;

Details about Serialization on the .net driver can be found here:
http://mongodb.github.io/mongo-csharp-driver/2.2/apidocs/html/R_Project_CSharpDriverDocs.htm
so there is a huge capability from the mongo driver:
http://mongodb.github.io/mongo-csharp-driver/2.2/apidocs/html/N_MongoDB_Bson_Serialization.htm
Update 2:
Wanting to elaborate, i'm sure you can find a hook to completely replace serialization, but if you want to use the mongo driver to for instance support 'schema' changes with the ExtraElements and such things i recommend looking in to, you're left with a collection interface IMongoCollection so if not using the Bson Serializer you'd have to store payload as string, which is sort of not good for querying.
However if You implement the serializing methods from link above, you can totally Use newtonsoft for serializing, just remember to tag your id with [BsonId] or it will generate one for You
Update 3: Example using the MongoDb.Driver and MongoDb.Json
I wouldn't normally interfere with the internal timestamp a.k.a _ts though i do not see why You couldn't expose it, it like the _id field relates to the MongoDb engine used to interface with cosmos. Wouldn't put virtual on, it's a .net thing not Bson/ Json.
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDB.Bson.Serialization.Attributes;

// ...
public class Student{
  [BsonId]
  public string Id { get; set; }
  [BsonDateTimeOptions]
  public DateTime LastUpdatedDateTime{ get; set;}
  [BsonElement("ts")]
  public BsonTimestamp TimeStamp{ get; set; }
  // ...
}

See section on timestamps: https://www.mongodb.com/docs/v4.4/reference/bson-types/
Also found a good article about dealing with mongo db engine related time issues: http://www.binaryintellect.net/articles/6c715186-97b1-427a-9ccc-deb3ece7b839.aspx this field has quite a few options.


text:
Q: Python: unknown # of files as function arg Having this working code to read 2 files and reprint them:
import sys
args = sys.argv[1:]

def funcprint(arg1, arg1):
    with open(arg1, "r") as inp:
        for line in inp:
            print(line)
    with open(arg2, "r") as inp:
        for line in inp:
            print(line)

funcprint("C:/file1.txt", "C:/file2.txt")

But how would one pass an arbitrary number of files to the function? Having *arg instead of 1 & 2 results in TypeError: invalid file:, even with just 1 passed file.
As a side question, is there a way to shorten the function call if all files are in the same folder? Something like funcprint("C:/": "file1.txt", "file2.txt").

A: If you want to pass an arbitrary number of file names, you'd do:
def funcprint(*args):
    for f in args:
        with open(f, 'r') as inp:
            ...

funcprint("C:/file1.txt", "C:/file2.txt")

If the files are all in the same directory, you could do:
def funcprint(dir, *args):
    for f in args:
        with open('{}{}'.format(dir, f), 'r') as inp:
            ...

funcprint('C:/', 'file1.txt', 'file2.txt')


text:
Q: Receiving and verifying the response from a webhook I am using typeform and for fetch the results i am using typeform's webhook. After a research i get to know the way to fetch response from webhook using PHP.
$json = file_get_contents('php://input');
$action = json_decode($json, true);

Now my questions are,

*

*How to verify if the response is sent by typeform only? as typeform containing a filed stripe payment, so i want to implement security and verify the data before saving to the database.

*Is it really a standrad way to fetch response from webhook, as i oubt Zend use http stream for that. So what is the way to fetch response from a webhook.

I researched for it but only found the way which i mentioned above.


text:
Q: Maven Transitive Dependency issue While building my project, there are two versions of org.bouncy-castle:bcprov required

*

*org.bouncy-castle:bcprov-jdk12

*org.bouncy-castle:bcprov-jdk16

So while listing down the dependency I am getting the jdkversion12
Is there any way to modify the POM file in such a way that jdkversion16 is listed first?

A: You can exclude a dependency by specifying it like this - in your case, you would exclude the jdk12 one:
    <dependency>
            <groupId>group</groupId>
            <artifactId>artifact</artifactId>
            <version>1.0.0</version>
            <exclusions>
                    <exclusion>
                            <groupId>org.bouncycastle</groupId>
                            <artifactId>bcprov-jdk12</artifactId>
                    </exclusion>
            </exclusions>
    </dependency>

This way, only the jdk16 one should be pulled in.
If you need to pull in one of the two based on where you're building and which version of the JDK is installed, you can use profiles to distinguish, e.g. like this:
<profile>
    <id>jdk12</id>
    <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>1.2</jdk>
    </activation>
    <dependencies>
        <dependency>
            <groupId>group</groupId>
            <artifactId>artifact</artifactId>
            <version>1.0.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.bouncycastle</groupId>
                    <artifactId>bcprov-jdk16</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
</profile>
<profile>
    <id>jdk16</id>
    <activation>
        <jdk>1.6</jdk>
    </activation>
    <dependencies>
        <dependency>
            <groupId>group</groupId>
            <artifactId>artifact</artifactId>
            <version>1.0.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.bouncycastle</groupId>
                    <artifactId>bcprov-jdk12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
</profile>

Example taken from: http://svn.apache.org/repos/asf/webservices/wss4j/trunk/pom.xml


text:
Q: Using Robocopy /minage: What is the Maximum number of days? I'm trying to run a batch script using Robocopy but when I try to put in MinAge days of 10 years ago (for example 3653 days) it doesn't like it and I'm getting an 'Invalid switch' error.  If I put in the date 20110101 it works perfectly.  Just trying to figure out the maximum number of days I can use for the MinAge parameter.
I've looked on Microsoft support, here an elsewhere and I don't see this being addressed.  Thank you in advance for your time and answers.

A: 1899 is the maximum days you can put in for MinAge.


text:
Q: Why isn't my section siding up to the right properly? I am currently making a webpage, which has a side section, such as the one in this photo:

What I currently have is this:

Why is it that my side column isn't showing up like the one in the first picture? I tried to make the side column and test where it would be by putting the words "side column????", however it isn't showing up properly. My code is as follows:
HTML:
<!DOCTYPE html>

    <meta charset="UTF-8" />
    <title>int222_162d16 - Assignment 2 - Home Page</title>
    <link rel="stylesheet" href="css/normalize.css"   type="text/css" media="screen" />
    <link rel="stylesheet" href="css/sitecss.css" type="text/css" media="screen" />

♠ My Zenit Account

Home

Gallery

Video

Audio

Tables With CSS

Forms

CSS Used

Extra

Welcome To The Home Page!

HTML5 & CSS Normalize

The reason why we use normalize.css is due to it providing cross-browser consistency in the styling of HTML elements.

SIDE COLUMN???

SIDE COLUMN???

TEXT

                TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT

CSS:
/*nav.fixed-nav-bar
{
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  width: 100%;
  height: 50px;
  margin-top: 10px;
}
*/
ul.nav
{
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #f3f3f3;
    border: 1px solid #e7e7e7;
    box-shadow: 5px 2px 10px #808080;
}

li.nav
{
    float: left;
}

li a
{

    display: block;
    color: #666;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

/* Change the link color on hover*/

li a:hover:not(.active)
{
    background-color: #ddd;
}

li a.active
{
    color: #ffffff;
    background-color: #9999ff;
}

section.s /*shadow on sections*/
{
    background-color: #ccccff;
    box-shadow: 5px 2px 10px #808080;
    width:63%;

}

/*div.s
{
    box-shadow: 5px 2px 10px #808080;

}
*/
footer
{

          width:100%;
          background:#ccccff;
          color:#000000;
          border:1px solid #cccccc;
          position:absolute;
          text-align:center;
          font-weight:bold;
          display:inline-block;
          margin: 0px auto;
          line-height:20px;
          box-shadow: 5px 2px 10px #808080;
          clear: both;
   }
   aside {
  float: right;
  width: 30%;
}

A: I would say, you need to change your HTML to

SIDE COLUMN???

HTML5 & CSS Normalize

The reason why we use normalize.css is due to it providing cross-browser consistency in the styling of HTML elements.

TEXT

            TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT TEXT

see, I moved  out of the section, to make it floats to the right

A: You can use a framework / structure like this to lay out your page as desired.
Simple Example:

*{position:relative;box-sizing:border-box;font-family:arial;}

nav{position:fixed;height:50px;width:99vw;background:darkcyan;color:white;text-align:center;overflow:auto;font-size:1.2rem;}
  nav div{float:left;width:30vw;}
  nav ul{float:left;width:65vw;height:50px;list-style:none;}
    nav ul li{display:inline-block;padding:0 5vw;}

#wrap{top:50px;overflow:hidden;}
  .both{float:left;min-height:500px;margin-left:2vw;padding:20px;}
  #main{width:60vw;border:1px solid orange;}
  aside{width:29.5vw;border:1px solid blue;}
    .sideDiv{margin-bottom:20px;}

File

Edit

View

    PHOTO GALLERY goes in here

    Side Area

Four other wonders

Social Media Links


text:
Q: How to mock angular/node third-party modules with jest I am trying to mock the whole ng-inline-svg module (which is a third-party angular module).
I have tried putting the following code into my jest global mocks file:
import { NgModule } from '@angular/core';

const ngInlineSvgBaseMock = jest.genMockFromModule('ng-inline-svg');

@NgModule()
class NgInlineSvgMockModule {
  public static forRoot = jest.fn();
}

ngInlineSvgBaseMock['InlineSVGModule'] = NgInlineSvgMockModule;

module.exports = ngInlineSvgBaseMock;

but I get the following error message:
Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:

     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.

     • If you need a custom transformation specify a "transform" option in your config.

     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:

    https://jestjs.io/docs/en/configuration.html

    Details:

    C:\git2\xxx-ui\node_modules\ng-inline-svg\lib\index.js:1

    export { InlineSVGConfig } from './inline-svg.config';

    ^^^^^^

    SyntaxError: Unexpected token 'export'

       9 |   public static forRoot = jest.fn();

      10 | }

    > 11 |

         | ^

      12 | ngInlineSvgBaseMock['InlineSVGModule'] = NgInlineSvgMockModule;

      13 |

      14 | module.exports = ngInlineSvgBaseMock;

      at Runtime._execModule (../../node_modules/jest-runtime/build/index.js:1179:56)

      at Object.<anonymous> (jest-globals.ts:11:32)

Can someone please help and provide tips as to how to use jest in order to mock whole third-party modules?


text:
Q: Add target=_blank on all link occurrences in a string How can I add a target="_blank" on all occurrences of the href tag in a string, using javascript inside a function?
For example:
input string:
var input = 'this is a test string example, and this is another test string example 2.'

var output = convertString(input);

output should equal: 'this is a test string example, and this is another test string example 2.'

A: just replace '

var input = 'this is a test string example, and this is another test string example 2';

function convertString(input){
  return input.split('<a').join('<a target="_blank"')
}

document.body.appendChild(document.createTextNode(convertString(input)))

A: Simple quick and dirty solution:
function convert(str) {
    const a_tag = //g;
    return str.replace(a_tag, '');
}

The regex uses a capture group to hold onto the various existing attributes of the tag and pipe them into the replacement string at the position of $1.
demo


text:
Q: Python: mapper function argument doesn't take effect when passing the Rename method to a DataFrame I am relatively beginner with Python programming language.
I have a dataframe defined as the following:
Record1 = pd.Series({'Type':'Fork', 'Material':'metal'})
Record2 = pd.Series({'Type':'Knife','Material':'Plastic'})
Record3 = pd.Series({'Type':'Spoon','Material':'wood'})

S = pd.DataFrame([Record1,Record2,Record3])

I try to apply it the rename method, with a mapper function intended to cast all the characters into uppercase:
S.rename(mapper = lambda x:x.upper(), axis = 1, inplace = True)

I expected to get the following dataframe with all its strings transformed to uppercase:
    TYPE    MATERIAL
0   Fork    metal
1   Knife   Plastic
2   Spoon   wood

But when I type S after having applied the mapper function, I still get it with lowercase characters.
Can anyone help me?

A: Your rename() lambda expression is manipulating the column headers, but not the values. Check this by using S.columns before and after the call to rename().
S.applymap(lambda x : x.capitalize())

This will manipulate the values not the column headers.


text:
Q: MS Word not embedding Math font I have created a document with two bespoke fonts (company fonts). I have set Word to embed fonts so maintain the look of the document when it is distributed outside of the company, and the main body font embeds fine. However, the Math font used for the equation does not embed properly. The font looks fine on my machine, it is when it is sent to a machine which doesn't have the font installed.

The Math font is an OpenType font

A: If this document is for distribution outside your offices, you probably want to make it a (non-editable) PDF file. Free tools, such as the Nitro PDF reader, will add a PDF "printer driver" visible from all Print dialogs. Just "Print" your Word document to "PDF", rather than the office printer This has pros and cons, depending on whether you wnat the recipient to be able to change the text.
An alternative is to take a screenshot of the equations in your document, and insert the image of the formula. That does not require font embedding, but the equation cannot be edited afterwards.


text:
Q: Get material design colors at runtime outside the scope I´m trying to outsource my custom view into an own library.
Is it possible to get the colorPrimary, colorPrimaryDark and colorAccent attributes outside the scope, maybe at runtime?
Solution
I´ve pointed it out myself.
In xml use:
?attr/attributeName

f.e.
?attr/colorAccent

In code use sth like:
public int getColorValueByAttr(Context context, int attrResId) {
    int color = 0;

    TypedArray a = null;
    try {
        int[] attrs = {attrResId};
        a = context.obtainStyledAttributes(attrs);
        color = a.getColor(0, 0);
    } finally {
        if (a != null) {
            a.recycle();
        }
    }

    return color;
}


text:
Q: Session not working for first time, from second time it works I don't know what is the problem. When I do login for first time after deleting all history and cookies and cache, it doesn't set session to redirected page. But when I do login for second time, session is set to redirected page. Here id the code of First & second page.
First Page
<?php
session_start();
include('includes/connection.php');
$email=$_POST['email'];
$password=$_POST['password'];

$data=mysqli_query($GLOBALS["___mysqli_ston"], "select * from  user_registration where email='$email' and password='$password' ");
$data1=mysqli_num_rows($data);
$val=mysqli_fetch_array($data);

if($data1>0)
{
   $_SESSION['user_id']=$val['user_id'];
   echo "<script>window.location.href='index.php'</script>";

}
else
{
    echo "<script>window.location.href='login.php'</script>";

}
?>

Second Page
<?php
  session_start();
  $val=$_SESSION['user_id'];
  echo $val;
?>

A:
session_start(); should be at the very top of both scripts!

Session variables are saved on server and assigned a unique code that are passed to browser in cookies.
Because the cookies are set by the headers they need to be sent before anything else!
Even a whitespace at the top of your script may cause session cookie to be not properly set on browser side.
So always start the both scripts like this:
<?php
session_start();

// Rest of the code....

It looks like they are on top on your question but I think you edited question later to put there.
That's the only reason sessions are not working the first time and they are working on second time.

A: instead of the echo use
header("Location: index.php");

EDIT
alsosession_start should be declared at the top of the first page because you cant set a session that doesn't exist in the context if you were running it in a console environment you would receive the following error
"$_SESSION['user_id'] does not exist in the current context"

A: same happening here. is php 5.6 is super strange problem. on some pages work normaly and on one dont. First request is like dont get recognized.. :)
for example: set
#when page load set:
$_SESSION['a']=0;
#then with JS requests increase $_SESSION['a']+=1; and this start working on third request...


text:
Q: Accessing OS X built in dictionary lookup in Firefox I am really frustrated that Firefox does not provide the three-finger-tap lookup operation is in built in OS X. What is baffling me is that it supports other gestures such as two finger swipes and taps. So why not the 3 finger tap dictionary ?
Is this possible to actually implement ? Or is it because access to in built dictionary and trackpad is blocked by OS ? How can I start looking at this problem ?

A: Unfortunately looks like this is still an open bug as of today.
https://bugzilla.mozilla.org/show_bug.cgi?id=687026

A: Firefox bug #687026 regarding 10.7 - 10.10 was fixed Jan 2016.
Firefox bug #1212527 regarding 10.11 was fixed in May 2016. Firefox 49+ has the fix.
Working as expected on 10.11 and 10.12.

A: As of now (Dec 1 2014), although the option is not present in right-click menu, three-finger dictionary lookup works perfectly fine in my Firefox (Developer Edition 35)
Also there have been certain plugins which help you look up words in dictionary through right click. For example https://addons.mozilla.org/en-US/firefox/addon/look-up-in-dictionary-7261/
EDIT (Oct 2017): I'm now using the new e10s Firefox and the dictionary lookup still works. You don't need any plugin, just tap with three fingers or press Control + Cmd + D.

A: One can open the MacOS dictionary by typing dict://word-in-question in the address bar.
This extension: https://addons.mozilla.org/en-US/firefox/addon/macos-dictionary-lookup/ adds a menu item to do it. In order for it to work, you need to do the above process manually, and allow Firefox to open the dictionary app.


text:
Q: Solution manual for " How to Prove it by D. Vellemen " I am solving this book. It has good exercises. Since i am new to proofs. Also i am doing every proof on my own but not sure if its correct. Writing single proof for checking on MSE takes lot of time. Is there any solution manual available for this book so that i can compare my proof with that ?
Thanks

A: If I am not wrong, there are solutions to suggested exercises at the back of the book.
Nevertheless, you might also want to refer here.


text:
Q: Adding titles to a multiple plot output in a similar situation as presented in this question, I am outputting multiple timeseries charts from a single dataframe, and I can not figure out to add the unique chart title to each plot....
my data can be found here
and I am approaching this as follows
gw <- read.csv("gw_cbp.csv")

require(ggplot2)
require(plyr)
require(gridExtra)

pl <- dlply(gw, .(Well.ID), function(dat) {
  ggplot(data = dat, aes(group = 1, x = Date, y = Benzene), ) + geom_line() +
    geom_point() + xlab("Date") + ylab("mg/Kg") +
    geom_smooth(method = "lm") + ggtitle(Well.ID)
})

ml <- do.call(marrangeGrob, c(pl, list(nrow = 32, ncol = 1)))
ggsave("benzene.pdf", ml, height = 72, width = 11, units = "in", limitsize = F)

here the
+ ggtitle(Well.ID)

is not finding the individual Well.ID's being used in the ddply function...
can anyone show me how to call the unique Well.ID's for this situation?
thanks     ZR

A: Try
+ ggtitle(dat$Well.ID)

The parameters for ggtitle are not evaulated in the context of the data.frame you pass to ggplot() so you need to be explicit about where that value is coming from.


text:
Q: Manipulating "Save PDF File As" function created by Adobe Reader XI Pro add-on First of all - I have been searching everywhere and non of the solutions I have found have fit for my problem.
Basically I am creating a bookkeeping program and everything is working perfect. After alot of time in developing it is almost finished, but now I have run into a big problem.
What the program wants to do?
The program wants to print a salary report file created by it by sending it to a printer "Adobe PDF" which creates a pdf AND  EVERYTHING HERE IS WORKING FINE. But now the program opens a new window called "Save As PDF", where I need to insert the name of the file and press enter. I wrote code for it, but the code does not work although the window is activated. :/
And here is my code sample for the print button, where "CreateReceipt" just draws all the text into the pdf.
private void palgalipik_Click(object sender, EventArgs e)
    {
        PrintDialog printDialog = new PrintDialog();
        PrintDocument printDocument = new PrintDocument();
        printDocument.PrinterSettings.PrinterName = "Adobe PDF";
        printDialog.Document = printDocument;
        printDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(CreateReceipt);
        printDocument.Print();
        System.Threading.Thread.Sleep(2500);
        SendKeys.SendWait(töötajanimi1.Text + "(" + palgaperiood.Text + ")");
        SendKeys.SendWait("{ENTER}");
    }

TL;DR problem
Need to insert insert a string into "Save PDF File As" dialog box and click ENTER aka "Save". Code should do it, but doesnt - what is the problem?
NB! I want to use Adobe Reader XI Pro, because all computer in the company have it so it is alot better than starting to do it with iTextSharp or other alternatives.
Thanks in advance and ask me if anything is still blurry about my question!

A: Use APIs to create a PDF instead of printer:
http://www.pdfsharp.com/PDFsharp/
or
http://sourceforge.net/projects/itextsharp/


text: Q: Applying trees to ordered discrete dependent variables? I am trying to use trees to model the number of months counties take to fully recover following an extreme weather event. Since I am looking at count of months, I have an ordered discrete dependent variable. I started by running classification trees; however, it seems like they are not fully capturing the nature of the data. I want to try accounting for the ordered nature of the dependent variable by fitting trees similar to how ordered logits are fit. I imagine that this is mostly a matter of fitting either a classification or regression tree, and calculating error correctly. I tried to find examples of or documentation for taking this kind of approach, but could not find anything. I am open to all advice and direction. I am working with the sklearn package for Python.


text:
Q: Disable scientific notation in Spark Scala I have a table to consume from Spark and do data transformations.
There is a column that have values with 8 numbers after . something like this: 0.00000001
This column have the absolute value like this number above.
I need to take the absolute value of that column, without let Spark transform this in scientific notation. When Spark reads the table, it transforms the column in scientific notation.
I have tried to convert in String, Double or Float, but nothing works. I need this field in the type Decimal. The type of the field is already Decimal natively in the column.
Is there some way to do this?
Code to simulate:
val df = spark.sparkContext.parallelize(Seq((0.00000001))).toDF("Value")

Spark shows me this: 0E-8
And i need this in Decimal Type: 0.00000001
Thanks!

A: You can use format_number function to get desired result.
spark.sparkContext.parallelize(Seq((0.00000001))).toDF("Value").
   selectExpr("format_number(Value,'#.########') as Value").show(false)

/*
+----------+
|Value     |
+----------+
|0.00000001|
+----------+*/


text:
Q: A criteria for an open subset of a compactly generated space to be compactly generated Is the following statement true or false?

An open subset $U$ of a compactly generated space $X$ is compactly generated if each point of $U$ has an open neighborhood in $X$ with closure contained in $U$.

(Added 2/16/2023) Summary of the answers:
The answer depends on which notion of "compactly generated" (CG) space is used.  There are multiple variants of the concept, as mentioned here for example, or in Stefan Hamcke's comment.
Definition 1: $X$ has the final topology with respect to the inclusions from all its compact subspaces.  This is the definition in wikipedia.
Definition 2: $X$ has the final topology with respect to all continuous maps from arbitrary compact Hausdorff spaces.  This is the definition in nlab and is the one more commonly used in algebraic topology.
Eric Wofsey's answer: with Definition 1, the desired statement is true.  Also note as a consequence:

(With definition 1)  In a CG regular space, all open subspaces are CG.

David Carchedi's answer: with Definition 2, all the open subsets of a CG space are CG.

A: ANY open subset of a compactly generated (possibly non-Hausdorff) space is compactly generated. Indeed, let $U$ be an open subset of a compactly generated space $X.$ Let $A$ be a subset of $U$ such that for any continuous map $f:K \to U$ from $K$ compact Hausdorff, $f^{-1}\left(A\right)$ is open in $K$. We want to show that $A$ is open in $U.$ But as $U$ is open in $X,$ this is iff $A$ is open in $X.$ So let $g:C \to X$ be a continuous map from a compact Hausdorff space. It suffices to show that $g^{-1}\left(A\right)$ is open in $C.$ Now, $g^{-1}\left(U\right)$ is an open neighborhood of $g^{-1}\left(A\right)$ in $C$ so it suffices to show that $g^{-1}\left(A\right)$ is open in $g^{-1}\left(U\right)$. But, as an open subspace of a compact Hausdorff space, $g^{-1}\left(U\right)$ is locally compact Hausdorff, and hence compactly generated. So it suffices to prove that for any map $h:D \to g^{-1}\left(U\right)$ with $D$ compact Hausdorff, $h^{-1}\left(g^{-1}\left(A\right)\right)$ is open in $D.$ But $$D \stackrel{h}{\to} g^{-1}\left(U\right) \stackrel{\tilde g}{\to} U$$ is a continuous map to $U$ from a compact Hausdorff space, where $\tilde g$ is the restriction of $g,$ so by assumption, $h^{-1}\left(\tilde g^{-1}\left(A\right)\right)$ is open in $D.$ But as $g^{-1}\left(U\right)$ contains $g^{-1}\left(A\right),$ this is the same as $h^{-1}\left(g^{-1}\left(A\right)\right),$ finishing the proof.

A: This is true.  Suppose $A\subseteq U$ is closed with respect to the compactly generated topology on $U$ and let $V=U\setminus A$.  We wish to show that $V$ is open in the subspace topology on $U$, or equivalently that $V$ is open in $X$.  Let $K\subseteq X$ be compact; it suffices to show that $V\cap K$ is open in $K$.  Fix a point $x\in V\cap K$ and let $W\subseteq X$ be an open neighborhood of $x$ whose closure is contained in $U$.  Then $L=\overline{W}\cap K$ is closed in $K$ and hence compact, and is contained in $U$.  Since $A$ is closed with respect to the compactly generated topology on $U$, $A\cap L$ is closed in $L$, and so $V\cap L$ is open in $L$.  Since $x\in V\cap L$ and $L$ contains a neighborhood of $x$ in $K$ (namely $W\cap K$), $V\cap L$ contains a neighborhood of $x$ in $K$, and hence so does $V\cap K$.  Since $x\in V\cap K$ was arbitrary, this means $V\cap K$ is open in $K$.


text:
Q: start CSS animation on page load Is it possible to initiate a css animation on pageload. Currently It only works for hover, focus and active states. The animation causes the item to bob but I want this to happen automatically and constantly.
the css is as follows:
@-webkit-keyframes hvr-bob {
  0% {
    -webkit-transform: translateY(-8px);
    transform: translateY(-8px);
  }

  50% {
    -webkit-transform: translateY(-4px);
    transform: translateY(-4px);
  }

  100% {
    -webkit-transform: translateY(-8px);
    transform: translateY(-8px);
  }
}

@keyframes hvr-bob {
  0% {
    -webkit-transform: translateY(-8px);
    transform: translateY(-8px);
  }

  50% {
    -webkit-transform: translateY(-4px);
    transform: translateY(-4px);
  }

  100% {
    -webkit-transform: translateY(-8px);
    transform: translateY(-8px);
  }
}

@-webkit-keyframes hvr-bob-float {
  100% {
    -webkit-transform: translateY(-8px);
    transform: translateY(-8px);
  }
}

@keyframes hvr-bob-float {
  100% {
    -webkit-transform: translateY(-8px);
    transform: translateY(-8px);
  }
}

.hvr-bob {
  display: inline-block;
  vertical-align: middle;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  box-shadow: 0 0 1px rgba(0, 0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -moz-osx-font-smoothing: grayscale;
}
.hvr-bob:before, .hvr-bob:focus, .hvr-bob:active {
  -webkit-animation-name: hvr-bob-float, hvr-bob;
  animation-name: hvr-bob-float, hvr-bob;
  -webkit-animation-duration: .3s, 1.5s;
  animation-duration: .3s, 1.5s;
  -webkit-animation-delay: 0s, .3s;
  animation-delay: 0s, .3s;
  -webkit-animation-timing-function: ease-out, ease-in-out;
  animation-timing-function: ease-out, ease-in-out;
  -webkit-animation-iteration-count: 1, infinite;
  animation-iteration-count: 1, infinite;
  -webkit-animation-fill-mode: forwards;
  animation-fill-mode: forwards;
  -webkit-animation-direction: normal, alternate;
  animation-direction: normal, alternate;
}

A: Change this line
.hvr-bob:before, .hvr-bob:focus, .hvr-bob:active {

to this
.hvr-bob {

JSBIN


text:
Q: Converting JIRA priority to Greenhopper Ranking I have an existing project that uses Priority to prioritize tickets.  I'd like to convert this project to a Greenhopper project, but I can't figure out how to do a one-time ordering of my backlog ordered by priority.
How can I do a one-time re-order of my Greenhopper backlog ranked in order of their old priority field?

A: I imagine that there MUST be a better way, however here's how I did it.
I created a separate Quick Filter for each of my priorities, eg. one each for P0, P1, P2, etc.
I created a separate Sprint for each priority, eg. one each for P0, P1, P2, etc., one each in that order.
For each priority, I enabled the quick filter for that priority, selected all of the stories in the backlog (which are all of the same priority), then dragged those stories to the corresponding Sprint.
Once I was done doing that, there were no more stories in the backlog.
Then, I deleted each sprint in backward order.  So first I deleted P4, then P3, then P2, etc.  With each deletion, the stories from that sprint were added to the top of the backlog.
When I was done, I had a list of stories in my backlog ordered by priority.
Then I deleted the priority quickfilters.


text:
Q: commutation relations in terms of eigenstates scalar product This question has caught my attention because I was unaware of the fact that the position-momentum canonical commutation relations could be derived out of the only assumption for $\langle x | p\rangle$ to be a plane wave $\textrm{e}^{ipx}$. It seems that the trick follows from the properties of the exponential function and the Dirac delta to be proportional to their derivatives times the exact accidental factors appearing in the game.
I was wondering whether the same could apply to any other pair of operators: namely let $A, B$ be two non-commuting operators with $\{|a\rangle\}, \{|b\rangle\}$ being the corresponding set of eigenstates. Along the same lines as in the answer one has:
$$
\langle a |[A,B]| a' \rangle = (a-a')\int\textrm{d}b'\,b'\,\langle a | b'\rangle\langle b' | a'\rangle
$$
or any other sum replacing the integral according to what the eigenvalues look like. In the above general case nothing can be said (can it?); in the other very special case of the angular momentum, with the eigenfunctions being the spherical harmonics, do we still have any accidental simplification of the wave functions in order to gain back the $\textrm{SU}(2)$ commutation relations (maybe due to some special recursive properties of those functions)?
Generalising, the question can be put as: given $A, B$ two self-adjoint operators, does the scalar product between elements of the corresponding complete sets of eigenstates fully determine the commutator (i. e. the action) of the two operators on the entire Hilbert space?


text:
Q: dynamic tooltip text d3 when select value change I am trying to draw a dynamic  choropleth map
i select the properties to diplay from a selection input
 the property is mapped in a json dataset and is rapresented with the d3 choropleth tecnique
when i try to diplay with an on mouse over tooltip the object value, the property doesn't refresh and the tooltip continue to show the old property's value.
Any suggestions?? My code is below.
Thanks in advance.
    var divtool = d3.select("body").append("div")
                .attr("class", "tooltip")
                .style("opacity", 0);

        //onchange choropleth
            d3.selectAll(".demosearch").on("change", function () {
                    var t = this.value;

                          if(t  != 'none'){

                                quantize.domain([
                                d3.min(mn_map.features, function(d) { return d.properties[t]; }),
                                d3.max(mn_map.features, function(d) { return d.properties[t]; })
                                ]);

                                d3.selectAll("#mappa").attr("class", t)
                                svg.selectAll(".comune")
                                   .data(mn_map.features)
                                   .attr("class",  function(d) { return (quantize(d.properties[t])); })
                                   .style("opacity", 0.8);

                      //Adding mouseevents
                                   .on('mouseover', function (d) {
                                    d3.select(this).transition().duration(100).style({'opacity': 0.8, 'stroke': 'red', "stroke-width": 4  })
                            divtool.text(d.properties.NOME_COM + " : " +t+" : "+ d.properties[t])
                                   .style("opacity", 1)
                                   .style("left", (d3.event.pageX) + "px")    .style("top", (d3.event.pageY -30) + "px");                                          })

                                   .on('mouseout', function (d) {                           d3.select(this).transition().duration(100).style({'opacity': 0.8, 'stroke': '#909090', "stroke-width": 1 });
                                    divtool.style("opacity", 0);
                                  })
                                            }// <-- End if test this.value

                        else {
                         svg.selectAll("#mappa")
                            .transition().duration(500)
                            .attr("class","mappa" )
                         divtool.remove();
                        };


text:
Q: Convert UIImage into Base64 String with less than 100 Characters. Swift 4.2 | iOS I want to encode a UIImage object into Base64 String. Generally, I'm a getting quite a large string and the process is taking a long execustion time as well.
func convertImageToBase64String () -> String {
    guard let imageData: Data = UIImage.jpegData()
    let imgString = imageData.base64EncodedString(options: .init(rawValue: 0))
    return imgString
}

class func convertBase64StringToImage (imageBase64String: String) -> UIImage? {
    guard let imageData = Data.init(base64Encoded: imageBase64String, options: .init(rawValue: 0)) else { return nil }
    let image = UIImage(data: imageData)
    return image
}

Please provide me a li'l help here.

A: What you want isn't possible. The JPEG data is already a compressed form of the image. And when you convert data to base64 encoding, the result is a string that will be 33% larger than the original data.
So the only way to get a base64 encoded string representation of a JPEG image that is less than 100 characters is to ensure that the original JPEG is less than 66 bytes. I'm pretty sure that even a 1x1 pixel JPEG will be more than 66 bytes.
If the JPEG is a full photograph taken on an iOS device, the resulting data will be a few megabytes. That takes time to submit.


text:
Q: Command to list contents if directory, or do output contents if file? Is there any command to list the contents if passed a directory, but output the contents if it's a file?
For example, often when I am navigating the directory structure I will start typing into the terminal something like
ll /etc/path/  # I see a file in tab-completion that interests me, called myfile.txt
ll /etc/path/myfile.txt  # I do the auto-completion to get it into the command line
less /etc/path/myfile.txt  # Now I have to go back and change 'll' to 'less'

Alternatively, if I'm looking for a file, I start with
less /etc/path  # I see in tab-completion several files that might interest me, so I need to know more
ll /etc/path  # See more info about file sizes, etc, so I can choose the file I want. Have to change 'less' to 'll'
less /etc/path/myfile.txt  # Now that I know which file I want, I have to go back and change 'll' to 'less'

This is something I end up doing dozens of times a day, and starts to slow me down. Is there a command or script that does the likeliest scenario for you? For example
some-program /etc/path/to/file/or/directory

If the target is a text file or symlink to a text file, 'less /etc/path/to/.....' would be executed. But if it were anything else, e.g. directory, binary file, block device, it would do 'll /etc/path/to/......'
Of course if it does something you don't want, like 'less' on a file symlink but you want to see the symlink itself with 'll', then you just run 'll' manually.
Anything like this exist (I bet it's out there, it seems like such a common task)? Or am I just using Linux command line in an inefficient way and there are better ways to navigate through it...how do you do it? Or I am really the only one going back and forth in the command line all the time switching 'less' to 'll' and back again?
some-program() {
  if [[ $# > 1 ]]; then
    echo "Only one argument supported at this time"
  exit 1
  fi
  if [[ $# == 0 ]]; then
    ELEMENT="."
  else
    ELEMENT="$1"
  fi
  if [[ -d $ELEMENT ]]; then
    ls --color=auto -alF "$ELEMENT"
  else
    less "$ELEMENT"
  fi
}

A: less has a really neat built-in feature that lets you do things like this.  See the lesspipe man page.
To use that feature to automatically show a directory listing of directories, do the following:

*

*Set up lesspipe following the man page: eval "$(lesspipe)"

*Create ~/.lessfilter with the following contents and make it executable:
#!/bin/sh
if [ -d "$1" ]; then
    ls -alF "$1"
else
    # We don't handle this format.
    exit 1
fi
exit 0

This sets up a filter script run by lesspipe to handle file types.  It checks to see if what you're trying to view is a directory and, if so, runs ls instead.
Your original request included color.  That's unfortunately a bit harder, since less doesn't show color by default and the output from the filter script is still piped through less.  You'd need to use -R as a default option (which is probably not a good idea if you ever view a binary file) to do that.  I don't think there's a way to have the lessfilter script tell less to add a new option.


text:
Q: Can I exclude features (routes, components...) in my Angular application during Build time depending on a env file? I would like to have two versions of my Application with the same codebase. One Version should for example include the "registration" feature and the other one not. Can I configure Angular somehow that an env file determines what gets excluded during compilation?
Or does the compiler anyway remove unreachable code. For example, if I have two feature.json files and each build process gets one of them. And in my code I just check if the feature is activated in my feature.json

A: Yes, angular has this built in. There are already two different compilation versions by default: production and development. You can add more. The environment objects are found in the environments directory. The build configurations are in angular.json. When building you use the command ng build --configuration=myConfigurationName.
Here's the docs: https://angular.io/guide/build
Here's the default configurations:
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "500kb",
                  "maximumError": "1mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "2kb",
                  "maximumError": "4kb"
                }
              ],
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "outputHashing": "all"
            },
            "development": {
              "buildOptimizer": false,
              "optimization": false,
              "vendorChunk": true,
              "extractLicenses": false,
              "sourceMap": true,
              "namedChunks": true
            }
          },
          "defaultConfiguration": "production"

Notice how in production, the environment.ts file gets replaced by the environment.prod.ts file.
So you have two options:

*

*You can create two new environment files and use boolean feature toggles to include and exclude functionality. So you import the object from environment.ts, but you replace that environment file during compilation. The issue is anyone can still activate that functionality using the debugger.

*You can have two versions of specific files and replace those files depending on what version you want. The downside is it'll be extra work to keep common functionality synced between versions. Anything that is not common will need to be in separate files.


text:
Q: Flutter shrinkwrap breaks page height shrinkwrap: true in ListView.builder makes AnimatedPositioned appear at the end of the widget (middle of the screen) instead of the bottom of the screen. Changing shrinkwrap: false causes an error because the ListView does not have size.
Is there a way to give ListView.builder a height or make AnimatedPositioned appear at the bottom of the screen?

A: you can wrap the ListView widget into SizedBox to give it a height.
and if you want to make it size responsive for different screens you can use MediaQuery.