text:
Q: Bundle RSS in emails I've been using the following code to pull in Google news, however, I need to have the final result on the web site be an actual rss feed so others can grab the feed.  Right now the output creates a nice index.php page.  That's great, but doesn't suit my purposes.  Can SimplePie create a page which is formatted as an rss output for grabbing purposes?
thank you in advance.

<?php

// Make sure SimplePie is included. You may need to change this to match the location of simplepie.inc.
require_once('simplepie.inc');

// We'll process this feed with all of the default options.
$feed = new SimplePie();

// Set the feed to process.
$feed->set_feed_url('http://news.google.com/news?hl=en&gl=us&q=new+york+commercial+real+estate&ie=UTF-8&output=rss');

// Run SimplePie.
$feed->init();

// This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it).
$feed->handle_content_type();

// Let's begin our XHTML webpage code.  The DOCTYPE is supposed to be the very first thing, so we'll keep it on the same line as the closing-PHP tag.
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
        "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    <title>Sample SimplePie Page</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

<a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?>

<?php echo $feed->get_description(); ?>

    <?php
    /*
    Here, we'll loop through all of the items in the feed, and $item represents the current item in the loop.
    */
    foreach ($feed->get_items() as $item):
    ?>

<a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?>

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

Posted on <?php echo $item->get_date('j F Y | g:i a'); ?>

    <?php endforeach; ?>

A: SimplePie is used only for the parsing stage, you need to write your own code to output it as RSS.
You can do it the quick and dirty way:
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
    <channel>
        <title>Your Site</title>

<?php
        foreach ($feed->get_items() as $item):
?>
        <entry>
            <title><?php echo $item->get_title() ?></title>
            <description><?php echo $item->get_content() ?></description>

        </entry>
    </channel>
</rss>

A much better way is to use SimpleXML to create the elements and then output the result of that. That will ensure that your XML is well-formed, and that everything is escaped correctly.
However, you also have to be careful about terms of service when doing this, as Brad mentioned. You should ensure proper attribution at the very least.


text:
Q: Javascript - Backward ( from Leaf to Root ) traversal inside JSON object     MyJSON= {
    "name":"ParentName",
    "photo":"images/p.jpg",
    "children":[
      {
      "name":"ChildName",
      "photo":"images/ch.jpg",
      "spouse":[
        {
        "name":"ch-spName",
        "photo":"images/sp.jpg"
        }],
       "children":[
        ...
       ]
      ...
    }]
}

I want to traverse forward and backward.
ie if user selects a child it should show the tree of that particular object. It can go up to the end. From there it should be able to traverse backward also.
I managed to traverse forward, it works fine. How can I traverse backward?
I am using Javascript for this.

A: You can try jquery parseXML , and make the server return a xml instead of json because according to this , by parsing xml ,

jData, our jQuery instance object, now contains the XML document object model (#document) which can be traversed using any of jQuery's sweet ass functions (ex. find(), children(), parent(), etc.).

redpajama_set_name: RedPajamaStackExchange


text:
Q: Kendo Theme Customization asper User Theme Selection in Angular 2+ I'm setting up a Kendo grid whose styles must change as per the different templates.
Here, I have -all.css file(at nodemodule) which is not compatible with the variables like mat-color function which requires variables.
Expected result : Styles of Kendo Grid are to be changed as per the theme setting.
Please explain how to change the .scss variables in node modules by the values from app folder(is it the right way? I'm bit stuck upon this).

A: After much consultations, and some research- here is the conclusion which is depicted the following steps:

*

*Create the new kendo.scss file in the app folder.

*Separate the Kendo theming (all.css) from the nodemodule folder to the new style sheet file in app folder by changing the angular.json file string calling the kendo styling(replace all.css to kendo.scss for all input links).
 "styles": [
              { //"input": "nodemodule/@progress/kendo-theming/all.css" to below
                "input": "src/app/theme/styles/_kendo.scss"
              },

*For theming use the variables given in the below link for Customization
https://www.telerik.com/kendo-angular-ui/components/styling/theme-default/customization/
By this, got what I need. If any bugs arises then stick to point 3 (which arises due to difference in the variable provided).

*For Theme Reseting for bootstrap, angular material we need to use Kendo ThemBuilder -> https://themebuilder.telerik.com/kendo-angular-ui


text:
Q: Why do Unix/Linux systems still need to depend on Microsoft? On an Ubuntu 20.04 system on Intel hardware:
# cd /boot/efi/EFI/
# file $(find . -name '*.efi')
./ubuntu/grubx64.efi: PE32+ executable …, for MS Windows
./ubuntu/shimx64.efi: PE32+ executable …, for MS Windows
./ubuntu/mmx64.efi:   PE32+ executable …, for MS Windows
./BOOT/fbx64.efi:     PE32+ executable …, for MS Windows
./BOOT/mmx64.efi:     PE32+ executable …, for MS Windows

It is Ubuntu-only, single-boot.
Unix systems predate Windows by fourteen years.
So why "MS Windows"?
Is there no way of escaping from the world of Microsoft?
(And yes, I know, resistance is futile.)

A: PE32+ is a public specification that was chosen for a reason (see the note on page 15 of the UEFI Specification 2.8B).

Note:This image type is chosen to enable UEFI images to contain Thumb and Thumb2 instructions while defining the EFI interfaces themselves to be in ARM mode)

It has nothing to do with dependency. Many specifications were developed by a company and then adopted as standards. For more info on the competing formats you could start here.


text:
Q: Calculate the sum of all files and all directories in a folder in php for a filemanagement i calculate the size of each file and the directories in a specific folder.
I calculate the size of the files like below:
 sizeFormat(filesize($dir . '/' . $file))

and the size of the directories (included subdirs) like below:
sizeFormat(recursive_directory_size($dir . '/' . $file))

How can i calculate now the sum size of all files and directories in that specific folder?

A: Try this function, it is what you need, I hope.
function dirsize($dir) {
 if(is_file($dir)) return array('size'=>filesize($dir));
  if($dh=opendir($dir)) {
    $size=0;
    $n = 0;
    while(($file=readdir($dh))!==false) {
        if($file=='.' || $file=='..') continue;
        $n++;
        $data = dirsize($dir.'/'.$file);
        $size += $data['size'];
    }
    closedir($dh);
    return array('size'=>$size);
  }
   return array('size'=>0);
 }

print_r(dirsize("bitnami.css"));
print_r(dirsize("some_folder"));


text:
Q: How many possible board states in 2048? I recently found out about the famous 2048 game.
For those of you who don't know how it works, it consists on a 4x4 board on where tiles which are powers of 2 are placed. On every turn, you "swipe" the board in any of the four directions, and a 2 (90% chance) or a 4 (10% chance) are placed randomly in any of the blank spaces. If two adjacent tiles are of the same value $n$, they can be merged into a tile of value $2n$. The game starts with 14 blank spaces and 2 randomly placed tiles (following the same rules as above).
I have written a considerably strong AI for it, but now I want to know how many possible different board states can be achieved (to see if the game can actually be mathematically solved).
Knowing the highest tile achievable is $2^{17}$, this means each tile can be in exactly 18 distinct positions (including 'blank' or zero). This yields an upper bound of $18^{16}$ different possible board states. However, it is obvious that all positions can't be achieved (for example, a board filled of 16 tiles of the same value, or a number higher than 4 being 'isolated' from the rest. Also, only one $2^{17}$, three $2^{16}$s,  five $2^{15}$s, etc can exist at the same time on the board).
Then, you can also take into account rotations and simmetries. For example, there are 480 starting positions, but if you group together those that are rotations and/or simmetries of each other, you end up with only 75 distinct and unique starting positions (computed with a simple script). Edit: the number of boards achieved after two turns I calculated and that appeared here was wrong.
Giving an exact result for achievable board states is probably quite a difficult task, so I'm asking for a good upper bound for these possible states (counting groups of rotated/simmetric boards as one, if possible).
Edit for clarification: I'm not asking for any AI strategy, or this question is in any way related to my AI. It's a question to get deeper knowledge of the game, that's all.

A: I think I have a solution... isnt not as beauty as I would like but my maths knowledge is limited. I will go point by point.
1.FIRST CONSIDERATIONS
We can think the board in the more simple way eliminating all symmetries: specular symmetries and rotational symmetries. So I will think the positions something like a tetris of 4 columns, i.e., the movement is from top to down.
Thinking this way cannot be possible to have any multiplicity of any number more than a pair (2) in any column but this formed by the suddenly apparition of a 2 or 4. So our pairs (or lines of three or four equal tiles) only can appear seeing by files instead of columns.
The pairs that we can have are of two types: contiguous and not contiguous. Contiguous pairs on columns only can appear after a collapse, so they are prohibited on columns of cardinality 4. And contiguous pairs of 2's are completely prohibited no matter what.
We think column as the position of elements but the sudden and random apparition of a 2 or 4 that occur in any board state.
2.COLUMS AND VARIATIONS ON COLUMS
From this we can have 5 types of columns, i.e., of cardinality 0 to 4, I will name as $C_i$ where i is the cardinality. The variations on the columns will depend if:
a) all tiles are different, in this case it will be $(17)_i$ where this is the representation of a falling factorial
b) there is some pair (or pairs), where we want that the pairs of 2 are not contiguous because you can have two contiguous pairs just if one of the number was generated by collapse (you cant generate a 2 by collapse). We will process the pair as a single, so for a column of 3 with a pair and a different number we will count it as $(17)_2$, i.e., the variations over two positions of 17 different values.
c) we must consider the geometry of pairs to compute variations only when the pair can be arranged in a different position. For a column of 3 if there is a pair of 2 it only can be as the extremes of the list because contiguity is prohibited for pair of 2's: 2o2. But for the case that the column have cardinality 4 we must consider the distributions 2o2c and the distribution o2c2. The singles values (the c and the o) from a point of view of the hipervariations (aka variations of level 2) are equivalents. But the case with two pairs different of 2's in xoxo cannot have any type of variation because the structure oxox in terms of the first variation level is equal.
d) to clarify: we calculate on columns over two levels of variations, just considering the different groups over the different distribution of singles and pairs of 2's or pairs of others numbers. Something like a variation level and a hipervariation level. We have then 3 types of sets: singles, pairs of 2's and others pairs, and a multiplicity bigger than a pair isnt possible on columns.
So the variations that we have by cardinality of the columns are: $C_0=1, C_1=17, C_2=(17)_2+16, C_3=(17)_3+3(17)_2-2\cdot 16, and\ C_4=(17)_4+2(17)_3+(17)_2$
This need a explanation: the first addend for each $C_i$ are the variations with all elements different, the others addends are the variations with valid pairs (any pairs are valid but the contiguous 2's). Example: for $C_2$ the variations of 17 different elements over two positions are $(17)_2$ and the valid pairs are just any pair but the 2's (16 type of pairs that arent 2's).
For $C_4$ the valid pairs are all with no contiguity at all because contiguity just can happen after a collapse of numbers that doesnt occur on a full column. You can have a column of 4 after a collapse by the apparition of a 2 or 4 but this is considered as a column of cardinality 3.
For $C_3$ the second number are permutations with repetition of 2 groups (multiplicity 1 and 2) multiplied by combinations of 17 elements in groups of two, i.e. $\binom{3}{2}\binom{17}{2}$. The third number are the invalid combinations with pair of 2's that are contiguous, i.e. $16\cdot 2$
3.VARIATIONS OF COLUMNS: COMPOSITION OF THE BOARD
The next level is to calculate all the variations of these 5 columns over the 4 possible positions (the board is 4x4) eliminating all the duplicates by specular and rotational symmetries.
First I will show a formula to express the variations of $C_i$
$$C_i=(17)_i+\binom{2/3}{i-3}3(17)_{i-1}+\binom{1}{i-4}(17)_{i-2}+(-2)^{i-2}16\cdot\delta_{2, 14\ \text{mod}\ i+1}$$
We need to add to the mix the presence of a 2 or 4 that is generated in every move of the board in any of the free positions, and the cases where one occupied tile is 2048. This is a factor that depends of the free (or blank) positions. And we need to fix the number of valid starting positions too, so
$$B(i)=(2(16-\Sigma i))^{1-\delta_{16,\Sigma i}}(1-\delta_{0,\Sigma i})$$
i.e. the total spaces less the cardinalities of the columns on this composition multiplied by 2 because we can have a 2 or a 4. The exponent is a Kronecker delta that prevent the zero when all columns have cardinality 4 (full board).
The second Kronecker delta eliminates the start with just one tile because you start with 2 tiles placed (you start with a column of cardinality 1).
(After is a fix for a few "floating" starting position, when both tiles arent on the borders of board).
We need to fix, from here, the duplicates that come from specular symmetry and rotational symmetry.
Fix for specular symmetry duplicates
All columns are duplicated by specularity in the sums but the compositions where columns have a perfect specular symmetry on cardinality (think about Rorschach images). So the formula need a general factor of $\frac{1}{2}$ to eliminate all of these duplicities and an internal factor that preserve the original multiplicity of these compositions with perfect symmetry (that are not duplicated).
This internal factor will be a Kronecker delta function that "see" when the composition have a perfect specular cardinality of columns.
The formula at this moment will be
$$S_1=\frac{1}{2}\sum_{a,b,c,d=0}^{4}C_aC_bC_cC_d\cdot B(i)\cdot 2^{\delta_{a,d}\delta_{b,c}}$$
But we need to add a fix for rotational duplicates too.
Fixing rotational duplicates
The rotational duplicates have a condition to exist: that cardinalities had a partial order what ensure a "stairs" shape that make possible for these composition to be rotated, so $a\geq b\geq c\geq d$. See that this law of composition prevent any duplicity by specularity.
This is because we are seeing the board as a tetris with a "gravity" so if the shape isnt something like a stairs the figure cant be rotated because isnt a valid shape with the fall mechanic.
So the fix for the rotational symmetry have this form
$$S_2=\sum_{a=1}^{4}\sum_{b=0}^{a}\sum_{c=0}^{b}\sum_{d=0}^{c}C_aC_bC_cC_d\cdot B(i)\cdot F(i)$$
Where F is a function that eliminates the false duplicates, i.e., the configurations that cant be rotated because they have pairs of contiguous 2's or more than pairs contiguous with other numbers.
In any position, talking of files of 3 or 4 contiguous and equals numbers, the probability for any number in any tile is $\frac{1}{17}$. So the probability that the same number appear contiguous is approximately $\frac{1}{17^3}$ if we are talking of 3 contiguous numbers or $\frac{1}{17^4}$ if we are talking of a full row. For the case of pairs of 2's the probability is $\frac{1}{18^2 17}$ that is an approximation of the mean of apparition (it changes depending on what tiles make the pair).
The amount of possible full rows of the same number is $d$, i.e., the cardinality of the last column in our stairs model for rotational duplicates.
The amount of possible trios will be $c+d$, and the amount of possible pairs of 2's will be $b+c+d$.
We will apply a factor (that is a probability) over each addend of $S_2$ (this is the F function). This is a binomial that is
$$P(X=0)=(1-p)^n, n\in\{d,c+d,b+c+d\}$$
So
$$F(i)=(1-\frac{1}{17^4}(1-\frac{1}{18^4 17}))^d(1-\frac{1}{17^3})^{c+d}(1-\frac{1}{18^2 17})^{b+c+d}$$
The second multiplier is a fix for duplicated full rows considering any numbers and two pairs of 2's.
4.FINAL FORMULA
The final (by now :p) formula is....:
$$S\approx S_1-S_2+S_3$$
Where $S_3=6$ that are a very little amount of starting positions where the first two tiles that appear are out of the borders.
P.S.: maybe a better approach to the problem a generating function... but my maths knowledge about it is near to zero.
P.S.2: sry, I had A LOT of edit of stupids and tiny mistakes (more) and some heavy mistakes (less). The formula of $C_i$ can be written in many different ways... I let one but surely isnt the more efficient on computational or symbolic sense.


text:
Q: Other computers think my program is a virus I created a program in visual studio (winForm, C#),
I even built a release version, but when I tried running the program in a different computer than my own, the antivirus popped up and said there may be a risk in running this program
My program is a rubik's cube solver for anyone wondering
How can I make my program be trusted by other computers?

A: Aside from the fair chance that a virus on your computer actually infects the executables you share:
Not at all, since your program is unknown to the receiver, and it is a risk executing it. So, that warning is correct, and should be heeded.
You might do such things as signing your executable, but that will only certify that it's your program, and not that it's harmless.


text:
Q: Validate checkbox selections Please check my JavaScript code bellow. Once i click on "Upload" i am always getting "You didn't checked any item" however i checked some item i get same alert run. How can i correct it so it will execute as per item i have selected?
<!DOCTYPE html>

    <title>Test</title>

<form>
    <input type="checkbox" name="check_item" value="1">Item 1

    <input type="checkbox" name="check_item" value="2">Item 2

    <input type="checkbox" name="check_item" value="3">Item 3

    <input type="button" class="uploadExternal" value="Upload"/>

</form>

A: document.getElementsByClassName method returns an array-like object of all child elements which have all of the given class names.
You should itare through all the items to check if any is checked.
For this, you can use Array.from function to create an array which includes all the checkbox elements with check_item class.

The Array.from() method creates a new Array instance from an
  array-like or iterable object.

Next, you have to check if there is at least a checkbox DOM element which is checked. For this, you should use some function.
some function accepts a callback provided method applied on every item in above array.
var checked=Array.from(check_item).some(function(checkbox){
  return checkbox.checked;
});

$(document).on("click", ".uploadExternal", function (e) {
    var check_item = document.getElementsByClassName("check_item");
    var checked=Array.from(check_item).some(function(checkbox){
      return checkbox.checked;
    });
    if (checked){
        alert("You have checked item");
    } else {
        alert("You didn't checked any item");
    }
});

<form>
    <input type="checkbox" class="check_item" name="check_item" value="1">Item 1

    <input type="checkbox" class="check_item" name="check_item" value="2">Item 2

    <input type="checkbox" class="check_item" name="check_item" value="3">Item 3

    <input type="button" class="uploadExternal" value="Upload"/>

</form>

A: The method document.getElementsByClassName("check_item") returns an array of elements. You need to iterate over them. With the checked attribute you can determine if the checkbox is checked. The result is something like this:
var check_item = document.getElementsByClassName("check_item");
var isChecked = false;
for (var i = 0; i < check_item.length; i++) {
    if (check_item[i].checked) {
        isChecked = true;
        break;
    }
}
if (isChecked) { ...

A:

$(document).on("click", ".uploadExternal", function(e) {

  var check_item = document.getElementsByClassName("check_item");
  console.log(check_item);
  if (check_item[0].checked) { //check if check_item empty

    alert("You have checked item 1");

  } else if (check_item[1].checked) { //check if check_item empty

    alert("You have checked item 2");

  } else if (check_item[2].checked) { //check if check_item empty

    alert("You have checked item 3");

  } else {
    alert("You didn't checked any item");
  }

});

<form>
  <input type="checkbox" class="check_item" value="1">Item 1

  <input type="checkbox" class="check_item" value="2">Item 2

  <input type="checkbox" class="check_item" value="3">Item 3

  <input type="button" class="uploadExternal" value="Upload" />
</form>

you have called document.getElementsByClassName("check_item"); but in your html code u didn't mentioned about class attribute.
Try this fiddle

A: Please add class tag to all of your items or fetch items by name


text:
Q: Node.Js: Unable to access values from returned mongodb object On querying my mongodb collection, I am getting the following output:
var test =[{"_id":"54075a2f4cb76dee03052bfa","Pincode":700065,"Country":"India","City":"Kolkata","RoomId":"Bedroom","HomeId":"Mysweethome","MACID":"imp","UUID":"54075954706221ea0389289f","__v":0}]
However, when I try to access each key-value pair individually using test._id, the output comes out to be undefined! What is the mistake that I'm making?

A: test is an Array of objects. You need to loop through them or access them by index: test[0]._id.


text:
Q: WhatsApp Automation with Selenium & JS I have been trying to replace execCommand() since it is obsolete/deprecated, but nothing seems to works. The below code works fine but I am checking if there is a better way?
This is the JS I used btw;
def insert(value, driver):
    script_insert = f'''
        const el = document.querySelector('div[title="Type a message"]');
        el.focus();
        document.execCommand('insertText', false, '{value}');
    '''
    driver.execute_script(script_insert)

    script_send = f'''
            const button = document.querySelector('button[data-tab="11"]');
            button.click()
        '''
    driver.execute_script(script_send)

A: Based on this answer Document.execCommmand() is not substituted by anything, so you can continue using that until it will not work anymore.
Another option is to find the input tag in the WhatsApp HTML and then use el.value = value.
Last idea could be using an already working and supported library like whatsapp-web.js in Node.JS if this is compatible with your project.


text:
Q: SQL needed to determine id in data set I am not able to arrive at a reasonable SQL that will return the required id's given the following data set and rules. The id's returned should be 1, 5 and 6.
Rule1 - Return id if both Alcohol and Drug categories are present and Alcohol <= 3 and Drug = No
Rule2 - Return id if only Alcohol category is present and Alcohol <= 3
Rule3 - Return id if only Drug category is present and Drug = No
id  Category Value
1   Alcohol  0
1   Drug     No
2   Alcohol  5
2   Drug     Yes
3   Alcohol  3
3   Drug     Yes
4   Alcohol  5
4   Drug     No
5   Alcohol  2
6   Drug     No
7   Alcohol  5
8   Drug     Yes

Thanks in advance.
select
    dt.id
from
(
    select
        id as id
    from
        @datatbl
    group by
        id
    having
        count(*) = 1
) X
inner join @datatbl dt on
    dt.id = X.id
where
    dt.value in ('0', '1', '2', '3', 'No')
union
select
    dt1.id
from
    @datatbl dt1
    inner join (
        select
        dt.id
        from
        (
            select
                id as id
            from
                @datatbl
            group by
                id
            having
                count(*) = 2
        ) X
        inner join @datatbl dt on
            dt.id = X.id
        where
            dt.category = 'Alcohol'
            and
            dt.value in ('0', '1', '2', '3')
    ) X on
        X.id = dt1.id
where
    dt1.category = 'Drug'
    and
    dt1.value in ('No')

A: Rule1:
SELECT *
FROM MyTable t1
INNER JOIN MyTable t2 ON t1.id = t2.id
  AND t1.Category <> t2.Category AND t2.Category = 'Drug'
WHERE t1.Category = 'Alcohol' AND t1.Value <= 3 AND t2.Value = 'No'

Rule2:
SELECT *
FROM MyTable t1
LEFT JOIN MyTable t2 ON t1.id = t2.id
  AND t1.Category <> t2.Category AND t2.Category = 'Drug'
WHERE t1.Category = 'Alcohol' AND t1.Value <= 3 AND t2.Category IS NULL

Rule3:
SELECT *
FROM MyTable t1
RIGHT JOIN MyTable t2 ON t1.id = t2.id
  AND t1.Category <> t2.Category AND t2.Category = 'Drug'
WHERE t2.Value = 'No' AND t1.Category IS NULL


text:
Q: Can the word "there" refer to multiple places? Probably a silly question, but can the word "there" refer to more than one place?
Consider the following sentence:
"I visited City A and City B again even though I went there last year."
Can "there" refer to both cities? Or should I use the following instead?
"I visited City A and City B again even though I went to them last year."

A: There provides a reference to the last-named place.

I visited City A and City B again even though I went there last year.

Here the reader understand that there refers to City B. If you wish to refer to multiple places, it's best (i.e., less ambiguous) to use your "them" construction instead.

I visited City A and City B again even though I visited them last year.

Here the pronoun them covers the entire list.


text:
Q: CA common to two servers under load balancer I would like to set up a TLS authentication on the two-server setup with a load balancer that spreads traffic between them. I do not have access to the load balancer, so I need to set up both servers separately. I need a certificate that would be signed by my own CA that I can pass on to the client which I want to authenticate. I know that it is possible to create a CA that is common for both servers, I am not sure how though. Is it as simple as creating a CA on each server with the same configuration?
I would appreciate some guidance.

A: TLS uses TCP connections, so the load balancer will only balance the establishment of TCP connections. After that the client is tied to any one of the two servers.
The certificate the servers present to their clients should match the URL or IP of the load balancer, so the clients can check if the certificate matches what they intended to connect to.
If you expose which backend server the client has reach (eg. because the load balancer redirects the connection, instead of tunneling it), your servers will probably need a wildcard certificate.


text:
Q: R connections to Snowflake produce verbose output After a system update some R-functions that are used to connect to Snowflake are producing pages of console output containing connection information:
Example: first lines of output, followed by lots more
Some example functions where the error occurs:
source()
dbGetQuery()
dbConnect()

I already tried calling the functions arguments (e.g. verbose=false, echo=false ...) and changing the global settings. I was not able to reset the console output to what I was used to see:
A simple confirmation running the code (connection) successfully.


text:
Q: I installed Maven Integration in the Eclipse but I can't create Maven POM file! Why? I installed Maven Integration in the Eclipse and now, I want to create a POM.xml. but I don't see Maven POM file item in  new project window. why?

A: This is how it works in Indigo with m2e 1.0.100:
File -> New -> Other... -> Maven -> Maven project

A: Or you can add pom to existing Java project by:

Right click on project>Confugure>convertToMavenProject

It will add Maven functionality to the Project.


text:
Q: node.js WebSocket Server currently i try to create a push server instance for new activities around our database. Of course, you find a lot of information about this topic.
I'm using:
http://static.brandedcode.com/nws-docs/#s6-p1
With the following client implementation:
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

        <script src="http://cdn.socket.io/stable/socket.io.js"></script>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>

        <title></title>
    </head>
    <body>
        <script type="text/javascript">
            (function() {
                var webSocket = new io.Socket('ws//test', {
                    port: 8080
                });

                webSocket.connect();

                webSocket.on('connect',function() {
                    console.log('Client has connected to the server!');
                });

                webSocket.on('message',function(data) {
                    console.log('Received a message from the server!',data);
                });

                webSocket.on('disconnect',function() {
                    console.log('The client has disconnected!');
                });

                window.ws = webSocket;
            }());
        </script>
    </body>
</html>

The console returns:
Unexpected response code: 404
XMLHttpRequest cannot load http://ws//test:8080/socket.io/xhr-polling//1303822796984. Origin http://test is not allowed by Access-Control-Allow-Origin.
1303822796984GET http://ws//test:8080/socket.io/xhr-polling//1303822796984 undefined (undefined)

I don't know the problem.
Thanks for your help.
Greets!

A: You´re trying to connect directly to a WebSocket server using Socket.io.
If you are running only a WebSocket server and not the Socket.io server, the you can use the normal HTML5 API to connect to websockets.
for example:
var ws = new WebSocket("ws://domain:port");
ws.onopen = function(){}
ws.onmessage = function(m){}
ws.onclose = function(){}

What browser are you using?
WebSockets are currently only supported by Google Chrome. Tests in other browsers will fail.

A: You probably wanted 'ws://push.xxx.binder.test' instead of 'ws//push.xxx.binder.test' (missing colon).

A: change
var webSocket = new io.Socket('ws//push.xxx.binder.test', {

to
var webSocket = new io.Socket('push.xxx.binder.test', {

You no need to add prefix for your domain for socket.io (especially without colon before slashes). Also var webSocket isn't good naming - socket.io can use not only websockets (even in your errors it using xhr-poliing)


text: Q: Ignore vendor directories in Ember rtl css We have an Ember application, where we are converting both the Vendor CSS and custom CSS into RTL CSS. We would like certain parts of vendor CSS to not be converted to RTL format. Can we exclude certain files from being converted


text:
Q: Angularjs - Clearing sticky state in angular ui-router I am trying to add multiple tabs in my angularjs application.
On click of any menu item, I open the view in a new tab.
User have a optin to close any existing tab and he can click the menu option again to opne the view again as a tab.
Till now all this is working fine, but the issue is when the tab is closed I am not able to clear the previous sticky state. When user clicks on the same menu the new view is loading with the previous state.
On the close tab action I am trying to clear the state as following.
 $stickyState.stateInactivated($state.$current)
 $stickyState.reset('tabs.survey')

My routing for the tab is as following.
 $stateProvider.state('tabs.survey', {
        url: '/survey',
        sticky: true,
        views: {
            'survey': {
                templateUrl: 'partials/survey.html',
                controller : 'surveyController'
            }
        }
    });

A: I applied a workaround/hack to fix this issue
I added a new parameter to the route as following.
 $stateProvider.state('tabs.survey', {
        url: '/survey/:ts',
        sticky: true,
        views: {
            'survey': {
                templateUrl: 'partials/survey.html',
                controller: 'surveyController'
            }
        }
    });

Added the module run configruation like following.
app.run(function ($state, $rootScope, $stateParams) {
    $rootScope.$state = $state;
    $rootScope.$stateParams = $stateParams;
})

Finally on creating of a new tab item, I tried to changed the parameter to refresh the old state as following.
 $state.go('tabs.survey', { "ts": 1 });
  $state.go('tabs.survey', { "ts": 0 });

This is just a workaround. There can be some better solution for this, which I am not sure at this point of time.
All suggestions are welcome.


text:
Q: Bot Framework Emulator - Cannot connect to local bot I am trying to connect to a local bot which has been pulled from a shared repo. Other developers have had this running and connected successfully. Points I have checked:

*

*App is running.

*Correct URL

*Correct AppId/AppPassword

*I have also tried both with/without ngrox.

Error/warning recieved:  Taking longer than usual to connect
Any ideas what might be causing this to only fail on my machine?

A: I finally figured this out. Running under IIS Express caused this issue for me. Changing to use the CLI and command dotnet run instead solved the issue.
Very bizzarre, I should think a re-install of IIS-Express will then sort it out. Thanks for the comments though.


text:
Q: i need to have 2 iframes on one page, one top of the other So i need to create an html page with 2 iframes on one page, one top of the other... The top one will take up most of the page and the bottom one will be about 80px high... View JSFiddle below.
The code i have seems to work but I notice when ever I scroll certain pages the scroll jumps around a bit... its not always a smooth scrolling experience... So my question is...
Is there a better way of achieving what I am try to do? or is this the best way?
html

css
#frame1 {
   background-color: #0099ff;
   position: absolute;
   top: 0px;
   left: 0px;
   bottom: 80px;
   right: 0px;
}

#frame2 {
   background-color: #000000;
   position: absolute;
   top: 0px;
   left: 0px;
   bottom: 0px;
   right: 0px;
}

heres a jsfiddle (http://jsfiddle.net/jstormthakid/TMSwq) of the code also.
Any help would be greatly appreciated...

A: DEMO HERE
html,body {
    height:100%;
}
.h_iframe1 iframe {
    position:absolute;
    top:0;
    left:0;
    width:100%;
    height:calc(100% - 120px);
}
.h_iframe2 iframe {
    position:absolute;
    bottom:0;
    right:0;
    width:100%;
    height:120px;
}

I you want no scroll bar visible in first iframe demo here
.h_iframe1 iframe {
    position:absolute;
    top:0;
    width:100%;
    height:calc(100% - 120px);
    right: -30px;
    padding-right: 15px;
    overflow-y: scroll;
}


text:
Q: Entity framework migrations with a modular application Im building a modular application. Some modules will be extensions on other modules. Every module is having its own project structure with services etc. Though some entities are shared between them.
This is the structure:
Shared
    - Entity A
    - Entity B
    - Entity C
Module A
   Entities
    - Entity D
    - Entity E
    - Entity F
   Dbcontext
     - Ent A, B, C, D, E, F
Module B
   Entities
    - Entity X
    - Entity Y
    - Entity Z
   Dbcontext
     - Ent A, B, C, X, Y, Z

All tables are in a shared database (this is because it could be in the feature that there will be a module that has entities A, D, X).
How can I migrate database changes with entityframework? What I would like is as long as it is a extension to the tables (so no destuction) that it just adds the tables and fields. If there is any destruction I'm ok with doing them manual.
P.S. Seperating the databases is in this scenario not an option due to performance reasons of joins and stuff.


text:
Q: Custom Membership Provider and MembershipUser I have simple question. I'm now thinking about creating custom membership provider for my app, because using separate tables for membership and for rest of the app is not that good idea.. not to mention some data is simply replicated along tables..
What I want to know, if I also have to reimplement other functionaly like checking if user is online, and so on. Or it's just enough if i copy part of db structure and implement provider ?
UPDATE!
What I really want to know is the methods from MembershipUser (like checking IF user IsOnline and so on), will work on custom database schema.
I know how to implement custom provider, I just want to know if I have more tedious work implementing functionality from other Membership* classes.

A: Separate Tables for membership and for rest of the app is not a good idea?  It has to be in a different table. Maybe you meant separate databases.
Any way, you do not need to impolement all methods. Here are the necessary methods you have to implement:
public class CustomMembershipProvider : MembershipProvider
{
  public override MembershipUser CreateUser(string username,
     string password, string email, string passwordQuestion,
     string passwordAnswer, bool isApproved,
     object providerUserKey, out MembershipCreateStatus status)
  {
      throw new NotImplementedException();
  }

  public override MembershipUser GetUser(string username, bool userIsOnline)
  {
      throw new NotImplementedException();
  }

  public override bool ValidateUser(string username, string password)
  {
      throw new NotImplementedException();
  }

  public override int MinRequiredPasswordLength
  {
      get { throw new NotImplementedException(); }
  }

  public override bool RequiresUniqueEmail
  {
      get { throw new NotImplementedException(); }
  }
}

You can find dozens of examples on the net. Some are:
http://www.asp.net/general/videos/how-do-i-create-a-custom-membership-provider
http://www.davidhayden.com/blog/dave/archive/2007/10/11/CreateCustomMembershipProviderASPNETWebsiteSecurity.aspx
http://www.shiningstar.net/aspnet_articles/customprovider/CustomProvider.aspx
http://www.devx.com/asp/Article/29256/0/page/3
http://www.15seconds.com/issue/050216.htm
http://www.codeproject.com/KB/aspnet/CustomMembershipProviders.aspx
http://www.codeproject.com/KB/aspnet/WSSecurityProvider.aspx

A: You don't need to implement the full MembershipProvider.  Just implement the bits you need, and for the other unused methods throw a NotImplementedException.

A: What's the best approach if I have some overriden methods that really just need to behave the same as the abstract method?
Example.
public override bool ValidateUser(string username, string password)
{
//      This won't work but I need something like this
        return Membership.ValidateUser(username, password);
}


text:
Q: Can Leaflet jump to new world copy on zoom instead of just on panning? The markers will appear on the map if I pan the map, but if I zoom out and then zoom in on a copy of the map without the markers, they will not appear until I pan again.
Is it possible to change this so that zooming in and out will cause the markers to recalculate on the map?

L.map('map', {
  'center': [0, 0],
  'zoom': 0,
  'worldCopyJump': true,
  'layers': [
    L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
      'attribution': 'Map data © OpenStreetMap contributors'
    }),
    L.marker([0, -135]),
    L.marker([0, -90]),
    L.marker([0, -45]),
    L.marker([0, 0]),
    L.marker([0, 45]),
    L.marker([0, 90]),
    L.marker([0, 135])
  ]
});
body {
    margin: 0;
}
html, body, #map {
    height: 100%
}
<link href="https://unpkg.com/leaflet/dist/leaflet.css" rel="stylesheet"/>

http://embed.plnkr.co/mWKc4M/

A:
The markers will appear on the map if I pan the map

Specifically, this behaviour happens only when dragging the map (and not when panning the map via any other method, e.g. using keyboard shortcuts). This is because, internally, the worldCopyJump functionality is defined inside the Drag handler at src/map/handler/Map.Drag.js:
// TODO refactor, move to CRS
// @option worldCopyJump: Boolean = false
// With this option enabled, the map tracks when you pan to another "copy"
// of the world and seamlessly jumps to the original one so that all overlays
// like markers and vector layers are still visible.
worldCopyJump: false,

(Do note that Leaflet has an explanation of what map handlers are and how they work)
As the code stands now, the worldCopyJump functionality affects only the dragging handler, and works by resetting the drag offset (instead of the map center) every time the map dragging handler is about to be updated:
if (map.options.worldCopyJump) {
    this._draggable.on('predrag', this._onPreDragWrap, this);
    map.on('zoomend', this._onZoomEnd, this);

    map.whenReady(this._onZoomEnd, this);
}
/* snip */
_onPreDragWrap: function () {
    // TODO refactor to be able to adjust map pane position after zoom
    var worldWidth = this._worldWidth,
        halfWidth = Math.round(worldWidth / 2),
        dx = this._initialWorldOffset,
        x = this._draggable._newPos.x,
        newX1 = (x - halfWidth + dx) % worldWidth + halfWidth - dx,
        newX2 = (x + halfWidth + dx) % worldWidth - halfWidth - dx,
        newX = Math.abs(newX1 + dx) < Math.abs(newX2 + dx) ? newX1 : newX2;

    this._draggable._absPos = this._draggable._newPos.clone();
    this._draggable._newPos.x = newX;
},

So, what to do? An option is to leverage wrapLatLng to reset the map center on every zoomend event, e.g.:
map.on('zoomend', function(ev){
    map.panTo(map.wrapLatLng(map.getCenter()), {animate: false})
});

That should just work. See a working demo.

As an alternative, consider using https://gitlab.com/IvanSanchez/Leaflet.RepeatedMarkers , which will create copies of each marker every 360° of longitude.


text:
Q: what is the type of field in MYSQL that Can store Integer or Double Values I mean in the same column you can store integer || Doubles ? what is the type of field in MYSQL that Can store Integer or Double Values
I mean in the same column you can store integer || Doubles ?
What is this type or how can I do It?
Any efforts will be appreciates.

A: There is no native MySQL datatype that meets your requirements.
In general, a DECIMAL datatype fits the bill, although that is an exact decimal value, and not a float-type approximation. And since it has a fixed decimal point, the range of values that can be stored is several orders of magnitude smaller than the DOUBLE type.
One option is to use a VARCHAR column, and store a character representation of the value.
Another (unwieldy) option would be to use a BIT(64) column.
But it seems that with either of those approaches, you would need some type of indicator as to which type of value was stored. And there's several drawbacks to both of those approaches. One big drawback is that these would allow for "invalid" values to be stored.
An approach I would consider (if I had this requirement) would be to use two columns, one of them INTEGER, the other DOUBLE, and specify a precedence, and allow a NULL value in the INTEGER column to represent that the value was stored in the DOUBLE column.

A: INT - A normal-sized integer that can be signed or unsigned. If signed, the allowable range is from -2147483648 to 2147483647. If unsigned, the allowable range is from 0 to 4294967295. You can specify a width of up to 11 digits.
DOUBLE(M,D) - A double precision floating-point number that cannot be unsigned. You can define the display length (M) and the number of decimals (D). This is not required and will default to 16,4, where 4 is the number of decimals. Decimal precision can go to 53 places for a DOUBLE. REAL is a synonym for DOUBLE.

A: you can use double data type and in your language(php,ja) show that value as a integer.

A: I don't think there is such data type in mysql. Probably you might want varchar instead, and cast to  the right data type in your server side code(php, java ...), but it might cause performance overhead. I'm not sure how come you have a such strange data type requirement. If the data has to be stored in this way, consider add an extra column for flagging data type.

A: I think you maybe miss understand how computers store numbers: either a number is an integer or it is a floating point number.  There is different circuitry for each in a processors Arithmetic Logic Unit (ALU).  You cannot have a number that is both.


text:
Q: How to get a backbone model's ID on the server upon model's destruction I'm trying to use a Backbone model in my Marionette application. I have a collection view which correctly displays all entries I have for a specific model. The item view contains a delete button. It listens for clicks on that button, calling a delete function when such a click occurs:
events: {
    'click .deleteItem': 'deleteItem'
},
deleteItem: function (event) {
    console.log('id', this.model.id);
    this.model.destroy({ wait: true });

}

this.model.destroy correctly make a DELETE request to the myModel/ url, but it doesn't seem to include any information on which entry is to be delete. For example, on the server side (a Node.js server), I don't see anything in req.body (yes, I'm using the body parser). How do I get the id of the entry I'm trying to delete when responding to the DELETE request on the server side?
Note: I can get it easily enough on the client side: this.model.id

A: Use the route parameters:
app.delete('/thing/:id', function(req, res){
    console.log('deleting ' + req.params.id);
});

Then your model would look like this:
var ThingModel = Backbone.Model.extend({
    idAttribute: '_id', // or whatever your id attribute is
    urlRoot: '/thing'
});

Then you would delete it like so:
var someThing = new ThingModel({_id:123, foo:'bar'});
someThing.destroy();

It sounds like you did not declare the urlRoot of your model. Read up on it here.


text:
Q: trying to show android progress circle but it stalls the search I found on stack to add these lines for a progress circle:
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setProgressBarIndeterminateVisibility(true);
setProgressBarIndeterminateVisibility(false);

I have an action bar that has a search widget and it executes a search and shows the results in a list view once its gets the json back form an api and parses it.
When I add the above code into my search code like this, it never returns the results and I do not see the spinner at all:
try {

                //start progress bar
                requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
                setProgressBarIndeterminateVisibility(true);

                System.out.println(result);
                Log.d("asycTask", "[ Gets into asyc task ]");
                ///get
                Log.d("search", "[ check if we get search results ]");
                Log.d("search", "[" + result + "]");

                JSONObject json = new JSONObject(result);

                //acces listview
                lv = (ListView) findViewById(android.R.id.list);

                //make array list for beer
                final List<BeerData> beerList = new ArrayList<BeerData>();

                //get json items
                for(int i = 0; i < json.getJSONArray("data").length(); i++) {

                    String beerId = GetBeerDataFromJSON(i,"id", json);
                    String beerName = GetBeerDataFromJSON(i,"name", json);
                    String beerDescription = GetBeerDataFromJSON(i,"description" , json);
                    String beerAbv = GetBeerDataFromJSON(i,"abv" , json);
                    String beerIbu = GetBeerDataFromJSON(i,"ibu" , json);
                    String beerIcon = GetBeerIconsFromJSON(i, "icon",json );
                    String beerMediumIcon = GetBeerIconsFromJSON(i, "medium",json );
                    String beerLargeIcon = GetBeerIconsFromJSON(i, "large",json );
                    String beerGlass = GetBeerGlassFromJSON(i, json );
                    String beerStyle = GetBeerStyleFromJSON(i,"name", json );
                    String beerStyleDescription = GetBeerStyleFromJSON(i,"description", json );
                    String beerBreweryId = GetBeerBreweryInfoFromJSON(i, "id", json );
                    String beerBreweryName = GetBeerBreweryInfoFromJSON(i, "name", json );
                    String beerBreweryDescription = GetBeerBreweryInfoFromJSON(i, "description", json );
                    String beerBreweryWebsite = GetBeerBreweryInfoFromJSON(i, "website", json );
                    String beerBreweryYear = GetBeerBreweryInfoFromJSON(i, "established", json );
                    String beerBreweryIcon = GetBeerBreweryIconsFromJSON(i,"large",json);

                    //create beer object
                    BeerData thisBeer = new BeerData(beerName, beerId, beerDescription, beerAbv, beerIbu, beerIcon,
                            beerMediumIcon,beerLargeIcon, beerGlass, beerStyle, beerStyleDescription, beerBreweryId, beerBreweryName,
                            beerBreweryDescription, beerBreweryYear, beerBreweryWebsite,beerBreweryIcon);

                    //add beer to list
                    beerList.add(thisBeer);

                }

                //update listview
                ArrayAdapter<BeerData> adapter1 = new ArrayAdapter<BeerData>(MainActivity.this, R.layout.list_item, R.id.itemName, beerList);
                lv.setAdapter(adapter1);

                //set up clicks
                lv.setOnItemClickListener(new OnItemClickListener() {
                       @Override
                       public void onItemClick(AdapterView<?> arg0, View arg1,
                                                int arg2, long arg3) {
                              Intent i = new Intent(MainActivity.this, BeerPage.class);

                              BeerData beerInfo = beerList.get(arg2);

                              //Toast.makeText(MainActivity.this,  beerInfo.beerName, Toast.LENGTH_SHORT).show();

                              i.putExtra("myBeerObject",  beerInfo);
                              i.setClass(MainActivity.this, BeerPage.class);

                              startActivity(i);

                       }
                   });

                //end progress bar
                setProgressBarIndeterminateVisibility(false);

            } catch (Exception e) {
                Log.d("ReadBeerDataTask", e.getLocalizedMessage());
            }
        }
    }

The xml for the the listview is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    tools:context=".MainActivity" >

    <LinearLayout
        android:id="@+id/linlaHeaderProgress"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center"
        android:orientation="vertical"
        android:visibility="gone" >

        <ProgressBar
            android:id="@+id/pbHeaderProgress"
            style="android@style/Spinner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
        </ProgressBar>
    </LinearLayout>

    <ListView
        android:id="@android:id/list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:dividerHeight="0.1dp"
        >
    </ListView>

</LinearLayout>


text:
Q: Show that For $A$ closed in a metric space $(,)$ and $a$ isn't in A, $(,A):=inf[(a,x) : x \in A]$ > 0 I understand the problem. Since a isn't on A, then the distance between a to closest point of A to x will be larger than zero because there will always be some distance between them and that point will always be on the closure of A, but I don't know how I can show this in Analysis terms. Can you show me some ways please?  Thank you in advance.
Can I just say:
Let $a\in X, a \notin A$ and $y \in A$. Then $\forall y \in A$ , $dist(a,x)>0 \implies inf[(a,x)| x \in A] > 0$

A: Assume $d(A, a) =0$.
By definition of the infimum, there's an element $x_n\in A$ such that $d(x_n, a) <1/n$ for every positive integer $n$.
But then $x_n\to a$ follows, and if $A$ is closed, it implies $a\in A$.


text:
Q: Alert message not rotating in IOS8 I am building an iPhone app which shows an alert message when a particular button is tapped. Auto-rotaion is in ON state. When i rotate my phone the whole app view as well as the alert message rotates in iOS7 But, in iOS8 views are rotated except alert message`

A: UIAlertView does not work properly in iOS8 The, iOS8 uses a new UIAlertController The given linked worked for my case.
Reference Link

A: This is happening because the iOS not able to understand the multiple operation at a time .You can call the UIalertview with delay like .I have same issue with iOS8 this code is working fine for me.
[self performSelector:@selector(showAlert) withObject:nil afterDelay:0.5];

-(void)showAlert
{
    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Your alert Title." message:@"Your alert Message." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
    [alert show];
}


text:
Q: Overcurrent protection won't let motor spin up I'm using a TLE5205 H-Bridge to drive a small DC motor.
The setup works just fine with small load (an LED for example), however once I connect the motor, it won't spin, only flicks slightly each time the direction of the output current is changed.
I'm pretty sure this is caused by the integral overcurrent protection feature of the H-bridge, since the error flag pin state behaves according to this situation. The OC protection is set to trigger at I = 10A (As seen in the datasheet). When the motor spins continuously, this is more than enough space, since it draws a steady current of 0.7A at 7V, however, while stalled, the motor draws up to 21A which is a lot more than what the OCP tolerates.
The IC doesn't seem to have a current limiting feature aside from the OCP, which shuts it down completely. I could potentially connect a resistor in series with the motor to limit the current it draws, however this would also limit the overall power of the motor, which I don't want. Is there a way to solve this issue, preferably without having to redo the whole PCB which has already been manufactured?

A: If it really is the overcurrent protection you could slowly ramp the motor speed up using pwm.

A: You can limit startup current by adding resistance in series with the motor.
If your motor draws 21A at 7V when stalled then its internal resistance is 7V/21A = 0.33Ω. The TLE5205's overcurrent shutdown point is 6A minimum, and total switch resistance is typically 0.45Ω at 3A. To limit startup current to 6A you need a total resistance of 7V/6A = 1.17Ω. Therefore the extra resistance required is 1.17Ω-(0.45Ω+0.33Ω) = 0.39Ω.
At 0.7A the added resistance will reduce motor voltage by 0.7A*0.39Ω = 0.27V. The motor will run 0.27V/7V = 4% slower than it would without the added resistance. If the load varies then speed regulation will be a bit worse because the total circuit resistance is now 1.17Ω/(0.45Ω+0.33Ω) = 1.5 times higher.
With current limited to 6A the motor should get 6A*0.33Ω = 2V at stall. If this is not enough to start up then you will need a more powerful H-bridge which can deliver more current (and preferably also has a lower switch resistance).


text:
Q: Foundation to Tailwind CSS: grid-padding-x and grid-margin-x? How do we do gutters in Tailwind CSS?
My attempt with gap-4 below:

1

1

1

1

1

But the result is not what I am trying to achieve as the gutters in Foundation:

12/6/4 cells

12/6/8 cells

12/6/4 cells

12/6/8 cells

Is it gaps that I should look for in TW? Or something else?

A: Use space-x-<n> and/or space-y-<n> (Space Between) for flexbox.
Use gap-<n> (Gap) for grids.

<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">

Flex

Flex

Flex

Flex

Grid

Grid

Grid

Grid


text:
Q: How to draw the leads of the Controlled Current Source in a Box? \documentclass{article}
\usepackage{tikz}
\usepackage{circuitikz}
\usetikzlibrary{chains}
\begin{document}

\begin{tikzpicture}[
      start chain=going right,
      box/.style={
        on chain,join,draw,
        minimum height=3cm,
        text centered,
        minimum width=2cm,
      },
      every join/.style={ultra thick},
      node distance=5mm
    ]

    \node [on chain] {$in$}; % Chain starts here

    \node [box,xshift=5mm,label=above:Some] (rec) {
      \begin{circuitikz}[american currents]
        \draw (0,0) to[C] (0,2);
      \end{circuitikz}
    };

    \node [on chain,join,draw,
      text width=1cm,
      minimum width=2cm,
      text centered,
      minimum height=3cm,
      label=above:Six,
    ] (ic) {
      \begin{circuitikz}[american currents]
        %\draw (0,0) to[Do] (0,2);
        \draw (0,0) to[cI] (0,-2);
      \end{circuitikz}
    };

    \node [box,label=above:Five] (inv) {
      \begin{circuitikz}
        %\draw (0,0) node[nigbt] {};
        \draw (0,0) to[C] (0,-2);
      \end{circuitikz}
    };

    \node [on chain,join,xshift=5mm]{$out$};
    % Chain ends here

    % CU box
    \node [
      rectangle,draw,
      below=5mm of ic,
      minimum width=8cm,
      minimum height=1cm,
    ] (cu) {\textbf{XXX}};

    % PU box
    \node [
      rectangle,draw,
      above=2mm of cu,
      minimum width=8cm,
      minimum height=4cm,
      label=\textbf{YYY},
    ] (pu) {};

    % Connections between CU and PU
    \draw[<->] (rec.south) -- ++(0,-5mm);
    \draw[<->] (cu.north) to (ic.south);
    \draw[<->] (inv.south) -- ++(0,-5mm);
    \end{tikzpicture}
\end{document}

Hi all,
My question is that middle box labelled "Six", I wish to draw controlled current with both of its legs/leads from its two ends shown . At the moment, from the picture attached, it only shows one leg. Any help is appreciated.
Cheers,
Menghan

A: This is a good example of why you shouldn't call tikz inside a tikz node.
\documentclass{article}
\usepackage{tikz}
\usepackage{circuitikz}
\usetikzlibrary{chains}
\newsavebox{\tempbox}
\begin{document}

\savebox{\tempbox}{%
\begin{circuitikz}[american currents]
   \draw (0,0) to[cI] (0,-2);
\end{circuitikz}}

\begin{tikzpicture}[
      start chain=going right,
      box/.style={
        on chain,join,draw,
        minimum height=3cm,
        text centered,
        minimum width=2cm,
      },
      every join/.style={ultra thick},
      node distance=5mm
    ]

    \node [on chain] {$in$}; % Chain starts here

    \node [box,xshift=5mm,label=above:Some] (rec) {
      \begin{circuitikz}[american currents]
        \draw (0,0) to[C] (0,2);
      \end{circuitikz}
    };

    \node [on chain,join,draw,
      text width=1cm,
      minimum width=2cm,
      text centered,
      minimum height=3cm,
      label=above:Six,
    ] (ic) {\usebox{\tempbox}};

    \node [box,label=above:Five] (inv) {
      \begin{circuitikz}
        %\draw (0,0) node[nigbt] {};
        \draw (0,0) to[C] (0,-2);
      \end{circuitikz}
    };

    \node [on chain,join,xshift=5mm]{$out$};
    % Chain ends here

    % CU box
    \node [
      rectangle,draw,
      below=5mm of ic,
      minimum width=8cm,
      minimum height=1cm,
    ] (cu) {\textbf{XXX}};

    % PU box
    \node [
      rectangle,draw,
      above=2mm of cu,
      minimum width=8cm,
      minimum height=4cm,
      label=\textbf{YYY},
    ] (pu) {};

    % Connections between CU and PU
    \draw[<->] (rec.south) -- ++(0,-5mm);
    \draw[<->] (cu.north) to (ic.south);
    \draw[<->] (inv.south) -- ++(0,-5mm);
    \end{tikzpicture}
\end{document}

A: Alternative solution without nesting tikz/ciciutikz images:
\documentclass{article}
    \usepackage{circuitikz}
\usetikzlibrary{calc,fit,positioning}

    \begin{document}
    \begin{circuitikz}[american currents,
       box/.style = {draw,
                     inner ysep = 5mm,
                     minimum width=2cm,
                    },
      node distance=24mm
                        ]
\coordinate (some);
\coordinate[right=of some]  (six);
\coordinate[right=of six]   (five);
% electrical elements
\draw   (some) to [C]   ++ (0,-2) coordinate (some')
        (six)  to [cI]  ++ (0,-2) coordinate (six')
        (five) to [C]   ++ (0,-2) coordinate (five');
% boxes around electrical elements
\node (in)  [box,fit=(some) (some')]    {};
\node (mid) [box,fit=(six)  (six') ]    {};
\node (out) [box,fit=(five) (five')]    {};
% input, output
\node (input)  [left =8mm of in ] {$in$};
\node (output) [right=8mm of out] {$out$};
% Connections nodes on chain
\draw[ultra thick]  (input) -- (in)  (in)  -- (mid)
                    (mid)   -- (out) (out) -- (output);
% PU box
\node (pu)  [draw,inner sep=4mm, fit= (in) (out),
             label=\textbf{YYY}]        {};
% CU box
\path   let \p1 = (pu.west),
            \p2 = (pu.east),
            \n1 = {veclen(\x2-\x1,\y2-\y1)} in
        node [draw, minimum width=\n1, minimum height=10mm,
              below=4mm of pu] (cu) {\textbf{XXX}};
% Connections between CU and PU
\path[draw,thick,<->]
    (in) edge (in |- cu.north)
    (mid) edge (cu.north)
    (out)  --  (out |- cu.north);
    \end{circuitikz}
\end{document}

It gives the following image:


text:
Q: Xamarin Android WebView ZenDesk widget can't upload files I'm hosting the ZenDesk web widget in a Xamarin Forms WebView control. The widget is rendered correctly on both iOS and Android but only the iOS version is allowing file uploads from the device.
The Android version allows a file to be selected but after choosing a file nothing happens. I've implemented a custom WebView control for Android that allows file access which I use elsewhere to read a file from the device for displaying in the WebView:
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.WebView> e)
{
    base.OnElementChanged(e);
    if (Control?.Settings != null && e.NewElement != null)
    {
        Control.Settings.SetSupportMultipleWindows(false);
        Control.Settings.AllowFileAccess = true;
    }
}

Is it possible to upload files on Android using the ZenDesk widget in a WebView?


text:
Q: creating Basic authentication in Slim framework I had seen 2 questions on SO and several topics on google but that didn't helped me out

*

*Authentication Based REST API with Slim

*Securing a REST API and Slim Framework
Slim provides you different methods like PUT,GET,POST etc. I want to implement basic authorization like being implemented by many API's.
First question: Is SSL necessay? (I dont have currently)
Second question: How to implement it? as in i have to send username and password in headers in encrypted form and then after this I have to use this authentication in each API call
Any help?

A: You can use Slim Authentication and XSS Middlewares, for example HttpBasic.
So added the Extras to your Slim Framework:
https://github.com/codeguy/Slim-Extras/tree/master/Middleware
How to use it? As as this:
use \Slim\Slim;
use \Slim\Extras\Middleware\HttpBasicAuth;

$app = new Slim();
$app->add(new HttpBasicAuth('theUsername', 'thePassword'));

A: You should really use SSL because you'll be sending passwords (or API secrets) over the internet. If it's not encrypted, anyone in between the user and your server can steal those credentials.
That's right - you'll send the username/pwd in the headers. There are a lot of resources out there for how to do http basic authentication. For example, this SO question. You'll need to authenticate on each call because you're making a RESTful API (i.e. stateless, so you can't have an 'authorized' state).
I'm not sure off-hand how you would get the username and password, but I would think they'd be in $app->request->headers()


text:
Q: Display actual Image from Switch Function instead of URL text I've been working on a script and almost have it working except I need a div (id) to show an actual image and not just the URL of the image.
You can see it in this JSFiddle.
Also, I would like to display a background image to show as a default image... then once you select inputs, the image change over the background image.
Here is the part of the script that generates the URL
$('#show_image_text').html(image_name); // Put the image URL
    $('#show_image').html(image_name); // Put the image value in the formula image field src.
});

Here is the div where I am wanting to display the image. It may need to be styled for width, height, and background-image

A: Try to use:
$('#show_image').html("");

instead of:
$('#show_image').html(image_name);

A: change your code as follows:
$('#show_image').css('background-image',"url('"+image_name+"')");
Also, the div #show_image doesn't have any height set, so the image won't be visible unless you set it's height explicitly
#show_image{
 height:50px;
 width:200px;
 background-image:url('path to default image'); //you can set a default image like this, which will be overridden once you set the image in code...
}

updated JSFiddle


text:
Q: Angular2 - Interaction between components using a service I have two component A and B, where component A contains a button. I wish when user click on this button, fire a function on component B

<router-outlet></router-outlet>

And the component B is rendered using routing.I am considering using a service with an observable boolean that indicate if the button in A is clicked. Is this the right way to achieve it ?

A: Shared service is a common way of communication between non-related components.
Your components need to use a single instance of the service, so make sure it's provided at the root level.
An example using the BehaviorSubject as a data delegate:
Shared service:
@Injectable()
export class SharedService {

    isVisibleSource: BehaviorSubject<boolean> = new BehaviorSubject(false);

    constructor() { }
}

Component 1:
export class Component1 {

    isVisible = false;

    constructor(private sharedService: SharedService) { }

    onClick(): void {
        this.isVisible = !this.isVisible;
        this.sharedService.isVisibleSource.next(this.isVisible);
    }
}

Component 2:
export class Component2 {

    constructor(private sharedService: SharedService) { }

    ngOnInit(): void {
        this.sharedService.isVisibleSource.subscribe((isVisible) => {
            console.log('isVisible: ', isVisible); // => true/false
        });
    }
}

It is worth mentioning that BehaviorSubject upon a subscription returns the last value it holds, therefore the component from the example above will be updated with the most recent value immediately after the instantiation.
BehaviorSubject also allows to get its most recent value without even subscribing to it:
this.sharedService.isVisibleSource.getValue(); // => true/false

A: Angular Service
You have to use a service to communicate between your two components.
See https://angular.io/docs/ts/latest/cookbook/component-communication.html#!#bidirectional-service
Your service has a property event. So the component A can emit the event and the component B can subscribe to it.
Use RxJS to emit and subscribe to your event.

If my answer does not satisfy you. Please tell me and I will work on
  it.

A: STOP USING SERVICES FOR COMPONENTS INTERACTION!!!
Service is a stateless concept in programming, it can only rely on the input and other injected services to produce its output. Storing data inside service(although works) is counter-pattern (since your service is now stateful).
You can achieve what you need with binding @Input() and @Output() of components:
//main container html

<router-outlet (activate)="onRouterOutletActivate($event)"></router-outlet>

//main container ts
@ViewChild(ComponentA, {static: false}) a : ComponentA;
onRouterOutletActivate(event: ContainerOfB): void {
    this.activeRouteComponent = event;
    // make sure doStuff method is defined public in ComponentB
    // clickOutput is an @Output() on ComponentA which propagates click event
    this.a.clickOutput.subscribe(() => this.activeRouteComponent.b.doStuff());
}

//ContainerOfB, the container that has B in it
@ViewChild(ComponentB, {static: false}) b : ComponentB;

//ComponentA html
<button (click)="callback()">button</button>

//ComponentA ts
@Output() clickOutput: EventEmitter<void> = new EventEmitter<void>()
callback() { this.clickOutput.emit(); }

You would also achieve asynchronicity and reactiveness which is strongly emphasized by having rxjs in the core of Angular (whereas with service approach you won't).
I get that sharing service for component communication is less complex than the above approach but just because it works it doesn't mean you should do it. If you're locked out of your Mercedes, what would you rather do: breaking the window glass and unlocking the door or calling the locksmith to come over and unlock it.
p.s. Angular is dope hence the analogy(Mercedes)


text:
Q: Laravel / PHPUnit: Asserting sameness of two models When integration testing (using a database) in Laravel. What is the best way to assert that two instances of the same Eloquent model are the same?
AssertEquals $model $model
Simply using ->assertEquals($modelOne, $modelTwo); wont work as even if they are the same PHPUnit checks class properties such as wasRecentlyCreated  and sometimes model ids can be a string or an integer.
AssertEquals $model->id $model->id
The problem here is model one may be an instance of another model e.g:
AssertEquals(Person::find(1)->id, Animal::find(1)->id); returns true.
AssertEquals $model->toArray() $model->toArray()
The issue here is properties are not always cast as the same type, Im not 100% sure why but there are times a models properties will be an int and other times a number string
AssertEquals($address->toArray(), $user->address->toArray())
[ postcode => 2454 ]
[ postcode => "2454" ]

How to assert in a simple, clean and repeatable manner two Eloquent models are the same database record?

A: One option would be to use PHPUnit's assertTrue method combined with the is method on the Illuminate\Database\Eloquent class.
$this->assertTrue($modelOne->is($modelTwo));

The is method will return true if the model you pass as an argument is not null, has the same primary key, same table and same connection.
With regards to testing the sameness of attributes, you should be safe just using PHPUnit's assertEquals on each model's attributes, which you can retrieve using getAttributes.
$model1 = new Model(['id' => 1, 'name' => 'test', 'enabled' => 0, 'number' => '1']);
$model2 = new Model(['id' => 1, 'name' => 'test', 'enabled' => false, 'number' => 1]);

$this->assertEquals($model1->getAttributes(), $model2->getAttributes());

In my tests, I have found that these assertions pass. The assertEquals method compares values loosely, in that values are compared as using == rather than the strict comparison (or identity) operator, ===. Internally, it will sort both of the arrays provided, and loosely compare values with the same keys. If you have any extra attributes on one model but not the other, the assertion will fail as well.


text:
Q: Rubidium as hydrogen-like - optical pumping Rubidium is an alkali metal with only a single valence electron.
I read in a lot of optical pumping papers that this enables us to approximate it as hydrogen-like.
I am interested in the significance of this approximation. What does it allow us to do and why do we do it? How does it help us in our explanation of the theory of optical pumping?
Thanks
edit: it allows us to ignore the inner electrons, but my question is on the significance of this...


text:
Q: C# System.IO.FileInfo gets virtual address which has sessions key Okay so the following line returns null because its path cannot be found:
System.IO.FileInfo fi = di.GetFiles()[position];

What I am currently doing is:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<ctl:Gallery runat="server" ID="Gallery1" FolderUrl="~/images/1/" Size="100" />

When this is invoked System.IO.FileInfo fi = di.GetFiles()[position]; it has the value similar to this:
C:\Users\SomeUsername\Desktop\Tiamo\(S(mr1h0l55ycuixfbtqxbmttek))\images\1

Any idea how I can return the virtual path without actually having the session key in there? Thank you in advanced for any help you may give :) much appreciated.

A: If I understand your question correctly, this should help you:
var path = Path.GetFullPath(HttpContext.Request.MapPath(HttpContext.Request.ApplicationPath)
var listOfFiles = Directory.GetFiles(path);


text:
Q: Where are all the network-bridges coming from, ifconfig shows me? I'm using Ubuntu 18.04.3 LTS
As I'm a developer, I have Docker, docker-compose and Virtualbox and Vagrant installed
If I enter in a terminal:
$ ifconfig

I got  a long list of network bridges.
br-2fdf26d8ad11: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.240.1  netmask 255.255.240.0  broadcast 192.168.255.255

br-3097f1941dd7: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.32.1  netmask 255.255.240.0  broadcast 192.168.47.255

br-604e362c8abb: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.28.0.1  netmask 255.255.0.0  broadcast 172.28.255.255

br-6bec4010864a: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.23.0.1  netmask 255.255.0.0  broadcast 172.23.255.255

br-729cfdd5c2dd: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.48.1  netmask 255.255.240.0  broadcast 192.16628.63.255

br-72c49f160076: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.19.0.1  netmask 255.255.0.0  broadcast 172.19.255.255

br-765c8f8c1edf: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.18.0.1  netmask 255.255.0.0  broadcast 172.18.255.255

br-7b6ec7d56aec: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.31.0.1  netmask 255.255.0.0  broadcast 172.31.255.255

br-9392c09745cd: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.27.0.1  netmask 255.255.0.0  broadcast 172.27.255.255

br-97685d1968fe: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.26.0.1  netmask 255.255.0.0  broadcast 172.26.255.255

br-9b033123127c: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255

br-bc2ff863085c: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.96.1  netmask 255.255.240.0  broadcast 192.168.111.255

br-bcc4b1218247: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.30.0.1  netmask 255.255.0.0  broadcast 172.30.255.255

br-d7d1dd0718f3: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.80.1  netmask 255.255.240.0  broadcast 192.168.95.255

br-dd4949ff923c: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.25.0.1  netmask 255.255.0.0  broadcast 172.25.255.255

br-de108e80ee4d: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.21.0.1  netmask 255.255.0.0  broadcast 172.21.255.255

br-e37000236cd8: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.0.1  netmask 255.255.240.0  broadcast 192.168.15.255

br-ec26f968abd4: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.20.0.1  netmask 255.255.0.0  broadcast 172.20.255.255

br-fa80bcc7af95: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.24.0.1  netmask 255.255.0.0  broadcast 172.24.255.255

docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.29.0.1  netmask 255.255.0.0  broadcast 172.29.255.255

enp0s31f6: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether xx:xx:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>

vboxnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.22.101.1  netmask 255.255.255.0  broadcast 172.22.101.255

wlp4s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1492
        inet 192.168.2.5  netmask 255.255.255.0  broadcast 192.168.2.255

I'm not sure, where they all come from.
My problem is, that, if I want to use a public network (train, airports and so on), they normally run on 172.xx -> normally it's already used by a bridge, so I first have to bring it down and then delete it, as described in my blog
sudo ip link set br-bcc4b1218247 down
sudo brctl delbr br-bcc4b1218247

I also read, that if you use the Ubuntu Network Manager, they can all come back.
I was trying to understand, where they come from but I haven't understood it yet really.


text:
Q: Update axes when toggling series jquery flot I have a chart with 5 series that I can toggle through the legend as discussed here But when toggling the series they get removed but the axis doesnt get updated. I have added setupGrid() after setData() and before draw() but with no result. So I thought that Flot still counts the hidden series, so I tried to go through the code and look for the setupGrid and in every series loop I added a check so that the loops continues if the line is hidden and that just messed up the whole calculation. Then I just added a check for it when calculating x/y max/min and that gave the same problem.
What should I do to make it calulate the axis correctly?

A: You are correct, flot does not take into account the visibility of the series when calculating it's auto-scaling.  In version 0.8.1, the culprit is around line 1177, when it sets the datamax/datamin attributes.  It could skip the series if it's never going to be drawn:
if (s.lines.show == false &&
    s.points.show == false &&
    s.bars.show == false) continue;

BUT, I'd worry this would break plugins that introduce additional plot types.

So instead, I'd just mask the data off to make the auto-scaling work:
togglePlot = function(seriesIdx)
{
  var someData = somePlot.getData();
  someData[seriesIdx].lines.show = !someData[seriesIdx].lines.show;
  if (!someData[seriesIdx].lines.show){
      someData[seriesIdx].tempData = someData[seriesIdx].data;
      someData[seriesIdx].data = [];  // store old data and blank out real data
  }
  else
  {
      someData[seriesIdx].data = someData[seriesIdx].tempData; // restore real data
  }
  somePlot.setData(someData);
  somePlot.setupGrid();
  somePlot.draw();
}

Updated fiddle here.


text:
Q: How to render Inequalities in R Shiny SelectInput dropdown list I have created an R Shiny app using the shinydashboard package.  I cannot seem to get inequalities or unicode characters to appear in dropdown boxes using the selectInput function.  Can anyone help me figure out how to get a greater than or greater than or equal to sign (≥) appear in a dropdown?  Here is an example that demonstrates the issue:
library(shiny)
library(shinydashboard)
library(shinyjs)

ui <- shinyUI(dashboardPage(
  dashboardHeader(),
  dashboardSidebar(collapsed = FALSE,

                   selectInput("Age", "4. Select Age Group:",
                               c("\u2265 6 months" = "_6plus",
                                 "&ge 6 months" = "_6plus2",
                                 "≥ 6months" = "_6plus3",
                                 "≥ 6months" = "_6plus3",
                                 "6 months - 4 years" = "_6_4"))),

  dashboardBody(
    useShinyjs()
  )
))

server <- shinyServer(function(input, output, session) {
  #addClass(selector = "body", class = "sidebar-collapse")
})

shinyApp(ui = ui, server = server)

However, this none of the attempts seems to work.  I'd appreciate any assistance.  Thanks.

A: You can use the render option of selectizeInput to use HTML code in the choice names:
library(shiny)

render <- "
{
  option: function(data, escape){return '
'+data.label+'
';},
  item: function(data, escape){return '
'+data.label+'
';}
}"

ui <- fluidPage(
  selectizeInput(
    "age", "Age category",
    choices = c(
      "≤ 6 months" = 1,
      "6 months - 17 years" = 2,
      "≥ 18 years" = 3
    ),
    options = list(
      render = I(render)
    )
  )
)

server <- function(input, output){}

shinyApp(ui, server)

A: After working on this for quite some time, I found one solution, but I would still appreciate suggestions from others.  The only way I've been able to accomplish this is by placing the age categories in a UTF-8 text file, say agegroups.txt, reading in the file with the readr package, creating a named vector from the read-in tibble, and then using the vector to create the dropdowns.  Here is an example that works:
Text File:
≥6 months
6 months - 17 years
≥18 years

R Code:
library(readr)
agegroups <- unique(read_csv("d:\\\\agegroups.txt"))
agegroupchoices <- setNames(agegroups$AgeGroups, agegroups$AgeGroups)

ui <- shinyUI(dashboardPage(
  dashboardHeader(),
  dashboardSidebar(
    collapsed = FALSE,
    selectInput("Age", "4. Select Age Group:", agegroupchoices)
  ),
  dashboardBody(
    useShinyjs()
  )
))

server <- shinyServer(function(input, output, session) {})
shinyApp(ui = ui, server = server)


text:
Q: VHDL-2008 instantiation using hierarchical library path? What do you call a VHDL instantiation that looks like this?:
  Osvvm.TbUtilPkg.CreateClock (
    Clk        => Clk,
    Period     => Tperiod_Clk
  );

Is this new to VHDL-2008?  What are the rules to use this type of instantiation?  It looks like they also relaxed the rules to allow anonymous instance names?
Here's the code I took the above snippet of code out of:
library ieee ;
  use ieee.std_logic_1164.all ;
  use ieee.numeric_std.all ;
  use ieee.numeric_std_unsigned.all ;

library osvvm ;
context osvvm.OsvvmContext ;

library osvvm_AXI4 ;
context osvvm_AXI4.AxiStreamContext ;

entity TbStream is
end entity TbStream ;
architecture TestHarness of TbStream is

begin

  -- create Clock
  Osvvm.TbUtilPkg.CreateClock (
    Clk        => Clk,
    Period     => Tperiod_Clk
  );

end entity;


text:
Q: forkEpic, redux-observable 1.0.0-alpha.2, typescript I have one epic
type GetRailwaysEpic = Epic<GetRailwaysActions, AppState>;

const getRailwaysEpic: GetRailwaysEpic = (action$, state$) =>
  action$.pipe(
    filter(isActionOf(getRailways.request)),
    switchMap(a =>
      getRailways(state$.value.mileages.filters.date)
        .then(getRailways.success)
        .catch(getRailways.failure)
    )
  );

when I call anywhere actions.getRailways.request() it works as expected (REQUEST action first, SUCCESS of FAILURE next)
I have another epic
const initEpic: Epic<FiltersActions, AppState> = (action$, state$) =>
  action$.pipe(
    filter(isActionOf(init)),
    switchMap(({ payload: { date, depotId, locTypeId, railwayId } }) =>
      of(selectDate(date)).pipe(
        concat(
          forkEpic(getRailwaysEpic, state$, getRailways.request())
        )
      )
    )
  );

my ForkEpic function:
function forkEpic<T extends Action, S>(
  epicFactory: Epic<T, S>,
  state$: StateObservable<S>,
  ...actions: T[]
) {
  const actions$ = ActionsObservable.of(...actions);
  return epicFactory(actions$, state$, null);
}

What I want: 'init' action -> 'selectDate' action -> 'getRailways.request' action -> 'getRailways.success' | 'getRailways.failure' action
What I see: 'init' action -> 'selectDate' action -> 'getRailways.success' | 'getRailways.failure' action
'getRailways.request' action's missing somewhere.
What I do wrong?
P.S. getRailways - is a function which returns promise
P.P.S. I've found similar question here How to chain async actions and wait for the result without store.dispatch
But it's not what I'm actualy looking for.

A: So the issue is that the forkEpic function is invoking getRailwaysEpic locally and because it is using switchMap it is swallowing a "request" action thus preventing it to reach the epicMiddleware.
The best solution is to concat "select" action with "request" action streams and return it so it is correctly propagated by epicMiddleware back to the store and then it will be intercepted and handled by getRailwaysEpic from the action$ stream.
Here is the working solution in the code-sandbox:
https://codesandbox.io/s/375z2qwv1
Here is the responsible code:
const requestEpic = action$ =>
  action$.pipe(
    filter(a => a.type === 'request'),
    switchMap(a => from(makeRequest()).pipe(map(success)))
  );

const initEpic = action$ =>
  action$.pipe(
    filter(a => a.type === 'init'),
    concatMap(a => of(select(), request()))
  );

const rootEpic = combineEpics(requestEpic, initEpic);
const epicMiddleware = createEpicMiddleware(rootEpic);

// 1
// store.dispatch(init());
// should be:
// init -> select -> request -> success

// 2
// store.dispatch(request());
// should be:
// request -> success


text:
Q: How can I parse a specific cookie from this string in Java? say I have the following string in a variable
cookie-one=someValue;HttpOnly;Secure;Path=/;SameSite=none, cookie-two=someOtherValue;Path=/;Secure;HttpOnly, cookie-three=oneMoreValue;Path=/;Secure

and I want a substring from the name of a cookie that I choose say cookie-two and store the string up to the contents of that cookie.
So basically I need
cookie-two=someOtherValue;Path=/;Secure;HttpOnly

How can I get this substring out?

A: You can just separate the String by commas first to separate the cookies. For example if you wanted just the cookie that has the name cookie-two:
String s = "cookie-one=someValue;HttpOnly;Secure;Path=/;SameSite=none, cookie-two=someOtherValue;Path=/;Secure;HttpOnly, cookie-three=oneMoreValue;Path=/;Secure";

String[] cookies = s.split(",");
for(String cookie : cookies){
  if(cookie.trim().startsWith("cookie-two")){
    System.out.println(cookie);
  }
}

A: This is possible to achieve in several different ways depending on how the data might vary in the sting. For your specific example we could for instance do like this:
String cookieString = "cookie-one=someValue;HttpOnly;Secure;Path=/;SameSite=none, cookie-two=someOtherValue;Path=/;Secure;HttpOnly, cookie-three=oneMoreValue;Path=/;Secure";
String result = "";
for(String s: cookieString.split(", ")) {
    if(s.startsWith("cookie-two")) {
        result = s;
        break;
    }
}

We could also use regex and/or streams to make the code look nicer, but this is probably one of the most straight forward ways of achieving what you want.


text:
Q: Count posts for each category I have 3 MySQL tables:
Table1: Posts
id | date | postname | content
1 | 2014-07-17 | Post 1 | Content of post 1
2 | 2014-07-18 | Post 2 | Content of post 2
3 | 2014-07-19 | Post 3 | Content of post 3

Table2: Categories
id | category
1 | Category 1
2 | Category 2
3 | Category 3

Table3: Connection
id | post_id | category_id
1 | 1 | 1
2 | 1 | 2
3 | 2 | 2
4 | 2 | 3
5 | 3 | 1
6 | 3 | 2
7 | 4 | 3

I'm trying to display category names with number of posts to each category: example in this way:
Category 1 - 2 posts
Category 2 - 2 Posts
category 3 - 3 posts

I'm trying something like:
Select * FROM posts
inner join
connection on...

A: Since you just need the post count per category, you don't need to join the posts table. Joining to the connection table and grouping by the category will suffice.
select c.category, count(*)
from categories c
join connection co on co.category_id = c.id
group by c.category


text:
Q: When is the chi-squared test becoming virtually identical to a Fisher exact test? I am conducting several hypothesis tests for caterorical variables, with several groups being compared.
I routinely use the Fisher exact test in Stata, but occasionally it may get time consuming and computationally intensive, forcing me to switch to a standard chi-squared test.
I do that assuming that the chi-squared test becomes virtually identical to a Fisher exact test when the sample is quite large and cell counts are not too small.
Is this correct? If so, in which circumstances? I am particularly interested in the following scenarios (row cells x column cells, or vice versa):

*

*3 x 3

*3 x 4

*3 x 5

*4 x 4

*4 x 5

*5 x 5


text:
Q: Theano symbol names usage Say, we have initialized a variable:
import theano.tensor as T
x = T.dscalar('x')

What I don't understand is the purpose of the string argument. According to the doc:

By calling T.dscalar with a string argument, you create a Variable
  representing a floating-point scalar quantity with the given name. If
  you provide no argument, the symbol will be unnamed. Names are not
  required, but they can help debugging.

I'm not sure what it implies exactly. How would one use this argument and in which situations would it be relevant?
As it stands, the presented code
from theano import function
x = T.dscalar('x')
y = T.dscalar('y')
z = x + y
f = function([x, y], z)

runs just as well if I remove the arguments from the initialization
x = T.dscalar()
y = T.dscalar()

or use any other symbols, even same ones for both, functionality doesn't seem to change.
What adds to confusion is that both variable and argument are 'x'. Is it ever useful to name it differently x = T.dscalar('var1')?
So, in what circumstances is this argument useful?

A: Debugging.
import theano as th
import theano.tensor as T
x = T.scalar()
y = T.scalar()
th.printing.pp(x+y)
#'(<TensorType(float32, scalar)> + <TensorType(float32, scalar)>)'
x = T.scalar('x')
y = T.scalar('y')
th.printing.pp(x+y)
#'(x + y)'

Also this one:
>>> x,y = T.scalars('xy')
>>> fn = th.function([x,y], x+y)
>>> th.printing.debugprint(fn)
HostFromGpu(gpuarray) [id A] ''   3
 |GpuElemwise{Add}[(0, 0)]<gpuarray> [id B] ''   2
   |GpuFromHost<None> [id C] ''   1
   | |x [id D]
   |GpuFromHost<None> [id E] ''   0
     |y [id F]

If you have a large model, giving symbolic variables some name can really help when you call theano.printing.pp or theano.printing.debugprint.
Sometimes, the model may crash due to shape mismatch or other errors, if you have exception_verbosity = high in .theanorc, the relevant model graph is dumped as in theano.printing.debugprint. With defined name, the dump may look much better and reduce your time spent in debugging.


text:
Q: The html menu collapses but does not move to the specified id I have a jquery code which moves "a" element after clicking on the link to the given id given in the link in href.
HTML code snippet:

        <button class="navbar-toggler custom-toggler" type="button" data-toggle="collapse" data-target="#menu_apietrzak">

        </button>

                Home
                O nas
                Oferta

                Kontakt

            tel. +48 500 192 282

My JQUERY CODE:
(jquery-3.4.1.min.js)

The menu is hidden, but the page does not move. I would like the menu to hide and go to a specific id at the same time.
You might go to the link: www.apietrzak.pl, when you want to see the page.
Thank for help!

A: You are including jQuery in the footer of your page, but you are using it as inline script. If you look at your console, you will see that JQuery is not defined when you are trying to use it.
You should rework your script so that it will be executed only when JQuery is already present. For example (not the best way) move your inclusion to the head of the document.

A: add a reference to jquery to Head:

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>APIETRZAK - Rental of construction machinery, vehicle mechanics</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" crossorigin="anonymous">
    <link rel="stylesheet" href="css/style.css">
    <link href="css/all.css" rel="stylesheet">
    <link rel="apple-touch-icon" sizes="57x57" href="images/icon/apple-icon-57x57.png">
    <link rel="apple-touch-icon" sizes="60x60" href="images/icon/apple-icon-60x60.png">
    <link rel="apple-touch-icon" sizes="72x72" href="images/icon/apple-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="76x76" href="images/icon/apple-icon-76x76.png">
    <link rel="apple-touch-icon" sizes="114x114" href="images/icon/apple-icon-114x114.png">
    <link rel="apple-touch-icon" sizes="120x120" href="images/icon/apple-icon-120x120.png">
    <link rel="apple-touch-icon" sizes="144x144" href="images/icon/apple-icon-144x144.png">
    <link rel="apple-touch-icon" sizes="152x152" href="images/icon/apple-icon-152x152.png">
    <link rel="apple-touch-icon" sizes="180x180" href="images/icon/apple-icon-180x180.png">
    <link rel="icon" type="image/png" sizes="192x192" href="images/icon/android-icon-192x192.png">
    <link rel="icon" type="image/png" sizes="32x32" href="images/icon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="96x96" href="images/icon/favicon-96x96.png">
    <link rel="icon" type="image/png" sizes="16x16" href="images/icon/favicon-16x16.png">
    <link rel="manifest" href="images/icon/manifest.json">

    <meta name="msapplication-TileColor" content="#ffffff">
    <meta name="msapplication-TileImage" content="images/icon/ms-icon-144x144.png">
    <meta name="theme-color" content="#ffffff">
    <link type="text/css" rel="stylesheet" charset="UTF-8" href="https://translate.googleapis.com/translate_static/css/translateelement.css">


text:
Q: Kotlin validate edittext for entry and length We have an EditText that is inputType numberDecimal and we can validate the number entered and if no value was entered. Our question is how to incorporate both in to one if statement or is this even possible. The code below runs with no issues until we try to add this length test to the value enter test with this line of code
if( F.toInt() < 1 || S.toInt() > 7 || L ==0  ){
    fun weekDAY(view: View?){

    val L:Int = etValOne.length()
    if(L == 0){

        toast("Check The Entry\nValid Entry 1 to 7")
        return@weekDAY
    }

    val F: String = etValOne.text.toString()
    val S: String = etValOne.text.toString()

    if( F.toInt() < 1 || S.toInt() > 7 ){
        toast("Check The Entry\nValid Entry 1 to 7")
        return@weekDAY
    }

    var dayOfWeek: String = etValOne.text.toString()
    var dayOfWeekInString = when(dayOfWeek.toInt()) {
        1 -> "Monday"
        2 -> "Tuesday"
        3 -> "Wednesday"
        4 -> "Thursday"
        5 -> "Friday"
        6 -> "Saturday"
        7 -> "Sunday"
        else -> "Invalid Day"
    }

    etANS.setText(dayOfWeekInString)
}

We understand the else statement in the when method we are trying to develop ERROR trapping methodology. Yes we have looked at other posts that is how we were able to write the two error check. No post had both values checked!

A: In your function you have duplicate unnecessary coding.
I try to simplify it:
fun weekDAY(view: View?){
    val F: String = etValOne.text.toString().trim()
    val L: Int = F.length
    var value = 0
    try {
        value = F.toInt()
    } catch (e: NumberFormatException) {
    }

    if((L == 0) || (value !in 1..7)) {
        toast("Check The Entry\nValid Entry 1 to 7")
        return@weekDAY
    }

    val dayOfWeekInString = when(value) {
        1 -> "Monday"
        2 -> "Tuesday"
        3 -> "Wednesday"
        4 -> "Thursday"
        5 -> "Friday"
        6 -> "Saturday"
        7 -> "Sunday"
        else -> "Invalid Day"
    }

    etANS.setText(dayOfWeekInString)
}

As you can see you need to get the string from the EditText etValOne only once: F Then you get its length: L
then you get the numeric value: value surrounded by try/catch so if the string is empty or not numeric the app will not crash.
After that you have only 1 if that checks both the lengh and the value.
The else part of the when statement will never be executed.
If you want the string "Invalid Day" to be displayed in the EditText etANS in case of invalid value then this must be coded inside the if block.
The above code can be simplified even more (but I kept your original logic) like this:
fun weekDAY(view: View?){
    val F: String = etValOne.text.toString().trim()
    var value = 0
    try {
        value = F.toInt()
    } catch (e: NumberFormatException) {
    }

    val dayOfWeekInString = when(value) {
        1 -> "Monday"
        2 -> "Tuesday"
        3 -> "Wednesday"
        4 -> "Thursday"
        5 -> "Friday"
        6 -> "Saturday"
        7 -> "Sunday"
        else -> {
            toast("Check The Entry\nValid Entry 1 to 7")
            "Invalid Day"
        }
    }
    etANS.setText(dayOfWeekInString)
}

This way you don't need to check explicitly the length because if it is 0 then a NumberFormatException will be caught by the catch statement and the variable value will remain 0. So the when statement later on will return "Invalid Day"

A: Though the above answer is correct but I would like to add something. Value to editText should not be set inside the method body rather it should return the valid day or error. Function will be doing its stand-alone task in this way and will be testable.
fun weekDAY(view: View?) : String{
    val F: String = etValOne.text.toString().trim()
    var value = 0
    try {
        value = F.toInt()
    } catch (e: NumberFormatException) {
    }

    return when(value) {
        1 -> "Monday"
        2 -> "Tuesday"
        3 -> "Wednesday"
        4 -> "Thursday"
        5 -> "Friday"
        6 -> "Saturday"
        7 -> "Sunday"
        else -> {
            toast("Check The Entry\nValid Entry 1 to 7")
            "Invalid Day"
        }
    }
}