text:
Q: How to display data when in grid? How to display data when toggle  list view of 8 items and grid view of 12 items in Vuejs?
My working Codepen link   https://codepen.io/santoshch/pen/wvJBjKq

var demo = new Vue({
  el: '#main',
  data: {
        // The layout mode, possible values are "grid" or "list".
    layout: 'grid',

        articles: [{
            "title": "What You Need To Know About CSS Variables",
            "url": "http://tutorialzine.com/2016/03/what-you-need-to-know-about-css-variables/",
            "image": {
                "large": "http://cdn.tutorialzine.com/wp-content/uploads/2016/03/css-variables.jpg",
                "small": "http://cdn.tutorialzine.com/wp-content/uploads/2016/03/css-variables-150x150.jpg"
            }
        },
        {
            "title": "Freebie: 4 Great Looking Pricing Tables",
            "url": "http://tutorialzine.com/2016/02/freebie-4-great-looking-pricing-tables/",
            "image": {
                "large": "http://cdn.tutorialzine.com/wp-content/uploads/2016/02/great-looking-pricing-tables.jpg",
                "small": "http://cdn.tutorialzine.com/wp-content/uploads/2016/02/great-looking-pricing-tables-150x150.jpg"
            }
        },
        {
            "title": "20 Interesting JavaScript and CSS Libraries for February 2016",
            "url": "http://tutorialzine.com/2016/02/20-interesting-javascript-and-css-libraries-for-february-2016/",
            "image": {
                "large": "http://cdn.tutorialzine.com/wp-content/uploads/2016/02/interesting-resources-february.jpg",
                "small": "http://cdn.tutorialzine.com/wp-content/uploads/2016/02/interesting-resources-february-150x150.jpg"
            }
        },
        {
            "title": "Quick Tip: The Easiest Way To Make Responsive Headers",
            "url": "http://tutorialzine.com/2016/02/quick-tip-easiest-way-to-make-responsive-headers/",
            "image": {
                "large": "http://cdn.tutorialzine.com/wp-content/uploads/2016/02/quick-tip-responsive-headers.png",
                "small": "http://cdn.tutorialzine.com/wp-content/uploads/2016/02/quick-tip-responsive-headers-150x150.png"
            }
        },
        {
            "title": "Learn SQL In 20 Minutes",
            "url": "http://tutorialzine.com/2016/01/learn-sql-in-20-minutes/",
            "image": {
                "large": "http://cdn.tutorialzine.com/wp-content/uploads/2016/01/learn-sql-20-minutes.png",
                "small": "http://cdn.tutorialzine.com/wp-content/uploads/2016/01/learn-sql-20-minutes-150x150.png"
            }
        },
        {
            "title": "Creating Your First Desktop App With HTML, JS and Electron",
            "url": "http://tutorialzine.com/2015/12/creating-your-first-desktop-app-with-html-js-and-electron/",
            "image": {
                "large": "http://cdn.tutorialzine.com/wp-content/uploads/2015/12/creating-your-first-desktop-app-with-electron.png",
                "small": "http://cdn.tutorialzine.com/wp-content/uploads/2015/12/creating-your-first-desktop-app-with-electron-150x150.png"
            }
        }]

  }
});

{{a.title}}

I am able to successfully toggle between grid and list view. But Now the issue is i need to display like
For list-view 8 items and grid-view 12 items

A: I updated your codepen here : https://codepen.io/Sorakkaist/pen/yLMeggN
As mentionned by previous answer, you can use a computed reacting to the layout changes:
tableSize() {
    return this.layout === "grid" ?  8 : 10
 }

Then instead of looping on items, you base your v-for on another computed :
rows() {
    return this.items.slice(0, this.tableSize)
 },

in your template :

{{row}}

A: You can use a computed property for that, e.g. filteredArticles, which will return 8 or 12 entries depending on the layout chosen using Array.prototype.slice:
computed: {
  filteredArticles () {
    return this.articles.slice(0, this.layout === 'list' ? 8 : 12);
  }
}

Then it is just a matter of using filteredArticles instead of articles in your v-for binding.


text:
Q: PHP: Enchant Spell Checking not working. Configuration in Windows? I am attempting to get a PHP spell checking app working, however when I try and use the Enchant extension, I can't get it to check a word for spelling errors.
Web server config

*

*PHP version 5.4.7

*Windows Server 2008

*IIS 7

In the php.ini file I have enabled the Enchant extension. eg:
extension=php_enchant.dll

Sample code:
    $broker = enchant_broker_init();
    $tag = 'en_US';

    $bprovides = enchant_broker_describe($broker);
    echo "Current broker provides the following backend(s):\n";
    print_r($bprovides);

    $dicts = enchant_broker_list_dicts($broker);
    echo "Current broker provides the following dictionaries:\n";
    print_r($dicts);

    enchant_broker_set_dict_path($broker, ENCHANT_MYSPELL, 'C:\php5.4.7\lib\enchant\MySpell');

    if (enchant_broker_dict_exists($broker, $tag)) {
     $dict = enchant_broker_request_dict($broker, $tag);
     $word = 'soong';
     $isCorrectlySpelled = enchant_dict_check($dict, $word);

     if ($isCorrectlySpelled !== true) {
      $suggestions = enchant_dict_suggest($dict, $word);

      echo nl2br(print_r($suggestions, true));
     } else {
      echo 'The word is correctly spelt!';
     }
    }

    enchant_broker_free($broker);

Returns:
Current broker provides the following backend(s):
Array
(
    [0] => Array
        (
            [name] => ispell
            [desc] => Ispell Provider
            [file] => C:\php5.4.7\libenchant_ispell.dll
        )

    [1] => Array
        (
            [name] => myspell
            [desc] => Myspell Provider
            [file] => C:\php5.4.7\libenchant_myspell.dll
        )

)
Current broker provides the following dictionaries:

However, this doesn't tell me if the word "soong" is spelt correctly or not!

A: It turns out that it is quite easy to get the Enchant extension working in Windows, IIS and PHP 5.4.7!
All you need to do is create some folders, download some dictionary files and it works brilliantly!
Go to https://wiki.mozilla.org/L10n:Dictionaries and download the dictionaries that you want to spell check against.
Then create this directory structure in your PHP folder: [PHP]\share\myspell\dicts
Finally, place the *.aff and the *.dic files (eg. en_US.aff and en_US.dic) into the dicts folder and then it works!
Now the code above returns the dictionary information, plus the spelling suggestions!
Current broker provides the following backend(s):
Array
(
    [0] => Array
        (
            [name] => ispell
            [desc] => Ispell Provider
            [file] => C:\php5.4.7\libenchant_ispell.dll
        )

    [1] => Array
        (
            [name] => myspell
            [desc] => Myspell Provider
            [file] => C:\php5.4.7\libenchant_myspell.dll
        )

)
Current broker provides the following dictionaries:
Array
(
    [0] => Array
        (
            [lang_tag] => en_GB
            [provider_name] => myspell
            [provider_desc] => Myspell Provider
            [provider_file] => C:\php5.4.7\libenchant_myspell.dll
        )

    [1] => Array
        (
            [lang_tag] => en_US
            [provider_name] => myspell
            [provider_desc] => Myspell Provider
            [provider_file] => C:\php5.4.7\libenchant_myspell.dll
        )

)
Array
(
    [0] => suing
    [1] => sung
    [2] => goons
    [3] => song
    [4] => soon
    [5] => soon g
)

Credits:
http://www.php.net/manual/en/enchant.examples.php#109925
http://my.opera.com/iwanluijks/blog/using-enchant-with-php-on-windows-part-1

A: In my case it didn't even listed those backends!!!
You need to copy libenchant_ispell.dll and libenchant_myspell.dll to "c:\PHP\lib\enchant".
Then after downloading dictionaries and using this UNDOCUMENTED function:
enchant_broker_set_dict_path($broker, ENCHANT_MYSPELL, 'C:\PHP\enchant\MySpell');

I made it finally work!

A: I had to perform a combination of steps suggested by others here and elsewhere.  I couldn't find a single place on the net that had all of these steps documented in the same place so I'm writing them here.  I'm using Windows 7 and php 5.5 installed from xamp.  Here is what I had to do:

*

*Uncomment the extension=php_enchant.dll line in php.ini

*Add the php installation directory to the windows PATH.  Otherwise php_enchant.dll won't be able to find libenchant.dll

*Move libenchant_ispell.dll and libenchant_myspell.dll from the php installation directory to [php]/lib/enchant/ .  You'll have to create these folders.

*Add en_US.aff and en_US.dic to [php]/share/myspell/dicts .  You'll have to create these folders too.  Those files can be found in C:\Program Files\Firefox\dictionaries under slightly different names.  But they must be renamed to en_US.aff and en_US.dic or they won't work.

After the steps and removing the call to enchant_broker_set_dict_path() in Paul's code, it worked great.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Forcing ResourceBundleViewResolver to load view.properties file from specific location Is there a way to set a specific location where the ResourceBundleViewResolver should look for the view.properties files?
By specific location I mean somewhere not inside the classpath but anywhere in the file system / network resource.
Thanks in advance.

A: It doesn't have to be in WEB-INF/classes, it just has to be somewhere on the classpath, and WEB-INF/classes is usually the most convenient place.
If you want to put it somewhere else, then you're free to do so, as long as it's in the "root" on the classpath, e.g. inside a JAR under WEB-INF/lib.
Furthermore, it doesn't have to be called views.properties, it can be anything you like. Read the javadoc for ResourceBundleViewResolver.setBaseName():

Set a single basename, following
  ResourceBundle  conventions. The
  default is "views".
ResourceBundle supports different
  suffixes. For example, a base name of
  "views" might map to ResourceBundle
  files "views", "views_en_au" and
  "views_de".
Note that ResourceBundle names are
  effectively classpath locations: As a
  consequence, the JDK's standard
  ResourceBundle treats dots as package
  separators. This means that
  "test.theme" is effectively equivalent
  to "test/theme", just like it is for
  programmatic java.util.ResourceBundle
  usage.

So it can be anywhere in the classpath you like. ResourceBundleViewResolver is a lot more flexible than you're giving it credit for - it pays to read the documentation.


text:
Q: Trouble with python3 and pip I'm on Linux Mint 18.3 Sylvia.
I have an issue with pip and python3, and no other issues helped me actually.
dsds
Everything work when I do
python -m pip --version pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
But whenusing python3 doing
python3 -m pip --version
I get the following message
Traceback (most recent call last):   File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main "__main__", mod_spec) File "/usr/lib/python3.5/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/max/.local/lib/python3.5/site-packages/pip/__main__.py", line 21, in <module> from pip._internal.cli.main import main as _main File "/home/max/.local/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 60 sys.stderr.write(f"ERROR: {exc}") ^ SyntaxError: invalid syntax
Any ideas to how solve this ? Thanks you!
edit: python command is Python 2.7.12
edit2: I originally wanted to install matplotlib as described here. By using the command python -m pip install -U pip as told in the installation process. This is probably the issue, as now it show the error for both python and python3 command...

A: Here's what I would try.
$ wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py

That should run the latest get-pip and install it in your python3 installation. As mentioned in my comment on your question, it looks like the version of pip that is installed is incompatible with your version of Python (it's running 3.6+ code in 3.5) so maybe installing fresh will make life better.

A: You must at first remove all pip* files :
sudo rm -rf /usr/local/lib/python3.x/dist-packages/pip*

Then reinstall pip :
sudo apt install python3.x-pip

A: When you are writing "python" on command windows
Which version it shows ?
Having python 2 and 3 simoltaneously should not make problem for you
But sometimes it is conflicting because of environmental variable or path.


text:
Q: resizing images in a folder using python PIL #!/usr/bin/python
from PIL import Image
import os, sys

path = "C:/Users/nonono/Desktop/hypergan/data/trainingData/"
dirs = os.listdir( path )

def resize():
    for item in dirs:
        if os.path.isfile(path+item):
            im = Image.open(path+item)
            f, e = os.path.splitext(path+item)
            imResize = im.resize((256,256), Image.ANTIALIAS)
            imResize.save(f + ' resized.jpg', 'JPEG', quality=90)

resize()

i got this code from another answer here and fitted it to my own parameters, yet when i run it in the command line i get an error:
Traceback (most recent call last):
  File "resize.py", line 16, in <module>
    resize()
  File "resize.py", line 11, in resize
    im = Image.open(path+item)
  File "C:\Users\nonono\AppData\Local\Programs\Python\Python37\lib\site-packages\PIL\Image.py", line 2822, in open
    raise IOError("cannot identify image file %r" % (filename if filename else fp))
OSError: cannot identify image file 'C:/Users/nonono/Desktop/hypergan/data/trainingData/bx71zze7egy18wel231 resized.jpg'

the folder trainingData is filled with a large amount of images, that i want to resize to 256x256 regardless of aspect ratio, i will not need the images afterwards so if there is a way to replace the images instead of just copying, resizing, and renaming, that would be great (unless i am reading this incorrectly, i have about 2 weeks experience in python)
any help would be appreciated


text:
Q: ¿Por que al recuperar datos de un archivo JSON no funciona con POST? Aprendiendo ajax me topo con que no funciona el llamado en html y la consola da el siguiente error

XHR POST "archivo JSON" [HTTP/1.1 405 Method Not Allowed 1ms].

La consigna del problema era cambiar la peticion con GET a con POST. Siendo html el archivo no funciona, verifique el codigo y no encuentro errores. Cambien el archivo a php y funciono sin mas. Si alguien es tan amable de explicarme esto se lo agradeceria. Dejo el codigo por las dudas
html:
   function mostrarSugerencia(str) {
   var paisElegido='';
   if (str=='spain') {paisElegido='España';}
   else if (str=='mexico') {paisElegido='México';}
   else if (str=='argentina') {paisElegido='Argentina';}
   else if (str=='colombia') {paisElegido='Colombia';}
   else {paisElegido='none';}

   var xmlhttp;
   if (str.length==0 ||paisElegido=='none') { document.getElementById("txtInformacion").innerHTML="no hay datos";
   mostrarCiudades(); return; }
   xmlhttp=new XMLHttpRequest();
   xmlhttp.onreadystatechange = function() {
   if (xmlhttp.readyState==4 && xmlhttp.status==200) {
       var jsonResponse = xmlhttp.responseText;
       var objeto_json = JSON.parse(jsonResponse);
       paisesRecibidos = objeto_json.listadoPaises.pais;
       for (var i=0; i<paisesRecibidos.length;i++) {
       var nombrePais = objeto_json.listadoPaises.pais[i].nombre;
           if (nombrePais==paisElegido) {
           document.getElementById("txtInformacion").innerHTML = 'El pais recibido por get en segundo plano es '+nombrePais+ ' y tiene indice '+i;
           var ciudadesPais = objeto_json.listadoPaises.pais[i].ciudadImportante;
           mostrarCiudades(ciudadesPais);
           }
       }

   }
   }

   var cadenaParametros = 'pais='+encodeURIComponent(str);
   xmlhttp.open('POST', 'listadoPaises.json'); // Método post y url invocada
   xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); // Establecer cabeceras de petición
   xmlhttp.send(cadenaParametros); // Envio de parámetros usando POST

   }

   function mostrarCiudades (arrayCiudades) {
   var nodoMostrarResultados = document.getElementById('listaCiudades');
   if (!arrayCiudades) {nodoMostrarResultados.innerHTML = ''; return}
   var contenidosAMostrar = '';
   for (var i=0; i<arrayCiudades.length;i++) {
       contenidosAMostrar = contenidosAMostrar+'
';
       contenidosAMostrar += '' + arrayCiudades[i]+ '
';
   }
   if (contenidosAMostrar) {nodoMostrarResultados.innerHTML = contenidosAMostrar;}
   }
   </script>


text:
Q: Does SVN support merging into sparse checkouts? I'm trying to merge a branch into a sparse checkout (all the files I touched in the branch are included in the checkout) and I'm getting the following error:

Cannot reintegrate into a working copy not entirely at infinite depth

Does this mean what I think it means? That you have to have a fully recursive checkout in order to merge into?

A: Just an update for anybody that stumbles across this (like I did)...
SVN 1.7 now supports this functionality.  I haven't tried to reintegrate yet but merging a range of revisions seems to work well.
TortoiseSVN 1.7 also has some nice features for working with sparse checkouts.

A: Merging into a full checkout worked, this is anecdotal evidence that you cannot merge into a sparse checkout.


text:
Q: Clear browser cache on background In our company we have web app (backend spring, frontend angularjs) which displays lot of photos and they are used for some evaluations. Default browser is FF. After some time period (10-20min) the working with app is so slowen down that it is almost unusable. In that case user press Ctrl+F5 and it is OK again.
The question: exists any javascript method to clear cache or simulate Ctrl+F5 on background WITHOUT showing the confirmation dialog "This page is asking you to confirm that you want to leave..."?
Thanks a lot for help.
Regards


text:
Q: Exportar arquivo .SAP no R Seria possivel exportar um arquivo em .SAP utilizando R ou Python ?
Encontre um tutorial que dizia que no R para exportar em .SAP seria da seguinte forma:
write_sas(df, "table.sas7bdat")

Porém fiquei com uma duvida, quando faço essa extração o final do arquivo fica realmente com a extensão ".sas7bat", só que em outro sistema que exporta em .SAP ele fica com a extensão .SAP

A: O pacote haven disponibiliza duas formas de exportar arquivo para o SAS no  R. Estas duas formas estão empacotadas nas funções write_sas() e write_xpt(). Você pode ler na documentação delas qual forma é mais adequada às suas necessidades.
Qualquer arquivo que você gerar com essas funções poderá ser lido no SAS, INDEPENDENTE DO SEU NOME (E PORTANTO EXTENSÃO)
O SAS será capaz de ler arquivos com a extensão errada (desde que seja de fato um arquivo para ser lido pelo SAS).
library(haven)
td <- tempdir()
# Arquivo com extensao errada
write_sas(mtcars, paste0(td, "/iris.xlsx"))
read_sas(paste0(td, "/iris.xlsx"))
#> # A tibble: 32 x 11
#>      mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb
#>    <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#>  1  21       6  160    110  3.9   2.62  16.5     0     1     4     4
#>  2  21       6  160    110  3.9   2.88  17.0     0     1     4     4
#>  3  22.8     4  108     93  3.85  2.32  18.6     1     1     4     1
#>  4  21.4     6  258    110  3.08  3.22  19.4     1     0     3     1
#>  5  18.7     8  360    175  3.15  3.44  17.0     0     0     3     2
#>  6  18.1     6  225    105  2.76  3.46  20.2     1     0     3     1
#>  7  14.3     8  360    245  3.21  3.57  15.8     0     0     3     4
#>  8  24.4     4  147.    62  3.69  3.19  20       1     0     4     2
#>  9  22.8     4  141.    95  3.92  3.15  22.9     1     0     4     2
#> 10  19.2     6  168.   123  3.92  3.44  18.3     1     0     4     4
#> # ... with 22 more rows

O SAS também será capaz de ler arquivos sem extensão:
# Arquivo sem extensao
write_sas(mtcars, paste0(td, "/sem_extensao"))
read_sas(paste0(td, "/sem_extensao"))
#> # A tibble: 32 x 11
#>      mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb
#>    <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#>  1  21       6  160    110  3.9   2.62  16.5     0     1     4     4
#>  2  21       6  160    110  3.9   2.88  17.0     0     1     4     4
#>  3  22.8     4  108     93  3.85  2.32  18.6     1     1     4     1
#>  4  21.4     6  258    110  3.08  3.22  19.4     1     0     3     1
#>  5  18.7     8  360    175  3.15  3.44  17.0     0     0     3     2
#>  6  18.1     6  225    105  2.76  3.46  20.2     1     0     3     1
#>  7  14.3     8  360    245  3.21  3.57  15.8     0     0     3     4
#>  8  24.4     4  147.    62  3.69  3.19  20       1     0     4     2
#>  9  22.8     4  141.    95  3.92  3.15  22.9     1     0     4     2
#> 10  19.2     6  168.   123  3.92  3.44  18.3     1     0     4     4
#> # ... with 22 more rows

E até com a extensão correta:
# O mesmo serve para as funções *_xpt
write_xpt(mtcars, paste0(td, "/mtcars.xpt"))
read_xpt(paste0(td, "/mtcars.xpt"))
#> # A tibble: 32 x 11
#>      mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb
#>    <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#>  1  21       6  160    110  3.9   2.62  16.5     0     1     4     4
#>  2  21       6  160    110  3.9   2.88  17.0     0     1     4     4
#>  3  22.8     4  108     93  3.85  2.32  18.6     1     1     4     1
#>  4  21.4     6  258    110  3.08  3.22  19.4     1     0     3     1
#>  5  18.7     8  360    175  3.15  3.44  17.0     0     0     3     2
#>  6  18.1     6  225    105  2.76  3.46  20.2     1     0     3     1
#>  7  14.3     8  360    245  3.21  3.57  15.8     0     0     3     4
#>  8  24.4     4  147.    62  3.69  3.19  20       1     0     4     2
#>  9  22.8     4  141.    95  3.92  3.15  22.9     1     0     4     2
#> 10  19.2     6  168.   123  3.92  3.44  18.3     1     0     4     4
#> # ... with 22 more rows
Created on 2019-02-22 by the reprex package (v0.2.1)

Nota sobre extensões
A extensão de um arquivo ajuda a entender o formato daquele arquivo, mas ela só ajuda e está pensada basicamente para humanos.
Programas costumam usar outros métodos para verificar como ler aquele arquivo. Uma delas, não sei se a única ou mesmo a mais utilizada, é ter uma número mágico da extensão. Mais informações sobre número mágico podem ser encontradas aqui.
No windows a extensão do arquivo é como o sistema operacional decide qual programa usará para abrir o arquivo por padrão, mas você pode escolher outro na mão caso queira ou ele não saiba qual usar.


text:
Q: Where can I find documentation for the \nolinebreak command? Where can I find documentation on how to use the \nolinebreak command?
The Guide to LaTeX2e for Authors at latex-project.org never makes mention of \nolinebreak
The source code guide states that \nolinebreak is implemented by multiplying its input parameter penalty by (-1) and passing the result into \nopagebreak.
I haven't found documentation on how to use the command.

A: The LaTeX2e source fails to emphasize that \linebreak and \nolinebreak deals with horizontal list output, while \pagebreak and \nopagebreak deals with vertical list output. It's just mentioned to be analogous.

Here is the code for \linebreak, from latex.ltx:
\def\linebreak{\@testopt{\@no@lnbk-}4}
\def\nolinebreak{\@testopt\@no@lnbk4}
\def\@no@lnbk #1[#2]{%
  \ifvmode
    \@nolnerr
  \else
    \@tempskipa\lastskip
    \unskip
    \penalty #1\@getpen{#2}%
    \ifdim\@tempskipa>\z@
      \hskip\@tempskipa
      \ignorespaces
    \fi
  \fi}

From this we see that both \linebreak and \nolinebreak calls \@no@lnbk internally. Calling \linebreak results in the first argument of \@no@lnbk to be a negative -, while \nolinebreak doesn't supply a first argument (or leaves it empty). In fact, \nolinebreak is equivalent to \linebreak[4].
Within \@no@lnbk, a test is made to ensure you're not in vertical mode (\ifvmode). If you are in vertical mode, \linebreak and \nolinebreak will result in an error (\@nolnerr or "There's no line here to end."). The following example replicates this failure:
\documentclass{article}

\begin{document}

Lorem ipsum

\linebreak

\end{document}

If you are not in vertical mode, the last skip is stored, undone (\unskip) and a \penalty is inserted. Penalties can increase or decrease the "badness" of what is being set on the page. Inserting a negative penalty (when you're using \linebreak) reduces the badness and therefore encourages a breaking point, while a positive penalty (when using \nolinebreak) increases the badness and therefore discourages a breaking point.
Once the penalty has been inserted, the original skip is replaced (and subsequent spaces inserted in the code is ignored (\ignorespaces). The penalty has to be inserted before the skip to avoid visually-odd breaking points.

\linebreak is equivalent to \linebreak[4], while

*

*\linebreak[0] inserts \penalty -0 (not necessary);

*\linebreak[1] inserts \penalty -\@lowpenalty (\penalty -51);

*\linebreak[2] inserts \penalty -\@medpenalty (\penalty -151);

*\linebreak[3] inserts \penalty -\@highpenalty (\penalty -301); and

*\linebreak[4] inserts \penalty -\@M (\penalty -10000)

*\nolinebreak inserts \penalty \@M (\penalty 10000)

A: See Sec. 9.8, texdoc latex2e. There is an online version on latexref.xyz. If you are interested in topic penalty, you can read TeX related books like The TeXbook and TeX by Topic.

A: You can find the command description in the LaTeX manual or in the LaTeX companion.
From the LaTeX manual (page 95):

Although unwanted line breaks are usually prevented with the ~ and \mbox commands described in Section 2.1.1, LaTeX also provides a \nolinebreak command that forbids TeX from breaking a line at that point. Like the \linebreak command, \nolinebreak takes a digit from 0 to 4 as an optional argument to convert the prohibition into a suggestion that this isn't a good place for a line break—the higher the number, the stronger the suggestion. A \nolinebreak[0] command is equivalent to \linebreak[0], and \nolinebreak[4] is equivalent to \nolinebreak.

On page 213:

\linebreak[num]
\nolinebreak[num]
  The \linebreak command encourages and \nolinebreak discourages a line break, by an amount depending upon num, which is a digit from 0 to 4. […]


text:
Q: Wordpress Nav menu: doesn't show on custom post type category pages I'm working on a WordPress site with 2 custom post types. For some reason that I cannot figure out, my nav menus are not displaying on my category.php pages. The header.php file is being called and rendered just fine, and the Nav menu works on all other pages. So, I believe the problem is not to do with the WP Nav menu, but with the query.
I had the same issue with my footer Nav menu. I found others who solved this problem by resetting the query to NULL just before footer.php is called. This works, though it seems like a poor solution.
Of course, I cannot do this before header.php is called because I need to use the query in order to fetch and render all the content on the page. I'm really stuck here. Has anyone else had this problem?
--- UPDATE ---
This is working, and is based on the same principle mentioned above: reset the query, get the nav menu.
// store the query in a variable
$query_store = $wp_query;

// reset the query
$wp_query = NULL;
$wp_query = new WP_Query(array('post_type' => 'projects'));

// get the header
get_header();

// retrieve the query from storage, use it
$wp_query = $query_store;

I am also sorting by custom meta_values. I am able to pass the active category to the new query using this method:
// get the current category, pass it to the new query arguments below
if (is_category('category-one')) { $category_name = 'category-one'; }
if (is_category('category-two')) { $category_name = 'category-two'; }

However, this presents another issue: the  class list (set in header.php) no longer contains the category class (which affects my CSS).
My original question still remains: is there a cleaner way to do this?

A: have you tried adding the 2 functions below at the end of every wp loop you have in the page?

wp_reset_postdata();
  wp_reset_query();

A: You have to reset all the postdata array and query array, for that you can use below links.
[1] http://codex.wordpress.org/Function_Reference/wp_reset_postdata
[2] http://codex.wordpress.org/Function_Reference/wp_reset_query
thanks.


text:
Q: Javascript redirect to two thank you pages, depending on form response There is a yes or no field on the form, depending on user's choice I would like to send them to a different thank you page depending on their answer.
With this, I just get a blank page. I've tried everything I can think of, so I appreciate any insight.

<form action="http://www.google.com/form" name="Lead" id="Lead" class="sem-form"  onsubmit="return redirectTY()">

        <select name="Invest_RD" id="Invest_RD">
        <option value="Yes">Yes</option>
        <option selected="selected" value="No">No</option>
        </select>

</form>

function redirectTY(){
    var qualify = document.getElementById("Invest_RD".value);
    if (qualify == "Yes"){
     window.location.href='http://www.google.com';
    } else {
     window.location.href='http://www.bing.com';
    }
}

A: Your code looks fine, except for this detail:
document.getElementById("Invest_RD".value);

This will crash all your javascript. Probably your console (developer tools) have red messages refered to this. To fix it write:
document.getElementById("Invest_RD").value;

That's because getElementById() is a method of document, and value is a property of the element returned by getElementById().

A: In your code snippet you are missing the submit button to submit the form or any other action call that executes the button submit. When the action call is done alone the form will submit and you can check upon the values.
Hence your HTML will look like
<form action="" name="Lead" id="Lead" class="sem-form"  onsubmit="return redirectTY()">

<select name="Invest_RD" id="Invest_RD">
<option value="Yes">Yes</option>
<option selected="selected" value="No">No</option>
</select>
<input type="submit" name="submit" value="SUBMIT" />
</form>

You no need an action to the since it is calling the JS after the form is submitted and you can catch up from there on.
The select tag value can be retrieved using the following JS and you can perform the calculations.
$('#Invest_RD').val(); // Getting the selected value from the select tag

A: Add submit button <input type ="submit" value="submit"> to trigger the onsubmit event in your html form. and change onsubmit = "redirectTY();return false;"

    <select name="Invest_RD" id="Invest_RD">
         <option value="Yes">Yes</option>
         <option selected="selected" value="No">No</option>
    </select>
   <input type ="submit" value="submit">
  </form>


text:
Q: Get vector from cv::Mat I am getting an input of vector of 2d points, make transformation on them and then output transformed vector of 2d points. My code needs to run fast so I want to optimize memory access time, is there a way to cast rotated_points to vector without copying the data?
    std::vector<cv::Point2f> points =
        std::vector<cv::Point2f>({{1, 0}, {0, 1}, {-1, 0}});
    auto points_mat= cv::Mat(points);
    auto rotation_matrix = cv::Matx22f({1, 2, 3, 4});
    cv::Mat rotated_points;
    cv::transform(points_mat, rotated_points, rotation_matrix);
    std::vector<cv::Point2f> res_vec;
    res_vec.assign(rotated_points.begin<cv::Point2f>(), rotated_points.end<cv::Point2f>());

I tried to execute the code without copying the data

A: std::vector<cv::Point2f> res_vec(points.size());
cv::Mat rotated_points(res_vec);
cv::transform(points_mat, rotated_points, rotation_matrix);

Create vector and pass it as argument to cv::Mat instance with copyData flag set to false (by default it is false cv::Mat ctor). cv::Mat
will just refer to vector data as underlying data - cv::Mat will share passed vector's data. All results generated by cv::transform will
be stored inside vector by cv::Mat interface.


text:
Q: How to fetch data from multi dimensional array in react native from api of php? data :
[
  { "flat":
    [
      {
        "title": "flat",
        "quote": {
          "flat": {
            "code": "flat.flat",
            "title": "flat",
            "cost": "5.00",
            "tax_class_id": "9",
            "text": "5.00"
          }
        },
        "sort_order": "1",
        "error": false
      }
    ]
  },
  { "pickup":
    [
      {
        "title": "pickup",
        "quote": {
          "pickup": {
            "code": "pickup.pickup",
            "title": "pickup",
            "cost": 0,
            "tax_class_id": 0,
            "text": 0
          }
        },
        "sort_order": "3",
        "error": false
      }
    ]
  },
  { "free":
  [
    {
      "title": "free",
      "quote": {
        "free": {
          "code": "free.free",
          "title": "free",
          "cost": 0,
          "tax_class_id": 0,
          "text": 0
        }
      },
      "sort_order": "0",
      "error": false
    }
  ]
}, {
  "auspost": [
    {
      "title": "auspost",
      "quote": {
        "Courier": {
          "code": "auspost.Courier",
          "title": "Courier",
          "cost": "246.65",
          "tax_class_id": "9",
          "text": "246.65"
        },
        "Express": {
          "code": "auspost.Express",
          "title": "Express",
          "cost": "196.65",
          "tax_class_id": "9",
          "text": "196.65"
         },
         "Standard": {
           "code": "auspost.Standard",
           "title": "Standard",
           "cost": "185.65",
           "tax_class_id": "9",
           "text": "185.65"
          }
        },
        "sort_order": "0",
        "error": ""
      }
    ]
  }
]

A: Use axios for any API calls,
Reference: https://alligator.io/react/axios-react/


text:
Q: Counting rows in mysql database I want to count from the row with the least value to the row with a specific value.
For example,
Name / Point
--------------------
Pikachu  / 7
Voltorb / 1
Abra / 4
Sunflora / 3
Squirtle / 8
Snorlax / 12

I want to count to the 7, so I get the returned result of '4' (counting the rows with values 1, 3, 4, 7)
I know I should use count() or mysql_num_rows() but I can't think of the specifics.
 Thanks.

A: I think you want this :
 select count(*) from mytable where Point<=7;

Count(*) counts all rows in a set.

A: If you're working with MySQL, then you could ORDER BY Point:
SELECT count(*) FROM table WHERE Point < 7 ORDER BY Point ASC

If you want to know all about ORDER BY, check out the w3schools page: http://www.w3schools.com/sql/sql_orderby.asp
Just in case you want to only count the rows based on the Point values:
SELECT count(*) FROM table WHERE Point < 7 GROUP BY Point

A: This may help you to get rows falling between range of values :
select count(*) from table where Point >= least_value and Point<= max_value


text:
Q: nodejs callback function inside a function -> how to return result I want make a function for calling API. If I execute "apifunc", the function calls the api. When the API execution is complete, the results are saved in "body". Now I want the function to return the "body". But it does not. The console did print out the "body". So the api worked. The problem here is return. How do I fix this problem.
exports.apifunc=function(a,b){
var request = require('request');
request.post(`https://abc.co.kr/api/${address}`,
{ json: {A:`${a}`, B: `${b}`} },
function (error, response2, body) {
  if (!error && response2.statusCode == 200) {
    console.log(body);
    return body;
  }
 });
}

A: Welcome to asynchronous programming, man!
You are using callback style, that means that all further actions you should perform inside request callback and so on deeper and deeper if you are doing async stuff with the result of initial request.
My solid advice is to use request-promise library and async/await flow. Look:
const request = require('request-promise');

exports.apifunc= async (a,b) => {
  const body = await request.post(
    `https://abc.co.kr/api/${address}`,
    { json: { A:`${a}`, B: `${b}`} }
  );

  return body;
}

Don't forget two things here. Errors handling is desired (try/catch) and that async function returns Promise. So, the outer funtion, that uses api function should either be async in order to await body there, or expect Promise and continue Promise chain by .then


text:
Q: Android why the port 443 is opened? I notice that my Android phone has the https port (443) opened.
This is the nmap report:
PORT    STATE SERVICE VERSION
443/tcp open  http    Mongoose httpd
|_http-methods: No Allow or Public header in OPTIONS response (status code 400)
|_http-title: Index of /

The port is not accessible, if I try to access from browser to this page: https://PHONE_IP I get this error: ERR_SSL_PROTOCOL_ERROR
I tried to connect using adb shell and the port is actually opened, this is the netstat report:
Proto Recv-Q Send-Q Local Address          Foreign Address        State
 tcp       0      0 127.0.0.1:7777         0.0.0.0:*              LISTEN
 tcp       0      0 127.0.0.1:7203         0.0.0.0:*              LISTEN
 tcp       0      0 127.0.0.1:5037         0.0.0.0:*              LISTEN
 tcp       0      0 127.0.0.1:80           0.0.0.0:*              LISTEN
 tcp       0      0 0.0.0.0:443            0.0.0.0:*              LISTEN

But I can't understand which process bind the 433 port.
Any suggestions?
UPDATE:
Android netstat has no options, not even the -h option.

A: I don't recall if Android's netstat has the -p option but if it does, that would be the easiest way to learn the process id that has the port open.
Failing that, you can either walk through /proc/ directories looking at the file descriptors open by each process until you find the offending one.


text:
Q: PHP Mysql ranking I have a Mysql database looking like this:
http://i.imgur.com/bLlXrGg.png
and I am calculating rank using this formula:
SELECT Name, Kills, Wins, Losses, Killstreak,
(((Wins * 5) + (Kills / 10) / (Losses / 10)) + ((Wins + Losses) / 50)) +
Killstreak as rank
FROM `hgstats` WHERE `Name` = '$inputPlayer'"

and that outputs the sum but I would like to have it say 1,2,3 and so on, how would I do this from within the query.

A: In MySQL, you would use variables.  Assuming you want the rank for a given player, you can assign all the ranks and then choose the row(s) you want:
SELECT r.*
FROM (SELECT Name, Kills, Wins, Losses, Killstreak,
             (((Wins * 5) + (Kills / 10) / (Losses / 10)) + ((Wins + Losses) / 50)) + Killstreak as rankvalue,
             @rn := @rn + 1 as rank
      FROM `hgstats` CROSS JOIN
           (SELECT @rn := 0) vars
      ORDER BY rankvalue
     ) r
WHERE `Name` = '$inputPlayer'"


text:
Q: Is there anyway to prevent Office/Outlook from using modal compose message windows? Examples...
This is happens in Office 2007/2010
In Windows Explorer, right click on file > Send To > Mail Recipient... This opens a modal new message window, I can't access anything else in outlook. So that bit of text from another email I wanted to copy/paste into the new email, can't.
In Excel, Send > E-Mail... This opens a modal new message window and locks out both Excel and Outlook. So the few cells of data I wanted to copy/paste into the email body, can't.
Is there anyway to prevent this? I don't want the new message windows to be modal.

A:
Is there anyway to prevent this?

Have another instance of Outlook/Excel open. No other way to go about this

A: I have made VBA procedure to generate Outlook message. The result is the same, but Outlook and Excel are not blocked when you want to send Active Workbook. You can put button on Quick Access Toolbar and call this procedure from automatically loaded module from XLSTART.
Sub SendActiveWorkbook()
    'Create Outlook Message and add Active Workbook file to it
    Dim temp_file_full_name As String
    Dim folder As String
    Dim base As String 'File name without extension
    Dim ext As String

    'Create temp copy of ActiveWorkbook
    With ActiveWorkbook
        folder = Environ$("temp") & "\"

        'Workbook name
        base = .Name

        'If workbook did not saved on disk, it does not have extension
        If InStr(base, ".") > 0 Then
            ext = Split(base, ".")(UBound(Split(base, ".")))
            base = left(base, Len(base) - Len(ext) - 1)
        Else
            Select Case .FileFormat
                Case xlExcel8: ext = "xls"
                Case xlOpenXMLWorkbook: ext = "xlsx"
                Case xlOpenXMLWorkbookMacroEnabled: ext = "xlsm"
                Case xlExcel12: ext = "xlsb"
                Case Else: ext = "xlsx"
            End Select
        End If

        temp_file_full_name = folder & base & "." & ext
        .SaveCopyAs temp_file_full_name
    End With

    'Create Outlook message with attachment of temp file and display it
    With CreateObject("Outlook.Application").CreateItem(0)
        .Subject = base
        .Attachments.Add temp_file_full_name
        .Display
    End With

    'Delete temp file. We don't need it anymore
    Kill temp_file_full_name
End Sub

A: More of a work around than an answer.
Once the message has gone Modal simply press the save button in the message.
This will save the email in your draft emails.  Then close the message.
Open the draft message and it will no longer be modal.

A: A few questions on this.
- Is this a home computer on a home network?
- Is this a government or company computer on their network
- If the case is a Government or Industry/Company this might be a windows configuration issue or a Microsoft office corruption issue. I have literally done this many times and never had this issue.
- Maybe checking your system resources to ensure that there is not a version of excel already open in memory that does not show up.
 The open in memory/ghost excel, I have seen block access to a file and cause all sorts of glitchy issues.
- Also, you might want to make sure your Microsoft outlook is the version being used "If you are using the Microsoft office pro version". Just to make sure to set the version to the one required.
- Also, have you tried from inside of excel with the "file > send to" drop-down menu did change in later versions of Microsoft Office. The later versions they took out the file send. You can re-enable this through similar steps to this "https://www.technipages.com/word-enable-send-to-mail-recipient-option". That is using Microsoft office 2016.
You might want to try opening the excel container with no file loaded.
Then go back to the explorer and try the same process.
Try to keep calm and carry on. I know sometimes it is hard not to get mad at Microsoft since they often send out their applications half-baked/buggy since they have millions of testers willing to report issues with there products for them for free.
I hope this helps, have a great day.


text:
Q: Bash: can't launch a program created with make on linux I want to build my program using make and then launch the created executable via bash script, but bash can't find the executable, although it was created and i can launch it manually. The problem only exist on linux mint 19 in Gnome-terminal.
Edit: The exact error message is: "/path/to/my/executable: no such file or directory"
I have a cross-platform project where i need to run cmake, then build the project and finally launch the created executable. I have a bash script to automate the process:
Edit: Its only the part that causes the trouble ;)
for TASK in $@; do
    if [[ $TASK == "make" ]]; then
        call cmake here, this creates a .sln or a make file
    elif [[ $TASK == "build" ]]; then
        if  [[ $OS == 'CYGWIN_NT-10.0' ]]; then
            MSBuild.exe "./build/debug/myproject.sln"
        elif [[ $OS == 'Linux' ]]; then
            cd ./build/debug/ && make
        else
            error...
        fi
    elif [[ $TASK == "run" ]]; then
        if  [[ $OS == 'CYGWIN_NT-10.0' ]]; then
            ./build/debug/Debug/program.exe
        elif [[ $OS == 'Linux' ]]; then
            ./build/debug/program
        else
            error...
        fi
    else
        error...
    fi
done

Calling "./script.sh make build run" should, for example, call cmake to create the build files, then call the build program (make on linux or msbuild on windows) and then launch the created executable. This works fine on windows 10 in a cygwin terminal. On Linux the call "./script.sh build run" fails, because it can't find the executable. However "./script.sh build && ./build/debug/program" works nicely. Surprisingly "./script.sh build && ./script.sh run" also works as expected.
Why is that? Is there any Bug in the bash script? And why does it work on Cygwin but not on linux mint?

A: Ok, I solved it. Asking questions seems to be the first step to finding a solution.
The problem seems to be, that the call "./script.sh build run" first evaluates the build command "cd ./build/debug/ && make". I thougth such commands would spawn a new sub shell, where the cd and make commands are then evaluated and then the shell would continue in the original working directory. Apparently this does not happen and the working directory of the executing script is changed to "./build/debug". The next command "run" tries to execute "./build/debug/program" but since the current working directory is changed, it is essentially looking for "./build/debug/build/debug/program" which does not exist.
I added the line
cd ../../

to the code for the build-command. It now looks like this
...
elif [[ $OS == 'Linux' ]]; then
    cd ./build/debug/ && make
    cd ../../
else
...

I don't know exactly why, but it works this way on linux.


text:
Q: How can I improve the alignment of a line on tab press in VSCode? I switched from Atom to VSCode. There is one point that is very annoying. Below is an example that prompted me to write a question here.

That is, pressing tab always inserts 2 spaces and has no understanding of the position of the beginning of the code in the upper line.
In Atom, tab can insert 1 space if required:

A: First go to the "Show All Commands" tab in VSCode.
Then search for "convert indentation".
Then you can edit your preference for spacing which should solve your problem.


text:
Q: Meteor unable to start Mongo server on windows 8.1 so I was trying to learn Meteor.js. I installed Chocolaty on my windows 8.1 machine, and with the command choco install meteor, I was able to successfully install meteor using Windows Powershell.
I created a new meteor project using the command meteor create demo and started the project using meteor command. Here's where I get Mongo server error, which says-
Unexpected mongo exit code 3221225781. Restarting.
Can't start Mongo server.

The server never starts and the process exits.
I tried uninstalling meteor and reinstalling with the same command as I mentioned above, but I am still facing the same error.
Please help.


text:
Q: Creating a custom content query web part The basic gist is that I would like to create a content query web part that shows the 10 most recent documents in the project provided by the URL parameter.
I currently have it set up such that all of my CQWPs are able to be filtered by the parameter, but i can't for the life of me figure out how to load the right document library.
For example:
If i have "project 1" and "project 2", i will then have two document libraries, one for each: dl_project 1 and dl_project2. Now, if i pass in the parameter for project1, i would like the 10 most recent documents either modified or created by the current user. That way when the user visits a project page, it loads the documents they were working on for that project. Ideas?


text:
Q: Crunching json with python Echoing my other question now need to find a way to crunch json down to one line: e.g.
{"node0":{
    "node1":{
        "attr0":"foo",
        "attr1":"foo bar",
        "attr2":"value with        long        spaces"
    }
}}

would like to crunch down to a single line:
{"node0":{"node1":{"attr0":"foo","attr1":"foo bar","attr2":"value with        long        spaces"}}}

by removing insignificant white spaces and preserving the ones that are within the value. Is there a library to do this in python?
EDIT
Thank you both drdaeman and Eli Courtwright for super quick response!

A: http://docs.python.org/library/json.html
>>> import json
>>> json.dumps(json.loads("""
... {"node0":{
...     "node1":{
...         "attr0":"foo",
...         "attr1":"foo bar",
...         "attr2":"value with        long        spaces"
...     }
... }}
... """))
'{"node0": {"node1": {"attr2": "value with        long        spaces", "attr0": "foo", "attr1": "foo bar"}}}'

A: In Python 2.6:
import json
print json.loads( json_string )

Basically, when you use the json module to parse json, then you get a Python dict.  If you simply print a dict and/or convert it to a string, it'll all be on one line.  Of course, in some cases the Python dict will be slightly different than the json-encoded string (such as with booleans and nulls), so if this matters then you can say
import json
print json.dumps( json.loads(json_string) )

If you don't have Python 2.6 then you can use the simplejson module.  In this case you'd simply say
import simplejson
print simplejson.loads( json_string )


text:
Q: laravel validation for checkboxes How can I validate 'at least one of the two checkboxes in my form was checked'? I know other ways but I want to know if there is a validation rule for this in laravel?

A: Yes, i think this is what you looking for:
$rules = array(
    'checkbox1' => 'required_without:checkbox2', //require if checkbox2 miss
    'checkbox2' => 'required_without:checkbox1', //require if checkbox1 miss
);

So if the two checkboxes are missed, validator will fail.

required_without:foo,bar,...
    The field under validation must be present only when any of the other specified fields are not present.

Doc

A: In Laravel, there is a way to require a check box field to be checked using accepted and what it does is that, the field under validation must be yes, on, or 1.
But you have different requirements and in this case you can add your custom rule using something like this:
// You may keep this code in your class before validation inside the method
Validator::extend('isOneChecked', function($attribute, $value, $parameters)
{
    return ($value || Input::has($parameters[0])) ? TRUE : FALSE;
});

Now you may use this rule for example, if one of your check box's name is checkbox1 and other one is checkbox2 then use something like this:
$rules = array (
    // other rules...
    'checkbox1' => 'isOneChecked:checkbox2',
);


text:
Q: Hilbert space sum Let $\{x_i\}_{i\in I}$ as orthonormal set in Hilbert space,
Now define $x = \sum_{i\in I}a_ix_i$ , can we prove $a_i = (x,x_i)$? If $I$ is uncountable set?
I know if we further impose $\sum_{i\in I}|a_i|^2 <\infty$ then set of $i$ such that $a_i \ne 0$ is almost countable(then taking limit,due to continuous of inner product),what about the case without this assumption?

A: It depends on your definition of "$x = \sum_{i \in I} a_i \, x_i$". I would say that for any reasonable definition, this series converges if and only if $\sum_{i \in I} |a_i|^2 < \infty$.


text:
Q: Create Java program that creates and emails a file I created an application that collects and saves form data into a text file. Right now, the only way for my to receive that information is to have the user manually email the file over. I would like the application to automatically send the email when the user presses submit to make the process more user friendly. How would I go about doing that? Here is my code. I found a few things online, but everything seems to be outdated and no longer works. Thank you in advance!
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
    JOptionPane.showMessageDialog(frame, "Thank you for joining BPA! A file has been created on your desktop. Please send the file to bpasignup@gmail.com to complete your registration.");
    String content = "," + FName.getText() + "," +
                     MName.getText() + "," +
                     LName.getText() + "," +
                     Email.getText() + "," +
                     Phone.getText() + "," +
                     SAddress.getText() + "," +
                     City.getText() + "," +
                     State.getSelectedItem() + "," +
                     ZIP.getText() + "," +
                     Grade.getSelectedItem() + "," +
                     Shop.getSelectedItem() + "," +
                     HRoom.getText() + "," +
                     PName.getText() + "," +
                     PEmail.getText() + ","
                     ;

try {

            File file = new File("c:/users/User/desktop/BPAsignup.txt");

            // if file doesnt exists, then create it
            if (!file.exists()) {
                file.createNewFile();
            }

            FileWriter fw = new FileWriter(file.getAbsoluteFile());
            BufferedWriter bw = new BufferedWriter(fw);
            bw.write(content);    //step2: write it
            bw.close();

            System.out.println("Done");

        } catch (IOException e) {
            e.printStackTrace();
            JOptionPane.showMessageDialog(frame, "Unable to create file. Please contact your BPA director directly to resolve this issue.");


text:
Q: In jQuery my function is not work I trying to make two conditional statement with jQuery like this.
$('#user_name, #user_email, #user_password').keyup(function () {
    if ($('#output-name').is('.field-output-comple') &&
            $('#output-email').is('.field-output-comple') &&
            $('#output-password').is('.field-output-comple') &&
            $('#confirm-terms-of-use').is(':checked')
    ) {
        $('#register-button').removeAttr('disabled');
    } else {
        $('#register-button').attr('disabled', 'disabled');
    }
});

$('#confirm-terms-of-use').change(function() {
    if ($('#output-name').is('.field-output-comple') &&
            $('#output-email').is('.field-output-comple') &&
            $('#output-password').is('.field-output-comple') &&
            $('#confirm-terms-of-use').is(':checked')
    ) {
        $('#register-button').removeAttr('disabled');
    } else {
        $('#register-button').attr('disabled', 'disabled');
    }
});

But you know this code is duplicated.
if ($('#output-name').is('.field-output-comple') &&
    $('#output-email').is('.field-output-comple') &&
    $('#output-password').is('.field-output-comple') &&
    $('#confirm-terms-of-use').is(':checked')
) {
    $('#register-button').removeAttr('disabled');
} else {
    $('#register-button').attr('disabled', 'disabled');
}

So I make this code with function like this.
$('#user_name, #user_email, #user_password').keyup(isValidPassword())
$('#confirm-terms-of-use').change(isValidPassword())

function isValidPassword() {
    if ($('#output-name').is('.field-output-comple') &&
            $('#output-email').is('.field-output-comple') &&
            $('#output-password').is('.field-output-comple') &&
            $('#confirm-terms-of-use').is(':checked')
    ) {
        $('#register-button').removeAttr('disabled');
    } else {
        $('#register-button').attr('disabled', 'disabled');
    }
}

But it does not worked well. No error but isValidPassword dose not output anything maybe. Where did I make mistake? Thank you for reading.

A: You need to pass the function reference to the event handlers, you are calling the function isValidPassword and is passing the value returned by it undefined as the event handler.
$('#user_name, #user_email, #user_password').keyup(isValidPassword)
$('#confirm-terms-of-use').change(isValidPassword)

A: This isn't doing what you think:
.keyup(isValidPassword())

This doesn't pass the isValidPassword function itself to keyup, it executes the function and passes the result of that function.  And that function doesn't return anything, so its result is undefined.
Don't execute the function, just pass the function itself as a variable:
.keyup(isValidPassword)


text:
Q: function to find length of 2d string array in cpp? Is there any inbuilt function in cpp that can give me the length of a 2d char array
for ex, the function for args
const char* args[] = {"412", "..7", ".58", "7.8", "32.", "6..", "351", "3.9", "985", "...", ".46"}

should return 11

A: I like to use a template function for this.
template <typename T, std::size_t N>
std::size_t size(T(&)[N]) { return N; }

The advantage over an approach using sizeof is that you can't accidentally do it with a pointer.

A: This will give the number of elements in args:
sizeof(args) / sizeof(args[0])

A: In C++11 you can use:
std::end(args) - std::begin(args)

A: sizeof(args) / sizeof(*args)


text:
Q: Selecting nonconsecutive odd and even numbers I am attempting to solve the following problem: Given n numbers (from 1->n), how many ways are there to select k even numbers, and j odd numbers, such that no two numbers are consecutive.
Can anyone provide a closed form for this; aka, without the use of recurrence relations or generating functions? Sigma is acceptable though.
I am aware of an existing question that tackles this, but without the even and odd distinction.

A: Well, there's a helpful recursion:
Let $S(n,j,k)$ be the answer.  Then, noting that either $1$ is in the selection or it is not, we see that $$S(n,j,k)=S(n-2,j-1,k)+S(n-1,k,j)$$
This, at least, provides a way to compute many examples.

A: I will suppose for the moment that $n=2m+1$ is odd.
Suppose that in the set of $k$ even numbers, there are $d$ pairs of "adjacent" even numbers, of the form $2i$ and $2i+2$. These pairs can overlap, so that $\{4,6,8,14,16\}$ has three adjacencies, $(4,6), (6,8)$ and $(14,16)$. Then it follows that there will be $2k-d$ odd numbers which are adjacent to a chosen even number, so there are $\binom{m+1-2k+d}{j}$ ways to choose the odd numbers. We just need to count the number of sets of even numbers with $d$ adjacencies, for each $d$, then sum over $d$.
There are $k-1$ possible adjacencies, so the adjacencies can be chosen in $\binom{k-1}{d}$ ways. The evens will break into $k-d$ blocks of consecutively adjacent numbers. Let $x_i$ be number of unchosen even numbers between blocks numbered $i$ and $i+1$, for $i=0,1,\dots,k-d$. Note $x_0$ is the number of unchosen numbers before the first clump, and $x_{k-d}$ is the number after the last clump. We need to have $x_i\ge 1$, for each $i=1,\dots,k-d-1$, but we only need $x_0,x_{k-d}\ge 0$. We also need $$x_0+x_1+\dots+x_{k-d}=m-k.$$ Alternatively, we have
$$
(x_0+1)+x_1+\dots+x_{k-d-1}+(x_{k-d}+1)=m-k+2,
$$with each summand is at least one. It follows from stars and bars that the number of ways to do this is
$$
\binom{m-k+1}{k-d}
$$
Therefore, the number of selections is
$$
\sum_{d=0}^{k-1}\binom{k-1}d\binom{m-k+1}{k-d}\binom{m+1-2k+d}{j}
$$
I leave it to you to see how the answer is different when $n=2m$ is even. This case seems like more of a headache; you need to condition based on whether or not $2m$ is in the chosen set of even numbers.


text:
Q: Geodjango, Openlayers 2: Override default fillColor in OpenLayers.Feature.Vector.style Update
I would certainly hard-code the source file
and change it as follows:
OpenLayers.Feature.Vector.style = {
    'default': {
        fillColor: "blue",
        ...
    },
    ...

... but this is rather a hack I would like to a avoid.

I am trying to change the fillcolor of a point shown in a django admin map.
I have already managed to change the color of a new point when I click on the map, following this solution, but I am unable to understand how I could change the color of an existing point that programmatically is inserted into the map when fetched from the database.
I have found several posts that describe how to override the StyleMap of a vector layer or how to dynamically style a map, but I do not understand how I could change the color of the dot when it is already on the map.
I attach a picture. The yellow dot is already in the database.
How can I paint it blue?

A: I have overriden the relevant settings as such:
OpenLayers.Feature.Vector.style.default.fillColor = 'blue';
OpenLayers.Feature.Vector.style.default.fillOpacity = 0.5;
OpenLayers.Feature.Vector.style.default.strokeWidth = 2;
OpenLayers.Feature.Vector.style.default.strokeColor = "red";


text:
Q: Javascript issue with moving list items up and down Recently started learning javascript, and am at the moment trying to build a simple app, that is an ul, with list items, where each li has two buttons, to move that li up or down.
But, I'm running into problem. Last item in list can never be moved up

    var ul = document.querySelector('ul');

    ul.addEventListener('click', (e) => {
     let clicked = e.target;
     let li  = clicked.parentNode;
     let next    = li.nextElementSibling.nextElementSibling;
      let prev    = li.previousElementSibling;

        if (clicked.className === 'down') {
         ul.removeChild(li);
            ul.insertBefore(li, next);
        } else if (clicked.className === 'up') {
         ul.removeChild(li);
         ul.insertBefore(li, prev);
        }
    });

item1 <button class="down">Move down</button><button class="up">Move up</button>

item2 <button class="down">Move down</button><button class="up">Move up</button>

item3 <button class="down">Move down</button><button class="up">Move up</button>

item4 <button class="down">Move down</button><button class="up">Move up</button>

item5 <button class="down">Move down</button><button class="up">Move up</button>

Here is the jsfiddle: https://jsfiddle.net/hu13x8w0/3/
Can someone explain to me, why it wont work in those 2 cases? What did I do wrong?

A: If you check the browser's console (F12 to open Dev Tools in most browsers) you'll see an error like this:
Uncaught TypeError: Cannot read property 'nextElementSibling' of null

That's because on this line:
li.nextElementSibling.nextElementSibling;

...the last element's .nextSibling is null (it doesn't have a next sibling). You need to test for null rather than just chaining an extra .nextElementSibling on the end:

    var ul = document.querySelector('ul');

    ul.addEventListener('click', (e) => {
     let clicked = e.target;
     let li  = clicked.parentNode;
     let next    = li.nextElementSibling;               // <-- Code changed
        if (next != null) next = next.nextElementSibling;  // <-- Code inserted
      let prev    = li.previousElementSibling;

        if (clicked.className === 'down') {
         ul.insertBefore(li, next);
        } else if (clicked.className === 'up') {
         ul.insertBefore(li, prev);
        }
    });

item1 <button class="down">Move down</button><button class="up">Move up</button>

item2 <button class="down">Move down</button><button class="up">Move up</button>

item3 <button class="down">Move down</button><button class="up">Move up</button>

item4 <button class="down">Move down</button><button class="up">Move up</button>

item5 <button class="down">Move down</button><button class="up">Move up</button>

Note that you don't need the calls to .removeChild(), because .insertBefore() will move the element (not copy it).


text:
Q: How i can build android apps for compiling a simple java code with android studio? I want to make an android application that can compile simple java code like the one below
Simple Code
and produces output as a text as shown below
Output
is there a library to support compiling java code in android? or is there another way?
I've been looking for references but can't find anything useful.


text:
Q: Windows 200x Server - User Group vs User privilege conflict I have denied to a specific user to write on a file. Unfortunately this user is a member of a User Group which have the privilege to write on this file. So there is a conflict between User vs. User-Group privileges. Which one will prevail here?

A: Explicit "Deny" permissions always take precedence over all other permissions (assuming canonical ACL ordering-- but that's probably a safe assumption). The permission denying the user "Write" permission will override any permission granting the user "Write" based on group membership.


text:
Q: Php include once generates error My file structure looks like this:
Lib
  -Models
     b.php
     c.php
  -Controllers
     a.php

In the a.php file I want to include b.php. How do I do this? Everything I try generates errors of this sort:

failed to open stream: No such file or directory

I've tried:
include_once '..\Models\b.php';
include_once '\..\Models\b.php';
include_once $_SERVER['DOCUMENT_ROOT'] .'\Models\b.php';
include_once __DIR__ .'\Models\b.php';

& some others
EDIT!
Forward slashes don't work either. I've also tried the following:
include_once '../Models/b.php';
include_once '/../Models/b.php';
include_once $_SERVER['DOCUMENT_ROOT'] .'/Models/b.php';
include_once __DIR__ .'/Models/b.php';

A: First up, find out which directory the code running the include is in:
die(var_dump(__DIR__));

Then, you'll know whether to go into or drop out of whichever folder you are in.
Use realpath($stringPath); to convert strings like /var/www/site/something/../data/file.php to the real path, /var/www/site/data/file.php
It's also worth defining a WEB_ROOT constant you could use:
define('WEB_ROOT', $_SERVER['DOCUMENT_ROOT']);

Then you can say require_once realpath(WEB_ROOT.$filePath);