text:
Q: Why does the file size matter for apache command Header append Vary User-Agent to trigger? I'm using symfony 3, and have the following .htaccess file (attached to the very bottom of this message noted as 'problem .htaccess').  I'm using the website gtmetrix.com (which uses pagespeed) to optimize my site, but I'm getting the following error for my .css and .js files.
Specify a Vary: Accept-Encoding header
F (33)
    SERVER  HIGH
What's this mean?
The following publicly cacheable, compressible resources should have a "Vary: Accept-Encoding" header:

http://{{my website here}}/css/main.css
http://{{my website here}}/js/main.js

Before you mention that it says Header append Vary User-Agent which clearly does not say accept-encoding..
1.) (I have already looked at How to Specify "Vary: Accept-Encoding" header in .htaccess), which talks about how to set this.
2.) The code I have listed works on another site on my same server and I get no vary encoding error message., which means that the code I have should have worked anyways (and the other site has a main.css and main.js also).  The only difference in that htaccess file is that it was for SLIM framework instead of symfony so it looked like the following below:
SLIM FRAMEWORK (OTHER SITE .HTACCESS)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

AddType application/x-font-ttf .ttf

Header unset Pragma
FileETag None
Header unset ETag

<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType font/ttf "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##

Symfony 3 FRAMEWORK (The Problem .HTACCESS)
# Use the front controller as index file. It serves as a fallback solution when
# every other rewrite/redirect fails (e.g. in an aliased environment without
# mod_rewrite). Additionally, this reduces the matching process for the
# start page (path "/") because otherwise Apache will apply the rewriting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex app.php

# By default, Apache does not evaluate symbolic links if you did not enable this
# feature in your server configuration. Uncomment the following line if you
# install assets as symlinks or if you experience problems related to symlinks
# when compiling LESS/Sass/CoffeScript assets.
# Options FollowSymlinks

# Disabling MultiViews prevents unwanted negotiation, e.g. "/app" should not resolve
# to the front controller "/app.php" but be rewritten to "/app.php/app".
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/js "access 1 week"
ExpiresByType application/javascript "access 1 week"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
## EXPIRES CACHING ##

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Determine the RewriteBase automatically and set it as environment variable.
    # If you are using Apache aliases to do mass virtual hosting or installed the
    # project in a subdirectory, the base path will be prepended to allow proper
    # resolution of the app.php file and to redirect to the correct URI. It will
    # work in environments without path prefix as well, providing a safe, one-size
    # fits all solution. But as you do not need it in this case, you can comment
    # the following 2 lines to eliminate the overhead.
    RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
    RewriteRule ^(.*) - [E=BASE:%1]

    # Sets the HTTP_AUTHORIZATION header removed by Apache
    RewriteCond %{HTTP:Authorization} .
    RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect to URI without front controller to prevent duplicate content
    # (with and without `/app.php`). Only do this redirect on the initial
    # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
    # endless redirect loop (request -> rewrite to front controller ->
    # redirect -> request -> ...).
    # So in case you get a "too many redirects" error or you always get redirected
    # to the start page because your Apache does not expose the REDIRECT_STATUS
    # environment variable, you have 2 choices:
    # - disable this feature by commenting the following 2 lines or
    # - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
    #   following RewriteCond (best solution)
    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteRule ^app\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]

    # If the requested filename exists, simply serve it.
    # We only want to let Apache serve files and not directories.
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ - [L]

    # Rewrite all other queries to the front controller.
    RewriteRule ^ %{ENV:BASE}/app.php [L]
</IfModule>

<IfModule !mod_rewrite.c>
    <IfModule mod_alias.c>
        # When mod_rewrite is not available, we instruct a temporary redirect of
        # the start page to the front controller explicitly so that the website
        # and the generated links can still be used.
        RedirectMatch 302 ^/$ /app.php/
        # RedirectTemp cannot be used instead
    </IfModule>
</IfModule>

# These rules need to be at the bottom!
# Make it aware of True Type Fonts for Web Fonts.
AddType application/x-font-ttf .ttf

Header unset Pragma
FileETag None
Header unset ETag

<IfModule mod_deflate.c>
  #The following line is enough for .js and .css
  AddOutputFilter DEFLATE js css

  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/js
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml

  # Remove browser bugs (only needed for really old browsers)
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  Header append Vary User-Agent
</IfModule>

Question is: What is different about symfony framework or their .htaccess file that will NOT allow me to use the Header append Vary User-Agent command?
UPDATE
So after doing some experimentation I modified symfony's .htaccess file to the same as slims, the only difference I had to do was add the line DirectoryIndex app.php to the slims .htaccess file and then, tell it to rewrite to app.php instead of index.php, but still the error persists.  This tells me its probably not the htaccess files but maybe the way I'm going about creating my assets?
In code it looks like this in a TWIG template.
{% spaceless %}
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>{% block title %}Welcome!{% endblock %}</title>
        {% block stylesheets %}
            <link href="{{ asset('css/main.css') }}" rel="stylesheet" />
        {% endblock %}
        <link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
    </head>
    <body>
        {% block body %}{% endblock %}
        {% block javascripts %}
            <script src="{{ asset('js/main.js') }}"></script>
        {% endblock %}
    </body>
</html>
{% endspaceless %}

Maybe because I'm using asset its doing something to the encoders for that resource somehow in the engine? I'm not sure how it would do that, but not sure where else to look for the moment.
Update #2
Ok made big headway in this mystery, I got the vary-encoding message to go away but I'm not entirely sure why, but I do know the file size of the main.css file is important.
When the main.css has the following it will fail to specify a vary:accept encoding header? Maybe because it was too small to compress in the first place?
.someclass{color:red;}.heythere{color:blue;}.heythereagain{color:blue;width:200px}.heytheretwice{color:green;height:50px;}

However give it the following main.css contents instead and the message goes away on gtmetrix.
a,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,nav,object,ol,output,p,pre,q,ruby,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:'';content:none}table{border-collapse:collapse;border-spacing:0}.red{background-color:rgba(255,0,0,.75)}.blue{background-color:rgba(0,0,255,.75)}.green{background-color:rgba(0,255,0,.75)}.purple{background-color:rgba(255,0,255,.75)}.orange{background-color:rgba(255,150,0,.75)}.yellow{background-color:rgba(255,255,0,.75)}.black{background-color:rgba(0,0,0,.75)}.hide{display:none}.inline_block_fix:before{display:inline-block;content:'';height:100%;width:0;vertical-align:middle}.vertical_align{vertical-align:middle;display:inline-block;height:100%;width:0}.header{height:70px;color:#FFF;background-color:#2c3e50;font-size:16px;text-align:right;font-family:ProximaNova;text-align:center}.header a{color:#fff;text-decoration:none}.header .fa-phone{color:#42c044;padding-left:10px;padding-right:10px;font-size:24px!important;vertical-align:middle}.mobile_menu{display:inline-block;vertical-align:middle;font-size:24px!important;padding-right:10px;cursor:pointer}.phonebox{display:inline-block;vertical-align:middle;margin-right:0;border-radius:10px 10px 10px 10px;-moz-border-radius:10px 10px 10px 10px;-webkit-border-radius:10px 10px 10px 10px;border:0 solid #000;background-color:#42c044;height:41px;width:210px;font-size:26px;font-weight:700;text-align:center}.phonebox .phonetext{display:inline-block;vertical-align:middle}.callustext{display:none;vertical-align:middle}@media all and (min-width:600px){.callustext{display:inline-block}.mobile_menu{display:none!important}.header{text-align:right}.phonebox{margin-right:40px}}.footer{background-color:#2c3e50;text-align:center;font-family:ProximaNova;color:#fff;padding-top:30px}.footer .copyright_area{height:60px;line-height:60px;background-color:#33383c;color:#aaa;font-size:12px;margin-top:30px}.footer .copyright_area .copyright_links{padding-left:20px}.footer .copyright_area .copyright_links a{color:#aaa;padding-left:2px;padding-right:2px}.footer .whitebox{display:inline-block;vertical-align:middle;margin-left:20px;margin-right:20px;padding-top:20px;padding-bottom:15px;padding-left:30px;padding-right:30px;background-color:#fff;border-radius:5px;text-align:center}.footer .whitebox .footer_logo{display:inline-block;background-image:url(/images/logo-hires-opt.png);background-repeat:no-repeat;background-position:top;background-attachment:scroll;background-size:196px 75px;height:95px;width:196px}.footer .whitebox .bar{border-bottom:2px solid #485867;margin-bottom:20px}.footer .whitebox .asp{display:inline-block;background-image:url(/images/asp-opt.jpg);background-size:95px 75px;background-repeat:no-repeat;height:75px;width:95px}.footer .whitebox .cpo{display:inline-block;background-image:url(/images/cpo-opt.jpg);background-size:75px 75px;background-repeat:no-repeat;background-position:center;height:75px;width:100px}.footer .links_area{display:inline-block;vertical-align:middle;text-align:left;font-size:18px;margin-left:20px;margin-right:20px;width:285px;margin-top:30px}.footer .links_area .links_area_title{font-size:28px;font-weight:700;margin-bottom:20px}.footer .links_area ul li{margin-left:10px;margin-top:10px}.footer .links_area ul li i{width:10px;margin-right:20px}.footer .links_area a{color:#fff;text-decoration:none;border-bottom:2px solid #777F88}@font-face{font-family:ProximaNova;src:url(/fonts/proximanova-regular-webfont.ttf)}@font-face{font-family:ProximaNovaAltBold;src:url(/fonts/proxima_nova_alt_bold-webfont.ttf)}

I still have the error on the javascript but I'm going to keep adding random functions to my javascript file to see if that makes the error go away.  Currently my JS file is:
function test(){alert('test');}function test2(){alert('test2');function test3(){alert('test3');alert('another test');}}

Update #3:
Indeed the file size was the culprit, changing my js file to..
function test(){alert('test');}function test2(){alert('test2');}function test3(){alert('test3');alert('another test');}function test4(){alert('test4');alert('another test4');}function test5(){alert('test5');alert('another test5');}function test6(){alert('test6');alert('another test6');}function test7(){alert('test7');alert('another test7');}function test8(){alert('test8');alert('another test8');}function test9(){alert('test9');alert('another test9');}function test10(){alert('test10');alert('another test10');}function test11(){alert('test11');alert('another test11');}function test12(){alert('test12');alert('another test12');}function test13(){alert('test13');alert('another test13');}function test14(){alert('test14');alert('another test14');}function test15(){alert('test15');alert('another test15');}function test16(){alert('test16');alert('another test16');}function test17(){alert('test17');alert('another test17');}function test18(){alert('test18');alert('another test18');}function test19(){alert('test19');alert('another test19');}function test20(){alert('test20');alert('another test20');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');alert('hello');}

was enough to twigger the header vary encoding error to go away.
Update #4
Was reading this page (https://www.fastly.com/blog/best-practices-for-using-the-vary-header), and apparently if you are using mod_deflate the correct Vary header is automatically added to your responses.  So its very likely that mod_deflate was overwriting my suggested change when the main.css and main.js files were small.
So new question:
Why does the file size matter when trying to add the  Header append Vary User-Agent command? Should I just ignore the speed optimization suggestion from gtmetrix (pagespeed) in this case? Or if mod_deflate is overwriting, is this even a problem? If so how do I fix the overwriting of the header that mod_deflate causes?

A: So after much research and deliberation I have come to the conclusion that mod_deflate is the culprit here.
According to apache it's self: http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
The mod_deflate module sends a Vary: Accept-Encoding HTTP response header to alert proxies that a cached response should be sent only to clients that send the appropriate Accept-Encoding request header. This prevents compressed content from being sent to a client that will not understand it.
The key here is understanding how compression works.  When you look at an HTTP Request from a users browser for example you might see this. (Use google chromes inspector or Firefox's firebug to see these).
GET /css/main.css HTTP/1.1
Host: dev.yoursitehere.com
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: text/css,*/*;q=0.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36
Referer: http://dev.yoursitehere.com
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,nb;q=0.6
Cookie: PHPSESSID=2fd616076481f661975f7de2a92a0016

Notice this line: Accept-Encoding: gzip, deflate, sdch
This is saying to the server, I can uncompress gzip, deflate and sdch compression formats if you send them back to me.
The server does NOT have to send back compressed results.  In fact this is what was happening in my situation when the file size was to small.
8096 bytes is the default set by the apache deflate moduels DeflateBufferSize
This means if the content you want to server is greater than 8096 bytes then it will compress the results, and according to my .htaccess file, I was using the DEFLATE method of compression.
Only once the file size was big enough did I notice the response headers looking like this.
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 29 Dec 2015 20:25:28 GMT
Content-Type: text/css
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Last-Modified: Tue, 29 Dec 2015 19:31:30 GMT
Cache-Control: max-age=2592000
Expires: Thu, 28 Jan 2016 20:25:28 GMT
Content-Encoding: gzip

Normally the Vary:Accept-Encoding response header was not there when the file size of the main.css or main.js file was to small, but once it was past the amount that was worthy of compressing the vary header was automatically added by the mod_deflate module.
That header tells chrome that this is NOT a normal uncompressed file but a file that needs to be uncompressed.  In this particular case, content-encoding was set to gzip.  This means it compressed the results before sending back to me.
https://en.wikipedia.org/wiki/Gzip
According to this, gzip uses the DEFLATE algorithm, (which my browser said it could handle in my request header with the line Accept-Encoding: gzip, deflate, sdch
Thus the browser was able to reconstruct it correctly.
This is why file size matters before the vary header is appended, and what the vary header actually means in this context.


text:
Q: spark dataframe with column when condition My requirement is as below
Joined two data frames as below:
     var c = a.join(b,keys,"fullouter")

c.printSchema() as below:
     |-- add: string (nullable = true)
     |-- sub: string (nullable = true)
     |-- delete: string (nullable = true)
     |-- mul: long (nullable = true)
     |-- ADD: string (nullable = true)
     |-- SUB: string (nullable = true)
     |-- DELETE: string (nullable = true)
     |-- MUL: long (nullable = true)
      It's good until here.

Now i am doing a withcolumn when condition as below
     val d = c.withColumn("column", when(c("a.add") === c("b.ADD"),
   "Neardata"))

error as below:
    Exception in thread "main" org.apache.spark.sql.AnalysisException:
    Cannot resolve column name "a.add"

I tried as below also
     val d = c.withColumn("column", when(col("a.add") === col("b.ADD"), "Neardata"))

    Again error.

   Please suggest.

A: You have to define alias with datframe.as("a") and dataframe1.as("b")
Example :

  import spark.sqlContext.implicits._
  val data = List(("James","","Smith","36636","M",60000),
    ("Michael","Rose","","40288","M",70000),
    ("Robert","","Williams","42114","",400000),
    ("Maria","Anne","Jones","39192","F",500000),
    ("Jen","Mary","Brown","","F",0))

  val cols = Seq("first_name","middle_name","last_name","dob","gender","salary")
  val df = spark.createDataFrame(data).toDF(cols:_*).as("a")
  val df2 = df.withColumn("a.new_gender", when(col("a.gender") === "M","Male")
    .when(col("a.gender") === "F","Female")
    .otherwise("Unknown")).show

Output :
+----------+-----------+---------+-----+------+------+------------+
|first_name|middle_name|last_name|  dob|gender|salary|a.new_gender|
+----------+-----------+---------+-----+------+------+------------+
|     James|           |    Smith|36636|     M| 60000|        Male|
|   Michael|       Rose|         |40288|     M| 70000|        Male|
|    Robert|           | Williams|42114|      |400000|     Unknown|
|     Maria|       Anne|    Jones|39192|     F|500000|      Female|
|       Jen|       Mary|    Brown|     |     F|     0|      Female|
+----------+-----------+---------+-----+------+------+------------+

I think with out alias you are trying to access like this... that might be the cause.
  val df2 = df.withColumn("df.new_gender", when(col("df.gender") === "M","Male")
    .when(col("df.gender") === "F","Female")
    .otherwise("Unknown")).show

redpajama_set_name: RedPajamaStackExchange


text:
Q: Accessing python egg's own metadata I've produced a python egg using setuptools and would like to access it's metadata at runtime. I currently got working this:
import pkg_resources
dist = pkg_resources.get_distribution("my_project")
print(dist.version)

but this would probably work incorrectly if I had multiple versions of the same egg installed. And if I have both installed egg and development version, then running this code from development version would pick up version of the installed egg.
So, how do I get metadata for my egg not some random matching egg installed on my system?

A: I am somewhat new to Python as well, but from what I understand:
Although you can install multiple versions of the "same" egg (having the same name), only one of them will be available to any particular piece of code at runtime (based on your discovery method).  So if your egg is the one calling this code, it must have already been selected as the version of my_project for this code, and your access will be to your own version.

A: Exactly. So you should only be able to get the information for the currently available egg (singular) of a library. If you have multiple eggs of the same library in your site-packages folder, check the easy-install.pth in the same folder to see which egg is really used :-)
On a site note: This is exactly the point of systems like zc.buildout which lets you define the exact version of a library that will be made available to you for example while developing an application or serving a web application. So you can for example use version 1.0 for one project and 1.2 for another.


text:
Q: jQuery : hide one column based on another column I have a simple HTML table containing 3 columns as shown below.

<!DOCTYPE html>

HTML Table

    Company
    Contact
    Country

    Alpha
    Maria Anders
    Germany

    Beta
    Francisco Chang
    Mexico

I would like to hide the 3rd column's value if there is value in 2nd column.
For example in my table (from the code snippet), since both the rows have value in the "Contact" column I want the data from the "Country" column to be hidden.
Is it possible to do this in jQuery ?

A: Following code will help you on this one
$(document).ready(function(){
    $("table tbody tr").each(function() {
        contact = $.trim($(this).children('td:nth-child(2)').html());
        if (contact) {
            $(this).children('td:nth-child(3)').html('');
        }
    });
});

I have used the pseudo class nth-child, you can also give class name for the td and use it to capture the data inside the cells.
Check the working snippet.

$(document).ready(function(){
    $("table tbody tr").each(function() {
        contact = $.trim($(this).children('td:nth-child(2)').html());
        if (contact) {
            $(this).children('td:nth-child(3)').html('');
        }
    });
});
table {
    font-family: arial, sans-serif;
    border-collapse: collapse;
    width: 100%;
}

td, th {
    border: 1px solid #dddddd;
    text-align: left;
    padding: 8px;
}
<!DOCTYPE html>

HTML Table

    Company
    Contact
    Country

    Alpha
    Maria Anders
    Germany

    Beta
    Francisco Chang
    Mexico

    Gamma

    USA


text:
Q: How to make 2nd async method run after 1st async method has finished I have two async methods that I run in succession, but I need to 2nd method called to execute only after the 1st method has resolved

class Class {
  constructor() {}

  async foo() {
    setTimeout(() => {
      console.log(1);
    }, 2000);
  }

  async bar() {
    setTimeout(() => {
      console.log(2);
    }, 0);
  }
}

(async() => {
  const obj = new Class();
  await obj.foo();
  await obj.bar();
})()

The output of the above code:
> 2
> 1

What I need is for the output to be:
> 1
> 2

There's clearly some gaps in my knowledge regarding async/await functions.
Is it possible for me to achieve this? Because of my gap in knowledge, is there a reason I shouldn't be wanting this? Any helped would be much apprecaited.

A: You need to return a custom promise that will resolve when the setTimeout finishes, you can't just use regular async functions. Like this:

class Class {
  constructor() {}

  foo() {
    return new Promise((resolve, reject) => setTimeout(() => {
      console.log(1);
      resolve();
    }, 2000));
  }

  bar() {
    return new Promise((resolve, reject) => setTimeout(() => {
      console.log(2);
      resolve();
    }, 0));
  }
}

(async() => {
  const obj = new Class();
  await obj.foo();
  await obj.bar();
})()

If you want to learn more about promises, then you might want to read this MDN article.


text:
Q: Windows 3.11 version .net I am currently developing a brand new hex editor for Windows 3.11, and I was wondering if I could use the latest version of .net.
Does windows 3.11 support .net 4.5 ?
Update:
Apparently there is no possiblity to run .net 4.5, but is there any emulators or virtualization (vmware) for windows 3.11, so it will be possible to "hack in" .net versions?

A: No, Windows 3.11 dates from the early 1990s and as such pre-dates .net by a loooong time. You cannot run any version of .net on Windows 3.11, never mind bleeding edge .net 4.5.


text:
Q: The new Default Toolbar in 13.1 may have a bug in which a label appears over it. Can label be removed? This post does not ask how to stop new toolbar from appearing but how to remove the described label above it.
I finally installed 13.1 and to my surprise Wolfram added a new Default Toolbar which appears to have a nice-rounded mix of common menu tasks. My only problem with it is the big useless label above it NotebookToolbar which almost doubles the toolbar's height. Right now I primarily use Mathematica on a desktop with a large enough screen, however there are times when my only access to it is on a laptop which has a much smaller screen.
Assuming it's a DockedCell using a CellLabel, can it be forced or set not to display this label?

Edit: A bug report was sent to Wolfram. When their feedback arrives
an answer shall be created with results. I'm using Windows 10 and here is a screenshot. Of the two toolbars, the top one is my own. The bottom one is the new Default toolbar in question.


text:
Q: NGINX Rules redirect with query string not working We are trying to redirect all the files that have this format:
ajax/(.*).php

towards
ajax/getfile.php?file=$1

We always get 404 not when testing ajax/somefile.php found but we discoverd that by adding a trailing slash the rule works:
ajax/somefile.php/

The rule we have so far is:
  location /ajax {
        rewrite ^/ajax/(.*).php/?$ /ajax/getfile.php?file=$1;
    }

The weirdest thing is that we have a similar scenario that actually works!
  location /javasc{
        rewrite ^/javasc/(.*).js/?$ /javasc/view.php?file=$1;
    }


text:
Q: how set geolocation to block in chrome using puppeteer I am looking for a way to respond block when being asked about sharing my location
I got to the point that I do
const context = browser.defaultBrowserContext();
context.clearPermissionOverrides();

I when I do this and login to my app I get the share location pop-up. After that I am able to set my location by doing
context.overridePermissions(global.URL, ['geolocation']);
 await page.setGeolocation({
   latitude: 39.103957,
   longitude: -76.834938
  });

What I actually looking to do is respond 'block' to the share location pop-up.
Below is how my test would eventually look
it("shows error page", async () => {
    await page.setUserAgent("Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X)
           AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1")
    const context = browser.defaultBrowserContext();
    context.clearPermissionOverrides();
    //somehow respond blocked
    await common.login(page, global.USER4,global.PASSWORD4)
    expect(await landingPage.getText()).toMatch("error text")
})


text:
Q: How to assign new object to existing one I've got a problem with reading an object from file..
in main, I made eshop end call a method loadshop.
MyShop eshop = new MyShop();
eshop.loadShop("eshop.txt");

and also I'm getting the shop object from file.
@Override
public void loadShop(String filename) {

    try{
         ObjectInput out = new ObjectInputStream(new FileInputStream(filename));
         MyShop shop = (MyShop)out.readObject();
         out.close();

    } catch (Exception e) {
           e.printStackTrace();
    }
}

But I just can't figure out how to assign "shop" to "eshop"
Thank you for any answer..:-)  (Sorry for my English)

A: Simply edit all eshop's fields, to match shop.

A: Just redesign, you don't need to write
MyShop eshop = new MyShop();

Instead, write
MyShop eshop = MyShop.loadShop("eshop.txt");

and make the loadShop method static. And make it return the MyShop instance, if it isn't already doing that.
If this is not an option, it is still better to get that instance through a hack than to write manual copying code:
public class MyShop {
  private MyShop readShop;

  public MyShop getReadShop() { return readShop; }

  public void loadShop(String fName) {
    try {
       ObjectInput out = new ObjectInputStream(new FileInputStream(filename));
       this.readShop = (MyShop)out.readObject();
       out.close();

    } catch (Exception e) {
      throw new RuntimeException(e);
    }
}

You'd use this like
MyShop tempShop = new MyShop();
tempShop.loadShop();
MyShop eshop = tempShop.getReadShop();

A: Make your loadShop method a static method. Make the method return the MyShop object. Call it on the MyShop class. Assign the return value to eshop. Example:
public class MyShop {
    public static MyShop loadShop(String filename) {
        // ...
        MyShop shop = (MyShop)out.readObject();

        // ...
        return shop;
    }
}

Where you call the method:
MyShop eshop = MyShop.loadShop("eshop.txt");


text:
Q: Summing numbers which increase by a fixed amount (arithmetic progression) An auditorium has 21 rows of seats. The first row has 18 seats, and each succeeding row has two more seats than the previous row. How many seats are there in the auditorium?
Now I supposed you could use sigma notation since this kind of problem reminds me of it, but I have little experience using it so I'm not sure.

A: If the auditorium is as described, then the first row has $18$ seats, the second row has $20$ seats, the third row has $22$, the fourth row has $24$, and so on. You can see that the $21$-th row has $18+(2)(20)$ seats, that is, $58$ seats. Now you can certainly add up the even numbers from $18$ to $58$.  It takes a while.
But the person who described the auditorium lied.  Actually, it has the same number of seats in every row, $18+58$, and it is full.  In the first row, the first $18$ people are boys, the remaining $58$ are girls.  In the second row, the first $20$ are boys, the rest are girls.  In the third row, the first $22$ are boys, the rest are girls. This pattern goes on until the very back, where the first $58$ are boys and the remaining $18$ are girls.  Perhaps you can make a sketch of the auditorium, and the seating pattern.
Now can you tell me quickly how many boys there are?

A: You could write the total using sigma notation as $$\sum_{k=0}^{20}(18+2k)\,$$ among many other ways, but I'm pretty sure that what's wanted here is the actual total. You can add everything up by hand, which is a bit tedious, or you can use the standard formula for the sum of an arithmetic progression, if you know it, or you can be clever and arrange the sizes of the rows like this:
$$\begin{array}{}
18&20&22&24&26&28&30&32&34&36&38\\
58&56&54&52&50&48&46&44&42&40\\ \hline
76&76&76&76&76&76&76&76&76&76&38
\end{array}$$
The bottom row is the sum of the top two, so adding it up gives you the total number of seats. And that's easy: it's $10\cdot 76+38=760+38=798$. This calculation is actually an adaptation to this particular problem of the usual derivation of the formula for the sum of an arithmetic progression, which in this particular case looks like this:
$$\begin{array}{}
18&20&22&24&26&\dots&50&52&54&56&58\\
58&56&54&52&50&\dots&26&24&22&20&18\\ \hline
76&76&76&76&76&\dots&76&76&76&76&76
\end{array}$$
The top row is the original set of row sizes; the second consists of the same numbers in reverse order; and the bottom row is again the sum of the top two. That now counts each seat twice, so the total number of seats is $$\frac12(21\cdot 76)=798\;.$$

A: $$s_1 = 18 = 18 + 2(1-1)\\
s_2 = 20 = 18 + 2(2-1) \\
s_3 = 22 = 18 + 2(3-1) \\
\ldots \\
s_{i} = 18 + 2(i - 1) \\
\ldots \\
s_{21} = 18 + 2(21 - 1)$$
Sum:
$$\sum_{i=1}^{21} (18 + 2(i-1))$$

A: To add on to the good answers already given, here is a diagram:

A: Hint
Arithmetic progression; What is the first term? What is the common difference? What is the sum of first $n$ terms of an arithmetic progression?
For the formula for sum, the "Gaussian trick" works well.

A: The $i$-th row has $18+2i$ seats, for $i=0,...,20$. The number of seats is thus
$$\sum_{i=0}^{20}18+2i=18\times21+\sum_{i=0}^{20}2i=378+2\frac{20\times 21}{2}=378+420=798$$


text:
Q: How to filter items by multiple attribures using eav model? I am building online catalog using eav antipatern. I know this is bad pattern, but i need to be able to add properties at runtime, so i choosed this.Also i cant use solr, because i use hotsted plateform. I have following tables:
Table values:
id| property_id | value
1   1             rtx3060
2   2             intel i5
3   2             intel i7

Table property:
id| name
1   gpu
2   cpu

Table item_value:
item_id | value_id
1         1
1         2
2         1
2         3

Table **item**:
id | name
1    laptop-1
2    laptop-2

I want to filter items in my catalog by multiple parametrs, like laptop which has both processor intel i5 and gpu rtx 3060. How can i do this with sql?
One brute force way to do this is following:
select item_id from item_value where value_id = (select id from value where value = 'intel i5') and item_id in (select item_id from item_value where value_id = (select id from value where value = 'rtx3060'));
This query finds intersection of all ids from item_value table. It can be expanded by and item_id in (select item_id from item_value where value_id = (select id from value where value = 'some') to filter by more values. But is there any faster approach?


text:
Q: While ol li style is applied to ul li? I'm trying to create nested list:

Digit

Circle

Digit

But what I get is:
1. Digit
    1. Circle
2. Digit

Why I'm getting a "decimal" marker in unordered list? I think I apply "decimal" only to ol li elements, not ul li.

A: The selector says "An li that is a descendent of an ol"
The li containing "Circle" is the grandchild of the ol, so it is a descendent.
(It shouldn't be a grandchild since the only permitted child elements of an ol are lis, so the ul should be inside an li (which would still make it a great-grandchild) or not inside the ol at all).
You might want to use the child selector > instead of the descendent selector (a space)


text:
Q: How do I run Juju on a local server? I'd like to use juju on my server at home to get to know juju and play with it. I have multiple computers and would like to access what's on the server from any of them. When I went through the tutorial it setup juju okay, but only exposed the services to the local machine. I want to expose them to the whole network. How can I do this?
Note: my server already exists and is running 12.04, I don't want to reinstall it using maas just to get juju working. I also don't want to run this "in the cloud" on ec2 or any other provider because I want to try this out on my own machine under my control on my network.
Edit:-

*

*No firewall

*No blocking, all ports open

*Yes. All computers on the LAN (192.168.1.0/24) can see the server (homeserver.local) on 192.168.1.2

*Pretty standard wired and wifi with one DHCP server dishing out IP addresses in the above range

*Setup correctly (just started again from scratch) and followed tutorial Luis directed me to, here's the results:- http://paste.ubuntu.com/5714640/

*juju status showed above.

So, all running okay, but the main issue is that the containers have IP addresses locally assigned on the server, which are only accessible on the server itself. While I could go around setting up ssh port forwarding all over the place to access the 10.x IP addresses from the 192.168.1.0/24 range, this seems overcomplicated and unnecessary. I'd like the containers exposed over my LAN.

A: For what I am able to understand, you have Juju installed and working but you want to expose a service to other computers on your network. I will assume all the computers on your network can see each other and have their IP addresses correct.
I am also guessing the tutorial you are talking about is one of this:

*

*How do I configure juju for local usage?

*Getting started with Juju
then I would imagine that if you want to make the service available for other computers you would do this:
juju expose SERVICE

Using How to install Hadoop? as the example I would:
juju expose hadoop-master

Juju Expose - https://jujucharms.com/docs/stable/charms-exposing
juju status SERVICE also helps in figuring out how the service is working.
Of course there are a couple of things I would need to know about the network and the server, for instance:

*

*Does the server have a firewall setup (iptables, ufw...)

*Does the network have a router configured to do something related to blocking, forwarding and such that would create a problem trying to access the server?

*Do the computers on the LAN see the server?

*Is there any special connection that is not common (Wireless or Wired) or security in used that could create a problem with the clients and server?

*Are all the steps to setup Juju correctly done (As provided by the tutorials mentioned, specially the part about environments.yaml which I tend to forget or get wrong).

*Does juju status give you some insight of what the problem could be?

*Do you have multiple environments set up in the environments.yaml file?

In case the service is not shown to the outside because of LXC, do the following (Provided by the answer popey gave and a lot of research):

*

*Setup bridged network br0 in /etc/network/interfaces

*Edit /etc/lxc/lxc.conf and set lxc.network.link=br0

*Edit /etc/default/lxc and set LXC_BRIDGE, LXC_ADDR, LXC_NETMASK, LXC_NETWORK, LXC_DHCP_RANGE & LXC_DHCP_MAX appropriately to the LAN (192.168.1.0/24 type settings)
Now juju status should show 192.168.1.0/24 addresses for my units and can be access over the LAN from another machine.

A: Ok, solved!
Setup bridged network br0 in /etc/network/interfaces.
auto eth1
iface eth1 inet manual

auto br0
iface br0 inet static
bridge_ports eth1
address 192.168.1.2
broadcast 192.168.1.255
netmask 255.255.255.0
gateway 192.168.1.1
bridge_stp off
bridge_fd 0
bridge_maxwait 0

Edit /etc/lxc/lxc.conf and set lxc.network.link=br0
lxc.network.type=veth
lxc.network.link=br0
lxc.network.flags=up

Edit /etc/default/lxc and set LXC_BRIDGE, LXC_ADDR, LXC_NETMASK, LXC_NETWORK, LXC_DHCP_RANGE & LXC_DHCP_MAX appropriately for my LAN (192.168.1.0/24 type settings)
now juju status shows 192.168.1.0/24 addresses for my units and I can access them over the LAN from another machine
LXC_BRIDGE="br0"
LXC_ADDR="192.168.1.2"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="192.168.1.0/24"
LXC_DHCP_RANGE="192.168.1.50,192.168.1.99"
LXC_DHCP_MAX="49"


text:
Q: How to use CameraX together with Camera2 API? I am currently trying to enable macro mode in Android using the CameraX API. As CameraX seems not to support macro focus mode, I want to make use of Camera2.
Is there a possibility to use Camera2 in order to enable macro for CameraX?
Thanks for any help.


text:
Q: How to get the last order of a customer in Woocommerce I am using "How can I get the latest order id in Woocommerce" answer code that returns last order with a custom function get_last_order_id().
Here is my code attempt where I get order items:
<?php

    $latest_order_id = get_last_order_id(); // Last order ID
    $order = wc_get_order( $latest_order_id ); // Get an instance of the WC_Order object
    $order_details = $order->get_data(); // Get the order data in an array
    $order_status = esc_html( wc_get_order_status_name( $order->get_status() ) );
    $order_items = $order_details['line_items'];
?>

Then I use this in this code:

        <?php
        foreach ($order_items as $product_name) { ?>

<?php echo $product_name['name']; ?>

        <?php
        }
        ?>

<?php echo $order_status; ?>

I would like to get the last order for the current customer. How can I change the custom function get_last_order_id() to get the last order for the current customer?
I would like to receive the contents of my cart in addition to the latest order from the current user.

A:
Updated: replaced WC()->customer by new WC_Customer( get_current_user_id() ); for better compatibility.

The Class WC_Customer Class include the get_last_order() method to get the last order for a customer (so you don't need anymore the custom function get_last_order_id() from this answer thread).
So your code will be:
<?php

    // For logged in users only
    if ( is_user_logged_in() ) :

    $user_id = get_current_user_id(); // The current user ID

    // Get the WC_Customer instance Object for the current user
    $customer = new WC_Customer( $user_id );

    // Get the last WC_Order Object instance from current customer
    $last_order = $customer->get_last_order();

    $order_id     = $last_order->get_id(); // Get the order id
    $order_data   = $last_order->get_data(); // Get the order unprotected data in an array
    $order_status = $last_order->get_status(); // Get the order status
?>

        <?php foreach ( $last_order->get_items() as $item ) : ?>

<?php echo $item->get_name(); ?>

        <?php endforeach; ?>

<?php echo esc_html( wc_get_order_status_name( $order_status ) ); ?>

<?php endif; ?>

Tested and works.
Note: Now to "receive the contents of the cart in addition to the latest order from the current user", you will have to ask a new question with more details, one question at the time please.
Related:

*

*How to get WooCommerce order details

*Get Order items and WC_Order_Item_Product in WooCommerce 3

*How to get Customer details from Order in WooCommerce?


text:
Q: Please make my table perfect with long caption Question: I want to ask to question here first adjust the vertical and horizontal alignment of cells and second adjust the position of caption so table looks perfect.
Please help me. This is what I have right now.
MWE
\documentclass[12pt]{article}
\usepackage[a4paper,top=0.6 in,bottom=0.6 in,left=0.6 in,right=0.6 in]{geometry}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{mathtools}
\begin{document}
\large
\begin{table}[]
\caption{Skin-friction co-efficient $Re_{x^{1/2}}C_{F_x}$ with linear stretching $n=1$ and non-linear stretching $n=1.5$ at $A=0.2$, $N_{r}=0.4$, $H=2$, $P_{r}=0.71$, $S_{c}=0.22$, $D_{f}=0.5$ and $S_{r}=1$}
\begin{tabular}{|c|c|c|c|c|cc|}
\hline
\multirow{2}{*}{$M$} & \multirow{2}{*}{$\gamma$} & \multirow{2}{*}{$\Tilde{N}$} & \multirow{2}{*}{$\lambda$} & \multirow{2}{*}{$k_{1}$} & \multicolumn{2}{c|}{$Re_{x^{1/2}}C_{F_x}$}                         \\ \cline{6-7}
                     &                      &                      &                      &                      & \multicolumn{1}{c|}{$G$}          & $H$          \\ \hline
1.1                  & 1                    & 1                    & 1.2                  & 0.5                  & \multicolumn{1}{c|}{0.3664295040} & 0.6593644125 \\ \hline
1.2                  & 1                    & 1                    & 1.2                  & 0.5                  & \multicolumn{1}{c|}{0.3415189701} & 0.6363362691 \\ \hline
1.3                  & 1                    & 1                    & 1.2                  & 0.5                  & \multicolumn{1}{c|}{0.3101361584} & 0.6292554996 \\ \hline
1                    & 1.1                  & 1                    & 1.2                  & 0.5                  & \multicolumn{1}{c|}{0.3642452938} & 0.6515014440 \\ \hline
1                    & 1.2                  & 1                    & 1.2                  & 0.5                  & \multicolumn{1}{c|}{0.3619918988} & 0.6444405649 \\ \hline
1                    & 1                    & 1.1                  & 1.2                  & 0.5                  & \multicolumn{1}{c|}{0.4139365457} & 0.7091621892 \\ \hline
1                    & 1                    & 1.2                  & 1.2                  & 0.5                  & \multicolumn{1}{c|}{0.4613301362} & 0.7588005786 \\ \hline
1                    & 1                    & 1                    & 1.3                  & 0.5                  & \multicolumn{1}{c|}{0.4660386532} & 0.7627708751 \\ \hline
1                    & 1                    & 1                    & 1.4                  & 0.5                  & \multicolumn{1}{c|}{0.5649027509} & 0.8652549292 \\ \hline
1                    & 1                    & 1                    & 0.2                  & 0.6                  & \multicolumn{1}{c|}{0.3921955746} & 0.7029730388 \\ \hline
1                    & 1                    & 1                    & 0.2                  & 0.7                  & \multicolumn{1}{c|}{0.4025037653} & 0.7326143623 \\ \hline
\end{tabular}
\end{table}
\end{document}

A: Some suggestions, in no partiular order: (a) Use a threeparttable environment to encase both the \caption statement and the tabular environment. That way, the width of the caption will be limited to that of the table body. (b) Employ the S column type (provided by the siunitx package) to align the numbers in the 7 data columns on their explicit or implicit decimal markers. (c) Give the table a much more open and inviting look by getting rid of all vertical rules (yes, really!) and using fewer, but well-spaced horizontal rules. (d) Load the caption package and employ the skip parameter to control the vertical separation below the caption.

\documentclass[12pt]{article}
\usepackage[a4paper,margin=0.6in]{geometry}
\usepackage{mathtools}
\usepackage{threeparttable} % for threeparttable environment
\usepackage{siunitx}        % for S column type
\usepackage{booktabs}       % for well-spaced horizontal rules
\usepackage[skip=0.5\baselineskip]{caption}

\begin{document}
\large %% are you sure you need this?

\begin{table}
\centering
\begin{threeparttable}

\caption{Skin-friction co-efficient $Re_{x^{1/2}}C_{F_x}$, with linear stretching
$n=1$ and non-linear stretching $n=1.5$. Other parameter settings:
$A=0.2$, $N_{r}=0.4$, $H=2$, $P_{r}=0.71$, $S_{c}=0.22$,
$D_{f}=0.5$, and $S_{r}=1$.}

\begin{tabular}{@{} *{5}{S[table-format=1.1]}
                    *{2}{S[table-format=1.10,group-digits=false]}
                @{}}
\toprule
{$M$} & {$\gamma$} & {$\widetilde{N}$} & {$\lambda$} & {$k_{1}$} &
\multicolumn{2}{c}{$Re_{x^{1/2}} C_{F_x}$} \\
\cmidrule(l){6-7}
& & & & & {$G$} & {$H$}  \\
\midrule
1.1 & 1   & 1   & 1.2 & 0.5 & 0.3664295040 & 0.6593644125 \\
1.2 & 1   & 1   & 1.2 & 0.5 & 0.3415189701 & 0.6363362691 \\
1.3 & 1   & 1   & 1.2 & 0.5 & 0.3101361584 & 0.6292554996 \\ \addlinespace
1   & 1.1 & 1   & 1.2 & 0.5 & 0.3642452938 & 0.6515014440 \\
1   & 1.2 & 1   & 1.2 & 0.5 & 0.3619918988 & 0.6444405649 \\
1   & 1   & 1.1 & 1.2 & 0.5 & 0.4139365457 & 0.7091621892 \\
1   & 1   & 1.2 & 1.2 & 0.5 & 0.4613301362 & 0.7588005786 \\ \addlinespace
1   & 1   & 1   & 1.3 & 0.5 & 0.4660386532 & 0.7627708751 \\
1   & 1   & 1   & 1.4 & 0.5 & 0.5649027509 & 0.8652549292 \\
1   & 1   & 1   & 0.2 & 0.6 & 0.3921955746 & 0.7029730388 \\
1   & 1   & 1   & 0.2 & 0.7 & 0.4025037653 & 0.7326143623 \\
\bottomrule
\end{tabular}
\end{threeparttable}
\end{table}
\end{document}

A: Hm, it is still unclear to me what is `perfect table" for you :-(. This is very opinion dependent ...
One possibilities, at least the code is much simpler than yours, is to use  the tabularray package (MWE below is tested by version 2022C) with siunitx library:
\documentclass[12pt]{article}
\usepackage[a4paper,
            margin=0.6 in]{geometry}
\usepackage{tabularray}
\UseTblrLibrary{amsmath, siunitx}
% \usepackage{mathtools} % not needed in this example
\usepackage[skip=0.33\baselineskip]{caption}

\begin{document}
    \begin{table}[ht]
\caption{Skin-friction co-efficient $Re_{x^{1/2}}C_{F_x}$ with linear stretching $n=1$ and non-linear stretching $n=1.5$ at $A=0.2$, $N_{r}=0.4$, $H=2$, $P_{r}=0.71$, $S_{c}=0.22$, $D_{f}=0.5$ and $S_{r}=1$}
\label{tab:???}
    \centering
\begin{tblr}{hlines, vlines,
             colspec = {*{5}{Q[c, si={table-format=1.1}]}
                        *{2}{Q[c, si={table-format=1.10}]}},
             colsep  = 12pt,
             row{1,2}= {guard, mode=math}
             }
\SetCell[r=2]{c}    M
    & \SetCell[r=2]{c}  \gamma
            & \SetCell[r=2]{c}  \Tilde{N}
                    & \SetCell[r=2]{c}  \lambda
                            & \SetCell[r=2]{c}  k_{1}
                                    & \SetCell[c=2]{c}  Re_{x^{1/2}}C_{F_x}
                                                    &               \\
    &       &       &       &       & G             & H             \\
1.1 & 1     & 1     & 1.2   & 0.5   & 0.3664295040  & 0.6593644125  \\
1.2 & 1     & 1     & 1.2   & 0.5   & 0.3415189701  & 0.6363362691  \\
1.3 & 1     & 1     & 1.2   & 0.5   & 0.3101361584  & 0.6292554996  \\
1   & 1.1   & 1     & 1.2   & 0.5   & 0.3642452938  & 0.6515014440  \\
1   & 1.2   & 1     & 1.2   & 0.5   & 0.3619918988  & 0.6444405649  \\
1   & 1     & 1.1   & 1.2   & 0.5   & 0.4139365457  & 0.7091621892  \\
1   & 1     & 1.2   & 1.2   & 0.5   & 0.4613301362  & 0.7588005786  \\
1   & 1     & 1     & 1.3   & 0.5   & 0.4660386532  & 0.7627708751  \\
1   & 1     & 1     & 1.4   & 0.5   & 0.5649027509  & 0.8652549292  \\
1   & 1     & 1     & 0.2   & 0.6   & 0.3921955746  & 0.7029730388  \\
1   & 1     & 1     & 0.2   & 0.7   & 0.4025037653  & 0.7326143623  \\
\end{tblr}
    \end{table}
\end{document}

However, you may liked that table's caption is not wider than table. In this case you should use talltblr environment, which s tabularray equivalent for "classic" threeparttable:
\documentclass[12pt]{article}
\usepackage[a4paper,
            margin=0.6 in]{geometry}
\usepackage{tabularray}
\UseTblrLibrary{amsmath, siunitx}
\usepackage[skip=0.33\baselineskip]{caption}

\begin{document}
    \begin{table}[ht]
    \centering
\begin{talltblr}[
caption = {Skin-friction co-efficient $Re_{x^{1/2}}C_{F_x}$ with linear stretching $n=1$ and non-linear stretching $n=1.5$ at $A=0.2$, $N_{r}=0.4$, $H=2$, $P_{r}=0.71$, $S_{c}=0.22$, $D_{f}=0.5$ and $S_{r}=1$},
  label = {tab:???}
                ]{hlines, vlines,
             colspec = {*{5}{Q[c, si={table-format=1.1}]}
                        *{2}{Q[c, si={table-format=1.10}]}},
             colsep  = 12pt,
             row{1,2}= {guard, mode=math}
             }
%% table body is the same as above

\end{talltblr}
    \end{table}
\end{document}

Addendum:
At the and a fancy version of your table. For exercise of use the tabularray package.
\documentclass[12pt]{article}
\usepackage[a4paper,
            margin=0.6 in]{geometry}
\usepackage{tabularray}
\UseTblrLibrary{amsmath, booktabs, counter, siunitx}
  \ExplSyntaxOn
\NewChildSelector{eachthree}
  {
    \int_step_inline:nnnn {6}{3}{\l_tblr_childs_total_tl}
      { \clist_put_right:Nn \l_tblr_childs_clist {##1} }
  }
\ExplSyntaxOff

\usepackage[skip=0pt,
            font = {small, sf},
            labelfont = bf,
            singlelinecheck = off
            ]{caption}

\NewTblrTheme{captionof}%
{\DefTblrTemplate{caption}{default}%
    {\addtocounter{table}{-1}%
     \captionof{table}{\InsertTblrText{caption}}%
    }
}

\begin{document}
    \begin{table}[ht]
    \centering
\begin{talltblr}[
  theme = captionof,
caption = {Skin friction coefficient $Re_{x^{1/2}}C_{F_x}$ with linear stretching $n=1$ and non-linear stretching $n=1.5$ at $A=0.2$, $N_{r}=0.4$, $H=2$, $P_{r}=0.71$, $S_{c}=0.22$, $D_{f}=0.5$ and $S_{r}=1$},
  label = {tab:???}
                ]{colspec = {*{5}{Q[c, si={table-format=1.1}]}
                             *{2}{Q[c, si={table-format=1.10}]}},
                  colsep  = 12pt,
                  row{1,2}= {guard, mode=math},
                  row{3-Z}= {rowsep=0pt},
                  row{eachthree} = {abovesep=1ex},
                 }
    \toprule
\SetCell[r=2]{c}    M
    & \SetCell[r=2]{c}  \gamma
            & \SetCell[r=2]{c}  \Tilde{N}
                    & \SetCell[r=2]{c}  \lambda
                            & \SetCell[r=2]{c}  k_{1}
                                    & \SetCell[c=2]{c}  Re_{x^{1/2}}C_{F_x}
                                                    &               \\
    \midrule
    &       &       &       &       & G             & H             \\
    \midrule
1.1 & 1     & 1     & 1.2   & 0.5   & 0.3664295040  & 0.6593644125  \\
1.2 & 1     & 1     & 1.2   & 0.5   & 0.3415189701  & 0.6363362691  \\
1.3 & 1     & 1     & 1.2   & 0.5   & 0.3101361584  & 0.6292554996  \\
1   & 1.1   & 1     & 1.2   & 0.5   & 0.3642452938  & 0.6515014440  \\
1   & 1.2   & 1     & 1.2   & 0.5   & 0.3619918988  & 0.6444405649  \\
1   & 1     & 1.1   & 1.2   & 0.5   & 0.4139365457  & 0.7091621892  \\
1   & 1     & 1.2   & 1.2   & 0.5   & 0.4613301362  & 0.7588005786  \\
1   & 1     & 1     & 1.3   & 0.5   & 0.4660386532  & 0.7627708751  \\
1   & 1     & 1     & 1.4   & 0.5   & 0.5649027509  & 0.8652549292  \\
1   & 1     & 1     & 0.2   & 0.6   & 0.3921955746  & 0.7029730388  \\
1   & 1     & 1     & 0.2   & 0.7   & 0.4025037653  & 0.7326143623  \\
    \bottomrule
\end{talltblr}
    \end{table}
\end{document}

A: I suggest giving some more air to the table by increasing the intercolumn space, otherwise the very short column headers make for too compact typesetting.
Another improvement is avoiding vertical rules and \multirow: the first six headers are at the same level as the common header for the final two columns. Using siunitx helps a lot with numeric tables.
Note that article is set up for captions below tables. If you want the reverse, load caption.
Another suggestion is never using \begin{document}\large; 12pt size is already quite big. If you really need 14pt size, load extarticle.
Final details: \Tilde does nothing different from \tilde; for the Reynolds number, use \mathit{Re} rather than Re.
\documentclass[12pt]{article}
\usepackage[a4paper,top=0.6 in,bottom=0.6 in,left=0.6 in,right=0.6 in]{geometry}

\usepackage{siunitx,booktabs,caption}

\begin{document}

\begin{table}[htp]
\centering

\caption{Skin-friction coefficient $\mathit{Re}_{x^{1/2}}C_{F_x}$ with linear
  stretching $n=1$ and non-linear stretching $n=1.5$ at $A=0.2$, $N_{r}=0.4$,
  $H=2$, $P_{r}=0.71$, $S_{c}=0.22$, $D_{f}=0.5$ and $S_{r}=1$}

\setlength{\tabcolsep}{2\tabcolsep}

\begin{tabular}{
  @{}
  S[table-format=1.1]
  S[table-format=1.1]
  S[table-format=1.1]
  S[table-format=1.1]
  S[table-format=1.1]
  S[table-format=1.10]
  S[table-format=1.10]
  @{}
}
\toprule
{$M$} & {$\gamma$} & {$\tilde{N}$} & {$\lambda$} & {$k_{1}$} &
\multicolumn{2}{c}{$\mathit{Re}_{x^{1/2}}C_{F_x}$} \\
\cmidrule(l{\tabcolsep}){6-7}
&&&&& {$G$} & {$H$} \\
\midrule
1.1 & 1   & 1   & 1.2 & 0.5 & 0.3664295040 & 0.6593644125 \\
1.2 & 1   & 1   & 1.2 & 0.5 & 0.3415189701 & 0.6363362691 \\
1.3 & 1   & 1   & 1.2 & 0.5 & 0.3101361584 & 0.6292554996 \\
1   & 1.1 & 1   & 1.2 & 0.5 & 0.3642452938 & 0.6515014440 \\
1   & 1.2 & 1   & 1.2 & 0.5 & 0.3619918988 & 0.6444405649 \\
1   & 1   & 1.1 & 1.2 & 0.5 & 0.4139365457 & 0.7091621892 \\
1   & 1   & 1.2 & 1.2 & 0.5 & 0.4613301362 & 0.7588005786 \\
1   & 1   & 1   & 1.3 & 0.5 & 0.4660386532 & 0.7627708751 \\
1   & 1   & 1   & 1.4 & 0.5 & 0.5649027509 & 0.8652549292 \\
1   & 1   & 1   & 0.2 & 0.6 & 0.3921955746 & 0.7029730388 \\
1   & 1   & 1   & 0.2 & 0.7 & 0.4025037653 & 0.7326143623 \\
\bottomrule
\end{tabular}

\end{table}

\end{document}


text:
Q: Enable PDF commenting with TexShop I'm using TexShop (Mac OS 10.5) to typeset a manuscript and I would like to share the generated PDF with some colleagues. In the process, I would like to add some comments to the generated PDF and allow my colleagues to do the same. The freely available Acrobat Reader has commenting functionality, but apparently the PDF must explicitly allow commenting (and probably other forms of editing as well). Is there a way that I can tell TexShop and/or the underlying Tex distribution to typeset the PDF with the proper permissions?
As an alternative, I just discovered the todonotes package, with which pop-up comments can be added to the source code and created when the document is originally typeset. This will work for me and perhaps one other colleague, but it's unlikely that I will be able to get all of my colleagues to pull the tex source from my git repo and edit it...so my original question remains.

A: Not if the PDF has to be editable with Adobe Reader (there are free readers that allow this, though - e.g. Foxit Reader). Adobe Reader only allows this if the PDF has been created by Adobe products; the PDFs have to be digitally signed with a key by Adobe. See the Wikipedia and a detailed explanation.


text:
Q: Rails 4 - Two models setup for one to many association but cannot pull all the records associated with one model I have 2 models: Doc and Row.
Doc has many Rows and a Row belongs_to a single Doc.
Here is what the models look like in code:
Doc:
# == Schema Information
#
# Table name: docs
#
#  id         :integer          not null, primary key
#  created_at :datetime
#  updated_at :datetime
#  numrows    :integer
#  user       :string(255)
#  source     :string(255)
#  size       :string(255)
#  location   :string(255)
#  status     :string(255)
#

class Doc < ActiveRecord::Base
    has_many :rows

Row:
# == Schema Information
#
# Table name: rows
#
#  id         :integer          not null, primary key
#  created_at :datetime
#  updated_at :datetime
#  numCols    :integer
#  type       :string(255)
#  content    :text
#  status     :string(255)
#  doc_id     :integer
#

class Row < ActiveRecord::Base
    belongs_to :doc, :foreign_key => "doc_id", :class_name => "Doc"

=begin
Status of a row can be:
1) header
2) body
3) ignore
4) nil
=end

Now in rails console Here are the set of commands Im running:
2.0.0-p247 :084 > @doc = Doc.find(9)
  Doc Load (0.7ms)  SELECT `docs`.* FROM `docs` WHERE `docs`.`id` = 9 LIMIT 1
 => #<Doc id: 9, created_at: "2014-07-14 16:42:54", updated_at: "2014-07-14 16:42:59", numrows: 761, user: "XXXX", source: nil, size: nil, location: "ABC.csv", status: "parsing_complete">

2.0.0-p247 :085 > @doc.rows
NoMethodError: undefined method `rows' for #<Doc:0x007ff20c1b8860>
    from /Users/XXXX/.rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.2/lib/active_model/attribute_methods.rb:439:in `method_missing'
    from /Users/XXXX/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.2/lib/active_record/attribute_methods.rb:155:in `method_missing'
    from (irb):85
    from /Users/XXXX/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands/console.rb:90:in `start'
    from /Users/xxxx/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands/console.rb:9:in `start'
    from /Users/XXXX/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.2/lib/rails/commands.rb:62:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'
2.0.0-p247 :086 >

2.0.0-p247 :086 > Row.where(:doc_id => 9)
  Row Load (31.7ms)  SELECT `rows`.* FROM `rows` WHERE `rows`.`doc_id` = 9
 => #<ActiveRecord::Relation [#<Row id: 1, created_at: "2014-07-14 16:42:57", updated_at: "2014-07-14 16:42:57", numCols: nil, type: nil, content: "[PROGRAMS] (All Locations|Consolidated),,,,,,,,,,,,...">,

,
....
So the Row objects exist. However, Im not able to pull them up through the corresponding Doc model object.
Since Ive set up all the association. I'm wondering what trick am I not getting here
Any help would be appreciated.
Thanks

A: So in Rails 4 due to strong params its not enough to set up the model relationships. One also has to permit the retrieval of the associated model by setting up the "model_params" method accordingly.
Here, I changed my docs_controller/doc_params to the following
     # Never trust parameters from the scary internet, only allow the white list through.
        def doc_params
          params.require(:doc).permit(:status, :user, :numrows, :size, :source, :location, :row_ids => [])
        end

Notice "row_ids => []". Thats what was missing. Now everything is fine.


text:
Q: How to replace a word which has a specific pattern in text? I have a ntext (or nvarchar(max)) column which contains HTML text for example:

Hello

 World!

Now I need to replace each path of the src from files/ to files/new/ (or to other path) but only those with path of files/.
a REPLACE won't work (I think) because it would change also files/folder1/ and files/folder2/.
In the above example, I need to only change the path for 1.JPG and 4.JPG.
How can I do it? (The question is specific to sql-server).
Note: The file names/content can vary. the above HTML is just an example.

A: Following a quick approach in order to replace a certain pattern within a nvarchar(max) string. To be more precisely: the code takes a nvarchar(max) variable @x as source and writes the transformed string into a new variable @y. However, I wrote only the part of the string replacement - the "Update" still has to be coded.
DECLARE @x nvarchar(max) = '
Hello

 World!

'

DECLARE @brPos int = (SELECT CHARINDEX('
', @x));
DECLARE @brPosPrev int = 0;

DECLARE @srcPos int;
DECLARE @SlashPos int;
DECLARE @JPGPos int;

DECLARE @y nvarchar(max) = '';

DECLARE @xPart nvarchar(max);

WHILE (@brPos != 0)
BEGIN
  SET @xPart = SUBSTRING(@x, CASE WHEN @brPosPrev = 0 THEN @brPosPrev ELSE @brPosPrev END, @brPos-CASE WHEN @brPosPrev = 0 THEN @brPosPrev ELSE @brPosPrev END+4)

  SET @srcPos = (SELECT CHARINDEX('src="files/', @xPart))+11;
  SET @JPGPos = (SELECT CHARINDEX('.JPG', @xPart));
  SET @SlashPos = (SELECT CHARINDEX('/', @xPart, @srcPos));

  IF (@JPGPos < @SlashPos OR @SlashPos = 0)
    SET @xPart = REPLACE(@xPart, 'src="files/', 'src="files/new/');

  SET @y = @y + @xPart;

  SET @brPosPrev = @brPos + 4;
  SET @brPos = (SELECT CHARINDEX('
', @x, @brPosPrev));

END

SELECT @y

The Patterns I used in the CHARINDEX calls can be moved to variables as well - so you are not bound to use .JPG or whatever.

A: My solution:
DECLARE @input nvarchar(max) =
'
Hello

 World!

'

DECLARE @path_old nvarchar(max) = 'files/';
DECLARE @path_new nvarchar(max) = 'files/new/';

DECLARE @i int, @j int;
DECLARE @path_len int = LEN(@path_old);
DECLARE @input_len int = LEN(@input);
DECLARE @start_location int = 1;
DECLARE @output nvarchar(max) = '';
DECLARE @p nvarchar(max);

WHILE 1 = 1
BEGIN
    SET @i = CHARINDEX('"' + @path_old, @input, @start_location)
    IF @i <> 0
    BEGIN
        SET @j = CHARINDEX('"', @input, @i + 1);
        SET @p = SUBSTRING(@input, @i + @path_len + 1, @j - @i - @path_len);
        IF CHARINDEX('/', @p) = 0
            SET @output = @output + SUBSTRING(@input, @start_location - 1, @i + 2 - @start_location) + @path_new + @p
        ELSE
            SET @output = @output + SUBSTRING(@input, @start_location - 1, @j + 2 - @start_location);

        SET @start_location = @j + 2
        IF @start_location >= @input_len BREAK;
    END
    ELSE
    BEGIN
        SET @output = @output + SUBSTRING(@input, @start_location - 1, @input_len - @start_location + 2);
        BREAK;
    END
END

PRINT @output

A: Method 1 - 1 or 2 known file names
If you only need to replace paths for 1.JPG and 4.JPG, then you can write an UPDATE statement:
UPDATE t
    SET html = REPLACE(REPLACE(html, 'src="files/4.JPG"', 'src="files/new/4.JPG"'), 'src="files/1.JPG"', 'src="files/new/1.JPG"')
FROM t
WHERE CHARINDEX('src="files/1.JPG"', html) + CHARINDEX('src="files/4.JPG"', html) > 0;

Or, if you'd rather keep them separate:
UPDATE t
    SET html = REPLACE(html, 'src="files/1.JPG"', 'src="files/new/1.JPG"')
FROM t
WHERE CHARINDEX('src="files/1.JPG"', html) > 0;

UPDATE t
    SET html = REPLACE(html, 'src="files/4.JPG"', 'src="files/new/4.JPG"')
FROM t
WHERE CHARINDEX('src="files/4.JPG"', html) > 0;

Method 2 - potentially large list of files, whose names can be determined from the filesystem
If you need to replace the paths for a large number of files, whose file names can be determined from the filesystem, try this instead:

*

*Enable xp_cmdshell if required (see Enable 'xp_cmdshell' SQL Server).

*Create a temporary table to store the file names:
CREATE TABLE #Images(
    Image_Name VARCHAR(100) NULL
)

*List all the files.
INSERT INTO #Images
exec xp_cmdshell 'dir D:\Data\*.jpg /b'

*Remove NULL lines and anything else that's not required.
DELETE FROM #Images
WHERE Image_Name IS NULL

*Generate SQL statements for each file name.
SELECT '
    UPDATE t
        SET html = REPLACE(html, ''src="files/' + Image_Name + '"'', ''src="files/new/' + Image_Name + '"'')
    FROM t
    WHERE CHARINDEX(''src="files/' + Image_Name + '"'', html) > 0;
'
FROM #Images

*Now simply copy-paste the output from executing the above SELECT statement back and execute the UPDATE queries.


text:
Q: Is there a way how to authenticate into Dynamics CRM API without username/password I have a website which needs to contact Dynamics CRM (online 2015) through its API. The web server is not part of company domain. From the documentation it seems the only way how to do it, is use user's login credentials. I'm feeling uneasy to have CRM administrator's credentials stored somewhere in 'plaintext'.
Is there a way how to authenticate with some pre-generated API key/token? What is the best practice for using the credentials? Should I create special user account (assign CRM license), possibly with limited rights?

A: As far as I'm aware the only authentication is username/password.  You should never have any credentials stored in 'plain text'.  At the very least do a basic encryption on your password and decrypt it in your code.
I definitely recommend creating a specialised account for integration and restricting its rights as much as possible (especially using CRM Online!).  Then you can at least ensure they can't create new users etc.


text:
Q: How to select the checkboxes .length and output it in an html element? For an exercise, I would like to know how many checkboxes are checked and output the .length of These with a button in an HTML Element.
This is as far as I got...
Code:

/*Anzahl*/
function cname() {
  var canzahl = document.getElementsByClassName('.classes').options;
  var count = 0;
  for (i = 0; i < canzahl.length; i++) {
    if (canzahl[i].selected)
      count++;
  }
  document.getElementById('mklassen').innerHTML = count;
}
/*Ausgabe*/
function ausgabe() {
  document.getElementById('Ausgabe').innerHTML =
    cname();
};
/*Checkbox*/
input[type="checkbox"] {
  display: none;
}

/*Checkbox*/
.classes:not(checked)+label:before {
  content: " ";
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid black;
  border-radius: 3px;
  margin-right: 5px;
}

/*Checkbox*/
.classes:checked+label:before {
  background-color: black;
}
<input class="classes" type="checkbox" value="text" id="cclass" name="class">
BI15b
<input class="classes" type="checkbox" value="text" id="bclass" name="class">
BI16b
<input class="classes" type="checkbox" value="text" id="dclass" name="class">
BI17b
<input class="classes" type="checkbox" value="text" id="eclass" name="class">
BI18b

<input id="Ausgabe" class="ausgabe" value="Submit" type="button" onclick="ausgabe();">

Markierte Klassen:

For your information I have seen answers on stackoverflow to this question already. Sadly These were either done with jQuery or just did not work for me.

A: You can find all checked checkboxes in the page using this code:
document.querySelectorAll('input[type="checkbox"]:checked');

If you want to output the length in an html element:
myElement.innerHTML = document.querySelectorAll('input[type="checkbox"]:checked').length;

A: Few mistakes on your part:
On checkboxes you are looking for the .checked state
Also, I didn't know why there was the .options on your selector. So removing it helped.
Finally, when your try to put count in the innerHtml. The id's didn't match.
Hope this is what you were looking for. Happy to explain or help in a better solution if needed.

/*Anzahl*/
function cname() {
  var canzahl = document.getElementsByClassName('classes');
  var count = 0;
  for (i = 0; i < canzahl.length; i++) {
    if (canzahl[i].checked)
      count++;
  }
  console.log(count);
  document.getElementById('mklaasen').innerHTML = count;
}
/*Ausgabe*/
function ausgabe() {
  document.getElementById('Ausgabe').innerHTML =
    cname();
};
/*Checkbox*/
input[type="checkbox"] {
  display: none;
}

/*Checkbox*/
.classes:not(checked)+label:before {
  content: " ";
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid black;
  border-radius: 3px;
  margin-right: 5px;
}

/*Checkbox*/
.classes:checked+label:before {
  background-color: black;
}
<input class="classes" type="checkbox" value="text" id="cclass" name="class">
BI15b
<input class="classes" type="checkbox" value="text" id="bclass" name="class">
BI16b
<input class="classes" type="checkbox" value="text" id="dclass" name="class">
BI17b
<input class="classes" type="checkbox" value="text" id="eclass" name="class">
BI18b

<input id="Ausgabe" class="ausgabe" value="Submit" type="button" onclick="ausgabe();">

Markierte Klassen:

A: I have found 3 issues in your code.

*

*getElementsByClassName should expect classes not .classes

*There shouldn't be any options property in getElementsByClassName method

*You misspelled id name which causes null innerHTML.

/*Anzahl*/
function cname() {
  var canzahl = document.getElementsByClassName('classes');
  var count = 0;
  for (i = 0; i < canzahl.length; i++) {
    if (canzahl[i].checked)
      count++;
  }
  document.getElementById('mklaasen').innerHTML = count;
}
/*Ausgabe*/
function ausgabe() {
  document.getElementById('Ausgabe').innerHTML =
    cname();
};
/*Checkbox*/
input[type="checkbox"] {
  display: none;
}

/*Checkbox*/
.classes:not(checked)+label:before {
  content: " ";
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid black;
  border-radius: 3px;
  margin-right: 5px;
}

/*Checkbox*/
.classes:checked+label:before {
  background-color: black;
}
<input class="classes" type="checkbox" value="text" id="cclass" name="class">
BI15b
<input class="classes" type="checkbox" value="text" id="bclass" name="class">
BI16b
<input class="classes" type="checkbox" value="text" id="dclass" name="class">
BI17b
<input class="classes" type="checkbox" value="text" id="eclass" name="class">
BI18b

<input id="Ausgabe" class="ausgabe" value="Submit" type="button" onclick="ausgabe();">

Markierte Klassen:


text:
Q: ListView извлечение данных Застопорился на элементе ListView.
Имеется код:
<ScrollViewer
ScrollViewer.HorizontalScrollBarVisibility="Visible"
Margin="755,170,10,380">
  <Grid>
    <ListView Name="CoreSystem" Margin="0,0,0,0"
    SelectedItem="Core1"
    SelectionChanged="CoreSystemChanged">
      <ListView.View>
        <GridView>
          <GridView.Columns>
            <GridViewColumn Header="Core 1" Width="60" DisplayMemberBinding="{Binding Path=Core1}"/>
            <GridViewColumn Header="Core 2" Width="60" DisplayMemberBinding="{Binding Path=Core2}"/>
          </GridView.Columns>
        </GridView>
     </ListView.View>
   </ListView>
  </Grid>
</ScrollViewer>

Данный ListView связан с БД. Обновление происходит при входе в программу:
private void DataBase_loaded(object sender, RoutedEventArgs e)
{
  var context = new CoreContainer();
  context.SystemN.Load();
  CoreSystem.ItemsSource = context.SystemN.Local.ToBindingList();
}

У ListView есть событие: CoreSystemChanged (см.выше)
Что нужно записать в обработчик чтобы при выделении отображалось Значение Core 1? У других контролов выделение активного значения довольно просто:
string comboBox = ComboboxItem.SelectedItem.ToString()

с последующим применением MessageBox.Show. но почему то с ListView не работает.


text:
Q: Javascript: 'Protected' Scoping How does one implement 'protected variables' in javascript?
var DIM = {
  makeOneDim: function(x) {
    var magic = Math.random();
    return {
      dist: function() {
        return x * magic;
      }
    };
  },
  makeTwoDim: function(x,y) {
    var o = DIM.makeOneDim(x);
    o.dist = function() {
      magic *= Math.random();
      return Math.sqrt(x*x+y*y) * magic;
      // !! cant access 'private' variable magic !!
    }
    return o;
  }
};
var o = DIM.makeOneDim(123);
var oo = DIM.makeTwoDim(1,2);
console.log(o.dist() + oo.dist());

I know in this example it would be possible to make a 'public getter', but i would still want to mutate the magic variable from within makeTwoDim's scope and hide it from its instances.
It would also be nice if I could somehow prevent recreating the dist functions on each creation of an instance.

A: There are a lot of ways you could engineer this, but the simplest would be to just keep the functions together:
var DIM = {
  makeOneDim: function(x) {
    var magic = Math.random();
    var dist = function() {
      return x * magic;
    };

    var dist2 = function(y, y) {
      magic *= Math.random();
      return Math.sqrt(x*x+y*y) * magic;
    };

    return {
      dist : dist,
      dist2 : dist2,
    };
  }
};

(and, did you really mean to change the value of magic with each call?)

A: Does this suit your needs? It uses a revealing module pattern to make magic private and return the functions. As such there is no need to call makeOneDim from makeTwoDim.
var DIM = (function () {

  var magic = Math.random();

  function makeOneDim(x) {
    return {
      dist: function() {
        return x * magic;
      }
    };
  }

  function makeTwoDim(x, y) {
    return {
      dist: function() {
        magic *= Math.random();
        return Math.sqrt(x * x + y * y) * magic;
      }
    }
  }

  return {
    makeOneDim: makeOneDim,
    makeTwoDim: makeTwoDim
  }

});

var o = DIM().makeOneDim(123);
var oo = DIM().makeTwoDim(1,2);

DEMO

A: You should be able to determine the value of magic within makeTwoDim by dividing o.dist() by x
var o = DIM.makeOneDim(x);
var magic = o.dist() / x;
console.log(magic)

A: You need to make environment with scope function.
The jQuery way :
var myClass;

(function () {
    var a = 0; // private var

    function protect_function() {
        //...
    }

    window.myClass = {
        public_function: function () { }
    };
})();

A: I know I'm likely to collect rotten tomatoes, but I'd like to say that I disagree with the use of "protected" or "private" variables in the scope of JavaScript OOP. There are no builtin safeguards in JavaScript, developpers are doomed to be better than the others, that's it :-D Don't try to mimic Java, just take it as an opportunity to improve your programming skills. Thus, this code looks perfect to me:
AClass = function () {
  // `rdm` should never change
  this.rdm = Math.random();
};


text:
Q: Jquery Datepicker : Never show the day selection "ui-datepicker-calendar" I need a datepicker to never show the day section.
I want to thus destroy/remove this element : "ui-datepicker-calendar"
It must never show. I want to only use the date and year selection.
The best place it seems is to look at "beforeShow"
$("#datepicker").datepicker({ dateFormat: 'dd/mm/yy', beforeShow: myFunction});

function myFunction(input,inst)
{
    alert(inst);
    $(".ui-datepicker-calendar").remove();
   //$(".ui-datepicker-calendar").destroy(); //this causes infinite loop
}

It this possible?
http://jsfiddle.net/UEnqL/9/
I have tried "destroy", "hide" it just comes back on the next click.

A: $("#datepicker").focus(function(){
    $(".ui-datepicker-calendar").remove()
})

Use the above code to remove the "ui-datepicker-calendar" section.


text:
Q: What does "opening a connection" actually mean? I was trying to explain to someone why database connections implement IDisposable, when I realized I don't really know what "opening a connection" actually mean.
So my question is - What does c# practically do when it opens a connection?
Thank you.

A: Good question.
From my (somewhat limited knowledge) of the "under-the-hood" working of a SQL Connection, many steps are involved, such as:
The Steps Under the Hood

*

*Physical socket/pipe is opened (using given drivers, eg ODBC)

*Handshake with SQL Server

*Connection string/credentials negotiated

*Transaction scoping

Not to mention connection pooling, i believe there is some kind of alogrithm involved (if the connection string matches one for an already existing pool, the connection is added to the pool, otherwise new one is created)
IDiposable
With regards to SQL Connections, we implement IDisposable so that when we call dispose (either via the using directive, or explicity), it places the connection back into the connection pool. This is in stark contrast with just the plain old sqlConnection.Close() - as all this does is close it temporarily, but reserves that connection for later use.
From my understanding, .Close() closes the connection to the database, whereas .Dispose() calls .Close(), and then releases unmanaged resources.
Those points in mind, at the very least it is good practice to implement IDisposable.

A: There are actually two classes involved in implementing a connection (actually more, but I'm simplifying).
One of these is the IDbConnection implementation (SQLConnection, NpgsqlConnection, OracleConnection, etc.) that you use in your code. The other is a "real" connection object that is internal to the assembly, and not visible to your code. We'll call this "RealConnection" for now, though its actual name differs with different implementations (e.g. in Npgsql, which is the case where I'm most familiar with the implementation, the class is called NpgsqlConnector).
When you create your IDbConnection, it does not have a RealConnection. Any attempt to do something with the database will fail. When you Open() it then the following happens:

*

*If pooling is enabled, and there is a RealConnection in the pool, deque it and make it the RealConnection for the IDbConnection.

*If pooling is enabled, and the total number of RealConnection objects in existence is larger than the maximum size, throw an exception.

*Otherwise create a new RealConnection. Initialise it, which will involve opening some sort of network connection (e.g. TCP/IP) or file handle (for something like Access), go through the database's protocol for hand-shaking (varies with database type) and authorise the connection. This then becomes the RealConnection for the IDbConnection.

Operations carried out on the IDbConnection are turned into operations the RealConnection does on its network connection (or whatever). The results are turned into objects implementing IDataReader and so on so as to give a consistent interface for your programming.
If a IDataReader was created with CommandBehavior.CloseConnection, then that datareader obtains "ownership" of the RealConnection.
When you call Close() then one of the following happens:

*

*If pooling, and if the pool isn't full, then the object is put in the queue for use with later operations.

*Otherwise the RealConnection will carry out any protocol-defined procedures for ending the connection (signalling to the database that the connection is going to shut down) and closes the network connection etc. The object can then fall out of scope and become available for garbage collection.

The exception would be if the CommandBehavior.CloseConnection case happened, in which case it's Close() or Dispose() being called on the IDataReader that triggers this.
If you call Dispose() then the same thing happens as per Close(). The difference is that Dispose() is considered as "clean-up" and can work with using, while Close() might be used in the middle of lifetime, and followed by a later Open().
Because of the use of the RealConnection object and the fact that they are pooled, opening and closing connections changes from being something relatively heavy to relatively light. Hence rather than it being important to keep connections open for a long time to avoid the overhead of opening them, it becomes important to keep them open for as short a time as possible, since the RealConnection deals with the overhead for you, and the more rapidly you use them, the more efficiently the pooled connections get shared between uses.
Note also, that it's okay to Dispose() an IDbConnection that you have already called Close() on (it's a rule that it should always be safe to call Dispose(), whatever the state, indeed even if it was already called). Hence if you were manually calling Close() it would still be good to have the connection in a using block, to catch cases where exceptions happen before the call to Close(). The only exception is where you actually want the connection to stay open; say you were returning an IDataReader created with CommandBehavior.CloseConnection, in which case you don't dispose the IDbConnection, but do dispose the reader.
Should you fail to dispose the connection, then the RealConnection will not be returned to the pool for reuse, or go through its shut-down procedure. Either the pool will reach its limit, or the number of underlying connections will increase to the point of damaging performance and blocking more from being created. Eventually the finaliser on RealConnection may be called and lead to this being fixed, but finalisation only reduces the damage and can't be depended upon. (The IDbConnection doesn't need a finaliser, as it's the RealConnection that holds the unmanaged resource and/or needs to do the shut-down).
It's also reasonable to assume that there is some other requirement for disposal unique to the implementation of the IDbConnection beyond this, and it should still be disposed of even if analysing the above leads you to believe its not necessary (the exception is when CommandBehavior.CloseConnection passes all disposal burden to the IDataReader, but then it is just as important to dispose that reader).

A: Adding to answers above...  The key is that upon "opening the connection" resources may be allocated that will take more than standard garbage collection to recover, namely an open socket/pipe/IPC of somekind.  The Dispose() method cleans these up.


text:
Q: Python Pandas how to speed up the __init__ class function correctly with numba? I have a class that does different mathematical calculations on a cycle
I want to speed up its processing with Numba
And now I'm trying to apply Namba to init functions
The class itself and its init function looks like this:
class Generic(object):
    #@numba.vectorize
    def __init__(self, N, N1, S1, S2):
        A = [['Time'],['Time','Price'], ["Time", 'Qty'], ['Time', 'Open_interest'], ['Time','Operation','Quantity']]
        self.table = pd.DataFrame(pd.read_csv('Datasets\\RobotMath\\table_OI.csv'))
        self.Reader()
        for a in A:
            if 'Time' in a:
                self.df = pd.DataFrame(pd.read_csv(Ex2_Csv, usecols=a, parse_dates=[0]))
                self.df['Time'] = self.df['Time'].dt.floor("S", 0)
                self.df['Time'] = pd.to_datetime(self.df['Time']).dt.time
                if a == ['Time']:
                    self.Tik()
                elif a == ['Time','Price']:
                    self.Poc()
                    self.Pmm()
                    self.SredPrice()
                    self.Delta_Ema(N, N1)
                    self.Comulative(S1, S2)
                    self.M()
                elif a == ["Time", 'Qty']:
                    self.Volume()
                elif a == ['Time', 'Open_interest']:
                    self.Open_intrest()
                elif a == ['Time','Operation','Quantity']:
                    self.D()
                    #self.Dataset()
                else:
                    print('Something went wrong', f"Set Error: {0} ".format(a))

All functions of the class are ordinary column calculations using Pandas.
Here are two of them for example:
    def Tik(self):
        df2 = self.df.groupby('Time').value_counts(ascending=False)
        df2.to_csv('Datasets\\RobotMath\\Tik.csv', )

    def Poc(self):
        g = self.df.groupby('Time', sort=False)
        out = (g.last()-g.first()).reset_index()
        out.to_csv('Datasets\\RobotMath\\Poc.csv', index=False)

I tried to use Numba in different ways, but I got an error everywhere.
Is it possible to speed up exactly the init function? Or do I need to look for another way and I can 't do without rewriting the class ?

A: So there's nothing special or magical about the init function, at run time, it's just another function like any other.
In terms of performance, your class is doing quite a lot here - it might be worth breaking down the timings of each component first to establish where your performance hang-ups lie.
For example, just reading in the files might be responsible for a fair amount of that time, and for Ex2_Csv you repeatedly do that within a loop, which is likely to be sub-optimal depending on the volume of data you're dealing with, but before targeting a resolution (like Numba for example) it'd be prudent to identify which aspect of the code is performing within expectations.
You can gather that information in a number of ways, but the simplest might be to add in some tagged print statements that emit the elapsed time since the last print statement.
e.g.
start = datetime.datetime.now()
print("starting", start)

## some block of code that does XXX

XXX_finish = datetime.datetime.now()
print("XXX_finished at", XXX_finish, "taking", XXX_finish-start)

## and repeat to generate a runtime report showing timings for each block of code

Then you can break the runtime of your program down into feature-aligned chunks, then when tweaking you'll be able to directly see the effect. Profiling the runtime of your code like this can really help when making performance tweaks, and it helps sharpen focus on what tweaks are benefiting/harming specific areas of your code.
For example, in the section that's performing the group-bys, with some timestamp outputs before and after you can compare running it with the numba turned on, and then again with it turned off.
From there, with a little careful debugging, sensible logging of times and a bit of old-fashioned sleuthing (I tend to jot these kinds of things down with paper and pencil) you (and if you share your findings, we) ought to be in a better position to answer your question more precisely.


text: Q: Liferay not creating tables in phpmyadmin Database I've just created a brand new phpmyadmin  Liferay Database. The database is empty and I'm trying to have Liferay populate it with the proper tables on Tomcat's startup.


text:
Q: pip install urllib2 #failed I am trying to install urllib2 in cmd console to import it from python 3.5.
I am getting this error:
pip install urllib2

Failed building wheel for urllib2
Command "c:\anaconda\python.exe -u -c "import setuptools, tokenize;file='C:\Users\NA401134\AppData\Local\Temp\pip-build-7meqhp18\urllib2\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record C:\Users\NA401134\AppData\Local\Temp\pip-it4nmmne-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\NA401134\AppData\Local\Temp\pip-build-7meqhp18\urllib2\

A: urllib2 is a built-in package in Python 2. You don't need to pip install it. Did you mean urllib3?


text:
Q: Reset in dijit.form.FilteringSelect hitting URL in Dojo I have FilteringSelect and dojox.data.QueryReadStore as store.  when i do reset on select filtering drop down it hitting server. dijit.byId("enquirerOrInstitution").reset();. What is the reason behind this and how can we stop it? I Have to use FilteringSelect and not ComboBox. Code as below:

<div id="accountList" dojoType="dojox.data.QueryReadStore" jsId="accountListStore"
                    url="<%=contextPath %>/<%=servlet%>?cmd_search_gcs_account_list=1">

            <select id="gcsAccountNumber" name="gcsAccountNumber" dojoType="dijit.form.FilteringSelect"
                style="width: 250px" searchAttr="accountNumber" autoComplete="false" pageSize="10" store="accountListStore">
</select>

and reset somewhere in JS dijit.byId("gcsAccountNumber").reset();.
At this movement, I see a call to server.

A: This would be an easy way out:
dijit.byId('gcsAccountNumber').removeOption(
       dijit.byId('gcsAccountNumber').getOptions()
);

Test if it does send request to your server.
If it does, the routine of removing inner children of the  DOM Element whould give a fair result. Don't worry about having relationships hanging on the dijit, as it will reset once you update its contents. The real memory is held in your store (which is also attempted reset with .reset() call)
while (node.firstChild) node.removeChild(node.firstChild);


text:
Q: Serialize a strange js object I got a js object, if I use the console.log, the result is like this:
{ title: 'testCase',
  id: '5e41538bbf4a7e93a12925a3e6ca12',
  links:
   [ URLLink {
       link: 'www.google.com' } ]
}

but If I use console.log("sometext" + wireObj);
The result is :

sometext[object Object]

If I use JSON.stringify(), the result will become:
{ title: 'testCase',
  id: '5e41538bbf4a7e93a12925a3e6ca12',
  links:
   [{
       link: 'www.google.com' }]
}

As you can see, the URLLink is missing, I would like to preserve this information as well. Any comments?

A: If what you're trying to do is model links as an array of URLLink objects then maybe you could do it like this:
{ title: 'testCase',
  id: '5e41538bbf4a7e93a12925a3e6ca12',
  links:
   [ {URLLink: {link: 'www.google.com' }},
     {URLLink: {link: 'www.yahoo.com' }} ]
}
Note the curly braces wrapping URLLink and the colon mentioned by @alexandru-ionut-mihai
That would be parsed like below:


text:
Q: Debugging objc4 (532.2) on OS X 10.9 I'm trying to get objc4-532.2 to work on Mavericks.
(First of all, I tried to compile the latest version of objc4 (objc4-551.1).
This fails due os/lock_private.h is missing (objc-os.h). Maybe anyone knows how to solve this issue?)
Back to topic:
To successfully build objc4-532.2 I need to link against the frameworks which are based
on OS X 10.8.
So I configured the Xcode project to use OS X 10.8 SDKs for Base SDK and OS X Deployment Target.
This works, and I can compile and link a simple console based C program (Xcode template).
However when I try to link this program against Foundation and debug it, it miserably fails with the following error:

dyld: Symbol not found: _objc_debug_taggedpointer_mask   Referenced from:
  /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
  Expected in:
  /Users/manu/Library/Developer/Xcode/DerivedData/objc-dtrsexfveobodwdnwlpknyyiekpe/Build/Products/Debug/libobjc.A.dylib
  in
  /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation

The symbol _objc_debug_taggedpointer_mask was first introduced in objc4-551.1 (latest runtime) and all 10.9 Frameworks needs to access this symbol (at least in debug mode).
Example:
$ cd /System/Library/Frameworks/Foundation.framework/Versions/C
$ grep objc_debug_taggedpointer_mask Foundation
Binary file Foundation matches

A Framework based on 10.8 doesn't contain such a symbol.
Since my project is configured to use 10.8 SDKs this error should not occur?!
So, what's the missing point?
Thanks!

A: I solved this problem: the symbol of objc_debug_taggedpointer_mask was imported into runtime after mac os x 10.9, so you need to add the new tags into the 532.2's code to make it compatible with os x 10.9's foundation and other frameworks.
Here is my working directory:

https://github.com/Jeswang/objc4-532.2

A:
(First of all, I tried to compile the latest version of objc4
  (objc4-551.1). This fails due os/lock_private.h is missing
  (objc-os.h). Maybe anyone knows how to solve this issue?)

The best solution I could find is to manually scrape together the header files as described here:
http://www.mulle-kybernetik.com/weblog/2011/how_to_build_libobjc_for_os_x.html
The closest thing to os/lock_private.h that I have found is private/tsd_private.h from the libpthread project:
https://opensource.apple.com/source/libpthread/libpthread-105.40.1/private/tsd_private.h
Edit
I have also found this:
https://github.com/samdmarshall/OSXPrivateSDK