All posts by stackoverflow

How to get css property of dynamic table created by javascript?

This is javascript code for creating dynamic table it creates a crossword

function generateTable(range) {
    document.write("<table style='border: 1px solid black;'>");
    for (var a = 1; a < 10; a++) {
        document.write("<tr >");
        for (var b = 1; b < 10; b++) {
            if (a % 2 == 0 && b % 2 == 0) {
                document.write("<td style='border: 1px solid black;'><button style='width:50px; height:50px; background-color:black'></button></td>");
            } else {
                document.write("<td style='border: 1px solid black;'><button style='width:50px; height:50px; background-color:white' ></button></td>");
            }
        }
        document.write("</tr>");
    }
    document.write("</table>");
}

read more

Fastest way to get class types of elements of a cell array

I have a (large) cell array, with various data types. For example,

 myCell = { 1, 2, 3, 'test',  1 , 'abc';
            4, 5, 6, 'foob', 'a', 'def' };

This can include more obscure types like java.awt.Color objects.

I want to ensure that the data in each column is of the same type, since I want to perform table-like operations on it. However, this process seems very slow!

My current method is to use cellfun to get the classes, and strcmp to check them

% Get class of every cell element
types = cellfun( @class, myCell, 'uni', false );
% Check that they are consistent for each column
typesOK = all( strcmp(repmat(types(1,:), size(types,1), 1), types), 1 );
% Output the types (mixed type columns can be handled using typesOK)
types = types(1, :);

% Output for the above example: 
% >> typesOK = [1 1 1 1 0 1]
% >> types = {'double', 'double', 'double', 'char', 'double', 'char'}

read more

Apache2 won’t restart after installing Graphite version 1.2

I just installed Graphite (version 1.2.0), but I’m not able to start Apache2 again. This is the error log I get:

 * The apache2 configtest failed.
Output of config test was:
[Thu Jan 18 20:12:39.906483 2018] [so:warn] [pid 2356] AH01574: module wsgi_module is already loaded, skipping
AH00526: Syntax error on line 56 of /etc/apache2/sites-enabled/apache2-graphite.conf:
WSGI process group not yet configured.
Action 'configtest' failed.
The Apache error log may have more information.

Here is my apache2-graphite.conf file:

LoadModule wsgi_module modules/mod_wsgi.so

WSGISocketPrefix /var/run/wsgi

Listen 80

<VirtualHost *:80>

 DocumentRoot /var/www/html
 <Directory />
 Options FollowSymLinks
 AllowOverride None
 </Directory>
 <Directory /var/www/html>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride None
 Order allow,deny
 allow from all
 </Directory>

 ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
 <Directory "/usr/lib/cgi-bin">
 AllowOverride None
 Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
 Order allow,deny
 Allow from all
 </Directory>

 ErrorLog /var/log/apache2/error.log

 # Possible values include: debug, info, notice, warn, error, crit,
 # alert, emerg.
 LogLevel warn

 CustomLog /var/log/apache2/access.log combined

 Alias /doc/ "/usr/share/doc/"
 <Directory "/usr/share/doc/">
 Options Indexes MultiViews FollowSymLinks
 AllowOverride None
 Order deny,allow
 Deny from all
 Allow from 127.0.0.0/255.0.0.0 ::1/128
 </Directory>

</VirtualHost>

<VirtualHost *:3020>

WSGIDaemonProcess graphite-web processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120 user=_graphite group=_graphite

WSGIProcessGroup graphite-web

WSGIImportScript /opt/graphite/conf/graphite.wsgi process-group=graphite-api application-group=%{GLOBAL}

WSGIScriptAlias /graphite /opt/graphite/conf/graphite.wsgi/graphite
Alias /graphite/static /opt/graphite/webapp/content

 Alias /content/ /usr/share/graphite-web/static/
 <Location "/content/">
 SetHandler None
 </Location>

 <Location "/server-status">
 SetHandler server-status
 Require all granted
 </Location>

 ErrorLog ${APACHE_LOG_DIR}/graphite-web_error.log

 # Possible values include: debug, info, notice, warn, error, crit,
 # alert, emerg.
 LogLevel warn

 CustomLog ${APACHE_LOG_DIR}/graphite-web_access.log combined

</VirtualHost>

read more

Add Eigen Library to Android NDK

I need to include Eigen library in my Android Studio project to do some linear algebra operations and use some C++ code that I’ve developed for desktop. I’ve been looking for information on this topic, but there isn’t too much and I’m new on Android NDK. Eigen library doesn’t need to be compiled, so I thought It would be easy, but I’m missing something. I’ve tried to copy the Eigen folder (which have all the includes) into the NDK folder (..\Android\Sdk\ndk-bundle\sysroot\usr\include) where there are other exteral libraries (GLES for example) but Android Studio don’t detect it. How can I do it?? Thank you in advance, I really need this.

read more

How to connect Dev-C++ to MySQL Server 5.7 using MySQL Connector C++?

Previously, I’ve tried connecting Dev-C++ to MySQL in XAMPP without much problem. But when I tried connecting Dev-C++ to MySQL Server 5.7 itself using MySQL Connector C++, I did not manage to do so even though I’ve followed all the instructions stated in the MySQL Connector/C++ Developer Guide.

The application crashed when trying to connect Dev-C++ to MySQL.
enter image description here

This is my first time posting a question to here. I found it so difficult to include the entire block of code.

How to connect Dev-C++ to MySQL Server 5.7 using MySQL Connector C++?

read more