text:
Q: if $(-1)$ is not an eigenvalue of $AB$, then it is not an eigenvalue of $A(B^{-1})$? Let $A,B$ be invertible matrices of order $n\times n$ over $\mathbb C$. It is easy to prove that if $(-1)$ is not an eigenvalue of $B$, then it is not an eigenvalue of $B^{-1}$. Under what conditions, it is true that if $(-1)$ is not an eigenvalue of $AB$, then it is not an eigenvalue of $A(B^{-1})$ ?

A: Some sufficient conditions:

*

*$B=B^{-1}$, for the trivial reason;

*$A$ is Hermitian and $B$ is unitary, so that $BA=(AB^{-1})^\ast$ (recall that for any two square matrices $A$ and $B$, $AB$ and $BA$ always have the same spectrum);

*$A$ is complex symmetric and $B$ is complex orthogonal, so that $BA=(AB^{-1})^T$;

*$A\overline{A}=I$ and $B$ is real, so that $BA=\left(\overline{AB^{-1}}\right)^{-1}$.

Note that we may interchange the roles of $A$ and $B$ in each of the above cases, because $AB$ has the same spectrum as $BA$, and $-1$ is an eigenvalue of $AB^{-1}$ iff $-1$ is an eigenvalue of $BA^{-1}=(AB^{-1})^{-1}$.

A: False.
Counter-example:
$$A =\begin{bmatrix}-2 & 0 \\0& 1\end{bmatrix},~~~B =\begin{bmatrix}2 & 0 \\0& 1\end{bmatrix}$$

$$AB =\begin{bmatrix}-4 & 0 \\0& 1\end{bmatrix},~~~A(B^{-1}) =\begin{bmatrix}-1 & 0 \\0& 1\end{bmatrix}$$
$-1$ is not an eigenvalue of $AB$, but $-1$ is an eigenvalue of $A(B^{-1})$.


text:
Q: How to fix signature of generic extension method in kotlin to resolve "Type inference failed" in kotlin I have created extension method:
@Suppress("UNCHECKED_CAST")
operator fun <T : View> View.get(@IdRes id:Int): T  =
        this.findViewById(id) as T

Main usage of this method:
class A {
    lateinit var text: TextView

    fun init(view:View) {
        text = view[R.id.text]
    }
}

This works perfectly, but when I try use it without variable:
fun test() {
    view[R.id.text].visibility = View.GONE // error
}

Error:
Type inference failed: Not enough information to infer parameter T in
operator fun <T : View> View.get(id: Int): T
Please specify it explicitly.

If I write the analog code in java, methods of class View available without direct specification of View type.
Is it possible in kotlin? Maybe do some changes in signature of generic type somehow?

A: It is not possible to specify the generics type on the get operator, and it is also not possible to the compiler to infer what type does that get should return.
You can call the get function as an ordinary function view.get<TextView>(R.id.text), without using the operator overloading convention.
To achieve the desired functionality, you can use the Kotlin Android Extensions as suggested by @Miha_x64, without the need to use the findViewByIdmethod.

redpajama_set_name: RedPajamaStackExchange


text:
Q: PluginTransformationException: Unable to add files to plugin jar We are having a problem building plugin project. We were able to run project without error. When we change the computer for building we get this error.
Jira Version:6.2.1

Console output:
[INFO] [talledLocalContainer] 2016-05-26 12:06:42,466 localhost-startStop-1 ERROR[plugin.osgi.factory.OsgiPluginFactory] Unable to load plugin: C:\Atlassian\jira\com.lbs.jira.plugins\target\jira\home\plugins\installed-plugins\logo-jira-plugin-4.0.8.jar
[INFO] [talledLocalContainer]com.atlassian.plugin.osgi.factory.transform.PluginTransformationException: Unable to add files to plugin jar
[INFO] [talledLocalContainer] at com.atlassian.plugin.osgi.factory.transform.DefaultPluginTransformer.transform(DefaultPluginTransformer.java:170)
[INFO] [talledLocalContainer] at com.atlassian.plugin.osgi.factory.OsgiPluginFactory.createOsgiPluginJar(OsgiPluginFactory.java:301)
[INFO] [talledLocalContainer] at com.atlassian.plugin.osgi.factory.OsgiPluginFactory.create(OsgiPluginFactory.java:224)
[INFO] [talledLocalContainer] at com.atlassian.jira.plugin.MasterPluginFactory.create(MasterPluginFactory.java:80)
[INFO] [talledLocalContainer] at com.atlassian.plugin.loaders.ScanningPluginLoader.deployPluginFromUnit(ScanningPluginLoader.java:155)
[INFO] [talledLocalContainer] at com.atlassian.plugin.loaders.ScanningPluginLoader.loadAllPlugins(ScanningPluginLoader.java:89)
[INFO] [talledLocalContainer] at com.atlassian.plugin.loaders.PermissionCheckingPluginLoader.loadAllPlugins(PermissionCheckingPluginLoader.java:24)
[INFO] [talledLocalContainer] at com.atlassian.plugin.manager.DefaultPluginManager.init(DefaultPluginManager.java:217)
[INFO] [talledLocalContainer] at com.atlassian.jira.plugin.JiraPluginManager.start(JiraPluginManager.java:83)
[INFO] [talledLocalContainer] at com.atlassian.jira.ComponentManager$PluginSystem.start(ComponentManager.java:722)
[INFO] [talledLocalContainer] at com.atlassian.jira.ComponentManager.quickStart(ComponentManager.java:225)
[INFO] [talledLocalContainer] at com.atlassian.jira.ComponentManager.start(ComponentManager.java:199)
[INFO] [talledLocalContainer] at com.atlassian.jira.upgrade.PluginSystemLauncher.start(PluginSystemLauncher.java:24)
[INFO] [talledLocalContainer] at com.atlassian.jira.startup.DefaultJiraLauncher$3.run(DefaultJiraLauncher.java:130)
[INFO] [talledLocalContainer] at com.atlassian.jira.config.database.DatabaseConfigurationManagerImpl.doNowOrEnqueue(DatabaseConfigurationManagerImpl.java:317)
[INFO] [talledLocalContainer] at com.atlassian.jira.config.database.DatabaseConfigurationManagerImpl.doNowOrWhenDatabaseActivated(DatabaseConfigurationManagerImpl.java:211)
[INFO] [talledLocalContainer] at com.atlassian.jira.startup.DefaultJiraLauncher.postDbLaunch(DefaultJiraLauncher.java:118)
[INFO] [talledLocalContainer] at com.atlassian.jira.startup.DefaultJiraLauncher.access$100(DefaultJiraLauncher.java:32)
[INFO] [talledLocalContainer] at com.atlassian.jira.startup.DefaultJiraLauncher$1.run(DefaultJiraLauncher.java:81)
[INFO] [talledLocalContainer] at com.atlassian.jira.util.devspeed.JiraDevSpeedTimer.run(JiraDevSpeedTimer.java:34)
[INFO] [talledLocalContainer] at com.atlassian.jira.startup.DefaultJiraLauncher.start(DefaultJiraLauncher.java:76)
[INFO] [talledLocalContainer] at com.atlassian.jira.startup.LauncherContextListener.contextInitialized(LauncherContextListener.java:54)
[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
[INFO] [talledLocalContainer] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
[INFO] [talledLocalContainer] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
[INFO] [talledLocalContainer] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
[INFO] [talledLocalContainer] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
[INFO] [talledLocalContainer] at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
[INFO] [talledLocalContainer] at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
[INFO] [talledLocalContainer] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
[INFO] [talledLocalContainer] at java.util.concurrent.FutureTask.run(FutureTask.java:262)
[INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[INFO] [talledLocalContainer] at java.lang.Thread.run(Thread.java:745)

A: The key error would appear to be this:
com.atlassian.plugin.osgi.factory.transform.PluginTransformationException: Unable to add files to plugin jar

This usually indicates some sort of disk-related error, so the likely causes are either:

*

*you are out of disk space or disk quota on the filesystem holding your $JIRA_DATA directory, or

*there is some sort of permission problem and the OS user account that JIRA runs under is unable to modify the necessary files within your $JIRA_DATA directory.

A: I got this error because the name of my jar file was too long.


text:
Q: Wamp not working properly after enable ssl module I have using WampServer Version 3.0.6 32bit with window 10 (32bit) in VMware Workstation 12 Player.
Apache 2.4.23 -
PHP 5.6.25 -
MySQL 5.7.14

and also using
Win32OpenSSL-1_1_0f

I try to run localhost with https.
I followed this link.
private.key & certificate.crt created successfully and I have setup properly in httpd-ssl.conf file as per instruction.
But I enable below module with remove # Apache
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf

After then restart WampServer with services that time WampServer not start properly and WampServer icon convert red to orange only but not convert in green.
but I disable below module then start wamp server its working fine properly.
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf

I try to run httpd -t its given
"Cannot load modules/mod_ssl.so into server: The operating system cannot run %1"
I enable also php extension.
extension=php_openssl.dll

Please Help how to configure localhost with https.


text:
Q: Where are Python's stdlib tests? Say I wrote a class that resembles a dict. I want it to pass the same unit test the standard dict passes, with maybe some modifications.
Where can I find that code?

A: Python tests are included with the python source, in Lib/test:
http://hg.python.org/releasing/2.7.4/file/9290822f2280/Lib/test/test_dict.py
http://hg.python.org/releasing/3.3.1/file/8e5812b35480/Lib/test/test_dict.py

A: To build on Pavel's answer, It looks like python is using mercurial now
http://hg.python.org/releasing/2.7.3/file/7bb96963d067/Lib/test/test_dict.py
For other tests go to
http://hg.python.org/
click on releasing/<python version> > browse (on the left menu) > navigate to the appropriate test. The structure at hg.python.org is similar to that of svn.python.org.


text:
Q: Solr grouping: can I alter the behavior for missing fields? What I'm looking for is an operation which would "partially collapse" my results so that documents which have a certain field are grouped, removing what could be seen as near duplicates, but all docs missing this field remain unaffected by the field collapsing.
(Specifically, the docs in question are individual posts in a discussion forum, which in turn is organized in threads. Since the forum displays a whole thread per page, multiple hits in the same thread are essentially duplicates as far as the user is concerned and as a thread grows long, this is quite inevitable if the users stick to the subject. However, there are many other types of docs for which this collapsing does not make any sense at all.)
Using Solr 3.5, the closest I've gotten is
...&group=true&group.main=true&group.field=threadid&group.limit=3

but it appears that Solr is treating "missing" as a value and collapses everything else into 3 hits - I would like it to treat missing values as "unique".
Can this be done or should I consider revising the schema design?

A: I don't think this is directly possible with the existing query parameters in solr.
You have two options which might work:

*

*Ensure each post has a threadid such that one-off posts have a unique threadid which does not conflict with the 'normal' threadids. When grouping on this field, these posts will show up in their own groups.

*Run two queries, one with the grouping enabled, but an fq parameter which filters out posts without a threadid (e.g. fq=threadid:[* TO *]), then another query for only the non-threaded posts with an inverse fq (fq=-threadid:[* TO *]), then merge these results in your own code.


text:
Q: Icon in JTable Cell Causing Misrendering I'm trying to use a custom renderer to set the background of individual cells to a given image. In this case, I'm giving a chessboard wooden squares.
Here's what it looks like before:

Here's what it looks like afterwards:

EDIT: With a little experimentation, it seems that every square is given the wood icon. Pieces can still be moved, resulting in this: (put it in the comments because I can't post more than 2 links)
In my code, I've merely replaced the setBackground(darkSquare) with setIcon(wood).
@SuppressWarnings("serial")
public class BoardCellRenderer extends DefaultTableCellRenderer {

    private ArrayList<Coordinate> possibleMoves = new ArrayList<Coordinate>();
    private ImageIcon wood = new ImageIcon("resources/images/light_square.png");

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

        setHorizontalAlignment(SwingConstants.CENTER);

        Color darkSquare = new Color(125, 125, 125);

        //pattern for the chessboard look
        if(row % 2 == 0 && column % 2 == 1)
            setBackground(darkSquare);
            //setIcon(wood);
        else if(row % 2 == 1 && column % 2 == 0)
            setBackground(darkSquare);
            //setIcon(wood);
        else
            setBackground(Color.WHITE);

        for(Coordinate move : possibleMoves)
            if(column == move.getX() && row == move.getY()){
                setBackground(new Color(255, 51, 51, 50));
                System.out.println("Highlighting (" + row + ", " + column + ")");
            }

        if(hasFocus){
            setBorder(new MatteBorder(2, 2, 2, 2, Color.RED));
            System.out.println("hasFocus [array]: " + row + ", " + column);
            System.out.println("hasFocus [coordinate]: " + column + ", " + row);
        }
        if(isSelected)
            setBorder(new MatteBorder(2, 2, 2, 2, Color.BLUE));

        return this;
    }

    public void setPossibleMoves(ArrayList<Coordinate> possibleMoves){
        this.possibleMoves = possibleMoves;
    }
}

A:
it seems that every square is given the wood icon.

The renderer remembers its last state.
So maybe something like:
//  set the default values

setBackground(Color.WHITE);
setIcon(null);

if(row % 2 == 0 && column % 2 == 1)
    //setBackground(darkSquare);
    setIcon(wood);
else if(row % 2 == 1 && column % 2 == 0)
    //setBackground(darkSquare);
    setIcon(wood);

Of course you will still have a problem when you want to display a chess piece on top of the wood as you will want to render two icons, one for the background and one for the chess piece.
I'm not sure if a JTable is the best component to use for this. It might be easier to use a JPanel with a grid of either JPanel/JLabel to represent the wood square. Then you add a JLabel with an Icon of the chess piece to the square. This posting of a simple Chess Board might give you some ideas.
Edit:

Would that be why the cell looks like it's printing ...?

Probably. The default for a JLabel is to display the icon followed by the text.
You can change this behaviour by using:
setHorizontalTextPosition(JLabel.CENTER);
setVerticalTextPosition(JLabel.CENTER);

in the constructor of your renderer. Then the text will be centered over the icon.


text:
Q: how to access view controller functions in the app delegate in swift 4
Xcode gives me the error "Instance member 'pauseGame322' cannot be used on type 'ViewController'; did you mean to use a value of this type instead?"

func applicationWillTerminate(_ application: UIApplication) {
    // Called when the application is about to terminate. Save data if  appropriate. See also applicationDidEnterBackground:.
    ViewController.pauseGame322(ViewController)
}

A: Try to add observer in your view controller
NotificationCenter.default.addObserver(self,
selector: #selector(applicationWillTerminate),
name: .UIApplicationWillTerminate,
object: nil)

callback
@objc func applicationWillTerminate() {

     self.pauseGame322()

}


text:
Q: Convert Visual Studio 2008 solution to 2010 WITHOUT Visual Studio? This question looked promising but the accepted answer requires using devenv, which is part of Visual Studio.
Say I have a build system that I don't want to waste a Visual Studio license on, but I want to have it automatically convert 2008 solution files to 2010 and build them using msbuild from Windows SDK 7.1. How can I do it?

A: Someone wrote a tool for that.
I suggest trying it on some dummy project, before converting the real one.
http://stevedunns.blogspot.co.il/2010/02/tool-to-switch-project-files-between.html


text:
Q: Non-existing picture appearing on table of contents I'm having a problem with a Microsoft Word document. My document has at least 60 pictures that's why I have a table of contents for all those pictures. Recently I have replaced one of the images and now the table of contents is showing a reference to a picture that does not exist in the document. I can't find it anywhere.

This is what is happening. I have a reference to a Figure 11 that does not exist. I've already updated the entire document references and still no luck. I've also hold the Ctrl button and clicked on the reference which leads to nowhere. Just for the record, I have the track changes setting on.
Does anyone know how to fix this?

A: Ok guys I've realized that this problem was realated to the Track Changes setting being on. Since MS Word was keeping track of all changes, when removing a picture you need to Right Click the area where that removal happened and press Accept Removal.


text:
Q: How can I look up a reference to a remote actor from a different system in akka? I have an ActorSystem running on port 2552 and another running on port 2553. Each of them create an Actor which instantiates a singleton object. I now want to create another system that manages both of these systems and can reference these actors in order to make use of the singletons simultaneously.
I know the actors are listening on the port because it gives me a log like this for each port
 Remoting started; listening on addresses :[akka.tcp://singletonApplication@127.0.0.1:2552]

and it when I look at the object using the debugger the actor shows up like this
 Actor[akka://singletonApplication/user/singleton]

I create the manager system using
 ActorSystem system = ActorSystem.create("managerSystem");

but when I try and reference the remote actors by the following line
 system.actorSelection("akka.tcp://singletonApplication@127.0.0.1:2552/user/singleton");

It gives me this in the object
 ActorSelection[Actor[akka://managerApplication/deadLetters]/user/singleton]

and when I try and send it a message it gives me a deadletter error log in the console
I am not really sure what I doing wrong but it looks like the system I am trying to use to look up the remote actors is messing up my actorSelection call. Do I need to be within the same system in order to reference a remote actor? I thought this was one of the points to using akka?

A: You are saying that you are accessing the remote actor from a different system. But i see that you are using 127.0.0.1 to address the remote system. 127.0.0.1 is a special loopback address and refers to the local machine. So you need to give addressable IP to access remote machine.
For more on Loopback check this http://en.wikipedia.org/wiki/Loopback
This is also clearly stated in the documentation:
"Note
Be sure to replace the default IP 127.0.0.1 with the real address the system is reachable by if you deploy onto multiple machines!
"


text:
Q: Ajax request not running used in codeigniter 4 I made an ajax request as below, but the request but it's not running. So I tried to 'console.log'  but it's not working.
                    <input type="text" class="form-control" id="search">
                      <table class="table table-hover">

The above is the input field and below is the script tag.
<script type="text/javascript">

                    var base_url = "<?php echo base_url(); ?>";

                      $(document).ready(function(){

                        $("#search").keypress(function(){
                            console.log('ko') //this console is running
                          $.ajax({
                              console.log('ko') //this console is not running
                            //   url:"<?php //echo base_url( 'Parts/search')?>",
                              type:'POST',
                              data:{
                                name:$("#search").val(),
                                },

                            success:function(data){
                              $("#output").html(data);

                            }
                          });
                        });
                      });
                    </script>


text:
Q: Is there an algorithm to translate Dowker-Thistlethwaite notation into braid notation? I am interested in translating DT-codes into braid words. As an example for the trefoil knot: $\{4,6,2\}$ into $\{1,1,1\}$, where the latter stands for the braid word in the braid group of two strands.
Is there an algorithm for this? The low-dimensional topology computation programs like SnapPy or SageMath can do this indirectly but I could not figure out how.

A: Sage allows to do this using the hidden method
_braid_word_components_vector of knots and links.
Example:
sage: Kn = Knots()
sage: dt = [4, 6, 2]
sage: K = Kn.from_dowker_code(dt)
sage: braid_word = K._braid_word_components_vector()
sage: braid_word
[1, 1, 1]

The above few lines can be turned into a function:
def braid_word_from_dt(dt):
    r"""
    Return the braid word corresponding to this DT code.

    A DT code is a Dowker-Thistlethwaite code.

    INPUT:

    - ``dt`` -- a dt code, as a list

    OUTPUT: the braid word for the corresponding knot.

    EXAMPLES::

        sage: dt = [4, 6, 2]
        sage: braid_word_from_dt(dt)
        [1, 1, 1]
    """
    return Knots().from_dowker_code(dt)._braid_word_components_vector()

Usage:
sage: braid_word_from_dt([4, 6, 2])
[1, 1, 1]

A: I have somehow overlook the function braid_word() in snapPy which also does the job. Although the input is a bit more complicated.
Example as a python script:
import snappy

def dt_to_braid(dt):
    return snappy.Link(dt).braid_word()

#The input dt has to be a string of the form: 'DT: [(i1,...,in)]'
#The output is [b1,...,bk]
#
#Example for the trefoil knot:
#dt_to_braid('DT: [(4,6,2)]') yields
#[1,1,1]


text:
Q: Limit django rest framework api according to payment plans I have some dynamically added features performed by an admin user, which i will associate with certain endpoints.
What would be a good approach to solve this problem?
The problem is how can i do this association?

A: I did the following:
1) Stablish some constants strings representing what I know as 'features'. i.e:

*

*feat1 = 'f1'

*feat2 = 'f2'

2) Used this to create FEATURE_CHOICES into a Feature model. (This one would be created dynamically by admin users. Such users will associate the corresponding choice, and add additional representative metadata, useful for user-agents.
FEATURE_CHOICES = ((feat1, 'Awesome feature'), (feat2, 'Just a regular feature'))

3) On my views, added the corresponding value as a class variable: api_feature = feat1
4) Created a custom DRF Permission Class that implements a has_feature function which checks if the user's plan has such requested feature.
This is the solution that i've implemented for now. All constants were managed by django-decouple.


text:
Q: Multiple problems with annyang For my school, we have been given the task to make a 'Decision Room', much like the one in the George W. Bush Decision Room in the SMU library. For the decision room I have been creating, I have chosen to make it voice activated using annyang (kind of a cheat code it is so easy).
BUT! I have been problems getting it to understand two different words individually. When I say '2', it redirects me to the next decision, but 1 will not work.
Also, I am trying to play a little tone that I have after it registers your speech, before the redirect.
Here's my code:
<script>
window.onload = function(){
if (annyang) {
    var commands = {
        '1': function() {document.getElementById('Turn.mp3').play();
            window.location = "room1a.html";
        }
    };
    annyang.addCommands(commands);
    annyang.start();
}
}
</script>

<script>
window.onload = function(){
if (annyang) {
    var commands = {
        '2': function() {document.getElementById('Turn.mp3').play();
            window.location = "room1b.html";
        }
    };
    annyang.addCommands(commands);
    annyang.start();
}
}
</script>

A: If you do it like this, the 2nd call of
annyang.addCommands(commands);

overwrites the first one. That's the reason it does not recognize it, when you say "one".
See documentation here.

initialize annyang, overwriting any previously added commands

A possible solution is, to add all your desired voice-commands in one commands-object:
<script>
window.onload = function(){
if (annyang) {
    var commands = {
        '1': function() {document.getElementById('Turn.mp3').play();
            window.location = "room1a.html";
        },
        '2': function() {document.getElementById('Turn.mp3').play();
            window.location = "room1b.html";
        }
    };
    annyang.addCommands(commands);
    annyang.start();
}
}
</script>


text:
Q: My Android application is crushing if the database is not populated I got some problem with my database in my Android application. Perhaps, my application is working but let me explain you.
Here are just parts of the code from my app.. i don't want to paste the whole it's not needed.
private SQLiteStatement insertStmt;
   private static final String INSERT = "insert into "
      + TABLE_NAME + "(name,surname) values (?,?)";

public DataHelper(Context context) {
      this.context = context;
      OpenHelper openHelper = new OpenHelper(this.context);
      this.db = openHelper.getWritableDatabase();
      this.insertStmt = this.db.compileStatement(INSERT);
    }

public long insert(String name, String surname) {
      this.insertStmt.bindString(1, name);
      this.insertStmt.bindString(2, surname);
      return this.insertStmt.executeInsert();
   }

@Override
      public void onCreate(SQLiteDatabase db) {
         db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_NAME +
          "(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, surname TEXT)");
      }

So when i try to run my app i get Force close, but when i put manually :
dh.insert("test", "ooo");

..in the onCreate method in my main activity everything is fine and working.
So, the conclusion is that i must put some value for the first time i run the app so it can work properly. I thought maybe to update that row with the new informations that i insert later through some TextView's from the app but i'm wondering if there is smarter solution than this?

A: Obviously there is no error with your insert, at least it's not what crashes your App.
Since you're getting a CursorIndexOutOfBoundsException, it means you have somewhere a select query and try to move or set it before checking if it's has any rows at all.
This usually happens if you move the cursor to a non-existing index, i.e. cursor.moveToFirst()  while your cursor is empty or cursor.move(n) where n is bigger than cursor.getCount()-1
Before moving or accessing a cursor you ALWAYS have to check if any rows are returned!
Cursor c = db.query(...);
if(c!=null && c.getCount()>0) {
    c.moveToFirst(); // (or c.move(0))

    // Do your cursor operations here!
}

Obviously your insert fails for some reason, you can easily check this, with:
long insertId = dh.insert("test", "ooo");

if(insertId > 0) {
    // insert was successfull
} else {
    // insert failed
}


text:
Q: belongs_to relation not firing after_update when nullify In the project i'm working on i have 2 models, user.rb and job.rb.
The user model is related to job, a user can have many job requests and a user can be hired in many jobs but only one user per job can be hired.
User.rb:
  has_many :job, dependent: :nullify, :foreign_key => "hired_contractor_id"

Job.rb:
  belongs_to :hired_contractor, class_name: "User", optional: true

Expected behaviour:
When a user is deleted (which that user is hired in a job) i want to change the job status.
For that i'm trying with after_update or after_save but none is fired by a nullify effect on a belongs_to relation.
What am i mising?

A: I ended up removing the dependent: :nullify because i found that it doesn't trigger any parent callback.
If you try to update every job in a before_destroy (user.rb) you will not find any job because the relation is gone.
My solution was to remove dependent: :nullify so i still have the job relations to find them in a before_destroy on user.rb and update every job :status and :hired_contractor_id columns manally.
Not the best solution but one that works finally.


text:
Q: R: User Defined Function to Find a string that contains two character strings I was trying to write a function in R that reads two words from me and then prints out all strings that contains both of those two words.
I have a data.frame named x and first column is where I need to search the strings from.
I wrote:
findcontain <- function{
Clue1 <- readline(prompt= "Enter the first Clue.")
Clue2 <- readline(prompt= "Enter the second Clue.")
Clues <- paste(Clue1, "&", Clue2, sep="")
grep(Clues, x[1,])}

This isn't working... What did I miss? Please help.

A: Depending on what you exactly want, you might need to adapt this a bit, but this might help you:
findcontain <- function(x){
  Clue1 <- readline(prompt= "Enter the first Clue.")
  Clue2 <- readline(prompt= "Enter the second Clue.")

intersect(grep(Clue1, x$col1) , grep(Clue2, x$col1)) }

 x<-data.frame(col1=c("this is an example","another example","bla","blabla","tree",
"house","house and tree"))

findcontain(x)


text:
Q: Python - can call same class twice(or more) in thread? I don't very understand the classes logic in python but cannot answer on web.
I have create a class to generate person info:
class person:
    def fristnameGen(gender):
        ...
    def emailGen(firstname,surname):
        ...

i create a bot to call it like this:
from person import *
class bots:
    def __init__(self):
        self.person = person()
    def createDB(self):
        print(self.person.name)
        #do something...

finally i call it by a button with thread
from bots import *
import threading
class Panel:
    def __init__(self):
        self.top = tk.Tk()
        self.bot = bots()
        self.buildUI()

    def foo(self):
        self.bot.createDB(self.stringPhone.get())

    def threadTheAction(func, *args):
        t = threading.Thread(target=func, args=args)
        t.setDaemon(True)
        t.start()

    def buildUI(self):
        Button = tk.Button(self.top, text ="Start", command = lambda :self.threadTheAction(self.foo))

I get this error:
TypeError: 'Panel' object is not callable

However, i call it directly, its work
        Button = tk.Button(self.top, text ="Start", command = lambda :self.foo())

How to fix the error?
...
2. Moreover,  i tried create p1 = person() and p2= person() and print it. Found p1 and p2 is a same person, i prefer each new a class have a new one. How to generate "new person" using classes?
Thank you

A: You seem to have a lot of confusion about Object Oriented Programming in Python. Some of your methods have self parameters and some do not, seemingly at random. That's the source of your current error.
The threadTheAction method in your Panel class is getting the Panel instance passed in as its first argument, but that's named func in the method (since you omitted self). The real function you're passing as an argument gets caught in the variable argument *args. When the thread tries unsuccessfully to call it, you get an exception. Adding self before func would fix the immediate problem:
def threadTheAction(self, func, *args):

I suspect if your code got further along, you'd run into other errors with other methods without self in their parameter lists. For instance, none of the methods you've shown in person are likely to work correctly.
As for your second question, you haven't shown enough of person to know what's happening, but you're probably doing instance variables wrong somehow. With no self parameter in the methods, that's almost inevitable (since you assign to self.whatever to set a whatever attribute on the current instance). If you need help squaring that away, I suggest you ask a separate question (Stack Overflow is best when each question is self-contained) and provide the full code for your person class.


text:
Q: IntelliJ Cursive REPL over SSH Usually, I work in vim, and I ssh to a server (doing web dev) to edit code, and run the dev server, etc. I'm trying to use Intellij IDEA with Cursive plugin for Clojure, and it would be great to replicate the same type of style. (So far, I'm really, really into the Intellij + Cursive combo!)
I've used sshfs mount, but IntelliJ understands that locally, so when I try to run a Ring server from the REPL, it runs locally instead of on the server, which is not what I'm looking for.
Basically, I'd like it to work via ssh transparently - edit the code on the remote server, run the REPL remotely, etc. If that is beyond what is possible today, that's an acceptable answer too.
I've searched high and low, thinking this would be (1) a reasonably common use case and (2) solved long ago, but maybe I just don't understand the IDE and clojure well enough yet (having started not too long ago).
Mountains of thanks if anyone has any words of advice for me.

A: Cursive dev here - I'm glad you're liking it!
Cursive, mostly because of IntelliJ, is really set up for working locally. I'd be interested to know how working over sshfs works for you, IntelliJ likes to scan files a lot as it indexes, I've tried working remotely like that before and it was fairly slow, but that was with a massive Java project so YMMV. sshfs may have improved in recent years too.
Re: the REPL, the best solution I can think of would be to start the REPL on the server manually, then you could connect to that using the Remote nREPL option over an SSH tunnel. It's a little clunky when setting it up and restarting the REPL, but it should work fine. Let me know if you'd like help setting that up.
I'll think about ways that might be made more transparent, too. I suspect that it will be difficult because IntelliJ is really designed around local work.


text:
Q: PlaySpec test passing even though the result doesn't match I have written the following spec. Surprisingly it passes even though the result doesn't match
code snippet
  val controller = new UserController(mockUserRepository,mockControllerComponents,mockSilhouette)
  //val request = FakeRequest[AnyContentAsJson]("POST", "/ws/users/signup").withJsonBody(Json.parse("""{"bad": "field"}"""))//FakeRequest(POST,"/ws/users/signup").withJsonBody(Json.parse("""{"bad":"field"}"""));
  val request = FakeRequest("POST","ws/users/signup")
  println("sending request",request)
  //val result = controller.someMethod()
  val result = controller.signupUser(request)

  Await.result(result,Duration("10 secs"))
  result.map(response => {
    println("response from controller:"+response)
    response mustBe play.api.mvc.Results.BadRequest
  })

console prints
(sending request,POST ws/users/signup)
print in controller. (received request,POST ws/users/signup)
Controller returns 200OK but I am matching it with BadRequest. Still the test passes!
response from controller:Result(200, Map())
I suspect that I am not matching the result correctly. I am doing response mustBe play.api.mvc.Results.BadRequest. I know that response is Results but BadRequest is Status. But I don'w know how else to match and also why the test doesn't fail. I also tried following and can see the the values are different but even then the test passes.
  println("response from controller:"+response.header.status+" compared with "+play.api.mvc.Results.BadRequest.header.status)
        response.header.status mustBe play.api.mvc.Results.BadRequest.header.status

console print - response from controller:200 compared with 400

A: Importing members of Helpers object like so
import play.api.test.Helpers._

gives access to various utility methods to extract results from Future[Result] in tests. For example, Helpers.status can be used to extract status code like so:
val result: Future[Result] = controller.signupUser(request)
status(result) mustBe BAD_REQUEST

Another option is to use whenReady from ScalaFutures:
val result: Future[Result] = controller.signupUser(request)
whenReady(result) { _.header.status mustBe BAD_REQUEST }

Another option is to extend AsyncWordSpec and then you can map over the Future like so:
val result: Future[Result] = controller.signupUser(request)
result.map(_.header.status mustBe BAD_REQUEST)


text:
Q: What can we say about $Q$ given $Q=P+\frac{1}{2}I$ where $P \in M_n \left(\mathbb{Z}\right)$ Let $P$ be a $n\times n$ matrix with integral entries and $Q=P+\frac{1}{2}I$, where $I$ denotes the $n\times n$ identity matrix. Then what can you say about $Q$.
Is it Idempotent?
Is it Invertible?
Is it Nilpotent?
Is it Unipotent?
According to me It is not necessary that it is Idempotent, Nilpotent, Unipotent.
For a counter example take the diagonal matrix $B=\left( b_{ij}\right)$ with $b_{ii}=i$.
I claim that it is invertible.
Consider the matrix $2Q=2P+I$. Reduce each entry modulo 2. We get $I$ whose determinant is $1$ hence determinant of $2Q$ must be odd. Hence $2Q$ is invertible and hence $Q$ is invertible.
Is this method correct?
Do you have any other better method?

A: Another way to get invertibility of $Q$ is as follows:
Suppose $\lambda$ is an eigenvalue of $P$, then $\lambda+\frac{1}{2}$ will be an eigenvalue of $Q$. We will show that $\lambda \neq -\frac{1}{2}$.
Consider the characteristic polynomial of $P$ (namely $\det(P-\lambda I)$). This is a monic polynomial with integer coefficients, so by the rational root theorem, all it's rational roots must be integers. Thus $\lambda$ cannot be $-1/2$, hence $Q$ does not have $0$ as an eigenvalue. This means $Q$ is invertible.


text: Q: What steps are needed to change a WebRTC audio stream to a video stream? I am developing Audio call and video call. Just imagine 2 users are doing audio call. Is there any possible to change the audio call to a video call? What steps are needed to change audio stream to video stream?


text:
Q: How to do i need to implemnet paging for jquery grid I have a gird with user data around like 5000 users in the grid.
right now I am displaying all the users in the grid. but I need to make it like only 500 user for page.
So i need to implement paging in the grid with previous and next button on the bottom of the page.
Can any body tell me how to do this?

A: The Fluid Pager Widget, from their Infusion framework, handles this issue really elegantly on the client side.
If you want to send fewer than 5k records to the browser at a time, you would still need to bake that intelligence into your server-side code.


text:
Q: Not able to click a button using WebDriver in Java I need to click on the save button after filling some text fields. The problem is the xpath keeps on changing every time I reload the page, the id is dynamic. Please help me in clicking this button in WebDriver. Is it possible to click using the text of the button ?
Here is the firebug out-put.

Please help how to generate a target to click this button.

<button id="ext-gen432" class="x-btn-text" type="button">Save</button>

<button id="ext-gen440" class="x-btn-text" type="button">Cancel</button>

A: I would use XPath. Assuming you have only one button name Save on this page you can do:
By.xpath("//button[text() = 'Save']")


text:
Q: Jquery issue on IE10 The following jquery code works just fine on the latest version of Chrome,
On focus event of the input field it should trigger the autocompletion of the field itself using ajax to retrieve the suggestions but it does not work at all on IE10
The console is empty...
<!DOCTYPE html>

<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">

  Your city:
  <input id="city">
  Powered by geonames.org

<button name="subject" id="myBut" value="HTML">HTML</button>

  Result:

A: There are known issues with scrollTop on IE. Might this help? document.body.scrollTop is always 0 in IE even when scrolling


text:
Q: Pass a variable into AWS Shadow I am just learning about how to use shadows in AWS. So I want to be able to pass a variable into AWS so it's read by the Shadow (sorry if I'm not explaining this correctly, but I hope it makes sense).
So basically, I have the following code:
Payload = """{ "state":
    { "report":
        {"seconds" : "10",
        "size" : "20"
        }
     },
"message: "Hello World"
}"""

And I get the exact same output in the "Device Shadow state" in AWS.
So what I want to do is have seconds and size as a variable.
I have tried setting a variable as:
size = "20"

and then using it as:
Payload = """{ "state":
        { "report":
            {"seconds" : "10",
            "size" : size
            }
         },
    "message: "Hello World"
    }"""

however, this didn't work and the Classic Shadow in AWS disappeared.
Can anyone please help?
Thank you!


text:
Q: How to use Pytorch to create a custom EfficientNet with the last layer written correctly I have a classification problem to predict 8 classes for example, I am using EfficientNetB3 in pytorch from here. However, I got confused on whether my custom class is correctly written. I think I want to strip the last layer of the pre-trained model to suit the 8 outputs right? Did I do it correctly? Because when I print y_preds = model(images) in my DataLoader, it seems to give me 1536 predictions. Is this an expected behavior?
!pip install geffnet
import geffnet

class EfficientNet(nn.Module):
    def __init__(self, config):
        super().__init__()
        self.config = config
        self.model = geffnet.create_model(config.effnet, pretrained=True)
        n_features = self.model.classifier.in_features
        # does the name fc matter?
        self.fc = nn.Linear(n_features, config.num_classes)
        self.model.classifier = nn.Identity()

    def extract(self, x):
        x = self.model(x)
        return x

    def forward(self, x):
        x = self.extract(x).squeeze(-1).squeeze(-1)
        return x

model = EfficientNet(config=config)
if torch.cuda.is_available():
    model.cuda()

Sample code for printing y_pred:
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
for step, (images, labels) in enumerate(sample_loader):
    images = images.to(device)
    labels = labels.to(device)
    batch_size = images.shape[0]
    y_preds = model(images)
    print('The predictions of the 4 images is as follows\n', y_preds)
    break

A: You're not even using self.fc in forward pass.
Either just introduce it as:
def forward(self, x):
    ....
    x = extract(x)...
    x = fc(x)
    return x

Or you can simply replace the layer named classifier (this way you don't need Identity layer):
self.model.classifier = nn.Linear(n_features, config.num_classes)

Also, here config.num_classes should be 8.


text:
Q: C segmentation fault threads This is a program made in C that compiles fine using gcc filename.c -o file -pthread. However when I go to run the program is tells me there is a segmentation fault and I am not sure how to fix it. This program is meant to make random integers in an array then compare how long it takes to find the 10 largest and 10 lowest numbers using a different amount of threads for reach iteration of the program.
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <time.h>

#define arraySize 10000
#define lval 0
#define hval 50000
#define maxthread 100

int num[arraySize];
int maxs[maxthread];
int mins[maxthread];
int threadsize;
int threadnum = 0;

void fill(){
    int i;
    int tmp[hval];
    for(i = lval;i < hval;i++)tmp[i] = i;
    for(i = 0;i < arraySize;i++){
        int t= i + rand()%(hval - 1);
        int temp = tmp[i];
        tmp[i] = tmp[t];
        tmp[t] = temp;
        num[i] = tmp[i];
    }
}

void print(){
    int i;
    printf("First 10 Numbers are: \n");
    for(i = 0;i < 10;i++)printf("\t%d\n",num[i]);
    printf("\n\nLast 10 Numbers: \n");
    for(i = (arraySize - 10);i < arraySize;i++)printf("\t%d\n",num[i]);
}

void *getminmax(void *arg){
    int i,n = threadnum++;
    int max = lval,min = hval;
    for(i = n*(arraySize / threadsize);i < (n + 1)*(arraySize / threadsize);i++){
        if (num[i] > max)max = num[i];
        if (num[i] < min)min = num[i];
    }
    maxs[n] = max;
    mins[n] = min;
    printf("Threads:%d Min: %d Max%d Thread Num: %d\n",threadsize,min,max,n);
}

void search(){
    int max = lval, min = hval;
    int i;
    int start = clock();
    pthread_t threads[threadsize];
    for(i = 0;i < threadsize;i++)
        pthread_create(&threads[i],NULL,getminmax,(void*)NULL);
    for(i = 0;i < threadsize;i++)
        pthread_join(threads[i],NULL);
    for(i = 0;i < threadsize;i++){
        if(maxs[i] > max)max = maxs[i];
        if(mins[i] < min)min = mins[i];
    }
    int end = clock();
    int d = end - start;
    printf("Threads %d Min: %d Time Taken: %d \n\n",threadsize,min,max,d);
}

int main(){
    fill();
    print();
    threadsize = 2;
    threadnum = 0;
    search();
    threadsize = 10;
    threadnum = 0;
    search();
    threadsize = 100;
    threadnum = 0;
    search();
    return 0;
}

A: There are few obvious bugs in your program.

*

*As yano pointed out, t = i + rand()%(hval - 1); will produce a t in the range between 0 and arraySize + hval - 2. That later value is well outside the valid range for accessing tmp[t] and is likely the cause of the segmentation fault.
You probably meant this instead: t = (i + rand()) % (hval - 1);

*The construct below is a data race. You are not at all guaranteeing distinct ns for different threads.
  int n = threadnum++;

The usual fix for problem 2 is to pass the thread number as the arg (which you didn't use).


text:
Q: Ubuntu 16.04 freezes on shutdown I deleted "quiet splash" from GRUB_CMDLINE_LINUX_DEFAULT in the GRUB config file.
And when I reboot with the command line, I can see the commands until it reaches target reached restarting now
And then.... nothing, it freezes there. So it is not possible to shut down.
It is a dual boot of Win10 with Ubuntu 16.04
I had a similar problem on launch but I fixed it on adding acpi=off after pushing the E key in the GRUB menu.
EDIT
I changed acpi=off to acpi=noirq and this gave me a freeze on restart and when I did force shutdown and restart it gave me a purple screen with nothing. I had to edit again from the GRUB menu to put it back to acpi=off

What else can I try?

A: This started happening on my Ubuntu machine after I extended the Ubuntu partition size.
The solution is to boot from a Ubuntu live-session (boot your computer on a Ubuntu live-CD or live-USB then choose "Try Ubuntu", it may work on an installed Ubuntu too).
Then:

*

*Make sure you are connected to the Internet

*Open a new Terminal, and type the following commands (press Enter after each line):
sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install -y boot-repair && boot-repair

This should repair your GRUB and help the OS shutdown correctly.

A: try acpi=noirq
like the answer to this question: acpi power off

A: Are you using Btrfs?
I had very long shutdowns of tens of minutes after moving my 8 data disks from ext4 to Btrfs. I worked-around it by adding nocache_space to the mount options for my Btrfs mount points in /etc/fstab.

A: I too had been experiencing random freezes after switching from 14LTS to 16LTS. I ran memtest86 and disk check but all passed. Just a couple of days ago out of exasperation I decided to revert from kernel 4.9 to kernel 4.4. Since then I've not had any hanging or freezing. In fact, it also seems to me my laptop runs cooler. Don't know why or any details but so far it is working for me.


text:
Q: .net ExtensionMethodeSQL Datareader GetValueOrDefault A question about good practices, with ExtensionMethod !
i would like get values of datareader, but sometimes, i would like avoid null values, because VB.net and C# are differents, (default function doesn't exist in vb), i did this :
Imports System.Runtime.CompilerServices
Imports System.Data.SqlClient

Public Module ExtensionMethodeSQL

<Extension()>
Public Function GetValueOrDefault(Of T)(ByVal dtReader As SqlDataReader, ByVal index As Integer) As T

    If dtReader.IsDBNull(index) = True Then
        If GetType(T).IsValueType = True Then
            Dim defaultValue As T = Nothing
            Return defaultValue
        Else
            Return Nothing
        End If
    Else
        Return CType(dtReader.GetValue(index), T)
    End If

End Function

<Extension()>
Public Function GetValueOrDefault(Of T)(ByVal aString As SqlDataReader, ByVal fieldName As String) As T
    Return aString.GetValueOrDefault(Of T)(aString.GetOrdinal(fieldName))
End Function
End Module

Is that good ? something to make it better?
Not sure for using CType, is trycast better for ValueType ?
Thx


text:
Q: Dual channel linear power supply As a learning project, I'm trying to create a simple linear power supply using LM317.
The basic circuit is well documented on internet, but I want to create a variant that allows me to have multiple output channels.
One of these output channels is for internals of the power supply: powering up an INA219 to measure current drawn, an atmega328 and an LCD for display.
Ideally I want to have two independant variable output channels (1.25V - 12V) and a single internal output channel (5V).
I think the following circuit should work, on paper, but I am not sure it will be really usable in practice. I have the feeling that sharing the same input lines (and grounds) between all channels will create undesirable side effects between them, especially with ICs using spike currents like the LCD.
Here is my take at a circuit diagram:

The top part is the variable output channel, the bottom part is the internal 5V channel. They are both forked from the 15V input from a switching wall adapter.

A: Try adding input and output caps to the "precision" regulator because if you don't it may bounce current back and forth with the current drawn by lm317. if you're not familiar with pcb traces and decoupling it's recomended to add one regulator for the digital 5v line and one another for the opamp. or powerup the opamo directly from the arduino? depending the power cycles consumed. that may add complexity to the design but provide a perceptual of higher quality design isolation from 15v.


text:
Q: Are there 0-1-matrices that are not unimodular? I am just wondering if there are matrices that only consists of $0$s and a few $1$s that are not totally unimodular (TU)? I cannot come up with an example but I am not very experienced with this stuff.
In a specific case, if I have a very sparse $0-1$ matrix where every row consist of at most two $1$s and every column consists of at most three $1$s, how can I find out whether this matrix is TU?
I cannot use the four sufficient conditions for $A$ to be totally unimodular (where $B, C$ is a disjoint partition of the rows of $A$), because condition 3 might be violated:

*

*Every column of contains at most two non-zero entries;

*Every entry in is $0, +1$, or $−1$;

*If two non-zero entries in a column of have the same sign, then the row of one is in $B$, and the other in $C$;

*If two non-zero entries in a column of have opposite signs, then the rows of both are in $B$, or both in $C$.

Thank you!

A: There is a (very simple) $2 \times 2$ example where the determinant is $0$.
Any $3 \times 3$ example with all rows having two $1$'s that does not have determinant $0$ has determinant $\pm 2$.

A: Consider the matrix:
$$\begin{bmatrix}
1 & 1 & 1 & 1\\
1 & 0 & 0 & 1\\
0 & 1 & 0 & 1\\
0 & 0 & 1 & 1\\
\end{bmatrix}$$
Observe that the determinant of this matrix is two so the matrix is not totally unimodular as required.
Note: credit for this example goes to Camion for his nice characterization of TU matrices in his 1965 paper (see citation below).
Camion, P., Characterization of totally unimodular matrices, Proc. Am. Math. Soc. 16, 1068-1073 (1965). ZBL0134.25201.


text:
Q: Stopping long running stored procedure from script I have a set of maintenance tasks in several databases that are triggered by a master stored procedure.  The master stored procedure is started using sp_procoption to start on mssql startup.  Then at a specified day and time, runs the child procedures in all of my databases.
I need to update this master script.
To clean up the update procedure, and not require stopping and restarting sql (to ensure that only one instance of the master procedure is running), I would like to be able to stop the stored procedure then restart it at the end of the update script.  Restarting is not an issue, but does anyone know a way to stop the procedure from the update script?
Here is the script for my master scheduling proc:
USE master
GO
IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'weekly_maintenance_task')
    DROP PROCEDURE weekly_maintenance_task
GO
CREATE PROCEDURE [dbo].[weekly_maintenance_task]
AS
BEGIN

    SET NOCOUNT ON
    DECLARE @timeToRun nvarchar(50)
    SET @timeToRun = '02:30:00'
    DECLARE @dayToRun nvarchar(10)
    SET @dayToRun = 'SUNDAY'

    WHILE 1 = 1
    BEGIN
        WAITFOR time @timeToRun
        BEGIN
            DECLARE @dayOfWeek NVARCHAR(10)
            SELECT @dayOfWeek = CASE DATEPART(weekday, GETDATE())
            WHEN 1 THEN 'SUNDAY'
            WHEN 2 THEN 'MONDAY'
            WHEN 3 THEN 'TUESDAY'
            WHEN 4 THEN 'WEDNESDAY'
            WHEN 5 THEN 'THURSDAY'
            WHEN 6 THEN 'FRIDAY'
            WHEN 7 THEN 'SATURDAY'
            END
            IF (@dayOfWeek = @dayToRun)
            BEGIN
                EXECUTE sp_msforeachdb 'USE ?
                IF DB_NAME() NOT IN (''master'', ''msdb'',''tempdb'',''model'')
                    IF EXISTS (select * from sys.procedures where name=''database_maintenance_weekly'')
                        EXECUTE database_maintenance_weekly'
            END
        END
    END
END

GO

sp_procoption @ProcName = 'weekly_maintenance_task',
              @OptionName = 'startup',
              @OptionValue = 'on'
GO

A: You can use the kill command to kill a session.  You can find the right session with dm_exec_requests and sys.fn_get_sql().
declare @nuke_spid int

select  @nuke_spid = session_id
from    sys.dm_exec_requests r
outer apply sys.fn_get_sql(r.sql_handle) s
where   s.text like '%dm_exec_requests r%'

exec ('kill ' + @nuke_spid)

This should return Cannot use KILL to kill your own process.

A: Why run a stored procedure in an infinite loop? Just schedule a job to run your SPs at a specified date/time.


text:
Q: Vector Rasterize error using QGIS? I am attempting to convert vector files to raster format in QGIS using the Rasterize tool and am receiving the error:

ERROR 1: Wrong value for -tr parameter.

I have attached an image of the input and errors I am getting. And I am using QGIS v 3.2.3.

A: You need to set a vertical and horizontal resolution, not leave it at zero.


text:
Q: need to create multiple groups using form in angular6 I need to create multiple groups in the form. when i create a childgroup and enter an input value the same value reflect in another group i known this is due to ngModel but how to overcome this issue. there is another issue i am facing under childGroup there is 2 table when i create another childGroup and add a new table row to that childGroup this will reflect in another childGroup also.
HTML
<fieldset *ngFor="let task of tasks; let a = index">
  <legend>childGroup</legend>
  <button (click)="deleteRow(a)" class="btn btn-sm btn-circle btn-danger actionMargin rmv-btn">X</button>

      Name

        <input type="text" class="input-sm" [(ngModel)]="task.Name" name="task[a].Name" required>

      Comm

        <input type="text" class="input-sm" [(ngModel)]="task.Config.command" name="task[a].Config.command" required>

ABC

          S no.
          Label
          Value
          Dynamic
          Action

          {{i + 1}}
          <input type="text" [(ngModel)]="item.Label" name="item[i].Label" [ngModelOptions]="{standalone: true}"
              class="inputborder" required>
          <input type="number" [disabled]="item[i].boolean" [(ngModel)]="item[i].Value" name="item.Value"
              [ngModelOptions]="{standalone: true}" class="inputborder" required>
          <input type="checkbox" [(ngModel)]="item[i].boolean" name="item[i].boolean" class="check"
              [ngModelOptions]="{standalone: true}" required>Yes
          <button (click)="deleteRow(i,'port')" placement="top" tooltip="Remove Port" class="btn btn-sm btn-circle btn-danger actionMargin rmv-btn">X</button>

    <button type="button" (click)="Addrow('port')" placement="top" tooltip="Add Port" class="btn btn-sm btn-primary posi">Add
      abc</button>

</fieldset>

TS.
tasks= [];
 taskObj = { //click on a blue + button i am pushing this object to tasks
    Name: "",
    Config: {
      command: ""
    },
    artifacts : [],
    ports : []
  };
// to add a table row
  Addrow(i) {
    if (i == 'port') {
      let num = 0;
      this.taskObj.ports.push({
        Label: '',
        Value: num,
        boolean: true
      });
    } else {
      this.taskObj.artifacts.push({
        Source: '',
        Relative: ''
      })
    }
    console.log(this.tasks);
  }
//remove the table row
  deleteRow(index, i) {
    if (i == "port") {
      this.taskObj.ports.splice(index, 1);
    } else {
      this.taskObj.artifacts.splice(index, 1);
    }
  }

I the HTML code i have not add 'XYZ' table code because its same as 'ABC' table. how to implement validation to this loop within loop. Please help me with this issue.


text:
Q: imagio throws an error when i try to extract text I am trying to package a computer vision software using pyinstaller. But python-imagio from easyocr seems to have a problem with something I suspect is handling formats. The Gui runs fine. I am able to capture images. But after capturing, when it gets to text extraction, it throws an error message and exits. I have followed the prompt to set the overwrite parameter to true in the format.py file, but this still won't cut it. Has anyone encountered the same problems with imageio? Please, I need feedback.
Here's the error message I get when I run from my command line:
Traceback (most recent call last):
  File "main.py", line 167, in run
  File "main.py", line 35, in ocr_text
  File "easyocr\easyocr.py", line 383, in readtext
    img, img_cv_grey = reformat_input(image)
  File "easyocr\utils.py", line 698, in reformat_input
    image = os.path.expanduser(image)
  File "easyocr\imgproc.py", line 12, in loadImage
    img = io.imread(img_file)           # RGB order
  File "skimage\io\_io.py", line 53, in imread
  File "skimage\io\manage_plugins.py", line 207, in call_plugin
  File "skimage\io\_plugins\imageio_plugin.py", line 10, in imread
  File "imageio\core\functions.py", line 159, in imread
    format : str
  File "imageio\core\imopen.py", line 194, in imopen
  File "imageio\config\plugins.py", line 101, in plugin_class
  File "importlib\__init__.py", line 127, in import_module
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Prospero\Desktop\occulus_App\dist\main\imageio\plugins\freeimage.py", line 513, in <module>
    _create_predefined_freeimage_formats()
  File "C:\Users\Prospero\Desktop\occulus_App\dist\main\imageio\plugins\freeimage.py", line 477, in _create_predefined_freeimage_formats
    formats.add_format(format)
  File "imageio\core\format.py", line 659, in add_format
    if overwrite:
ValueError: A Format named BMP-FI is already registered, use `overwrite=True` to replace.


text:
Q: Netbeans Object Explorer equivalent of Visual Studio Object Explorer Is there a Netbeans Object Explorer equivalent of the Visual Studio Object Explorer?  If not is there one in any of the Eclipse releases (i.e. Helios)?
Just a useful tool that I use a lot in Visual Studio and miss in Netbeans.  I have to use the intellisense to look for classes from the code editor.
Screenshot of VS2008 Object Explorer:

Thanks
Andez

A: Yes it is:

*

*Navigator Window - shows all members, methods etc. of your class

*Javadoc Window - shows the javadoc (there's one for showing the sourcecode as well, also shows up eg. C/C++ documentation)

*Typing eg. System. will show you all methods / members of this class, including full javadoc of it

*Classes Window - Class-browser (C/C++)

*ctrl + left mouse will open the full sourcecode of the file, additional it will be displayed at the Navigation Window (see above)

*Open Libraries in the tree view shows you all libraries of you project, you now can browse through all your packages, classes, interfaces, methods, fields, ... as you much as you need

Here's a goog screenshot from the internet: http://pliki.onet.pl/zdjecia/pliki/n/netbeans-cpp.jpg (showing C/C++)


text:
Q: Error while installing jdeveloper 12 c in windows 10 Since .exe file is not working directly i extracted jdev_suite_122110_win64.exe file and executed the command in command prompt as mentioned in this question
C:\PROGRA~1\Java\jdk1.8.0_25\bin\java.exe -jar install/modules/ora-launcher.jar DISKCNT=1 JRE_COMPONENT=oracle.jdk,oracle.jre

But i am getting an error in command prompt

Invalid variable(s): DISKCNT,JRE_COMPONENT

is this is the problem with windows 10 installation?
is there another way to install jdeveloper in windows 10?

A: I found using the generic installer and running from an admin level command prompt via
E:\Program Files\Java\jdk1.8.0_111\bin> java -jar e:\downloads\jdev_suite_122120.jar

worked ok (amend for your environment and java versions).


text:
Q: Why this slowness of .Call in R? I have created a DLL with Haskell. It exports two functions:

*

*readXLSX: takes as arguments a xlsx file name, a sheet name, and returns the contents of the sheet in a R list

*readXLSXbig: no argument, this is the same function as readXLSX but it always read the sheet named Sheet 1 of a file named big.xlsx
First, let's try readXLSX on a small file:
> library(readxl)
> library(microbenchmark)
> microbenchmark(
+   readxl = read_xlsx("example.xlsx", "Sheet1", col_types="list", col_names=FALSE),
+   haskell = .Call("readXLSX", "example.xlsx", "Sheet1"),
+   times=2
+ )
Unit: milliseconds
    expr      min       lq     mean   median        uq       max neval cld
  readxl 9.294365 9.294365 9.660375 9.660375 10.026385 10.026385     2   b
 haskell 2.164942 2.164942 2.593681 2.593681  3.022419  3.022419     2  a

Well, it is faster than readxl (not surprising because readxl provides more features, and tests for the existence of the file, etc).
Now, let's try on the file big.xlsx, which is bigger:
> microbenchmark(
+   readxl = read_xlsx("big.xlsx", "Sheet 1", col_types="list", col_names=FALSE),
+   H1 = .Call("readXLSXbig"),
+   H2 = .Call("readXLSX", "big.xlsx", "Sheet 1"),
+   times=2
+ )
Unit: milliseconds
   expr        min         lq       mean     median        uq       max neval cld
 readxl  143.74213  143.74213  144.05025  144.05025  144.3584  144.3584     2  a
     H1   33.38596   33.38596   68.60333   68.60333  103.8207  103.8207     2  a
     H2 8845.17038 8845.17038 9149.19542 9149.19542 9453.2205 9453.2205     2   b

In fact, the results of this benchmark are quite variable (I don't know why) but I always observe the same behaviour: readXLSXbig is faster than readxl and readXLSX is very slower.
Let me recall that readXLSXbig does exactly the same thing as readXLSX; the only difference is that the file name big.xlsx and the sheet name Sheet 1 are already given in readXLSXbig:
readXLSXbig :: SEXP V 'R.Vector
readXLSXbig = unsafePerformIO $ do
  fcellmap <- xlsxSheetToFormattedCellMap "big.xlsx" "Sheet 1"
  formattedCellMapToRList fcellmap fcellToCellValue 0

readXLSX :: SEXP s 'R.String -> SEXP s 'R.String -> SEXP V 'R.Vector
readXLSX file sheet = unsafePerformIO $ do
  fcellmap <- xlsxSheetToFormattedCellMap (fromSEXP file) (fromSEXP sheet)
  formattedCellMapToRList fcellmap fcellToCellValue 0

Why such a difference ? readXLSX takes ~9 seconds on the big file while readXLSXbig takes only ~70 milliseconds. On the small file example.xlsx, we have seen that readXLSX takes <3 milliseconds, therefore there are not 9 seconds wasted to read the file name and the sheet name.

A: TL;DR: unsafe stuff is unsafe.
This code
readXLSXbig :: SEXP V 'R.Vector
readXLSXbig = unsafePerformIO $ do ...

declares a constant expression, which will most likely be evaluated only once in the whole program. Each subsequent call after the first one can either re-execute the do ... action, or return the previously computed value without re-executing anything.
Essentially, GHC is caching your whole spreadsheet.
unsafePerformIO action tells the compiler that we don't care about when action is run, or how many times it is run, since the IO action will never perform important side effects, and will always return the same result. We are telling the compiler "I know that this is potentially unsafe, but do it anyway -- I'll take the responsibility".
As an ugly, ugly fix, you can add a dummy argument and pray that GHC does not cache previous results.
The actual fix would be to remove the unsafe stuff, and return a proper IO (...) type. In this way we do not lie to the compiler, which will do the right thing. The FFI machinery should still make that callable from R.


text:
Q: Rails: Nested Form for 2 Scaffolded Models? How do I create a nested form for 2 scaffolded models?
I have a Syllabus model, which has many Missions. Previously, the only way to create Missions was through the Syllabus nested form (which I made with Railscasts). Yesterday, I decided that users should be able to create Missions by itself, so I scaffolded the Missions while skipping the migrations, so it created all the controllers and views for the existing Missions Model.
So here's the problem: I can now create Missions by itself, but when I try to create Missions through the Syllabus nested form, it gives me an error "undefined method `difficulty' for #<\Mission:0xb372ffc.>" I'm guessing it's trying to pass in the Syllabus attributes to the Missions attribute, which isn't defined in the Missions schema. (difficulty is an attribute only for Syllabus).
To sum up: Nested forms worked with "builder" when I only had Model for Missions, but when I scaffolded the Missions so it could exist by itself, I couldn't use the nested form.
Because there were more than a couple files that may affect this, I created a gist.
https://gist.github.com/2631734
Btw, these are the params that should be passed in
{"utf8"=>"✓",
"authenticity_token"=>"YxkzNmIJl0jBA467tdHP2zqNv22DgKrzSx+WCFgwKtk=",
"syllabus"=>
    {"category"=>"Technology and Internet",
    "difficulty"=>"Beginner",
    "title"=>"missions testing",
    "description"=>"deccrip",
    "missions_attributes"=>
        {"0"=>
            {"_destroy"=>"false",
            "title"=>"plz",
            "content"=>"<p>\r\n\tdad</p>\r\n"
            }
        }
    },
    "commit"=>"Create Syllabus"
}

A: My best guess is that creations in
current_user.creations.build(params[:syllabus])

refers to a collection of mission instead of syllabus. Its kindof hard to determine without the full error and user model.

A: I figured it out, but it is really messy... I'm sure there's a better way to do it, but after struggling with this for a few days, I'm more than happy with this solution:
  @syllabus = Syllabus.new(:title => params[:syllabus][:title], :category => params[:syllabus][:category], :difficulty => params[:syllabus][:difficulty], :description => params[:syllabus][:description], :author_id => current_user)

  @syllabus.save!

  params[:syllabus][:missions_attributes].each do |a, b|

    @mission = Mission.new(:title => b[:title], :content => b[:content], :syllabus_id => @syllabus.id, :author_id => current_user, :category => @syllabus.category)

    @mission.save!

    end


text:
Q: A question on irreducible unitary representations of the unitary group $ U(n)$ Let $n$ be a positive integer and $U(n)$ be the group of $n\times n$ unitary matrices. I have two question regarding the irreducible unitary representations of $U(n)$.

*

*Is there any irreducible unitary representation $\pi$ of $U(n)$ such that $1<\dim \pi < n$, where $\dim \pi$ is the dimension of the corresponding representation space.

*Let $\pi_1:U(n)\to GL_n(C)$ and $\pi_2:U(n)\to GL_n(C)$ be defined by
$$\pi_1(u)=u,~~~\pi_2(u)=\overline u,~u\in U(n).$$
Here $\overline{u}$ is the conjugate matrix of $u$.
Clearly, $\pi_1$ and $\pi_2$ are two irreducible unitary representation  of $U(n)$ where the  dimension of the corresponding representation space is $n$. Are these all irreducible unitary representation  of $U(n)$ (upto unitary equivalence) where the dimension of the corresponding representation space is $n$?
I know that there is a Weyl dimension formula for  irreducible unitary representation  of $U(n)$.
But I was not able to solve the above questions using that formula. Also I am very new in this area. Any help or reference will be highly appreciated.
Thanks in advance!


text:
Q: UIModalPresentationStyle.PageSheet does not display ViewController content I currently have a segue that presents a VC modally in PresentationStyle.PageSheet. I have done this both programmatically and with just the storyboard. I get the same result with both approaches, the modal pop over presents itself but does not show any content inside the UIView from the VC. It will only show the background color of the view and that is all. I also want to point out that everything is displayed if I do a default modal segue (full screen) but fails with page sheet presentation style or with using UIPopoverController. Here are some screen shots that show what I am talking about.
This is what it looks like in the storyboard:

This is what it looks like in the simulator and on an actual ipad:

Here is what my coding approach looked like:
@IBAction func addPickUp(){
    var addPickupVC = self.storyboard?.instantiateViewControllerWithIdentifier("pickup") as AddPickupViewController
    addPickupVC.modalPresentationStyle = UIModalPresentationStyle.PageSheet
    self.presentViewController(addPickupVC, animated: true, completion: nil)
}

This written in swift for ipad ios8.
What am I missing here? Any constructive feed back is appreciated!
EDIT: Here is the document outline of the VC that is to presented modally.

A: Your code for presenting popover is correct.
Probably there is problem with AutoLayout constraints.
As you can see your popover is presented but label is missing.

*

*Remove your AutoLayout (they will be auto generated) and see if the label will be visible now

*Try to add new label. Drag and drop it, and don't specify any constraints

*Debug your view

*

*Click "Debug view hierarchy" button at the debug panel

*Now you can see your view hearty. Select your label, if it's present and see it's constraints.

*Check your AutoLayout constraints and Label is present in correct Size Classes
Size classes is shown bellow UI designer. In my case it's (Any Any).
It means that it's for all sizes and all devices.
Also check that your constrains is not removes at runtime.
You can see it on inspector in right side.

A: In the storyboard, you can simply control drag a connection from your button to your presented Viewcontroller. There's no reason to have a @IBAction for this. If you use the InterfaceBuilder  approach you can optionally set the presentation style on the segue to PageSheet.


text:
Q: Warning on git bash start "bash: C:/Users/RS3/Anaconda3/etc/profile.d/conda.sh: No such file or directory" Whenever I open git bash I get the following warning:
bash: C:/Users/RS3/Anaconda3/etc/profile.d/conda.sh: No such file or directory
The problem is that I uninstalled Anaconda, because I installed independent python, which resulted in giving that error.
How to remove this Warning.

A: Check the content of ~/.bashrc (which was mentioned here)
Maybe that (or ~/.profile, mentioned here) includes a command for that old uni uninstalled program.
Remove those lines, and try to open again a git bash session.

A: To remove that warning, simply erase the file path string in the .bashrc file using nano command. Here's how:
Steps to remove that warning:

*

*Open Git Bash and check .bashrc location by typing ~/.bashrc into git bash.

*Navigate to folder where .bashrc file is located.

*Type nano .bashrc

*Erase the string that says C:/Users/RS3/Anaconda3/etc/profile.d/conda.sh

*Press ctrl+O to save .bashrc file and then ctrl+X to exit.

When you reopen git bash nothing should appear because .bashrc doesn't have that path in it anymore. Also, if conda commands were working before it will still continue to work after erasing this.


text:
Q: Cannot convert the "Microsoft.SharePoint.Client.ClientResult`1[System.IO.Stream]" to type "System.Byte[] I have the following PnP script to get the list items attachments from a list name "tickets" and save them locally inside a folder named "C:\Attachments" :-
        $ApprovalListItems = Get-PnPListItem -List "tickets" -PageSize 1000 -ScriptBlock { Param($items) $items.Context.ExecuteQuery()} | ForEach-Object {

        $ctx = Get-PnPContext
        $spSourceWeb= Get-PnPWeb

        $ItemAttachmentURLPrefix = 'https://******.sharepoint.com/Lists/tickets/Attachments/'+$_['ID']+'/'
        $attachmentCollection = ForEach-Object{Get-PnPProperty -ClientObject $_ -Property "AttachmentFiles"}

        $AttachmentSeq = 0
        ForEach($Attachment in $attachmentCollection)
        {
        Write-Host "`tDownloading Attachement: " $attachment $ItemAttachmentURLPrefix

        $AttachmentSeq++

        $AttachmentDataObj = "" | Select "Attachment Seq", "JDE Company", "Vendor Number", "Vendor Invoice Number", "Attachment Name", "Attachment System Name", "Job-run Date/Time Stamp"
Write-Host $Attachment.FileName
        $file = Get-PnPFile -Url ($ItemAttachmentURLPrefix + $Attachment.FileName)
        $bytes = (Get-PnPFile -Url ($ItemAttachmentURLPrefix + $Attachment.FileName)).OpenBinaryStream()
        $name = "C:\Attachments\"+$Attachment.FileName
         $fs = new-object System.IO.FileStream($name, "OpenOrCreate")
        $fs.Write($bytes, 0 , $bytes.Length)
        $fs.Close()
        $stream = $streamResult.Value
        Write-Host $file.Name
        Write-Host $stream.Name
        }
        }

but this is raising the following exception:-
Cannot convert argument "array", with value: "Microsoft.SharePoint.Client.ClientResult`1[System.IO.Stream]", for
"Write" to type "System.Byte[]": "Cannot convert the "Microsoft.SharePoint.Client.ClientResult`1[System.IO.Stream]"
value of type "Microsoft.SharePoint.Client.ClientResult`1[[System.IO.Stream, mscorlib, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089]]" to type "System.Byte[]"."
At line:22 char:9
+         $fs.Write($bytes, 0 , $bytes.Length)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument

any advice?


text:
Q: Custom hook is not a function React When I try and call a function from my custom hook I get back an error when the screen loads saying setAuth is not a function.
useAuth.js
import { useContext } from "react";
import AuthContext from "../context/AuthProvider";
const useAuth = () => {
  return useContext(AuthContext);
}
export default useAuth;

login.js
import useAuth from '../hooks/useAuth';
...
const Login = () => {
 const { setAuth } = useAuth();
 ....
 setAuth({ email, password, accessToken });
 ...
 }

If I try and display typeof(setAuth) I get undifined.

A: You need to ensure your AuthContext has a setAuth function. Where you are calling your AuthContext.Provider you must provide setAuth function in the value prop
<AuthContext.Provider value={{ setAuth }}>

You can then access setAuth
const useAuth = () => {
 const { setAuth } = useContext(AuthContext);
 return setAuth
}

login.js
const Login = () => {
 const setAuth = useAuth();
 ....
 setAuth({ email, password, accessToken });
 ...
 }


text:
Q: Use the type parameter of the object in a default interface method I want to compose two codecs (code below) together, so they must have compatible types to fit together. The code works but I had to use the line Codec<F,T> c = this; for it to work otherwise the compiler didn't seem to understand correctly the type parameters (and restrictions on codec2). I'm glad the code compiles but is there a cleaner way to achieve this?
/**
 * Represents a coder-decoder from a format F to a format T
 */
public interface Codec <F,T> {
    T encode(F obj);
    F decode(T obj);

    /**
     * Compose two codecs with types <F,T> and <T,E> to a codec with type <F,E>.
     * @param codec2 The second codec
     * @return the new codec
     */
    public default <E> Codec<F,E> compose(Codec<T,E> codec2) {
        Codec<F,T> c = this;
        return new Codec<F,E>() {
            public E encode(F obj) { return codec2.encode(c.encode(obj)); }
            public F decode(E obj) { return c.decode(codec2.decode(obj)); }
        };
    }
}

A: You're declaring an anonymous inner class that implements the Codec interface.
return new Codec<F,E>() {
    public E encode(F obj) { return codec2.encode(c.encode(obj)); }
    public F decode(E obj) { return c.decode(codec2.decode(obj)); }
};

Within the body of that anonymous class declaration, this refers to the instance of this anonymous inner class, ie. of type Codec<F, E>.
Use Codec.this to refer to the instance of the enclosing class (the interface in this case).
public E encode(F obj) {
    return codec2.encode(Codec.this.encode(obj));
}

public F decode(E obj) {
    return Codec.this.decode(codec2.decode(obj));
}


text: Q: Setting a GuildMembers Nickname new here. I utilize DSharp for writing my first Discord Bot. I can't for the life of me seem to figure out how to set the GuildMembers Nickname. I am able to get it, however I can't figure out how to set it. Anyone have any ideas? Thank you so much in advance!


text:
Q: Component K2 is damaged, says class K2HelperHTML not found My Joomla powered website was hacked several days ago, after it was cleaned and restored, a problem emerged.
On back-end, when I click Components -> k2 and an fatal error appears:
Fatal error: Class 'K2HelperHTML' not found in ~/administrator/components/com_k2/k2.php on line 77

I compare this k2.php file with a working site's k2.php but no differenced was found.
Then I inpsected the file where class K2HelperHTML was defined, which I believe is ~\administrator\components\com_k2\helpers\html.php, it doesn't show any differenct from a working site's corresponding file.
Now I'm stuck here, what should I do next to repair this.

A: Have you tried reinstalling the most recent version? That would be a good place to start. Simply use the Joomla installer to install the latest version.

A: I just encountered same problem with fresh installed component and solution for me was pretty easy. All I had to do, was clear application cache.
To do it go to System -> Clear Cache and then click Delete all.


text:
Q: How do I enable data downloads from a jupyter webapp without writing on the server? I am writing a web app with jupyter-lab, ipywidgets, and voila.
In this web app, after taking instructions by the user, the notebook generates some data (a dictionary) that the user needs to download (as a .json file).
The simple solution I found online is to write a file on the server with the content and provide the user with a link. However, I think this is super ugly, and very inefficient or dangerous if many users run the web app at the same time.
I wonder if there is a way to create a download option for the user without writing anything on the server-side.
Does anyone have some clue?
Thanks in advance,
Lorenzo

A: Just convert your file to be downloaded with pybase64 (file=base64.b64encode...) then ipywidgets
 HTML("<a download='name.txt' href='data:text/ascii;base64,%s'> download/>" %(file,)}


text:
Q: Printf statement in for loop So I'm trying to compare the values of these 2 arrays, and I created a test comparing each element of each array to each other. However I only want the printf statement to print once only if all the elements of each array are equal to each other.
This code prints the statement for each element that is equal, but I only need it to print once if all the elements are the same. What should I do?
int MatrixEqualsActual[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int MatrixEquals[3][3] = {{3, 5, 9}, {1, 2, 6}, {9, 0, 1}};

int i, j;
for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
        if(MatrixEqualsActual[i][j] == MatrixEquals[i][j])
        {
            printf("PASSED (2/2): MatrixEquals()\n");
        }
    }
}

A: Just use a flag, and print only if it is set!
Like:
...
bool flag = true;
for (i = 0; i < 3; i++)
{
    for (j = 0; j < 3; j++)
    {
        if(MatrixEqualsActual[i][j] != MatrixEquals[i][j])
        {
            flag = false;
            break; // we break since we already know that at least one element doesn't match.
        }
   }
}
if(flag)
{
    printf("PASSED (2/2): MatrixEquals()\n");
}

Just remember to #include <stdbool.h> or you will not be able to use boolean type in C.
If you don't want to include that, an int variable will do just good!

A: You can keep a flag in the loop that says whether or not the matrices are equal:
int areEqual = 1;
for(...){
    for(...){
        if (MatrixEqualsActual[i][j] != MatrixEquals[i][j]){
            areEqual = 0;
            break; //stop checking by breaking out of the loop
        }
    }
}
if (areEqual) printf("They're the same matrix\n");

A: There are three possible ways to implement this without using break - In C/C++ break can only terminate the innermost loop, which is not really what you are after.
Version 1 using a simple return:
int i, j;
for (i = 0; i < 3; i++) {
   for (j = 0; j < 3; j++) {
      if (MatrixEqualsActual[i][j] != MatrixEquals[i][j])
      {
          return;
      }
   }
}
printf("PASSED (2/2): MatrixEquals()\n");

Version 2 using goto:
int i, j;
for (i = 0; i < 3; i++) {
    for (j = 0; j < 3; j++) {
       if (MatrixEqualsActual[i][j] != MatrixEquals[i][j])
       {
           goto mark;
       }
    }
}
printf("PASSED (2/2): MatrixEquals()\n");
mark: {} // Matrices do not equal

Version 3 using a flag:
int i, j;
int flag = 1;
for (i = 0; (i < 3) && flag; i++) {
    for (j = 0; (j < 3) && flag; j++) {
        if (MatrixEqualsActual[i][j] != MatrixEquals[i][j])
        {
            flag = 0;
        }
    }
}
if (flag) {
    printf("PASSED (2/2): MatrixEquals()\n");
}

In addition you may want to replace your hardcoded 3 in the looping conditions with a computed length like so:
size_t length_outer = sizeof(MatrixEqualsActual) / sizeof(MatrixEqualsActual[0]);
size_t length_inner = sizeof(MatrixEqualsActual[0]) / sizeof(MatrixEqualsActual[0][0]);


text:
Q: Solve $a_{n+1} - a_n = n^2$ using generating functions The Full Question
Using the method of generating functions, solve $a_{n+1} - a_n = n^2$ where $a_0 = 1$
My Research
Scanned the website for similar answers, reviewed the following links:
Solve the following recurrences using generating functions.
can we use generating functions to solve the recurrence relation $a_n = a_{n-1} + a_{n-2}$, $a_1=1$, $a_2=2$?
Solving a recurrence equation using generating functions
Using Generating Functions to Solve Recursions
Solve the following recursive relation by using generating functions
Solve a recursion using generating functions?
Solving recurrences using generating functions
None of them would make my question a duplicate and none of them really addressed what I was having difficulty with.
My Work
If we multiply each side by $x^{n+1}$ and sum each of the possible cases $a_0,a_1,\dots$
we have:
$$\sum\limits_{j=0}^{\infty}{a_{n+1}x^{n+1}} - x\sum\limits_{j=0}^{\infty}a_nx^n = \sum\limits_{j=0}^{\infty}n^2x^{n+1}$$
If we let $f(x) = \sum\limits_{j=0}^{\infty}a_nx^n$ our equation transforms into:
$$f(x)-a_0 -xf(x) = \sum\limits_{j=0}^{\infty}n^2x^{n+1}$$
Factoring $f(x)$ and observing the LHS is a well known generating functions and using the fact that $a_0 = 1$, we get:
$$f(x)(1-x) = \frac{x(1+x)}{(1-x)^3} + 1 \implies f(x) = \frac{x(1+x)}{(1-x)^4} + \frac{1}{1-x}$$
We now need the coefficients of $x^n$ of these two functions we are adding. The right function it is well known that is has coefficients of $1$. We need partial fraction decomposition to obtain the coefficients of the left hand side.
$$\frac{x(1+x)}{(1-x)^4}= \frac{A}{1-x}+\frac{B}{(1-x)^2}+\frac{C}{(1-x)^3}+\frac{D}{(1-x)^4}$$
$\implies x(1+x)= A(1-x)^3+B(1-x)^2+C(1-x)+D$
Expanding this, we have
$Ax^3+3Ax^2 - 3Ax + A + Bx^2 -2Bx + B +C -Cx +D$
Which gives us the system of equations:
1) $A+B+C+D = 0$
2) $-3A-2B-C =1$
3) $3A+B = 1$
4) $A = 0$
5) $D = 0$
$3(0)+B=1 \implies B=1$ Using equations 3&4
$-3(0) -2 - C=1\implies C=3$ Using equations Using equations 2&1 and the result above
$0+1+3+0 = 0$  plugging in our results to equation 1
that is obviously not correct. Where did I make my mistake. I feel I'm very close and must have messed up the partial fraction decomposition somewhere, but maybe the mistake is somewhere else. Can anyone find where I went wrong?

A: You made a mistake in solving
$$ x(1+x)= A(1-x)^3+B(1-x)^2+C(1-x)+D$$
A faster way to solve this is the following:
$$x = 1 \Rightarrow D=2$$
Next derivate
$$1+2x=-3A(1-x)^2-2B(1-x)-C$$
plug in $x=1$. Then derivate again, and plug in $x=1$. Continue...

A: Define the generating function $A(z) = \sum_{n \ge 0} a_n z^n$. Take the recurrence, multiply by $z^n$, sum over $n \ge 0$:
$$
\sum_{n \ge 0} a_{n + 1} z^n - \sum_{n \ge 0} a_n z^n = \sum_{n \ge 0} n^2 z^n
$$
Recognize some sums, note that:
$\begin{align}
\sum_{n \ge 0} z^n
  &= \frac{1}{1 - z} \\
\sum_{n \ge 0} n z^n
  &= z \frac{\mathrm{d}}{\mathrm{d} z} \frac{1}{1 - z} \\
  &= \frac{z}{(1 - z)^2} \\
\sum_{n \ge 0} n^2 z^n
  &= z \frac{\mathrm{d}}{\mathrm{d} z} \frac{z}{(1 - z)^2} \\
  &= \frac{z + z^2}{(1 - z)^3} \\
\end{align}$
$$
\frac{A(z) - a_0}{z} - A(z) = \frac{z + z^2}{(1 - z)^3}
$$
Plug in $a_0 = 1$, solve for $A(z)$, split into partial fractions:
$\begin{align}
A(z)
  &= \frac{1 - 3 z + 4 z^2}{1 - 4 z + 6 z^2 - 4 z^3 + z^4} \\
  &= \frac{4}{(1 - z)^2}
       + \frac{5}{(1 - z)^3}
       + \frac{2}{(1 - z)^4}
\end{align}$
Consider that:
$$
(1 - z)^{-r}
  = \sum_{n \ge 0} (-1)^n \binom{-r}{n} z^n
  = \sum_{n \ge 0} \binom{r + n - 1}{r - 1} z^n
$$
Note that $\binom{n + r - 1}{r - 1}$ is a polynomial of degree $r - 1$ in $n$.
Pick the coefficient of $z^n$ of $A(z)$:
$\begin{align}
a_n
  &= 4 \binom{n + 1}{1} + 5 \binom{n + 2}{2} + 2 \binom{n + 3}{3} \\
  &= \frac{2 n^3 + 27 n^2 + 91 n + 66}{6}
\end{align}$


text:
Q: foreach item like button (access to variable through struct )(SwiftUI) I am developing MVVM app and I have two views and view model for one of them. One view for forEach cell, and another for forEach. So i want to implement like button in "cell" view, and i have no idea how to do it, because i cant edit data from cellView. Here is my code:
TownsListView.swift

struct TownsListView: View {
    @StateObject private var viewModel = TownsViewModel()

     var body: some View {
         ScrollView() {
             ForEach(viewModel.towns) { town in
                TownView(name: town.name)
                    .padding(.bottom)
                    .frame(width: 300, height: 40, alignment: .center)
                    .background(Color.yellow)
             }

         }
         .onAppear {
           viewModel.getTowns()
         }
     }
 }

TownView.swift

struct TownView : View {

var name: String

  @StateObject var viewModel = TownViewModel()

  var body : some View {
    HStack {
    Text(self.name)
        Spacer()
        Button(action: {/* viewModel.setLike */}) {
            Image(systemName: "heart")
        }
    }
  }
}

TownsViewModel.swift

class TownsViewModel : ObservableObject {

    @Published var towns = [Town]()

    func getTowns() {

        for town in townsArray {
            towns.append(town)
        }
    }
}

TownViewModel.swift

class TownViewModel : ObservableObject {

    func setLike() {
        //Here i want to implement like function
    }
}

and Model.swift

struct Town : Identifiable {

    var id : String = UUID().uuidString
    var name : String
    var liked : Bool
}

var paris = Town(name: "Paris", liked: false)
var london = Town(name: "London", liked: false)
var barcelona = Town(name: "Barcelona", liked: false)
var tokyo = Town(name: "Tokyo", liked: false)

let townsArray = [paris,london,barcelona,tokyo]

How to implement like function for toggle liked property of Town?

A: Here's how I would handle this:

struct TownsListView: View {
    @StateObject private var viewModel = TownsViewModel()

    var body: some View {
        ScrollView() {
            ForEach(viewModel.towns) { town in
                TownView(town: viewModel.bindingForTown(id: town.id))
                    .padding(.bottom)
                    .frame(width: 300, height: 40, alignment: .center)
                    .background(Color.yellow)
            }
        }
        .onAppear {
            viewModel.getTowns()
        }
    }
}

struct TownView : View {

    @Binding var town: Town

    var body : some View {
        HStack {
            Text(town.name)
            Spacer()
            Button(action: {
                town.liked.toggle()
            }) {
                Image(systemName: "heart")
            }.foregroundColor(town.liked ? .red : .black)
        }
    }
}

class TownsViewModel : ObservableObject {

    @Published var towns : [Town] = []

    func bindingForTown(id: String) -> Binding<Town> {
        .init {
            self.towns.first { $0.id == id }!
        } set: { newValue in
            self.towns = self.towns.map { $0.id == newValue.id ? newValue : $0 }
        }

    }

    func getTowns() {
        towns = townsArray
    }
}

This uses a custom binding to pass down to the TownView. If you can use Swift 5.5, this gets even easier and you can use ForEach with an automatic binding:
struct TownsListView: View {
    @StateObject private var viewModel = TownsViewModel()

    var body: some View {
        ScrollView() {
            ForEach($viewModel.towns) { $town in
                TownView(town: $town)
                    .padding(.bottom)
                    .frame(width: 300, height: 40, alignment: .center)
                    .background(Color.yellow)
            }
        }
        .onAppear {
            viewModel.getTowns()
        }
    }
}

A: You were overthinking this. Your model needs to provide the state of the app, not a function to change the state. Your views take that state and update them. I simply pulled your function stub out of class TownViewModel and added a bool like. In your view, all you need to do is have change the bool in the TownView button and you will change the state and have a record of it.
Model:
class TownViewModel : ObservableObject {

    @Published var like: Bool = false
}

View:
struct TownView: View {
    var name: String

    @StateObject var viewModel = TownViewModel()

    var body : some View {
        HStack {
            Text(self.name)
            Spacer()
            Button(action: {
                viewModel.like.toggle() // Changes the "like" state
            }) {
                Image(systemName: (viewModel.like ? "heart.fill" : "heart")) // This is a simple
                // tertiary operator that takes the current value of the "like" and changes the heart to match.
            }
        }
    }
}


text:
Q: Do "in future" and "in the future" imply different meanings? Do in future and in the future imply different meanings? If so, using which one is grammatically correct?

A: You may see "in future" when "future" is modifying a noun for which "in" is an appropriate preposition.
Fore example:
in future ______

*

*shows

*plays

*events

and etc.

A: In future is much more common in the UK and Ireland, as in In future, be more careful. In the US, we would tend to say In the future, be more careful. They mean exactly the same thing.

A: Both forms are possible. "In future" is often used in reprimands:

In future please sign and date your letters

It is very general, talking about all times from now onwards. You can find many examples on Google (search for "in future please take care").
"In the future" is more neutral and more specific:

In the future I would like to go to Australia, but now I don't have enough money.

A:
He would be more careful in future.
  They plan on getting married in the near future.

In the first sentence, "in future" means "from now on"; the NOAD says its use is chiefly British.
In the second sentence, "in the future" means "the time or a period of time following the moment of speaking or writing."

A: The difference is only in whether future is a noun or an adjective.
In the future, please be more careful and Please be more careful in the future both use future as a noun.
In future activities, please be more careful uses future to modify the noun activities.
To my knowledge is it not correct to say in future in the place of in the future.

A: In future is commonly used in British English and is perfectly correct but has a different meaning than in the future.
In the future refers to an unspecified point in time, while in future means from now on.

It'a shame I missed you when I popped round to see you yesterday. I'll ring up beforehand in future.
In the future people will look back at the mobile phones we use today and laugh at their simplicity.

A: In future is how they say it in the UK and India. It is common and considered normal.

In future, we will avoid water beds.

In American English, In future sounds strange; in the future is preferred or at least will get you fewer strange looks.

A: As far as grammar goes the difference between in future and in the future is contextual.
One usually comes across phrases like in future endeavours or in future meets where future serves as an adjective.
But if the reference is only to the times ahead,in the future would be correct and not in future.
Thus,it would be correct to say:
Be more careful in the future.
or
There will come a time in the future when there will be no petroleum left on the planet.
and incorrect to go with the other.
However,the spoken word in Britain and many former colonies where the influence of British English is enduring,it's not uncommon to come across simple notes that use in future.
Perhaps they find it more easy on their ears.Nonetheless,grammatically wanting.


text:
Q: In sql, how do I obtain the prior value conditional on another value? Thank you in advance.
I need to calculate the yellow column in the screenshot.
Basically, look for the prior qualified customer. If they were missed, then the yellow column should have a 1.

Here is the query that builds the data in the screenshot
with data as (
select 'a' customer, 'Jan 1' Period, 0 qualified, 0 missed, 0 desired_behavior_prior_qualified_was_missed
UNION
select 'b' customer, 'Jan 2' Period, 1 qualified, 1 missed, 0 desired_behavior_prior_qualified_was_missed
UNION
select 'c' customer, 'Jan 3' Period, 0 qualified, 0 missed, 1 desired_behavior_prior_qualified_was_missed
UNION
select 'd' customer, 'Jan 4' Period, 1 qualified, 0 missed, 1 desired_behavior_prior_qualified_was_missed
)

select * from data

A: Thanks to this post I got the answer
with data as (
select 'a' customer, 'Jan 1' Period, 0 qualified, 0 missed, 0 desired_behavior_prior_qualified_was_missed
UNION
select 'b' customer, 'Jan 2' Period, 1 qualified, 1 missed, 0 desired_behavior_prior_qualified_was_missed
UNION
select 'c' customer, 'Jan 3' Period, 0 qualified, 0 missed, 1 desired_behavior_prior_qualified_was_missed
UNION
select 'd' customer, 'Jan 4' Period, 1 qualified, 0 missed, 1 desired_behavior_prior_qualified_was_missed
)

, data_1 as (
select *,
LAG(
  CASE
    WHEN qualified = 0
    THEN NULL
    ELSE concat(customer,period)
    END
) IGNORE NULLS OVER ( ORDER BY period ) period_qualified_customer

from data
order by period)

select  a.customer,
        a.period,
        a.qualified,
        a.missed,
        a.desired_behavior_prior_qualified_was_missed,
        coalesce(b.missed,0) as prior_qualified_was_missed
from data_1 a
LEFT JOIN data b on concat(b.customer,b.period) = a.period_qualified_customer
order by customer;


text:
Q: How can I reset pg_stat_user_tables on Heroku? (pg_stat_reset() requires superuser) I am using Heroku Postgres and want to see what the effect has been of adding some additional indexes to my database.
I am querying pg_stat_user_tables to see what proportion of queries are using indexes, but I believe that is using statistics from ever since I created the database.
I understand that running SELECT pg_stat_reset(); would reset these statistics, but when I try to run that in the pg:psql console I get the error:
ERROR:  must be superuser to reset statistics counters

Is there another way to achieve this with a Heroku Postgres production database?

A: I found out via a support request today that this has now been added:
heroku plugins:install git://github.com/heroku/heroku-pg-extras.git
heroku pg:stats_reset

A: How easy is it for you to reproduce the scenarios or tests that will exercise those queries? Could you do the following?

*

*Create a new test app and test database on heroku

*Deploy the old version of your app, with the old indexes (and a representative subset of data if copying your entire database is not feasible)

*Run your queries or tests, or exercise your app

*Note the db statistics

*Drop the test database and create a new one

*Fill the new test database with your data, and add the new indexes

*Point the test app at the new database

*Run your queries or tests again

*Note the new db statics

Hopefully you are able to easily create a representative set of data that will let you test your queries more easily.


text:
Q: about view size I'm experiencing a problem and I don't really know why.
I use Photoshop for creating the objects. I made a new document at WVGA resolution (480x800). The same resoloution than my Nexus S.
I use this document as interface template, and export any single object later as a PNG file. So far so good, but when I open the PNG at Eclipse, they appear much bigger than they really are. I checked the resolution of the file by itself and its right, but once I bring them into Eclipse the seems to be bigger.
Does Eclipse have dpi value? I've been playing with this value but I almost sure it has nothing to do with this issue. Any other idea?
Thanks for your help,
Greetings

I'm talking about layout XML constructor and un nexus s too. not android emulator.
Thanks