text:
Q: Making a JFrame button create a Alert Dialog. Java - Netbeans I use NetBeans IDE, as you may know there is a JFrame creator plugin (Its pre-installed) I use it to make JFrames (Because I'm too lazy to do it my self =/). in the event of creating a button within that JFrame it will generate a area for the event code. I was wondering what code i need to type in to generate the Alert Dialog. Heres what is pre-generated upon create a swing/awt component or a JFrame:
    public class NewJFrame extends javax.swing.JFrame {

public NewJFrame() {
    initComponents();
}

@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

    jDialog2 = new javax.swing.JDialog();
    jButton1 = new javax.swing.JButton();

    javax.swing.GroupLayout jDialog2Layout = new javax.swing.GroupLayout(jDialog2.getContentPane());
    jDialog2.getContentPane().setLayout(jDialog2Layout);
    jDialog2Layout.setHorizontalGroup(
        jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 400, Short.MAX_VALUE)
    );
    jDialog2Layout.setVerticalGroup(
        jDialog2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGap(0, 300, Short.MAX_VALUE)
    );

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle(">:D");
    setResizable(false);
    addHierarchyBoundsListener(new java.awt.event.HierarchyBoundsListener() {
        public void ancestorMoved(java.awt.event.HierarchyEvent evt) {
            formAncestorMoved(evt);
        }
        public void ancestorResized(java.awt.event.HierarchyEvent evt) {
        }
    });

    jButton1.setText("Press Me :D");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 349, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
    );

    pack();
    setLocationRelativeTo(null);
}// </editor-fold>

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    //This is the area for the code dialog code
}

private void formAncestorMoved(java.awt.event.HierarchyEvent evt) {
    // TODO add your handling code here:
}

/**
 * @param args the command line arguments
 */
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new NewJFrame().setVisible(true);
        }
    });
}

Did you see the Button1ActionPerformed thing????
that's where the code goes.
I need code that will create a new Alert Dialog (javax.swing.JDialog)
When that is pressed.
Thanks in advance

A: Sounds like you might want a JOptionPane message dialog...
Try this:
JOptionPane.showMessageDialog(null, "<your message here...>", "Alert", JOptionPane.ERROR_MESSAGE);

So for your case, this is what your action performed method will look like:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    JOptionPane.showMessageDialog(null, "<your message here...>", "Alert", JOptionPane.ERROR_MESSAGE);
}

Note there is no "variable" to store the JOptionPane object, it's a static method called on the JOptionPane class. Each time you want an alert/confirm/input/etc. dialog, you generate one on the fly using the static members of the JOptionPane class.
See the reference for more info...

A: This is what i see
public class NewJFrame extends javax.swing.JFrame {

/**
 * Creates new form NewJFrame
 */
public NewJFrame() {
    initComponents();
}

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

    jOptionPane1 = new javax.swing.JOptionPane();
    jButton1 = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle(">:D");
    setResizable(false);
    addHierarchyBoundsListener(new java.awt.event.HierarchyBoundsListener() {
        public void ancestorMoved(java.awt.event.HierarchyEvent evt) {
            formAncestorMoved(evt);
        }
        public void ancestorResized(java.awt.event.HierarchyEvent evt) {
        }
    });

    jButton1.setText("Press Me :D");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 353, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(0, 45, Short.MAX_VALUE)
                .addComponent(jOptionPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 46, Short.MAX_VALUE)))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jButton1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jOptionPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE)))
    );

    pack();
    setLocationRelativeTo(null);
}// </editor-fold>

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
//jOptionPane.showMessageDialog(null, "<your message here...>", "Alert", jOptionPane.ERROR_MESSAGE);
}

private void formAncestorMoved(java.awt.event.HierarchyEvent evt) {
    // TODO add your handling code here:
}

/**
 * @param args the command line arguments
 */
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new NewJFrame().setVisible(true);
        }
    });
}

// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JOptionPane jOptionPane1;
// End of variables declaration

}


text:
Q: How to use column name 'use' in sqlserver I've got a DB I migrated from MySQL to SQLServer.  One of the table's column names is use.  How can I write my insert statement to not throw an error becuase of it?  I'm getting the error:
Msg 156, Level 15, State 1, Line 4830
Incorrect syntax near the keyword 'use'.

My insert looks something like:
insert into foo (id, use, some_other_attrs) values(1, fun, other_stuff);

A: use is a reserved keyword (the hint is right there in the error message!) that allows you to change database context (e.g. USE master;). You shouldn't use reserved words as identifiers (table names, column names, database names, users, etc).
You need to either fix the column name (I suggest something a little more descriptive and self-documenting) or surround it with square brackets (which tells SQL Server to ignore that it is a keyword). Also, please always use the schema prefix on objects:
INSERT dbo.foo(id, [use], ...) SELECT 1, 'fun', ...;

A: I guess you have to put the name in [use]
insert into foo (id, [use], some_other_attrs) values(1, fun, other_stuff);

On a side note:- Do not prefer to use Reserve keyword as column names

A: Wrap it with []
insert into foo (id, [use], some_other_attrs) values(1, fun, other_stuff);

Stay away from reserved words for column names
http://technet.microsoft.com/en-us/library/ms189822.aspx

redpajama_set_name: RedPajamaStackExchange


text:
Q: Explanation left in a .tex file I'm trying to create my CV in using Awesome_CV.zip (template) from www.sharelatex.com. I tried to compile resume.tex, but they ask me to do many things I don't understand.

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
% Awesome CV LaTeX Template
%
% This template has been downloaded from:
% https://github.com/posquit0/Awesome-CV
%
% Author:
% Claud D. Park <posquit0.bj@gmail.com>
% http://www.posquit0.com
%
% Template license:
% CC BY-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%     Configuration
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Themes: Awesome-CV
\documentclass[11pt, a4paper]{awesome-cv}

%%% Override a directory location for fonts(default: 'fonts/')
\fontdir[fonts/]

%%% Configure a directory location for sections
\newcommand*{\sectiondir}{resume/}

%%% Override color
% Awesome Colors: awesome-emerald, awesome-skyblue, awesome-red, awesome-pink, awesome-orange
%                 awesome-nephritis, awesome-concrete, awesome-darknight
%% Color for highlight
% Define your custom color if you don't like awesome colors
\colorlet{awesome}{awesome-red}
%\definecolor{awesome}{HTML}{CA63A8}
%% Colors for text
%\definecolor{darktext}{HTML}{414141}
%\definecolor{text}{HTML}{414141}
%\definecolor{graytext}{HTML}{414141}
%\definecolor{lighttext}{HTML}{414141}

%%% Override a separator for social informations in header(default: ' | ')
%\headersocialsep[\quad\textbar\quad]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%     3rd party packages
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Needed to divide into several files
\usepackage{import}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%     Personal Data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Essentials
\name{Claud D.}{Park}
\address{246-1002, Gwangmyeongmayrouge Apt. 86, Cheongna lime-ro, Seo-gu, Incheon-si, 22738, Rep. of KOREA}
\mobile{(+82) 10-9030-1843}
%%% Social
\email{posquit0.bj@gmail.com}
\homepage{www.posquit0.com}
\github{posquit0}
\linkedin{posquit0}
%%% Optionals
\position{Software Engineer{\enskip\cdotp\enskip}Security Expert}
\quote{``Make the change that you want to see in the world."}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%     Content
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Make a footer for CV with three arguments(<left>, <center>, <right>)
\makecvfooter
  {\today}
  {Claud D. Park~~~·~~~Résumé}
  {\thepage}

\begin{document}
%%% Make a header for CV with personal data
\makecvheader

%%% Import contents
\import{\sectiondir}{education.tex}
\import{\sectiondir}{experience.tex}
\import{\sectiondir}{extracurricular.tex}
\import{\sectiondir}{honors.tex}
\import{\sectiondir}{presentation.tex}
\import{\sectiondir}{writing.tex}
\import{\sectiondir}{committees.tex}

\end{document}

I need explanation please for the following things  and how to do it:

*

*"Override a directory location for fonts(default: 'fonts/')"

*"Configure a directory location for sections"

*"Override color"

*"Override a separator for social informations in header(default: ' | ') %\headersocialsep[\quad\textbar\quad] "

*"Import contents"

Thanks in advance!

A: %%% Override a directory location for fonts(default: 'fonts/')
\fontdir[fonts/]

These lines say that you can choose a different place for the fonts, if you like, by writing the directory name between the square brackets. The default is fonts/, simply because this is currently written there. You don't have to do anything, since your fonts are in the subdirectory fonts.
%%% Configure a directory location for sections
\newcommand*{\sectiondir}{resume/}

These lines say that you can choose a different place for the files containing the sections, if you like, by writing the directory name between the braces. Currently resume/ is written there. Since you have put the section files into a subdirectory of this name, you don't have to do anything.
% Define your custom color if you don't like awesome colors
\colorlet{awesome}{awesome-red}
%\definecolor{awesome}{HTML}{CA63A8}

These lines set awesome (which determines the color of some elements of the document) to be the color awesome-red. The line below it is commented out (=not active) because of the leading % sign. It gives an example for an alternate definition. Don't change any colors now. Later, if you don't like some coloring in the document, return to these lines and modify the colors.
%%% Override a separator for social informations in header(default: ' | ')
%\headersocialsep[\quad\textbar\quad]

The headline will contain a vertical bar to separate two parts. Don't modify it now. If you don't like it later on, return to this place and modify it.
%%% Import contents

This is just a comment explaning what is happening in the lines below: The contents of the files in subdirectory resume (this name is stored in \sectiondir) is included in the document. You just have to fill your data into the files in the subdirectory resume. Nothing to do here.

What you have to do is to write your personal information into the files in the subdirectory resume. Then compile resume.tex in the main directory. If you get any errors, it is not because of the lines that you are worried about. If you can't help yourself, post a new question here, including the error message as well as the LaTeX source code.


text:
Q: Binary operator in std::transform with vector of unique_ptr I am getting confused with standard library transform when applied to a vector of unique_ptr. I have defined a binary functor addScalar that take 2 const references to unique_ptr and return a const reference to a unique_ptr in order to avoid copying (that is forbidden with unique_ptr).
I then try to use it in a std::transform, but it seems impossible for unique_ptr do undergo binary operation at all, in spite of all my precautions to avoid unique_ptr copying...
Has anybody an idea of how to use std::transform with std::unique_ptr ? Or am I obliged to run through the vector with a for-loop and perform the addition "manually" ? I am also wondering if I could use unique_ptr<const Scalar> in my functor.
Here is my class :
#include "space.h"
#include "scalar.h"
#include <vector>
#include <algorithm>
#include <memory>

using std::vector;
using std::ostream;
using std::unique_ptr;

class addScalar
{
   public:
      unique_ptr<Scalar> const& operator()(unique_ptr<Scalar> const& scal1, unique_ptr<Scalar> const& scal2)
      {
         *scal1 += *scal2;
         return scal1;
      };
};

class Tensor4D
{
   public:
      Tensor4D(Space& space_in, int ncomp);
      Tensor4D(const Tensor4D& tens);
      Tensor4D& operator=(const Tensor4D& tens);
      size_t size() const {return comp.size();};
      ~Tensor4D();
   protected:
      Space* const space;
      vector<unique_ptr<Scalar>> comp;
   public:
      Tensor4D& operator+=(const Tensor4D& tens);
};

and here is the implementation of operator+= :
Tensor4D& Tensor4D::operator+=(const Tensor4D& tens)
{
   assert(comp.size() == tens.comp.size());
   transform(tens.comp.begin(), tens.comp.end(), comp.begin(), tens.comp.begin(), addScalar());
   return *this;
}

I get the following ugly compiler errors :
/usr/include/c++/4.8/bits/stl_algo.h: In instantiation of '_OIter std::transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation) [with _IIter1 = __gnu_cxx::__normal_iterator<const std::unique_ptr<Scalar>*, std::vector<std::unique_ptr<Scalar> > >; _IIter2 = __gnu_cxx::__normal_iterator<std::unique_ptr<Scalar>*, std::vector<std::unique_ptr<Scalar> > >; _OIter = __gnu_cxx::__normal_iterator<const std::unique_ptr<Scalar>*, std::vector<std::unique_ptr<Scalar> > >; _BinaryOperation = addScalar]':
tensor4D.C:44:94:   required from here
/usr/include/c++/4.8/bits/stl_algo.h:4965:12: error: no match for 'operator=' (operand types are 'const std::unique_ptr<Scalar>' and 'const std::unique_ptr<Scalar>')
  *__result = __binary_op(*__first1, *__first2);
        ^
/usr/include/c++/4.8/bits/stl_algo.h:4965:12: note: candidates are:
In file included from /usr/include/c++/4.8/memory:81:0,
             from /home/gmartinon/Kadath/C++/Include/scalar.h:27,
             from tensor4D.h:5,
             from tensor4D.C:1:
/usr/include/c++/4.8/bits/unique_ptr.h:190:7: note: std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Tp, _Dp>&&) [with _Tp = Scalar; _Dp = std::default_delete<Scalar>]
   operator=(unique_ptr&& __u) noexcept
   ^
/usr/include/c++/4.8/bits/unique_ptr.h:190:7: note:   no known conversion for argument 1 from 'const std::unique_ptr<Scalar>' to 'std::unique_ptr<Scalar>&&'
/usr/include/c++/4.8/bits/unique_ptr.h:203:2: note: template<class _Up, class _Ep> typename std::enable_if<std::__and_<std::is_convertible<typename std::unique_ptr<_Up, _Ep>::pointer, typename std::unique_ptr<_Tp, _Dp>::_Pointer::type>, std::__not_<std::is_array<_Up> > >::value, std::unique_ptr<_Tp, _Dp>&>::type std::unique_ptr<_Tp, _Dp>::operator=(std::unique_ptr<_Up, _Ep>&&) [with _Up = _Up; _Ep = _Ep; _Tp = Scalar; _Dp = std::default_delete<Scalar>]
  operator=(unique_ptr<_Up, _Ep>&& __u) noexcept
  ^
/usr/include/c++/4.8/bits/unique_ptr.h:203:2: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/4.8/algorithm:62:0,
             from tensor4D.h:8,
             from tensor4D.C:1:
/usr/include/c++/4.8/bits/stl_algo.h:4965:12: note:   types 'std::unique_ptr<_Tp, _Dp>' and 'const std::unique_ptr<Scalar>' have incompatible cv-qualifiers
  *__result = __binary_op(*__first1, *__first2);
        ^
In file included from /usr/include/c++/4.8/memory:81:0,
             from /home/gmartinon/Kadath/C++/Include/scalar.h:27,
             from tensor4D.h:5,
             from tensor4D.C:1:
/usr/include/c++/4.8/bits/unique_ptr.h:211:7: note: std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(std::nullptr_t) [with _Tp = Scalar; _Dp = std::default_delete<Scalar>; std::nullptr_t = std::nullptr_t]
       operator=(nullptr_t) noexcept
       ^
/usr/include/c++/4.8/bits/unique_ptr.h:211:7: note:   no known conversion for argument 1 from 'const std::unique_ptr<Scalar>' to 'std::nullptr_t'
/usr/include/c++/4.8/bits/unique_ptr.h:274:19: note: std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = Scalar; _Dp = std::default_delete<Scalar>] <near match>
   unique_ptr& operator=(const unique_ptr&) = delete;
               ^
/usr/include/c++/4.8/bits/unique_ptr.h:274:19: note:   no known conversion for implicit 'this' parameter from 'const std::unique_ptr<Scalar>*' to 'std::unique_ptr<Scalar>*'

A: The return type of addScalar will be assigned to a unique_ptr<Scalar> so it cannot return a const reference because unique_ptr has no copy assignment. So you will have to return by-value to invoke the move assignment.
To avoid constructing a new Scalar you could use a std:move_iterator to move into addScalar and then move assign to overwrite the moved from value:
class addScalar
{
public:
    unique_ptr<Scalar> operator()(unique_ptr<Scalar> scal1,
                                  unique_ptr<Scalar> const& scal2) {
      *scal1 += *scal2;
      return scal1;
    };
};

Tensor4D& Tensor4D::operator+=(const Tensor4D& tens)
{
   assert(comp.size() == tens.comp.size());
   transform(make_move_iterator(comp.begin()), make_move_iterator(comp.end()),
               tens.comp.begin(), comp.begin(), addScalar());
   return *this;
}

Andrey makes a good point, it is not clear if this is strictly allowed according to the standard. I'll leave that to a language lawyer. See also this answer.
Live demo.

A: The C++ standard for std::transform says:

binary_op must not invalidate any iterators, including the end
  iterators, or modify any elements of the ranges involved.

The best way for you is to implement your own transform function for specific needs.


text:
Q: Getting a log of the SQL SubSonic is using Linq2SQL has the great Log property to see what the actual SQL statements that it is generating. Does SubSonic 2.2 have something similar to this?

A: http://www.e-webdevelopers.com/268/view-the-sql-generated-by-subsonic/
SqlQuery sq = new Select()
                   .From(Item.Schema)
                   .InnerJoin(ItemStatus.IstIDColumn, Item.ItmStatusColumn)
                   .InnerJoin(ItemCategory.ItcItemIDColumn, Item.ItmIDColumn)
                   .WhereExpression("ItmIsEnabled").IsEqualTo(true)
                   .AndExpression("ItmName").Like("%" + findThis + "%")
                   .Or(Item.ItmShortDescriptionColumn).Like("%" + findThis + "%")
                   .Or(Item.ItmItemCodeColumn).Like("%" + findThis + "%")
                   .Or(Item.ItmLongDescriptionColumn).Like("%" + findThis + "%")
                   .Paged(pageIndex, PageSize)
                   .OrderAsc("itmName");

          Response.Write(sq.ToString());

Not tested as I'm not infront of my dev box. Hope that helps.

A: SubSonic 2.2 ActiveRecord has some events you can override, like AfterValidate() and BeforeCommit(). You could use one of those to log the Sql, but you would have to modify your templates so that code ended up in all your classes.
Or just hit up SubSonic\DataProviders\DataService.cs in your local SubSonic source and see if it will work to add your logging events to all of the .Execute* methods.

A: It is not possible


text:
Q: Token error on getting started tutorial with Node.js and Google Cloud datastore I'm building a webapp with google appengine, node.js and socket.io, and I'm currently trying to set up a google compute instance to use the google cloud datastore api following this tutorial. So far, I've completed steps 1 and 2, but when running the downloaded adams.js file locally, I get this:
Error: No access or refresh token is set.

Stuff I've tried:

*

*gcloud auth login (this logs me in google, but doesn't set my token locally)

*changing the way I'm exporting my DATASTORE_SERVICE_ACCOUNT and DATASTORE_PRIVATE_KEY_FILE values, as strings, plain text, etc.

*logging my credentials on the line before the error (I'm definitely missing a token)

*creating a new service account and going through key creation steps again

*ran
curl "http://metadata/computeMetadata/v1/instance/service-accounts/default/token" -D "Metadata-Flavor: Google" to get more info.

that command gives me this:

<title>301 Moved Permanently</title>

301 Moved Permanently

nginx

so I'm definitely missing a token, but for some reason I cannot figure out how I am supposed to be getting it. Or where I need to store it when my app is deployed and wants to access the API online. It feels like this should be a really easy thing to find, but for some reason all the documentation I'm reading is leading me into walls. Any help would be awesome.

A: If your code is running on a Google Compute Instance, and the instance has the correct scopes, you don't need to set any environment variables.
You can confirm the scopes by looking at the instance in the Developers Console or by asking the metadata server:
curl http://metadata/computeMetadata/v1/instance/service-accounts/default/scopes -H "Metadata-Flavor: Google"

To use Cloud Datastore, both the datastore and userinfo.email scopes must be present.


text:
Q: Expression language and navigation query I am trying to to get a new web page to load after the client successfully logs in. So the databases is checked for the username and password and then the boolean variable (greetController.greet) is set. In the expression language, I want to allow the user to move to the next web page (index2) if they are successful. Within the command link I have used a rendered attribute so that the redirect should only happen if the boolean variable is true. Below item (1) is showing the following warning,the action value does not match a navigation case outcome. When I run it, it just prints index to screen. I would appreciate if someone can correct my error
Thanks
Expression language(EL)
<h:form>
    <h:commandButton value="login" action="#{greetController.greet}" />
    <h:commandLink rendered="#{greetController.logInSuccessful}"
        (1) **action="index2?faces-redirect=true"**
        value="Index2" />
</h:form>

faces-config.xml
<navigation-rule>
    <from-view-id>/greet.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>index2</from-outcome>
        <to-view-id>/index2.html</to-view-id>
        <redirect />
    </navigation-case>
</navigation-rule>


text:
Q: Wordpress Plugin JS remove version Hello I want to include my js file without adding ?ver=x.x.x to it I tried all the solutions but nothing help me to get the success
Here is my Code I am trying to add
add_action( 'wp_enqueue_scripts', 'register_script');
function register_script() {
    wp_enqueue_script( 'customJS', plugins_url( '/assets/script.js', __FILE__ ), false);
}

Output it returns
<script src='http://localhost/wordpress/myplugin/assets/script.js?ver=5.4.4'></script>

Output I need
<script src='http://localhost/wordpress/myplugin/assets/script.js'></script>

A: Version is set by 4th param, use NULL, more info at https://developer.wordpress.org/reference/functions/wp_enqueue_script/.
wp_enqueue_script( 'customJS', plugins_url( '/assets/script.js', __FILE__ ), false, NULL);


text:
Q: Getting and passing data to/from a ReactJs component I am trying to figure out how to set the message on an alert window and bring back a success or failure message from it depending on user's interactions when the "addSkill" action is called. I have the code for the alertmodal and the addskill action below:
Add skill action:
addSkill(e) {
    e.preventDefault();
    let id = guid();
    let skill_name = ReactDOM.findDOMNode(this.refs.skill_name).value.trim();
    ReactDOM.findDOMNode(this.refs.skill_name).value = '';
    ProfileDispatcher.dispatch({
      action: ADD_SKILL,
      new_skill: {
        name: skill_name
      }
    });
  }

AlertModal component
class AlertModal extends React.Component {

  constructor() {
    super();
    this.state = {};
  }

  render() {

    if (this.props.show) {
        return (

{this.props.heading}

{this.props.message}

                 <button>Cancel</button>
                 <button>OK</button>

      );
    }
    return null;
  }
};

export default AlertModal;


text:
Q: Sharing values through namespaces My question is probably stupid, but I can't share a value through namespaces.
namespace AceEngine
{
    namespace Graphics
    {
        namespace Interface
        {
            void drawDebugScreen()
            {
                // I want to access AceEngine::System::Version from here.
            }
        }
    }

    namespace System
    {
        string Version("DEBUG");
    }
}

How can I access this string?
EDIT:
ae.cpp
#include "stdafx.h"
#include "sha256.h"
#include <iostream>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::getline;
using std::string;

namespace AceEngine
{
    namespace Graphics
    {
        namespace Interface
        {
            void drawDebugScreen()
            {
                cout << "Version: " << AceEngine::System::Version << endl;
            }
            class Window{};
        }
    }
    namespace System
    {
        class User{};
        void pause(){cin.get();}
        extern string Version("DEBUG");
    }
}

ae.h
#pragma once
#include "stdafx.h"
#include <string>
using std::string;

namespace AceEngine
{
    namespace Graphics
    {
        namespace Interface
        {
            void drawDebugScreen();
            class Window{};
        }
    }

    namespace System
    {
        class User{};
        void pause();
        extern string Version;
    }
}

I removed the useless parts (I left some classes to show there are stuff in the namespaces and it's not useless)

A: As always, names need to be declared before use.
You probably want to declare it in a header, so it can be used from any source file. You need extern when declaring a global variable:
namespace AceEngine {
    namespace System {
        extern string Version;
    }
}

Or, if you only need it in this file, you could just move the System namespace to come before whatever needs it.
UPDATE: Now you've posted the full code, the problem is that the source file doesn't include the header.

A: It is necessary to place the declaration of the string before its point of use.
#include <iostream>   //  for std::cout

namespace AceEngine
{
    namespace System
    {
        string Version("DEBUG");    // declare it here
    }

    namespace Graphics
    {
        namespace Interface
        {
            void drawDebugScreen()   // access it in here
            {
                std::cout << AceEngine::System::Version << '\n;
            }
        }
    }

}

int main()
{
     AceEngine::Graphics::Interface::drawDebugScreen();
     return 0;
}

If you need that number of nested namespaces, you're probably over thinking your design.   But that's another story.


text:
Q: Calculating the group co-homology of the symmetric group $S_3$ with integer coefficients. I have been trying for a while to make sense of Ex V.3.5 & Ex III.10.1 in Brown's book 'Co-homology of Groups': Calculate the Co-homology of $S_3$ with co-efficients in $\mathbb{Z}$, possibly using cup products.
Ex III.10.1 says that it is possible to calculate this using III.10.3: The p-primary part of $H^n(S_3, M)$ is isomorphic to the $S_3$-invariant elements of $H^n(H, M)$ where $H$ is a Sylow $p$-subgroup of $G$.
The Sylow $p$-subgroups of $S_3$ are a copy of $\mathbb{Z}_3$ and $\mathbb{Z}_2$, so the first step I suppose is to compute the $S_3$-invariant elements of $H^2(\mathbb{Z}_3, \mathbb{Z})$.  The only method I know to compute these is using a resolution $F_*$ of $\mathbb{Z}$ by $\mathbb{Z}[S_3]$ modules: finding a generator of $H^2(\mathbb{Z}_3, \mathbb{Z})$ in the chain complex $\mathcal{Hom}_{\mathbb{Z}[\mathbb{Z}_3]}(F_*, \mathbb{Z})$ and watching what happens to it under the action of $S_3$.  At this point I am completely stuck, I cannot think of a way to explicitly find a generator of $H^2(\mathbb{Z}_3, \mathbb{Z})$ in this chain complex.
So I am wondering, have I started going about this the right way?  Perhaps there is an easier chain complex in which I can compute the $S_3$-invariant elements, or a way to compute what such a generator of $H^2(\mathbb{Z}_3, \mathbb{Z})$?
Thanks for any help that anyone can give.

A: Here are my solutions from when I was studied under Ken Brown as an undergraduate:
V.3.5:
From the semi-direct product representation $S_3=\mathbb{Z}_3\rtimes \mathbb{Z}_2$ where $\mathbb{Z}_2$ acts on $\mathbb{Z}_3$ by conjugation, $H^*(S_3)=H^*(S_3)_{(2)}\oplus H^*(S_3)_{(3)}\cong H^*(S_3)_{(2)}\oplus H^*(\mathbb{Z}_3)^{\mathbb{Z}_2}$ by Theorem III.10.3, with $H^*(S_3)_{(2)}$ isomorphic to the set of $S_3$-invariant elements of $H^*(\mathbb{Z}_2)$.  Exercise III.10.1 showed that $H^*(S_3)_{(2)}\cong \mathbb{Z}_2$, so it suffices to compute $H^*(\mathbb{Z}_3)^{\mathbb{Z}_2}$ where we know that $\mathbb{Z}_2$ acts by conjugation on $\mathbb{Z}_3$ ($1\mapsto 1$, $x\mapsto x^2$, $x^2\mapsto x$).  But this action can be considered as the endomorphism $\alpha(2)$ from Exercise V.3.4 since $(1)^2=1$ and $(x)^2=x^2$ and $(x^2)^2=x^4=x$, and that exercise implies that the induced map on the $(2i)^{th}$-cohomology is multiplication by $2^i$ [we know that the cohomology is trivial in odd dimensions].  Now $2^1\equiv 2\,\text{mod}3$ and $2^2\equiv 1\,\text{mod}3$, so by multiplying both of those statements by $2$ repeatedly we see that $2^i\equiv 1\,\text{mod}3$ for $i$ even and $2^i\equiv 2\,\text{mod}3$ for $i$ odd.  Thus the largest $\mathbb{Z}_2$-submodule of $H^{2i}(\mathbb{Z}_3)\cong\mathbb{Z}_3$ on which $\mathbb{Z}_2$ acts trivially is $\mathbb{Z}_3$ (itself) for $i$ even, and is $0$ for $i$ odd.  It now follows that the integral cohomology $H^*(S_3)$ is the same as that which was deduced in Exercise III.10.1, namely, it is $\mathbb{Z}_2$ in the $2\,\text{mod}4$ dimensions and is $\mathbb{Z}_6$ in the nonzero $0\,\text{mod}4$ dimensions and is $0$ otherwise (besides the $0^{th}$-dimension in which it is $\mathbb{Z}$).
III.10.1:
From the semi-direct product representation $S_3=\mathbb{Z}_3\rtimes \mathbb{Z}_2$ where $\mathbb{Z}_2$ acts on $\mathbb{Z}_3$ by conjugation, $H^*(S_3)=H^*(S_3)_{(2)}\oplus H^*(S_3)_{(3)}\cong H^*(S_3)_{(2)}\oplus H^*(\mathbb{Z}_3)^{\mathbb{Z}_2}$ by Theorem III.10.3.  Now $S_3$ is the unique nonabelian group of order 6, so $D_6\cong S_3$ and we can use a result (given below as "additional exercise") which implies that the $\mathbb{Z}_2$-action on $H_{2i-1}(\mathbb{Z}_3)\cong H^{2i}(\mathbb{Z}_3)$ is multiplication by $(-1)^i$.  Thus $H^n(\mathbb{Z}_3)^{\mathbb{Z}_2}$ is isomorphic to $\mathbb{Z}_3$ for $n=2i$ where $i$ is even, and is trivial for $n$ odd and $n = 2i$ where $i$ is odd.  Taking any Sylow $2$-subgroup $H\cong \mathbb{Z}_2$, Theorem III.10.3 states that $H^*(S_3)_{(2)}$ is isomorphic to the set of $S_3$-invariant elements of $H^*(H)$.  In particular we have the monomorphism $H^{2i-1}(S_3)_{(2)}\hookrightarrow H^{2i-1}(H)=0$, so $H^{2i-1}(S_3)_{(2)}=0$.  An $S_3$-invariant element $z\in H^{2i}(H)\cong\mathbb{Z}_2$ must satisfy the equation $\text{res}^H_Kz=\text{res}^{gHg^{-1}}_Kgz$, where $K$ denotes $H\cap gHg^{-1}$.  If $g\in H$ then $gHg^{-1}=H$ and the above condition is trivially satisfied for all $z$ ($hz=z$ by Proposition III.8.1).  If $g\notin H$ then $K=\lbrace 1\rbrace$ because $H$ is not normal in $S_3$ and only contains two elements, so the intersection must only contain the trivial element.  But then the image of both restriction maps is zero, so the condition is satisfied for all $z$; thus $H^{2i}(S_3)_{(2)}=\mathbb{Z}_2$.  Alternatively, a theorem of Richard Swan states that if $G$ is a finite group such that $\text{Syl}_p(G)$ is abelian and $M$ is a trivial $G$-module, then $\text{Im}(\text{res}^G_{\text{Syl}_p(G)})=H^*(\text{Syl}_p(G),M)^{N_G(\text{Syl}_p(G))}$.  It is a fact that $N_{S_3}(\mathbb{Z}_2)=\mathbb{Z}_2$, so taking $G=S_3$ and $H=\text{Syl}_2(S_3)\cong\mathbb{Z}_2$ and $M=\mathbb{Z}$ we have $\text{Im}(\text{res}^{S_3}_H)=(\mathbb{Z}_2)^{\mathbb{Z}_2}=\mathbb{Z}_2$ in the even-dimensional case.  Since any invariant is in the image of the above restriction map (by Theorem III.10.3), the result $H^{2i}(S_3)_{(2)}=\mathbb{Z}_2$ follows.
Additional Exercise: The cyclic group $C_m$ is a normal subgroup of the dihedral group $D_m=C_m\rtimes C_2$ (of symmetries of the regular $m$-gon).  There is a $C_2$-action on $C_m=\langle \sigma\rangle$ given by $\sigma\mapsto \sigma^{-1}$.  Determine the action of $C_2$ on the homology $H_{2i-1}(C_m,\mathbb{Z})$, noting that there is an element $g\in D_m$ such that $g\sigma g^{-1}=\sigma^{-1}$.
Solution: Letting $c(g):C_m\rightarrow C_m$ be conjugation by $g$, we can apply Corollary III.8.2 to obtain the induced action of $D_m/C_m\cong C_2$ on $H_*(C_m,\mathbb{Z})$ given by $z\mapsto c(g)_*z$.  It suffices to compute $c(g)_*$ on the chain level, using the periodic free resolution $P$ of $C_m$, and using the trivial action on $\mathbb{Z}$.  Using the condition $\tau(hx)=[c(g)](h)\tau(x)=h^{-1}\tau(x)$ on the chain map $\tau:P\rightarrow P$ (for $h\in C_m$), we claim that $\tau_{2i-1}(x)=\tau_{2i}(x)=(-1)^i\sigma^{m-i}x$ for $i\in\mathbb{N}$ and $\tau_0(x)=x$.  Assuming this claim holds, the chain map $P\otimes_{C_m}\mathbb{Z}\rightarrow P\otimes_{C_m}\mathbb{Z}$ [in odd dimensions] is given by $x\otimes y\mapsto (-1)^i\sigma^{m-i}x\otimes gy=(-1)^i\sigma^{m-i}x\otimes y=(-1)^ix\otimes \sigma^{i-m}y=(-1)^ix\otimes y$, and so $c(g)_*$ [hence the $C_2$-action] is multiplication by $(-1)^i$ on $H_{2i-1}(C_m,\mathbb{Z})$.  It suffices to prove the claim.  Seeing that $N\tau_{2i}(1)=\tau_{2i-1}(N)=N\tau_{2i-1}(1)$ where $N$ is the norm element, we can restrict our attention to $\tau_{2i-1}$ and use induction on $i$ since $(\sigma-1)\tau_1(1)=(\sigma-1)(-\sigma^{m-1})=\sigma^{m-1}-1=\sigma^{-1}-1=\tau_0(\sigma-1)$.  This chain map must satisfy commutativity $(\sigma-1)\tau_{2i-1}(1)=\tau_{2(i-1)}(\sigma-1)$, and this is indeed the case because $(\sigma-1)\tau_{2i-1}(1)=(-1)^i(\sigma^{m-i+1}-\sigma^{m-i})$ and $\tau_{2(i-1)}(\sigma-1)=(\sigma^{-1}-1)(-1)^{i-1}\sigma^{m-i+1}=(-1)^i(\sigma^{m-i+1}-\sigma^{m-i})$.
Recap: $H^n(S_3)\cong$
$\mathbb{Z}$ for $n=0$,
$\mathbb{Z}_6$ for $n\equiv 0\;\text{mod}\,4$ with $n\ne 0$,
$\mathbb{Z}_2$ for $n\equiv 2\;\text{mod}\,4$,
$0$ otherwise


text:
Q: How to block the app opening in android 3.0? Can any one please help to block the app opening from android 3.0. I used some of the codes below but this doesn't helped me. So can any one help me with some other solutions which would work better.
<compatible-screens>
    all small size screens
    <screen android:screenSize="small" android:screenDensity="ldpi" />
    <screen android:screenSize="small" android:screenDensity="mdpi" />
    <screen android:screenSize="small" android:screenDensity="hdpi" />
    <screen android:screenSize="small" android:screenDensity="xhdpi" />
    all normal size screens
    <screen android:screenSize="normal" android:screenDensity="ldpi" />
    <screen android:screenSize="normal" android:screenDensity="mdpi" />
    <screen android:screenSize="normal" android:screenDensity="hdpi" />
    <screen android:screenSize="normal" android:screenDensity="xhdpi" />
</compatible-screens>

<uses-sdk android:minSdkVersion="8" android:maxSdkVersion="10"/>

<supports-screens
    android:xlargeScreens="false"
    android:largeScreens="false"
    android:normalScreens="true"
    android:smallScreens="true" />

Thanks in advance

A: Check the SDK version on load
int SDK_INT = android.os.Build.VERSION.SDK_INT;

and act accordingly.


text:
Q: OAuth with Dropbox API - Repeated App Confirmation Having this issue with my Dropbox App which is integrated with the OAUTH Dropbox API.
Orangedox for Dropbox
Application works fine except, everytime a user accesses the app (even after the first time) they are continuously prompted with a confirmation for the application to access their files and folders.  Is this expected behaviour? or should this only occur once when the user first accesses the application?
Anyone have experience with the Dropbox API?

A: Correct me if I'm wrong, but I think what you're asking is why when you redirect the user to the auth page, they get prompted to "allow" the app even though they already have.
This app is using OAuth 1. Dropbox does do auto redirection for OAuth 2 if the user has already authorized the app. So if you use OAuth 2 instead, a user who has already authorized your app will be forwarded directly back to the app instead of being asked to click the Allow button first.


text:
Q: Open new python shell on C-c C-c in python-mode.el I have a small GTK python application that imports a package (Twisted) that may not be loaded twice.
If I run my application in emacs with python-mode.el and press C-c C-c, the application gets executed in a python shell window.
If I now close the application, the python shell stays up and running. If I now press C-c C-c again, emacs "reuses" the old python process and thus I run into problems because I'm installing a Twisted reactor twice.
Is it possible to have python-mode.el open a new shell window each time I execute a buffer?

A: python-mode.el comes with a command py-execute-buffer-dedicated,
 opening a new and reserved process for it

A: In python.el, a new inferior process is launched in a new buffer if the python-buffer variable is set to nil. Therefore, it's possible to advise the python-send-buffer function to reset that variable to nil after every invocation, thereby forcing a new Python process to be executed for every subsequent python-send-buffer command. Something like the following should work:
(defadvice
  python-send-buffer
  (after python-send-buffer-new-proc activate)
  (setq python-buffer nil))

(ad-activate python-send-buffer)

I know that your post was asking for help with python-mode.el, but I thought it might be helpful to mention this anyway, as I'd surprised if python-mode.el doesn't use a similar mechanism. If I have time, I'll try to look into it.
Edit: the python-mode.el package uses the command py-shell to initiate a new inferior Python process. I found a mailing list posting in which a user provides an ad hoc function that appears to do what you need.
By the way, it might be worth considering that trying to alter the default behavior of python-mode isn't the best approach to this problem. I don't know what your code does, and I'm not particularly familiar with Twisted, but it seems to me that experiencing major errors when evaluating your code a second time within the same session could be a sign of a more fundamental design problem. I fail to see how it could be a matter of multiple imports of the same module being the issue, as Python modules are only loaded once, with successive import statements having no effect (for that, an explicit reload or execfile() is required). If I'm completely off-base here, I apologize, but I felt this possibility might merit mention.


text:
Q: Crontab for an rsync backup with ssh connection UBUNTU 16.04 Root Server.
I would like to have a crontab job run an rsync backup job every night at 2:14am.
It copies a "folder" from an Ubuntu 16.04 machine to another root server in the internet.
There is an ssh connection possible with a ssh key login.
The following command works in the terminal:

/usr/bin/rsync -az --delete -e ssh /home/user/folder/ user@server.example.com:/home/user/folder

But the following crontab job does not work:

14 2 * * * /usr/bin/rsync -az --delete -e ssh /home/user/folder/ user@server.example.com:/home/user/folder

I am having a hard time with crontab to be honest. It always feels to be a lucky situation if the job actually works.
Can someone see from the crontab job above what I am doing wrong?
greetings, Chris

A: The problem I had was that the ssh connection
The Host Key verification failed.
I ran the cronjob on the crontab of root.
(I added the cronjob via "sudo crontab -e".)

14 2 * * * /usr/bin/rsync -az --delete -e ssh /home/user/folder/ user@server.example.com:/home/user/folder

It seems that the ssh connection then is established by the root user and not by the "user".
So the connection attempt is actually:

ssh root@server.example.com

and not

ssh user@server.example.com

So I added the cronjob to the crontab of the "user".
(crontab -e (without sudo)).
Now the Host Key Verification works and the crontab rsync job is executed properly.
I don't know exactly if the above assumptions are correct but this solved the problem.
I hope this thread will help someone else at some stage as well.
Greetings, Chris

A: In addittion to run crontab -e as the user yo are using,  you have to create a public key without passphrase.


text:
Q: Getting time difference in python 2.7 I am importing some data from a REST API into a list. One of the columns contains just date/time information.
Column A format/example : 2015-06-11 07:59:10.000 GMT
I need to be able to check the time difference between two rows , i tried using
datetime.strptime(variable_name, "%Y-%m-%d %H:%M:%S")

however i got the following error :
ValueError: unconverted data remains: .000 GMT

Is there any way to fix this without having to modify and remove the offending part out of every entry in my list ?
Any help would be greatly appreciated.

A: You need to use %f for decimal part and %Z for timezone :
>>> variable_name='2015-06-11 07:59:10.000 GMT'
>>> datetime.strptime(variable_name, "%Y-%m-%d %H:%M:%S.%f %Z")
datetime.datetime(2015, 6, 11, 7, 59, 10)

A: Try this
datetime.strptime (time , "%Y-%m-%d %H:%M:%S.%f %Z")

"%f" is for anything that comes after the seconds. It will give the microseconds and "%Z" will give the the time zone


text:
Q: Toggling between blocks Why is this code not working and how to solve the one block is shown and some block is hide?
function vsd(){
    var asd = document.getElementById("asd");
    var vsd = document.getElementById("vsd");
    var psd = document.getElementById("psd");
    var vps = document.getElementById("vps");
    var asp = document.getElementById("asp");
    var vsp = document.getElementById("vsp");
    var sad = document.getElementById("sad");
    if (vsd.style.display === "none") {
        vsd.style.display ="block";
        asd.style.display = "none";
        psd.style.display = "none";
        vps.style.display = "none";
        asp.style.display = "none";
        vsp.style.display = "none";
        sad.style.display = "none";
    } else {
        vsd.style.display = "none";}
}

A: Be sure that vsd is in display:none mode at load time and in the else statement think to show back psd, vsd blah

A: I have replaced your approach with a  css class hide

window.onload = vsd();

function vsd(){
    var asd = document.getElementById("asd");
    var vsd = document.getElementById("vsd");
    var psd = document.getElementById("psd");
    var vps = document.getElementById("vps");
    var asp = document.getElementById("asp");
    var vsp = document.getElementById("vsp");
    var sad = document.getElementById("sad");
    console.log($("#vsd")[0].attr('style'))
    if (vsd.classList.contains("hide") {
        vsd.classList -= "hide";
        asd.classList += "hide";
        psd.classList += "hide";
        vps.classList += "hide";
        asp.classList += "hide";
        vsp.classList += "hide";
        sad.classList += "hide";
    } else {
        vsd.classList += "hide";
    }
}
.hide {
  display : none;
}
<button id="vsd" class="">vsd</button>
<button id="asd" class="hide">asd</button>
<button id="psd" class="hide">psd</button>
<button id="vps" class="hide">vps</button>
<button id="asp" class="hide">asp</button>
<button id="vsp" class="hide">vsp</button>
<button id="sad" class="hide">sad</button>


text:
Q: No query defined for that name [findStreet] I have the following entity Street.java:
@NamedQueries({
        @NamedQuery(
                name = "findStreet",
                query = "select s from Street s"
        )
})
@Entity
@Table(name = "STREET", schema = "C##HOUSE")
public class Street implements java.io.Serializable {
    ...
}

JUnit Test Case
@Test
public void test03(){
    EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("test");
    EntityManager entityManager = entityManagerFactory.createEntityManager();
    Query query = entityManager.createNamedQuery("findStreet");
    List<Street> list = query.getResultList();
}

However I am getting the following error:
java.lang.IllegalArgumentException: No query defined for that name [findStreet]


text:
Q: Set permission AWS s3 to only creator Is there a way to set access permissions (READ/WRITE) to only the creators of the buckets/objects?
We are working on a project that requires storing the data only for specific users. (I know about setting permissions to the specific groups - Admin, Developers. etc. but it's not the case here, as some other Developers are not allowed to view the items either).
Is it possible to perform it via policy?
Or it's just not possible to do so.
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AWSConfigBucketPermissionsCheck",
      "Effect": "Allow",
      "Principal": {
        "Service": "config.amazonaws.com"
      },
      "Action": "s3:GetBucketAcl",
      "Resource": "arn:aws:s3:::targetBucketName",
      "Condition": {
        "StringEquals": {
          "AWS:SourceAccount": "sourceAccountID"
        }
      }
    },
    {
      "Sid": "AWSConfigBucketExistenceCheck",
      "Effect": "Allow",
      "Principal": {
        "Service": "config.amazonaws.com"
      },
      "Action": "s3:ListBucket",
      "Resource": "arn:aws:s3:::targetBucketName",
      "Condition": {
        "StringEquals": {
          "AWS:SourceAccount": "sourceAccountID"
        }
      }
    },
    {
      "Sid": "AWSConfigBucketDelivery",
      "Effect": "Allow",
      "Principal": {
        "Service": "config.amazonaws.com"
      },
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::targetBucketName/[optional] prefix/AWSLogs/sourceAccountID/Config/*",
      "Condition": {
        "StringEquals": {
          "s3:x-amz-acl": "bucket-owner-full-control",
          "AWS:SourceAccount": "sourceAccountID"
        }
      }
    }
  ]
}


text:
Q: How to avoid "Illegal mix of collations for operation 'concat'" in procedure I have uncovered an unexplained instance of the:

*

*"Illegal mix of collations for operation 'concat'"

Which only seems to occur when I use a stored PROCEDURE.  The mystery is that all strings are literals within the script and I had expected that they all possess the same collating sequence.  There are several questions on this, though none relate to this kind of problem that I can see (I've pasted a list below for or others who find this question).
The script uses a stored procedure to do a simple heading.  Here is the original 'design':
 DELIMITER $$$
 CREATE PROCEDURE    new_script( IN  label   VARCHAR(50) )
 BEGIN
     set @SCRIPT_NAME=label;

     set @script_count:=@script_count+1;
     set @script_error_count:=0;

     set @sqlstmt := concat('select \'', @DASHES, '\' as \'', @SCRIPT_NAME, ': starting ...\'');

     PREPARE stmt FROM @sqlstmt;
     EXECUTE stmt;

     DROP PREPARE stmt;
 END$$$  -- new_script
 DELIMITER ;

The concat() statement fails with:

*

*ERROR 1271 (HY000) at line 241 in file: 'd:\work\test.sql':

*Illegal mix of collations for operation 'concat'

However WHEN I make an assignment to: @SCRIPT_NAME outside the procedure and comment-out the line:
     --  set @SCRIPT_NAME=label;

as shown, everything works!  For example:
  set @SCRIPT_NAME='dummy_script.sql';

  call new_script( 'IGNORED dummy_script.sql' );

Output:
  +--------------------------------------------------+
  | dummy_script.sql: starting ...                   |
  +--------------------------------------------------+
  |   ---------------------------------------------- |
  +--------------------------------------------------+

As required.
After playing with this a bit, I believe the problem is with the assignment from the parameter: label to the script variable: @SCRIPT_NAME.
It appears that label uses a different collation.  The thing I'd like is how to call the procedure and NOT have this error.  I would prefer not to set the value of @SCRIPT_NAME outside the new_script procedure.

*

*Is there a method to specify the SQL-script's collating sequence?  (Something like an XML header).  That way I could tell MYSQL to use the same collation for everything.

*Is there a way to find the collating sequence the SQL-script itself is using?

*Can I control the collating sequence used in the stored procedure?

*And really, why does MYSQL do this?

Or perhaps you have a better approach than these ideas -- Please share?

related:

*

*Illegal mix of collations for operation 'concat'

*Illegal mix of collations for operation 'concat' from mysql

*MySQL concatenation and Illegal mix of collations error

*"Illegal mix of collations for operation 'concat'" appears after data base import

*error Illegal mix of collations for concat

*#1271 - Illegal mix of collations for operation 'UNION'

*Illegal mix of collations for operation '='

A: SHOW PROCEDURE ...

You will see a character set / collation was established when you CREATEd the SP.  DROP the SP, SET NAME ...; and re-CREATE the SP.


text:
Q: nodejs token is empty I started studying nodejs and I ran into a problem,
when i post my login on 'postman' i got success message, but the token content is empty.
this is my server.js code:
var express = require('express');
var bodyParser = require('body-parser');
var morgan = require('morgan');
var config = require('./config');
var mongoose = require('mongoose');
var app = express();
.......
app.use(bodyParser.urlencoded({
  extended: true
}));
app.use(bodyParser.json());

and this is my api code:
var jsonwebtoken = require('jsonwebtoken');

function createToken(user){
    jsonwebtoken.sign({
        _id: user._id,
        name: user.name,
        username: user.username
    }, secretKey,{
        expiresIn: '144000000m'
    });

    return jsonwebtoken;
};
    api.post('/login',function(req,res){

        User.findOne({
            username: req.body.username
            }).select('password').exec(function(err,user){
                if (err)
                {
                    res.send(err);
                }
                else if (!user) {
                    res.send({message : "User dosen't exist."});
                }
                else if (user){
                    var validPassword = user.comparePassword(req.body.password);
                    if (!validPassword)
                    {
                        res.send({ message : "Password is incorrect." });
                    }
                    else
                    {
                        ///// token
                        var token= createToken(user);
                        if (token)
                        {
                        res.json({
                            success: true,
                            message: "Successfuly login!",
                            token: token
                        });
                        }

                        else
                        {
                            console.log('error');
                        }
                    }
                }
            })
        });

In fact at the end I get this message from 'postman':
{
    "success": true,
    "message": "Successfuly login!",
    "token": {}
}

as you can see, the token is empty.
thanks!

A: In createToken(), you need to return the token itself instead of the imported library, e.g:
function createToken(user){
    return jsonwebtoken.sign({
        _id: user._id,
        name: user.name,
        username: user.username
    }, secretKey,{
        expiresIn: '144000000m'
    });
}


text: Q: Element targeting in jquery I have an element that I am using as an expander.  When I click on it uses the toggle function to show/hide the expander-container element.


text:
Q: RequireJS text! plugin and Load timeout I'm using the text! plugin with RequireJS and Firefox seems to hate my text templates. My code seems to work just fine in Chrome and Safari. Here is the error I get.
Error: Load timeout for modules: text!templates/a.html_unnormalized2,
       text!templates/b.html_unnormalized3,
       text!templates/c.html_unnormalized4,    // _unnormalized# <- What is this?
       ...
       text!templates/n.html,    // I don't see _unnormalized here... why?
       text!templates/o.html,
       text!templates/p.html,
       ...
       http://requirejs.org/docs/errors.html#timeout

First, what does the _unnormalized# mean? It seems to append itself to the file name for some of my templates but not all. However, all of my templates are listed in the error message.
Looking at the Net inspector, it seems to be downloading the necessary template files.

A: I think I figured it out part of the mystery, although I'm not sure about the details. I noticed that this error occurs when I'm using Firebug and in the console options, ShowXMLHttpRequests is turned on. By turing this option off, the page loads without a hitch.
What do you think guys, is this a Firebug problem? Or a requireJS issue? I'd love to understand why this occurs.

A: In my case, if I just disable the "Script" tab of FireBug, I have no more freeze or time out error.
Firefox 27.0.1
Firebug 1.12.7


text:
Q: Edit the text selected in JtextPane I have two Jtextpane what i want to do is that i what to select the text from 1 Jtextpane and i want that it should appear in the second Jtextpane after a menu item Edit is selected
which i have done
 popMenu[i].addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        String str = e.getActionCommand();
                   .....
                        if (str.equalsIgnoreCase("edit")) {
                            taSecond.setBackground(new Color(0xFBFCDD));
                            taSecond.setText(taFirst.getSelectedText());
                            System.out.println("bounds====>"+taFirst.getBounds());
                            taFirst.getBounds().setBounds(taFirst.getBounds());
                            editedText = true;

                        }
                    }
                });

Now I am clueless that how would i put the edited  text back to the selcted position from where i got the text
can anyone tell the solution

A: Thank you
try {

                    doc.remove(start, end-start);
                    doc.insertString(start, str, normal);
                    editedText=false;
                } catch (BadLocationException ex) {
                    Logger.getLogger(ChatPane.class.getName()).log(Level.SEVERE, null, ex);
                }


text:
Q: Proving $(A\wedge B) \vee (\neg A\wedge \neg B)$ from $A\leftrightarrow B$ So I'm stuck on a fitch style proof to get $(A \wedge B) \vee (\neg A \wedge \neg B)$ from
$A\leftrightarrow B$. I'm not allowed to use De Morgan's or Modus Tollens for this proof.
I know I have to isolate each letter but I'm not sure how to do so because each attempt I end up isolating one of the letters but in the scope of a subproof, not the main scope line.
Right now I assumed the negation of the conclusion and eliminated the biconditional and that's what I've been working around now.
Thanks for helping.

A: *

*$A \implies B$ (base assumption)

*$B \implies A$ (base assumption)

*

*$A$ (assumption)

*$A \implies B$ (restating 1)

*$B$ (by 3 and 4, $\implies$ elim)

*$A \vee \neg A $   (taut)

*$(A \wedge B) \vee (\neg A)$ ($\wedge$ intro from 2-3)

*

*$\neg A$ (assumption)

*

*$B$ (assumption)

*$A$ (by 2)

*contradiction so $\neg B$ by above

*$\neg A \implies (\neg A \wedge \neg B)$

*($A \wedge B) \vee (\neg A \wedge \neg B)$

As you can probably tell, I'm new to this area. But i do believe this is a complete proof. Please point out any issues in the comments. (Also if anyone knows how to write out the proofs better, please do point me in the right direction or feel free to edit).

A: Here's a possible proof not assuming you already know excluded middle follows in the Fitch system as mdave16's answer did:

*

*$(A \rightarrow B) \wedge (B \rightarrow A)$ (assumption)

*$\quad A \rightarrow B, B \rightarrow A$ ($\wedge$-elim) on 1

*$\quad \lnot ((A \wedge B) \vee (\lnot A \wedge \lnot B))$ (assumption)

*$\quad\quad A \wedge B$  (assumption)

*$\quad\quad\quad (A \wedge B) \vee (\lnot A \wedge \lnot B)$ ($\vee$-intro from 4)

*$\quad\quad\quad \lnot ((A \wedge B) \vee (\lnot A \wedge \lnot B))$ (from 3)

*$\quad\quad A\wedge B \rightarrow (A \wedge B) \vee (\lnot A \wedge \lnot B)$ ($\rightarrow$-intro from 4 through 5)

*$\quad\quad A\wedge B \rightarrow \lnot ((A \wedge B) \vee (\lnot A \wedge \lnot B))$ ($\rightarrow$-intro from 4 through 6)

*$\quad\quad \lnot(A\wedge B)$ ($\lnot$-intro from 7 and 8)

*$\quad\quad A$ (assumption)

*$\quad\quad\quad A \rightarrow B$ (from 2)

*$\quad\quad\quad B$ (modus ponens from 11 and 10)

*$\quad\quad\quad A \wedge B$ ($\wedge$-intro from 10 and 12)

*$\quad\quad\quad \lnot (A \wedge B)$ (from 9)

*$\quad\quad A \rightarrow A \wedge B$ ($\rightarrow$-intro from 10 through 13)

*$\quad\quad A \rightarrow \lnot (A \wedge B)$ ($\rightarrow$-intro from 10 through 14)

*$\quad\quad \lnot A$ ($\lnot$-intro from 15 and 16)

*$\quad\quad B$ (assumption)

*$\quad\quad\quad \lnot A$ (from 17)

*$\quad\quad B \rightarrow \lnot A$ ($\rightarrow$-intro from 18 through 19)

*$\quad\quad B \rightarrow A$ (from 2)

*$\quad\quad \lnot B$ ($\lnot$-intro from 21 and 20)

*$\quad\quad \lnot A \wedge \lnot B$ ($\wedge$-intro from 17 and 22)

*$\quad\quad (A \wedge B) \vee (\lnot A \wedge \lnot B)$ ($\vee$-intro from 23)

*$\quad\quad \lnot ((A \wedge B) \vee (\lnot A \wedge \lnot B))$ (from 3)

*$\quad \lnot ((A \wedge B) \vee (\lnot A \wedge \lnot B)) \rightarrow (A \wedge B) \vee (\lnot A \wedge \lnot B)$ ($\rightarrow$-intro from 3 through 24)

*$\quad \lnot ((A \wedge B) \vee (\lnot A \wedge \lnot B)) \rightarrow \lnot ((A \wedge B) \vee (\lnot A \wedge \lnot B))$ ($\rightarrow$-intro from 3 through 25)

*$\quad (A \wedge B) \vee (\lnot A \wedge \lnot B)$ ($\lnot$-elim from 26 and 27)

*(optional) $(A \leftrightarrow B) \rightarrow ((A \wedge B) \vee (\lnot A \wedge \lnot B))$ ($\rightarrow$-intro from 1 through 28)

So, to summarize the logical flow of the proof:
Suppose $A \leftrightarrow B$; we will prove $(A \wedge B) \vee (\lnot A \vee \lnot B)$ by contradiction.  So, suppose also that $\lnot ((A \wedge B) \vee (\lnot A \vee \lnot B))$.  Then this implies $\lnot (A \wedge B)$ (up through line 9).  This in turn implies $A$ cannot be true; otherwise $B$ would also be true, and we would get a contradiction $A \wedge B$ (up through line 17).  However, since $B \rightarrow A$, if we know $\lnot A$ holds, then $\lnot B$ also holds (up through line 22).  But now we have $\lnot A \wedge \lnot B$, so $(A \wedge B) \vee (\lnot A \wedge \lnot B)$ in fact holds, contradicting the assumption (up through line 25).  Therefore, by contradiction, we have proven that $(A \wedge B) \vee (\lnot A \vee \lnot B)$ (up through line 28).

A: Here is another Fitch style proof:
$\def\fitch#1#2{\begin{array}{|l}#1 \\ \hline #2\end{array}}$
$\fitch{
1. A \leftrightarrow B \quad Premise}{
\fitch{
2. \neg ((A \land B) \lor (\neg A \land \neg B)) \quad \ Assume}
{
\fitch{
3. A \quad \ Assume}{
4. B \quad \leftrightarrow \ Elim \ 1,3\\
5. A \land B \quad \land \ Intro \ 3,4\\
6. (A \land B) \lor (\neg A \land \neg B) \quad \lor \ Intro \ 5\\
7. \bot \quad \bot \ Intro \ 2,6\\
}\\
8. \neg A \quad \neg \ Intro \ 3-7\\
\fitch{
9. B \quad Assume}{
10. A \quad \leftrightarrow \ Elim \ 1,9\\
11. \bot \quad \bot \ Intro \ 8,10\\
}\\
12. \neg B \quad \neg \ Intro \ 9-11\\
13. \neg A \land \neg B \quad \land \ Intro \ 8,12\\
14. (A \land B) \lor (\neg A \land \neg B) \quad \lor \ Intro \ 13\\
15. \bot \quad \bot \ Intro \ 2,14\\
}\\
16. \neg \neg ((A \land B) \lor (\neg A \land \neg B)) \quad \neg \ Intro \ 2-15\\
17. (A \land B) \lor (\neg A \land \neg B) \quad \neg \ Elim \ 16\\
}$


text:
Q: Metal/good conductor frame in a changing magnetic field Imagine that we put a metal/good conductor frame into a changing magnetic field. Due to the fact that this is an electromagnetic induction phenomenon, an induced EMF can be measured between the two terminals of the conducting frame (see the image below).

To the best of my knowledge, a metal/good conductor is equipotential, and the electric field inside it is always zero. So how is this possible, that there will be a potential difference between terminal A and B?
Thanks in advance!

A: If the magnetic field into the screen is increasing, there will be a non-conservative electric field urging positive charge around the conductor from A towards B.
Positive charge will then pile up on B, leaving negative on A. These charges will set up a conservative (Coulombic) electric field in the conductor acting from B towards A.
In a very short time (if the magnetic field continues to increase steadily) the resultant electric field in the conductor will be zero, yet there will be a potential difference between A and B due to the build-up of static charge.
["a metal/good conductor is equipotential, and the electric field inside it is always zero." This is not the case. An ordinary conductor carrying a current has an electric field along it. Otherwise there'd be no current.]

A: the electric field is not always zero.
If the magnetic field changes steadily, a steady non-zero voltage builds up between A and B in accordance to faraday's induction law.

A: according to Maxwell's equations, the changing magnetic field can produce non-conservative electric field which make electrons move along with the conductor.
this non-conservative electric field is called vortex electric field .


text:
Q: CloudPage: CampaignMember creation not working I have a CloudPage that contains a simple form. I ask for an email address, and upon submit, the page first checks in Salesforce if a (Person)Account exists. If not, it creates one, if so, then it updates the account.
What follows is the code below, which is supposed to check if the person is already a CampaignMember for a specific campaign. If not, it should create a CampaignMember record with Status as Responded. If so, it should update the existing record with Status as Responded. But because I need the Contact ID for that and I only have the Account ID, I start by looking up the Contact ID for the Account ID.
However, I'm getting a HTTP 500 error when I submit, and no CampaignMember record is being created. My Account gets updated, I can see the timestamp update, so my guess is that something in the CampaignMember part is wrong. Seeing as my Ampscript skills are still limited, I'm afraid it could be something really simple. Can anyone see something that could be wrong?
SET @contactId = RetrieveSalesforceObjects('Contact', 'Id', 'AccountId', '=', @accountId)
SET @sfCampaignMemberLookup   = RetrieveSalesforceObjects('CampaignMember', 'Id', 'CampaignId', '=', @campaignId, 'ContactId', '=', @contactId)
SET @sfCampaignMemberCount    = RowCount(@sfCampaignMemberLookup)

IF @sfCampaignMemberCount == 0 THEN
  SET @sfCampaignMemberResult = CreateSalesforceObject('CampaignMember', 3
      , 'CampaignId', @campaignId
      , 'ContactId', @contactId
      , 'Status', 'Responded'
    )
ENDIF

IF @sfCampaignMemberCount == 1 THEN
  SET @sfCampaignMemberId = Field(@sfCampaignMemberLookup, 'Id')
  SET @sfCampaignMemberResult = UpdateSingleSalesforceObject('CampaignMember', @sfCampaignMemberId
      , 'Status', 'Responded'
    )

Even like this, it gives the error:
SET @contactId = RetrieveSalesforceObjects('Contact', 'Id', 'AccountId', '=', @accountId)
SET @sfCampaignMemberLookup   = RetrieveSalesforceObjects('CampaignMember', 'Id', 'CampaignId', '=', @campaignId, 'ContactId', '=', @contactId)
SET @sfCampaignMemberCount    = RowCount(@sfCampaignMemberLookup)

IF @sfCampaignMemberCount == 0 THEN
  SET @sfCampaignMemberResult = CreateSalesforceObject('CampaignMember', 2
      , 'CampaignId', @campaignId
      , 'ContactId', @contactId
    )
ENDIF

Is it the Contact lookup? The count? The creation of the CampaignMember object? I've checked, and only CampaignId and ContactId (or LeadId) are required, correct?


text:
Q: Bootstrap 3: create 2 blocks with their own content in the same line with bootstrap 3 container Need to get such result:

Any solution with central block width = fixed container width. Red blocks width depends on user screen size.
If it's a trouble with HTML+CSS then js variant.

A: You can use flex for this & with calc from CSS3. However, you still need to adjust max-width based on bootstrap breakpoints of .container class.

.wrapper {
  display: flex;
  flex-flow: row wrap;
  align-items: stretch;
}

.left {
  max-width: calc(calc(100% - 720px)/2);
  background-color: red;
  display: block;
}

.container {
  background-color: yellow;
}

.right {
  max-width: calc(calc(100% - 720px)/2);
  background-color: green;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
    in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
    in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
    in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum

A: as i can see red blocks are 1/2 width of blue one so it can go like this

 LEFT

 CENTER

 RIGHT

Or if you want to hide red blocks on phone sizes you can put hidden-xs instead of col-xs-3 and put col-xs-12 in center div instead of col-xs-6
It all depends on your wish what will it do on small screens.

A: You can always do this, but it's not an orthodox method:

something red here

something green here

something red here

Also nothing stops you from adding your container inside your middle col like this:

something red here

Your new row/cols can be inserted here

something red here

for smaller screens you should modify your classes according to col-md-*, col-sm-* and col-xs-* . Also check the official link
EDIT: If you want to always have the middle container (i.e. 60% width) and the sidebars resized according to screen resolution you can do the following:

*

*You can add a new class in your container so it is like this:
 , then you can override the bootstrap css with your new class in your custom.css file, i.e.:
.myclass{
 width: 60%!important;
}
Next step is to create media queries for your desirable resolutions like this:
@media (max-width: 1024px){
  .myclass{
    width: 60%!important;
}
@media (max-width: 768px){
  .myclass{
    width: 60%!important;
}
And so on... Check about media queries here , but you can find more on the web


text:
Q: I'm trying to use regex to pattern match a line from my input file I have an input file with lines containing 10 columns in the following format:
String,Only Integer,Only String,Alpha Numeric,Alpha Numeric of length 7,
Alpha Numeric of length 7(with 1,3,4 as characters and 2,5,6,7 as digits),
Decimal(range from 0.4 to 0.8),Decimal,Only String,Only Integer of length 5

All the 10 columns are in the same line. I'm Trying to use the regex pattern to get only columns 7,8,9. I'm trying with this regex. Can someone help please.
private static class RegexParser{
   private static final String regex = "(.*),(^[0-9]*$),(^[a-z][A-Z]*$),"
              + "(^[a-z][A-Z][0-9]*$),(^[a-z][A-Z][0-9]{7}*$),"
              + "([a-z][0-9][a-z][a-z][-9][0-9][0-9]{7}*$),([0].[4-8]*$),"
              + "(^[0-9]+(.[0-9][0-9]?)?),(.*),(^[1-9]{5}*$)";
                private static final Pattern pattern = Pattern.compile(regex);

                private Matcher matcher = pattern.matcher("");

                public String parse(String line) {
                    matcher = matcher.reset(line);
                    if (matcher.matches()) {
                        String m = matcher.group(7) + matcher.group(8) + matcher.group(9);
                        return m;
                    }
                    return null;
                }
            }

A: Matching groups in regex seems like overkill for your scenario.  Use a CSV parser, or if the values are all comma-separated and no values contain commas, something as simple as this can probably do the trick.
String[] elements = line.split(",");

return elements[7] + elements[8] + elements[9];


text:
Q: AAD Privilege Escalation i was reading about AAD privilege escalation in one of the article where the author states that "if you compromise an Application Administrator account or the on-premise Sync Account you can read and modify directory settings, group memberships, user accounts, SharePoint sites and OneDrive files. This is done by assigning credentials to an existing service principal with these permissions and then impersonating these applications"
my questions are?
1.how can i find what privilege my app admin account has and how it is different from the permissions
 that "application " has.
2. what does assigning credentials to a service principal means?

A: As mentioned in Carl's link,

*

*The Application Administrator role allows users to create and manage all aspects of enterprise applications, application registrations, and application proxy settings. This role also grants the ability to consent to delegated permissions and application permissions, with the exception of permissions on the Microsoft Graph API.
Applications can have different privileges added to them, and a user in the Application Administrator role can add extra permissions to an application and theoretically use those credentials to impersonate the app's identity and have more privileges than originally intended.

*An Azure service principal is a security identity used by user-created apps, services, and automation tools to access specific Azure resources. Just as a user is represented by a security principal called a user principal, an app is represented by a service principal. The service principal provides an identity for your app, allowing you to delegate only the necessary permissions to the app. It improves security if you only grant it the minimum permissions level needed to perform its management tasks. So if you assign credentials to a service principal you can grant or restrict the app's access to certain resources.


text:
Q: ServiceStack OrmLite Many to One Relationship I just started using Service Stack ORMLite for SQL Server and not able to figure out a few things. Let me show you by example, what I am trying to achieve:
I have 2 tables - Users and Roles
public partial class Users : IHasId<int>
{
[AutoIncrement]
public int Id { get; set; }
[Required]
public string Email { get; set; }
[Required]
public string Password { get; set; }
[References(typeof(Roles))]
[Required]
public int RolesId { get; set; }
}

public partial class Roles : IHasId<int>
{
[AutoIncrement]
public int Id { get; set; }
[Required]
public string Name { get; set; }
}

A user can belong to only 1 Role. But many users can also be part of the same Role. Example:
User 1 - Role 1
User 2 - Role 1
User 3 - Role 2

When I execute this code
db.LoadSelect<Users>(x => x.Id == 1);

I get the Users object fine. I want the query to return the Roles object as well (instead of me querying the Roles table separately), how do I do that? What am I missing here? I dont want "How many Users have X Role?" (Typical One 2 Many relationship like this: ServiceStack OrmLite mapping with references not working), instead I want "What is the Role of this User?"

A: A User can only belong to 1 Role is a 1:1 relationship that is supported in OrmLite using self references by adding a Roles property to your Users table, e.g:
public partial class Users : IHasId<int>
{
    [AutoIncrement]
    public int Id { get; set; }
    [Required]
    public string Email { get; set; }
    [Required]
    public string Password { get; set; }

    [References(typeof(Roles))]
    [Required]
    public int RolesId { get; set; }

    [Reference]
    public Roles Roles { get; set; }
}

public partial class Roles : IHasId<int>
{
    [AutoIncrement]
    public int Id { get; set; }

    [Required]
    public string Name { get; set; }
}

Which will then be populated when using Load* APIs, e.g:
db.CreateTable<Roles>();
db.CreateTable<Users>();

db.Insert(new Roles { Name = "Role 1" });
db.Insert(new Roles { Name = "Role 2" });

db.Insert(new Users { Email = "user1@gmail.com", Password = "test", RolesId = 1 });
db.Insert(new Users { Email = "user2@gmail.com", Password = "test", RolesId = 1 });
db.Insert(new Users { Email = "user3@gmail.com", Password = "test", RolesId = 2 });

var user1 = db.LoadSelect<Users>(x => x.Id == 1);

user1.PrintDump();

Which prints out User 1 and Role 1:
[
    {
        Id: 1,
        Email: user1@gmail.com,
        Password: test,
        RolesId: 1,
        Roles:
        {
            Id: 1,
            Name: Role 1
        }
    }
]

I've created a Live example of this on Gistlyn you can experiment with.


text:
Q: Modification in wordpress theme? I am extremely new in wordpress, have installed it today. I am working on a task to customize main page in wordpress. I face a problem that I want to insert logo into theme which I am unable to do that
Here is the code

<--! Here I want to add my logo>

I have use theme logo plugin to insert that but it shows all the code on the screen

A: The answer is dependent on how you wish to incorporate the image into your theme.
If the image is an asset of the theme itself, meaning the files are located in the theme package, you can include the file using get_template_directory_uri().
<img src="<?php echo get_template_directory_uri(); ?>/images/logo.jpg">

WP also has a Custom Headers feature that will give you the ability to manage a header image from the WP Admin  https://codex.wordpress.org/Custom_Headers
functions.php
$args = array(
  'width'         => 980,
  'height'        => 60,
  'default-image' => get_template_directory_uri() . '/images/header.jpg',
);
add_theme_support( 'custom-header', $args );

In your theme
<img src="<?php echo( get_header_image() ); ?>" alt="<?php echo( get_bloginfo( 'title' ) ); ?>" />

A: <img src = "<?php echo get_template_directory_uri()."logo.jpg";?>" alt="logo">

Use the above code.
get_template_directory_uri() give you the path of your current theme.
Refer

A: if your logo is in "images" folder in root directory (not in your WP theme:
/images/logo.jpg

If your logo is in images folder of WP Theme:
<?php bloginfo('template_url');?>/images/logo.jpg

if your logo is not in "images" folder, then delete the reference for images folder.


text:
Q: How to test for causation in a static panel data model with small t? I have a static panel data model with small T (T=5) that makes it impossible for me to use granger causality as it requires a long time span.
So my question:

*

*Is there any alternative solution to test for causation even in a  small T context?

Any hint will be highely appreciated!

A: I guess the current (econometrics) industry standard for this setting is fixed effects regression.  Take a look at the section on panel data in this paper by Austin Nichols for a concise discussion.  For these kinds of analyses you want larger N, typically, though.  (By the way, for those with a background in statistics rather than econometrics, the usage of "fixed effects" is different for econometricians.  For them, it means a regression that uses differencing or dummy variables to account for unmeasured (linearly additive) confounders in a repeat observation setting. This is different than what statisticians usually mean, which is usually in contrasting "fixed" and "random" effects.)


text:
Q: How to make a sequential workflow automatically goto next task I have a sequential workflow with an OnWorkflowActivated and three Create Tasks which are inside of a Sequence. Currently, after the OnWorkFlowActivated is called and done executing the code, it will call the first of the three Create Tasks. However, once the first task is done executing all the code, it won't call the next two tasks. The only way one task can call the next task is by calling the actual method name, e.g.
uploadToFTPTask_MethodInvoking(sender, e);

I would like the workflow to automatically (without user input) go to the next task as long as all the code in the previous task has completed successfully. And if the code has not completed, have the workflow report that the workflow did not complete. This workflow is inside Visual Studio and not SharePoint designer.

A: I needed have a unique correlation token for each task as well as populate the task GUID at runtime and associate the ListItemID at runtime. The code inside the task method looks like this:
        UploadToFTPTask_TaskId1 = Guid.NewGuid();
        UploadToFTPTask_ListItemId1 = workflowProperties.ItemId;

With that code, I didn't need to call on the next task with its method name, the workflow automatically went to the next task as long as it had a unique TaskID and a ListItemID.


text:
Q: A few questions about the properties of $O(n)$, $o(n)$ and $\Theta(n)$ I have started learning about calculational complexities, for now only about $o(n)$, $O(n)$ and $\Theta(n)$. I am wondering whether these properties are valid - my intuition tells me that this is the case. I do not need a formal proof, just the intuition.
$$f(n) = o(g(n)) \Rightarrow f(n) = O(g(n))$$
$$f(n) = \Theta(g(n)) \iff f(n) = O(g(n)) \land g(n) = O(f(n))$$
$$f(n) = O(n) \Rightarrow f(n) = O(n^2) \Rightarrow \dots \Rightarrow f(n) = O(n^k)$$
As I have already mentioned, I think that all of them are valid. Shoudl it not be the case, could you please present a counter-example?

A: $\bullet$ If $f(n)=o\left(g\left(n\right)\right)$ then for all $\epsilon>0$ it exists $N$ such as if $n>N$
$$
\left|f(n)\right|<\epsilon \left|g(n)\right|
$$
choose $\epsilon = \pi$ ( random ) then
$$
\left|f(n)\right|<\pi \left|g(n)\right| \Rightarrow f(n)=O(g(n))
$$

A: The first one is right; $o$ means that $f/g$ goes to zero while $O$ means that $f/g$ remains bounded.
The second one is right; $\Theta$ means that both $f/g$ and $g/f$ remain bounded.
Assuming that (as usual in complexity theory) the relevant limit is $n \to \infty$, the third one is right. The point is that $n^k$ grows much slower than $n^m$ if $k<m$.

A: The first $2$ are always true and the third is true when $x\to\infty$

In an informal language:

*

*$f(x)=O(g(x))$ means "$f(x)$ growth is at most asymptotically equal to $g(x)$ growth"

*$f(x)=o(g(x))$ means "$g(x)$ growth is infinitely faster than $f(x)$ growth"

*$f(x)=\Theta(g(x))$ means "$f(x)$ growth is asymptotically equal to $g(x)$ growth"

So if $f(x)=o(g(x))$ implies that $f(x)$ growth is less than asymptotic equal to $g(x)$ growth hence we have $f(x)=O(g(x))$
If $f(x)=\Theta(g(x))$ then $g(x)$ and $f(x)$ growth is asymptotic equal hence $g(x)=O(f(x))\land f(x)=O(g(x))$
When $x\to\infty$ $x^n$ growth is less than $x^{n+1}$ growth hence $f(n) = O(n) \implies f(n) = O(n^2) \implies \dots \implies f(n) = O(n^k)$


text:
Q: How to convert an adjacency list into an adjacency matrix in Python I have an adjacency list like this:
0 1 4 5
1 0 2 6
2 1 3 7
3 2 4 8
4 0 3 9
5 0 7 8
6 1 8 9
7 2 5 9
8 3 5 6
9 4 6 7

Where the first row is saying 0 is adjacent to 1, 4, and 5; the second row is saying 1 is adjacent to 0, 2, and 6; the third row is saying 2 is adjacent to 1, 3, and 7, ...
How can I convert it into an adjacency matrix like so?
0 1 0 0 1 1 0 0 0 0
1 0 1 0 0 0 1 0 0 0
0 1 0 1 0 0 0 1 0 0
0 0 1 0 1 0 0 0 1 0
1 0 0 1 0 0 0 0 0 1
1 0 0 0 0 0 0 1 1 0
0 1 0 0 0 0 0 0 1 1
0 0 1 0 0 1 0 0 0 1
0 0 0 1 0 1 1 0 0 0
0 0 0 0 1 0 1 1 0 0

A: import numpy as np
adj_dict = {}
path_to_list = '../adj_list.txt'
# Replace with zero if vertices are connected to themselves
empty_digonal = 1
with open(path_to_list) as f:
    adj_dict = {int(line.split()[0]):[int(x) for x in line.split()[empty_diagonal:]] for line in f.read().strip('\n').splitlines()}
adj_mx = np.zeros([len(adj_dict),len(adj_dict)])
for i in adj_dict:
        adj_mx[i,adj_dict[i]] = 1
assert sum(sum(adj_mx - adj_mx.T)) == 0, 'The matrix is not symmetric'

Probably not the optimal solution, but it works

A: How about creating lists of positioned 0s and 1s, of same length, inside the dataframe and then pulling them out as series.
# the lists will all be this length
maxlen = df.max().max()

df = pd.DataFrame([
    [0, 1, 4, 5],
    [1, 0, 2, 6],
    [2, 1, 3, 7],
    [3, 2, 4, 8],
    [4, 0, 3, 9],
    [5, 0, 7, 8],
    [6, 1, 8, 9],
    [7, 2, 5, 9],
    [8, 3, 5, 6],
    [9, 4, 6, 7]])

# the function used to create the lists
def createlist(x):
    arr=(maxlen+1)*[0]
    arr[x]=1
    return arr

# create the list for each cell, then concatenate the lists per row vertically, sum them, giving each final row
df2 = df.applymap(createlist).apply(lambda x: pd.concat([pd.Series(x[i]) for i in range(len(df.columns))], axis=1).sum(axis=1),axis=1)

df2

    0   1   2   3   4   5   6   7   8   9
0   1   1   0   0   1   1   0   0   0   0
1   1   1   1   0   0   0   1   0   0   0
2   0   1   1   1   0   0   0   1   0   0
3   0   0   1   1   1   0   0   0   1   0
4   1   0   0   1   1   0   0   0   0   1
5   1   0   0   0   0   1   0   1   1   0
6   0   1   0   0   0   0   1   0   1   1
7   0   0   1   0   0   1   0   1   0   1
8   0   0   0   1   0   1   1   0   1   0
9   0   0   0   0   1   0   1   1   0   1

To set the diagonal to zeroes do something like:
df3 = df2.values

np.fill_diagonal(df3, 0)

A: import numpy as np

rows = (
    [0, 1, 4, 5],
    [1, 0, 2, 6],
    [2, 1, 3, 7],
    [3, 2, 4, 8],
    [4, 0, 3, 9],
    [5, 0, 7, 8],
    [6, 1, 8, 9],
    [7, 2, 5, 9],
    [8, 3, 5, 6],
    [9, 4, 6, 7]
)

matrix = np.zeros((10,10))
for row in rows:
    matrix[row[0],row[1:]] = 1
print(matrix)


text:
Q: How to Select specific link from Database using query in Datatable i have 117 links of paging=3 like
http://www.shophive.com/apple?cat=22& p=2

and 3 links of paging=3 like
http://www.shophive.com/apple?cat=19&p=3

i want to select just links of p=2 through Data table in C# sql ,
contains and Not IN query is not working

A: you can use this query to get specific results i guess it will help you out
select * from tablename WHERE columnName LIKE '%&p=3%'


text:
Q: Request time out when hitting api using URL Sessions I have created a function for Hitting API Methods and I use it entire project. This function was working perfect but now when I am using this function maximum times request time takes more time and I get request time out(Only when I am connected to wifi only). I am not sure it is backend issue or my code.
// MARK: Calling Web services
class func callWebServices(url: String, methodName: String, parameters: String, showLoader: Bool, completion: @escaping CompletionHandler) {

    var url_param = url
    if showLoader {
        KVNProgress.show()
    }
    if(methodName == "GET" && parameters != "") {
        url_param = url_param + "?" + parameters
    }
    var request = URLRequest(url: URL(string: url_param)!)
    request.httpMethod = methodName

    if(methodName == "POST" && parameters != "") {
        let postString = parameters
        request.httpBody = postString.data(using: .utf8)
    }
    let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
        guard let data = data, error == nil else {
            print("error = \(String(describing: error))")
            return
        }
        if let httpsStatus = response as? HTTPURLResponse, httpsStatus.statusCode != 200 {
            print("Status Code should be 200, but it is \(httpsStatus.statusCode)")
            print("response = \(String(describing: response))")
        }
        do {
            let dictData = try JSONSerialization.jsonObject(with: data, options: .mutableContainers) as! NSDictionary

            DispatchQueue.main.async {
                print("Json Result :\(dictData)")
                KVNProgress.dismiss()
                completion(dictData)
            }
        } catch {
            KVNProgress.dismiss()
            print("error is : \(error)")
        }
    }
    task.resume()
}


text:
Q: What is the best partition(Hard disk) for windows system? I have lot of multimedia, audio, video, images, etc,
How should i partition my hard disk for effective usage of space?

A: Whether or not you have multiple partitions is really a matter of personal taste
The advantage of having multiple partitions is if you reinstall frequently, you can seperate your personal files from the system files (eg, my documents in windows XP, users in windows vista and better, and /home/ in linux). The disadvantage is that if you missize the partitions, you'll need to resize them.Personally, i don't do multiple partitions - i used to, but its only a feature of my multiboot boxen cause it was often a pain to manage if you get it wrong. partitioning also has a tiny bit of overhead
The most effective way to handle it, to me is to let the filesystem do all the hard work, and just have one partition. Depending on your OS, you may want to consider deduplicating file systems if possible if you really want to be efficient.
On the other hand, if you have seperate drives for system boot, and data, you get some degree of redundancy, and the ability to mix and match drives - for example, a SSD for OS (which is faster) and a large standard HDD for data.

A: I kinda agree with most folk who've already answered, but you're quite clear in your question that you're interested in effective usage of space. In that case I'd recommend having one partition.
The reason I say that is if you think you might start running out of space, partitions can be a b!tch. It's frustrating having 2GB free on three partitions, and having one 3GB file that you can't store anywhere. It might sound a little contrived, but in practice I think that's been my experience (personally it doesn't bother me in the slightest as I'm not particularly focussed on being efficient with space, but that's another matter.)

A: You should make one partition for Windows and programs, and a second partition for data.
The size of the first partition depends on what kind of programs you use.
I would probably recommend about 100GB + 5GB per game.

A: Partitioning has no overhead whatsoever. Partitioning is a function of the file system. Basically, partitions are nothing but break points in the record of the file system. It's like adding a new section title to a table of contents. The biggest advantage of partitioning is that you can separate data. For example, I keep my OS and programs separate from my documents and music. I image my OS partition and I create a file backup for my documents and music. I image my OS partition every week and I file backup my documents and music as needed. If my OS gets corrupted, I don't have to worry about moving my documents and music since I can just reimage a single partition and be up and running again.

A: Advantage of having more than one partition.

*

*If you run out of space in your data partition, your system partition is unaffected.  No boot problem on the following morning if vuze or emule have been running all night long.

Disadvantage of having separate partitions:

*

*Drag and drop between 2 partitions on the same disk are copies unless you know what you're doing and press CTRL/SHIFT to achieve your goal.  So that you end up with too much clutter.  Edit thx to Andy's comment.  Even if you move (as opposed to copy), you can't escape the IO cost sincce there are in effect two different file systems involved.

*Some people back up files from one partition to the other which has no added value whatsoever in case of HDD failure.
Size of a system partition in 2011
Now to answer your question more precisely, I'd says that, given the size of today's HDD, a 100GB system partition is not particularly oversized.


text:
Q: Preserve padding while setting an axis limit in matplotlib Setting xlim and ylim for axis in pyplot removes the padding. How to set them without changing the padding?
Example:
fig, ax = plt.subplots()
x = np.linspace(0, 200, 500)
ax.set_ylim(ymax=100)
line = ax.plot(x, data, '--', linewidth=2, label='foo bar')
plt.show()

In the plot shown, x axis will have a padding while y axis don't. How to make them both have padding while having the ylim I want?

A: Axes.set_ymargin and Axes.set_ylim are mutually exclusive. Setting a limit to an axis overwrites the margin.
There are two options to have a margin (padding).
a. use margins
It's possible to adapt the margin using
ax.set_ymargin(0.1)   or   ax.margins(y=0.1)
where 0.1 would be a 10% margin on both axis ends. (Same for x axis of course). The drawback here is that the margin is always symmetric.
b. use limits
Using the limits set by ax.set_ylim(0, 100) and adapt them to the needs.
E.g. if data is the data to plot in form of a numpy array, and we want to have a 10% margin to the bottom and a 40% margin to the top, we could use
ymin = data.min()-0.1*(data.max()-data.min())
ymax = data.max()+0.4*(data.max()-data.min())
ax.set_ylim((ymin, ymax))

It would of course equally be possible to simply set ymax to ymax = 100, if this is desired.

A: With matplotlib 3.5, I used autoscaling as follows;
axs[row,column].plot(divs['Dividends'], c='red',linewidth=1, marker='.', mec='blue',mfc='blue')
axs[row,column].set_ylim(bottom = 0)
axs[row,column].autoscale()

Solved this problem for me. See attached pics of the graphs for the difference autoscaling did.
Using .margins() with a value or 'tight=True' or .set_ymargin() didn't seem to do anything no matter what values I used to pad.
Changing the lower or bottom limit to <0 moved the Zero line well up the y axis when dividends in my examples are close to zero.
Graph with Autoscaling
Graph without Autoscaling

A: You can modify the ax.dataLim bounding box and reapply ax.autoscale_view()
Before:
fig, ax = plt.subplots()
x = np.linspace(0, 10, 11)
line = ax.plot(x, x, '--', linewidth=2, label='foo bar')

After:
pts = ax.dataLim.get_points()  # numpy array [[xmin, ymin], [xmax, ymax]]
pts[1, 1] = 11  # new ymax
ax.dataLim.set_points(pts)
ax.autoscale_view()


text:
Q: How to jump to a slide in a beamer presentation? I have to prepare a beamer presentation, but depending on the audience, during the presentation I might decide to skip some material.  Is there a way to do this without having to skip quickly through the slides?  I seem to remember that there was a command, but I forgot what it was and anyway I never succeeded in having it work.  Thanks for your help!

A: Beamer offers a variety of navigation buttons for such purposes. Together with the \hyperlink command they can be used to conveniently jump to other slides or frames.
\documentclass{beamer}

\begin{document}
\begin{frame}
1

\hyperlink{foo}{\beamerskipbutton{skip slide}}

\end{frame}

\begin{frame}
2
\end{frame}

\begin{frame}[label=foo]
3
\end{frame}
\end{document}

For more examples, please see section 11.1 Adding Hyperlinks and Buttons from the beamer user guide.

A:

*Add \usepackage{hyperref} to the preamble. (Or, immediately above \begin{document})

*Label the frame you want to go to. For this, add \label{SOME_NAME} after \begin{frame}.

*Where needed, place the icon that links to that slide:
 \hyperlink{SOME_NAME}{\beamerbutton{link}}

which produces this:

You can change the icon style and text accordingly.

*If you want to go back to the slide you were before, you can add another link button as above. For neatness, (e.g. if going back to a slide shown before), this button can be invisible. For instance, add this:
 \hyperlink{back}{\hspace{3cm}}

where back is the label of the original slide.

A: You could use the hyperref package and create references to the slides you want to view.


text:
Q: I want to do Triangle-like Carousel but How? How can reach info for this shaped carousel

I searched "triangle carousel", "pointy carousel", "sharp carousel" and found nothing

A: You could use clip-path property to do so

.caroussel {
  background-color: teal;
  height: 80vh;
  display: flex;
  justify-content: center;
  align-items: center;
  clip-path: polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%);
}

h1 {
  font-size: 4rem;
  color: white;
}

Hello