text:
Q: GDB's .gdbinit issues annoying feedback when "focus cmd" is used I am writting a .gdbinit file which would set up my layout as I always want it.So I put this inside the .gdbinit:
tui enable
tui new-layout mylayout {-horizontal {src 8 asm 2} 6 regs 4} 8 status 0 cmd 2
layout mylayout
refresh
set tui border-kind space
set tui tab-width 4
set tui compact-source on
focus cmd

Then I start GDB with a command gdb-multiarch and everything is set up correctly, except that I get this annoying feedback:
--Type <RET> for more, q to quit, c to continue without paging--

It looks like this:

I found out that if I comment out the last line in the .gdbinit, feedback message dissapears. But then cmd window is not focused.
How can I focus the cmd window and at the same time avoid the annoying feedback message?

A: Since GDB 9 you could use the with command.  Change the last line to:
with pagination off -- focus cmd

This will temporarily turn off pagination while the focus command runs, which will prevent the query being displayed.
Of course, that the query is displayed at all is clearly a bug... but the above should allow you to work around it.


text:
Q: Setting a return-path when sending trough Yahoo servers returns error 553 I'm using the following code to send the emails and it was working ok
    $headers = array (
        'From' => $emailAddress,
        'To' => $emailDest,
            'Subject' => $subject,
            'Return-Path' => 'bounce@*****.eu',
            'X-Codent' => '['.$codent_header.']',
            'X-Ent' => '['.$ent_header.']',
            'X-Bzd' => '['.$database.']',
            'X-Email' => '['.$email['Email'].']'
    );
    $hdrs = $mime->headers($headers, true);

    $smtp = Mail::factory('smtp',
        array ('host' => 'ssl://'.$emailServer,
        'auth' => true,
        'port' => '465',
        'username' => $emailUtilizator,
        'password' => $emailParola));

    $mail = $smtp->send($emailDest, $hdrs, $body);

However a few days ago the script stopped working when sending trough yahoo. A quick check of the logs revealed the send attempt returned the following error:
Failed to set sender: bounce@*****.eu [SMTP: Invalid response code received from server (code: 553, response: From address not verified - see http://help.yahoo.com/l/us/yahoo/mail/original/manage/sendfrom-07.html)]

The script works if I remove the Return-Path but doing so will mean I can't track emails anymore and won't be able to get accurate reports.
The error occurs only when dealing with yahoo. Google, live and other addresses work fine.
Any idea on how to overcome this?

A: I suggest checking your mail server logs. Find out what the remote (yahoo) mail server does - I think it's trying to verify that the return address is actually valid.
Also make sure that the return address exists and accepts mail.

redpajama_set_name: RedPajamaStackExchange


text:
Q: while loop/switch statement I am getting a " java.util.NoSuchElementException" that seems to point to my Scanner object within the while loop. everything works and prints fine, but when it loops through it always has the same error there.
I've tried to clear the buffer. I've tried moving my scanner outside of the loop.
I've tried moving my instantiation of the object as well as the variable itself.
while(loop) {
  printMenu();
  scanA1.next();
        switch (choice) {

Exception in thread "main" java.util.NoSuchElementException

A: It probably happens because there are no more tokens left when scanA1.next() is called.
You can check if there are tokens left like this:
  while(loop) {
    printMenu();
    if (scanA1.hasNext()) { // Checks if there are more tokens to read
        scanA1.next();
            switch (choice) {
...

A: It was because I made several different scanners w/in the methods of my switch that I closed. Once I deleted the .close(); the loop worked perfect. Thanks for the help though!


text:
Q: sprintf not working correctly - causing access violation I am using sprintf() however, I am getting an Access Violation error;
This error only occurs when the content of the string only contains 3 or less ints. (displayed below)
This is a method which reads in ints from a txt file and then sorts them;
string getIntsFromFile() {

ifstream myfile("/pathToFile/file.txt");
vector<int> values;
int value = 0;
string testString;

while (!myfile.eof())
{
    myfile >> value;

    if (myfile.eof()) break;

    values.push_back(value);
}

sort(values.begin(), values.end(), greater<int>());

for (int i = 0; i < values.size(); i++)
    testString = testString + to_string(values[i]) + "\n";
return testString;
}

Then I call this function using;
char myString[128];
sprintf(myString, "%s", getIntsFromFile());
This only works if there are more than 3 ints in the txt file but any less prompt an Access Violation error.
The ints in the txt file are seperated by a '\n', so there is only one int on each line.

A: sprintf with "%s" format specifier expects a char* argument. getIntsFromFile() on the other hand returns an std::string. The behavior is undefined (which in your case you can observe as an access violation) in case the argument type does not match the expected type .
To confirm this, you can try
sprintf(myString, "%s", getIntsFromFile().c_str());

instead.
Note however, that this is also likely to fail as the number of integers increases and the string exceeds the allocated size of the myString buffer.

A: Either use c_str() method on string or use std::copy() method for this purpose.


text:
Q: Dimension formula $\dim_x(X) = \dim(S_p)+\text{trdeg}_ k\ \kappa (\mathfrak p)$ from The Stacks project I have a question about the proof of  Lemma 10.116.3  from The Stacks project. The claim is:
Lemma 10.116.3. Let $k$ be a field. Let $S$ be a finite type
$k$ algebra.
Let $X=\operatorname{Spec}(S)$. Let $\mathfrak p \subset S$ be a prime ideal,
and let $x \in X$ be the corresponding point. Then we have
$$\dim_x(X) = \dim(S_p)+\text{trdeg}_ k\  \kappa (\mathfrak p).$$
Proof. By Lemma 10.116.1 we know that
$r= \text{trdeg}_ k\  \kappa (\mathfrak p)$ is equal to
the dimension of $V(\mathfrak p)$. Pick any maximal chain of primes
$ \mathfrak p \subset \mathfrak p_1 \subset \ldots \subset \mathfrak p_ r $
starting with $p$ in $S$. This has length $r$ by Lemma 10.114.4.
Let $q_j, j \in J$ be the minimal primes of $S$ which are
contained in $p$.
These correspond 1−1 to minimal primes in the localization $S_p$
via the rule $\mathfrak q_ j \mapsto \mathfrak q_ jS_{\mathfrak p}$.
By Lemma 10.114.5 we know that
$\dim_x(X)$ is equal to the maximum of the dimensions of the
rings $S/q_j$. For each $j$ pick a maximal chain of primes
$\mathfrak q_ j \subset \mathfrak p'_1 \subset \ldots \subset \mathfrak p'_{s(j)} = \mathfrak p$.
Then $\dim (S_{\mathfrak p})=\max _{j \in J} s(j)$. Now, each chain
$$ \mathfrak q_ i \subset \mathfrak p'_1 \subset \ldots \subset \mathfrak p'_{s(j)} = \mathfrak p \subset \mathfrak p_1 \subset \ldots \subset \mathfrak p_ r   $$
is a maximal chain in $S/\mathfrak q_ j$, and by what was said before we
have $ \dim _ x(X) = \max _{j \in J} r + s(j) $. The lemma follows.
Question: Why the constructed prime ideals chain
$$ \mathfrak q_ i \subset \mathfrak p'_1 \subset \ldots \subset \mathfrak p'_{s(j)} = \mathfrak p \subset \mathfrak p_1 \subset \ldots \subset \mathfrak p_ r   $$
is maximal in $S/\mathfrak q_ j$. Or in other words why every maximal
prime chain in $S/\mathfrak q_ j$ should contain $\mathfrak p$
as an intermediete chain member. That is I not see any reason why for an arbitrary $k$ algebra $R$ and prime $p \subset R$ there should be hold $\dim(R)= \dim(R_p)+ \dim(R/p)$. $S$ and $S/\mathfrak q_ j$ were not assumed
to be catenary rings or do I miss something.
Adds: I know that there is a bunch of books on cummutative algebra containing a different proof of this claim but my motivation here is to understand the step in this proof.

A: To address the question: A finite type $k$-algebra that is a domain, is catenary. The reference for this statement is Matsumura, Commutative Algebra, Chapter 5, (14.H).
So every maximal chain of prime ideals in $S/\mathfrak{q_j}$ has the same length.


text:
Q: Error calling to the cloud jclouds So I am trying to download files on a rackspace server to my local server. It is laid out here. For some odd reason, I am trying to make the initial call to the cloud and it is giving me some serious feedback. No idea where to go from here. I've tried all sorts of different Maven dependencies to fix the problem, but none have come close. Am I overlooking something? TIA!
My code:
public static void main (String[] args){

    CloudFilesApi cloudFilesApi = ContextBuilder.newBuilder(PROVIDER)
            .credentials(USERNAME, KEY)
            .buildApi(CloudFilesApi.class);

}

And here are my errors (without Guice):
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/inject/Stage
at org.jclouds.ContextBuilder.<clinit>(ContextBuilder.java:151)
at com.unidev.download.Main.main(Main.java:10)
Caused by: java.lang.ClassNotFoundException: com.google.inject.Stage
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 2 more

Here are my dependencies (now):
<dependencies>
<!-- Rackspace US dependencies -->
<dependency>
  <groupId>org.apache.jclouds.provider</groupId>
  <artifactId>rackspace-cloudfiles-us</artifactId>
  <version>${jclouds.version}</version>
</dependency>

Code snippet for dependency tree(updated): https://codeshare.io/bfbKg

A: I guess it is a Maven issue... When I was building the Maven project and using the dependencies via the pom file, it was somehow building incorrectly. Instead, I started a Java file and built a lib folder, pulled all the jars I needed and then just tied them in via the build path... and it is working well now...


text:
Q: Airflow-Installation User issue We have installed airflow in linux environment after creating virtual environment. It was installed as root user. All the installed files were created with root permission.
In dag, we are using BashOperator, where python script is called as bash command. This script supposed to run as different user 'ABC'. I cannot trigger the airflow using this user.
While running dag, airflow is triggered as root by default, which causes the python script to run as root and script fails due to permission issues of folder structure.
Airflow should not triggered as root.
Cant we install the airflow, using user other than root? Kindly suggest the best practices to be followed for this case.

A: You have two options here:
1/ install airflow with another user (reconmmended)
2/ if you just want to execute script as different specific unix users, the BashOperator allows you to do it with the parameter "run_as_user":
t1 = BashOperator(task_id='create_dir', bash_command='mkdir /tmp/airflow_dir_test', dag=dag, run_as_user='user1')


text:
Q: XSLT Conversion I need to perform an XML XSLT conversion. I am new to this and have read a lot of tutorials but have come across one that is a bit challenging for me and hoping someone can point me in the right direction.
I have two elements, for example:
<linum class="topic/linum secondAtt/secondVal">Blah</linum>
<linum class="topic/linum">Blah</linum>

If the linum class attribute has a second value, i must add another attribute to that element using the second value of that attribute. If it only has one then I leave it as is.
So the output for the above two the output would be:
<linum class="topic/linum secondAtt/secondVal" newAttribute="secondVal">Blah</linum>
<linum class="topic/linum">Blah</linum>

I hope I have explained this well, if not hopefully my output is clear as only the first element is transformed by adding a new attribute with the second value.
I appreciate any help I am given!

A: The following will work for your example, where the class attribute contains no more than two space-delimited values:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>

<!-- identity transform -->
<xsl:template match="@*|node()">
    <xsl:copy>
        <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="linum[contains(@class, ' ')]">
    <linum class="{@class}" newAttribute="{substring-after(substring-after(@class, ' '), '/')}">
        <xsl:apply-templates/>
    </linum>
</xsl:template>

</xsl:stylesheet>


text:
Q: Mac cannot preview SRT files in Finder or QuickLook view (other Mac can view file without opening) Does anyone have any idea why this might have happened? I suspect it has something to do with installing VLC, but I could be wrong. Is there any way I can fix this?
Setting Text Edit to open all SRT files and even AppCleaning VLC from the machine didn't fix the issue. Nor did restarting the Mac after doing these things.


text:
Q: Calculating maximum number of consecutive decrease in value in recent 6 months

PID
XID
Name
StatementDate
Balance

Person A
Trans 1
Account 1
2015-04-30
100

Person A
Trans 1
Account 1
2015-05-31
0

Person A
Trans 2
Account 2
2015-04-30
1000

Person A
Trans 2
Account 2
2015-05-31
900

Person A
Trans 2
Account 2
2015-06-30
800

Person A
Trans 2
Account 2
2015-07-31
700

Person B
Trans 3
Account 3
2015-04-30
200

Person B
Trans 3
Account 3
2015-05-31
100

Person B
Trans 3
Account 4
2015-04-30
700

Person B
Trans 3
Account 4
2015-05-31
800

Person B
Trans 3
Account 4
2015-06-30
600

Person B
Trans 3
Account 4
2015-07-31
1000

In the above table, I am trying to find out the maximum consecutive decrease for each Account Name in the recent 6 months and append it to the dataset (as below, the rows which have missing Balance).

PID
XID
Name
StatementDate
Balance
IsDecreasing
ConsecDecrease
MaxConsecutiveDecreaseL6M

Person A
Trans 1
Account 1
2015-07-31

0

Person A
Trans 1
Account 1
2015-04-30
100
FALSE
0

Person A
Trans 1
Account 1
2015-05-31
0
TRUE
1

Person A
Trans 1
Account 1
2015-07-31

3

Person A
Trans 2
Account 2
2015-04-30
1000
FALSE
0

Person A
Trans 2
Account 2
2015-05-31
900
TRUE
1

Person A
Trans 2
Account 2
2015-06-30
800
TRUE
2

Person A
Trans 2
Account 2
2015-07-31
700
TRUE
3

Person B
Trans 3
Account 3
2015-07-31

1

Person B
Trans 3
Account 3
2015-04-30
200
FALSE
0

Person B
Trans 3
Account 3
2015-05-31
100
TRUE
1

Person B
Trans 3
Account 4
2015-07-31

2

Person B
Trans 3
Account 4
2015-04-30
700
FALSE
0

Person B
Trans 3
Account 4
2015-05-31
800
TRUE
1

Person B
Trans 3
Account 4
2015-06-30
600
TRUE
2

Person B
Trans 3
Account 4
2015-07-31
1000
FALSE
0

The data I have is [PID, AccountName, StatementDate, Balance].
The columns I'm trying to create is [IsDecreasing, Consecutive, MaxConsecutiveDecreaseL6M], with the last field as the ultimate goal.
I'm trying to do this with pandas but I'm having issue finding out the Balance of previous months to determine whether the Balance has decreased from M-1 to M , for each AccountName (for every month in the recent 6 months).
Anyone has any idea to do this via python/pandas?
Edit:
I have successfully gotten the desired columns and values with the below code by looping through each row in the dataframe.
But it is taking quite a long time as I have around 86k rows.
Is there any other way to do it which could shorten the computing time?
P.S. Assuming that the name of dataframe which I have loaded the first table as 'joined_df'.
# Compute Max Consecutive Decrease in recent 6 months

# Create IsDecreasing column
for idx in joined_df.index:
    # Skipping first row as there is no previous row to compare to
    if idx == 0:
        continue

    # If 'PID', 'XID', 'Name' matches with previous row, check whether the 'Balance' is higher than previous row (next month)
    if (joined_df.loc[idx, ['PID', 'XID', 'Name']] == joined_df.loc[idx - 1, ['PID', 'XID', 'Name']]).all():
            if ((joined_df.loc[idx, 'Balance']) - (joined_df.loc[idx - 1, 'Balance'])) > 0:
                joined_df.loc[idx, 'IsDecreasing'] = True
            else:
                joined_df.loc[idx, 'IsDecreasing'] = False
    else:
        joined_df.loc[idx, 'IsDecreasing'] = False

# Create ConsecDecrease column
for idx in joined_df.index:
    # Skipping first row as there is no previous row to compare to
    if idx == 0:
        continue

    # Initialize variable
    consec_decrease = 0

    # Loop back to previous rows (maximum 5 rows back, i.e. 5 months)
    # If 'PID', 'XID', 'Name' matches, compute the Consecutive Decrease for each row.
    if (joined_df.loc[idx, ['PID', 'XID', 'Name']] == joined_df.loc[idx - 1, ['PID', 'XID', 'Name']]).all():
        if joined_df.loc[idx, 'IsDecreasing'] == True:
            for n in range(6):
                if joined_df.loc[idx - n, 'IsDecreasing'] == True:
                    consec_decrease += 1
                else:
                    # Break the loop if IsDecreasing becomes False in previous record
                    break
        else:
            consec_decrease = 0

    # Convert ConsecDecrease column type to integer
    joined_df.loc[idx, 'ConsecDecrease'] = int(consec_decrease)

# Create MaxConsecBalanceDecreaseL6M column
reference_month = datetime.datetime(2016, 1, 31)
reference_month_begin = reference_month.replace(day = 1)
reference_month_end = reference_month + dateutil.relativedelta.relativedelta(day = 31)
l6m = reference_month_begin - dateutil.relativedelta.relativedelta(months = 5)

max_consec_decrease_s = joined_df[(l6m <= joined_df['StatementDate']) & (joined_df['StatementDate'] <= reference_month_end)] \
                   .groupby(['PID', 'XID', 'Name'])['ConsecDecrease'].max()

consec_decrease_df = max_consec_decrease_s.rename('MaxConsecBalanceDecreaseL6M') \
                                          .reset_index()

consec_decrease_df['StatementDate'] = reference_month

# Append MaxConsecBalanceDecreaseL6M column into main dataset
final_df = joined_df.append(consec_decrease_df, ignore_index = True, sort = False)


text:
Q: How to get the return value from the hook of fastify? How to pass parameters from hooks to request handler in Fastify?
For example, I want to get the username in the BasicAuth hook from the request.
const fastify = require('fastify')()
const authenticate = {realm: 'Westeros'}
fastify.register(require('@fastify/basic-auth'), { validate, authenticate })
function validate (username, password, req, reply, done) {
  if (username === 'Tyrion' && password === 'wine') {
    // How to return username from here?
    done()
  } else {
    done(new Error('Winter is coming'))
  }
}

fastify.after(() => {
  fastify.addHook('onRequest', fastify.basicAuth)

  fastify.get('/', (req, reply) => {
    // How to get the username here?
  })
})

A: You need to attach it to the request object:
const fastify = require('fastify')()
const authenticate = { realm: 'Westeros' }
fastify.register(require('@fastify/basic-auth'), { validate, authenticate })

// this decoration will help the V8 engine to improve the memory allocation for the request object
fastify.decorateRequest('user', null)

function validate(username, password, req, reply, done) {
  if (username === 'Tyrion' && password === 'wine') {
    // add it to the
    req.user = { username }
    done()
  } else {
    done(new Error('Winter is coming'))
  }
}

fastify.after(() => {
  fastify.addHook('onRequest', fastify.basicAuth)

  fastify.get('/', async (req, reply) => {
    return { hello: req.user.username }
  })
})

fastify.inject({
  method: 'GET',
  url: '/',
  headers: {
    authorization: 'Basic ' + Buffer.from('Tyrion:wine').toString('base64')
  }
}, (err, res) => {
  console.log(res.payload)
})


text:
Q: CardView as BottomSheetDialog In the app I am designing I would like to be able to bring a BottomSheet with transparent background, with contents in a CardView so that the cardview overlays on top of whatever is on the screen.
Note that now whenever I open it the background of the linearlayout is still grey, so that "floating" feeling is not there, it's just a CardView drawn on a grey background, not transparent.
Here is the code for the Sheet dialog:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@android:color/transparent"
android:orientation="vertical">

<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/spacing_middle"
    app:cardCornerRadius="3dp"
    app:cardElevation="5dp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="@dimen/spacing_smlarge">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:minHeight="@dimen/spacing_mxlarge"
            android:orientation="horizontal">

            <LinearLayout
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="vertical">

                <TextView
                    android:id="@+id/name"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:text="Place Name"
                    android:textAppearance="@style/TextAppearance.AppCompat.Title"
                    android:textColor="@color/colorPrimary" />

            </LinearLayout>

            <ImageButton
                android:id="@+id/bt_close"
                android:layout_width="@dimen/spacing_mxlarge"
                android:layout_height="@dimen/spacing_mxlarge"
                android:background="?attr/selectableItemBackgroundBorderless"
                android:tint="@color/grey_60"
                app:srcCompat="@drawable/ic_close" />

        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:layout_marginBottom="@dimen/spacing_middle"
            android:layout_marginTop="@dimen/spacing_middle"
            android:background="@color/colorPrimary" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:id="@+id/horeca_logo"
                android:layout_width="@dimen/spacing_large"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/spacing_medium"
                android:layout_marginRight="@dimen/spacing_medium"
                android:tint="@color/grey_40"
                app:srcCompat="@drawable/ic_home" />

            <TextView
                android:id="@+id/horeca_type"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:textSize="16dp"
                android:text="Place Type"
                android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
                android:textColor="@color/grey_600" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ImageView
                android:layout_width="@dimen/spacing_large"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/spacing_medium"
                android:layout_marginRight="@dimen/spacing_medium"
                android:tint="@color/grey_40"
                app:srcCompat="@drawable/ic_location" />

            <TextView
                android:id="@+id/address"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:textSize="16dp"
                android:text="Place Address"
                android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
                android:textColor="@color/grey_600" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="@dimen/spacing_large"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/spacing_medium"
                android:layout_marginRight="@dimen/spacing_medium"
                android:tint="@color/grey_40"
                app:srcCompat="@drawable/ic_assessment" />

            <android.support.v7.widget.AppCompatRatingBar
                android:id="@+id/horeca_stars"
                style="@style/Yellow.Small.AppCompatRatingBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:numStars="5"
                android:rating="3.5"
                android:stepSize="0.5"
                android:theme="@style/Yellow.Small.AppCompatRatingBar" />

            <TextView
                android:id="@+id/horeca_rating"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="4.7 (51)"
                android:tint="@color/grey_40" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">

            <ImageView
                android:layout_width="@dimen/spacing_large"
                android:layout_height="wrap_content"
                android:layout_marginEnd="@dimen/spacing_medium"
                android:layout_marginRight="@dimen/spacing_medium"
                android:tint="@color/grey_40"
                app:srcCompat="@drawable/ic_clock" />

            <TextView
                android:id="@+id/opening_hours"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:textSize="16dp"
                android:layout_marginTop="8dp"
                android:text="Opening Hours"
                android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
                android:textColor="@color/grey_600" />

            <View
                android:layout_width="80dp"
                android:layout_height="match_parent"/>

            <Button
                android:id="@+id/bt_details"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:layout_marginEnd="5dp"
                android:background="@drawable/custom_button_outlined"
                android:textColor="@color/colorPrimary"
                android:text="Pin'Ups"
                android:textStyle="bold"
                android:theme="@style/Button.Primary" />

        </LinearLayout>

    </LinearLayout>

</android.support.v7.widget.CardView>

The design should look similar to this:

A: -add this property to cardview tag, it will add effect like shadow.
    app:cardUseCompatPadding="true"


text:
Q: Count the number of selected options using jQuery I have over 53 similar select sections in my DOM and I need to count how many of a particular option have been selected by the user.
An example of my DOM would be something like this:
<select name="attendance" class="dd" id="20130101">
  <option>p</option>
  <option>a</option>
  <option>s</option>
</select>
<select name="attendance" class="dd" id="20130102">
  <option>p</option>
  <option>a</option>
  <option>s</option>
</select>
... x 51 more times!

What I would like to do is return the quantity (count) of options where the user has selected "a" for example. I have tried $('.dd option:selected').length however it returns the total count of all select sections (being 53).
Thanks for any help!

A: http://jsfiddle.net/dkK5x/
$(".dd option:selected[value=a]").length;

A: You can just combine selectors, in this case :contains:
$(".dd option:contains(a):selected").length;

However, this depends on no option being contained entirely by another option, for example:
<option>a</option>
<option>aa</option>

You could also set the value of the option instead, perhaps even with jQuery:
$("option").val(function () {
   return $(this).text();
});

A: I would put a value-attribute into your options
<select name="attendance" class="dd" id="20130101">
  <option value="p">p</option>
  <option value="a">a</option>
  <option value="s">s</option>
</select>

Through this, the selector is fairly easy through using an attribute-selector:
$('select option[value="a"]:selected').length;

I created a small fiddle to show you this in actual use: http://jsfiddle.net/mx5Yd/1/
The number of selected options with the "a" - value is logged to the console when clicking "count"


text:
Q: Filter Blanks when link is by RefRecId I have created a new table QueryCodes and used the new surrogate key functionality in 2012.
A Foreign key relationship has been added to SalesTable using a RefRecId as per the new RecID foreign key guidelines. This all works great and I can now select a QueryCode on the SalesTable by a descriptive field rather than a drop down full of RecIds.
However - Filtering! In any grid showing all sales orders (SalesTable) I cannot filter for "Blank" query codes, ie SalesTable records without a query code attached. I can filter the sales table perfectly using the descriptive field from QueryCodes (for the record it is called "name").
For example, if I filter by QueryCode "Q_1" on SalesTable I see all "Q_1" queried sales orders.
When filtering by "" (blank) I see all orders, both with and without a QueryCode populated.
Is this a limitation in the new RefRecId functionality or is there something I need to change to be able to filter a blank foreign key reference field?
Edit;
The Customers list page can be used to see a standard example of this issue, personalize the grid to add "employee responsible" (the second in the list, the first is deleted). This is referenced by rec id and filtering the field by blank does not work. Filtering by employee name or not blank does (!"").

A: Okay, I am of the opinion that this is a bug. However I have found a partial workaround.
In the example above a filter for a specific Employee Responsible name (including wildcards) will work, however a NOT filter or a blank filter will not.
To filter for blanks I would type the following in the filter field to query for a zero RecId directly;
(CustTable.MainContactWorker == 0)

or non blanks;
(CustTable.MainContactWorker != 0)

This does not fix the issue where filtering for something like !Anthony* does not include blanks, but it will allow a list of blanks.


text:
Q: Exr file sequence to mov with ffmpeg When I convert an EXR file sequence with x264 using FFmpeg and convert the colorspace from linear to SRGB (with gamma 0.45454545) I get some heavy banding issues (most visible on a dark gradient). For me it looks like it converts the video first and afterwards applies the gamma correction on 8-bit clipped video. If so is it somehow possible to convert the imagesequence from linear to srg first and then convert it into Quicktime?
Here is the ffmpeg command I use:
C:/ffmpeg.exe -y -i C:/seq_v001.%04d.exr -vf lutrgb=r=gammaval(0.45454545):g=gammaval(0.45454545):b=gammaval(0.45454545) -vcodec libx264 -pix_fmt yuv420p -preset slow -crf 18 -r 25 C:/out.mov

Here is the output:
ffmpeg version N-47062-g26c531c Copyright (c) 2000-2012 the FFmpeg developers
  built on Nov 25 2012 12:25:21 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-pthreads --enable-runtime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
  libavutil      52.  9.100 / 52.  9.100
  libavcodec     54. 77.100 / 54. 77.100
  libavformat    54. 37.100 / 54. 37.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.102 /  3. 23.102
  libswscale      2.  1.102 /  2.  1.102
  libswresample   0. 17.101 /  0. 17.101
  libpostproc    52.  2.100 / 52.  2.100
Input #0, image2, from 'C:/seq_v001.%04d.exr':
  Duration: 00:00:09.60, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: exr, rgb48le, 960x540 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
[libx264 @ 0000000004d11540] using SAR=1/1
[libx264 @ 0000000004d11540] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
[libx264 @ 0000000004d11540] profile High, level 3.1
[libx264 @ 0000000004d11540] 264 - core 128 r2216 198a7ea - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=18 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=50 rc=crf mbtree=1 crf=18.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mov, to 'C:/out.mov':
  Metadata:
    encoder         : Lavf54.37.100
    Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p, 960x540 [SAR 1:1 DAR 16:9], q=-1--1, 12800 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (exr -> libx264)
Press [q] to stop, [?] for help
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
frame=   16 fps=0.0 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s
Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
frame=   34 fps= 33 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s
Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
frame=   52 fps= 34 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s
Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
frame=   68 fps= 34 q=0.0 size=       0kB time=00:00:00.00 bitrate=   0.0kbits/s
Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
frame=   85 fps= 33 q=23.0 size=      47kB time=00:00:00.44 bitrate= 867.5kbits/s
Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
frame=  104 fps= 34 q=23.0 size=      94kB time=00:00:01.20 bitrate= 640.3kbits/s
Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
frame=  121 fps= 34 q=23.0 size=     133kB time=00:00:01.88 bitrate= 577.8kbits/s
Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
frame=  139 fps= 34 q=23.0 size=     172kB time=00:00:02.60 bitrate= 543.4kbits/s
Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
frame=  157 fps= 34 q=23.0 size=     213kB time=00:00:03.32 bitrate= 525.6kbits/s
Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
frame=  175 fps= 34 q=23.0 size=     254kB time=00:00:04.04 bitrate= 516.0kbits/s
Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
frame=  193 fps= 35 q=23.0 size=     287kB time=00:00:04.76 bitrate= 494.6kbits/s
Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
frame=  211 fps= 35 q=23.0 size=     332kB time=00:00:05.48 bitrate= 496.4kbits/s
Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
[exr @ 000000000dffa660] Found more than one compression attribute
[exr @ 000000000dffaaa0] Found more than one compression attribute
[exr @ 000000000dffaf00] Found more than one compression attribute
[exr @ 000000000dffb340] Found more than one compression attribute
[exr @ 000000000dffb7a0] Found more than one compression attribute
[exr @ 000000000dffbbe0] Found more than one compression attribute
[exr @ 000000000dffc040] Found more than one compression attribute
[exr @ 000000000dff8c40] Found more than one compression attribute
[exr @ 000000000dff90c0] Found more than one compression attribute
[exr @ 000000000dff9520] Found more than one compression attribute
[exr @ 000000000dff9960] Found more than one compression attribute
[exr @ 000000000dff9dc0] Found more than one compression attribute
[exr @ 000000000dffa200] Found more than one compression attribute
frame=  228 fps= 34 q=23.0 size=     421kB time=00:00:06.16 bitrate= 559.8kbits/s
frame=  240 fps= 32 q=-1.0 Lsize=     708kB time=00:00:09.52 bitrate= 609.3kbits/s

video:705kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.505636%
[libx264 @ 0000000004d11540] frame I:2     Avg QP:15.07  size: 18186
[libx264 @ 0000000004d11540] frame P:73    Avg QP:16.51  size:  3719
[libx264 @ 0000000004d11540] frame B:165   Avg QP:18.38  size:  2502
[libx264 @ 0000000004d11540] consecutive B-frames:  2.5%  3.3% 42.5% 51.7%
[libx264 @ 0000000004d11540] mb I  I16..4: 46.2% 33.3% 20.4%
[libx264 @ 0000000004d11540] mb P  I16..4:  6.8%  2.0%  0.6%  P16..4: 29.4% 10.5%  4.6%  0.0%  0.0%    skip:46.1%
[libx264 @ 0000000004d11540] mb B  I16..4:  1.8%  0.7%  0.2%  B16..8: 40.9%  6.5%  0.3%  direct: 1.2%  skip:48.5%  L0:52.0% L1:47.5% BI: 0.5%
[libx264 @ 0000000004d11540] 8x8 transform intra:24.7% inter:81.3%
[libx264 @ 0000000004d11540] direct mvs  spatial:93.3% temporal:6.7%
[libx264 @ 0000000004d11540] coded y,uvDC,uvAC intra: 10.7% 31.4% 24.9% inter: 2.3% 9.0% 2.9%
[libx264 @ 0000000004d11540] i16 v,h,dc,p: 83% 11%  6%  1%
[libx264 @ 0000000004d11540] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  9%  9% 52%  6%  4%  4%  5%  5%  5%
[libx264 @ 0000000004d11540] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 11% 44%  5%  4%  3%  3%  4%  3%
[libx264 @ 0000000004d11540] i8c dc,h,v,p: 69% 15% 15%  2%
[libx264 @ 0000000004d11540] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0000000004d11540] ref P L0: 48.9%  0.1% 16.8% 17.0% 11.3%  5.8%
[libx264 @ 0000000004d11540] ref B L0: 57.7% 21.9% 13.9%  6.4%
[libx264 @ 0000000004d11540] ref B L1: 82.4% 17.6%
[libx264 @ 0000000004d11540] kb/s:600.61

Does someone have an idea where to start?

A: Probably a bit late here, but if anyone else has the same issue.
The problem is the gamma correction is applied after the initial exr image has already been loaded. Load the exr with the gamma 2.2 for sRGB and don't gamma correct the output video. Also, quicktime is notorious for wierd gamma shifts so don't use it to play back your videos.
C:/ffmpeg.exe -y -gamma 2.2 -i C:/seq_v001.%04d.exr -vcodec libx264 -pix_fmt yuv420p -preset slow -crf 18 -r 25 C:/out.mov

A: Hi dont know if i got it all but did some further testing. I converted a exr with linear space and a exr with srgb space.
The linear i converted with ffmpeg into srgb with the following tag:
-vf lutrgb=r=gammaval(0.45454545):g=gammaval(0.45454545):b=gammaval(0.45454545)

and the result had the banding:

The one which already was srgb and did not have the -vf lutrgb tag looked nice:

Do you still think the problem is the bits reduction because both source images had exactly the same bit depth? Is there something else i should try which could lead to a solution?
@rajib Dont you think the problem is that the colorspace conversion happens after the bits reduction. And then of course the 8 bit image has not enough information left for the colorspace conversion?
If so is it somehow possible to stack different operations in a given order:
1. Dont change the input bit depth or have it higher than 8 bits
2. Do the gamma lut conversion
3. Reduce the bit depth to 8 bits

A: Possibly you should convert the 32 bit images to lower bits if you wish to use ffmpeg to save a mov file.
Else you are better off using Nuke to render to mov. Nuke is perfectly capable of rendering to mov format, and applying the gamma correction in a grade node will convert from linear space to sRGB. The bits will be also "scaled" down automatically when you save to a 10 bit or 8 bit mov.


text:
Q: How to get the table-name and database-name in the CDC event received from debezium kafka connect Setup: I have CDC enabled on MS SQL Server and the CDC events are fed to Kafka using debezium kafka connect(source). Also more than one table CDC events are routed to a single topic in Kafka.
Question: Since I have more than one table data in the kafka topic, I would like to have the table name and the database name in the CDC data.
I am getting the table name and database name in MySQL CDC but not in MS SQL CDC.
Below is the Debezium source connector for the SQL Server
curl -i -X POST -H "Accept:application/json" -H "Content-Type:application/json" localhost:8083/connectors/ -d '{
  "name": "cdc-user_profile-connector",
  "config": {
    "connector.class": "io.debezium.connector.sqlserver.SqlServerConnector",
    "tasks.max": "1",
    "database.hostname": "<<hostname>>",
    "database.port": "<<port>>",
    "database.user": "<<username>>",
    "database.password": "<<password>>",
    "database.server.name": "test",
    "database.dbname": "testDb",
    "table.whitelist": "schema01.table1,schema01.table2",
    "database.history.kafka.bootstrap.servers": "broker:9092",
    "database.history.kafka.topic": "digital.user_profile.schema.audit",
    "database.history.store.only.monitored.tables.ddl": true,
    "include.schema.changes": false,
    "event.deserialization.failure.handling.mode": "fail",
    "snapshot.mode": "initial_schema_only",
    "snapshot.locking.mode": "none",
    "transforms":"addStaticField,topicRoute",
    "transforms.addStaticField.type":"org.apache.kafka.connect.transforms.InsertField$Value",
    "transforms.addStaticField.static.field":"source_system",
    "transforms.addStaticField.static.value":"source_system_1",
    "transforms.topicRoute.type":"org.apache.kafka.connect.transforms.RegexRouter",
    "transforms.topicRoute.regex":"(.*)",
    "transforms.topicRoute.replacement":"digital.user_profile",
    "errors.tolerance": "none",
    "errors.log.enable": true,
    "errors.log.include.messages": true,
    "errors.retry.delay.max.ms": 60000,
    "errors.retry.timeout": 300000
  }
}'

I am getting the below output (Demo data)
{
  "before": {
    "profile_id": 147,
    "email_address": "test@gmail.com"
  },
  "after": {
    "profile_id": 147,
    "email_address": "test_modified@gmail.com"
  },
  "source": {
    "version": "0.9.4.Final",
    "connector": "sqlserver",
    "name": "test",
    "ts_ms": 1556723528917,
    "change_lsn": "0007cbe5:0000b98c:0002",
    "commit_lsn": "0007cbe5:0000b98c:0003",
    "snapshot": false
  },
  "op": "u",
  "ts_ms": 1556748731417,
  "source_system": "source_system_1"
}

My requirement is to get as below
{
  "before": {
    "profile_id": 147,
    "email_address": "test@gmail.com"
  },
  "after": {
    "profile_id": 147,
    "email_address": "test_modified@gmail.com"
  },
  "source": {
    "version": "0.9.4.Final",
    "connector": "sqlserver",
    "name": "test",
    "ts_ms": 1556723528917,
    "change_lsn": "0007cbe5:0000b98c:0002",
    "commit_lsn": "0007cbe5:0000b98c:0003",
    "snapshot": false,
    "db": "testDb",
    "table": "table1/table2"
  },
  "op": "u",
  "ts_ms": 1556748731417,
  "source_system": "source_system_1"
}

A: Debezium Kafka-Connect generally puts data from each table in a separate topic and the topic name is of the format hostname.database.table. We generally use the topic name to distinguish between the source table & database name.
If you are putting the data from all the tables manually into one topic then you might have to add the table and database name manually as well.

A: This is planned as a part of https://issues.jboss.org/browse/DBZ-875 issue


text:
Q: Crear conexión a base de datos sql en un modulo de drupal 8 MySQL y SQL Server Estoy creando un módulo custom de Drupal 8 y quiero incluir una conexión a una base de datos y que devuelva el nombre de las tablas existentes.
El módulo se instala correctamente, aparece en el menú de configuración, el problema surge al pinchar en el enlace, pues me dice: "The website encountered an unexpected error. Please try again later." y no muestra la página. Adjunto código hasta el momento creado.
<?php
/**
 * @file
 * Contains \Drupal\hello_world\Controller\HelloController.
 */
namespace Drupal\hello_world\Controller;
class HelloController {
  public function content() {

    $usuario="emerita";
    $password="1234";
    $host="localhost";
    $kk = "";
    try {
        $dbh = new PDO( "mysql:host=$host", $usuario, $password);
        $dbs = $dbh->query( 'SHOW databases' );

        while( ( $db = $dbs->fetchColumn( 0 ) ) !== false ){
        // $kk .= $db."<br>";

        }
    }
    catch(PDOException $e){
       echo "Connection failed: " . $e->getMessage();
    }

    return array(
      '#type' => 'markup',
      '#markup' => t($db),
    );
  }
}

Cualquier ayuda es bienvenida. Un saludo.
EDITO
En vista de que no he podido hacerlo, dado que al tratar con un array no se le puede hacer que muestre $db así, lo que he hecho ha sido crear un formulario y derivar todo a un archivo.php en la propia raiz de Drupal. Después de procesar todo genera un botón para enviar al usuario de vuelta al Drupal base.
No es una forma elegante, y seguramente tenga mas de un problema a nivel de seguridad, pero es una forma que, para salir del paso, sirve.
Al igual este sistema me ha servido para mostrar una serie de imágenes guardadas en la base de datos (están en el sistema de archivo, pero se guarda una "ruta" en la base de datos y el nombre, para poder crear un enlace luego en el src de ).
Igualmente se agradece cualquier apunte al respecto o consejo.

A: Al final la forma mas cómoda, y que me permite hacer lo que quiero, ha sido el siguiente código:
<?php
/**
 * @file
 * Contains \Drupal\edicion_slider\Controller\edicionslider.
 */
namespace Drupal\edicion_slider\Controller;
class edicionslider {

 public function content() {

include "llamadabdatossli.php";

    return array(
      '#type' => 'markup',
      '#markup' => basedatosslider(),
      '#attached' => [
        'library' => [
          'edicion_slider/slider_admin',

         ],
      ],
    );
  }
}
?>

He montado el módulo de manera normal, pero en el archivo php que va dentro del controller lo que hice fue llamar a una función ubicada en otro archivo, en este caso llamadabdatossli.php. El sistema de Drupal 8 no está mal, pero hay cosas que prefiero gestionar yo de una manera mas directa, pero sin tener que tocar el core. Por tanto la llamada a la base de datos, inserción de imagenes, edición y visualización se hace todo a traves de un archivo, el que mencione antes, que, mediante PDO y prepare statements, gestiona la base de datos y los inputs que el usuario puede hacer. Desde luego, si Drupal 8 te permite hacer lo que quieres hacer, debería hacerse el módulo como indican en los tutoriales, pero en este caso, que quería mas precisión, mas bloques y que un solo bloque puede mostrar mas contenido de manera condicional, está ha sido la mejor manera para mí.


text:
Q: Tables Relation in database can I have three tables in my database and link them to each other like this?is it correct?

A: Yes, you can set up your data this way.
No, it is probably not a good idea if orders.userId is supposed to be the same as orders.IndexCards.UserId.  Unless you need the redundancy for a good reason, it is better to have the link in only one place.
Of course, if orders.userId has nothing to do with the corresponding IndexCards.userId, then your data model is fine.

A: You have an anomaly in your db. The anomaly that I've found is in the table named Orders. Since IndexCard Table has that column(idfromUsers), you should delete it from that table(Orders) and removed its relationship to User table.
This means that orders has a relation to IndexCards and IndexCards has a relation to the Users.


text:
Q: Styling triangle pattern with icon in AngularJS with CSS I want to replace all the star character in my pattern with any of the CSS icon. But all I get is only one Icon. The whole h1 tag is replaced by the one star. I can't access every character in the variable to replace with star icon since it is bonded to HTML as an array.
I don't get any clue.

   <input class="form-control" type="number" ng-model="givenNumber" ng-change="printStars()">

{{x}}

I want the output to be a triangle pattern with an icon but not in the text.

A: I have somewhat modified your initial code and it is working now. This is far from perfect but you will get the general idea: it is easy to handle this if you imagine a 2 dimensional array (array of arrays). Like columns and rows. I renamed your variables to better represent this approach.
Also note that I completely removed the "*" string because it is not required at all. In the line where I wrote row.push(j) you could add anything in there instead of j (e.g. the following string: "example") because it does not matter - the ng-repeat will run on each item and the value is not used.
Again, this is far from perfect, but will guide you to the right direction I hope!

var app = angular.module("demo", []);
app.controller("testCtrl", function($scope) {
   $scope.temp = "";
   $scope.rows = []; // init empty array

   $scope.printStars = function() {
      var n = $scope.givenNumber;
      $scope.rows = [];

      for(var i = 1; i<=n; i++){
        var row = [];
        for(j = 1; j<=i; j++){
          row.push(j);
        }
        $scope.rows.push(row);
      }
   }
});
.row{
  display:inline-block; /* to make sure rows' stars appear next to each other */
}

<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">

     <input class="form-control" type="number" ng-model="givenNumber" ng-change="printStars()">


text:
Q: How to print empty value for element without an integer value in C So far I have the program does what it needs to do. My issue now is that I have two arrays and when I print them I get 0s for empty elements. I want the empty elements to print nothing.
Example:
Array 1:
1 1
Array 2:
3 3 3 3
Output:
1 3 1 3 0 3 0 3
My goal is:
1 3 1 3 3 3
which is to remove the 0s if I didnt input 0 in array
My code:
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main(void) {
    char * line = NULL;
    size_t len = 0;

    char * line2 = NULL;
    size_t len2 = 0;

    char ch;
    int counter = 0;

    char ch2;
    int counter2 = 0;

    int mSize;
    int mergedArray[20];

    int i = 0; // for loop
    int j = 0;

    int * myPtr;
    myPtr = (int * ) malloc(counter * sizeof(int));

    int * myPtr2;
    myPtr2 = (int * ) malloc(counter2 * sizeof(int));

    while (getline( & line, & len, stdin) != EOF) {
        //===============
        //value 1 for line 1
        ch = * line;

        printf("line 1: Test: %s\n", line);

        char * start = line;
        char * eon;
        long value;
        //===============
        //value 2 line 2
        getline( & line2, & len2, stdin);
        ch2 = * line2;
        printf("line 2: Test: %s\n", line2);

        char * start2 = line2;
        char * eon2;
        long value2;

        //==============
        errno = 0;

        //============loop for line 1 =================

        printf("=============\n");
        printf("Line 1\n");
        while ((value = strtol(start, & eon, 0)),
            eon != start &&
            !((errno == EINVAL && value == 0) ||
                (errno == ERANGE && (value == LONG_MIN || value == LONG_MAX))))

        {

            //getting the size of the line
            counter++;

            start = eon;
            errno = 0;

            myPtr[counter] = value;
            // printf("Array #1 [%d] %d\n",counter , myPtr[counter]);

        } //end of while
        printf("Size: %d\n", counter);
        printf("=============\n");

        //============loop for line 2 =================
        printf("Line 2\n");
        while ((value2 = strtol(start2, & eon2, 0)),
            eon2 != start2 &&
            !((errno == EINVAL && value2 == 0) ||
                (errno == ERANGE && (value2 == LONG_MIN || value2 == LONG_MAX))))

        {
            //getting the size of the line
            counter2++;

            start2 = eon2;
            errno = 0;

            myPtr2[counter2] = value2;
            //printf("Array #2 [%d] %d\n",counter2 , myPtr2[counter2]);

        } //end of while
        printf("Size: %d\n", counter2);
        printf("=============\n");

    for (i = 0; i < counter; i++) {
        mergedArray[i] = myPtr[i + 1]; // not used
    }

    mSize = counter + counter2;

    for (i = 0, j = counter; j < mSize && i < counter2; i++, j++) {
        mergedArray[j] = myPtr2[i + 1]; // not used
        //here I print out both arrays
        printf("%d %d ", myPtr[i + 1], myPtr2[i + 1]);
    }
    } // end of main while

    return 0;
}

A: Your program is extremelly complicated. It is a good practice to separate login into functions. In the solution below you need to provide large enouth array for the destination array and both arrays to be merged.
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define SA(a) (sizeof(a)/sizeof((a)[0]))

size_t mergeArrays(int *dest, const int *src1, const int *src2, size_t size_1, size_t size_2)
{
    size_t pos = 0;
    for(size_t index = 0; index < MAX(size_1, size_2); index++)
    {
        if(index < size_1) dest[pos++] = src1[index];
        if(index < size_2) dest[pos++] = src2[index];
    }
    return pos;
}

int main(void)
{
    int arr1[] = {1,1};
    int arr2[] = {3,3,3,3,3};
    int dest[SA(arr1) + SA(arr2)];

    size_t destsize = mergeArrays(dest, arr1, arr2, SA(arr1), SA(arr2));

    for(size_t index = 0; index < destsize; index++)
    {
        printf("%d ", dest[index]);
    }
    printf("\n");
}

https://godbolt.org/z/WG4v6T
Here you have the version reading from user and using dynamic memory allocation:
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define SA(a) (sizeof(a)/sizeof((a)[0]))

size_t mergeArrays(int *dest, const int *src1, const int *src2, size_t size_1, size_t size_2)
{
    size_t pos = 0;
    for(size_t index = 0; index < MAX(size_1, size_2); index++)
    {
        if(index < size_1) dest[pos++] = src1[index];
        if(index < size_2) dest[pos++] = src2[index];
    }
    return pos;
}

int *readArray(size_t *size)
{
    int *arr = NULL;

    printf("Enter size:");
    if(scanf(" %zu", size) != 1) goto func_return;
    arr = malloc(*size * sizeof(*arr));
    if(!arr) { free(arr); arr = NULL; goto func_return;}
    for(size_t index = 0; index < *size; index++)
    {
        if(scanf(" %d", &arr[index]) != 1) {free(arr); arr = NULL; goto func_return;}
    }

    func_return:
    return arr;
}

int main(void)
{
    size_t size1, size2;
    int *arr1 = readArray(&size1);
    int *arr2 = readArray(&size2);
    int *dest = NULL;

    if(arr1 && arr2) dest = malloc(size1 + size2);

    if(dest)
    {
        size_t destsize = mergeArrays(dest, arr1, arr2, size1, size2);

        for(size_t index = 0; index < destsize; index++)
        {
            printf("%d ", dest[index]);
        }
    }
    printf("\n");
    free(arr1);
    free(arr2);
    free(dest);
}

https://godbolt.org/z/5sMbYj


text:
Q: Convolution of multiple 1D signals in a 2D matrix with multiple 1D kernels in a 2D matrix I have a randomly defined H matrix of size 600 x 10. Each element in this matrix H can be represented as H(k,t).  I obtained a speech spectrogram S which is 600 x 597. I obtained it using Mel features, so it should be 40 x 611 but then I used a frame stacking concept in which I stacked 15 frames together. Therefore it gave me (40x15) x (611-15+1) which is 600 x 597.
Now I want to obtain an output matrix Y which is given by the equation based on convolution Y(k,t) = ∑ H(k,τ)S(k,t-τ). The sum goes from τ=0 to τ=Lh-1.  Lh in this case would be 597.
I don't know how to obtain Y. Also, my doubt is the indexing into both H and S when computing the convolution.  Specifically, for Y(1,1), we have:
Y(1,1) = H(1,0)S(1,1) + H(1,1)S(1,0) + H(1,2)S(1,-1) + H(1,3)S(1,-2) + ...
Now, there is no such thing as negative indices in MATLAB - for example, S(1,-1) S(1,-2) and so on. So, what type of convolution should I use to obtain Y? I tried using conv2 or fftfilt but I think that will not give me Y because Y must also be the size of S.

A: That's very easy.  That's a convolution on a 2D signal only being applied to 1 dimension.  If we assume that the variable k is used to access the rows and t is used to access the columns, you can consider each row of H and S as separate signals where each row of S is a 1D signal and each row of H is a convolution kernel.
There are two ways you can approach this problem.
Time domain
If you want to stick with time domain, the easiest thing would be to loop over each row of the output, find the convolution of each pair of rows of S and H and store the output in the corresponding output row.  From what I can tell, there is no utility that can convolve in one dimension only given an N-D signal.... unless you go into frequency domain stuff, but let's leave that for later.
Something like:
Y = zeros(size(S));
for idx = 1 : size(Y,1)
    Y(idx,:) = conv(S(idx,:), H(idx,:), 'same');
end

For each row of the output, we perform a row-wise convolution with a row of S and a row of H.  I use the 'same' flag because the output should be the same size as a row of S... which is the bigger row.
Frequency domain
You can also perform the same computation in frequency domain.  If you know anything about the properties of convolution and the Fourier Transform, you know that convolution in time domain is multiplication in the frequency domain.  You take the Fourier Transform of both signals, multiply them element-wise, then take the Inverse Fourier Transform back.
However, you need to keep the following intricacies in mind:

*

*Performing a full convolution means that the final length of the output signal is length(A)+length(B)-1, assuming A and B are 1D signals.  Therefore, you need to make sure that both A and B are zero-padded so that they both match the same size.  The reason why you make sure that the signals are the same size is to allow for the multiplication operation to work.

*Once you multiply the signals in the frequency domain then take the inverse, you will see that each row of Y is the full length of the convolution.  To ensure that you get an output that is the same size as the input, you need to trim off some points at the beginning and at the end.  Specifically, since each kernel / column length of H is 10, you would have to remove the first 5 and last 5 points of each signal in the output to match what you get in the for loop code.

*Usually after the inverse Fourier Transform, there are some residual complex coefficients due to the nature of the FFT algorithm.  It's good practice to use real to remove the complex valued parts of the results.
Putting all of this theory together, this is what the code would look like:
%// Define zero-padded H and S matrices
%// Rows are the same, but columns must be padded to match point #1
H2 = zeros(size(H,1), size(H,2)+size(S,2)-1);
S2 = zeros(size(S,1), size(H,2)+size(S,2)-1);

%// Place H and S at the beginning and leave the rest of the columns zero
H2(:,1:size(H,2)) = H;
S2(:,1:size(S,2)) = S;

%// Perform Fourier Transform on each row separately of padded matrices
Hfft = fft(H2, [], 2);
Sfft = fft(S2, [], 2);

%// Perform convolution
Yfft = Hfft .* Sfft;

%// Take inverse Fourier Transform and convert to real
Y2 = real(ifft(Yfft, [], 2));

%// Trim off unnecessary values
Y2 = Y2(:,size(H,2)/2 + 1 : end - size(H,2)/2 + 1);

Y2 should be the convolved result and should match Y in the previous for loop code.
Comparison between them both
If you actually want to compare them, we can.  What we'll need to do first is define H and S.  To reconstruct what I did, I generated random values with a known seed:
rng(123);
H = rand(600,10);
S = rand(600,597);

Once we run the above code for both the time domain version and frequency domain version, let's see how they match up in the command prompt.  Let's show the first 5 rows and 5 columns:
>> format long g;
>> Y(1:5,1:5)

ans =

          1.63740867892464          1.94924208172753          2.38365646354643          2.05455605619097          2.21772526557861
          2.04478411247085          2.15915645246324          2.13672842742653          2.07661341840867          2.61567534623066
         0.987777477630861           1.3969752201781          2.46239452105228          3.07699790208937          3.04588738611503
          1.36555260994797          1.48506871890027          1.69896157726456          1.82433906982894          1.62526864072424
          1.52085236885395          2.53506897420001          2.36780282057747          2.22335617436888          3.04025523335182

>> Y2(1:5,1:5)

ans =

      1.63740867892464          1.94924208172753          2.38365646354643          2.05455605619097          2.21772526557861
      2.04478411247085          2.15915645246324          2.13672842742653          2.07661341840867          2.61567534623066
     0.987777477630861           1.3969752201781          2.46239452105228          3.07699790208937          3.04588738611503
      1.36555260994797          1.48506871890027          1.69896157726456          1.82433906982894          1.62526864072424
      1.52085236885395          2.53506897420001          2.36780282057747          2.22335617436888          3.04025523335182

Looks good to me!  As another measure, let's figure out what the largest difference is between one value in Y and a corresponding value in Y2:
>> max(abs(Y(:) - Y2(:)))

ans =

      5.32907051820075e-15

That's saying that the max error seen between both outputs is in the order of 10-15.  I'd say that's pretty good.


text:
Q: How do i find a value stored in a linked list than in turn is stored in a hashmap I have the following hashmap, that stores string keys and linked list values
public HashMap<String, LinkedList<String>> wordIndex = new HashMap<>();

My wordIndex contains multiple linked lists that contains the word "algorithms", so I wrote the following code to see if my hashmap is able to find the word "algorithms"
String getWord(String query) { //query=user input in this case algorithms

    if(wordIndex.containsValue(query.toLowerCase()))
    {
        return "hello";          //should return hello if word is found
    }
    else
    {
        return "none";
    }
}

However it is always returning none, which means it can find the word in the linked list.
So what is the correct procedure to traverse through linked Lists inside Hashmaps. I searched but couldn't find any answer.
Also I need to return all the KEYS, containing the query word (in this case "algorithm"). I cant seem to find a function in the hashmap class that can do that(or maybe I saw it but didn't understand it). I am new to hashmaps could you guys please help me out and point me in the right direction.

A: You can't do that. If you want to check if there is the word in any LinkedList in the HashMap, you should do something like :
String getWord(String query) { //query=user input in this case algorithms
    for(LinkedList<String> l : wordIndex.values()) {
        if(l.contains(query.toLowerCase())) {
            return "hello";          //should return hello if word is found
        }
    }
    return "none";
}

A: public boolean containsValue(Object value) {
if (value == null)
        return containsNullValue();

Entry[] tab = table;
    for (int i = 0; i < tab.length ; i++)
        for (Entry e = tab[i] ; e != null ; e = e.next)
            if (value.equals(e.value))
                return true;
return false;
}

if you look at the containsValue method you will see it uses Entry object equals method for matching and if you look this Entry class equals method objects other than Entry type it returns false. I think the best way is using contains method of linked list while iterating over map for each record
 public final boolean equals(Object o) {
        if (!(o instanceof Map.Entry))
            return false;
        Map.Entry e = (Map.Entry)o;
        Object k1 = getKey();
        Object k2 = e.getKey();
        if (k1 == k2 || (k1 != null && k1.equals(k2))) {
            Object v1 = getValue();
            Object v2 = e.getValue();
            if (v1 == v2 || (v1 != null && v1.equals(v2)))
                return true;
        }
        return false;
    }


text:
Q: How to save & retrieve image in Database from PictureBox control in windows Forms (VB.NET) I am having trouble in browse & then save an image to SQL Server.ALso I want to retrieve that image.
This is the code to browse image & show it in PictureBox1 Control
Public Sub SelectImage()

    With OpenFileDialog1
        '.InitialDirectory = "C:\"
        .Filter = "All Files|*.*|Bitmaps|*.bmp|GIFs|*.gif|JPEGs|*.jpg"
        .FilterIndex = 4
    End With

    If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
        PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
        PictureBox1.BorderStyle = BorderStyle.Fixed3D
    End If

I have created a image feild in a table & this is my stored procedure
  Public Sub Insert_Update_Personal()
    Dim ds As DataSet = New DataSet()
    Dim cmd As SqlCommand = New SqlCommand("sp_Insert_Update_Personal", con)
    con.Open()
    cmd.CommandType = CommandType.StoredProcedure
    cmd.Parameters.AddWithValue("@picture", UploadImage)
    LastPID = Convert.ToInt32(cmd.ExecuteScalar())
    cmd.Dispose()
    con.Close()

But don't know how to pass it to image parameter & Please suggest .Also is there any way that I can save image on Local drive & just save the url /location/name in database?
Which method would be better
Thanks

A: Just another approach, try this to save your image file localy and load them without storeing them in database.
Note: picPath is the path of the image file, you can use openfiledialog or other method to set it in lblPhoto.text
Private Sub SavePhoto()
Try
Dim picPath As String = ""
Dim picName As String = ""
picPath = lblPhoto.Text
If lblPhoto.Text = "" Then
picName = (txtimage.Text + ".tus")
End If
If picPath <> "" And (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\Photo\\" + picName) = True) Then
File.Delete(AppDomain.CurrentDomain.BaseDirectory + "\\Photo\\" + picName)
Else
picName = (txtimage.Text + ".tus")
File.Copy(picPath, AppDomain.CurrentDomain.BaseDirectory + "\\Photo\\" + picName, True)
End If
Catch ex As Exception

End Try

End Sub

Now to load the saved photo do the following
If (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "Photo\" + txtimage.Text + ".tus") = True) Then
PictureBox1.Image = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + "Photo\" + txtPolicy_No.Text + ".tus", True)
End If


text:
Q: Cydia Repo "The following signatures were invalid: NODATA 1 NODATA 2" Can anyone help us to check why our Cydia repo always generate an error message "GPG error,  Release: The following signatures were invalid: NODATA 1 NODATA 2
When add the source to Cydia or the Cydia sour Reload.
Our repo url is http://ikeymonitor.com/apt
Thanks for your help

A: I haven't experienced anything unusual when adding your repo.
I can even install the iLostFinder without any problems.
Where is your repo hosted? If it's at home, you need to note that some services dosen't work indside the local network. I don't know if that does also count cydia repos. But try using another network and/or another iPad/iPhone.


text:
Q: load: failed to read matrix from file I'm try to load a some variables ( matrix,number ...) from a file .dat,  but when I try to load I get the mistake load: failed to read matrix from file.
this is the main file
function resultado = batallaNaval()
   init();
end

function resultado =init()
  load historial.dat;
  jugadas = historial()
end

The code the file historial.dat is:
a=[1 1 ;2 1; 3  0; 4  7];
numberBoats= 5;

which is the correct form to load the variables?

A: I think you want to do this instead
load('historial.dat', '-mat');

This tells MATLAB it's in the .mat file format, even though it doesn't have the right extension.


text:
Q: Obtain word before/after a character with regex in Python This is supposed to be easy using capturing groups, but I am not getting the correct words. I have been using the following:
#Before
print(re.sub(r'\b([A-Za-z0-9]+)\b(?=\.?\s*(\&|\-|and))',r'\1','A. & B.',flags=re.IGNORECASE))
A. & B.

#After
print(re.sub(r'(\&|\-|and)\s*\b([A-Za-z0-9]+)\b',r'\2','A. & B.',flags=re.IGNORECASE))
A. B.

The string can be one of the following:
A. - B.
A.-B.
A. & B.
A.&B.
A. AND B.

The idea is to get the word before/after of ampersand| hyphen | and I divided in two regex to get both words. In this example, before would get just A and the after B.
Why the capturing groups are not printing A and B in the previous examples?
Thanks in advance :)

A: The string '\1' is octal for the decimal value 1 or 0x01 hex.
>>> import re
>>> re.sub(r'\b([A-Za-z0-9]+)\b(?=\.?\s*(\&|\-|and))','\1','A. & B.',re.IGNORECASE)
'\x01. & B.'

Regex needs backreferences to be escaped.
Either of these replacement strings refer to capture group 1
'\\r'
>>> import re
>>> re.sub(r'\b([A-Za-z0-9]+)\b(?=\.?\s*(\&|\-|and))','\\1','A. & B.',re.IGNORECASE)
'A. & B.'

Or,
r'\1'
>>> import re
>>> re.sub(r'\b([A-Za-z0-9]+)\b(?=\.?\s*(\&|\-|and))',r'\1','A. & B.',re.IGNORECASE)
'A. & B.'

A: Use re.search() instead and group the desired words before and after one of the options &,-,and:
text = re.search('(\w+)\.+\s*[\&*\-*AND*and*]*\s*(\w+)\.+', 'A. & B.')
print (text.groups())


text:
Q: SQL SERVER round up to the nearest tenth and to the whole number I need to convert a calculation from VBS to Sql server to the whole number and the nearest tenth.  This is the calculation on VB:
 a=2/28/2016
    b=6/15/2016
    d=1
    Days360(a, b) = 107
    -INT(-(10^d)*DAYS360(a,b)/30)/(10^d) =
    -INT(-(10^1)*107/30)/(10^1) =
    -INT(-10*107/30)/10 =
    -INT(-1070/30)/10 =
    -INT(-35.666667)/10 =
    -(-36)/10 =
    36/10 = 3.6 --- result for nearest tenth

a=2/28/2016
b=6/15/2016
d=0
Days360(a, b) = 107
-INT(-(10^d)*DAYS360(a,b)/30)/(10^d) =
-INT(-(10^0)*107/30)/(10^0) =
-INT(-1*107/30)/1 =
-INT(-107/30)/1 =
-INT(-3.5666667)/1 =
-(-4)/1 =
4/1 =4  ---result for the whole number

How do I convert these two to sql?  I use these two queries but I don't get the results I expected:
SELECT ROUND(DATEDIFF(day,'2016-02-28','2016-06-15')*10/30/10,0) AS DiffDate
SELECT ROUND(DATEDIFF(day,'2016-02-28','2016-06-15')*10/30/10,1) AS DiffDate

A: Some versions of SQL server have the following behaviour when dealing with literals:
Any non-enclosed numeral with no decimal point is an integer constant. When dividing two integers, the result is by default an integer, so the expression might get evaluated to 107 * 10 / 30 / 10 => 1070 / 30 / 10 => 35 / 10 => 3 with the usual precedence rules. Try using floating-point constants and observe the results. (E.g. write 10.0 instead of 10 )
See also this page for more information about constants: https://msdn.microsoft.com/en-us/library/ms179899.aspx. Or see this SO question: How to get a float result by dividing two integer values?


text:
Q: переполнение pipe Пишу эмюляцию конвейера shell, есть уже распаршенный список команд (см. структуру command). Программа корректно отрабатывает, когда ее вывод небольшой, на пример ls | more. Однако, когда вывод программы очень большой, на пример ls -lR /* | more, то программа крашается. Подскажите, пожалуйста, как переписать функцию run_pipe() чтобы процессы могли обмениваться и большими объемами информации:
код:
struct command
{
    vector<char*> argv;
    command* follow_pipe;  //следующая, если конвейер

    command() {
        follow_pipe = 0;
    }
};

void pipe_run (command* ptr) {
    pid_t pid, wpid;
    int pfd[2], input, status;
    bool first = true;
    while (ptr != nullptr ) {
        pipe(pfd);
        if (!(pid = fork())) {
            if (!first) {
                dup2(input, 0);
                close(input);
            }
            if ( ptr->follow_pipe != nullptr )
                dup2(pfd[1], 1);
            close(pfd[0]);
            close(pfd[1]);
            execvp( ptr->argv[0], &ptr->argv[0]);
            cerr<<"exec_vp"<<'\n';
        }
        if (!first)
            close(input);
        close(pfd[1]);
        input = pfd[0];
        do {
            wpid = waitpid(pid, &status, WUNTRACED);
        } while (!WIFEXITED(status) && !WIFSIGNALED(status));
        first = false;
        ptr = ptr->follow_pipe;
    }
}

update: добавил минимальный воспроизводимый пример (структура command была немного изменена, но это никак не влияет на проблему при тех же тестах):
#include <iostream>
#include <unistd.h>
#include <string>
#include <cstring>
#include <sys/wait.h>
#include <fstream>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <cstdlib>
#include <vector>
#include <dirent.h>
#include <algorithm>

using namespace std;

struct command
{
    char** argv;

    command* follow_pipe;  //следующая, если конвейер

    command() {
        argv = 0;
        follow_pipe = 0;
    }

};

void pipe_run (command* ptr) {
    pid_t pid, wpid;
    int pfd[2], input, status;
    bool first = true;
    while (ptr != nullptr ) {
        pipe(pfd);
        if (!(pid = fork())) {
            if (!first) {
                dup2(input, 0);
                close(input);
            }
            if ( ptr->follow_pipe != nullptr )
                dup2(pfd[1], 1);
            close(pfd[0]);
            close(pfd[1]);
            execvp( ptr->argv[0], &ptr->argv[0]);
        }
        if (!first)
            close(input);
        close(pfd[1]);
        input = pfd[0];
        do {
            wpid = waitpid(pid, &status, WUNTRACED);
        } while (!WIFEXITED(status) && !WIFSIGNALED(status));
        first = false;
        ptr = ptr->follow_pipe;
    }
}

int main () {
    command* temp1 = new command;
    command* temp2 =  new command;

    vector<string> A(3), B(1);
    A[0] = "ls";
    A[1] = "-lR";
    A[2] = "/";  // при запуске в маленькой дирректории и без добавления этого аргумента программа работает корректно
    B[0] = "more";

    temp1->argv = new char* [A.size() +1 ];
    for ( size_t i = 0; i < A.size() ; ++i ) {
        temp1->argv[i] = new char[A[i].size()];
        strcpy( temp1->argv[i], A[i].c_str() );
    }
    temp1->argv[A.size()] = nullptr;

    temp2->argv = new char* [B.size() +1 ];
    for ( size_t i = 0; i < B.size() ; ++i ) {
        temp2->argv[i] = new char[B[i].size()];
        strcpy( temp2->argv[i], B[i].c_str() );
    }
    temp2->argv[B.size()] = nullptr;

    temp1->follow_pipe = temp2;
    pipe_run(temp1);
}

A: Проблема в вопросе в том, что сначала запускается один элемент конвейера и сразу ожидается его окончание. Само собой если этот процесс не завершается, пытаясь писать в трубу, из которой ни кто не читает то всё зависает. Нужно сначала запустить все элементы конвейера, а уже потом ждать их завершения. т.е. цикл с waitpid()'ами должны идти после цикла запуска. PID'ы всех потомков соответственно нужно предварительно сохранить. в итоге это будет выглядеть как-то так:
struct command
{
    // ...
    int pid;
};

void pipe_run (command* ptr) {
    pid_t wpid;
    int pfd[2], input, status;
    bool first = true;
    for (command *cmd=ptr; cmd; cmd = cmd->follow_pipe) {
        pipe(pfd);
        if (!(cmd->pid = fork())) {
            if (!first) {
                dup2(input, 0);
                close(input);
            }
            if ( cmd->follow_pipe != nullptr )
                dup2(pfd[1], 1);
            close(pfd[0]);
            close(pfd[1]);
            execvp( cmd->argv[0], &cmd->argv[0]);
        }
        if (!first)
            close(input);
        close(pfd[1]);
        input = pfd[0];
        first = false;
    }
    for (command *cmd=ptr; cmd; cmd = cmd->follow_pipe) {
        do {
            wpid = waitpid(cmd->pid, &status, WUNTRACED);
        } while (!WIFEXITED(status) && !WIFSIGNALED(status));
    }
}


text:
Q: regex issue while validating the contact no i have have problem with regex while validating contact no.. cant identify what i doing wrong.. code i use as below
  $('#contact_no').bind('keypress', function (event) {
       var regex = new RegExp("^[+0-9\b]");
       var key = String.fromCharCode(!event.charCode ? event.which : event.charCode);
       if (!regex.test(key)) {
           event.preventDefault();
           return false;
       }
   });

what i want no is starting with +(sign) and it is mendatory user can enter +xxxxxxxxxx or xxxxxxxxxx and +(sign) occure only once at 1st position after that +(sign) is disabled.

A: You can use this regex:
var regex = /^\+?[0-9]+$/;

No need to use a RegExp object here as you can use a regex literal to do your job.
This regex allows one optional + at start followed by 1 or more digits.

Update:
Problem is using keypress event for binding. Which is sending each entered character to this code.
You can use:
$('#contact_no').bind('submit focusout', function (event) {
       var regex = /^\+?\d+$/;
       var key = $('#contact_no').val();
       if (!regex.test(key)) {
           event.preventDefault();
           console.log("Invalid value: " + key);
           return false;
       }
});

JSFiddle Demo


text:
Q: Why can't I shutdown the Netty Server or Netty Client ? Expected behavior
I have launched a netty server and establish a connection with it via netty client. The client sends a message to the server, while the server will feedback and close context (Channel), when the client got a message from the server, it will close channel and shutdown EventLoopGroup, and then exit the program.
Actual behavior
However, all the channel was closed, but the EventLoopGroup unable to shutdown (isShutdown always false), no matter client or server, the main thread blocked.
Steps to reproduce
The code as follow.
Minimal yet complete reproducer code (or URL to code)
The code in this issue
Netty version
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-all</artifactId>
        <version>4.1.20.Final</version>
    </dependency>

JVM version (e.g. java -version)
java version "1.8.0_131"
OS version (e.g. uname -a)

*

*Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-104-generic x86_64)

*OSX 10.13.1

A: It's the bug of the 4.1.20,just update to 4.1.21
My issue
The clearThread is not deamon thread


text:
Q: How to create a library that targets both .NET 2.0 and .NET Standard? I have a small library that currently supports .NET 2.0+.
I don't use any features of the later framework versions so it would be nice to keep 2.0 support, but I also want to target .NET Core (or more precisely, .NET Standard).
I tried to add both frameworks to project.json:
"frameworks": {
  "net20": {},
  "netstandard1.6": {
    "imports": "dnxcore50"
  }
}

But the NuGet packages my library needs to run on .NET Standard (System.Reflection and Microsoft.AspNetCore.WebUtilities) aren't compatible with .NET 2.0.
How can I solve this issue without maintaining two completely separate projects with almost identical code?

A: You can't, if you depend on Microsoft.AspNetCore.* packages as the absolute minimum for supporting .NET Standard is .NET 4.5.
.NET 4.5 is the first version to include System.Runtime on which .NET Core is based on. But when you think closer about it, it also makes no sense. If you need support for ASP.NET Core within your library.
If your library is supposed to run for ASP.NET Core and ASP.NET 4 (i.e. MVC 5, WebApi 2), then you will need to use your ASP.NET Dependencies conditionally and use #if preprocessor directives.
"frameworks": {
  "net20": {
    "dependencies": {
      "NameOf.AspNetLegacyPackage": "1.2.3"
    }
  },
  "netstandard1.3": {
    "dependencies": {
      "Microsoft.AspNetCore.WebUtilities" : "1.1.0"
    },
    "imports": "dnxcore50"
  }
}

I used netstandard1.3 as that's the minimum for Microsoft.AspNetCore.WebUtilities, but depending on your other dependencies you may need to go higher or lower.
NameOf.AspNetLegacyPackage is the name of the package which contains the same functionality as Microsoft.AspNetCore.WebUtilities which you need, but which works on .NET Framework 2.0, if there is any. If not you have to remove it and write the replacement functions yourself.
Then in your code use
#if NETSTANDARD1_3
    // Code or APIs which is only available in netstandard1.3/net4.6
    // this includes the Microsoft.AspNetCore.WebUtillities
#else
    // Use code or API which runs under .NET Framework 2.0
#endif

Alternatively, if you are going to give up the .NET Framework 2.0 support and go for 4.5.1, you can keep using Microsoft.AspNetCore.WebUtillities (see NuGet page for dependencies) it in both
"dependencies": {
  "Microsoft.AspNetCore.WebUtilities" : "1.1.0"
},
"frameworks": {
  "net451": {
  },
  "netstandard1.3": {
    "imports": "dnxcore50"
  }
}

A: You can do this by putting your code into a Shared project, then created a Class Library which targets .Net 2.0, and another Class Library project which targets NetStandard.  If there are things in 2.0 or Netstandard which aren't available in the other platform, you can use compiler directives to write compatible code for each.


text:
Q: need regular expression for now(date) format
regular expression will valid the below strings.
1.now(today date)
2.now-1d(yesterday)
3.now+1w(add 1 week to today)
4.now/M(starting date of the month)
5.now/y(starting date of the year)
6.now-w/w(remove 1 week from today and starting date of that week)
I need regular express for the above.

/^now(([-+])(\d+)(\w)(\/\w)?|\/(\w)|)/

This is the regular expression i generated but it fails some words like
now-1d/2

A: Thanks @Michel Butscher.
^now(?:([-+])(\d+)([dmMwy]))?(?:\/([dmMwy]))?$

This works for me.


text:
Q: Power of Power to calculate in Java I have a program to write. The requirement is 1.    Implement code (choose your favorite language) which will calculate the value of 2^(3^(4^(5^6)))
What I have written is this so far ( for 4^(5^6).However, I get 0 as output despite the fact I have even changed the second argument from integer to long.A little help is needed.Here is my code:
public static void main(String args[]) {
    int i=4,j=5,k=6;
    System.out.println(pow(i,pow(j,k)));
}

public static long pow(int c, long l){
    long n=1;
    for(int i=0;i<l;i++){
        n=c*n;
    }
    return n;
}

A: 4^(5^6) equals 4^15625, which is approximately 1,53*10^9407, a number which greatly exceeds the maximum value for the Long type, which is (2^64)-1.
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

A: These numbers are humongous. Really. 5^6 = 15625. Raise 4 to that power and you'll get enough digits as there are particles in the known Universe.
Your problem with 0 comes from the fact that 4 is 100 in binary. Multiply by 4 and you get 10000 in binary. Raise to a little more than that (max power 8, 16, maybe 32 if data types support it; talking in general) and you'll drop the single 1 bit you had out of the integer representation => 0.

A: As you said you can choose the language. I advise you to implement this computation with Matlab or Octave:
2^3^4^5^6

prints the result you expect.

A: The output is large enough and trips over to zero after crossing Long.MAX_VALUE.

A: You can use Java's BigInteger, but I'm not sure whether such a huge number can be stored in memory.

A: First of all, you might use Math.pow(2, 3), to calculate 2 ^ 3. However since the output is that large, as shown in the following code, even double will return Infinity:
package test;

public class Test {

    public static void main(String[] args) throws Exception {
        // 2^(3^(4^(5^6)))
        System.out.println(Math.pow(2, Math.pow(3, Math.pow(4, Math.pow(5, 6)))));
    }

}

However you might use java.math.BigDecimal, which can handle this large integers. For this question I would propose python, were you could just write
2 ** (3 ** (4 ** (5 ** 6)))

EDIT:
Do you know that 4 ** (5 ** 6) already is
http://paste.ubuntu.com/6840260/
do you really want to calculate with this number in Java, which is not the fastest language for math problems?

A: did you try this algorithm ? Exponentation by squaring


text:
Q: How to disable all scheduled jobs in 1C Server? How can I disable all scheduled jobs?
When developing projects, we faced the problem of shortage and blocking of resources and processes.
We have many scheduled jobs for the server, but for development machines, they are causing issues because they do not allow updating database configuration as it keeps saying:
«InfoBase exceptional lock error.»
I have not found standard and common procedures to resolve this issue. Maybe someone has faced something like this and knows how to solve it.

A: If you use the server version 1C, the easiest way to block all scheduled jobs is to use the 1C server administration utility.
See screenshots below...
first, open the properties of the database for which you want to disable scheduled jobs:
and now put the flag "Execution of scheduled jobs is disabled"