text:
Q: Confused with shell script reading CSV data from file I'm fairly new to Linux/CentOS and shell scripting. Let's say I have a file named useraccounts.list. This file contains CSV data in this specific order:
first name, middle initial, last name, username, password

for example:
John,N,Snow,seords,cuai2Ohzdh

What I'm trying to do is traverse through this list creating user accounts from the provided data, and with the password at the end of each line. I would like to store it using the passwd command for each individual user.
Here is what I have so far:
#!/bin/sh
for i in 'more useraccounts.list'
do
        echo "$1 $2 $3 $4 $5 $6"
done <file.txt

Can someone please help me out?

A: Before you get to how you will store the password, you need to sort out how you will read the values from the file correctly. In bash, the primary tool for determining how the shell will break a line into individual tokens is the Internal Field Separator (default: space tab newline). The process is called word-splitting The IFS variable allows you to set the characters that will control word-splitting.
You can use that to your advantage in reading lines such as yours by including a comma in IFS. This will allow you to specify individual variable to read each name, initial, last, user name and password into. A while loop is the normal way to accomplish this -- and it allows you to set the IFS for that block of code without effecting the remainder of the script.
An Example, in your case, would be:
#!/bin/bash

[ -z "$1" ] && {    ## validate one argument given on command line
    printf "error: insufficient input. usage: %s filename.\n" "${0##*/}"
    exit 1
}

[ -r "$1" ] || {    ## validate it is a readable filename
    printf "error: file not found/readable '%s'.\n" "$1"
    exit 1
}

## read each line in file separated by ','
#  set Internal Field Separator to break on ',' and '\n'
#  protect against lack of '\n' on last line with $pw test
while IFS=$',\n' read -r first mi last uname pw || [ -n "$pw" ]; do

    printf "name: %-5s %s. %-6s user: %s  pass: %s\n" \
        "$first" "$mi" "$last" "$uname" "$pw"

    ## Create User Accounts/Store Password Here...

done <"$1"

exit 0

Input
$ cat dat/useracct.txt
John,N,Snow,seords,cuai2Ohzdh
Jill,O,Rain,reords,cuai3Ohzdh
Jane,P,Sleet,peords,cuai4Ohzdh

Output
$ bash readuserfile.sh dat/useracct.txt
name: John  N. Snow   user: seords  pass: cuai2Ohzdh
name: Jill  O. Rain   user: reords  pass: cuai3Ohzdh
name: Jane  P. Sleet  user: peords  pass: cuai4Ohzdh

You can then create the user accounts with the desired options and store the password any way you like. Let me know if you have any questions.


text:
Q: Textboxes validate by Dropdownlist VB aspx.net
I have a few textboxes and a dropdownlist. Value input by user in the textbox will look something like this (00000000000000015010000000000). mid(16,4) will be the date (yymm) that i need to cross check with the dropdownlist.
For example the user select 1 year in the dropdownlist application take today date subtraction the value input by user if its more than the dropdownlist selected value warn the user that the value input is wrong.

A: Do you mean you want to pop an error message if the year/date selected is more than one year in the future?

*

*First thing, use a DateTimePicker control, NOT a TextBox
Then, you'll want to compare the value of this DateTimePicker, and put it into an If statement
Dim dateToCheck As Date = DateTimePicker1.Value

If dateToCheck > Date.Today.AddYears(1) Then
   MessageBox.Show("This is not a valid date.", "Error")
   Exit Sub
End If

Alternatively, you can validate the DateTimePicker control to not allow dates over/before a certain date.
DateTimePicker1.MaxDate = Today.AddYears(1)
DateTimePicker1.MinDate = Today

redpajama_set_name: RedPajamaStackExchange


text:
Q: Sum up child values and save the values calculated in intermediate steps struct node {
    int value;
    struct node* left;
    struct node* right;
    int left_sum;
    int right_sum;
}

In a binary tree, from a particular node, there is a simply recursive algorithm to sum up all its child values. Is there a way to save the values calculated in the intermediate steps and store them as left_sum and right_sum in child nodes?
Will it be easier to do this bottom up by adding a struct node* parent link to the node definition?

A: No, this is clearly an exercise in recursion. Think about what the sum means. It's zero plus the "sum of all values from the root down".
Interestingly enough, the "sum of all values from the root down" is the value of the root node plus the "sum of all values from its left node down" plus the "sum of all values from its right node down".
Hopefully, you can see where I'm going here.
The essence of recursion is to define an operation in terms of similar, simpler, operations with a terminating condition.
The terminating condition, in this case, is the leaf nodes of the tree or, to make the code simpler, beyond the leaf nodes.
Examine the following pseudo-code:
def sumAllNodes (node):
    if node == NULL:
        return 0
    return node.value + sumAllNodes (node.left) + sumAllNodes (node.right)

fullSum = sumAllNodes (rootnode)

That's really all there is to it. With the following tree:
           __A(9)__
          /        \
      B(3)          C(2)
     /    \             \
D(21)      E(7)          F(1)

Using the pseudo-code, the sum is the value of A (9) plus the sums of the left and right subtrees.
The left subtree of A is the value of B (3) plus the sums of its left and right subtrees.
The left subtree of B is the value of D (21) plus the sums of its left and right subtrees.
The left subtree of D is the value of NULL (0).
Later on, the right subtree of A is the value of C (2) plus the sums of its left and right subtrees, it's left subtree being empty, its right subtree being F (1).
Because you're doing this recursively, you don't explicitly ever walk your way up the tree. It's the fact that the recursive calls are returning with the summed values which gives that ability. In other words, it happens under the covers.

And the other part of your question is not really useful though, of course, there may be unstated requirements that I'm not taking into account, because they're, well, ... unstated :-)

Is there a way to save the values calculated in the intermediate steps and store them as left_sum and right_sum in child nodes?

You never actually re-use the sums for a given sub-tree. During a sum calculation, you would calculate the B-and-below subtree only once as part of adding it to A and the C-and-below subtree.
You could store those values so that B contained both the value and the two sums (left and right) - this would mean that every change to the tree would have to propagate itself up to the root as well but it's doable.
Now there are some situations where that may be useful. For example, if the tree itself changes very rarely but you want the sum very frequently, it makes sense performance wise to do it on update so that the cost is amortised across lots of reads.
I sometimes use this method with databases (which are mostly read far more often than written) but it's unusual to see it in "normal" binary trees.
Another possible optimisation: just maintain the sum as a separate variable in the tree object. Initialise it to zero then, whenever you add a node, add its value to the sum.
When you delete a node, subtract its value from the sum. That gives you your very fast O(1) "return sum" function without having to propagate upwards on update.
The downside is that you only have a sum for the tree as a whole but I'm having a hard time coming up with a valid use case for needing the sum of subtrees. If you have such a use case, then I'd go for something like:
def updateAllNodes (node):
    if node == NULL:
        return 0
    node.leftSum = updateAllNodes (node.left)
    node.rightSum = updateAllNodes (node.right)
    return node.value + node.leftSum + node.rightSum

change the tree somehow (possibly many times)
fullSum = updateAllNodes (root)

In other words, just update the entire tree after each change (or batch the changes then update if you know there's quite a few changes happening). This will probably be a little simpler than trying to do it as part of the tree update itself.
You can even use a separate dirtyFlag which is set to true whenever the tree changes and set to false whenever you calculate and store the sum. Then use that in the sum calculation code to only do the recalc if it's dirty (in other words, a cache of the sums).
That way, code like:
fullSum = updateAllNodes (root)
fullSum = updateAllNodes (root)
fullSum = updateAllNodes (root)
fullSum = updateAllNodes (root)
fullSum = updateAllNodes (root)

will only incur a cost on the first invocation. The other four should be blindingly fast since the sum is cached.


text:
Q: Structuring a list of objects in python for vectorization: Can a list of structures(objects) be vectorized, or are explicit arrays required Energy calculations in molecular simulation are inherently full of "for" loops. Traditionally coordinates for each atom/molecule were stored in arrays. arrays are fairly straightforward to vectorize, but structures are nice to code with. Treating molecules as individual objects, each with their own coordinates, and other properties, is very convenient and much clearer as far as book-keeping goes.
I am using Python version 3.6
My problem is that I cannot figure out how to vectorize calculations when I am using an array of objects... it seems that a for loop cannot be avoided. Is it necessary for me to use arrays in order to take advantage of numpy and vectorize my code?
Here is a python example which utilizes arrays (line 121 of the code), and shows a fast (numpy) and slow ( 'normal') python energy calculation.
https://github.com/Allen-Tildesley/examples/blob/master/python_examples/mc_lj_module.py
The calculation is much faster using the numpy accelerated method because it is vectorized.
How would I vectorize an energy calculation if I was not using arrays, but an array of objects, each with their own coordinates? This seems to necessitate using the slower for loop.
Here is a simple example code with a working slow version of the for loop, and an attempted vectorization that doesn't work:
import numpy as np
import time

class Mol:
    num = 0
    def __init__(self, r):
        Mol.num += 1
        self.r       = np.empty((3),dtype=np.float_)
        self.r[0]     = r[0]
        self.r[1]     = r[1]
        self.r[2]     = r[2]
    """ Alot more useful things go in here in practice"""

################################################
#                                              #
#               Main Program                   #
#                                              #
################################################
L = 5.0            # Length of simulation box (arbitrary)
r_cut_box_sq = L/2 # arbitrary cutoff - required
mol_list=[]
nmol = 1000    # number of molecules
part = 1    # arbitrary molecule to interact with rest of molecules

""" make 1000 molecules (1 atom per molecule), give random coordinates """
for i in range(nmol):
    r = np.random.rand(3) * L
    mol_list.append( Mol( r ) )

energy = 0.0

start = time.time()
################################################
#                                              #
#   Slow but functioning loop                  #
#                                              #
################################################
for i in range(nmol):
    if i == part:
        continue

    rij = mol_list[part].r - mol_list[i].r
    rij = rij - np.rint(rij/L)*L                # apply periodic boundary conditions
    rij_sq = np.sum(rij**2)  # Squared separations

    in_range = rij_sq < r_cut_box_sq
    sr2      = np.where ( in_range, 1.0 / rij_sq, 0.0 )
    sr6  = sr2 ** 3
    sr12 = sr6 ** 2
    energy  += sr12 - sr6

end = time.time()
print('slow: ', end-start)
print('energy: ', energy)

start = time.time()
################################################
#                                              #
#   Failed vectorization attempt               #
#                                              #
################################################

    """ The next line is my problem, how do I vectorize this so I can avoid the for loop all together?
Leads to error AttributeError: 'list' object has no attribute 'r' """

""" I also must add in that part cannot interact with itself in mol_list"""
rij = mol_list[part].r - mol_list[:].r
rij = rij - np.rint(rij/L)*L                # apply periodic boundary conditions
rij_sq = np.sum(rij**2)

in_range = rij_sq < r_cut_box_sq
sr2      = np.where ( in_range, 1.0 / rij_sq, 0.0 )
sr6  = sr2 ** 3
sr12 = sr6 ** 2
energy  = sr12 - sr6

energy = sum(energy)
end = time.time()
print('faster??: ', end-start)
print('energy: ', energy)

Lastly
Would any possible solutions be affected if inside the energy calculation, it was necessary to loop over each atom in each molecule where their is now more than 1 atom per molecule, and not all molecules have the same number of atoms, thus having a double for loop for molecule-molecule interactions rather than the simple pair-pair interactions currently employed.

A: Making use of the itertools library might be the way forward here. Suppose you wrap the energy calculation of a pair of molecules in a function:
def calc_pairwise_energy((mol_a,mol_b)):
    # function takes a 2 item tuple of molecules
    # energy calculating code here
    return pairwise_energy

Then you can use itertools.combinations to get all the pairs of molecules and python's built in list comprehensions (the code inside [ ] on the last line below):
from itertools import combinations
pairs = combinations(mol_list,2)
energy = sum( [calc_pairwise_energy(pair) for pair in pairs] )

I've come back to this answer as I realised I hadn't properly answered your question. With what I've already posted the pairwise energy calculation function looked like this (I've made a few optimisations to your code):
def calc_pairwise_energy(molecules):
    rij = molecules[0].r - molecules[1].r
    rij = rij - np.rint(rij/L)*L
    rij_sq = np.sum(rij**2)  # Squared separations
    if rij_sq < r_cut_box_sq:
        return (rij_sq ** -6) - (rij_sq ** - 3)
    else:
        return 0.0

Whereas a vectorised implementation that does all the pairwise calculations in a single call might look like this:
def calc_all_energies(molecules):
    energy = 0
    for i in range(len(molecules)-1):
        mol_a = molecules[i]
        other_mols = molecules[i+1:]
        coords = np.array([mol.r for mol in other_mols])
        rijs = coords - mol_a.r
        # np.apply_along_axis replaced as per @hpaulj's  comment (see below)
        #rijs = np.apply_along_axis(lambda x: x - np.rint(x/L)*L,0,rijs)
        rijs = rijs - np.rint(rijs/L)*L
        rijs_sq = np.sum(rijs**2,axis=1)
        rijs_in_range= rijs_sq[rijs_sq < r_cut_box_sq]
        energy += sum(rijs_in_range ** -6 - rijs_in_range ** -3)
    return energy

This is much faster but there is still plenty to optimise here.

A: If you want to calculate energies with coordinates as inputs, I'm assuming you're looking for pair-wise distances. For this, you should look into the SciPy library. Specifically, I would look at scipy.spatial.distance.pdist. The documentation can be found here.


text:
Q: Hikari CP (Spring Boot) Connection Recovery Problem After DB Failure We have several microservices build on Spring Boot (2.2.4) and Hikari CP (3.4.2) with PostgreSQL.
Recently we have faced DB failure around 30 seconds. After the connections are lost some of the containers are failed to recover connections while others which has exactly the same configuration and application are just fine. Unfortunately we don't have the log indicating the pool sizes(idle active waiting) on time of the error.
We have received some broken pipe and connection lost errors on all containers when the connections are lost. After DB recovery we got the following exception only on some (2/18) containers that are failed to recover.
StackTrace:
org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:402)   ... 20 moreCaused by:
java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30000ms.  at
com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:689)   at
com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:196)    at
com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:161)    at
com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:128) at
org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)    at
org.hibernate.internal.NonContextualJdbcConnectionAccess.obtainConnection(NonContextualJdbcConnectionAccess.java:38)    at
org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:104)
... 30 moreCaused by:org.postgresql.util.PSQLException: This connection has been closed.    at
org.postgresql.jdbc.PgConnection.checkClosed(PgConnection.java:857) at
org.postgresql.jdbc.PgConnection.setNetworkTimeout(PgConnection.java:1639)  at
com.zaxxer.hikari.pool.PoolBase.setNetworkTimeout(PoolBase.java:556)    at
com.zaxxer.hikari.pool.PoolBase.isConnectionAlive(PoolBase.java:169)    at
com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:185)    ... 35 more

we have seen similar(on the same system) situations and tests where the DB failovers and connections are restored on Hikari without any problem. But in this case one of the containers are restored by itself after 1 hour and others after restart.
As far as we know Hikari is not returning the broken connections on the pool and evicts them from the pool after marked as broken or closed. Any ideas what might happened to those containers while the others(exactly same image and configuration) are just fine.
PS: we cannot reproduce the problem.
Hikari configuration:
allowPoolSuspension.............false
connectionInitSql...............none
connectionTestQuery.............none
connectionTimeout...............30000
idleTimeout.....................600000
initializationFailTimeout.......1
isolateInternalQueries..........false
leakDetectionThreshold..........0
maxLifetime.....................1800000
maximumPoolSize.................15
minimumIdle.....................15
validationTimeout...............5000

A: You can configure something like:
connectionTestQuery=select 1

This way Hikari tests that the connection is still alive before handling it over to Hibernate.


text:
Q: How to make Laravel's Validator $rules optional? Let's say I have User model with two methods:
User.php
class User extends Eloquent
{
    /* Validation rules */
    private static $rules = array(
        'user'  => 'unique:users|required|alpha_num',
        'email' => 'required|email'
    );

    /* Validate against registration form */
    public static function register($data)
    {
        $validator = Validator::make($data, static::$rules);
        if($validator->fails())
        {
            /*... do someting */
        }
        else
        {
            /* .. do something else */
        }
    }

    /* Validate against update form */
    public static function update($data)
    {
        $validator = Validator::make($data, static::$rules);
        if($validator->fails())
        {
            /*... do someting */
        }
        else
        {
            /* .. do something else */
        }
    }
}

My question: How can I make validation rules optional, so even if data for update() would be just email field, it would ignore user and still validate to true.
Is this even possible or am I missing something?
Sorry for my bad English.

A: Not sure if I'm getting your question right but if the user is optional you should remove 'required' from the validator. This way you will have:
'user'  => 'unique:users|alpha_num',

instead of:
'user'  => 'unique:users|required|alpha_num',

On the other hand I create a custom method for my models that is able to return custom validation rules depending on incoming parameters.
For example:
private function getValidationRules($rules)
{
    if ($rules == UPDATE_EMAIL)
    {
        return array('email' => 'required|email');
    } else {
        return array(
            'user'  => 'unique:users|required|alpha_num',
            'email' => 'required|email'
        );
    }
}

I guess it's only a personal choice, but I have found that getting the validation rules from a method allows more control over what I really want to validate, especially when you want to perform some advanced validations.
Hope it helps you.

A: In stock Laravel, you can call update() on a model, and it won't validate by default, which will give you the desired behavior you described. In the code you posted, you're explicitly overriding the update() method to force validation.
There are two ways to make the "user" field optional in the code you posted:

*

*Don't set "required" in your $rules for that field.
'user'  => 'unique:users|alpha_num',

*Don't override the update() method to force validation before updating.

A: How about:
private static $rules = array(
    'user'  => 'unique:users|required|alpha_num',
    'email' => 'required|email'
);
private static $update_rules = array(
    'user'  => 'required|alpha_num',
    'email' => 'required|email'
);

* Validate against registration form */
public static function register($data)
{
    $validator = Validator::make($data, static::$rules);
    if($validator->fails())
    {
        /*... do someting */
    }
    else
    {
        /* .. do something else */
    }
}

/* Validate against update form */
public static function update($data)
{
    $validator = Validator::make($data, static::$update_rules);
    if($validator->fails())
    {
        /*... do someting */
    }
    else
    {
        /* .. do something else */
    }
}


text:
Q: Pipeline on Devops with SonarQube gets "Could not find target branch" I tried a Pull Request and i triggered the pipeline before complete de merge, but I got the followed log

{"task":{"id":"AXuKvrZjTmGb5CxwFPXc","type":"REPORT","componentId":"AXuKvrZYTmGb5CxwFPXb","componentKey":"Portal.API","componentName":"Portal.API","componentQualifier":"TRK","status":"FAILED","submittedAt":"2021-08-28T03:12:39+0000","submitterLogin":"myemail@email.com.br","startedAt":"2021-08-28T03:12:39+0000","executedAt":"2021-08-28T03:12:39+0000","executionTimeMs":30,"logs":false,"errorMessage":"Could
not find target branch 'null' in
project","hasScannerContext":true,"pullRequest":"198","warningCount":0,"warnings":[]}}

anyone have a suggestion?

A: For me, I find that the branch here should be set to be the same (name) as your PR's target branch name:

and then, when your PR is successfully scanned, it will show like this

A: In Prepare Analysis Configuration task, you can try to add the following Properties.
sonar.pullrequest.vsts.instanceUrl = https://dev.azure.com/org/
sonar.pullrequest.vsts.project= Projectname
sonar.pullrequest.vsts.repository =reponame

This will help sonarqube to determine the Pull Reuqest in Azure DevOps.


text:
Q: intValue always return 0 That's code:
NSLog(@"value  = %@",[currentPatient kids_val]);
NSLog(@"value  = %d",[[currentPatient kids_val] intValue]);

And this is console:
2012-07-23 21:43:52.665 Sample[24491:207] value  =
    14
2012-07-23 21:43:52.665 Sample[24491:207] value  = 0

I need intValue. But it returns 0. I think there is a '/r' problem.

A: yes it is problem of '/r', intValue returns 0 if the receiver doesn't begin with a valid decimal text representation of a number.


text:
Q: Encryption using libsodium I have been struggling to encrypt/decrypt some data using crypto_secretbox_easy() in libsodium. I can't seem to find any good documentation on the usage.
I want to get a password from the user, use that to somehow make a key, then encrypt/decrypt the data using that.
The problem with the toy code that I have posted below is that the crypto_secretbox_open_easy() returns -1 from within verify_16.c. Does anyone have any idea where I could find source showing how to use this interface or what could be going wrong? Thanks!
 unsigned char * cipher;
 unsigned char * decoded;
 unsigned char * message;
 unsigned long long message_len = 32;
 size_t noncelen = sizeof(char) * crypto_secretbox_noncebytes();
 size_t keylen = sizeof(char) * crypto_secretbox_keybytes();
 unsigned char * nonce = calloc(noncelen, noncelen);
 unsigned char * key = calloc(keylen, keylen);

 message = calloc(32*sizeof(char), sizeof(char) * 32);
 cipher = calloc(32*sizeof(char), sizeof(char) * 32);
 decoded = calloc(32*sizeof(char), sizeof(char) * 32);

 crypto_secretbox_easy((unsigned char *)cipher, (const unsigned char *)message,
                      message_len, nonce, key);

 crypto_secretbox_open_easy((unsigned char *)decoded, (const unsigned char *) cipher,
                            message_len, nonce, key);

A: The test/secretbox_easy2.c file (in the sodium source code) shows how to use it:
randombytes_buf(nonce, sizeof nonce);
crypto_secretbox_easy(c, m, mlen, nonce, k);
crypto_secretbox_open_easy(decoded, c, mlen + crypto_secretbox_MACBYTES,
                           nonce, k);

In order to derive a key from a password, sodium provides crypto_pwhash_scryptsalsa208sha256.

A: the size of cipher should be 16 bytes larger then message for the MAC bytes, so alloc 16 more bytes and on open_easy just add + 16 to the message_len.
Also take a look, your call to calloc actually allocate a lot memory than needed, because calloc do the multiplying inside the method.


text:
Q: php: find any combination of 2 or 3 numbers in string and separate as variable How can I find if a combination of 2 or 3 numbers exists in string and then split it in two variables?
example: $input = "this and that 12" or $input = "this and that 100"
I want to separate this strings into two variables:
$text = "this and that",

$number = "12" (or "100" as in the above example)
P.S string is user input and could as well not contain any number, example $input = "this and that";

A: Haven't tried but should work.
$number = preg_replace( '/[^0-9]/', '', $string );
$text = str_replace($number, "", $string);

A: Another one
$aStrings = array('This and that 123','This and Not That 12');

foreach($aStrings as $str){
preg_match('/\D+/',$str, $text);
preg_match('/\d+/', $str, $num);

echo "
$text[0]
$num[0]
- - - -
";
}

Output:
This and that
123
- - - -

This and Not That
12
- - - -

Example Code

A: Try this
<?php
$string1 = "this and that 12";
$string2 = "this and that 100";
$combine = explode(' ',$string1.' '.$string2);
$vars  = '';
$integer ='';
foreach($combine as $key =>$val)
{
    if(is_numeric($val))
    {
        $vars[] = $val;
    }
    else
    {
        $integer[] =$val;
    }
}
echo "<pre>"; print_r(array_unique($vars));
echo "<pre>"; print_r(array_unique($integer));
?>

this will output
Array
(
    [0] => 12
    [1] => 100
)

Array
(
    [0] => this
    [1] => and
    [2] => that
)

A: you try this code
$string="this and that 12";//this and that 100
preg_match_all('/^([^\d]+)(\d+)/', $string, $match);

echo $text = $match[1][0];
echo $num = $match[2][0];


text:
Q: Directory owned by a group that doesn't exist? I'm witnessing a a directory which has for group owner "1002" ...
However I do not have any group with such ID (verified with getent group | grep 1002 ).
Even history | grep groupadd gave nothing.
Where could that be coming from.
Any '100x' group ID is a user ID if I'm right no ?

A: Group IDs and User IDs are independent. The same number may be used for user "foo" and group "bar".
Some Linux distributions by default create a new group "foo" when you create user "foo", both having the same numerical ID. (This kills the very notion of group, IMHO.)
ls by default shows the group name, but the filesystem stores the numerical group ID. If a group is removed, files belonging to it are not, then ls shows the numerical ID.
So the situation you observe may come from, e.g.:

*

*creating a user who gets affected number 1002 and implying creation of group 1002, then removing this user (assuming the distribution tools then remove the associated group)

*syncing a file from another computer where its owning group has number 1002


text:
Q: How to exclude 1 sheet from my save to pdf VBA macro I have a VBA code that works well, apart from the fact that i don't know how to exclude one sheet from saving to the PDF.  I would like the exclude the sheet named 'Control' from being included in the export and save to PDF.  Any ideas how or where i should add this?
Thanks
Sub CreatePDF()

Dim saveAsName As String
Dim WhereTo As String
Dim sFileName As String
Dim ws As Worksheet
Dim myrange

' Retrieve information from Control sheet
Sheets("Control").Activate
Range("C4").Activate
periodName = ActiveCell.Value
Range("C5").Activate
saveAsName = ActiveCell.Value
Range("C6").Activate
WhereTo = ActiveCell.Value

Set myrange = Worksheets("Control").Range("range_sheetProperties")

' Check if Stamp-field has any value at all
' if not, add the current date.
If Stamp = "" Then Stamp = Date

' Assemble the filename
     sFileName = WhereTo & saveAsName & " (" & Format(CDate(Date), "DD-MMM-YYYY") & ").pdf"

' Format all sheets as landsape, autofit to 1 page and provide header
For Each ws In ActiveWorkbook.Worksheets

    With ws.PageSetup
    Application.PrintCommunication = False
    .Orientation = xlLandscape
    .Zoom = False
    .FitToPagesWide = 1
    .CenterHorizontally = True
    .ScaleWithDocHeaderFooter = False
    .AlignMarginsHeaderFooter = False
    .HeaderMargin = Application.InchesToPoints(0.31496062992126)
    Application.PrintCommunication = True

    DisplayHeader = Application.VLookup(ws.Name, myrange, 2, False)
        If Not IsError(DisplayHeader) Then
        .LeftHeader = "&L &""Arial,Bold""&11&K00-048DIVA: " & DisplayHeader
        Else: .LeftHeader = "&L &""Arial,Bold""&11&KFF0000WORKSHEET NOT DEFINED IN CONTROL SHEET "
        End If
    .CenterHeader = "&C &""Arial,Bold""&11&K00-048" & periodName
    End With

Next

' Save the File as PDF
    ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        sFileName, Quality _
        :=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
        OpenAfterPublish:=True

     MsgBox "PDF document has been created and saved to : " & sFileName

' Make sure we open the Control sheet upon Exit
    Sheets("Control").Activate

End Sub

A: You could hide the worksheet at the beginning of the code and then make it visible again at the end.
TESTED:
' Retrieve information from Control sheet

Sheets("Control").Visible = False

'YOUR PDF CREATION CODE

Sheets("Control").Visible = True
Sheets("Control").Activate

A: I ran into the same problem and just hid the sheet during the export function, then I brought it back... Here is the code:
 'Hide the log sheet to exclude from export
 ActiveWorkbook.Sheets("Log").Visible = xlSheetHidden

ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, FileName:=FilePath + Today + "\" + Range("H2").Value _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=True

'Bring back the log sheet to allow for editing
ActiveWorkbook.Sheets("Log").Visible = xlSheetVisible


text:
Q: Set camera focus on particular marker on Google map on itemclick With the help of this Tutorial
 I made onItemClickListner class
public class OnItemClickListenerListViewItem implements OnItemClickListener {

@Override

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    Context context = view.getContext();

    TextView textViewItem = ((TextView) view.findViewById(R.id.textViewItem));

    // get the clicked item name

    String listItemText = textViewItem.getText().toString();

    // get the clicked item ID

    String listItemId = textViewItem.getTag().toString();

    // Toast not showing Item name

    Toast.makeText(context, "Item: " + listItemText + ", Item ID: " + listItemId, Toast.LENGTH_SHORT).show();

}

Camera focus is not working

if (listItemText.equals("ROMYS")) {
        CameraUpdate location = CameraUpdateFactory.newLatLngZoom(
                coordinate, 15);
        googleMap.animateCamera(location);
    }

I tried this Code but it does not work
And this is my class code right now myClassCode Pastbin Link


text:
Q: Naming Variables using Pyspark Even though my problem is pretty simple, since I'm new to spark having issues resolving it.
The normal python query for my issue is the following:
for line in file('schedule.txt'):
  origin,dest,depart,arrive,price=line.split(',')

I could read the file as
sched=sc.textFile('/PATH/schedule.txt')

But when I was trying the following code:
  origin,dest,depart,arrive,price=sched.split(',')

I'm getting this error:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-46-ba0e8c07ca89> in <module>()
----> 1 origin,dest,depart,arrive,price=sched.split(',')

AttributeError: 'RDD' object has no attribute 'split'

I could split the file using lambda function. But don't know how to create those 5 variable names.
If somebody can please help me.

A: sched=sc.textFile('/PATH/schedule.txt') returns an RDD which is a different datatype than a python file object and supports a different API. The equivalent of your python code would be something like:
sched=sc.textFile('/PATH/schedule.txt')
# extract values
vals = sched.map(lambda line:line.split(','))
# now you can do some processing, for example sum price
price = vals.reduce(lambda v1,v2:v1[4]+v2[4])
# or just collect the raw values
raw_vals = vals.collect()

update:
if you want to be able to access the values of each line as local variables you could define a dedicated function instead of just a lambda and pass that to .map():
def process_line(line):
    origin,dest,depart,arrive,price=line.split(',')
    # do whatever
    # remember to return a result

sche.map(process_line)

update2:
The specific processing you want to do on the file is not trivial because it requires writing to a shared variable (flights). Instead, i'd suggest grouping the lines by orig,dest, then collecting the results and inserting into a dict:
flights_data = sched.map(lambda line: ((line[0],line[1]),tuple(line[2:]))).groupByKey().collect()
flights = {f:ds for f,ds in flights_data}


text:
Q: How to paste multiple times at once in Excel between data Say I have data like this
  A   B   C
1 Jim 1 10
2 Jim 2 20
3 Jim 3 30
4 Tom 1 20
5
6
7 Jos 1 15
8
9

What I want is copy the row 2 and 3 then paste to row 5 and 6, and then 8 and 9, and so on. The blank rows are always 2.
There is a formula in the cell 2C and 3C that calculate the value in column B multiplied by cell C1.
So, the result would be like this
  A   B   C
1 Jim 1 10
2 Jim 2 20
3 Jim 3 30
4 Tom 1 20
5 Tom 2 40
6 Tom 3 60
7 Jos 1 15
8 Jos 2 30
9 Jos 3 45

The problem is I have to paste hundreds times that would be time consuming.
I would appreciate if anyone can help.

A: Sub MakeRows()
    Dim Sh As Worksheet, DataRng As Range, CopyRng As Range, TargetRng As Range

    Set Sh = Sheets(1) 'select your sheet here
                       'you can also do it like this = Worksheets("name")

    Set DataRng = Sh.Range("B2")
    Set TargetRng = Sh.Range("A4")

    While IsEmpty(TargetRng) = False
       TargetRng.Copy TargetRng.Offset(1, 0)
       TargetRng.Copy TargetRng.Offset(2, 0)

       Set CopyRng = Sh.Range(DataRng, DataRng.Offset(1, 1))
       CopyRng.Copy TargetRng.Offset(1, 1)

       Set TargetRng = TargetRng.Offset(3, 0)
       Set DataRng = DataRng.Offset(3, 0)
    Wend
End Sub

Works with relative references in cells 2C and 3C.

A: Please keep in mind:

*

*You'll need to make sure you have a value in column A1, otherwise
just increase the value of i to the second row with data.

*Var is a dummy variable used to keep track when a new name occurs.

*firstValue will contain the rownumber of the first row per name.
Code
Sub test()

Var = 0
LastRow = Cells(Rows.Count, "A").End(xlUp).Row + 2

For i = 2 To LastRow
    If Range("A" & i).Value = "" Then
        If Var = 0 Then
            firstValue = i - 1
            Range("A" & i).Value = Range("A" & i - 1).Value
            Range("B" & i).Value = Range("B" & i - 1).Value + 1
            Range("C" & i).Value = Range("C" & firstValue).Value + Range("C" & i - 1).Value
            Var = Var + 1
        Else
            Range("A" & i).Value = Range("A" & i - 1).Value
            Range("B" & i).Value = Range("B" & i - 1).Value + 1
            Range("C" & i).Value = Range("C" & firstValue).Value + Range("C" & i - 1).Value
            Var = Var + 1
        End If
    Else
        Var = 0
    End If
Next i

End Sub


text:
Q: IOS Coredata Autofill textfield with searching I am working on coredatabase project and implementing Text-field autofill search functionality. I am new to coredata. so, i can't understand how to get result of searched text in Autofilltableview and how to use Nspredicate to search the string from coredata..
Here is my try:
  - (BOOL)textField:(UITextField *)textField
    shouldChangeCharactersInRange:(NSRange)range
    replacementString:(NSString *)string
    {
        if (textField==_textField1) {
            [popupView bringSubviewToFront:autocompleteTableView];
            [autocompleteTableView setHidden:NO];

            NSString *substring = [NSString stringWithString:textField.text];
            substring = [substring stringByReplacingCharactersInRange:range withString:string];
            [self searchAutocompleteEntriesWithSubstring:substring];
    }
            return YES;
            //[popupView bringSubviewToFront:autoCompleteTextField];

            //[self searchedbuttonclcked ];

    }

        - (void)searchAutocompleteEntriesWithSubstring:(NSString *)substring {

        //searcharray=[NSMutableArray new];
        AppDelegate *appdelegate=[[UIApplication sharedApplication]delegate];
        NSManagedObjectContext *contex;
        contex=[appdelegate managedObjectContext];
        NSEntityDescription *entity = [NSEntityDescription
                                       entityForName:@"Iw" inManagedObjectContext:contex];
        NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

        [fetchRequest setEntity:entity];
         NSError *error;
        NSArray *queryArray;
        NSPredicate *predicate=[NSPredicate predicateWithFormat:@"name contains[c] %@",self.textField1.text];

        [fetchRequest setPredicate:predicate];
        queryArray = [contex executeFetchRequest:fetchRequest error:&error];

      [autocompleteTableView reloadData]; // This is tableview which contains result below the textfield
    }

    #pragma mark -->Autocomplete tablevie methods
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
        return 1;
    }

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        id  sectionInfo =
        [[_fetchedResultsController sections] objectAtIndex:section];
        return [sectionInfo numberOfObjects];

    }

    - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
      //  _searchfetch  = [_fetchedResultsController objectAtIndexPath:indexPath];

        NSManagedObject *fetchsidename = [self.searchfetch objectAtIndex:indexPath.row];

    [cell.textLabel setText:[NSString stringWithFormat:@"%@", [fetchsidename valueForKey:@"name"]]];

       }

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

        if (!cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
        }

        [self configureCell:cell atIndexPath:indexPath];

        return cell;
    }


text:
Q: Out of memory exception in dataflow with windowing on bounded input I have created a dataflow which takes input from datastore and performs transform to convert it to BigQuery TableRow. I am attaching timestamp with each element in a transform. Then window of one day is applied to the PCollection. The windowed output is written to a partition in BigQuery table using Apache Beam's BigQueryIO.
The job fails with OOM error.
Dataflow Job ID: 2018-03-26_20_45_39-10536011060742036262
workerMachineType used: n1-standard-8
The dataflow pipeline at a high level is:
// Read from datastore
PCollection<Entity> entities =
        pipeline.apply("ReadFromDatastore",
                DatastoreIO.v1().read().withProjectId(options.getProject())
                        .withQuery(query).withNamespace(options.getNamespace()));

// Apply processing to convert it to BigQuery TableRow
PCollection<TableRow> tableRow =
        entities.apply("ConvertToTableRow", ParDo.of(new ProcessEntityFn()));

// Apply timestamp to TableRow element, and then apply windowing of one day on that
PCollection<TableRow> tableRowWindow =
        tableRow.apply("tableAddTimestamp", ParDo.of(new ApplyTimestampFn())).apply(
                "tableApplyWindow",
                Window.<TableRow> into(CalendarWindows.days(1).withTimeZone(
                        DateTimeZone.forID(options.getTimeZone()))));

// Write windowed output to BigQuery partitions
tableRowWindow.apply(
        "WriteTableToBQ",
        BigQueryIO
                .writeTableRows()
                .withSchema(BigqueryHelper.getSchema())
                .to(TableRefPartition.perDay(options.getProject(),
                        options.getBigQueryDataset(), options.getTableName()))
                .withWriteDisposition(BigQueryIO.Write.WriteDisposition.WRITE_TRUNCATE));

I am getting following error logs several times:
An OutOfMemoryException occurred. Consider specifying higher memory instances in PipelineOptions.
java.lang.RuntimeException: org.apache.beam.sdk.util.UserCodeException: java.lang.OutOfMemoryError: Java heap space
    at com.google.cloud.dataflow.worker.GroupAlsoByWindowsParDoFn$1.output(GroupAlsoByWindowsParDoFn.java:182)
    at com.google.cloud.dataflow.worker.GroupAlsoByWindowFnRunner$1.outputWindowedValue(GroupAlsoByWindowFnRunner.java:104)
    at com.google.cloud.dataflow.worker.util.BatchGroupAlsoByWindowReshuffleFn.processElement(BatchGroupAlsoByWindowReshuffleFn.java:54)
    at com.google.cloud.dataflow.worker.util.BatchGroupAlsoByWindowReshuffleFn.processElement(BatchGroupAlsoByWindowReshuffleFn.java:37)
    at com.google.cloud.dataflow.worker.GroupAlsoByWindowFnRunner.invokeProcessElement(GroupAlsoByWindowFnRunner.java:117)
    at com.google.cloud.dataflow.worker.GroupAlsoByWindowFnRunner.processElement(GroupAlsoByWindowFnRunner.java:74)
    at com.google.cloud.dataflow.worker.GroupAlsoByWindowsParDoFn.processElement(GroupAlsoByWindowsParDoFn.java:113)
    at com.google.cloud.dataflow.worker.util.common.worker.ParDoOperation.process(ParDoOperation.java:48)
    at com.google.cloud.dataflow.worker.util.common.worker.OutputReceiver.process(OutputReceiver.java:52)
    at com.google.cloud.dataflow.worker.util.common.worker.ReadOperation.runReadLoop(ReadOperation.java:187)
    at com.google.cloud.dataflow.worker.util.common.worker.ReadOperation.start(ReadOperation.java:148)
    at com.google.cloud.dataflow.worker.util.common.worker.MapTaskExecutor.execute(MapTaskExecutor.java:68)
    at com.google.cloud.dataflow.worker.DataflowWorker.executeWork(DataflowWorker.java:330)
    at com.google.cloud.dataflow.worker.DataflowWorker.doWork(DataflowWorker.java:302)
    at com.google.cloud.dataflow.worker.DataflowWorker.getAndPerformWork(DataflowWorker.java:251)
    at com.google.cloud.dataflow.worker.DataflowBatchWorkerHarness$WorkerThread.doWork(DataflowBatchWorkerHarness.java:135)
    at com.google.cloud.dataflow.worker.DataflowBatchWorkerHarness$WorkerThread.call(DataflowBatchWorkerHarness.java:115)
    at com.google.cloud.dataflow.worker.DataflowBatchWorkerHarness$WorkerThread.call(DataflowBatchWorkerHarness.java:102)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.beam.sdk.util.UserCodeException: java.lang.OutOfMemoryError: Java heap space
    at org.apache.beam.sdk.util.UserCodeException.wrap(UserCodeException.java:36)
    at org.apache.beam.sdk.io.gcp.bigquery.WriteBundlesToFiles$DoFnInvoker.invokeProcessElement(Unknown Source)
    at org.apache.beam.runners.core.SimpleDoFnRunner.invokeProcessElement(SimpleDoFnRunner.java:177)
    at org.apache.beam.runners.core.SimpleDoFnRunner.processElement(SimpleDoFnRunner.java:138)
    at com.google.cloud.dataflow.worker.SimpleParDoFn.processElement(SimpleParDoFn.java:324)
    at com.google.cloud.dataflow.worker.util.common.worker.ParDoOperation.process(ParDoOperation.java:48)
    at com.google.cloud.dataflow.worker.util.common.worker.OutputReceiver.process(OutputReceiver.java:52)
    at com.google.cloud.dataflow.worker.AssignWindowsParDoFnFactory$AssignWindowsParDoFn.processElement(AssignWindowsParDoFnFactory.java:116)
    at com.google.cloud.dataflow.worker.util.common.worker.ParDoOperation.process(ParDoOperation.java:48)
    at com.google.cloud.dataflow.worker.util.common.worker.OutputReceiver.process(OutputReceiver.java:52)
    at com.google.cloud.dataflow.worker.SimpleParDoFn$1.output(SimpleParDoFn.java:272)
    at org.apache.beam.runners.core.SimpleDoFnRunner.outputWindowedValue(SimpleDoFnRunner.java:211)
    at org.apache.beam.runners.core.SimpleDoFnRunner.access$700(SimpleDoFnRunner.java:66)
    at org.apache.beam.runners.core.SimpleDoFnRunner$DoFnProcessContext.output(SimpleDoFnRunner.java:436)
    at org.apache.beam.runners.core.SimpleDoFnRunner$DoFnProcessContext.output(SimpleDoFnRunner.java:424)
    at org.apache.beam.sdk.io.gcp.bigquery.PrepareWrite$1.processElement(PrepareWrite.java:62)
    at org.apache.beam.sdk.io.gcp.bigquery.PrepareWrite$1$DoFnInvoker.invokeProcessElement(Unknown Source)
    at org.apache.beam.runners.core.SimpleDoFnRunner.invokeProcessElement(SimpleDoFnRunner.java:177)
    at org.apache.beam.runners.core.SimpleDoFnRunner.processElement(SimpleDoFnRunner.java:138)
    at com.google.cloud.dataflow.worker.SimpleParDoFn.processElement(SimpleParDoFn.java:324)
    at com.google.cloud.dataflow.worker.util.common.worker.ParDoOperation.process(ParDoOperation.java:48)
    at com.google.cloud.dataflow.worker.util.common.worker.OutputReceiver.process(OutputReceiver.java:52)
    at com.google.cloud.dataflow.worker.AssignWindowsParDoFnFactory$AssignWindowsParDoFn.processElement(AssignWindowsParDoFnFactory.java:116)
    at com.google.cloud.dataflow.worker.util.common.worker.ParDoOperation.process(ParDoOperation.java:48)
    at com.google.cloud.dataflow.worker.util.common.worker.OutputReceiver.process(OutputReceiver.java:52)
    at com.google.cloud.dataflow.worker.SimpleParDoFn$1.output(SimpleParDoFn.java:272)
    at org.apache.beam.runners.core.SimpleDoFnRunner.outputWindowedValue(SimpleDoFnRunner.java:211)
    at org.apache.beam.runners.core.SimpleDoFnRunner.access$700(SimpleDoFnRunner.java:66)
    at org.apache.beam.runners.core.SimpleDoFnRunner$DoFnProcessContext.outputWithTimestamp(SimpleDoFnRunner.java:443)
    at org.apache.beam.runners.core.SimpleDoFnRunner$DoFnProcessContext.outputWithTimestamp(SimpleDoFnRunner.java:430)
    at com.ittiam.cvml.dataflow.service.LoadIsmDataflow$ApplyTimestampFn.processElement(LoadIsmDataflow.java:526)
    at com.ittiam.cvml.dataflow.service.LoadIsmDataflow$ApplyTimestampFn$DoFnInvoker.invokeProcessElement(Unknown Source)
    at org.apache.beam.runners.core.SimpleDoFnRunner.invokeProcessElement(SimpleDoFnRunner.java:177)
    at org.apache.beam.runners.core.SimpleDoFnRunner.processElement(SimpleDoFnRunner.java:141)
    at com.google.cloud.dataflow.worker.SimpleParDoFn.processElement(SimpleParDoFn.java:324)
    at com.google.cloud.dataflow.worker.util.common.worker.ParDoOperation.process(ParDoOperation.java:48)
    at com.google.cloud.dataflow.worker.util.common.worker.OutputReceiver.process(OutputReceiver.java:52)
    at com.google.cloud.dataflow.worker.SimpleParDoFn$1.output(SimpleParDoFn.java:272)
    at org.apache.beam.runners.core.SimpleDoFnRunner.outputWindowedValue(SimpleDoFnRunner.java:211)
    at org.apache.beam.runners.core.SimpleDoFnRunner.access$700(SimpleDoFnRunner.java:66)
    at org.apache.beam.runners.core.SimpleDoFnRunner$DoFnProcessContext.output(SimpleDoFnRunner.java:436)
    at org.apache.beam.runners.core.SimpleDoFnRunner$DoFnProcessContext.output(SimpleDoFnRunner.java:424)
    at com.ittiam.cvml.dataflow.service.LoadIsmDataflow$ProcessEntityFn.processElement(LoadIsmDataflow.java:478)
    at com.ittiam.cvml.dataflow.service.LoadIsmDataflow$ProcessEntityFn$DoFnInvoker.invokeProcessElement(Unknown Source)
    at org.apache.beam.runners.core.SimpleDoFnRunner.invokeProcessElement(SimpleDoFnRunner.java:177)
    at org.apache.beam.runners.core.SimpleDoFnRunner.processElement(SimpleDoFnRunner.java:138)
    at com.google.cloud.dataflow.worker.SimpleParDoFn.processElement(SimpleParDoFn.java:324)
    at com.google.cloud.dataflow.worker.util.common.worker.ParDoOperation.process(ParDoOperation.java:48)
    at com.google.cloud.dataflow.worker.util.common.worker.OutputReceiver.process(OutputReceiver.java:52)
    at com.google.cloud.dataflow.worker.SimpleParDoFn$1.output(SimpleParDoFn.java:272)
    at org.apache.beam.runners.core.SimpleDoFnRunner.outputWindowedValue(SimpleDoFnRunner.java:211)
    at org.apache.beam.runners.core.SimpleDoFnRunner.access$700(SimpleDoFnRunner.java:66)
    at org.apache.beam.runners.core.SimpleDoFnRunner$DoFnProcessContext.output(SimpleDoFnRunner.java:436)
    at org.apache.beam.runners.core.SimpleDoFnRunner$DoFnProcessContext.output(SimpleDoFnRunner.java:424)
    at org.apache.beam.sdk.io.gcp.datastore.DatastoreV1$Read$ReadFn.processElement(DatastoreV1.java:919)
    at org.apache.beam.sdk.io.gcp.datastore.DatastoreV1$Read$ReadFn$DoFnInvoker.invokeProcessElement(Unknown Source)
    at org.apache.beam.runners.core.SimpleDoFnRunner.invokeProcessElement(SimpleDoFnRunner.java:177)
    at org.apache.beam.runners.core.SimpleDoFnRunner.processElement(SimpleDoFnRunner.java:141)
    at com.google.cloud.dataflow.worker.SimpleParDoFn.processElement(SimpleParDoFn.java:324)
    at com.google.cloud.dataflow.worker.util.common.worker.ParDoOperation.process(ParDoOperation.java:48)
    at com.google.cloud.dataflow.worker.util.common.worker.OutputReceiver.process(OutputReceiver.java:52)
    at com.google.cloud.dataflow.worker.SimpleParDoFn$1.output(SimpleParDoFn.java:272)
    at org.apache.beam.runners.core.SimpleDoFnRunner.outputWindowedValue(SimpleDoFnRunner.java:211)
    at org.apache.beam.runners.core.SimpleDoFnRunner.access$700(SimpleDoFnRunner.java:66)
    at org.apache.beam.runners.core.SimpleDoFnRunner$DoFnProcessContext.output(SimpleDoFnRunner.java:436)
    at org.apache.beam.runners.core.SimpleDoFnRunner$DoFnProcessContext.output(SimpleDoFnRunner.java:424)
    at org.apache.beam.sdk.transforms.MapElements$1.processElement(MapElements.java:122)
    at org.apache.beam.sdk.transforms.MapElements$1$DoFnInvoker.invokeProcessElement(Unknown Source)
    at org.apache.beam.runners.core.SimpleDoFnRunner.invokeProcessElement(SimpleDoFnRunner.java:177)
    at org.apache.beam.runners.core.SimpleDoFnRunner.processElement(SimpleDoFnRunner.java:141)
    at com.google.cloud.dataflow.worker.SimpleParDoFn.processElement(SimpleParDoFn.java:324)
    at com.google.cloud.dataflow.worker.util.common.worker.ParDoOperation.process(ParDoOperation.java:48)
    at com.google.cloud.dataflow.worker.util.common.worker.OutputReceiver.process(OutputReceiver.java:52)
    at com.google.cloud.dataflow.worker.SimpleParDoFn$1.output(SimpleParDoFn.java:272)
    at org.apache.beam.runners.core.SimpleDoFnRunner.outputWindowedValue(SimpleDoFnRunner.java:211)
    at org.apache.beam.runners.core.SimpleDoFnRunner.access$700(SimpleDoFnRunner.java:66)
    at org.apache.beam.runners.core.SimpleDoFnRunner$DoFnProcessContext.output(SimpleDoFnRunner.java:436)
    at org.apache.beam.runners.core.SimpleDoFnRunner$DoFnProcessContext.output(SimpleDoFnRunner.java:424)
    at org.apache.beam.runners.dataflow.ReshuffleOverrideFactory$ReshuffleWithOnlyTrigger$1.processElement(ReshuffleOverrideFactory.java:84)
    at org.apache.beam.runners.dataflow.ReshuffleOverrideFactory$ReshuffleWithOnlyTrigger$1$DoFnInvoker.invokeProcessElement(Unknown Source)
    at org.apache.beam.runners.core.SimpleDoFnRunner.invokeProcessElement(SimpleDoFnRunner.java:177)
    at org.apache.beam.runners.core.SimpleDoFnRunner.processElement(SimpleDoFnRunner.java:141)
    at com.google.cloud.dataflow.worker.SimpleParDoFn.processElement(SimpleParDoFn.java:324)
    at com.google.cloud.dataflow.worker.util.common.worker.ParDoOperation.process(ParDoOperation.java:48)
    at com.google.cloud.dataflow.worker.util.common.worker.OutputReceiver.process(OutputReceiver.java:52)
    at com.google.cloud.dataflow.worker.GroupAlsoByWindowsParDoFn$1.output(GroupAlsoByWindowsParDoFn.java:180)
    ... 21 more
Caused by: java.lang.OutOfMemoryError: Java heap space
    at com.google.api.client.googleapis.media.MediaHttpUploader.setContentAndHeadersOnCurrentRequest(MediaHttpUploader.java:603)
    at com.google.api.client.googleapis.media.MediaHttpUploader.resumableUpload(MediaHttpUploader.java:409)
    at com.google.api.client.googleapis.media.MediaHttpUploader.upload(MediaHttpUploader.java:336)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:427)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)
    at com.google.cloud.hadoop.util.AbstractGoogleAsyncWriteChannel$UploadOperation.call(AbstractGoogleAsyncWriteChannel.java:357)

Dataflow pipeline fails with the following error log:
Workflow failed. Causes: S53:ReadIsmFromDatastore/Reshuffle/Reshuffle/GroupByKey/Read+ReadIsmFromDatastore/Reshuffle/Reshuffle/GroupByKey/GroupByWindow+ReadIsmFromDatastore/Reshuffle/Reshuffle/ExpandIterable+ReadIsmFromDatastore/Reshuffle/Values/Values/Map+ReadIsmFromDatastore/Read+ConvertToTableRow+IsmTableAddTimestamp+TrackerTableAddTimestamp+IsmTableApplyWindow/Window.Assign+TrackerTableApplyWindow/Window.Assign+WriteTrackerTableToBQ/PrepareWrite/ParDo(Anonymous)+WriteTrackerTableToBQ/BatchLoads/rewindowIntoGlobal/Window.Assign+WriteTrackerTableToBQ/BatchLoads/WriteBundlesToFiles+WriteTrackerTableToBQ/BatchLoads/ReifyResults/View.AsIterable/View.CreatePCollectionView/ParDo(ToIsmRecordForGlobalWindow)+WriteTrackerTableToBQ/BatchLoads/GroupByDestination/Reify+WriteTrackerTableToBQ/BatchLoads/GroupByDestination/Write+WriteIsmTableToBQ/PrepareWrite/ParDo(Anonymous)+WriteIsmTableToBQ/BatchLoads/rewindowIntoGlobal/Window.Assign+WriteIsmTableToBQ/BatchLoads/WriteBundlesToFiles+WriteIsmTableToBQ/BatchLoads/ReifyResults/View.AsIterable/View.CreatePCollectionView/ParDo(ToIsmRecordForGlobalWindow)+WriteIsmTableToBQ/BatchLoads/GroupByDestination/Reify+WriteIsmTableToBQ/BatchLoads/GroupByDestination/Write failed., A work item was attempted 4 times without success. Each time the worker eventually lost contact with the service.


text:
Q: Dynamic column in PDFMAKE i'm using PdfMake to generate PDFs with on my VueJS app and i would like to know if i can control the impression of columns in my template, for example, using the data who was being printed like an variable.
I'm trying to reach something like this:
let var1: string = 'test';
let var2: string = 'test2';
1) Original code
var dd = {
    content: [
        {
            alignment: 'justify',
            columns: [
                {
                    text: 'var1'
                },
                {
                    text: 'var2'
                }
            ]
        },

    ],
    styles: {
        header: {
            fontSize: 18,
            bold: true
        },
        bigger: {
            fontSize: 15,
            italics: true
        }
    },
    defaultStyle: {
        columnGap: 50
    }

}

2) After/with validation
if var2 == null
var dd = {
        content: [
            {
                alignment: 'justify',
                columns: [
                    {
                        text: 'var1'
                    }
                ]
            },

        ],
        styles: {
            header: {
                fontSize: 18,
                bold: true
            },
            bigger: {
                fontSize: 15,
                italics: true
            }
        },
        defaultStyle: {
            columnGap: 50
        }

    }

A: Wouldn't setting a variable outside the document definition suffice?, I believe a piece of code will do the trick.
      var columns = [];
      var var1; // Defaults to undefined
      var var2; // Defaults to undefined

      var1 ="";

      // If we have a value we add the column
      if (var1 !== undefined) {
        columns.push({ text: "var1" });
      }

      if (var2 !== undefined) {
        columns.push({ text: "var2" });
      }

      // PDFMake document definition
      var dd = {
        content: [
            {
                alignment: 'justify',
                columns: columns
            },

        ]
        ...
    }


text:
Q: I need a javascript code that will check the valid values are entered in month and days depending on the type of year I want some extra piece of code in this so that it will check for leap year and if it is it will allow 29 days in February month otherwise it should check for 28 days and if greater it should show an alert message.

    <title>
        Redirection using Delay
    </title>

Enter Date in Valid Formats:

    <input type="text" id="dat" name="date" />
    <input type="submit" value="Go" name="submit" onclick="datecheck();" />

A: check for leap year with this
if(((dats[2] % 4 == 0) && (dats[2] % 100 != 0)) || (dats[2] % 400 == 0))

then check for month within the above if condition and have you logic... easy :)


text:
Q: What to do with CIDs in text extracted by PDFMiner? I've some PDFs which are in Hindi, and have extractable text. I used pdfminer.six for python 3.6, to do the extraction. The output looks like:

As one can see, there are a number of characters that are converted into the form "(cid :number)".
On further analysis, I found out that a PDF contains CMAPs which map character codes to glyph indices. So, a CID is a character identity for the glyph it maps to, inside the CMAP table.
But how are these character codes related to Unicode values? Basically, how is a PDF viewer able to show the glyph using this mapping?
Moreover, according to a comment to this similar question, this process may not be legal. But I'm not trying to steal someone's font. I want the text. How does this process become illegal?
Since there are many questions like this one, I want to clarify that I do not aim at solving the "cid" problem. I want to clarify the reasons for the problem and reasons for it's illegality.
EDIT: This issues page for pdfminer discusses this issue, where the author clearly says that there seems to be no reliable workaround for this issue. Is there some general, basic limitation (like, no access to font) that makes this issue continual?

A:
But how are these character codes related to Unicode values? Basically, how is a PDF viewer able to show the glyph using this mapping?

The character codes one finds in the PDF content streams do not need to be related to Unicode values in any obvious way. In particular, a PDF viewer does not at all need a Unicode code point for a character code to show the matching glyph.
In a PDF a font has a mapping (or a sequence of mappings) from character code to glyph ID in the font program, and this mapping may be completely arbitrary.
E.g. in case of embedded font subsets the subset font program often is created by giving the first glyph used on a page a starting glyph id n, then giving the second, different glyph on that page id n+1, then the next, different glyph id n+2 etc etc, and then the character codes often are identical to the glyph ids, i.e. the mapping above is the identity mapping. If there are no additional information anymore, a text extractor has no chance to properly do its job.

I want to clarify the reasons for the problem

Regular text extraction usually has the following options to find the Unicode value for a character code:

*

*A PDF font may include a ToUnicode map (mapping from character code to Unicode) to support operations like searching strings or copy & paste in a PDF viewer. This map immediately provides the mapping the text extractor needs.
Beware, though: these ToUnicode maps can be incomplete and sometimes even contain intentionally incorrect mappings!

*The PDF font encoding definition may contain the name of a pre-defined standard encoding (e.g. WinAnsiEncoding or GBpc-EUC-H) or a standardized character name (e.g. space, seven, or ntilde) for a given code. A text extractor merely needs to know the encoding represented by that encoding name or the code represented by that character name.
But the Encoding may also be an identity (Identity–H and Identity–V with character code = glyph code) which doesn't give away anything, and a character name may also be non-standardized (e.g. g17).
The PDF specification says: If these methods fail to produce a Unicode value, there is no way to determine what the character code represents in which case a conforming reader may choose a character code of their choosing.
In case of your text extraction output I would guess the PDF font has an incomplete ToUnicode map.
Actually there are some more locations to look for additional information, e.g. the font program might include an own mapping of its glyphs to Unicode, but those additional information also are optional.

... and reasons for it's illegality.

In case of all the above options I don't see any sensible font license being violated, in particular as most of those options didn't even look into the font program (e.g. the *.ttf) itself, merely into the PDF metadata wrapping it.
On the other hand, if e.g. you had the idea to construct ToUnicode maps for those fonts missing such a map by drawing each glyph of the font onto a bitmap, nicely separated from anything else, and applying OCR to it, you as the recipient of the PDF suddenly would use the font program to draw something else than the original document, and this might be considered usage not covered by the license.


text:
Q: Combine Redmine and TFS Our company want to implement an bug tracker, which will be usable for our partners. Currently we are using TFS as our source control and ALM system. Now i'm confused, how to combine these two systems, because in the TFS we have our product versions and work items (maybe also bugs). But when we start using Redmine, we don't have them in the TFS any more, or is there a way, to use them together?
I could not find any plugins or something similar.
Maybe some one has experiances in the area, thank you!

A: First, things reported by customers are not bugs in the engineering sence. They are defects that may or may not be bugs.
Specifically in TFS a bug work item is used to represent the meta data of a failing test or exception.
To integrate you will either have to roll your own or buy a tool. I recommend talking to TaskTop as the best work item tracking integration tool...

A: With all due respect, the accepted answer has misleading statements.

First, things reported by customers are not bugs in the engineering
  sence. They are defects that may or may not be bugs.

Even when we talk about TFS/Redmine and the like, the concept of a bug is very different from what is being expressed here.
According to ISTQB (and other qualification boards related to software quality) there is a difference between an Error, a Failure, and a Defect.
Let me explain each concept:
Error: is produced by a human being's actions (for now :) ) it's existence may or may not be detected and may or may not be classified as a software Defect
Failure: is how an Error can be detected while using the Application Under Test (i.e. error messages, data inconsistency, unexpected behavior, etc). A Failure may or may not be detected, but most often ends up being classified as a Defect.
Defect: is the documented description of a software Failure. It usually includes actual software behavior and expected software behavior. More and varied information can be included as well (i.e. software version, environment, etc)
Now what is a "Bug"??
"Bug", as a term, is a software testing slang that dates back to the late 40's.
Check this out:
http://www.computerhistory.org/tdih/September/9/
Taking all the aforementioned, we can say that the Work Items in TFS and Issues in Redmine both have a "Bug" category that refer to work items that allow Defect management actions.
In conclusion, whether or not the unexpected behavior was found by a customer does not change the fact that a "Defect" is a "Defect", and therefore a "Bug" is a "Bug".


text:
Q: Percentages with Arrays Hi i've been having trouble with this python program. it keeps saying the percentage is = to 0.0
players_goals = ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"]
players_fouls = ["0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0"]

players_goals[0] = int(input("type in number of goals for player 1 then press enter "))
players_goals[1] = int(input("type in number of goals for player 2 then press enter "))
players_goals[2] = int(input("type in number of goals for player 3 then press enter "))
players_goals[3] = int(input("type in number of goals for player 4 then press enter "))
players_goals[4] = int(input("type in number of goals for player 5 then press enter "))
players_goals[5] = int(input("type in number of goals for player 6 then press enter "))
players_goals[6] = int(input("type in number of goals for player 7 then press enter "))
players_goals[7] = int(input("type in number of goals for player 8 then press enter "))
players_goals[8] = int(input("type in number of goals for player 9 then press enter "))
players_goals[9] = int(input("type in number of goals for player 10 then press enter "))
players_goals[10] = int(input("type in number of goals for player 11 then press enter "))

players_fouls[0] = int(input("Now type in number of fouls for player 1 then press enter "))
players_fouls[1] = int(input("type in number of fouls for player 2 then press enter "))
players_fouls[2] = int(input("type in number of fouls for player 3 then press enter "))
players_fouls[3] = int(input("type in number of fouls for player 4 then press enter "))
players_fouls[4] = int(input("type in number of fouls for player 5 then press enter "))
players_fouls[5] = int(input("type in number of fouls for player 6 then press enter "))
players_fouls[6] = int(input("type in number of fouls for player 7 then press enter "))
players_fouls[7] = int(input("type in number of fouls for player 8 then press enter "))
players_fouls[8] = int(input("type in number of fouls for player 9 then press enter "))
players_fouls[9] = int(input("type in number of fouls for player 10 then press enter "))
players_fouls[10] = int(input("type in number of fouls for player 11 then press enter "))

print""
print"the total number of goals is ", players_goals[0] + players_goals[1] + players_goals[2] + players_goals[3] + players_goals[4] + players_goals[5] + players_goals[6] + players_goals[7] + players_goals[8] + players_goals[9] + players_goals[10]
print"the total number of fouls is ", players_fouls[0] + players_fouls[1] + players_fouls[2] + players_fouls[3] + players_fouls[4] + players_fouls[5] + players_fouls[6] + players_fouls[7] + players_fouls[8] + players_fouls[9] + players_fouls[10]

print"player 1's goal percentage is ", (players_goals[0] / (players_fouls[0] + players_goals[0])) * 100.0

my problem is in the last line. no matter what i put in it will always = 0
Thanks for the help
p.s. i'm using python 3.4.1

A: If you input the positive integer number, players_goals[0] <= (players_fouls[0] + players_goals[0].
So players_goals[0] / (players_fouls[0] + players_goals[0] = 0, like 2/(1+2) = 0 in python.
You can use float instead of integer.


text:
Q: Upgrade existing Site Column in SharePoint-hosted app My Scenario:
I have a SharePoint-hosted app with several Lists, Content Types and Site Columns. Now I would like to add some new choices to an existing Site Column (Choice Field).
The Problem:
When upgrading the app, only the Site Column and the Site Content Types are updated. The List Content Types and the List Columns still have the old choices.
The questions:

*

*Is there a declarative way to push down the changes to the List instances?

*Is there a mechanism to catch the upgrade event to inject custom CSOM code?

A: All of the SharePoint components that are deployed to the app web are contained in Web-scoped Features in the app package. For that reason, updating these components is a matter of updating one or more of the Features. This process has not changed since SharePoint 2010 and is documented in How to: Add Elements to an Existing Feature in the SharePoint 2010 SDK. Other articles in the Upgrading Features node may be helpful also, but consider that apps must not include custom code on the SharePoint server, so some aspects of Feature upgrading in SharePoint 2010 are not relevant to updating apps. For example, you can't use the CustomUpgradeAction element when you upgrade the Feature of an app for SharePoint.
Reference : https://msdn.microsoft.com/en-us/library/office/dn265911.aspx

A: According to Steve Curran (MVP) it seems to be impossible to have declarative way of handle the site column lifecycle:
Link to MSDN Forum Entry
In my view Microsoft has to provide a better mechanism than using custom code with every page load.


text:
Q: C# Nested classes I am trying to create a few nested classes within my main class.
public class MyPlayer : Player
{

    public bool TargetEnemy()
    {
        return true;

    }

    public class Movement
    {
        public uint aInt = 1;

        public TurnLeft()
        {

        }
    }

    public class ActionBar
    {

    }
}

I have many different classes so that I would be able to access the MyPlayer class through out the code without passing it to all them I just created a static class that holds the variable for it. I am able to access the MyPlayer->Movement using Main.Units.MyPlayer.Movement but this is not linked to the MyPlayer instance I have defined in the static class.
I want to be able to do MyPlayer->Movement->TurnLeft() for example. How would I achieve this? Thanks for your answers.

A: You might be mistaking the concept of class nesting with class composition. In order to have a Movement instance within your Player class, you can define a private field movement and a public property Movement to access it.
public class Player
{
    public bool TargetEnemy()
    {
        return true;
    }

    private Movement movement = new Movement();

    public Movement Movement
    {
        get { return movement; }
        set { movement = value; }
    }
}

public class Movement
{
    public uint aInt = 1;

    public TurnLeft()
    {

    }
}

public class ActionBar
{

}

Then, you may create an instance of your Player class and access its contained Movement:
Player myPlayer = new Player();
myPlayer.Movement.TurnLeft();

A: Then MyPlayer should have a reference to a Movement instance.
public class MyPlayer : Player
{
    public static Movement movement = new Movement();
    ...
}


text:
Q: error using predict() in r in order to plot ROC i'm doing a logistic regression classifier and i want to plot ROC curve.
My code at the end, when doing prediction and trying to plot Roc is this:
library('ROCR')
pred <- predict(logMod, testing, type = "prob")
pred <- prediction(pred, testing$RainTomorrow)
evalL <- performance(pred, "acc")
plot(evalL)

My classifier is: logistic regression
code:
logMod <- glm(RainTomorrow ~ ., data = training, family = 'binomial')
summary(logMod)

i want to set type = 'prob' in order to plot ROC but when i do so i get the error: Error in match.arg(type): 'arg' should be one of "link", "response", "terms"
Can someone help me? Thanks in advance


text:
Q: For loop in R will not initialize/assign proper values to i Assuming that this is the structure of my initial dataframe random:
title<-c(1:10)
x1<-c(runif(10))
x2<-c(runif(10))
y1<-c(runif(10))
y2<-c(runif(10))
random<-data.frame(title, x1, x2, y1, y2)

I am trying to calculate the relative difference for each variable such that: rel_dif_x = (x2 - x1)/x1.
I am trying to use a for loop to do this, that will print a new data frame analisis_random that has the following structure:
> str(analisis_random)
'data.frame':   10 obs. of  3 variables:
 $ title:
 $dif_rel_x:
 $dif_rel_y:

The for loop I have runs fine when run line-by-line, but when running the whole script it neither initialises the loop nor assigns the proper values to i; it assigns observation values rather than variable values.
for (i in random[ ,c(1, 2*i, 2*i+1)]){

  name1 <- paste("dif_rel_", names(random)[2*i], sep="")
  result <- data.frame(rel_dif=(random[,3]-random[,2])/random[,2])
  names(result) <- c(name1)

  if (i==1){
    analisis_random <- cbind(title=random$title, result)
  }else
    analisis_random <- analisis_random %>%
    cbind(result)
}

A: set.seed(20180808)
# needed for reproductible example

title<-c(1:10)

x1<-c(runif(10))
x2<-c(runif(10))

y1<-c(runif(10))
y2<-c(runif(10))

z1<-c(runif(10))
z2<-c(runif(10))

random<-data.frame(title, x1, x2, y1, y2, z1, z2)

This leads to :
   title        x1         x2        y1        y2         z1        z2
1      1 0.7121342 0.29333074 0.6794730 0.2137924 0.21198103 0.7449928
2      2 0.5885867 0.96948469 0.8244739 0.2012238 0.62282812 0.4100822
3      3 0.1157999 0.30372600 0.9212240 0.8259835 0.57565854 0.7912434
4      4 0.3729795 0.62767128 0.6722178 0.6159081 0.09886538 0.0742936
5      5 0.7058853 0.76085048 0.6954550 0.8716693 0.50313245 0.5764264
6      6 0.8249212 0.07457001 0.1529763 0.8033486 0.24885531 0.1529997
7      7 0.9134835 0.14298191 0.8090683 0.7189970 0.53919015 0.7723871
8      8 0.2983176 0.18880266 0.9015305 0.3370120 0.43882282 0.1521721
9      9 0.6579563 0.63984312 0.9350361 0.9302642 0.35204606 0.7087695
10    10 0.4136457 0.42151020 0.1064115 0.4648270 0.48859854 0.7495744

The loop :
nb.var <- ncol(random) %/% 2
random.analysis <- data.frame(random$title)
for( i in 1:nb.var ) {
  j <- 2*i
  name <- colnames(random)[j]
  name <- substr(name, 1, length(name))
  random.analysis[[name]] <- (random[, j+1] - random[, j]) / random[, j]
}

The result as OP asked :
random.title           x            y          z
1             1 -0.58809625 -0.685355501  2.5144315
2             2  0.64714012 -0.755936777 -0.3415805
3             3  1.62285258 -0.103384684  0.3745013
4             4  0.68285737 -0.083767116 -0.2485377
5             5  0.07786703  0.253379759  0.1456752
6             6 -0.90960348  4.251458518 -0.3851862
7             7 -0.84347621 -0.111327223  0.4324947
8             8 -0.36710858 -0.626177931 -0.6532265
9             9 -0.02752952 -0.005103397  1.0132863
10           10  0.01901274  3.368201500  0.5341314

A: We can use seq() with by = 2 in the for loop to iterate through pairs of columns of the data.frame.
nc <- ncol(random)
for (i in seq(from=2, to=nc-1, by=2)) {
  random[paste0("dif_rel_", names(random)[i])] <- (random[i+1]-random[i])/random[i]
}


text:
Q: What should I change in this Dockerfile to differentiate host and container user permissions? With the aim of avoiding root user running in the container, I've got the following Dockerfile:
FROM public.ecr.aws/docker/library/node:14-alpine AS deps

RUN apk add --no-cache libc6-compat curl \
 && addgroup --system --gid 1001 app_user \
 && adduser --system --uid 1001 app_user

RUN mkdir /app \
  && chown -R app_user:app_user /app
USER app_user
WORKDIR /app

COPY --chown=app_user:app_user package*.json yarn.lock ./
RUN yarn install --production=false --pure-lockfile --ignore-engines

FROM public.ecr.aws/docker/library/node:14-alpine AS builder
WORKDIR /app

COPY --chown=app_user:app_user components pages public queries styles lib @types ./
COPY --chown=app_user:app_user tsconfig.json constants.js next.config.js .babelrc ./
COPY --chown=app_user:app_user scripts/cache/ ./scripts/cache

COPY --chown=app_user:app_user --from=deps /usr/src/app/package.json ./
COPY --chown=app_user:app_user --from=deps /usr/src/app/node_modules ./node_modules

ENV CACHE_REFRESH_SECRET_TOKEN=$CACHE_REFRESH_SECRET_TOKEN

RUN CODEBUILD_BUILD_ID=$CODEBUILD_BUILD_ID DEBUG=graphql:errors,graphql:queries,cache:redis DEBUG_COLORS=true npm run build

EXPOSE 8080 6379
ENTRYPOINT [ "npm", "start"]

Line COPY --chown=app_user:app_user package*.json yarn.lock ./ won't fail, but once reaching the line COPY --chown=app_user:app_user components pages public queries styles lib @types ./ it'll err out with the following message:
unable to convert uid/gid chown string to host mapping: can't find uid for user app_user: no such user: app_user

I'm a bit strange as I think I'm following directions from docs and multiple guides. What should be corrected?

A: There's no particular requirement that the (non-root) user running the container be the same user that owns the files.  It can be a minor security improvement to have the source code owned by root and not world-writable, which will prevent the application from doing things like overwriting its own static images (intentionally or otherwise).
One straightforward approach is to do all of the package installation and building as root in the Dockerfile, and only switch to the non-root user at the very end of the Dockerfile.
FROM public.ecr.aws/docker/library/node:14-alpine AS deps

# Doing the `yarn install` step as root, so no need to create a user here
RUN apk add --no-cache libc6-compat curl

WORKDIR /app
COPY package*.json yarn.lock ./
RUN yarn install --production=false --pure-lockfile --ignore-engines

FROM public.ecr.aws/docker/library/node:14-alpine AS builder

# Create the non-root user, without a specific uid; do not switch yet
RUN adduser --system app_user

# Do the rest of the installation steps, still as root
WORKDIR /app
COPY components pages public queries styles lib @types ./
COPY tsconfig.json constants.js next.config.js .babelrc ./
COPY scripts/cache/ ./scripts/cache

COPY --from=deps /app/package.json /app/yarn.lock ./
COPY --from=deps app/node_modules ./node_modules

RUN yarn build

# As part of the runtime setup, switch to the non-root user now
EXPOSE 8080
USER app_user
CMD ["yarn", "start"]

A: In multistage of docker build you can not re-use the same user so in each FROM you must re-create it.
I made the changes in lines 17 to 23
  1 FROM public.ecr.aws/docker/library/node:14-alpine AS deps
  2
  3 RUN apk add --no-cache libc6-compat curl \
  4  && addgroup --system --gid 1001 app_user \
  5  && adduser --system --uid 1001 app_user
  6
  7 RUN mkdir /app \
  8   && chown -R app_user:app_user /app
  9 USER app_user
 10 WORKDIR /app
 11
 12 COPY --chown=app_user:app_user package*.json yarn.lock ./
 13 RUN yarn install --production=false --pure-lockfile --ignore-engines
 14
 15 FROM public.ecr.aws/docker/library/node:14-alpine AS builder
 16
 17 RUN apk add --no-cache libc6-compat curl \
 18  && addgroup --system --gid 1001 app_user \
 19  && adduser --system --uid 1001 app_user
 20
 21 RUN mkdir /app \
 22   && chown -R app_user:app_user /app
 23 USER app_user
 24 WORKDIR /app
 25
 26 ARG NODE_ENV=production
 27 ARG CODEBUILD_RESOLVED_SOURCE_VERSION
 28 ARG CODEBUILD_BUILD_ID
 29 ARG CODEBUILD_BUILD_NUMBER
 30 ARG CODEBUILD_START_TIME
 31 ARG ELASTIC_CACHE_NODE_ADDRESS
 32 ARG CONTENTFUL_SPACE_ID
 33 ARG CONTENTFUL_ENVIRONMENT_ID
 34 ARG CONTENTFUL_DELIVERY_TOKEN
 35 ARG CONTENTFUL_PREVIEW_TOKEN
 36 ARG PREVIEW_MODE_SECRET_TOKEN
 37 ARG BUILD_TRIGGER_SECRET_TOKEN
 38 ARG CACHE_REFRESH_SECRET_TOKEN
 39 ARG BUILD_RSS_SECRET_TOKEN
 40
 41 ARG NEXT_PUBLIC_ALGOLIA_APPLICATION_ID
 42 ARG NEXT_PUBLIC_ALGOLIA_INDEX_NAME
 43 ARG NEXT_PUBLIC_ALGOLIA_SEARCH_KEY
 44 ARG ALGOLIA_INDEXING_SECRET_TOKEN
 45
 46 ARG CSP_REPORT_URI
 47 ARG CSP_ENABLED
 48
 49 ARG POSTS_CSV_SECRET_TOKEN
 50
 51 ENV CODEBUILD_RESOLVED_SOURCE_VERSION=$CODEBUILD_RESOLVED_SOURCE_VERSION
 52 ENV CODEBUILD_BUILD_ID=$CODEBUILD_BUILD_ID
 53 ENV ELASTIC_CACHE_NODE_ADDRESS=$ELASTIC_CACHE_NODE_ADDRESS
 54 ENV CONTENTFUL_SPACE_ID=$CONTENTFUL_SPACE_ID
 55 ENV CONTENTFUL_ENVIRONMENT_ID=$CONTENTFUL_ENVIRONMENT_ID
 56 ENV CONTENTFUL_DELIVERY_TOKEN=$CONTENTFUL_DELIVERY_TOKEN
 57 ENV CONTENTFUL_PREVIEW_TOKEN=$CONTENTFUL_PREVIEW_TOKEN
 58 ENV PREVIEW_MODE_SECRET_TOKEN=$PREVIEW_MODE_SECRET_TOKEN
 59 ENV BUILD_TRIGGER_SECRET_TOKEN=$BUILD_TRIGGER_SECRET_TOKEN
 60 ENV BUILD_RSS_SECRET_TOKEN=$BUILD_RSS_SECRET_TOKEN
 61
 62 ENV CSP_REPORT_URI=$CSP_REPORT_URI
 63 ENV CSP_ENABLED=$CSP_ENABLED
 64
 65 ENV NEXT_PUBLIC_ALGOLIA_APPLICATION_ID=$NEXT_PUBLIC_ALGOLIA_APPLICATION_ID
 66 ENV NEXT_PUBLIC_ALGOLIA_INDEX_NAME=$NEXT_PUBLIC_ALGOLIA_INDEX_NAME
 67 ENV NEXT_PUBLIC_ALGOLIA_SEARCH_KEY=$NEXT_PUBLIC_ALGOLIA_SEARCH_KEY
 68 ENV ALGOLIA_INDEXING_SECRET_TOKEN=$ALGOLIA_INDEXING_SECRET_TOKEN
 69
 70 ENV POSTS_CSV_SECRET_TOKEN=$POSTS_CSV_SECRET_TOKEN
 71
 72 ENV NEXT_PUBLIC_CODEBUILD_RESOLVED_SOURCE_VERSION=$CODEBUILD_RESOLVED_SOURCE_VERSION
 73 ENV NEXT_PUBLIC_CODEBUILD_BUILD_ID=$CODEBUILD_BUILD_ID
 74 ENV NEXT_PUBLIC_CTF_ENVIRONMENT_ID=$CONTENTFUL_ENVIRONMENT_ID
 75 ENV NEXT_PUBLIC_CODEBUILD_BUILD_NUMBER=$CODEBUILD_BUILD_NUMBER
 76 ENV NEXT_PUBLIC_CODEBUILD_START_TIME=$CODEBUILD_START_TIME
 77
 78 COPY --chown=app_user:app_user components pages public queries styles lib @types ./
 79 COPY --chown=app_user:app_user tsconfig.json constants.js next.config.js .babelrc ./
 80 COPY --chown=app_user:app_user scripts/cache/ ./scripts/cache
 81
 82 COPY --chown=app_user:app_user --from=deps /usr/src/app/package.json ./
 83 COPY --chown=app_user:app_user --from=deps /usr/src/app/node_modules ./node_modules
 84
 85 ENV CACHE_REFRESH_SECRET_TOKEN=$CACHE_REFRESH_SECRET_TOKEN
 86
 87 RUN CODEBUILD_BUILD_ID=$CODEBUILD_BUILD_ID DEBUG=graphql:errors,graphql:queries,cache:redis DEBUG_COLORS=true npm run build
 88
 89 EXPOSE 8080 6379
 90 ENTRYPOINT [ "npm", "start"]


text:
Q: Unable to generate Report when using jasmine-reporters in protractor i Used the following code in config
var jasmineReporters = require('jasmine-reporters');
onPrepare: function() {
    browser.driver.manage().window().maximize();
    browser.params.envi='DEVINT';
    //For output reports
    jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter('./test', true, true));

},

When i ran the tests it ran successfully, but im not seeing any reports generated.
Any Suggestions?

A: I had the same problem. It was sloved by:
framework: "jasmine2",  //must set it if you use JUnitXmlReporter

    onPrepare: function(){  //configure junit xml report

        var jasmineReporters = require('jasmine-reporters');
        jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
            consolidateAll: true,
            filePrefix: 'guitest-xmloutput',
            savePath: 'test/reports'
        }));

    },

Look on the current documentation of https://github.com/larrymyers/jasmine-reporters. At the bottom is the instruction for protractor. I solved the same problem by adding this to protractor.conf.js

A: Not sure it would help but here is what is working for me:
onPrepare: function () {
    require("jasmine-reporters");

    // junit reporter
    var capsPromise = browser.getCapabilities();
    capsPromise.then(function (caps) {
        var browserName = caps.caps_.browserName.toUpperCase();
        var browserVersion = caps.caps_.version;
        var prePendStr = browserName + "-" + browserVersion + "-";
        jasmine.getEnv().addReporter(new
            jasmine.JUnitXmlReporter("test-results", true, true, prePendStr));
    });
},

Using jasmine 1.3, jasmine-reporters 1.0.1, protractor 2.0.

A: s-patchamatla
You need to downgrade version of Jasmine to jasmine-reporters@1.0.0
Newer versions of jasmine reporters does no longer attaches to the Jasmine object
so, in case you tried to use jasmine-reporters with Protractor, you need to use a 1.x version of jasmine-reporters.
npm install jasmine-reporters@~1.0.0
onPrepare: function () {
    require("jasmine-reporters");

    // junit reporter
    var capsPromise = browser.getCapabilities();
    capsPromise.then(function (caps) {
        var browserName = caps.caps_.browserName.toUpperCase();
        var browserVersion = caps.caps_.version;
        var prePendStr = browserName + "-" + browserVersion + "-";
        jasmine.getEnv().addReporter(new
            jasmine.JUnitXmlReporter(<report path>, true, true, prePendStr));
    });
}

i guess this should work for you.


text:
Q: Speed up Eclipse CDT start up? it takes loads of time for eclipse CDT to start!
in order to test a simple .cpp file we need to wait for minutes to actually start coding.
any tips to speed up it's start?
i have disabled all plugins at start up and i'm using java 7.1 and eclipse juno.
i tried to configure the eclipse.ini file which lead to crash many times.

A: This answer about configuring the ecilpse.ini file can help you:
What are the best JVM settings for Eclipse?
The configuration I have has increased a bit the overal performance, but at the cost of slightly slower startup
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20120913-144807
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-nosplash
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-server
-Dosgi.requiredJavaVersion=1.7
-Dhelp.lucene.tokenizer=standard
-Xss1m
-Xms512m
-Xmx1g
-Xverify:none
-XX:CompileThreshold=2500

A: I think since Eclipse is written in Java and relies on the JVM, you might want to look at where your JVM in installed (in addition to looking where Eclipse itself is installed). Maybe you have a slow disk. I like having my development tools on a SSD, but that is an expensive option.


text:
Q: Laravel Event:fire payload wrong format I am currently using Laravel 4.2.
When I fire an Event sending the payload as array, listener retrieves the payload with it only being the first item in the associative array.
Firing the event:
$data = array('user' => $user, 'password_clear'  => $pass);
Event::fire('user.created', $data);

Listening like this:
Event::listen('user.created', function($data) {
    dd($data);
}

Dumps the following:
object(User)#809 (20) {
    ...
}

While I would have expected an array. Am I missing something?
Thanks,
Federico


text:
Q: How can I find a first occurrence of a string from a list in another string in python I have a list of strings (about 100), and I want to find the first occurence of one of them in another string and the index in which it occurred.
I keep the index, and afterwords search again using another word list from that index on, and back to the first list until it reaches the end of the string.
My current code (that searches for the first occurrence) looks like:
        def findFirstOccurence(wordList, bigString, startIndex):
            substrIndex = sys.maxint
            for word in wordList:
                tempIndex = bigString.find(word, startIndex)
                if tempIndex < substrIndex and tempIndex != -1:
                    substrIndex = tempIndex
            return substrIndex

This codes does the job, but takes a lot of time (I run it several times for the same word lists but in 100 big strings (about ~10K-20K words each).
I am sure there's a better way (and a more pythonic way to do so).

A: This seems work well and tells you what word it found (although that could be left out):
words = 'a big red dog car woman mountain are the ditch'.split()
sentence = 'her smooth lips reminded me of the front of a big red car lying in the ditch'

from sys import maxint
def find(word, sentence):
    try:
        return sentence.index(word), word
    except ValueError:
        return maxint, None
print min(find(word, sentence) for word in words)

A: A one liner with list comprehension would be
return min([index for index in [bigString.find(word, startIndex) for word in wordList] if index != -1])

But I would argue if you split it into two lines its more readable
indexes = [bigString.find(word, startIndex) for word in wordList]
return min([index for index in indexes if index != -1])

A: import re

def findFirstOccurence(wordList, bigString, startIndex=0):
    return re.search('|'.join(wordList), bigString[startIndex:]).start()

wordList = ['hello', 'world']
bigString = '1 2 3 world'

print findFirstOccurence(wordList, bigString)


text:
Q: Spark JobServer JobEnvironment def main(args: Array[String]) {
  val conf = new SparkConf().setMaster("local[4]").setAppName("LongPiJob")
  val sc = new SparkContext(conf)
  val env = new JobEnvironment {
    def jobId: String = "abcdef"
    //scalastyle:off
    def namedObjects: NamedObjects = ???
    def contextConfig: Config = ConfigFactory.empty
  }
  val results = runJob(sc, env, 5)
  println("Result is " + results)
}

I took this code from the longpi example for spark jobserver relating to the new api which is part of the github repo. I don't understand what new JobEnvironment or any of the variables inside it. My IDE is complains with these default settings.
https://github.com/spark-jobserver/spark-jobserver/blob/spark-2.0-preview/job-server-tests/src/main/scala/spark/jobserver/LongPiJob.scala

A: JobEnvironment has runtime information about the Job. Like jobId, contextConfig and namedObjects
Now it is easy for you to access these information from runJob.


text:
Q: Release Google Places Autocomplete Response - now declared as internal Recently upgrading Google API versions from 11.8.0 to 12.0.1 resulted in task.result.release() in my completion listener from Task<AutocompletePredictionBufferResponse> being marked as internal.
Should I handle the possibility of an internal data leak differently? Does the Google Places API now handle releasing the result itself? I cannot find information about this in the release notes for 12.0.0 or 12.0.1. The current documentation still says you must release the result.
Here is where I use it:
.addOnCompleteListener { task: Task<AutocompletePredictionBufferResponse> ->
    if (task.isSuccessful) {

        {...}

        //Release to avoid internal data leak
        task.result.release()
    } else {
        Log.e("AutoCompletePredictions", task.exception?.message)

        //Release to avoid internal data leak
        task.result.release()
    }
}
.addOnFailureListener(this@NewLocationActivity) {
    Log.e("AutoCompletePredictions", it.message)
}

This is the error message I am receiving:

zzb.release is marked as internal and should not be accessed from apps less... (⌘F1)
  This API has been flagged with a restriction that has not been met.  Examples of API restrictions: * Method can only be invoked by a subclass * Method can only be accessed from within the same library (defined by the Gradle library group id) .* Method can only be accessed from tests. . You can add your own API restrictions with the @RestrictTo annotation.

The full getSuggestions() method in which I use the completion listener
private fun getSuggestions() {
    val filter = AutocompleteFilter.Builder()
        .setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS)
        .setCountry(CountryManager.getCountryISO())
        .build()

    Places.getGeoDataClient(this@NewLocationActivity/*, null*/) // uncomment for v11.8.0
        .getAutocompletePredictions(
            activity_new_location_edit_text.text.toString(),
            null,
            filter
        )
        .addOnCompleteListener { task: Task<AutocompletePredictionBufferResponse> ->
            if (task.isSuccessful) {
                val addressList: ArrayList<String> = arrayListOf()

                var index = 0
                for(item in task.result) {
                    if(index >= MAX_SUGGESTION_RESULTS)
                        break

                    addressList.add(item.getFullText(null).toString())
                    index++
                }

                if(!(addressList.size == 1 && addressList[0] == activity_new_location_edit_text.text.toString()))
                    loadGoogleAddressesIntoSuggestionList(addressList)

                //Release to avoid internal data leak
                task.result.release()
            } else {
                Log.e("AutoCompletePredictions", task.exception?.message)

                //Release to avoid internal data leak
                task.result.release()
            }
        }
        .addOnFailureListener(this@NewLocationActivity) {
            Log.e("AutoCompletePredictions", it.message)
        }
}

A: Seems like an unintended change.
It started in 12.0.0, that has the following "known issue" in its release notes:

An annotation causes spurious lint errors claiming GoogleSignIn and
  CredentialsClient are internal-only. These can safely be ignored.

Guess they weren't only for GoogleSignIn and CredentialsClient, but they fixed only those in 12.0.1:

Fixes issue that caused spurious Android lint errors claiming
  GoogleSignIn and CredentialsClient were internal-only.

The corresponding source code of release() appears to be the same across versions 11.8.0-12.0.1, so i believe you can safely ignore these warnings.


text:
Q: nginx permission denied error on alpine drupal 8 docker image We have created a container from this image: https://github.com/bytepark/alpine-drupal8 and connected our drupal 8 site. It seems to load just fine, but when we go to add a new field to a content-type, it fails with no error in the page. Checking /var/log/nginx/error.log I see:

2016/09/16 20:58:11 [crit] 13685#13685: *26 open()
  "/var/lib/nginx/tmp/fastcgi/7/00/0000000007" failed (13: Permission
  denied) while reading upstream, client: x.x.x.x, server: _, request:
  "POST
  /admin/structure/views/ajax/add-handler/content/page_1/field?_wrapper_format=drupal_ajax
  HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host:
  "x.x.x.x:8080", referrer:
  "http://x.x.x.x:8080/admin/structure/views/view/content"

I have tried setting permissions to 777 on /var/lib/nginx and subfolders but that has no effect:
root@:/usr/share/nginx/html# ls -l /var/lib/nginx/
total 8
drwxrwxrwx    2 root     root          4096 Sep 16 20:11 html
lrwxrwxrwx    1 root     root            14 Aug 24 13:27 logs -> /var/log/nginx
lrwxrwxrwx    1 root     root            22 Aug 24 13:27 modules -> /usr/lib/nginx/modules
lrwxrwxrwx    1 root     root            10 Aug 24 13:27 run -> /run/nginx
drwxrwxrwx    6 nginx    nginx         4096 Sep 16 20:04 tmp

root@:/usr/share/nginx/html# ls -l /var/lib/nginx/tmp
total 16
drwxrwxrwx    2 nginx    nginx         4096 Sep 16 20:04 fastcgi
drwxrwxrwx    2 nginx    nginx         4096 Sep 16 20:04 proxy
drwxrwxrwx    2 nginx    nginx         4096 Sep 16 20:04 scgi
drwxrwxrwx    2 nginx    nginx         4096 Sep 16 20:04 uwsgi

I've tried lots of different solutions from google but nothing seems to make any difference, is there something I am missing here?


text:
Q: can´t PUT with node.js I keep getting a Cannot POST /discos/edit/ message, with a 404 error at my terminal.
I can´t seem to find the correct path, as i believe it may be a URL error somewhere i can´t find.
Thanks for your help.
My code:
`router.get(`/discos/edit/:id`, editRecord)`

discosCtrl.editRecord = async (req, res) => {
const disco = await DiscoSchema.findById(req.params.id).lean()
//console.log(disco)
res.render(`discos/edit-record`, {disco})
}`

This get method works fine.
Then, this is my PUT method, where i can´t post the info i´ve received from my previous GET request.
`router.put(`/discos/edit/:id`, updateRecord)`

`discosCtrl.updateRecord =  (req, res) => {
console.log(req.body)
}`

My Html line, where i override the POST method:
<form action="/discos/edit/{{disco.id}}?_method=PUT" method="POST">
<input type="hidden" name="_method" value="PUT">

`
Thanks for your help.
I can´t seem to find my mistake. I´m following some tutorial using the same code but they´re succeeding while i´m just getting the same 404 error.