text:
Q: Netbeans lamp php interpereter not working I am following this netbean guide https://netbeans.org/kb/docs/php/configure-php-environment-ubuntu.html#createDocumentRootLocation
But I am stuck at creating the virtual host. I try to do as in the tutorial but there is no <Directory> tags in the "000-default.conf" file. I kept going and ignored that.
I did as in the tutorial and put it in my /home/user/public_html. but now when I run it the php code is not interpreted
If I a2ensite the default I can access virtual host set at /var/www/html and that php is interpreted
There are no errors the php is just not being interpreted, what am I doing wrong here.
Im using:

*

*Ubuntu 18.10 LTS

*PHP 7.2.10-0ubuntu1 (cli)

*Apache/2.4.34

Edit:
My "TestPhp.conf" file:
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /home/jelly/public_html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Edit 2 and answer:
Turned out to be some lines in my "php7.2.conf" file that had to be commented out as the out-commented lines in that file explains. as running PHP scripts in user directories is disabled by default.

A: what is your test script like? if you start with <? try <?php instead.
Also check php.ini for expose_php = false (may hide php form the headers)
If the error persists, include your config and test script, along with any errors in http.log
You need to find a config file which enables php
I only have a Ubuntu, and the files in my installation may vary compared to yours:
Enable PHP engine [php.load]
This is the part that loads the PHP interpreter, and allows you to use php scripts
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

Enable .php file directed to php  [php5.conf]
This is the part tells apache to send *.php (and in this case some other extensions like *.phtml) to the php interpreter
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
    SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
    SetHandler application/x-httpd-php-source
    # Deny access to raw php sources by default
    # To re-enable it's recommended to enable access to the files
    # only in specific virtual host or directory
    Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(p[345]?|t|tml|ps)$">
    Require all denied
</FilesMatch>

EDIT I noticed that you were on UBUNTU as well
use sudo a2enmod and select php in the list
EDIT 2
Note that if you are following a general Guide and not a UBUNTU specific one, you may encounter several issues since the UBUNTU apache config is spread out in several files, as opposed to one big file, which is what you may encounter in other distros


text:
Q: Add timeout to CircleCI build for Xcode I can't quite seem to get my circle.yml file in order to extend the timeout for my iOS tests. I've basically followed their example and things run, but because my tests are slow, it never completes and times out at the 600s mark (default). I need to add the timeout modifer (somewhere) to get this to run to completion. Can someone point me to where the timeout modifier should go to allow this to run longer than 5 minutes.
circle.yml
machine:
  timezone:
    America/Chicago
  xcode:
    version: 8.3

dependencies:
  pre:
    - xcrun instruments -w "iPad Air 2" || true

test:
  override:
    - set -o pipefail &&
      xcodebuild
        CODE_SIGNING_REQUIRED=NO
        CODE_SIGNING_IDENTITY=
        PROVISIONING_PROFILE=
        GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES
        GCC_GENERATE_TEST_COVERAGE_FILES=YES
        -sdk iphonesimulator
        -destination 'platform=iOS Simulator,name=iPad Air 2'
        -workspace Augusta.xcworkspace
        -scheme "Augusta"
        clean build test |
      tee $CIRCLE_ARTIFACTS/xcode_raw.log |
      xcpretty --color --report junit --output $CIRCLE_TEST_REPORTS/xcode/results.xml
    - bash <(curl -s https://codecov.io/bash)

A: I eventually got some feedback from CircleCI on this. They weren't able to answer it completely, but gave me enough to figure it out on my own.
The issue boiled down to having all of the items on their own separate lines. YML doesn't take too kindly to that. It works when you only have 1 line and no modifiers, but breaks down pretty bad when you start adding to it. Putting the command on 1 line and just letting it soft wrap was the key. Here is what I am using and it works just fine.
general:
  branches:
    ignore:
      - /^wip.*/ #ignore wip branches

machine:
  timezone:
    America/Chicago
  xcode:
    version: 8.3

dependencies:
  pre:
    - xcrun instruments -w "iPhone 7" || true

test:
  override:
    - set -o pipefail && xcodebuild CODE_SIGNING_REQUIRED=NO CODE_SIGNING_IDENTITY= PROVISIONING_PROFILE= GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 7' -workspace "Augusta.xcworkspace" -scheme "Augusta" clean build test | tee $CIRCLE_ARTIFACTS/xcode_raw.log | xcpretty --color --report junit --output $CIRCLE_TEST_REPORTS/xcode/results.xml:
       timeout: 3600
    - bash <(curl -s https://codecov.io/bash)

redpajama_set_name: RedPajamaStackExchange


text:
Q: Removing factor $x$ from a number I am required to implement this code function but I have no idea what it is asking for. Can someone explain this to me in simpler terms so that I can try to turn it into code?
Given $x$ and $y$, I need to return $Z$.
The description of the function:
If $x$ can be expressed as $x=qy^n$, then $z = q$ i.e. remove factor $y$ from the number $x$, such that $z$ no longer has $y$ as a factor.
Some example results:
x: 2835, y = 3, result = 35
x: 2357, y = 19, result = 2357
I just need a clearer idea of what they are actually asking for.
Thank you

A: The solution was to simply divide the x value as much as possible by y, and return the final divisible value.
Thank you to the kind souls for helping me out! Point noted on the formatting in future.


text:
Q: dotnet restore file matching My folder structure for a code base looks like this

*

*src

*

*Test

*

*Users.Services

*Users.Services

*Users.Domain

*Users.Infra

Now, if want to restore for only the Users projects and not the Test projects, I cannot get the file matching to work.
I have tried different exclude combinations. This is part of my yaml file, but this doesn't work. It fails with a failed pattern match.
- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    projects: '!src/Test/**/*.csproj;src/**/*.csproj'
    command: restore
    verbosityRestore: Minimal

Any idea of what I am missing ?

A: Please try this:
    - task: DotNetCoreCLI@2
      displayName: Restore
      inputs:
        projects: |
            src/**/*.csproj
            !src/Test/**/*.csproj
        command: restore
        verbosityRestore: Minimal

Here you have link to pattern matching.
And pipe is simply multiline. You will find example here


text:
Q: Bash split large file into smaller files So I want to split up a rather large file into several little ones based on the 8th column. So I wrote this script:
#!/bin/bash
run_command(){
eval ${1}
wait
}
chInput=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "Z" "T" "G" "F" "A" "D" "P")
sampInput=("heyA")

for ((x=0;x<${#chInput[@]};x++));do
com="awk -F'\t' '$8=="${chInput[x]}"' /home/location/"$sampInput"_This_P.txt > "$sampInput"Ch"${chInput[x]}".txt"
run_command "${com}"
done

But it isn't working because of

'$8=="

awk: ==1
awk: ^ syntax error
awk: ==2
awk: ^ syntax error
awk: ==3
awk: ^ syntax error
awk: ==4
awk: ^ syntax error

But just doing
awk -F'\t' '$8==1' /home/location/heyA_This_P.txt > Ch1.txt

from the command line did work
What can I do to fix this problem?

A: The acute problem is the double quotes; $8 will be substituted by something (probably nothing at all) at the time you assign the variable.  You could try to use single quotes with proper escaping, but the real solution would probably be to take a deep breath and start over without having either eval or the Awk script in a variable.
What is the purpose of this pretzel logic, anyway?  You should probably read, and take to heart, the advice in http://mywiki.wooledge.org/BashFAQ/050
Here is a quick attempt at resolving your problem:
#!/bin/bash

chInput=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "Z" "T" "G" "F" "A" "D" "P")
sampInput=("heyA")

for ((x=0;x<${#chInput[@]};x++));do
    awk -F'\t' '$8=="'"${chInput[x]}"'"' /home/location/"$sampInput"_This_P.txt > "$sampInput"Ch"${chInput[x]}".txt
done

Notice in particular the construct for interpolating "${chInput[X]}" into the script (that's really the only thing I changed, actually, apart from removing the variable and the eval stuff).  That's a string in single quotes, adjacent to a string in double quotes, adjacent to a string in single quotes, which evaluate to a single string in Bash.  So 'foo'"bar"'baz' evaluates to foobarbaz and similarly '"foo"' adjacent to "'bar'" evaluates to "foo"'bar'.  Here, '$8=="' adjacent to "${chInput[x]}" adjacent to '"' evaluates to $8=="..." where the stuff in the double quotes is substituted at the time of the assignment.
(You don't really need the array, either; you could just do
for c in "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" \
         "13" "14" "15" "16" "17" "18" "19" "Z" "T" "G" "F" \
         "A" "D" "P"
do
    awk -F'\t' '$8=="'"$c"'"' /home/location/"$sampInput"_This_P.txt > "${sampInput}Ch$c.txt"
done

and be compatible with Classic Bourne shell.)


text:
Q: Debian 7 - Disk lag when copying files I'm hosting multiple game servers on a machine with Debian 7 and after a game server is created, a new game folder is extracted with the game files on it, which involves copying around 2-4 GB, and while the files are being copied, every game server freezes for around 3 seconds or more.
Is there anyway to avoid this lag?
I'm using cfq as the default I/O scheduler, but maybe there is a way to slow down the copying speed so the machine doesn't lag?
Thanks in advice.

A: Depending on the reason for the slowdown, you might be able to use ionice or nice (I/O usage or CPU usage, respectively) to lower the priority of the copy.  This will incidentally slow it down if there is other load that takes priority.


text:
Q: Past progressive's special use The description below is about the special use of past progressive from Practical English Usage:

The past progressive is quite often used with verbs of saying: this gives more relative importance to the following verb - to what is said.
(Ex)  Jack was saying that he still can't find a job.

I don't understand the part of "more relative importance" because there is no explanation about this.

A: In my experience, the construction was saying is most frequently used in a positive response by one person to something said by another, as in:
A: I saw a removal van parked outside the Smith's house this morning.
B: Yes, the postmistress was saying that their house has now been sold.
It would be grammatically correct to write: Yes, the postmistress said...
but using the past progressive both picks up on person A's remark and gives the impression that this continues to be the case - that the house has been sold.
More examples:
A: I know of three people in the village who have gone down with (the) flu.
B: Yes, the doctor was saying that it's a bad year for the flu.
A: I saw the postman with a young woman in the passenger seat of his van.
B: Yes, he was saying that he had to show a new employee the delivery route.


text:
Q: Add a foreign key column to Identity database using code first in ASP.NET MVC5 I would like to extend my AspNetUsers table with a foreign key attribute, CustomerID.
I managed to migrate the ASP.NET Identity Database with our own created database. So the Identity tables and the tables in our own created database, now share the exact same database.
However, I would like to map a relation between AspNetUsers and Customer using code first. How can I do that?

A: Override this in your db context and do something similar but with your Customer:
    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        base.OnModelCreating(modelBuilder);

        var user = modelBuilder.Entity<TUser>()
            .ToTable("AspNetUsers");
        user.HasMany(u => u.Roles).WithRequired().HasForeignKey(ur => ur.UserId);


text:
Q: DBIx::Class example In this example below:
my $rs = $schema->resultset('CD')->search(
{
  'artist.name' => 'Bob Marley'
  'liner_notes.notes' => { 'like', '%some text%' },
},
{
  join     => [qw/ artist liner_notes /],
  order_by => [qw/ artist.name /],
}
);

The DBIx cookbook says that this is the sql that will be generated:
# Equivalent SQL:
# SELECT cd.*, artist.*, liner_notes.* FROM cd
# JOIN artist ON cd.artist = artist.id
# JOIN liner_notes ON cd.id = liner_notes.cd
# WHERE artist.name = 'Bob Marley'
# ORDER BY artist.name

But from the rest of the cookbook, I've been lead to believe that the query would only select cd.*, unless of course prefetch was used like so:
my $rs = $schema->resultset('CD')->search(
{
  'artist.name' => 'Bob Marley'
  'liner_notes.notes' => { 'like', '%some text%' },
},
{
  join     => [qw/ artist liner_notes /],
  order_by => [qw/ artist.name /],
  prefetch => [qw/ artist liner_notes/],
}
);

Below is the statement that leads me to believe this:
[Prefetch] allows you to fetch results from related tables in advance

Can anyone explain to me either what I'm missing here? Or not? Thanks a lot!

A: The Equivalent SQL contradicts the previous section of the cookbook and looks like an error.
Join will use the columns from the joined tables when performing the query and applying the filter and sorting conditions, but it won't return the columns for the joined tables. This means that if you do $cd->artist->name then it will need it to do an additional SELECT artist.* FROM artist WHERE artist.id = ? to get the artist's name each time you call that statement.
Prefetch is used to select all columns from the prefetch tables as well. It is more efficient to use prefetch when you actually need those columns, e.g. so you can do $cd->artist->name without needing it to do the additional query. But if you don't need those columns then you have an unnecessary performance hit for loading up that data.


text:
Q: Does the UP in 1-UP stand for anything? I'm curious.  Is it literally going "1 up" or does it stand for something else?

A: There may be extremely vague meaning behind it, according to Wikipedia.

"1-up" was first seen in multi-player pinball and other arcade games. In these games, "1UP" meant that it was player one's turn. Likewise, "2UP" meant it was player two's turn, and so on. In some cases, arcade games also used this terminology to designate which score was whose. "1UP" followed by a score indicated it was player one's score, for example. It is believed in some circles to be short-hand for "player 1, step up to the machine," since a standard pinball table only has enough space and control mechanisms for one player to operate at a time.

From there, it probably caught on as just "1 more life / try".

A: It's a phrase that originated in pinball machines. There is no hidden meaning as far as I can tell, it's just something someone came up with and caught on, like so many terms.


text:
Q: How to guarantee execution order with Node's stream writer? How can I change this code:
const fs = require('fs');

let list = ['a', 'b', 'c'];
list.forEach(x => {
  console.log('processing ' + x);
  let out_path = x + '.txt';
  let writeStream = fs.createWriteStream(out_path);
  writeStream.write('a lot of stuff will go here', 'utf8');
  writeStream.on('finish', () => {
    console.log(out_path + ' saved');
  });
  writeStream.end();
});

to get this:
processing a
a.txt saved
processing b
b.txt saved
processing c
c.txt saved

instead of this:
processing a
processing b
processing c
a.txt saved
b.txt saved
c.txt saved

?
It works fine if I were building an object in the forEach loop and then writing each object to file using fs.writeFile... but I can't do that, because I'm writing huge amounts of data (GBs) and would soon reach the heap's limit.

A: Use async await
(async () => {
  const fs = require('fs');

  let list = ['a', 'b', 'c'];
  for (let x of list) {
    console.log('processing ' + x);
    let out_path = x + '.txt';
    let writeStream = fs.createWriteStream(out_path);
    writeStream.write('a lot of stuff will go here', 'utf8');
    writeStream.end();
    await new Promise(resolve => {
      writeStream.on('finish', () => {
        console.log(out_path + ' saved');
        resolve();
      });
    })
  }
})();


text:
Q: Cannot resolve symbol ActionBarActivity in Android studio 3.0.1 I can't resolve symbol and so I'm getting loads of other errors. Please help, I have seen that early versions or Android had this problem is don't know what's the problem now?

A: ActionbarActivity has been deprecated since Android Support Library version 22.1.0, released in April 2015.
Use AppCompatActivity instead.
Credit to this answer.


text:
Q: Normal form of a vector field in $\mathbb {R}^2$ Edited after considering the comments
Problem: What is the normal form of the vector field:
$$\dot x_1=x_1+x_2^2$$
$$\dot x_2=2x_2+x_1^2$$
Solution: The eugine values of the matrix of the linearised around $(0,0)$ system are $2$ and $1$. We, therefore, have the only resonance $2=2\dot{}1+0\dot{} 2$. The resonant vector-monome is $(0,x_1^2)$. The normal form is then
$$\dot x_1=x_1$$
$$\dot x_2=2x_2+cx_1^2$$
Question: I believe this is correct, is it not?

A: I would use $y$ instead of $x$ in the normal form, since these are not the same variables. Otherwise, what you did is correct. (I don't know if the problem required the identification of  a transformation between $x$ and $y$.)


text:
Q: Failed to generate endpoints api with maven using Multiclass API - Java Inheritance I based my endpoint classes from this example
@Api(name = "tictactoe", version = "v1")
class TicTacToeBase { … }

// TicTacToeA and TicTacToeB both behave as if they have the same @Api annotation as
// TicTacToeBase
class TicTacToeA extends TicTacToeBase { … }
class TicTacToeB extends TicTacToeBase { … }

Endpoints works perfectly with android studio's gradle.
but when I move the source files to my maven-structured project it doesn't recognized TicTacToeA  & TicTacToeB as endpoints classes. I've tried to use just simple annotated Endpoint class and it works.
web.xml contents from gradle-structured project is also copied to maven-structured project.
I noticed from target folder of maven-structured project that web.xml was generated but this time only with
<param-value>com.sample.TicTacToeBase</param-value>
shouldn't it be
<param-value>com.sample.TicTacToeA,com.sample.TicTacToeB</param-value>?

A: You are right! Each API needs to be declared in the web.xml file. Normally you can do this in the file src/main/webapp/WEB-INF/web.xml. (the web.xml file in the target folder is just a copy)
For example, you have a class TicTacToeAPI with annotations which define your API and two subclasses which extend this one.
TicTacToeAPI
@Api(name = "tictactoe",
    canonicalName = "TicTacToe API",
    version = "v1",
    title = "TicTacToe Client API",
    description = "TicTacToe Client API.",
    namespace = @ApiNamespace(
            ownerName = "tictactoe.com",
            ownerDomain = "tictactoe.com")
)
public class TicTacToeAPI {
    // ...
}

TicTacToeA & TicTacToeB
public class TicTacToeA extends TicTacToeAPI {
    // Exposes some methods using annotations.
}

public class TicTacToeB extends TicTacToeAPI {
    // Exposes some methods using annotations.
}

In your web.xml file, you cannot declare only the top level class. All subclasses have to be defined.
web.xml
<web-app>
    ...

    <!--Google Cloud Endpoint-->
    <servlet>
        <servlet-name>SystemServiceServlet</servlet-name>
        <servlet-class>
            com.google.api.server.spi.SystemServiceServlet
        </servlet-class>
        <init-param>
            <param-name>services</param-name>
            <param-value>
                com.sample.TicTacToeA,
                com.sample.TicTacToeB
            </param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>SystemServiceServlet</servlet-name>
        <url-pattern>/_ah/spi/*</url-pattern>
    </servlet-mapping>

    ...
</web-app>


text:
Q: Show Firebase notification only if user wants it to I've set an option via SharedPreferences to show notifications only if the user wants it to. How can I implement this? Thanks.
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
    Log.i("FIREBASE", remoteMessage.getNotification().getBody());
    if (ALLOW_NOTIFICATIONS){
        //show notification
    }
    else {
        //do nothing
    }
}

A: I think you can't handle on your application, because it handled automatically by Firebase SDK.
So the tricky way that you can use is using send topic on firebase.
for example if user want to receive notification just subscribe the topic with this code :
FirebaseMessaging.getInstance().subscribeToTopic("AllowNotification");
and if user won't to receive the notif jus unsubscribe it.
FirebaseMessaging.getInstance().unsubscribeFromTopic("AllowNotification");


text:
Q: Uncaught TypeError: Illegal invocation with new FormData() through ajax I have a form:
<form id="myForm" method="post" onsubmit="return ajaxSubmit();">
...
</form>

On submit is called an ajax request:
data = $('#myForm').serialize();
$.ajax({
    type: 'post',
    url: 'phpFile.php',
    data: data,
    response: 'text',
    async: true,
    success: function (result) {
        console.log(result)
        $('#element').html(result['products']);
    }
})

The result in console log is:
{"ok":1,"products":"<\/span>\n<select id=\"productName\" name=\"productId\">\n        <option value=\"37\">osrieu<\/option>\n    <\/select>"}

So the key "products" in this json is a result of a Twig_Environment->render('htmlFile.html',['placeholder' => $variable]). In this case everything renders fine.
But the problems begins if i change the data variable to this:
data = new FormData($('#myForm'));

After this in the console log i get this:
Uncaught TypeError: Illegal invocation
jQuery.param.add @ jquery.js:7499
buildParams @ jquery.js:7551
jQuery.param @ jquery.js:7519
jQuery.extend.ajax @ jquery.js:8021
ajaxAdminPanelSubmit @ jsFile.js:66
onsubmit @ phpFile.php:84

Then a redirect to a blank page, and in the redirected page all i see is the same json:
{"ok":1,"products":"<\/span>\n<select id=\"productName\" name=\"productId\">\n        <option value=\"37\">osrieu<\/option>\n    <\/select>"}

My question is – why Uncaught TypeError: Illegal invocation occurs in this case?
Could this be fixed? And why it happens?


text:
Q: How to setup a debugger in QtCreator? I don't have a debugger. When I click on debug, a window pops up stating "no debugger set up". I don't have any idea how to fix it so I need step-by-step instructions for dummies. If need be, a download link would be very useful(x64).

A: MingW
Install MingW when installing Qt, and it gets everything in the paths correctly.
MSVC 2010
Install the tool chain through Visual Studio or Visual Studio Express and then hunt down where the debugger gets installed to.  Qt may be able to auto detect it, if it was already installed before you install Qt Creator.
The Qt Creator documentation is pretty good, too.
http://qt-project.org/doc/qtcreator-3.2/creator-debugger-engines.html#installing-native-debuggers


text:
Q: Mongo DB $near query in c#? var query ="{'Geo':{'$near': {'$geometry': {'type': 'Point' ,'coordinates':[]} }}}";
var parsing = BsonDocument.Parse(query);
var qwithcoor = parsing["Geo"]["$near"]["$geometry"]["coordinates"].AsBsonArray;
qwithcoor.AddRange(coordinates);
parsing["Geo"]["$near"].AsBsonDocument.Add("$maxDistance", radius);

var collection = database.GetCollection<BsonDocument>("mycollection");
var documents = await collection.Find(parsing).ToListAsync();

I want to do this with Builders<BsonDocument>.Filter. Like this:
var query=Builders<BsonDocument>.Filter.Near();
var documents=await collection.Find(query).ToListAsync();

do I use Near after the Filter? What are the Near parameters?

A: I solve this with
var gp =new GeoJsonPoint<GeoJson2DGeographicCoordinates>(new GeoJson2DGeographicCoordinates(coordinates[0], coordinates[1]));
var query=Builders<BsonDocument>.Filter.Near("Geo",gp,radius);
var result = await col.Find(query).ToListAsync();


text:
Q: Print Table from DataBase in Clojure my goal is to print my Table as close with even spaces between each col.
(defn PrintTable [tableName]
  "prints table in clear format"
  (let [tableRef (get (deref dataBase) tableName) ; get refrence for table
        keyList (keys @tableRef)] ; get key list of table
    (doseq [tableKeys (range (count keyList))] ; print the keys of the table
      (let [key (nth (keys @tableRef) tableKeys)]
        (print key "\t|"))
    )
    (println)
    (doseq [rows (range (count @(tableRef (nth (keys @tableRef) 0))))] ; print for each rows all the values
      (doseq [cols (range (count keyList))]
        (let [key (nth (keys @tableRef) cols)]
          (print (@(tableRef key) rows) "\t|")
        )
      )
      (println)
    )
  )
  (println)
)

i have tried using tab however this is the out come i get:
P_Id    |LastName   |FirstName  |Address    |City   |
1   |Darmon     |Gilad  |ishayahu   |Haifa  |
2   |SM     |Shiran     |erez   |RamatIshay     |

D_Id    |Name   |OwnerLastName  |OwnerFirstName     |
a   |Bono   |Darmon     |Gilad  |
b   |Bony   |SM     |Shiran     |

any suggestion for a nicer and aligned print?

A: use format to make the cols line up:
user> (println (format "%20s %20s %20s\n%20s %20s %20s"
                 "short" "medium" "reallylong"
                 "reallylong" "medium" "short"))

               short               medium           reallylong
          reallylong               medium                short
nil
user>

or left justify with %-20s
user> (println (format "%-20s %-20s %-20s\n%-20s %-20s %-20s"
                        "short" "medium" "reallylong"
                        "reallylong" "medium" "short"))

short                medium               reallylong
reallylong           medium               short
nil
user>

A: This might be helpful:
http://clojuredocs.org/clojure_core/clojure.pprint/print-table
Alpha - subject to change.
Prints a collection of maps in a textual table. Prints table headings
ks, and then a line of output for each row, corresponding to the keys
in ks. If ks are not specified, use the keys of the first item in rows.

A: (defn print-table [res]
  (let [headers (map name (keys (first res)))
        table (concat [headers] (map vals res))
        trans-table (apply map vector table)
        cols-width (map #(apply max (map (comp count str) %))
                        trans-table)]
    (doseq [row table]
      (println
       (apply format
              (str "|" (apply str (str/join "|" (map #(str "%-" % "s")
                                                     cols-width)))
                   "|")
              row)))))

(print-table res)
=> |P_Id|LastName|FirstName|Address |City      |
   |1   |Darmon  |Gilad    |ishayahu|Haifa     |
   |2   |SM      |Shiran   |erez    |RamatIshay|

A: I am used to print-table with with-out-str
user=> (def res [{:P_Id 1 :LastName "Darmon" :FirstName "Gilad"} {:P_Id 2 :LastName "SM" :FirstName "Shiran"}])
#'user/res
user=> (printf "res=%s" (with-out-str (clojure.pprint/print-table res)))
res=
| :P_Id | :LastName | :FirstName |
|-------+-----------+------------|
|     1 |    Darmon |      Gilad |
|     2 |        SM |     Shiran |
nil


text:
Q: Ramification points and Weierstrass points This is question 7.4.7 out of Liu's book:
Let X be a hyperelliptic curve of genus $g \geq 2$ endowed with a separable morphism $f: X \rightarrow \mathbb{P}^1_k$ of degree 2. We can write $K(X) = k(t)[y]$ with a relation $y^2+Q(t)y=P(t)$ .Let $x_0 \in X(k)$ and assume that $x_0$ is a Weierstrass point, i.e that $l(2x_0) \geq 2$. We want to show that a Weierstrass point is a ramification point. We know that fixed points of the hyperelliptic involution $\rho$ are ramification points.
The exercise is divided in steps, in a) assume that $x_0$ is not a ramifcation point, then $x'_0 = \rho(x_0)$ is distinct from $x_0$. Now you take $h \in L(2x_0) \setminus k$ , and show that $(h \pm \rho(h))_\infty = 2[x_0]+2[x'_0] = 2 f^\ast [f(x_0)]$. I have no problem with showing this.
In b) you show that you can assume that h is of the form $h=a(t)+b(t)y$ . I can do this without problem. Here is my problem:
c) By considering the degree of $h - \rho(h)$, show that $g \leq 1$.
How can I calculate the degree of $h - \rho(h)$ and how can I from it, conclude that it has genus less than or equal to 1?

A: I think the point $f(x_0)$ is $t=\infty$.
If $f$ is unramified at $x_0$, then $t$ is a parameter at $x_0$ :
$\mathrm{ord}_{x_0}t=1$.
Let $g$ be the genus of $X$. Then $\deg P=2g+1$ or $2g+2$ and $\deg Q\le g+1$.
We have $\sigma(y)=-y-Q$. So $h-\sigma(h)=b(t)(2y+Q(t))$. Now distinguish two cases.

*

*If $k$ has characteristic $2$, then
$$2=\deg b(t)+\deg Q(t)\ge \deg Q(t).$$
As $f$ is unramified above $t=\infty$, and the double cover $f$ around $\infty$ is given by the equation
$$(\frac{y}{t^{g+1}})^2+(\frac{Q(t)}{t^{g+1}})\frac{y}{t^{g+1}}=\frac{P(t)}{t^{2g+2}},$$
we must have $\frac{Q(t)}{t^{g+1}}|_{t=\infty}\ne 0$. This means $\deg Q(t)=g+1$. The above inequality then implies that $g\le 1$.

*If $k$ has characteristic different from $2$. We can choose $Q=0$. Then
$$(\frac{y}{t^{g+1}})^2=\frac{P(t)}{t^{2g+2}}.$$
As $f$ is supposed to be unramified above $\infty$, the RHS must be non-zero at $t=\infty$. In other words, $\deg P(t)=2g+2$ and $y/t^{g+1}$ is regular and invertible at points above $\infty$. So $\mathrm{ord}_{x_0}(y)=g+1$. On the other hands,
$$2=\mathrm{ord}_{x_0}(h-\sigma(h))=\deg b(t)+ \mathrm{ord}_{x_0}(y)\ge g+1.$$
Hence $g\le 1$.


text:
Q: Remove ':hover' CSS behavior from element I have CSS that changes formatting when you hover over an element.

.test:hover { border: 1px solid red; }

blah

In some cases, I don't want to apply CSS on hover. One way would be to just remove the CSS class from the div using jQuery, but that would break other things since I am also using that class to format its child elements.
Is there a way to remove 'hover' css styling from an element?

A: I would use two classes. Keep your test class and add a second class called testhover which you only add to those you want to hover - alongside the test class. This isn't directly what you asked but without more context it feels like the best solution and is possibly the cleanest and simplest way of doing it.
Example:

.test {  border: 0px; }
.testhover:hover {  border: 1px solid red; }

 blah

 blah

 blah

A: One method to do this is to add:
pointer-events: none;

to the element, you want to disable hover on.
(Note: this also disables javascript events on that element too, click events will actually fall through to the element behind ).
Browser Support  ( 98.12% as of Jan 1, 2021 )
This seems to be much cleaner

/**
 * This allows you to disable hover events for any elements
*/
.disabled {
  pointer-events: none;  /* <----------- */
  opacity: 0.2;
}

.button {
  border-radius: 30px;
  padding: 10px 15px;
  border: 2px solid #000;
  color: #FFF;
  background: #2D2D2D;
  text-shadow: 1px 1px 0px #000;
  cursor: pointer;
  display: inline-block;
  margin: 10px;
}

.button-red:hover {
  background: red;
}

.button-green:hover {
  background:green;
}

I'm a red button hover over me

I'm a green button hover over me

I'm a disabled red button

I'm a disabled green button

A: Use the :not pseudo-class to exclude the classes you don't want the hover to apply to:
FIDDLE

 blah

 blah

 blah

.test:not(.nohover):hover {
    border: 1px solid red;
}

This does what you want in one css rule!

A: add a new .css class:
#test.nohover:hover { border: 0 }

and

blah

The more "specific" css rule wins, so this border:0 version will override the generic one specified elsewhere.

A: I also had this problem, my solution was to have an element above the element i dont want a hover effect on:

.no-hover {
  position: relative;
  opacity: 0.65 !important;
  display: inline-block;
}

.no-hover::before {
  content: '';
  background-color: transparent;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 60;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />

<button class="btn btn-primary">hover</button>

  <button class="btn btn-primary ">no hover</button>

A: You want to keep the selector, so adding/removing it won't work.  Instead of writing a hard and fast CSS selectors (or two), perhaps you can just use the original selector to apply new CSS rule to that element based on some criterion:
$(".test").hover(
  if(some evaluation) {
    $(this).css('border':0);
  }
);


text:
Q: Show that the Petersen graph is vertex transitive Show that the Petersen graph is vertex transitive.
This is my first opinion to show that the Petersen graph is vertex transitive :
The vertices of the petersen graph $G$ are labeled with 2-element subsets of {$1,2,3,4,5$} and two vertices are adjacent if and only if their intersection is empty. This is the Kneser graph labelling (1955). So that $S_5$ is contained in Automorphisms and so Graph $G$ is vertex transitive. In fact automorphism of $G$ = $S_5$.
High appreciated if someone can explain it clearly.

A:
Consider the Petersen graph in the image on the left. I have labeled the vertices via sets, i.e., $12$ is $\{1,2\} = \{2,1\}$ and $34$ is $\{3,4\} = \{4,3\}$ et cetera. If you apply the permutation $(1,4,5,2,3)$ to the vertices, you get a clockwise rotation, that is, $(1,4,5,2,3)$ takes $\{1,2\}$ and maps it to $\{4,3\}$ and so on. The cycle notation $(1,4,5,2,3)$ means $1 \mapsto 4$ and $4 \mapsto 5$ and $5 \mapsto 2$ and $2\mapsto 3$ and $3\mapsto 1$. All you have to do now is the following: If you find a permutation which maps the inner $5$ vertices onto the outer $5$ vertices, the you are finished because then you can mix the two permutations to map every vertex onto every other. Still unclear?

A: *

*Show that, for any permutation $\pi$ of the set $\{1,2,3,4,5\},$ there is an isomorphism of the Petersen graph which maps each vertex $\{x,y\}$ to $\{\pi(x),\pi(y)\}.$

*Show that, for any two vertices $\{x,y\}$ and $\{u,v\}$ of the Petersen graph, there is a permutation $\pi$ of $\{1,2,3,4,5\}$ such that $\pi(x)=u$ and $\pi(y)=v.$

*Conclude that the Petersen graph is vertex-transitive.


text:
Q: Cannot remove directory on btrfs There is an object on btrfs file system called "????????? ??????" which probably some improperly deleted or copied temporary file or directory. And which can't be removed with common commands: rm, rm -d:
[root@localhost sessions]# rm -d \?\?\?\?\?\?\?\?\?\ \?\?\?\?\?\?/
rm: cannot remove '????????? ??????/': Directory not empty
[root@localhost sessions]# rm -dr \?\?\?\?\?\?\?\?\?\ \?\?\?\?\?\?/
rm: descend into directory '????????? ??????/'? y
rm: remove directory '????????? ??????/'? y
rm: cannot remove '????????? ??????/': No such file or directory
[root@localhost sessions]# rm \?\?\?\?\?\?\?\?\?\ \?\?\?\?\?\?/
rm: cannot remove '????????? ??????/': Is a directory
[root@localhost sessions]# file \?\?\?\?\?\?\?\?\?\ \?\?\?\?\?\?/
????????? ??????/: directory

How such objects should be deleted?
UPDATE: OS and shell:

Linux 4.0.4-2-ARCH #1 SMP PREEMPT Fri May 22 03:19:32 UTC 2015 i686
  GNU/Linux
GNU bash, version 4.3.39(1)-release (i686-pc-linux-gnu)

UPDATE2:
[root@localhost sessions]# rm -fr \?\?\?\?\?\?\?\?\?\ \?\?\?\?\?\?/
[root@localhost sessions]# ls
????????? ??????   backup-9.session
[root@localhost sessions]# lsattr \?\?\?\?\?\?\?\?\?\ \?\?\?\?\?\?/
[root@localhost sessions]#

UPDATE3:
[root@localhost sessions]# echo $LANG
en_US.UTF-8
[root@localhost sessions]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

UPDATE4:
[root@localhost sessions]# ls -la
ls: ????????? ??????: No such file or directory
total 23760
drwxr-xr-x 1 al users       0 Aug 13  2014 ????????? ??????
drwxr-xr-x 1 al users       0 Jun  7 05:53 .
drwx------ 1 al users       0 Jun  8 05:06 ..
-rw-r--r-- 1 al users  274557 May 24 18:58 backup-11.session

UPDATE5:
[root@localhost sessions]# find . -exec rm -fr {} \;
rm: refusing to remove '.' or '..' directory: skipping '.'
[root@localhost sessions]# ls -la
ls: ????????? ??????: No such file or directory
total 0
drwxr-xr-x 1 al users 0 Aug 13  2014 ????????? ??????
drwxr-xr-x 1 al users 0 Jun  8 17:03 .
drwx------ 1 al users 0 Jun  8 05:06 ..
[root@localhost sessions]#

A: After rebuilding checksums for the whole partition, running scrub and --repair one more time - the garbage filesystem entries are at last gone.

A: Please try to run as follows:
rm -fr <directory>

also check attributes using lsattr, if need be can use chattr to change attributes, see appropriate man pages.


text:
Q: How to compute the MIN, MAX, AVG of all rows in MySQL table I have a MySQL table that contains measurements data. For example:
# name, time
first, 0.0013
second, 0.0015
third, 0.0012
fourth, 0.0019

I want to compute the MAX, MIN and AVG of all rows. So the results of the above example should be:
MIN: 0.0012
MAX: 0.0019
AVG: 0.001475

I am aware of MIN, MAX, and AVG MYSQL functions. But they return the result of a single field. I need aggregated results similar to COUNT function.
EDIT:
It is not necessary for me to get all the 3 functions results in one query. It is fine to have 3 different queries. The main problem is how to aggregate the, say, MAX of all rows as I illustrated in the example.

A: If I understand correctly from our comments I believe this is what you're looking for and should do it in one query.
SELECT
    MIN(time) AS minimum,
    MAX(time) AS maximum,
    AVG(time) AS average
FROM t;

A: You don't mind having it in different queries? Then you can aggregate easily without any hassle.
SELECT MIN(time) AS minimum FROM <tablename>

SELECT MAX(time) AS minimum FROM <tablename>

SELECT AVG(time) AS minimum FROM <tablename>

Edit: This can be summarized without issues into a single query, too.
SELECT MIN(time) AS minimum, MAX(time) AS maximum, AVG(time) AS average FROM <tablename>

I was not aware that multiple columns could be returned while using an aggregator without grouping. Nice special case here. Thanks for clarification by Johan and HoldOffHunger.

A: like this :
  select ROW_NUMBER(), least(first, second, third, fourth) as min,
   greatest(first, second, third, fourth) as max,
  (first+ second+ third+ fourth)/4 as avg
  from table t;

then if you need avg of all rows you can write another query to compute it from this result.


text:
Q: How to get HTTP/2 working in a Kubernetes cluster using ingress-nginx We have a number of services behind an API gateway which is itself behind ingress-nginx. We're trying to use HTTP/2 to speed up data transfer to the front-end but all of our connections are still being done with HTTP/1.1.
The connection from client to nginx is over HTTPS, but nginx communicates with our API gateway using HTTP, and the gateway also uses HTTP to communicate with the backend services.
Do we need to use HTTPS from end-to-end to get HTTP/2 to work? If so, what's the best way to set this up re: using certificates? If not, what could be causing the connection to drop to HTTP/1.1?
We are using ingress-nginx version 0.21.0, which has nginx 1.15.6 and OpenSSL 1.1.1, which should be sufficient to support TLS 1.3/ALPN/HTTP2. Our nginx-configuration configmap has use-http2 set to true and I can see that the pod's /etc/nginx.conf has a listen ... http2; line.

Edit 10/05/2019:
Further to the comments of @Barry Pollard and @Rico, I've found out that AWS Elastic Load Balancer, which sits in front of our ingress-nginx controller, doesn't support HTTP/2. I've cut nginx out of the stack and our API Gateway is being provisioned its own Network Load Balancer. However, we're still on HTTP/1.1. It looks like ASP.Net Core 2.2's HTTP server Kestrel uses HTTP/2 by default, so I'm not sure why the connection is still dropping to 1.1.

A: Like @BarryPollard said you shouldn't need HTTP/2 end to end to establish HTTP/2 connections on your browser.
It sounds like whatever you are using for a client is dropping to HTTP/1.1, make sure you try with one of the following:

*

*Chrome 51

*Firefox 53

*Edge 12

*Internet Explorer 11

*Opera 38

You didn't specify what architecture is fronting your nginx. Is it connected directly to the internet? or it's going through cloud load balancer? CDN? You can also test with Wireshark as described here.


text:
Q: Player Detection System Unity is not very accurate I have written code for player detection system.
I have a boss that will keep looking for the player position and once the player is within a certain sphere collider trigger radius then the player will be detected.
It is done using a raycast and OnTriggerStay and OnTriggerExit.
The problem is that the Player Detection System is not very accurate so sometimes it work , some other times it doesn't. I can't seem to find or understand why.
Here is the part of the code (of interest) I wrote:
 void OnTriggerStay(Collider other)
{
    if (other.gameObject.tag == "player")
    {

        playerDetected = false;

        Vector3 direction = other.transform.position - transform.position;
        float angle = Vector3.Angle(direction, transform.forward);

        Debug.DrawRay(transform.position + transform.up / 2, direction, Color.green);

        if (angle < fieldOfView)
        {

            RaycastHit hit;

            //if (Physics.Raycast(transform.position + transform.up / 2, direction, out hit, col.radius, ignoreRaycast))

            if (Physics.Raycast(transform.position + transform.up / 2, direction,out hit, col.radius))
            {
                if (hit.collider.gameObject.tag == "player")
                {
                    playerDetected = true;
                }
            }
        }
    }
}

void OnTriggerExit(Collider other)
{
    if (other.gameObject.tag == "player")
    {
        playerDetected = false;

    }
}

and this is the full code:
https://pastebin.com/YZH9Fc99
This will show you the behavior (look at the bool tick of PlayerDetected going on and off)
https://gyazo.com/74961847eca520a335d18c194201d0c2

A: So I figured out that the player was holding a sword with a box collider trigger.
When she moves the sword is above the body collider and it couldn't detect it.
It was solved by adding a layer to the player and to ignore everything but the player layer.
add
public LayerMask ignoreRaycast;

Replace
 if (Physics.Raycast(transform.position + transform.up / 2, direction,out hit, col.radius))

by
 if (Physics.Raycast(transform.position + transform.up / 2, direction,out hit, col.radius,ignoreRaycast))

For ignoreRaycast select just player layer


text:
Q: videojs - how to show thumbnails as the progress-slider is moved On YouTube's player, when you hover on progress-bar and traverse your mouse along, you see a series of thumbnails, as well as time-values.  This is great, when you're tying to find a scene that you know of visually, and want its time-value.
Whereas, on videojs player, you see only time-values.
(On X-Finity (Comcast, their fast-forward similarly shows rapid series of thumbnails.  But, googling seems to reveal that Videojs doesn't have fast-forward.  And, I think I'd prefer YouTube's feature over a fast-forward.)
So, bottom-line question is:  How to make Videojs player behave like YouTube's?
(I'm thinking this would be difficult to implement for the end-user, in javascript.  Detecting that the slider is being moved is no doubt straight-forward, but code to display thumbnails would be the part that I have NO IDEA
how to accomplish.)
Anyone know how to program this?

A: BrightCove developed a 'thumbnails' plugin that implements this.
See their example coding here:
    https://support.brightcove.com/display-thumbnail-previews-plugin#Example
There is more specific discussion on the subject in this forum here:
    How to generate video preview thumbnails for use in VideoJS?
My first cut at implementing the notion is here:
    https://weasel.firmfriends.us/Private3-BB/


text:
Q: VB.NET indexof not finding string() Here is my code:
Dim list As New List(Of String)
'populate list with string values

Dim list2 As New List(Of String())

    For i As Integer = 0 To list.Count - 1
        list2.Add({list.Item(i), "temp"})
    Next

    for x as integer = 0 to list.count
        Dim test1 = list2.indexof({list.item(x), "temp"}) '***this line is returning -1
    next

Although I can clearly see that list2 contains in its first index the strings:
"Garry" and "temp"
it refuses to return an index other than -1 when I search for an index containing:
{"Garry", "temp"}

A: Just ended up restructuring my code as to avoid the problem -- all good now.
I am not sure as to why this wasn't working; if anybody comes looking for a solution.


text:
Q: HTML, CSS - HOVER для элементов из разных блоков Необходимо сделать так, чтобы при наведении на любой из элементов с классом row-1 менялся фон одновременно у всех элементов с классом row-1.
Это маленькая табличка из div-ов.
Задача: при наведении на столбец любую ячейку столбца должен загораться весь столбец.
Возможно ли это?
Подскажите как?

.table-stu {
  display: flex;
  flex-direction: column;
  border: 1px solid black;
  border-radius: 10px;
  max-width: 700px;
}

.row-table-stu {
  display: flex;
}

.row-table-stu div {
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid black;
  width: 100px;
  height: 46px;
  text-align: center;
}

.row-table-stu div:first-child {
  min-width: 100px;
  font-weight: bold;
}

.row-table-stu div:last-child {
  font-weight: bold;
}

.table-stu .row-table-stu:first-child {
  font-weight: bold;
}

.table-stu-price-descr {
  font-size: 12px;
  max-width: 700px;
}

.row-table-stu:first-child div:first-child {
  border-radius: 8px 0 0 0;
}

.row-table-stu:first-child div:last-child {
  border-radius: 0 8px 0 0;
}

.row-table-stu:last-child div:first-child {
  border-radius: 0 0 0 8px;
}

.row-table-stu:last-child div:last-child {
  border-radius: 0 0 8px 0;
}

Lorem1

Lorem2

Lorem3

Lorem1

Lorem2

Lorem3

Lorem1

Lorem2

Lorem3

A: В данной реализации без JavaScript не обойтись. Если реализовывать средствами css, то придется переделать табличку и вместо строк объединять ячейки колонками.
Вариант на jQuery

$('.table-stu').on({
    mouseenter: function () {
      var num = $('.row-table-stu').eq(0).find('.cell').length;

        for (var i = 1; i <= num; i++) {
         if ($(this).hasClass('row-' + i)) {
           $('.row-' + i).addClass('row-hover');
          }
        }
    },
    mouseleave: function () {
        $('.cell').removeClass('row-hover');
    }
}, '.cell');
.table-stu {
    display: flex;
    flex-direction: column;
    border: 1px solid black;
    border-radius: 10px;
    max-width: 700px;
}

.row-table-stu {
    display: flex;
}

.row-table-stu div {
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid black;
    width: 100px;
    height: 46px;
    text-align: center;

}
.row-table-stu div:first-child {
    min-width: 100px;
    font-weight: bold;
}
.row-table-stu div:last-child {
    font-weight: bold;
}
.table-stu .row-table-stu:first-child {
    font-weight: bold;
}
.table-stu-price-descr {
    font-size: 12px;
    max-width: 700px;
}
.row-table-stu:first-child div:first-child {
    border-radius: 8px 0 0 0;
}
.row-table-stu:first-child div:last-child {
    border-radius: 0 8px 0 0;
}
.row-table-stu:last-child div:first-child {
    border-radius: 0 0 0 8px;
}
.row-table-stu:last-child div:last-child {
    border-radius: 0 0 8px 0;
}

.row-hover {
  background-color: #ccc;
}

Lorem

Lorem

Lorem

Lorem

Lorem

Lorem

Lorem

Lorem

Lorem

Вариант на CSS если переделать табличку колонками

.table {
  width: 400px;
  display: flex;
  border: 1px solid #000;
  border-radius: 8px;
  overflow: hidden;
}

.table-col {
  width: 33.33%;
  box-sizing: border-box;
}

.table-col + .table-col {
  border-left: 1px solid #000;
}

.table-col:hover .table-cell {
  background-color: #ccc;
}

.table-cell {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
  font-size: 20px;
  font-weight: bold;
}

.table-cell + .table-cell {
  border-top: 1px solid #000;
}

1

1

1

2

2

2

3

3

3


text:
Q: Trying to create a pattern out of circles? I am trying to imitate a pattern I found on the internet, but I get weird lines in the middle and when trying to connect another set of circles on top.
Also, when I try to fill, it becomes fully black.

console.log("grid");

var canvas = document.getElementById("canvas");
var image_b = document.getElementById("brown");
var image_g = document.getElementById("grey");

canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

var ctx = canvas.getContext("2d");

var side = 160;
var side2 = 150;

ctx.strokeStyle = 'black';
ctx.fillStyle = 'white';

function draw() {

  canvas.width = window.innerWidth;
  canvas.height = window.innerHeight;

  ctx.clearRect(0, 0, window.innerWidth, window.innerHeight);
  var widthNbr = Math.ceil(window.innerWidth / side) + 1;
  var heightNbr = Math.ceil(window.innerHeight / side) + 1;

  var counter = 0;
  for (var i = 0; i < widthNbr; i++) {
    for (var j = 0; j < heightNbr; j++) {

      ctx.beginPath();

      var x = side * i + side / 2;
      var y = side * j + side / 2;

      var a = side * i + side / 2;
      var s = side * j + side / 2;

      var d = side * i + side / 2;
      var f = side * j + side / 2;

      var g = side * i + side / 2;
      var h = side * j + side / 2;

      var q = side * i + side / 2;
      var w = side * j + side / 2;

      var o = side * i + side / 2;
      var p = side * j + side / 2;

      var x1 = side2 * i + side2;
      var y1 = side2 * j + side2;

      var a1 = side2 * i + side2;
      var s1 = side2 * j + side2;

      var d1 = side2 * i + side2;
      var f1 = side2 * j + side2;

      var g1 = side2 * i + side2;
      var h1 = side2 * j + side2;

      var q1 = side2 * i + side2;
      var w1 = side2 * j + side2;

      var o1 = side2 * i + side2;
      var p1 = side2 * j + side2;

      ctx.arc(x, y, side / 2, 0, Math.PI * 2);
      ctx.arc(a, s, side / 2.5, 0, Math.PI * 2);
      ctx.arc(d, f, side / 3.5, 0, Math.PI * 2);
      ctx.arc(g, h, side / 5.3, 0, Math.PI * 2);
      ctx.arc(q, w, side / 9, 0, Math.PI * 2);
      ctx.arc(o, p, side / 18, 0, Math.PI * 2);
      ctx.lineWidth = 5;

      ctx.arc(x1, y1, side2 / 2, 0, Math.PI * 2);
      ctx.arc(a1, s1, side2 / 2.5, 0, Math.PI * 2);
      ctx.arc(d1, f1, side2 / 3.5, 0, Math.PI * 2);
      ctx.arc(g1, h1, side2 / 5.3, 0, Math.PI * 2);
      ctx.arc(q1, w1, side2 / 9, 0, Math.PI * 2);
      ctx.arc(o1, p1, side2 / 18, 0, Math.PI * 2);

      ctx.stroke();
      // ctx.fill();

      ctx.closePath();
      counter++;

    }
  }

}

draw();
<canvas id="canvas"></canvas>

A: You have to think about canvas Path drawings as pencil drawing on a paper :
Just after the path declaration (beginPath), when you say ctx.arc(x, y, rad, 0, Math.PI*2) your pen goes to coordinates (x, y), and because x and y are the center position of your arc it will be putted at a rad distance from this center to draw the circle. Your 0 tells it to start at 3 o'clock, so in this case, we just need to add this rad to the x value.
At this moment, your pen is on the paper.
It draws the arc, and when you tell it arc(x1, y1, rad, ...), it goes directly to coordinates (x1+rad, y1) and draws the new arc.
The problem here is that you never told it to raise the pencil from the paper, so you can see the line that goes from the last point on the first arc to the first point on the next one.
Fortunately, Canvas API comes with a handy set of operations, and the "Raise_the_pen_and_move_to_coordinates_x,y_without_ruining_my_paper" is simply called moveTo.
By telling the context to gently raise the pencil and to move to the next first drawing point, before actually drawing the arc, you'll avoid all these trailing lines.
So basically, for three arcs it would be :
// initialize a new drawing
ctx.beginPath();
// here we can set it directly because the pen is not on the paper yet
ctx.arc(x, y, rad, 0, Math.PI*2);
// tell it to raise the pen off the paper
//  and to go to the next starting point (3 o'clock in our case)
ctx.moveTo(x1 + rad, y1);
ctx.arc(x1, y1, rad, 0, Math.PI*2);
// once again
ctx.moveTo(x2 + rad, y2);
ctx.arc(x2, y2, rad, 0, Math.PI*2);
// now we've got clear independents arcs
ctx.stroke();

And with your code (That you could clean a lot by using arrays btw)

var canvas = document.getElementById("canvas");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;

var ctx = canvas.getContext("2d");

var side = 160;
var side2 = 150;

ctx.strokeStyle = 'black';
ctx.fillStyle = 'white';

function draw() {

  canvas.width = window.innerWidth;
  canvas.height = window.innerHeight;

  ctx.clearRect(0, 0, window.innerWidth, window.innerHeight);
  var widthNbr = Math.ceil(window.innerWidth / side) + 1;
  var heightNbr = Math.ceil(window.innerHeight / side) + 1;

  var counter = 0;
  for (var i = 0; i < widthNbr; i++) {
    for (var j = 0; j < heightNbr; j++) {

      ctx.beginPath();

      var x = side * i + side / 2;
      var y = side * j + side / 2;

      var a = side * i + side / 2;
      var s = side * j + side / 2;

      var d = side * i + side / 2;
      var f = side * j + side / 2;

      var g = side * i + side / 2;
      var h = side * j + side / 2;

      var q = side * i + side / 2;
      var w = side * j + side / 2;

      var o = side * i + side / 2;
      var p = side * j + side / 2;

      var x1 = side2 * i + side2;
      var y1 = side2 * j + side2;

      var a1 = side2 * i + side2;
      var s1 = side2 * j + side2;

      var d1 = side2 * i + side2;
      var f1 = side2 * j + side2;

      var g1 = side2 * i + side2;
      var h1 = side2 * j + side2;

      var q1 = side2 * i + side2;
      var w1 = side2 * j + side2;

      var o1 = side2 * i + side2;
      var p1 = side2 * j + side2;

      ctx.moveTo(x + side / 2, y);
      ctx.arc(x, y, side / 2, 0, Math.PI * 2);
      ctx.moveTo(a + side / 2.5, s);
      ctx.arc(a, s, side / 2.5, 0, Math.PI * 2);
      ctx.moveTo(d + side / 3.5, f)
      ctx.arc(d, f, side / 3.5, 0, Math.PI * 2);
      ctx.moveTo(g + side / 5.3, h)
      ctx.arc(g, h, side / 5.3, 0, Math.PI * 2);
      ctx.moveTo(q + side / 9, w)
      ctx.arc(q, w, side / 9, 0, Math.PI * 2);
      ctx.moveTo(o + side / 18, p)
      ctx.arc(o, p, side / 18, 0, Math.PI * 2);
      ctx.lineWidth = 5;

      ctx.moveTo(x1 + side2 / 2, y1)
      ctx.arc(x1, y1, side2 / 2, 0, Math.PI * 2);
      ctx.moveTo(a1 + side2 / 2.5, s1)
      ctx.arc(a1, s1, side2 / 2.5, 0, Math.PI * 2);
      ctx.moveTo(d1 + side2 / 3.5, f1)
      ctx.arc(d1, f1, side2 / 3.5, 0, Math.PI * 2);
      ctx.moveTo(g1 + side2 / 5.3, h1)
      ctx.arc(g1, h1, side2 / 5.3, 0, Math.PI * 2);
      ctx.moveTo(q1 + side2 / 9, w1)
      ctx.arc(q1, w1, side2 / 9, 0, Math.PI * 2);
      ctx.moveTo(o1 + side2 / 18, p1)
      ctx.arc(o1, p1, side2 / 18, 0, Math.PI * 2);

      ctx.stroke();

      counter++;

    }
  }

}

draw();
<canvas id="canvas"></canvas>

As correctly noted by Spencer Wieczorek in comments above, to get the result you wanted, you'll also have to white-fill the largest arcs, but I let you find the way to do it as a training.

Also, a small note on closePath() that you were using in your code, his name might be quite confusing when we see the number of people misusing it, but note that it doesn't ends your Path declaration. All it does is a lineTo(last_time_I_putted_the_pencil). In the case of closed circle, it doesn't have any effect because last_time_I_putted_the_pencil === current_pencil_position_on_the_paper, but it's often the source of a lot of problems.

And an other small note, for users a bit more experienced (probably OP in few days / weeks) :
Other operations allow us to raise our pencil from the paper : the transformation commands.
(mainly setTransform, and its subsets transform, translate, rotate and scale).
These operations will first raise the pen, and then move the paper rather than the pen. This comes handy in a lot of situations.
And to set it back to its normal position, you just have to call setTransform(1,0,0,1,0,0).

A: As I was far too slow in responding to this question please consider this an addendum to the excellent answer already provided by Kaiido.

When thinking about problems like this it is sometimes useful to separate the calculation of values from their application.  Of course, this kind of understanding only comes with experience, unless that is we can plug into the experience of others - which is exactly what sites like StackOverflow are for! :)
The image we're intending to make is made entirely of circles, so we can greatly reduce  repetition in our code by creating a function that deals with just that one thing for us.  Something like...
/* draw circle */
function drawCircle(x, y, r, LW) {
  context.lineWidth = LW;

  context.beginPath();
  context.arc(x, y, r, 0, Math.PI*2, true);
  context.fill();
  context.stroke();
}

Although this function only draws a single circle to the canvas we can pass it values that can be used to  draw every element we need.
The reference image is built out of sets of circles, where each circle-set has the same (x,y) position.  If we know those starting co-ordinates for X & Y, and the radius of the largest circle in the set, then we can create a function to calculate the values we need and pass them into the drawCircles() function above...
function circleSet(X, Y, Radius) {
  var count = 5; /* number of circles in each set */
  var step = Radius / count;
  var ln_width;
  var rad;

  while (count > 0) {
    ln_width = count > 3 ? 3 : (count > 1 ? 2 : 1);
    rad = count * step;

    drawCircle(X, Y, rad, ln_width);

    count--;
  }
}

The while-loop reduces the count variable from 5 to 1 and line width and radius values are calculated before being passed into the aforementioned drawCircle() function, along with (x,y) co-ordinates.
The conditional in the first line of the while-loop says:

*

*if count is 4 or 5 then ln_width equals 3;

*or else if count is 2 or 3 then ln_width equals 2;

*or else ln_width equals 1.

The rad variable holds a value that starts at Radius and is decreased by 1 x steps for each iteration of the loop.
Now that the circle-set parameters are ready to be calculated all that's needed is to calculate the values to pass to the circleSet() function, that is; the (x,y) co-ordinates and starting radius of each set.
As your original code snippet showed, we can use two nested for-loops for this. one to deal with the vertical and one to deal with the horizontal, but first we need to make some decisions.
If we want to have 10 circle-sets across the canvas then the width of each set would be...
    var circleSet_Size = canvas.width / 10;

...and the maximum radius of each circle-set would therefore be...
    var circleSet_Radius = circleSet_Size / 2;

We also need to draw two lots of circle-sets to make something like the reference image, one lot for the 'background' and one lot for the 'foreground'.  So we need to determine the starting (x,y) co-ordinates of each pass as well as width/height of the area we want to draw over.  We can create a function for that too.  Something like...
function loopXYPosition(startX, startY) {
  for (var y = startY; y < (canvas.height + circleSet_Radius); y += circleSet_Size) {
    for (var x = startX; x < (canvas.width + circleSet_Radius); x += circleSet_Size) {

      circleSet(x, y, setRadius);

    }
  }
}

 /* 'background' pass */
loopXYPosition(0, 0);
/* 'foreground' pass */
loopXYPosition(circleSet_Radius, circleSet_Radius);

With all that in place we can collate our functions into a single script. But before we do that it's worth taking note of those values which need to be calculated each time a function is called and which values remain static once calculated.  Bearing all that in mind we end up with something like...

var circlePattern = (function() {
  /* define variables available
     to all functions */
  var canvas
    , ctx
    , cWidth
    , cHeight
    , circleCount
    , circleSet_Size
    , circleSet_Radius
    , P360;

  /* draw each cicle */
  function drawCircle(x, y, r, LW) {
    ctx.beginPath();
    ctx.lineWidth = LW;
    ctx.arc(x, y, r, 0, P360, true);
    ctx.fill();
    ctx.stroke();
  }

  /* calculate each set of circles (circle-set) */
  function circleSet(X, Y, R) {
    var count = circleCount,
      radiusSteps = R / count,
      ln_width,
      rad;

    while (count > 0) {
      ln_width = count > 3 ? 2.5 : (count > 1 ? 2 : 1.5);
      rad = count * radiusSteps;

      drawCircle(X, Y, rad, ln_width);

      count--;
    }

  }

  function loopXYPosition(startX, startY) {
    /* add circleSet_Radius to canvas width
       and height to make sure we draw right
       up to the edges of the canvas */
    var cHcR = cHeight + circleSet_Radius;
    var cWcR = cWidth + circleSet_Radius;

    /* to get the effect we want we need to create
       a little padding around each circle-set,
       therefore we reduce the circelSet_Radius value
       by 5% before passing to drawCircleSet() */
    var setRadius = circleSet_Radius * 0.95;

    /* step across and down canvas in
       increments of 'circleSet_Size' */
    for (var y = startY; y < cHcR; y += circleSet_Size) {
      for (var x = startX; x < cWcR; x += circleSet_Size) {

        circleSet(x, y, setRadius);

      }
    }

  }

  function begin(NoC, cCount) {
    var numberOfCircles = NoC;

    /* set variables needed later */
    circleSet_Size = cWidth / numberOfCircles;
    circleSet_Radius = circleSet_Size / 2;
    circleCount = cCount;

    /* draw rows of circles */
    loopXYPosition(0, 0);
    loopXYPosition(circleSet_Radius, circleSet_Radius);
  }

  /* initialise canvas */
  function init(e) {
    /* Set variables to use later */
    canvas = document.getElementById('canvas');
    ctx = canvas.getContext('2d');

    cWidth = canvas.width;
    cHeight = canvas.height;

    P360 = Math.PI * 2;

    /* fillStyle & strokeStyle are properties
       of the Canvas, so we only need to set
       them once here */
    ctx.fillStyle = '#fff';
    ctx.strokeStyle = '#000';

    /* fill canvas (background) */
    ctx.fillRect(0, 0, cWidth, cHeight);

    /* first argument: number of horizontal circle-sets
       second argument: number of circles in each set
       !Try different values here! */
    begin(7, 6);
  }

  return {
    go: init
  };
}());

window.onload = circlePattern.go;
body {
    color:#000;
    background-color:#fff;
    font-family:sans-serif;
}
div.box {
    width:100%;
    height:auto;
    text-align:center;
    margin:2em auto;
    display:block;
}
div.box h3 {
    font-size:1.3em;
    line-height:2.3em;
}
#refimg, #canvas {
    width:600px;
    margin:0 auto;
    clear:both;
    display:block;
}
#refimg {
    height:360px;
}
#canvas {
    height:400px;
}

Refernece Image

Canvas Image

    <canvas id="canvas" width="600" height="400" title="Canvas image"></canvas>

Not exactly the same results, though pretty close. With the exception of the (x,y) co-ordinates which pass through it the circleSet() function produces the same sequence of values each time it is called, so those values could be calculated once and stored in an Object, but I've included it here for simplicity and to highlight the sequence of events.
Feeding different values into the begin() function and playing with setRadius in the loopXYPosition() function yields some interesting results.
I hope the process outlined here gives you some hints in your continuing exploration of the HTML5 Canvas API.
;)


text:
Q: Firebase .indexOn, how can i make sure this index is unique I have the following data structure:
{"applicants":[
{
"-KNbKoNzPGsz2TAQp-j9" : {
"email" : "zahavi@post.tau.ac.il",
"id" : "056042344",
"name" : "Jacob",
"prefix" : "Prof.",
"surname" : "Zahavi"
},
"-KNbWPpsrFGJBDaWK2EN" : {
"email" : "chamud@gmail.com",
"id" : "314965211",
"name" : "Ilay",
"prefix" : "Mr.",
"surname" : "Shvo"
},
"-KNd8HvkzAYi0LtG9qNj" : {
"email" : "zahavi@zpost.tau.ac.il",
"id" : "056042344",
"name" : "Jacob",
"prefix" : "Prof.",
"surname" : "Zahavi"
}]
}
}

I would like to enforce uniqueness rule on the field id, so it will not be possible to create two entries in applicants collection that has the same id value.
currently my rules are:
{
"rules": {
".read": true,
".write": true,
  "Tables":{"applicants":{"id":{".indexOn":".value"}}}
}
}

I explored two possible solutions that are:
1. transaction. unfortunately i did not find a way to run transaction from a query.
2. rules. but failed to find something suitable.
Edit (from comments):
I tried the following rules:
{
    "rules": {
        ".read": true,
        ".write": true,
        "Tables": {
            "applicants": {
                "$app": {
                    "id": {
                        ".indexOn": ".value",
                        ".validate": "!root.child('Tables').child('applicants').child(newData.child('id').val()).exists()"
                    },
                }
            }
        }
    }
}

and I always got creation failed permission denied even for values that were not exist


text:
Q: is it possible to change column datatype to SET in mysql? i downloaded imdb database and while i was able to import it into mysql, i coulden't put the genre column datatype to "SET", even tho imdb only has 21 genre's for movies, when i imported the data i set the genre data type to VARCHAR(255), and i can not change it to SET, is it possible?
here's what i tried:
ALTER TABLE movies
MODIFY genre SET('Drama', 'Comedy', 'Action', 'Crime', 'Romance', 'Thriller', 'Adventure', 'Horror', 'Mystery', 'Fantasy', 'Sci-Fi', 'Biography', 'Family', 'Animation', 'Music', 'History', 'War', 'Sport', 'Musical', 'Western', 'Film-Noir') NOT NULL;
and i get the error code 1265 "Data truncated for column 'genre' at row 2", I'm guessing that's because row 2 has more than only one genre, but i thought that's the difference between ENUM data type in SET, am i missing something?

A: In MySQL, the SET data type requires no spaces between the values.
You said your string is:
'Biography, Crime, Drama'

This means the latter two strings have a preceding space:
'Biography',' Crime',' Drama'

Since you don't have ' Crime' or ' Drama' (prepended with spaces) as valid choices in your SET definition, the result is that no bit is set for them in your SET value.
So before you can alter your table with the SET data type you show, you need to remove spaces:
UPDATE movies SET genre = REPLACE(genre, ' ', '');

It's convenient in your case that there are no spaces in the string data that you want to keep. That is, no genre name contains an intentional space character.


text:
Q: Separate Interface or Utility class for defining constants in core java project I am working on a project (using JDK7) which has 30 to 40 constants. These constants are being used by many classes of my project. I want to separate these constants into a single file. Which type of file should I prefer?, Interface or Utility class, I am thinking of using interface. Would it be appropriate ?

A: According to the SonarQube rules Constants should not be defined in interfaces

You should use a class or an enum.

A: I use a class with a private constructor in the case.
But be aware you should only put constants together in one file it there is a conceptual connection between them. Do not simply store a bunch of unrelated constants in a class.
If the constants may change over time because they are more of the configuration type, I would go the extra effort to store them in a configuration file.

A: I do it like this..
class Constants {

private Constants() {

}

public static final String CONST_1 = "";
//add your constants here as public static final properties

}


text:
Q: Saving an XML file using AS3 Is there a way of actually saving this as an XML file itself to then be read into the flash file separately?
var book:XML = <book/>;
book.publisher = <publisher/>;
book.publisher.@name ="O'Reilly";

book.title = "Learning ActionScript 3.0";

book.appendChild(<subject/>);
book.subject.prependChild("Action Script");
book.insertChildAfter(book.subject, <authors/>);

book.authors.author.firstname = "Zevan";
book.authors.author.lastname = "Rosser";

var tempList:XMLList = book.authors.author.copy()
tempList[0].firstname = "Rich"
tempList[0].lastname = "Shupe"
book.authors.insertChildBefore(book.authors.author, tempList);

trace (book);

A: There is a way, in fact there's already a question on stack overflow that had and adequate answer, you could check: Flash Actionscript 3 saving a XML file locally has a "Save As" window (How can I remove it?) .
Any way, you could do it using AIR as flash has a library that will help you save files as a background process, you can find all the informations you need here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html

A: You can save this as an xml. and read in flash. store it locally and use shared object. check this link for reference.


text:
Q: Why eclipse thinks df.as[CaseClass] as an error in Scala Spark program? I'm trying to convert a dataframe to dataset using the syntax

case class Schema(...)
val ds = df.as[Schema]

So my code looks like

case class Rule(rule_on: String, rule_operator: String, rule_value: Int, rule_name: String)
val rules_ds = rules_df
   .select("rule_on", "rule_operator", "rule_value", "rule_name")
   .as[Rule]

But eclipse is highlighting .as[Rule] as error. Screen shots of the same as below.

How to resolve this issue? I know its not a Scala issue, as it works on command line.
Environment (as in Eclipse):

*

*Scala - 2.11.11

*Spark - 2.4.0

*JRE   - 1.8

A: As suggested by Raphael Roth (in comments) I defined case class outside main method and it works like charm. Also other solution (without using case class) is to typecast the dataframe to dataset as below

import org.apache.spark.sql._
val ds: Dataset[Row] = df

The above solution was taken from here


text:
Q: Assign the filename to the imported array in pandas I have folder which includes many csv files namely a_1, a_2, b_1, b_2, b_1, b_2....
I want to import each csv file as their names. For example
a_1 = pd.read_csv("a_1.csv")
a_2 = pd.read_csv("a_2.csv")
In order to do that:
path = r"C:\Users\Desktop\sync\work\all_csvs"
csv_files = glob.glob(path + "/*.csv")

colname=['time', 'var_1', 'var_2', 'var_3', 'var_4', 'var_5']
os.path.basename(csv_files[0]).split(".")[0] = pd.read_csv(csv_files[0], names=colname ,header=None)

But it doesn't work. Is there any way to make the system dynamic? I will use it in the for loop.
Thanks in advance

A: Once you have the list of files in csv_files, loop through the list to import all of the files.
files = {}

for file in csv_files:
    files[file] = pd.read_csv(os.path.join(path, file), ....)

We use os.path.join to generate the absolute path for the file.
This will store all the imported csv files into the files dictionary with keys as the name of the file.


text:
Q: How to redirect after the subscription payment is completed in Razorpay using JS? <form>
    <script src="https://cdn.razorpay.com/static/widget/subscription-button.js"
            data-subscription_button_id="*********"
            data-button_theme="rzp-dark-standard" async>
        if (typeof response.razorpay_payment_id == 'undefined' ||
            response.razorpay_payment_id < 1)
        {
            redirect_url = 'https://www.google.com/';
        }
        else
        {
            redirect_url = 'https://in.search.yahoo.com/?fr2=inr';
        }
        location.href = redirect_url;
    </script>
</form>

This is the Razorpay subscription form.
This does not work to redirect.

A: Not sure, if this is the only problem you are facing, but if the <script> tag has the src attribute, browsers should ignore the content between <script> and </script>.
Try this example:
<!DOCTYPE html>
<html lang="en">
<head><meta charset="utf-8"><title>script example</title></head>
<body>
<script src="a.js">
 console.log("inside");
</script>
</body>
</html>

while a.js contains:
console.log("from a.js");

This produces only from a.js output in the console. Removing the src attribute from <script> tag produces inside output in the console.


text:
Q: Want Firebase Phone Auth to link with Email and then only proceed I want user to move only further if the OTP is correct and then create an account with Email and then link it with phone credentials. And for this I am trying the following.. I have tried making changes here and there but no success.. If the OTP is wrong it still moves further and creates an account with email and password. What I am doing wrong here pls correct me. Thanks.
    Future<void>verifyPhone(String code){

try{
  AuthCredential phoneAuthCredential = PhoneAuthProvider.credential(verificationId: vid, smsCode: code);

  auth.signInWithCredential(phoneAuthCredential).then((valueSignIn){
      auth.createUserWithEmailAndPassword(email: _email, password: _password).then((valueEmail) {
        auth.currentUser.linkWithCredential(phoneAuthCredential).then((valueLink) {
          insertData();
          Navigator.push(context, MaterialPageRoute(builder: (context)=>HomeScreen()));

        }).catchError((err){print("phone auth error 1: $err");
          print("phone auth error code 1: ${err.code}");
          if(err.code == "invalid-verification-code"){
            Fluttertoast.showToast( msg: "Invalid OTP, Try Again Or Check Your Phone Number",
                toastLength: Toast.LENGTH_SHORT,
                gravity: ToastGravity.BOTTOM,
                timeInSecForIosWeb: 3,
                backgroundColor: Colors.blueGrey,
                textColor: Colors.white,
                fontSize: 16.0);
          }else{
            Fluttertoast.showToast( msg: "Something Went Wrong, Try Again",
                toastLength: Toast.LENGTH_SHORT,
                gravity: ToastGravity.BOTTOM,
                timeInSecForIosWeb: 3,
                backgroundColor: Colors.blueGrey,
                textColor: Colors.white,
                fontSize: 16.0);
          }
        }).catchError((err){
          print("phone auth error 2: $err");
          print("phone auth error code 2: ${err.code}");
          if(err.code == "invalid-verification-code"){
            Fluttertoast.showToast( msg: "Invalid OTP, Try Again Or Check Your Phone Number",
                toastLength: Toast.LENGTH_SHORT,
                gravity: ToastGravity.BOTTOM,
                timeInSecForIosWeb: 3,
                backgroundColor: Colors.blueGrey,
                textColor: Colors.white,
                fontSize: 16.0);
          }else{
            Fluttertoast.showToast( msg: "Something Went Wrong, Try Again",
                toastLength: Toast.LENGTH_SHORT,
                gravity: ToastGravity.BOTTOM,
                timeInSecForIosWeb: 3,
                backgroundColor: Colors.blueGrey,
                textColor: Colors.white,
                fontSize: 16.0);
          }
        });

      });
    }).catchError((err){
    print("phone auth error 3: $err");
    print("phone auth error code 3: ${err.code}");
    if(err.code == "invalid-verification-code"){
      Fluttertoast.showToast( msg: "Invalid OTP, Try Again Or Check Your Phone Number",
          toastLength: Toast.LENGTH_SHORT,
          gravity: ToastGravity.BOTTOM,
          timeInSecForIosWeb: 3,
          backgroundColor: Colors.blueGrey,
          textColor: Colors.white,
          fontSize: 16.0);
    }else{
      Fluttertoast.showToast( msg: "Something Went Wrong, Try Again",
          toastLength: Toast.LENGTH_SHORT,
          gravity: ToastGravity.BOTTOM,
          timeInSecForIosWeb: 3,
          backgroundColor: Colors.blueGrey,
          textColor: Colors.white,
          fontSize: 16.0);
    }
  });

}catch(e){
  print("Phone Auth Credential $e");
}

}


text: Q: Is every simply connected finite complex the classifying space of a finite monoid On page 323 of Fiedorowicz, "Classifying Spaces of Topological Monoids and Categories" it was stated that "it seems likely that any finite simply connected complex should [have the same weak homotopy type as] the classifying space of a finite monoid." The paper was published in 1984. Has any progress been made in the last 30 years that would allow us to replace "it seems likely" by "it is known"?


text:
Q: updating $_POST and passing to php via jquery without submit caveat: this would probably be pretty simple with a submit, but because of someone else's #%^$!& code, every submit clears all data on all forms on the page, so i cannot use .submit()
here's what i'm trying to do:
step 1: a link on a page, via Javascript, opens a popup. that popup has a some fields you fill it out, and using window.opener.getElementById('hiddenX').value, various hidden html elements on the original page are then updated, and the popup is closed.
step 2: on unload of the popup, the html elements are modified via Javascript.
step 3: the updated html elements are added back to $_POST on the page
Step 4: a bit of php code runs a php function using the values from $_POST as well as the values produced by earlier php code  to create and send an email.
I do not think i can pass the values via a GET-style url since some of the values are very very long text strings, and tehre will probably be some arrays as well. I have tried using .post(window.location, {val1 : "1stvalue"}) in combination with a .load() on the div containing the php code from step 4. i think the div updates, but the POST value remains empty. any ideas?
script:
$(".email1").on('click', function (event) {
        var win1 = window.open("../sub1.php","_blank","height=450,width=510, status=yes,toolbar=no,menubar=no,location=no");
         $(win1).on('unload', function (event){
             if(document.getElementById('hidden1').value != "z"){
              $tosend2 = document.getElementById('hidden3').value;
              ...... // various changes to $tosend2 and other elements on the page
              $.post( window.location, { hidden3 : "abc"  }); //temporarily use "abc" instead of $tosend2
              $( "#emaildiv" ).load(location.href+" #emaildiv2>*","" );

              }
         });
});

html / php :

   <input type="hidden" name="hidden1" id="hidden1" value="z" />
   <input type="hidden" name="hidden3" id="hidden3" value="z" />

<?php
   echo "
 what is the val?: " . $_POST['hidden1'] . "
";
  if( !empty($_POST['hidden1']) ){
    if( $_POST['hidden1'] != "z" ){
        echo "
 what is it now?: " . $_POST['hidden1'] . "
";
    //emailstuff($locnlist, $_POST['hidden1'], $_POST['hidden3']);
    //echo "email sent";
    }
}
?>

A: I solved this by moving the email function and php div to a separate php page, called sub2.php, and then sending the post values to that page via ajax
                        $.ajax({
                            type: 'post',
                            url: '/routing/sub2.php' ,
                            data: { hidden1 : document.getElementById('hidden1').value ,
                                    hidden2 : document.getElementById('hidden2').value ,
                                    hidden4 : document.getElementById('hidden4').value ,
                                    locnlist : loclist },
                            success: function () {
                            alert("Email has been sent!");
                            }
                        });

this doesn't actually solve the initial issue, but it works just as well.
if someone has a better solution, i'd be very pleased to know what it is


text:
Q: Smaato custom banner view could not be instantiated (Android) I tried to use Smaato ad in my app. For first look it's simple to use, but in practice I got a problem. I put in main view XML a Smaato banner. The problem number one is that Eclipse shows me in GraphicLayout tab the next error message:
*

The following classes could not be instantiated:
  - com.smaato.SOMA.SOMABanner See the Error Log (Window > Show View) for more details. Tip: Use View.isInEditMode() in your custom views to
  skip code when shown in Eclipse

*
main.xml file code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RootLayout"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
  <com.smaato.SOMA.SOMABanner
    android:id="@+id/bannerView"
    android:layout_width="fill_parent"
    android:layout_height="90dp"
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
  />
</LinearLayout>

Accordingly to official SOMA SDK Developer guide:
1) I defined a banner view in my application (described above)
2) In code I add manully to onCreate method:
SOMABanner mBanner = (SOMABanner)findViewById(R.id.BannerView);
//In order to fetch live ads inside the activity, add your PublisherID and AdspaceID in the
//onCreate method. For example:
mBanner.setPublisherId(my_publisher_id);
mBanner.setAdSpaceId(my_adspace_id);

When I ran a programm, throws an exception:

12-20 03:00:48.415: ERROR/AndroidRuntime(12819): FATAL EXCEPTION: main
  12-20 03:00:48.415: ERROR/AndroidRuntime(12819):
  java.lang.RuntimeException: Unable to start activity
  ComponentInfo{com.example.android.My/com.example.android.My.App}:
  java.lang.ClassCastException: android.widget.TextView 12-20
  03:00:48.415: ERROR/AndroidRuntime(12819):     at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1821)
  12-20 03:00:48.415: ERROR/AndroidRuntime(12819):     at
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1842)
  12-20 03:00:48.415: ERROR/AndroidRuntime(12819):     at
  android.app.ActivityThread.access$1500(ActivityThread.java:132) 12-20
  03:00:48.415: ERROR/AndroidRuntime(12819):     at
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
  12-20 03:00:48.415: ERROR/AndroidRuntime(12819):     at
  android.os.Handler.dispatchMessage(Handler.java:99) 12-20
  03:00:48.415: ERROR/AndroidRuntime(12819):     at
  android.os.Looper.loop(Looper.java:143) 12-20 03:00:48.415:
  ERROR/AndroidRuntime(12819):     at
  android.app.ActivityThread.main(ActivityThread.java:4268) 12-20
  03:00:48.415: ERROR/AndroidRuntime(12819):     at
  java.lang.reflect.Method.invokeNative(Native Method) 12-20
  03:00:48.415: ERROR/AndroidRuntime(12819):     at
  java.lang.reflect.Method.invoke(Method.java:507) 12-20 03:00:48.415:
  ERROR/AndroidRuntime(12819):     at
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  12-20 03:00:48.415: ERROR/AndroidRuntime(12819):     at
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 12-20
  03:00:48.415: ERROR/AndroidRuntime(12819):     at
  dalvik.system.NativeStart.main(Native Method) 12-20 03:00:48.415:
  ERROR/AndroidRuntime(12819): Caused by: java.lang.ClassCastException:
  android.widget.TextView 12-20 03:00:48.415:
  ERROR/AndroidRuntime(12819):     at
  com.example.android.My.App.onCreate(Commander.java:132) 12-20
  03:00:48.415: ERROR/AndroidRuntime(12819):     at
  android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
  12-20 03:00:48.415: ERROR/AndroidRuntime(12819):     at
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1785)
  12-20 03:00:48.415: ERROR/AndroidRuntime(12819):     ... 11 more

Who knows what is the problem? What I need to do to fix it? Any body works with Smaato?
Used Smaato SDK version 2.5.4

A: It shows you get a ClassCastException in your Commander class at line #132.
Please post the onCreate method of your Commander class or look into TextView casts in onCreate method.

A: Here is the solution what worked for me :
 - In eclipse, right click on the project-> properties -> Java Build Path -> Order and Export
Check the SOMA jar file in the path and try now !

A: I copied the Smaato jar into the libs/ directory; that seemed to help.


text:
Q: Chart.js multiple columns of data for the same label I'm using Chart.js 2.7 and I want to show multiple columns of data for the same label. For example I want a chart with the months of the year as labels, but to show a number for each day of the month, not a number per month. So for a single label I will have about 30 columns of data.
Is this possible?

A: That sounds like a grouped Bar chart. Here's an example that uses RGraph ( https://www.rgraph.net ) to show it:
https://www.rgraph.net/fiddle/view.html/a-grouped-bar-chart-example
The amount of data that you have makes for a very wide chart though (12x30 bars) though, so here you have a 5000px wide canvas which sits inside a 1000px DIV tag which has the CSS overflow set to auto (so that you get a scroll bar).
Here's the code from that page:
Include the libraries:
<script src="/libraries/RGraph.common.core.js"></script>
<script src="/libraries/RGraph.bar.js"></script>

Define the canvas tag in your HTML:
<div style="width: 1000px; overflow: auto">
    <canvas id="cvs" width="5000" height="250">[No canvas support]</canvas>
</div>

And the code that makes the chart:
var bar = new RGraph.Bar({
    id: "cvs",
    data: [
        [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], // January
        [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2], // February
        [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], // March
        [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2], // April
        [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], // May
        [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2], // June
        [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], // July
        [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2], // August
        [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], // September
        [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2], // October
        [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], // November
        [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]  // December
    ],
    options: {
        colors: ['red'],
        shadow: false,
        labels: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
    }
}).draw();


text:
Q: How to Expand Abbreviations Inline in Fish Shell? I'm trying to save some time in Fish Shell by setting an abbreviation (nu) to expand to the string:
my-username@my-ip-address:/home/my-username
What I'm hoping to achieve is to enter:
scp some-file nu
...then tab- or space- complete the nu abbreviation to expand it to the string I set in my config.fish.
I have more use cases for this functionality, but Fish doesn't seem to cover it. It offers abbreviations, but they only seem to work at the beginning of a command; I can't get them to work inline. Any ideas?

A: Fish currently only allows abbreviation expansion in the command position. Which means, for example, it works after the | (pipe) symbol but not in the middle of a command. There have been many issues opened about it over the years. See
https://github.com/fish-shell/fish-shell/issues/5003
https://github.com/fish-shell/fish-shell/issues/1963
https://github.com/fish-shell/fish-shell/issues/1220
And probably several others. Also, note that abbreviation expansion only supports literal string substitution with no customization of the result (and that is unlikely to ever change). So if you want parts of the expansion (e.g., my-ip-address) to vary depending on factors like the system you're on you'll need to create the abbreviation when you start the shell.


text:
Q: How to shade an area in ggplot mixing geom_rect and geom_line? Consider this data:
shade <- structure(list(from = structure(c(6940, 7670, 8766, 13879, 14610,
15340), class = "Date"), to = structure(c(6940, 7670, 10227,
13879, 14610, 17897), class = "Date")), class = "data.frame", row.names = c(NA,
-6L))

I am trying to shade an area in ggplot with shade. The other part of the data is:
df <- structure(list(Date = structure(c(4383, 4748, 5113, 5479, 5844,
6209, 6574, 6940, 7305, 7670, 8035, 8401, 8766, 9131, 9496, 9862,
10227, 10592, 10957, 11323, 11688, 12053, 12418, 12784, 13149,
13514, 13879, 14245, 14610, 14975, 15340, 15706, 16071, 16436,
16801, 17167, 17532, 17897), class = "Date"), growth = c(0.0623150839421278,
-0.0118611051533168, -0.0664501162049262, -0.087782956704693,
-0.129496959622578, -0.18594460634209, -0.188214164298442, -0.172238123190157,
-0.94277027404306, -0.0834575040012719, -0.0883082379839397,
-0.101106281706148, -0.0371396056259545, -0.011174839245335,
0.0182311778775262, 0.0549337165151567, 0.35326560836822, 0.320551702135409,
0.295635261636084, 0.201819487872301, 0.045320365597334, 0.036634868496078,
0.000464348739324549, -0.0302907006607054, -0.0615712296201636,
-0.0850991148284894, -0.0819342537954828, -0.0874010742126909,
-0.0688419496282826, -0.086814819317242, -0.0567750186957099,
-0.0333039095763059, -0.00719293166024748, 0.0166361057943032,
0.0707141351711211, 0.133846612601381, 0.156206411946355, 0.329862325903626
)), row.names = 23:60, class = "data.frame")

This is what I've tried, but it ignores rows that have the same values in shade$from and shade$to:
library(ggplot2)

ggplot() +
  geom_rect(data = shade, aes(xmin = from, xmax = to, ymin = -Inf, ymax = Inf)) +
  geom_line(data = df,  aes(x = Date, y = growth))

I guess a mix of geom_rect and geom_line from ggplot would work.

A: Simply add an geom_vline for the cases where your shaded areas are just vertical lines:
library(ggplot2)
library(dplyr)

ggplot() +
  geom_vline(data = dplyr::filter(shade, from == to), aes(xintercept = from)) +
  geom_rect(data = shade, aes(xmin = from, xmax = to, ymin = -Inf, ymax = Inf)) +
  geom_line(data = df,  aes(x = Date, y = growth))

Created on 2020-06-26 by the reprex package (v0.3.0)

A: Two options with or without a legend:
For a legend: add a factor to the shade data frame;
Use colour aesthetic as well as fill to manage the dates which are the same.
I suspect you cannot fill an area with no width.
You do not need to add additional geoms using this approach:

library(ggplot2)
library(patchwork)

shade$area <- letters[1:nrow(shade)]

p1 <- ggplot() +
  geom_rect(data = shade, aes(xmin = from, xmax = to, ymin = -Inf, ymax = Inf, colour = area, fill = area)) +
  geom_line(data = df,  aes(x = Date, y = growth))+
  ggtitle("Shade each area identifiable with legend")

p2 <- ggplot() +
  geom_rect(data = shade, aes(xmin = from, xmax = to, ymin = -Inf, ymax = Inf), colour = "gray50", fill = "gray50") +
  geom_line(data = df,  aes(x = Date, y = growth))+
  ggtitle("Shade uniform colour, without legend")

p1/p2

Created on 2020-06-26 by the reprex package (v0.3.0)


text:
Q: How many people could you take on in a fight? A while back I played Planetside for a time. I remember sometimes not being able to get to a particular continent because the number of players on it was too high.
How many players were allowed on a continent at once? Was it an overall cap, or a cap of players per faction (e.g. to keep battles more even)? Basically, what was the maximum number of people your faction could be facing in a particular battle at any time?

A: According to this wiki article, the number has changed multiple times, so it'd would depend on when you played.

Points from the article:

*

*In 2003 the population cap for an empire was 2/3rds total for a continent (total estimated around 500-550 players), leaving 1/3rd to split between the other two factions.

*In 2004 the population cap for an empire was reduced to 166 players.

*In 2005 the population cap for an empire was reduced to it's current 133 players.


text:
Q: How to set up MPI_COMM_SPAWN to behave like mpirun? I use MPI (openMPI 3.0.1) in C for my work and i want to know how to set up mpi_comm_spawn to behave as if I run my executable with mpirun ?
I use this hostfile :
# This is a single processor node:

# This is a height-processor node. Oversubscribing
# to it is prevented by setting max-slots=4:

# host  | rank | nb procs | max nb procs
  node7   0,2    slots=2    max-slots=4

# This is a height-processor node. Oversubscribing
# to it is prevented by setting max-slots=8:

# host  | rank        | nb procs | max nb procs
  node8   1,3,4,5,6,7   slots=6    max-slots=8

so when I launch hostname with
mpirun -hostfile /path/to/mpi_hostfile hostname

I gave
node7
node7
node8
node8
node8
node8
node8
node8

but when I spawn new processes with (warning this is pseudo code)
maxprocs = to_unsigned(arg)
info_key = "add-hostfile"
info_value = "/path/to/mpi_hostfile"

mpi_comm_spawn(....)

and this is the code I use
mpi->comm_spawn->set_attr_command(argv[0]);
mpi->comm_spawn->set_attr_argv(argv + 1);
mpi->comm_spawn->set_attr_maxprocs(universe_size - 1);

if (mc_options.hostfile == nullptr)
  mpi->comm_spawn->set_attr_info(spot::mpi::info_null);
else
  {
     // OpenMPI specific
     const char* hostfile = "add-hostfile";

     mpi->info_create->set_attr_info(&info);
     mpi->info_create->do_info_create();

     mpi->info_set->set_attr_info(info);
     mpi->info_set->set_attr_key(hostfile);
     mpi->info_set->set_attr_value(mc_options.hostfile);
     mpi->info_set->do_info_set();

     mpi->comm_spawn->set_attr_info(info);
   }

 mpi->comm_spawn->set_attr_root(master);
 mpi->comm_spawn->set_attr_comm(spot::mpi::comm_self);
 mpi->comm_spawn->set_attr_intercomm(&children);
 mpi->comm_spawn->
 set_attr_array_of_errcodes(spot::mpi::errcodes_ignore);
 mpi->comm_spawn->do_comm_spawn();

I Have all my processes on node7 and I can't launch more than 2 processes (like I specifying in mpi_hostfile for node7)
Process #0: on HOST node7
Process #1: on HOST node7

if I try to launch more
--------------------------------------------------------------------------
There are not enough slots available in the system to satisfy the 3 slots
that were requested by the application:
/* my executable*/

Either request fewer slots for your application, or make more slots available
for use.
--------------------------------------------------------------------------
[node7:2306] *** An error occurred in MPI_Comm_spawn
[node7:2306] *** reported by process [4042260481,0]
[node7:2306] *** on communicator MPI_COMM_SELF
[node7:2306] *** MPI_ERR_SPAWN: could not spawn processes
[node7:2306] *** MPI_ERRORS_ARE_FATAL (processes in this communicator will now abort,
[node7:2306] ***    and potentially your MPI job)

and I want to have
node7
node7
node8
node8
node8
node8
node8
node8

like with mpirun
I don't understand why it's different ?
thanks.


text:
Q: Unable to toggle the visibility property on hover in CSS (Testing in Chrome)
In the below CSS, I'm trying to toggle the visibility of a P-tag when the mouse hovers over it. It's hidden but becomes visible on hover with a yellow highlight.
p {
    visibility: hidden;
}

p:hover {
    background-color: yellow;
    text-decoration: overline;
    visibility: visible;
}

But this isn't working; the P element is always hidden. I verified that if I remove the first definition, then the hover works, but I need to hide it most of the time.

A: I'd suggest toggling the opacity property instead.

p {
    opacity: 0;
}
p:hover {
    background-color: yellow;
    text-decoration: overline;
    opacity: 1;
}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam accumsan, orci ut posuere aliquet, libero erat vestibulum ligula, nec eleifend sapien nunc eu leo. Mauris ligula sapien, posuere eu ligula et, tincidunt pharetra velit. Pellentesque volutpat elit sed mollis lacinia. Donec nunc diam, viverra vel sapien non, dictum faucibus nibh. Donec dictum nec diam non sagittis. Quisque eget arcu et nunc lobortis accumsan vitae vel urna. Vivamus semper mollis auctor. Donec tempus, lectus quis maximus gravida, arcu lorem sollicitudin elit, nec sollicitudin sem neque a felis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse vehicula, nibh vel euismod fringilla, mi lorem luctus dui, viverra efficitur diam sapien sit amet mi. Maecenas sed laoreet mauris. Nunc sodales, mi eu vulputate ullamcorper, ligula augue imperdiet massa, vitae fringilla tellus lorem id dui. In dapibus arcu nec felis porttitor varius.

In doing so, the element will still consume the same amount of space when it isn't visible. In other words, the hidden text will continue to behave similarly to text hidden with visibility: hidden.