text:
Q: data option in sassOptions stopped working in gatsby-plugin-sass after upgrading to v3 and replaced node-sass with sass I decided to remove node-sass from my gatsby project and use sass instead. I followed what is mentioned here for v3. I removed node-sass and now I have these versions in my package.json:
"gatsby-plugin-sass": "3.1.0",
"sass": "1.32.5",

I need to be able to write some @use or @import rules ONCE for global variables/mixins/functions so I can use them in all my scss files and so I won't have to repeat the same rules over and over again.
With node-sass something like this worked:
{
  resolve: `gatsby-plugin-sass`,
  options: {
    includePaths: [`${__dirname}/src/styles`],
    data: `@import "globals.scss";`,
  },
},

After the upgrade, the includePaths attribute does work but the data does not and I get errors from my scss files about "missing" variables:
{
  resolve: `gatsby-plugin-sass`,
  options: {
    sassOptions: {
      includePaths: [`${__dirname}/src/styles`],
      data: `@use 'globals' as *;`,
    },
  },
},

If I insert the rule @use 'globals' as *; in each scss file the errors disappear and everything works as expected but I don't want to insert this line and modify all my sass files.
I am pretty sure that the issue has to do with sass-loader and this statement (documentation) but I can't figure out how to make it work and why it worked before:

ℹ Options such as data and file are unavailable and will be ignored.

A: According to the changelog, data option has been renamed to prependData and then removed in favor of additionalData. So:
{
  resolve: `gatsby-plugin-sass`,
  options: {
    additionalData: `@use 'globals' as *;`,
    sassOptions: {
      includePaths: [`${__dirname}/src/styles`],
    },
  },
},


text: Q: Module AppRegistry is not a registered callable module (calling unmountApplicationComponentAtRootTag) when I run my react-native ios app it displayed Module AppRegistry is not a registered callable module (calling unmountApplicationComponentAtRootTag) error in terminal and in simulator display this error:

redpajama_set_name: RedPajamaStackExchange


text:
Q: FOR XML with XSINIL using dynamic node names Kinda stuck on this one.  I have a table with name/value columns:
NameValue table
-----------------------------------------------------------
Name varchar(100)    Value varchar(100)
-----------------------------------------------------------
FirstName            First value
SecondName           Second value
ThirdName            Null or Empty String
etc...

I'm trying to get my result to look like the following XML, but I can't quite get there.
<MyValues xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <FirstName>First value</FirstName>
  <SecondName>Second value</SecondName>
  <ThirdName xsi:nil="true" />
</MyValues>

To get the dynamic names working, I concat the XML and cast as XML like so:
select cast('<' + name +  '>' + value + '</' + name + '>' as xml)
from NameValue
for xml raw(''), root('MyValues'), elements xsinil

The above query produces this XML without xsi:nil="true"
<MyValues xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <FirstName>First value</FirstName>
  <SecondName>Second value</SecondName>
  <ThirdName />
</MyValues>

If I don't cast as XML, I'm left with the following:
<MyValues xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<FirstName>First value</FirstName><
etc...

I tried adding the xsi:nil="true" in the concatination, but receive errors about the missing namespace.  I'm guessing to make this work, I'm going to have to add the same namespace to every single row that contains null or empty string, so the result would look like the following:
<MyValues>
  <FirstName>First value</FirstName>
  <SecondName>Second value</SecondName>
  <ThirdName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
</MyValues>

There could be a few hundred of these empty strings in the resultset, so I'd prefer to put the namespace at the root level to conserve on bandwidth.  Is this at all possible?

A: Instead of using FOR XML, I simply did the entire XML as a concatinated string.
declare @xml varchar(max)
set @xml = '<MyValues xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'

select @xml = '<' + name +
    case when len(value) = 0 then 'xsi:nil="true" />'
         else '>' + value + '</' + name + '>'
    end
from NameValue

select @xml + "</MyValues>"


text:
Q: Commence "on" vs. "from"
The examination will commence _____  Monday.

a) on
b) from
which of the above will be used?
Also explain, how commence is used.
In my opinion, it should be "from".

A:
The examination will commence on Monday.

says Monday is the starting date. It is unknown if it will last for only one day or additional days.

The examination will commence from Monday.

implies it will start on Monday but continue for one or more days. There is an implied "to":

The examination will commence from Monday and continue to Wednesday.


text:
Q: Can make "target" take an argument? lets say I am doing mk "target" to build something. Is it possible to pass an argument to it?
i.e. mk "target" "x" and it will do things accordingly? I know that I will be providing mk "target" an argument and I know its semantics, just dont know the name well in advance.
Possible?

A: You might want to make use of GNU Make's "Variables":
$ cat Makefile

ifndef LOLCAKES
   LOLCAKES=1
endif

all:
   @echo $(LOLCAKES)

$ make all LOLCAKES=42

You didn't explain what you're trying to accomplish, so it's hard to know what kind of "argument" you're after.

A: make target x will cause make to try to build target and x.  There's no way to have a modifier like you seem to be expecting.  A good solution can be to have rules with compound names:
target: target.debug target.release

target.release:
    # recipe for release build

target.debug:
    # recipe for debug build

Then you can use target.debug, target.release, or just target, and get some sane behaviour.

A: You can use environment variables:
$ cat Makefile
all:
    @echo $(FOO)
$ FOO=bar make
bar


text:
Q: HTML WYSIWYG edtor: why is the editable content moved in an iFrame Why is the editable html moved into an iFrame? I analysed different editors (TinyMce, CKEditor, etc) and all move the editable content into a separate iFrame which they lay over the original text.
What is the technical reason for this. I experimented with the contenteditable="true", which is the base of all this editors too, and didn't find a reason yet to do this.

A: From the tinymce froum

Hi Zappino!
It is the very nature of editors like TinyMCE to use an IFrame because
  in a frame you can modify any part of an HTML document to suit your
  needs without breaking anything in the main page's document.
  Especially if you want to edit a complete HTML document including the
  parts between  and  you won't be able to do so without an
  IFrame.
Cross Domain Skripting will occur if you store TinyMCE's files on a
  different (sub-)domain than the page from which you embed the editor.
  Show us a test scenario of your installation with which you are having
  trouble and someone might be able to help you out!
Greetings from Germany (back to Germany )
Felix Riesterer.

A: I'm CKEditor core developer. Not for a long time - just for last half of the year, but I've learnt a lot about why we use iframed editable :)

*

*Styling - content of the iframed editor doesn't inherit styles of the page. This is extremely important, because we cannot reset styles (sic! CSS really sucks). What's more - in iframe we can freely add our own styles which is helpful too.

*Only in iframed editable we can work on entire page with head, metas, body styles, title, etc. Some of our users need this.

*Browsers have very buggy (and incomplete) impls of contenteditable. E.g. guess what will happen when you paste list into the editable which is a <h1> element on Firefox (you can check that in this editor - http://createjs.org/demo/hallo/)? It will leak out of editable area and become a non-editable element. We have to handle these cases manually in the editor and this is really hard work :).

*I'm not sure about this but I believe that designMode wich allows to switch entire document into the editable area had been first and contenteditable came later. So the reason may be historical too - it's hard to switch from one approach to another.

*Probably there're more reasons why we use an iframed editable. I'll update my answer when I'll learn them :)


text:
Q: What happened to bootstrap customize? Bootstrap 3 used to have this customize option: https://getbootstrap.com/docs/3.3/customize/
However, I'm unable to find such a link for Bootstrap 4. I'm just building a simple website and won't be using 80% of it's functionality for sure. I don't want most of the JS functionalities too. How do I go about this?

A: This feature is not yet in Bootstrap 4 afaik.
But you can modify the SCSS file and build the Bootstrap css and js file.
This is what @mdo say about it

This is essentially the same as commenting out an import statement in bootstrap.scss. I know there's a bit more to it when it comes to shared components, but it's basically 1:1. It's been requested before and I was a pass then, still am now.

Check the Bootstrap issue/feature-request here
Example
@import "node_modules/bootstrap/scss/functions";
@import "node_modules/bootstrap/scss/variables";
@import "node_modules/bootstrap/scss/mixins";
@import "node_modules/bootstrap/scss/root";
@import "node_modules/bootstrap/scss/print";
@import "node_modules/bootstrap/scss/reboot";
@import "node_modules/bootstrap/scss/type";
//@import "node_modules/bootstrap/scss/images";
@import "node_modules/bootstrap/scss/code";
@import "node_modules/bootstrap/scss/grid";
@import "node_modules/bootstrap/scss/tables";
@import "node_modules/bootstrap/scss/forms";
@import "node_modules/bootstrap/scss/buttons";
@import "node_modules/bootstrap/scss/transitions";

Update:
This is a very good online Bootstrap customizer Bootstrap.build

A: There will not be a customizer at all for Bootstrap 4:

Dropped the online Customizer in favor of more extensive setup
  documentation and customized builds.

(source)
However if you want to customize Bootstrap in the web, you can use a third party tool like http://bootstrapcustomizer.com/.


text:
Q: How to fail declarative Jenkins pipeline if maven tests fail? I am running a declarative pipeline like this -
stage ('Integration Tests') {
    steps {
      bat "mvn clean verify"
    }
}

How can I fail this pipeline if integration tests fail? I have tried wrapping the step inside a script with try-catch block but that did not help. I am using JBehave Maven plugin to trigger integration tests.

A: Ok so based on my understanding you should add:
-Dmaven.test.failure.ignore=false to the MAVEN_OPTS if you click on Advanced button in the Build section of your Jenkins Job.
See  Maven Surefire Plugin - surefire:test options for reference.
This is due to jenkins specifies this value to true per default. Have a look at issues.jenkins-ci.org/browse/JENKINS-24655

A: JBehave Maven plugin has a flag ignoreFailureInStories that needed to be set as true in my case.


text:
Q: Extract current facebook username using iOS SDK 4 I am using Graph API to get facebook user information as follows:
[facebook requestWithGraphPath:@"me" andDelegate:self];

How can I do this? I know that server response is in the form of JSON object but don't know how to parse it.

A: I don't find the links that helped me to resolve this issue.
This is the code I used (request:didLoad: is a FBRequestDelegate callback):
- (void)request:(FBRequest *)request didLoad:(id)result {
if ([result isKindOfClass:[NSDictionary class]]) {

    NSDictionary* hash = result;

    NSString *username = (NSString*)[hash valueForKey:@"name"];

    [[NSUserDefaults standardUserDefaults] setObject:username forKey:@"Username"];
}
[self publishStream]; // publishStream is a custom methods of mine to create the post to publish
};

I remember that I read the FB ios api code and maybe this and this
I hope this works for you.
Bye,
Fran

A: I have answered this question here How to retrieve Facebook response using Facebook iOS SDK


text:
Q: Tensorflow failed to decode jpeg bytes in tfrecords I tried to write some images to a tfrecord file, but I found it is too large. Then I tried to write the origin jpeg bytes into The tfrecord file. but when I try to read it, there is exception:
ValueError: Shape must be rank 0 but is rank 1 for 'DecodeJpeg' (op: 'DecodeJpeg') with input shapes: [32].
Followed is my code
import tensorflow as tf
import os

def write_features(example_image_paths, tf_records_path):
    with tf.python_io.TFRecordWriter(tf_records_path) as writer:
        for image_path in example_image_paths:
            with open(image_path, 'rb') as f:
                image_bytes = f.read()
            feautres = tf.train.Features(
                feautres={
                    'images':
                    tf.train.Feature(bytes_list=tf.train.BytesList(
                        value=image_bytes))
                })
            example = tf.train.Example(feautres)
            writer.write(example.SerializeToString())

def extract_features_batch(serialized_batch):
    """

    :param serialized_batch:
    :return:
    """
    features = tf.parse_example(
        serialized_batch,
        features={'images': tf.FixedLenFeature([], tf.string)})
    bs = features['images'].shape[0]
    images = tf.image.decode_image(features['images'], 3)
    w, h = (280, 32)
    images = tf.cast(x=images, dtype=tf.float32)
    images = tf.reshape(images, [bs, h, w, 3])

    return images

def inputs(tfrecords_path, batch_size, num_epochs, num_threads=4):
    """

    :param tfrecords_path:
    :param batch_size:
    :param num_epochs:
    :param num_threads:
    :return: input_images, input_labels, input_image_names
    """

    if not num_epochs:
        num_epochs = None

    dataset = tf.data.TFRecordDataset(tfrecords_path)

    dataset = dataset.batch(batch_size, drop_remainder=True)

    # The map transformation takes a function and applies it to every element
    # of the dataset.
    dataset = dataset.map(map_func=extract_features_batch,
                          num_parallel_calls=num_threads)
    dataset = dataset.shuffle(buffer_size=1000)
    dataset = dataset.repeat()

    iterator = dataset.make_one_shot_iterator()

    return iterator.get_next(name='IteratorGetNext')

if __name__ == '__main__':
    pass
    # img_names = os.listdir('./images')
    # img_paths = []
    # for img_name in img_paths:
    #     img_paths.append(os.path.join('./images', img_name))
    # write_features(img_paths, 'test.tfrecords')

    images = inputs('./test.tfrecords', 32, None)

How can I read and decode the jpeg bytes properly? Thanks!

A: You need to decode images before batching the dataset. In other words, in your inputs() function the 'correct' order would be:
dataset = dataset.map(map_func=extract_features_batch,
                      num_parallel_calls=num_threads)

dataset = dataset.batch(batch_size, drop_remainder=True)

The documentation says (https://www.tensorflow.org/api_docs/python/tf/io/decode_image) that tf.io.decode_image expects an image in a form of a scalar or 0-dimensional string (0-D string is considered a scalar) while if you batch the dataset object first the tf.io.decode_image receives a list (or a batch) of images (represented as a list of batch_size times 0 dimensional strings). It then complains that it expected 0-dimensional array while received an array with the shape of [32] (which is the batch size in your case).
I have no idea about how we could optimize input pipeline for batch-processing other than inefficiently do batching after processing. As usual, there is nothing about it in docs on tf 2.0.


text:
Q: table micro adjustment help needed First thing first, the code listed as below,
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper, top=0.2in, bottom=0.15in, left=0.25in, right=0.25in]{geometry}
\usepackage{multirow,array,varwidth,spreadtab,caption}
\usepackage{booktabs}
\usepackage{siunitx,booktabs,caption}
\usepackage{multirow,array,varwidth,spreadtab,}
\usepackage{siunitx,booktabs,caption}
\usepackage{ragged2e}
\usepackage{layout}
\usepackage{float}
\restylefloat{table}
\newcolumntype{L}[1]{>{\RaggedRight\hspace{0pt}}p{#1}}
\newcolumntype{R}[1]{>{\RaggedLeft\hspace{0pt}}p{#1}}
\usepackage[scaled]{helvet}
\renewcommand\familydefault{\sfdefault}
\usepackage[T1]{fontenc}
\usepackage{pythontex}

\begin{document}
\noindent
\begin{minipage}[t]{.11\textwidth}
\raggedright
\raggedleft
\scriptsize
\begin{tabular}[t]{@{} r l @{}}% <-- Don't forget @{}!
\textbf{COMPANY:}&{ffffff}\\ %%enter value in the space after "&"
\textbf{FACTORY:}&\\
\textbf{FIELD:}&  \\%%enter value in the space after "&"
\textbf{LEASE:}&  fadsfasdfasd  \\%%enter value in the space after "&"
\end{tabular}
\end{minipage}% <-- Don't forget this one
%
\hfill
%
 \begin{minipage}[c]{.735\textwidth}
  \small
    \centering
  \textbf{PETROBRA COMPANY LIMITED} \\
  \textbf{THE ESTIMATE OF RESERVES AND FUTURE INCOME ATTRIBUTABLE} \\
  \textbf{TO CERTAIN INTERESTS} \\
  \textbf{As of JAN 1 2017}}
\end{minipage}
%
\hfill
%
\begin{minipage}[t]{.135\textwidth}
\raggedleft
\scriptsize
\begin{tabular}[t]{@{} r l @{}}% <-- Don't forget @{}!
\textbf{ID:} &         gsfd  \\ %%enter value in the space after "&"
\textbf{MAJOR PHASE:} & Oil \\%%enter value in the space after "&"
\textbf{AAAA Reserves:} & gfdsgsd \\%%enter value in the space after "&"
\textbf{Dev.Status:} &     gsdf\\%%enter value in the space after "&"
\end{tabular}
\end{minipage}
\end{document}

What I want to do are,

*

*minimize or reduce the gap between "COMPANY" and "ffffff" Adjust;

*right side mini pages position, make it to left enough to allow long
    ID existing;

*Make sure mid-mini page is centered.

P.S Even I added @{} in table environment, it wont' help much.

A: See, if this is similar to layout, which you like to achieve:

\documentclass{article}
\usepackage[a4paper, top=0.2in, bottom=0.15in,
            left=0.25in, right=0.25in,
            ]{geometry}
    \usepackage{array}
    \usepackage{calc}% <-- added

\begin{document}
\setlength\tabcolsep{2pt}
\noindent\begin{tabular}{|@{}
        >{\scriptsize}m{0.2\textwidth-1\tabcolsep}|
        >{\centering\bfseries}m{.6\textwidth-4\tabcolsep}|
        >{\raggedleft\scriptsize}m{.2\textwidth-\tabcolsep}|
                   @{}|}
\begin{tabular}[t]{@{}>{\bfseries}rl}% <-- Don't forget @{}!
COMPANY:  & ffffff          \\ %%enter value in the space after "&"
FACTORY:  &                 \\
FIELD:    &                 \\%%enter value in the space after "&"
LEASE:    & fadsfasdfasd    \\%%enter value in the space after "&"
\end{tabular}
%
&
%
PETROBRA COMPANY LIMITED

THE ESTIMATE OF RESERVES AND FUTURE INCOME ATTRIBUTABLE %

TO CERTAIN INTERESTS

As of JAN 1 2017
%
&
%
\begin{tabular}[t]{>{\bfseries}rl@{}}% <-- Don't forget @{}!
ID:             & gsfd      \\%%enter value in the space after "&"
MAJOR PHASE:    & Oil       \\%%enter value in the space after "&"
AAAA Reserves:  & gfdsgsd   \\%%enter value in the space after "&"
Dev.Status:     & gsdf      \\%%enter value in the space after "&"
\end{tabular}
    \end{tabular}
\end{document}

Vertical lines are only for orientation. On the end they had to be omitted. As can you see, I didn't use minipages. Instead of them I employ \tabular in which in the first and last column are nested your tables. For determination their column width I added package calc.
Also I move commands for bold fonts to option of column type.
Addendum:
Probably you wish, that the text in the nested (sub) tables has bold text in the same position regardless of width of no bold text. IN this case is better for their second column instead column type l use ˙p{}where you deliberately select width. For examplep{12ex}` for your right sub table seems to be good selection. Try this with your real cells content and see, if it is ok.
Warning: since sub tables have column types r andl, its can happen, that in case that text in cells will be longer then reserved width in main tablar, they will protrude outside of main table column width.
Addendum (2): In case, that you like to align content of all cells with their bottom, you only need to change column type accordingly from m change to b and sub tables position from t to b. With slightly reformatted main title layout in this case you obtain:

\noindent\begin{tabular}{@{}
        >{\scriptsize}b{0.2\textwidth-1\tabcolsep}
        >{\centering\bfseries}b{.6\textwidth-4\tabcolsep}
        >{\raggedleft\scriptsize}b{.2\textwidth-\tabcolsep}
                   @{}}
\begin{tabular}[b]{@{}>{\bfseries}rl}% <-- Don't forget @{}!
COMPANY:  & ffffff          \\ %%enter value in the space after "&"
FACTORY:  &                 \\ %%enter value in the space after "&"
FIELD:    &                 \\ %%enter value in the space after "&"
LEASE:    & fadsfasdfasd    \\ %%enter value in the space after "&"
\end{tabular}
    &
PETROBRA COMPANY LIMITED
THE ESTIMATE OF RESERVES AND FUTURE INCOME ATTRIBUTABLE TO CERTAIN INTERESTS

As of JAN 1 2017
        &
\begin{tabular}[b]{>{\bfseries}rl@{}}% <-- Don't forget @{}!
ID:             & gsfd      \\%%enter value in the space after "&"
MAJOR PHASE:    & Oil       \\%%enter value in the space after "&"
AAAA Reserves:  & gfdsgsd   \\%%enter value in the space after "&"
Dev.Status:     & gsdf      \\%%enter value in the space after "&"
\end{tabular}
    \end{tabular}

For the top position you need to change m to p and sub tables position to t:

\noindent\begin{tabular}{@{}
        >{\scriptsize}p{0.2\textwidth-1\tabcolsep}
        >{\centering\bfseries}p{.6\textwidth-4\tabcolsep}
        >{\raggedleft\scriptsize}p{.2\textwidth-\tabcolsep}
                   @{}}
\begin{tabular}[t]{@{}>{\bfseries}rl}% <-- Don't forget @{}!
COMPANY:  & ffffff          \\ %%enter value in the space after "&"
FACTORY:  &                 \\ %%enter value in the space after "&"
FIELD:    &                 \\ %%enter value in the space after "&"
LEASE:    & fadsfasdfasd    \\ %%enter value in the space after "&"
\end{tabular}
    &
PETROBRA COMPANY LIMITED
THE ESTIMATE OF RESERVES AND FUTURE INCOME ATTRIBUTABLE TO CERTAIN INTERESTS

As of JAN 1 2017
        &
\begin{tabular}[t]{>{\bfseries}rl@{}}% <-- Don't forget @{}!
ID:             & gsfd      \\%%enter value in the space after "&"
MAJOR PHASE:    & Oil       \\%%enter value in the space after "&"
AAAA Reserves:  & gfdsgsd   \\%%enter value in the space after "&"
Dev.Status:     & gsdf      \\%%enter value in the space after "&"
\end{tabular}
    \end{tabular}


text:
Q: I am getting different startTimestamp and endtimestamp that i provided in networkstatsmanager.querydetailsforuid() method. How to solve it? Getting different start time and end time that I am providing in NetworkStatsManager.queryDetailsForUid
Here is my code snippet :
I want to get application data usage in an interval of start time and end time
I am calling method and passing start date and end date from calendar in milliseconds but after calling to the queryDetailsForUid() it showing some different time:
Calendar cal1 = Calendar.getInstance();
Date end = cal1.getTime();
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -100);
long start = cal.getTime().getTime();

long s = getPackageTxBytesMobile(uid, cal.getTimeInMillis(), cal1.getTimeInMillis());
long r = getPackageRxBytesMobile(uid, cal.getTimeInMillis(), cal1.getTimeInMillis());

Here is the method:
public long getPackageTxBytesMobile(int uid, long startDate, long endDate) {
    NetworkStats networkStats = null;

    NetworkStatsManager networkStatsManager = (NetworkStatsManager)
    context1.getSystemService(Context.NETWORK_STATS_SERVICE);
    TelephonyManager tm = (TelephonyManager)context1.getSystemService(Context.TELEPHONY_SERVICE);
    String subId = null;
    if(ActivityCompat.checkSelfPermission(context1, Manifest.permission.READ_PHONE_STATE) ==
            PackageManager.PERMISSION_GRANTED) {
        subId = tm.getSubscriberId();
    }
    Log.d("Startdate: ",""+startDate+"   ");
    Log.d("Enddate: ",""+endDate+"    ");
    try {
        networkStats = networkStatsManager.queryDetailsForUid(
                ConnectivityManager.TYPE_MOBILE,
                subId,
                startDate,
                endDate ,
                uid);
    } catch (Exception e) {
        return -1;
    }
    NetworkStats.Bucket bucket = new NetworkStats.Bucket();
    networkStats.getNextBucket(bucket);
    long tx = bucket.getTxBytes();
    Log.d("tag1","StartTime: "+bucket.getStartTimeStamp());
    Log.d("tag1","EndTime: "+bucket.getEndTimeStamp());

    networkStats.close();
    return tx;
}

and here is log output:
2020-04-25 10:08:47.248 17889-17889/com.pkdev.mdmtemp D/tag1: StartTime: 1579168800000
2020-04-25 10:08:47.248 17889-17889/com.pkdev.mdmtemp D/tag1: EndTime: 1579176000000
2020-04-25 10:08:47.280 17889-17889/com.pkdev.mdmtemp D/Startdate:: 1579149527275
2020-04-25 10:08:47.280 17889-17889/com.pkdev.mdmtemp D/Enddate:: 1587789527275
2020-04-25 10:08:47.284 17889-17889/com.pkdev.mdmtemp D/tag1: StartTime: 1579154400000
2020-04-25 10:08:47.284 17889-17889/com.pkdev.mdmtemp D/tag1: EndTime: 1579161600000
2020-04-25 10:08:47.324 17889-17889/com.pkdev.mdmtemp D/Startdate:: 1579149527321
2020-04-25 10:08:47.324 17889-17889/com.pkdev.mdmtemp D/Enddate:: 1587789527320
2020-04-25 10:08:47.326 17889-17889/com.pkdev.mdmtemp D/tag1: StartTime: 1582466400000
2020-04-25 10:08:47.326 17889-17889/com.pkdev.mdmtemp D/tag1: EndTime: 1582473600000
2020-04-25 10:08:47.360 17889-17889/com.pkdev.mdmtemp D/Startdate:: 1579149527357
2020-04-25 10:08:47.360 17889-17889/com.pkdev.mdmtemp D/Enddate:: 1587789527357
2020-04-25 10:08:47.365 17889-17889/com.pkdev.mdmtemp D/tag1: StartTime: 1579161600000
2020-04-25 10:08:47.365 17889-17889/com.pkdev.mdmtemp D/tag1: EndTime: 1579168800000

A: You are using just one NetworkStats.Bucket, use hasNextBucket() to get the following buckets too.
So change your method's bottom part to this:
long tx = 0L
NetworkStats.Bucket bucket = new NetworkStats.Bucket();
while (networkStats.hasNextBucket()) {
    networkStats.getNextBucket(bucket);
    tx += bucket.getTxBytes();
    Log.d("tag1","StartTime: "+bucket.getStartTimeStamp());
    Log.d("tag1","EndTime: "+bucket.getEndTimeStamp());
}

networkStats.close();
return tx;


text:
Q: UnicodeDecodeError import csv into MySql DB I try to load an absolute easy csv file into my db. I added the column "Success" to my csv file and now I get following error.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 5: ordinal not in range(128)
ERROR: Import data file: 'ascii' codec can't decode byte 0xc3 in position 5: ordinal not in range(128)
This is my csv file...
Spieltag;Heimtore;Awaytore;Heimteam;Awayteam;Success
1;3;2;4;2;1
2;1;5;2;1;4
And this is my table
CREATE TABLE `resultate` (
  `Spieltag` int(11) NOT NULL,
  `Heimtore` int(11) DEFAULT NULL,
  `Auswärtstore` int(11) DEFAULT NULL,
  `Heimteam` int(11) NOT NULL,
  `Auswärtsteam` int(11) NOT NULL,
  `Saison` int(11) NOT NULL DEFAULT '1819',
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Ueber` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`Spieltag`,`Heimteam`,`Auswärtsteam`,`Saison`),
  UNIQUE KEY `ID_UNIQUE` (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=405 DEFAULT CHARSET=latin1

What the hell is wrong with my table or my csv file? I can't find the problem...


text:
Q: Using Phonegap for bb10, touch, and non-touch devices I intend to develop a Blackberry app targeting the older devices and new BB 10. Is it that I have to develop different apps for older platform, new BB10 platform, for touch, and for non-touch devices? Please also guide me on how I can publish this as a single app. Any other info related to this subject would be appreciated.
Thanks

A: read for phonegap and webworks. You can do this with single app code just keep in mind

*

*change the config file when switching from BBOS 7 and lower to BB 10.

*In BBOS 7 remove one line from your config.xml that says something like focus-enable then default focus control would be cursor oriented.


text:
Q: How do we get android token on ionic 4? Hello i'm using fcm ionic native plugin, its working well with android 7 and below but on android 8 Oreo and above it can't get the device token, what could be the problem?

A: You can use the code below and hope it works out for you:
export interface AuthResponseData {
  kind: string;
  idToken: string;
  email: string;
  refreshToken: string;
  localId: string;
  expiresIn: string;
  registered?: boolean;
}

export class AuthService implements OnDestroy {
  private _user = new BehaviorSubject<User>(null);

  get token() {
    return this._user.asObservable().pipe(
      map(user => {
        if (user) {
          return user.token;
        } else {
          return false;
        }
      })
    );
  }

  constructor(private http: HttpClient) { }

  signup(email: string, password: string) {
    return this.http
      .post<AuthResponseData>(
        `https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=${yourAPIKey}`,
        { email, password, returnSecureToken: true })
      .pipe(tap(this.setUserData.bind(this)));
  }

  login(email: string, password: string) {
    return this.http
      .post<AuthResponseData>(
        `https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=${yourAPIKey}`,
        { email, password, returnSecureToken: true })
      .pipe(tap(this.setUserData.bind(this)));
  }

  private setUserData(userData: AuthResponseData) {
    const expirationTime = new Date(new Date().getTime() + +userData.expiresIn * 1000);
    const user = new User(userData.localId, userData.email, userData.idToken, expirationTime);
    this._user.next(user);
    this.storeAuthData(userData.localId, userData.idToken, expirationTime.toISOString(), userData.email);
  }

  private storeAuthData(userId: string, token: string, tokenExpirationDate: string, email: string) {
    const data = JSON.stringify({ userId, token, tokenExpirationDate, email });
    Plugins.Storage.set({ key: 'authData', value: data });
  }
}

And you can use this link for more information


text:
Q: How does one breed the new Apocalpyse dragon? I saw the new Apocalypse Dragon in the marketplace.  I heard it has four elements required but I didn't see that in the game, how do I breed it?  Let's hope I get it before the world ends. :)  Thanks!

A: Yes, the new Apocalpyse Dragon requires four breeding element: Plant, Lightning, Cold and Metal.  So you need two hybrid dragons that contain those elements.
A confirmed combination would be Magnetic Dragon (Metal and Lighting) and Lichen Dragon (Plant and Cold).  It's a limited dragon and only here for a period of time.
Source: Apocalpyse Dragon on Dragonvale Breeding Guide

A: Cactus and Mine/ Copper and Paper/Lichen and magnetic /Mine and Ash


text:
Q: rails migration is not reflecting while migration is successful I have created 2 tables (categories and products) and I did has_many association like Category has_many :products and Product belongs_to :category.
When I do a migration like:
rails generate migration add_product_id_to_categories product_id:integer

then migration is running but not seeing product_id in Category.
I've tried multiple ways like
add_product_id_to_category product_id:integer

but still facing the same problem.

A: You only generated a migration file (rails generate migration add_product_id_to_categories product_id:integer). You have to run the migration with rake db:migrate.

A: Generating a migration is a different thing than actually running it. You just generated it, and in order to execute what you have written, you need to run it, and you can do so by invoking the following command:
rake db:migrate

Not sure that either you have run the migration or not, run the following command, and it will tell you the statues of all the migrations. If the status is up, the migration has been run, and for down, a migration couldn't be run.
rake db:migrate:status

When you run a migration, and you would like to get notified in terminal that it has been successfully run, you can add a puts statement in there like following:
class AddColumnToCategories < ActiveRecord::Migration
  def change
    add_column :categories, :product_id, :integer, index: true
    puts "product_id column has been added into categories."
  end
end

A: Have you tried rails generate migration AddProductIdToCategories product_id:integer?
When you have created the migration if you look inside the migration file you can see if any code has been generated in the change method before you run the migration. If it has not generated any content you can manually add it:
def change
    add_column :categories, :product_id, :integer
end


text:
Q: Mysql Query to retrieve data based on values length Hii Guys!!!
             i have a table named cdrcost which has dst column.I am need to retrieve the values based on digits in the column values.
For example:
dst
0001266
2545
874545565612
25452`
Any suggestion will be welcomed

A: Assuming I understood what you're asking for:
SELECT *
FROM cdrcost
WHERE LENGTH(dst) = 31;


text:
Q: Upgrade to React version 16.10.2 error while using Ant Design Components. Function components cannot be given refs I recently upgraded to React version 16.10.2. And facing errors while using And Design Components.
I want to use Title from Typography.
Here is what I was doing earlier.
import { Typography } from 'antd'
const { Title } = Typography

<Title level={4}>Hello World</Title>

I have an error in console as follows

Function components cannot be given refs. Attempts to access this ref
  will fail. Did you mean to use React.forwardRef()?

A: This issue has been fixed in antd@3.23.6: https://github.com/ant-design/ant-design/pull/19074


text:
Q: Get default font name in Cocoa for NSMenuItem? I am using NSAttributed NSString in my NSMenuItem, but it's Font is changed as compare to default font, I wants to use default font for Attributed string.
Can any one explain, how to find or fetch the default Font for NSMenuItems.
Right now I am using this :

 NSDictionary *attributes = @{
                                 NSFontAttributeName: [NSFont fontWithName:@"Helvetica" size:14],
                                 NSForegroundColorAttributeName: [NSColor blackColor],
                                 NSParagraphStyleAttributeName:paragraphStyle

                                 };

Thanks

A: To get the default font of an NSMenuItem just use the method [NSFont menuBarFontOfSize:0].
NSDictionary *attributes = @{ NSFontAttributeName: [NSFont menuBarFontOfSize:0],
                              NSForegroundColorAttributeName: [NSColor blackColor],
                              NSParagraphStyleAttributeName: paragraphStyle };

which is easier in all ways.

A: I got the solution, I used this
NSFont *oldFont = [menu font];
NSLog(@"%@",oldFont.familyName);

and used like this
NSDictionary *attributes = @{
                                 NSFontAttributeName:[NSFont fontWithName:@"Lucida Grande" size:14],
                                 NSForegroundColorAttributeName: [NSColor blackColor],
                                 NSParagraphStyleAttributeName:paragraphStyle

                                 };


text:
Q: Valuation ring of $k(x, y)$ of dimension $2$ My question is as follows:

Given a field $k$, is it always possible to find a valuation ring of $k(x, y)$ of dimension $2$?

A: If by $k(x,y)$ you mean the rational function field in two variables over $k$, then the answer is yes.
Consider the map $v:k[x,y]\rightarrow\mathbb{Z}\times\mathbb{Z}$ defined as follows: express a polynomial $f\neq 0$ in the form $f=x^ay^bg$, where $g$ is neither divisible by $x$ nor by $y$, and set $v(f):=(a,b)$. Since $v$ is multiplicative it can be extended to the fraction field $k(x,y)$ of $k[x,y]$. Order the group $\mathbb{Z}\times\mathbb{Z}$ lexikographically: $(a,b)<(c,d):\Leftrightarrow (a<c)\vee (a=c\wedge b<d)$. Then $v$ is a valuation having a valuation ring of Krull dimension $2$.
Remark: all valuation rings of $k(x,y)$ containing $k$ can be obtained using the construction just described but replacing $x,y$ with other prime polynomials.


text:
Q: Unable to get Topic Exchange to Work in RabbitMQ AMQP 1.0 I am finding it very difficult to work with RabbitMQ and AMQP 1.0, particularly as it pertains to topic exchanges using AMQPNetLite.  I am unable to send a message using a topic exchange to a specific queue.  I'm not even using wildcards.
My situation is super simple too.  I have one topic exchange.  I have one queue that the topic exchange sends to.  When I send to the topic exchange, the queue never receives the message.
test.exchange:
  bind: testqueue - routing key: test

testqueue:
  bound to exchange with routing key: test

The AMQP 1.0 documentation says that the "Subject" is the routing key right?  Well when I use AMQPNetLite to send to RabbitMQ, it appears to connect, and the topic appears to have received the message, but it is never routed to the queue.
Here's the entire code:
            var rabbitMqAddress = $"amqp://127.0.0.1:5672";
            var address = new Address(rabbitMqAddress);
            var producerName = $"Producer-test.topic-{Time.GetTimeStamp()}";

            var connection = new Connection(address, null, new Open
            {
                ContainerId = Guid.NewGuid().ToString(),
                ChannelMax = 64,
            }, null);

            var session = new Session(connection);
            var senderLink = new SenderLink(session, producerName, "/topic/test.exchange");

            senderLink.Send(new Message
            {
                BodySection = new AmqpValue { Value = "test 123" },
                Properties = new Properties
                {
                    Subject = "test",
                }
            });

The image proves the binding.  Is there something I'm missing?

A: i think you mix two ways of doing it.
Either you publish to address "/topic/test" -where test is your routingkey
OR
you publish to "/exchange/test.exchange" and set the Subject-property to "test".
Both works. if you use the "/topic/"-prefix in your address you are going through the default "amq.topic"-exchange and not your own "test-exchange".
made sense?
more information in the "Routing and Addressing"-secion here: https://github.com/rabbitmq/rabbitmq-amqp1.0


text:
Q: Detecting Duplicates Using Divide and Conquer - Merge Sort I want to detect duplicates in a given array using divide and conquer approach. Can I use Merge Sort for this:

*

*First split the array in log N steps

*Then sort by merging

*While merging use a counter variable to detect duplicates. O(N)
So in total it will take O(N log N) steps...
Is this approach correct?

A: You don't need to. You can do it in O(n)
You have the original array int A[N]; Create a secound array bool a[N] too, of type bool=false. Iterate the first array and set a[A[i]]=true if was false, else you have found a duplicate.

A: You just use merge sort to sort the array which takes O(nlogn) , once the array is sorted
you can detect duplicates in O(n) time so total time is O(nlogn).

For example the array is arr[] and it has N elements.
1.Sort array using merge sort.

2. (a)variables
   start -- initially at position 1 of array (arr has elements from 1 to N).
   count--- to count number of times a specific number occurs

   (b)method
   for(i=2;i<=N;i++)
   {
       if(arr[i]!=arr[start])
       {
           printf("%d has occurred %d times",arr[start],count);
           count=1;
           start=i;
       }
       else count++;
   }
   printf("%d has occurred %d times",arr[start],count);

Thuis total time O(nlogn) space O(n).


text:
Q: What are the worst things that inexperienced developers forget to think about? As a young developer, I would find it useful to get some advice regarding things to think about in order to develop a high-quality application. In my college courses, most teachers emphasized input validation and some talked about security concerns, but no one covered the importance of certain other things, like logging for example.
What are some mistakes that inexperienced developers tend to make which could lead to frustration for more experienced developers?

A: *

*Tests.

*Tests.

*More tests.

*Source Control

*Taxes appropriate to whatever program you're targeting.

On Windows, these taxes are:

*

*Dealing with High DPI environments

*Roaming User Profiles

*Fast User Switching

*Remote Desktop (e.g. you don't want to use double buffering when RDP is in effect

*Playing nicely with Hierarchical Storage Management

*Multiple Monitors

*64 bit Windows

On pretty much every platform, you'll have to deal with:

*

*Unicode

*Localization

*Power Managment

A: In my experience, the one thing nearly all inexperienced developers fail to bear in mind is that you're (almost always) working in a commercial environment. Your code has to be good, but not perfect. The most important thing is not perfection, it's that your code ships.
Put another way, delivering the perfect piece of code three months after your company has gone bust is no good to anyone.
In my opinion, this is one of the most significant ways in which development in the real world differs from development as taught at university.

A: Really broad question; to answer in detail is ...multiple books.
Here's a general systems-definition checklist to get you started -

*

*What are the critical resources in the system and how might the demands on them change?

*What are the performance capabilities of the system and how might they need to grow?

*Which areas of requirement might become unnecessary and removable?

*Is there the possibility of a need to have different versions of the system with different capabilities?

*What are the implications on manpower and computer resources if the identified changes come about?

*What impact will the new system have on existing operation systems?

*Which areas of function have the greater chance of requiring change in the light of experience with the system?

*Who are the system's future users?

*What are the system's future maintainers?

*What are the future enhancements that the system's future users can identify as likely?

*How does the system fit into the user's overall plans and how are they expected to develop?

A: I find the main thing new developers forget is that in the real world they are often working as part of a team. This shows itself as..

*

*Checking in code that breaks the
build

*Not reusing code that's already
there

*Doing things their way rather
than the same way as everyone else -
which makes maintenance expensive

That's not to say their code isn't up to scratch in isolation, but they aren't working in isolation anymore.

A: The clean decoupling of the system on one's development machine, and the target machine, so that one does not end up with "Well, it works on my machine" situations.
And how quickly can you reconstruct your development machine?

*

*Do you know which packages you requires?

*Do you have a push button solution to rebuild your database?

*Do you have a push button solution to test the integrity on the source code?

A: I think its probably design - ie the approach of thinking about what you're going to do before you do it.
Too many inexperienced coders (remember when you first started) like to jump in and get something going, then add a bit more and ad a bit more and add a bit more. This approach can work if you've planned to do it that way (each bit can be tested as you go after all), but most inexperienced coders only focus on the part they're writing.. so all the additions tend to be hacked in on top. And we've all seen code that's evolved like that!
Organization is the next thing, often they're too focused on the code they've written to remember how they did it, and what was required. So they forget to bundle or document a dependency that's required. They also tend to put things where they fall, I had to criticism a junior last week who checked in his code in the root directory including 3 wsdls, 2 of which were the same file, and a set of 3rd party dlls which he committed in a sub directory and the root directory. The code wasn't formatted to any standard you could think up either, and there were several functions that were present but never called.
Obviously he got it working but it was not tidy, and that meant installation, and maintenance, would have been troublesome.

A: I think the biggest differences are in the coding technique. Everyone has a slightly different approach, but inexperienced developers tend to produce code that:

*

*does not handle boundary cases

*is far lengthier than necessary

*has bad performance characteristics in relevant scenarios

*has poor separation of concerns

*lacks self protecting techniques like use of const, sealed, readonly, etc.

*oddball ways of returning data and collections of data

*

*this more demonstrates inexperience with a platform

A: Because you asked the worst things, then my answer is as follows:

*

*Forgot to think of sanitizing the development machine from spywares, malwares, and trojan viruses.

*Forgot to think of making a regular backup saved in secure storages that are in different geographic locations.

A: My biggest one is remembering to plan for flexibility.  In classes, the requirements are almost always set forth at the beginning and never change.  In software, it's often the opposite: you get a vague set of requirements, and they change often (even daily).  The best thing that you can do to help with this is to code flexibly: loose coupling, small functions that can be used reliably in multiple situations, and avoiding hard-coding things as much as possible.
In time, you're likely to learn a) what things are most likely to change, and conversely what likely won't, and b) how to anticipate change requests and plan for them.


text:
Q: How to allow sign in with devise if user is already authenticated? There's an App which creates a new user when you first time open the site (if you don't have a cookie). Also you can sign in as different user. The problem is Devise doesn't allow to sign in as already authenticated user. Even if I override require_no_authentication in SessionsController warden still remembers the user through session.
I do aware about guest user pattern but there's no guest user. The app is intended to create real user accounts and allow to sign in as another users.
So the question is should I create new Warden strategy and if so, what checks shall I do there? Or there's another way?

A: Just reset the session in the desired action. You can just make the first line be reset_session, or make it a before filter, like so:
before_filter :deauthorize_user, only: [ :some_action ]

def deauthorize_user
  reset_session
end


text:
Q: Apache Camel return producer errors I have a simple proxy configuration like the following:
from("netty-http://0.0.0.0:8080/xyz")
    .toD("netty-http:" + "https://abc/xyu")
    .process(this::processResponse);

But when abc service return 400 with readable errors, camel return own exception:
org.apache.camel.component.netty.http.NettyHttpOperationFailedException: Netty HTTP operation failed invoking
What can I do to simply return the error from producer service?

A: You can try setting the throwExceptionOnFailure option to false. Http components in camel have this enabled on default, probably so that failures can easily be caught and handled like any other exceptions in camel.
When its enabled you can get the Exception and details about the exception through Exchange properties which in this chase you can probably cast to NettyHttpOperationFailedException to get more information about it.
Exception cause = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);

A: I had a similar issue with jetty (Apache-Camel / Camel-Jetty / Don't return exception-stack-trace in case of 401 response)
In my case the options bridgeEndpoint=true and throwExceptionOnFailure=false solved the issue (except for http 401)
from("netty-http://0.0.0.0:8080/xyz")
    .toD("netty-http:" + "https://abc/xyu?bridgeEndpoint=true&throwExceptionOnFailure=false")
    .process(this::processResponse);


text: Q: Inject JS into a live site from localhost I'm working with Monetate, a testing tool which injects JS into our clients sites once the targeted page has loaded. Although Monetate is great for tests it is not good for developing and there is no community for it. I'm looking for a way to have a dev setup (express server, gulp task runner, sass etc) and to dynamically inject the JS and CSS files into our clients sites, simulating Monetate. I've been trying browser-sync but I can't seem to inject files from my local server into a live site. Any ideas would be most welcome!


text:
Q: Show text on image hover doesn't work - CSS/HTML I'd like text to appear on the right side of a logo when the person moves the cursor over the logo. I checked out other similar questions and tried their solutions and it still doesn't work. When I hover over the logo, nothing appears. When I check the inspector, the browser doesn't seem to read the hover effect. Its still reading opacity:0 and visibility:hidden.

.logo {
  display: block;
  width: 90px;
}

.puneet-name {
  position: absolute;
  visibility: hidden;
  opacity: 0;
  transition: opacity .2s, visibility .2s;
}

.logo img:hover .puneet-name {
  visibility: visible;
  opacity: 1;
}

.header_menu {
  padding: 25px 0;
  z-index: 12;
  margin-right: 2px;
  margin-left: 0.1px;
}

Person Name

A: Text will show when hovering over the image

.container {
  position: relative;
  width: 50%;
}

.image {
  display: block;
  width: 100%;
  height: auto;
}

.hover-text {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100%;
  width: 100%;
  opacity: 0;
  transition: .5s ease;
  background-color: #008CBA;
}

.container:hover .hover-text {
  opacity: 1;
}

Person Name


text:
Q: Is the m2eclipse mailing list being managed? I tried to subscribe to the m2eclipse mailing list by sending an email to user-subscribe@m2eclipse.codehaus.org but it never sent me back any confirmation email.  I sent an email to info@sonatype.com asking if the mailing list was still running a couple of weeks ago and haven't received any response back to that either.
Then I found another way to subscribe via http://xircles.codehaus.org/lists/info/search. So I did and am now receiving emails sent to the list.  However, I can't send the list emails.  They get bounced back with a failure notice:
Hi. This is the qmail-send program at mail.codehaus.org.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<user@m2eclipse.codehaus.org>:
Sorry, only subscribers may post. If you are a subscriber, please forward this
message to user-owner@m2eclipse.codehaus.org to get your new address included. (#5.7.2)

I've forwarded this message as instructed twice now (once yesterday and once this morning) without result so far.
Does anyone know if this mailing list is being managed?  It sucks to be only able to read messages and not to send them.
Thanks in advance!

A: The mailing list has now been moved from codehaus to Sonatype.  See http://m2eclipse.sonatype.org/project-information.html for subscribe info.


text:
Q: Why is object_a != object_b, if they have the exact same id, type, and attributes? I have two User objects that should be the same, but ruby is saying they are not. Can anyone please explain to me what is going on here?
a = current_user
b = votable.user

a == b
false
a.id == b.id
true
a.name == b.name
true
a.attributes == b.attributes
true

Updates / additional information since the original posting:

*

*Turns out the problem I'm having is intermittent. It occurs about 30% of the time I refresh the page in question. 70% of the time, A == B and everything works as expected. But 30% of the time, A does not equal B.

*When the problem occurs, Ruby is actually telling me that the class (type) of my objects is not the same, even though they look identical (User and User). Here's the output for that 30% of the time when the problem is happening:

.
a.class == b.class AKA a.type == b.type
false (note: this is a correction to the original post which said true)
a.class.to_s
"User"
b.class.to_s
"User"
a.class.name == b.class.name
true
a.class.methods == b.class.methods
true
a.class.object_id == b.class.object_id
false

So the class (type) of the objects looks exactly the same. It is said to be User. But when you evaluate a.class == b.class, the answer is false the 30% of the time when I render the page, causing the problem.
Can anyone tell me what's going on? Many thanks.
➜  ~  ruby --version
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
➜  ~  rails --version
Rails 3.0.10

A: If a == b is false then I'm guessing it's doing something like a.object_id == b.object_id which would only be true if the references are pointing to the same object.
a.id == b.id is probably just checking the User.id and it makes sense that it would be true.
Easiest thing to do is keep checking on User.id. If you really want to use == you'll need to override it in the User class with something like:
class User
  def ==(other)
    self.id == other.id
  end
end

A: I don't know what kind of objects these are. Do they just decent from Object?
Object#== really just does Object#=== unless you override #== and define a more appropriate behavior. For Object#=== to be true they have to actually be references to the SAME OBJECT, not equivalent objects.
Just define a #== method and use some sane logic to determine if two objects are the same... then you can use a == b and get true.
If these are ActiveRecord::Base descendants then something else is going on, as ActiveRecord::Base objects do have a sane #== method (though you can overwrite that behavior too).

A: The two objets are not the same object. They are, however, referencing the same user in the database.
I suggest that you compare them on the id as you did.

A: If you are using Rails 3 and assuming each of your methods above returns an ActiveRelation (or at a minimum, one of them does). Then it would be safe to say that the first comparison is right, as each ActiveRelation probably is a different object.
My answer makes a few assumptions about your code, but might help offer some insight.

A: According to the Rails documentation at http://api.rubyonrails.org/classes/ActiveRecord/Base.html#method-i-3D-3D , the equality operator should be checking type and id.
# File activerecord/lib/active_record/base.rb, line 1811
def ==(comparison_object)
  super ||
    comparison_object.instance_of?(self.class) &&
    id.present? &&
    comparison_object.id == id
end

What must be happening is that they are not the same class.  Could you please check and output the results?
votable.user.class
current_user.class

A: Logicl explanation:
They have simmilar attributes, but they are different essentially. Note that the Earth and the Marth are different planets, even if we only look at the facts that both of them are in the Milky Way galaxy and both of them are planets.
If an object is like another object it is not necessarily the same.
Technical explanation:
When you create an object a reference to the object will be created. If you create another object another reference will be created.
If you have object A and object.
a = current_user
b = votable.user
a == b
false

a = current_user
b = a
a== b
true

Two objects are equal if their reference is the same (and their attributes are the same too, of course). You can always write methods to define new equivalence relations if the standard relations are not enough ;)


text:
Q: Setting up a Linux Ubuntu Server to provide Samba, AFP and Windows Roaming Profiles I'm replacing our old Windows XP Pro office server with a HP Microserver running Ubuntu Server 12.04 LTS.
I'm not a Linux expert but I can find my way around a terminal prompt, I'm a Mac user by choice.
The office use a mix of Windows XP Pro machines and OSX Lion laptops. I included Samba during installation, and I'm planning on using Netatalk for the AFP and Bonjour sharing.
I'd quite like to have samba make the server appear in 'My network places' on the Windows machines the way Bonjour makes it appear in finder on the Macs, if this is possible?
I want to get to a point so that a user logging into Windows, gets connected to the Ubuntu server (do they need an Ubuntu user account?) which get them their shares and their Windows user profile (though a standard profile across users would do).
The upshot is to make centralised control of user accounts (e.g. If a person leaves, killing their account on the server stops their Windows logon and ability to access Samba shares) and to ensure files aren't stored on the individual machines for backup/security purposes.
I want to make this as simple as possible, so don't want to have loads of stuff I don't need, I just can't figure out:
What I need at the server end:
- will Samba be enough (already installed as part of initial installation), or will I need to cock around with LDAP (and how does this interact with Samba)
- For someone of moderate Linux competence like me, is there a package that offers easy admin of user accounts, e.g. a GUI like phpLDAPadmin (if LDAP is necessary)
How to configure the XP machines:
- do I need to have the XP machines set up as a domain controller (I've no idea on this aspect of Windows and Im struggling to find a meaningful definition of domains/profiles/AD/etc)
- roaming profiles looks to offer the feature of putting the user's files on the server rather than the machine itself along with a profile that follows the user from machine to machine.
Syncing Mac user's home folders with the server
This is less of a concern because I can set up Time Machine if it comes to it, but I'd appreciate any recommendations of what approach I should take having the Mac home folders synced to the server.

A: If you want roaming profiles, your best bet may be Samba 4, which has recently become stable enough to have release candidates.
Here's a Samba 4 HowT-To which takes you step-by-step.  In this howto, you configure Samba 4 as a domain controller.  Then you can join your Windows clients to the domain, which gets you roaming profiles, group policy, centralized account management, redirected folders, and so on.  Here you'd manage your domain using Microsoft's graphical tools (MMC snap-ins) called Remote Server Administration Tools (RSAT), so you'd never need to use OpenLDAP's command-line tools.  (Though you could use those tools to query your Active Directory.)
Here's another ServerFault thread about what you can expect with Samba4: Active Directory Domain with SAMBA or Other Tool.
I am not sure about syncing Mac's user home folders with the server.  Here you could take several approaches... use something to join Macs to the domain (if such a thing exists), or give Macs the ability to access files over NFS / SFTP.  Here the worry is that Samba 4 uses the filesystem's extended attributes / ACLs to track file access control list, and if you give users direct access to the filesystem on your Linux/Samba server, bypassing Samba 4, NTFS permissions will be messed up.  I don't know a way around this.  I hope others contribute to this question.


text:
Q: Custom route mistaken for object id in Rails I have the following route:
 view_all_styles        /styles/view_all(.:format)                styles#view_all

When I point my broswer at xyz.com/styles/view_all I receive the error:
ActiveRecord::RecordNotFound at /styles/view_all
Couldn't find Style with id=view_all

I'm also routed to the show action??
Request parameters
{"action"=>"show", "controller"=>"styles", "id"=>"view_all"}

A: It sounds like you've got your routes defined in the wrong order - you'll want to define your custom route before the resource routes of styles. Otherwise, you'll run into exactly this problem.
Since your route, /styles/view_all also fits into the route for #show, /styles/:id ('view_all' being the :id), it will match and pass along the request to #show before it even tries to match your custom route.


text:
Q: Get records for yesterday from list c# I set up a list with 7 columns and Thousands of rows.
I also have a data table with the same data (yes, redundant).
What I am trying to do is get all the records related to yesterdays date.
I've started a few queries on the data table with no success.  It keeps on coming up empty. Same with the list.
Below is all my code for the table/list.
     DataTable dtTesting = new DataTable();
            List<string>[] listA = new List<string> [8];
            listA[0] = new List<string>();
            listA[1] = new List<string>();
            listA[2] = new List<string>();
            listA[3] = new List<string>();
            listA[4] = new List<string>();
            listA[5] = new List<string>();
            listA[6] = new List<string>();
            listA[7] = new List<string>();

            dtTesting.Columns.Add("Over2Minutes", typeof(string));
            dtTesting.Columns.Add("AgentName", typeof(string));
            dtTesting.Columns.Add("PhoneNumber", typeof(string));
            dtTesting.Columns.Add("DateTime", typeof(DateTime ));
            dtTesting.Columns.Add("Direction", typeof(string));
            dtTesting.Columns.Add("CallTo", typeof(string));
            dtTesting.Columns.Add("ManagerName", typeof(string));
            dtTesting.Columns.Add("Duration", typeof(string));

            // List<string> listE = new List<string>();
            //List<string> listF = new List<string>();

            while (!reader.EndOfStream)
            {
                var line = reader.ReadLine();
                var values = line.Split(',');

                DataRow data = dtTesting.NewRow();
                data["Over2Minutes"] = values[0];
                data["AgentName"] = values[1];
                data["PhoneNumber"] = values[2];
                data["DateTime"] = values[3];
                data["Direction"] = values[4];
                data["CallTo"] = values[5];
                data["ManagerName"] = values[6];
                data["Duration"] = values[7];

                listA[0].Add(values[0]);
                listA[1].Add(values[1]);
                listA[2].Add(values[2]);
                listA[3].Add(values[3]);
                listA[4].Add(values[4]);
                listA[5].Add(values[5]);
                listA[6].Add(values[6]);
                listA[7].Add(values[7]);

            }
            //start of filters

            DataTable filtered = new DataTable();
            DateTime yesterday = DateTime.Today.AddDays(-1);
            DateTime today = DateTime.Today.AddDays(1);

            //List<string> listBD = new List<string>();
           // listBD.AddRange(listB);
         //   listBD.AddRange(listD);
           //

            if (cbDayList.SelectedIndex == 0)
            {
                try
                {
                  var FilteredData =

                }
                catch
                {
                    MessageBox.Show("No Data To Show");
                }
            }

A: If you want to filter the DataTable rows according to a particular data you use the Select method of the DataTable. But, being the FilterExpression of the Select method a string, you are forced to convert the DateTime variables to a string. And this is where the problem begin.
You cannot use the default conversion of a DateTime to a string because in case of DateTime the FilterExpression requires the date to be expressed according to the InvariantCulture format. "M/d/yyyy"
 var FilteredData = dtSettings.Select("DateTime >= #" +
                                      yesterday.ToString("M/d/yyyy") +
                                      "# AND date <= #" +
                                      today.ToString("M/d/yyyy") + "#");

By the way, albeit improbable this query gets also the records stored exactly  at midnight. Probably you need < today.ToString("M/d/yyyy")
Another way to reach your goal is through the IEnumerable extension Where (Linq namespace)
 var  FilteredData = dtSettings.AsEnumerable()
              .Where(x => x.Field<DateTime>("DateTime") >= yesterday &&
                          x.Field<DateTime>("DateTime") < today);


text:
Q: How can I conditionally copy between Google sheets? I would like to conditional copy a value from one sheet to another.
About the below script:

*

*It checks if in SOURCE tab the value in column H is equal to 45 and if Column A is empty. If so, it should copy the value in Column G into the last row of column A in TARGET tab. It also ads data to some of the TARGET tab columns

*If I change this: sourceSheet.getRange(rangeToCopy).copyTo(destination.getRange(destination.getLastRow()+1, 1)),{contentsOnly:true};
to this: sourceSheet.getRange(rangeToCopy).copyTo(destination.getRange(destination.getLastRow()-1, 1)),{contentsOnly:true}; the cell is pasted on Column A on the penultimate row, which makes me think that the present code tries to copy to a row after the last visible one instead of pasting into the next blank cell after a non blank one in Column A, hence returning the error explained on the next bullet

*As is, it returns the error: The coordinates of the range are outside the dimensions of the sheet. (I understood that the problem is because of the use of getlasrow and being used as is, it's trying to retrieve a row that does not exist)
This is the code so far:
 function CopyTo(){
  var sheet = SpreadsheetApp.getActive();
  var sourceSheet = sheet.getSheetByName("SOURCE");
  var destination = sheet.getSheetByName("TARGET");
  var lastRow = sourceSheet.getDataRange().getLastRow();

  for(var row=3; row<=lastRow; row++){
  if(sourceSheet.getRange(row,1).getValue() == "" & sourceSheet.getRange(row,8).getValue() >= "45"){
 Logger.log("CELL H"+row+" has \">=45\""+"\n=================\n"+"CELL A"+row+" is \"empty\""+"\n=================\n"+"RANGE TO COPY:\n"+ "\"G"+row+":G"+row+"\"");
      var rangeToCopy = "G"+row+":G"+row;
      sourceSheet.getRange(rangeToCopy).copyTo(destination.getRange(destination.getLastRow()+1, 1)),{contentsOnly:true};
      destination.getRange(destination.getLastRow(), 9).setValue("Added Text Column 9");
      destination.getRange(destination.getLastRow(), 13).setValue("Added Text Column 13");
      destination.getRange(destination.getLastRow(), 14).setValue(new Date());
    }
  }
}

Also, there are other columns in Target sheet that fetch values so maybe that's the reason why the script isn't pasting on the right place but I can't get it to work.
Could you be so kind to help out?
Thank you in advance.
This is a test sheet which returns the previously mentioned error when running the script.
UPDATE
I've added to the script:
var column = destination.getRange('A' + destination.getMaxRows())
      var lastFilledRow = column.getNextDataCell(SpreadsheetApp.Direction.UP).getA1Notation().slice(1)
      Logger.log(lastFilledRow);

so I would get the last filled row number in Column A. It retrieves it but I'm having trouble in using it as range and I get the error: Exception: Cannot convert 'Range' to int.
sourceSheet.getRange(rangeToCopy).copyTo(destination.getRange(destination.getRange(lastFilledRow,1), 1)),{contentsOnly:true};

A: The problem lies with your TARGET sheet having a set maximum row of 84, thus, destination.getLastRow()+1 will return 85 which is outside the said maximum row.

To solve this, create a new TARGET sheet or find a way to remove the limit in the current TARGET sheet. Your current code should be fine.
EDIT:
I've edited your v2 code to make it work on the current test sheet provided. Please see code below.
   function CopyTo_V2(){
  var sheet = SpreadsheetApp.getActive();
  var sourceSheet = sheet.getSheetByName("SOURCE");
  var destination = sheet.getSheetByName("TARGET");
  var lastRow = sourceSheet.getDataRange().getLastRow();
  var column = destination.getRange('A' + destination.getMaxRows())

  for(var row=3; row<=lastRow; row++){
  if(sourceSheet.getRange(row,1).getValue() == "" & sourceSheet.getRange(row,8).getValue() >= "45"){
 Logger.log("CELL H"+row+" has \">=45\""+"\n=================\n"+"CELL A"+row+" is \"empty\""+"\n=================\n"+"RANGE TO COPY:\n"+ "\"G"+row+":G"+row+"\"");
      var rangeToCopy = "G"+row+":G"+row;
      var lastFilledRow = parseInt(column.getNextDataCell(SpreadsheetApp.Direction.UP).getA1Notation().slice(1))
      Logger.log(lastFilledRow);
      sourceSheet.getRange(rangeToCopy).copyTo(destination.getRange(lastFilledRow+1,1)),{contentsOnly:true};
      destination.getRange(lastFilledRow+1, 9).setValue("Added Text Column 9");
      destination.getRange(lastFilledRow+1, 13).setValue("Added Text Column 13");
      destination.getRange(lastFilledRow+1, 14).setValue(new Date());
    }
  }
}


text:
Q: Re-assign private IP address in AWS? I have an AWS instance running behind an elastic IP. The instance also has a private IP address in my VPC. I will be re-assigning the elastic IP to another instance and am trying to re-assign the private IP as well. Note that the instance only has one private IP (no secondary).
Is this possible?

A: assign the same/old instance private ip to a new instance upon below conditions.

*

*creating a new instance on the same VPC as of Old instance

*terminate the old instance after taking AMI backup

*and you cannot assign private IP of old instance to new instance primary private IP after launching the instance.

Follow the below steps to Re-assign an old instance private IP to new instance primary private IP
1. Open EC2 dashboard.
2. Click on Launch Instance.
3. Then choose My AMIs on the left side tab and select your AMI.
4. Select the desired instance type.
5. Click on "Next :Configure Instance details".
6. Then select/provide the VPC ID and choose the subnet in network and subnet field respectively.
7. Select "disable" option in " Auto-assign Public IP" field of "Configure Instance" (which is third step of launching an instance)
8. In the same page, scroll down and click on Network Interfaces.
9. Then paste the required private IP in Primary IP field.
10. Add storage, configure Security group if required ( if you wish)
11. Click on Launch.

A: Unless this is a 'secondary private ip address' (and you said it was not), then no, you can't:

You can assign additional private IP addresses, known as secondary
  private IP addresses, to instances that are running in a VPC. Unlike a
  primary private IP address, you can reassign a secondary private IP
  address from one network interface to another. For more information
  about primary and secondary IP addresses, see Multiple IP Addresses in
  the Amazon EC2 User Guide for Linux Instances.

http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-ip-addressing.html

A: If you have an existing instance with the private IP you want (EXAMPLE: 10.0.0.101).
You should take an image (AMI) and then terminate that instance.  Because it is in a VPC, just stopping it won't free the private IP.
Once you have a good image, terminate it.  That would free up its Private IP Address. Thus you would have (10.0.0.101) available
Then assign a secondary private IP to your new instance that you want and specify the private IP to be the one you want it to be (10.0.0.101)

To assign a secondary private IP to an existing instance
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
In the navigation pane, choose Network Interfaces, and then select the network interface attached to the instance.
Choose Actions, and then select Manage Private IP Addresses.
In the Manage Private IP Addresses dialog box, do the following:
Choose Assign new IP.
Enter a specific IP address that's within the subnet range for the instance, or leave the field blank and we'll select an IP address for you.
(Optional) Select Allow reassignment to allow the secondary private IP address to be reassigned if it is already assigned to another network interface.
Choose Yes, Update, and then choose Close.
Note that alternatively, you can assign a secondary private IP address to an instance. Choose Instances in the navigation pane, select the instance, choose Actions, select Networking, and then select Manage Private IP Addresses. You can configure the same information in the dialog as you did in the steps above.


text:
Q: unable to install pyaudio in python 3.9 how to install I'm using VSCode editor I want to install PyAudio but it generating some errors.
I tried to install PyAudio wheels but the compiler said ERROR: PyAudio-0.2.11-cp310-cp310-win32.whl is not a supported wheel on this platform. I'm using python 3.9.
How can I install PyAudio?

A: From the explanation it looks like you have Python 3.9 on and Windows system.
Please try with the below whl files based on the whether you have 64 bit or 32 bit python installed from this link.
PyAudio‑0.2.11‑cp39‑cp39‑win_amd64.whl
or
PyAudio‑0.2.11‑cp39‑cp39‑win32.whl

A: It looks like you choose the wrong version for you computer, have a try with
PyAudio‑0.2.11‑cp39‑cp39‑win_amd64.whl

as said above


text:
Q: How to open a data:image/png;base64 URL in the browser from a Firefox OS app? I need to open a data:image/png;base64 URL in the default browser in Firefox OS.
The relevant portions of the code:
HTML:

Link

JS:
document.getElementById("link").href=document.getElementsByTagName('canvas')[0].toDataURL();

The code works in Google Chrome.

A: In your JavaScript you have the expression:
document.getElementsByTagName('canvas')

but you don't have any canvas elements in your HTML code.
What you should be doing is using canvas' drawImage calls to place the bitmap into a canvas 2D context, then calling toDataURL on the canvas.
Also, why does the user have to touch the image first to generate the link?  Why not create the data URL in one step?


text:
Q: "Dynamic cast failure failure" from AnyObject? to Int Nutshell - I'm trying to get a highscore out of a plist
Here's the code to read the data:
    var myOutput: AnyObject? = NSUserDefaults.standardUserDefaults().objectForKey("highscore")
    println(myOutput!)

This is successful and the result of the println is the correct data
    if myOutput != nil{
        highscore = myOutput! as Int
    }

This gives me a "Swift dynamic cast failure". From everything I've read this should be working, so any tips would be great.

A: Thanks to user2864740 got me on the right track. Correct solution is:
    if myOutput != nil{
        highscore = myOutput!.integerValue
    }


text:
Q: Define switch for key=value In nim, you can define a symbol via -d:value and test if it was defined with defined(value). It is possible however to define a key and retrieve its value? I'm looking for something in the vein of --colors:on but user defined.

A: I also looked for this and didn't find anything for my nim-small-coreutils. I ended up using environment variables as a hack and read them in a nonportable manner:
const colors = staticExec "echo \"$colors\""

when colors == "on":
  echo "It's on!"
else:
  echo "I guess it's off? The value is: ", colors

This takes the environment variable at compile time, so you can use it like this:
colors=on nim c example

or alternatively:
nim c --putEnv:colors=on c example


text:
Q: Search result by range? I have to search for posts that have in tags or custom fields a number(price): example 152. Each post have a price tag. How I do to search for all post greater than a price for example I need to search for all post who have a price tag of minimum 100.
Something like /?s=keyword&price>=300
Thx

A: If the price is stored as a custom field you'll need to use the meta_query argument of WP_Query (see Codex). For instance:
 //Get posts with custom field 'price' between 20 and 100
 $price_filtered = WP_Query(array(
     'meta_query'=>array(
         array(
            'key' => 'price',
            'value' => array( 20, 100 ),
            'type' => 'numeric',
            'compare' => 'BETWEEN'
         ),
      )
 ));

(where price is the key of the custom field). Depending on how you might be implementing this (is it intended to be the 'main query' or not - you might want to use this at pre_get_posts)
Edit
If filtering a search result:
add_action('pre_get_posts', 'wpse71814_filter_search');
function wpse71814_filter_search( $query ){
     if( $query->is_search() && isset($_GET['min']) ){

         //Collect user input from $_GET for example
         $user_input_min_value = $_GET['min'];

         $meta_query = $query->get('meta_query');

         $meta_query[] = array(
            'key' => 'price',
            'value' => $user_input_min_value,
            'type' => 'NUMERIC',
            'compare' => '>='
         );

         $query->set('meta_query',$meta_query);
      }
}

Note: The original answer had a meta query which specified a range. The second answer has a meta query which filters for prices above some minimum value.
Usage: /?s=keyword&min=300

A: If you save the the price in a meta field, you can query posts using meta_query:
<?php
    $the_posts = new WP_Query( array(
        'meta_key' => 'price',
        'orderby' => 'meta_value_num',
        'order' => 'ASC',
        'meta_query' => array(
            array(
                'key' => 'price',
                'value' => '100',
                'type' => 'NUMERIC',
                'compare' => '>='
            )
        )
    ));
?>
<?php while ( $the_posts->have_posts() ) : $the_posts->the_post(); ?>

<?php the_title(); ?>

<?php endwhile; wp_reset_query(); ?>


text:
Q: Wordpress Custom Plugin CSS And
* Tag I have an issue while trying to apply a class on an li tag from my custom plugin css. I load my plugin after the theme is setup.
    add_action('after_setup_theme', 'run_menufix');

Still the li tag is being controlled by the theme css. Is there anything I can do here to make the plugin css to take control of the li tag? Thanks for anyput.

A: You can try like this to add your own classes
function main_menu() {
    add_theme_support('menus');
    register_nav_menus(array(
        'primary' => __('Main Menu'),
    ));
    register_nav_menus(array(
        'secondary' => __('Secondary Menu'),
    ));
}

function menu_item_class( $classes, $item, $args) {
    unset($classes);
  $classes = ["col-xs-6","col-sm-6","col-md-2","filter"];
  return $classes;
}

//Menu
add_action('after_setup_theme', 'main_menu');
add_filter('nav_menu_css_class', 'menu_item_class', 1, 3);

A: First I dequeued the theme styles and enqued added plugin styles. When I checked the html source I found that dequeued files are coming first followed by plugin file. Following code is my solution.
      wp_dequeue_style( 'child-style' );
      wp_dequeue_style( 'main-styles' );

    //re-enqueue the stylesheet
    wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/menufix-public.css', array('child-style','main-styles'), $this->version, 'all' );


text:
Q: Porting from struts2-dojo to jquery: periodically update a frame inside a jsp In my jsp I have this:
<s:url action="listarichiesteAjax.action" var="richiesteAjax" >
    <s:param name="messaggioUtente" value="messaggioUtente"></s:param>
</s:url>
<sx:div href="%{#richiesteAjax}" updateFreq="10000" preload="true">

This piece of code refresh every 10sec (calling the action listarichiesteAjax that execute a query) a JSP called from the action. I would like to port this and use jQuery.
Do I have to change my actions structure? Or do I just need to edit this jsp?
How do I will modify the code?
(I read here that it's preferable use jQuery instead of Struts2-jQuery plugin)

A: From the DivTag documentation:
updateFreq    false    false    Number
              How often to reload the content (in milliseconds). e.g. 5000

So it is there and it also has the same name.
You only need to change <sx: to <sj: , import jquery tags:
<%@ taglib prefix="sj" uri="/struts-jquery-tags" %>

and put <sj:head/> in your <head> section, where you should already have <sx:head/>


text:
Q: Spring yaml does not work on aws server I have a spring boot app with this yaml:
    ---
spring:
    profiles: production
server:
    port: 8080

servicesUrl:
  aaa:  aaa.aaa.aaa:9090

I create the jar using gradle assemble.
When I run it locally:
java -Dspring.profiles.acitve=production -jar aaa.jar

All works well.
I scp the jar to the server and when I run the exact same command  I get:
BeanCreationException: Error creating bean with name 'aaaController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'servicesUrl.aaa' in value "${servicesUrl.aaa}"

I have to state that the different ports are being served according to the profile, both locally and AWS.
This is the line in the class:
@Value("${servicesUrl.aaa}")
private String aaaServiceUrl;

What did I do wrong?

A: Your YAML file seems to have an issue:
    ---
spring:
    profiles: production
server:
    port: 8080

servicesUrl:
  aaa:  aaa.aaa.aaa:9090

YAML accepts 2 spaces indention only. If you mix indention with \t or 4 spaces then your file wont be parsed correctly. Here is what your YAML file should look like:
---
spring:
  profiles: production
server:
  port: 8080

servicesUrl:
  aaa:  aaa.aaa.aaa:9090

There is also a typo in your java command (word "acitve"):
java -Dspring.profiles.acitve=production -jar aaa.jar

it should be:
java -Dspring.profiles.active=production -jar aaa.jar


text:
Q: Binomial Theorem of Differentiation? I noticed that $$\frac{d^{n}}{dx^{n}} f(x)g(x)=\sum_{i=0}^n {n \choose i} f^{(i)}(x)g^{(n-i)}(x)$$ and it's had me scratching for a little bit. It's easy to see how the cross terms add up but can anyone draw a direct comparison between the behavior being exhibited here and the binomial expansion? It seems to work for the case equivalent to the multinomial theorem as well ($\frac{d^{m}}{dx^{m}} \prod_{k=1}^{n} f_k(x)$). Can someone produce a proof for this more general case (preferably by induction)? Any and all insights are welcome!

A: Taylor series expansion of $f(x+h)$
$$
f(x+h)=f(x)+h\frac{d}{dx} \left(f(x) \right)+\frac{h^2 }{2!}\frac{d^2}{dx^2} \left( f(x) \right)+\frac{h^3 }{3!}\frac{d^3}{dx^3} \left( f(x) \right)+....
$$
Taylor series expansion of $g(x+h)$
$$
g(x+h)=g(x)+h\frac{d}{dx} \left(g(x) \right)+\frac{h^2 }{2!}\frac{d^2}{dx^2} \left( g(x) \right)+\frac{h^3 }{3!}\frac{d^3}{dx^3} \left( g(x) \right)+....
$$
Taylor series expansion of $f(x+h)g(x+h)$
$$
f(x+h)g(x+h)=f(x)g(x)+h\frac{d}{dx} \left(f(x)g(x) \right)+\frac{h^2 }{2!}\frac{d^2}{dx^2} \left( f(x)g(x) \right)+\frac{h^3 }{3!}\frac{d^3}{dx^3} \left( f(x)g(x) \right)+....
$$

$$
f(x+h)g(x+h)=f(x)g(x)+h\frac{d}{dx} \left(f(x)g(x) \right)+\frac{h^2 }{2!}\frac{d^2}{dx^2} \left( f(x)g(x) \right)+\frac{h^3 }{3!}\frac{d^3}{dx^3} \left( f(x)g(x) \right)+....=(f(x)+h\frac{d}{dx} \left(f(x) \right)+\frac{h^2 }{2!}\frac{d^2}{dx^2} \left( f(x) \right)+\frac{h^3 }{3!}\frac{d^3}{dx^3} \left( f(x) \right)+....)(g(x)+h\frac{d}{dx} \left(g(x) \right)+\frac{h^2 }{2!}\frac{d^2}{dx^2} \left( g(x) \right)+\frac{h^3 }{3!}\frac{d^3}{dx^3} \left( g(x) \right)+....)
$$
If you order $h^n$, it will give you binom expansion
$$\frac{d^{n}}{dx^{n}} f(x)g(x)=\sum_{i=0}^n {n \choose i} f^{(i)}(x)g^{(n-i)}(x)$$
Because it has exactly the same coefficient of
$$
=(1+hx +\frac{h^2 x^2 }{2!}+\frac{h^3x^3 }{3!}+....)(1+hy +\frac{h^2 y^2 }{2!}+\frac{h^3y^3 }{3!}+....)=e^{hx}e^{hy}=e^{h(x+y)}
$$
$$
e^{h(x+y)}=1+h(x+y) +\frac{h^2 (x+y)^2 }{2!}+\frac{h^3(x+y)^3 }{3!}+....
$$
If you order $h^n$ of $e^{hx}e^{hy}$  and equal to $h^n$ of $e^{h(x+y)}$ , it will give you binom expansion proof.
$$\frac{(x+y)^n }{n!}=\sum_{i=0}^n  \frac{x^i y^{n-i}}{i! (n-i)!} $$
$$(x+y)^n=\sum_{i=0}^n  \frac{n! x^i y^{n-i}}{i! (n-i)!} $$
$$(x+y)^n=\sum_{i=0}^n  {n \choose i} x^i y^{n-i} $$
Thus it is also true
$$\frac{d^{n}}{dx^{n}} f(x)g(x)=\sum_{i=0}^n {n \choose i} f^{(i)}(x)g^{(n-i)}(x)$$

A: This is something you typically do by induction (I have fixed a misprint in your notation), starng with
$$
\frac{d}{dx} \left( f(x) g(x) \right) = \frac{d}{dx}\left( f(x) \right)g(x) + f(x) \frac{d}{dx} \left( g(x) \right).
$$
Here is as it goes:
\begin{align}\frac{d^{n+1}}{dx^{n+1}} f(x)g(x)&= \frac{d}{dx} \sum_{i=0}^n {n \choose i} f^{(i)}(x)g^{(n-i)}(x) \\&= \sum_{i=0}^n {n \choose i} f^{(i+1)}(x)g^{(n-i)}(x) + \sum_{i=0}^n {n \choose i} f^{(i)}(x)g^{(n-i+1)}(x) \\&= \sum_{i=1}^{n+1} {n \choose i-1} f^{(i)}(x)g^{()n+1)-i)}(x) + \sum_{i=0}^n {n \choose i} f^{(i)}(x)g^{(n+1)-i)}(x)\\&= \sum_{i=0}^{n+1} \left( {n \choose i-1} + {n \choose i}\right) f^{(i)}(x)g^{(n+1)-i)}(x)\\&=\sum_{i=0}^{n+1} \left( {n+1 \choose 1}\right) f^{(i)}(x)g^{(n+1)-i)}(x).\end{align}


text:
Q: Function returning pointer called twice from main() I'm trying to make a function that generates random matrixes.
I'm not great at pointers but i really thought this should work.
Here's my function that I call twice from main, and that generates the same matrix in both cases...
int **generate_matrix(size_t m, size_t n){
int i1,i2;

int **ptr1=(int **)malloc(sizeof(int *)*m);

srand(time(0));
for(i1=0; i1<m; i1++){
    ptr1[i1] = (int*)malloc(sizeof(int)*n);
    for(i2=0; i2 < n; i2++){
        ptr1[i1][i2]=rand()%10;
    }
 }
return ptr1;
}

In main i call them in a normal way:
int **matrix1,**matrix2;
matrix1=generate_matrix(3,3);
matrix2=generate_matrix(3,3);
(...)
//prints and stuff
free(matrix1);
free(matrix2);

A: You are seeding your rand with srand(time(0));. If your calculations are fast enough (i.e. the next second is not reached) time will return the same value twice due to its granularity of 1s.
You could check your results by seeding with definitely different numbers.


text:
Q: Steam Install not finding internet connection on Ubuntu 20.04 I recently installed Steam on my new Ubuntu install, but whenever I try to run it, I get an error message that says "Fatal Error: Steam needs to be online to update. Please confirm your network connection and try again". The log file for this goes as follows:
[2021-02-21 13:27:18] Startup - updater built Apr  9 2019 22:48:20
ILocalize::AddFile() failed to load file "public/steambootstrapper_english.txt".
Looks like steam didn't shutdown cleanly, scheduling immediate update check
[2021-02-21 13:27:18] Checking for update on startup
[2021-02-21 13:27:18] Checking for available update...
[2021-02-21 13:27:18] Downloading manifest: client-download.steampowered.com/client/steam_client_ubuntu12
KeyValues Error: LoadFromBuffer: missing {   (current key: '<!DOCTYPE') in file manifest [offset: 14]

../tier1/KeyValues.cpp (2958) : Assertion Failed: Error while parsing text KeyValues for resource manifest
../tier1/KeyValues.cpp (2958) : Assertion Failed: Error while parsing text KeyValues for resource manifest
[2021-02-21 13:27:19] failed to load manifest from buffer.
[2021-02-21 13:27:19] Failed to load manifest
[2021-02-21 13:27:19] Error: Download failed: http error 200
[2021-02-21 13:27:19] Verifying installation...
[2021-02-21 13:27:19] Performing checksum verification of executable files
[2021-02-21 13:27:19] Unable to read and verify install manifest /home/evanr50/.steam/debian-installation/package/steam_client_ubuntu12.installed
[2021-02-21 13:27:19] Verification complete
[2021-02-21 13:27:19] Downloading Update...
[2021-02-21 13:27:19] Checking for available update...
[2021-02-21 13:27:19] Downloading manifest: client-download.steampowered.com/client/steam_client_ubuntu12
KeyValues Error: LoadFromBuffer: missing {   (current key: '<!DOCTYPE') in file manifest [offset: 14]

../tier1/KeyValues.cpp (2958) : Assertion Failed: Error while parsing text KeyValues for resource manifest
../tier1/KeyValues.cpp (2958) : Assertion Failed: Error while parsing text KeyValues for resource manifest
[2021-02-21 13:27:19] failed to load manifest from buffer.
[2021-02-21 13:27:19] Failed to load manifest
[2021-02-21 13:27:19] Error: Download failed: http error 200
[2021-02-21 13:27:19] Error: Steam needs to be online to update.     Please confirm your network connection and try again.
[2021-02-21 13:27:20] Shutdown
threadtools.cpp (3225) : Assertion Failed: Illegal termination of worker thread 'Thread(0x0x58633190/0x0xf4c07b'
threadtools.cpp (3225) : Assertion Failed: Illegal termination of worker thread 'Thread(0x0x58633190/0x0xf4c07b'
cat: '/home/evanr50/.steam/debian-installation/ubuntu12_32/steam-runtime.tar.xz.part*': No such file or directory
tar: This does not look like a tar archive
xz: (stdin): File format not recognized
tar: Child returned status 1
tar: Error is not recoverable: exiting now
find: '/home/evanr50/.steam/debian-installation/ubuntu12_32/steam-runtime': No such file or directory

Have any of you encountered this error before? And do you know how to resolve it? Thanks!

A: I had this same issue, and scoured these forums. Here's one you've probably seen before but with a special twist that worked for me:

*

*ping media.steampowered.com to get its IP

*then edit /etc/hosts --- add [The IP] client-download.steampowered.com

The important change for me was "client-download" rather than "media" which is what I'd seen previously and hadn't solved my problem.
Hope this helps


text:
Q: Why does a Stopped VLC inhibit Suspend? When VLC is running, it prevents the computer from suspending.
I want it to allow suspend IF VLC is stopped (the media finished playing).
How can this be done?

A: I was experiencing the same issue on a Ubuntu 12.04 PC.  I fixed it by taking @hbdgaf's suggestion.  Sucks to fall asleep watching something and wake up to find out that the screen saver never came on.  My solution written in C is what I use now.  It is a daemon that uses the low level DBus API to call methods on VLC to get the playback status and ask VLC to quit if it is stopped.  The bash and python scripts were not reliable when run as Ubuntu Startup Applications on my machine, which is what I wanted.  I shouldn't have to remember to restart a script every time I reboot, right?  They would work if run manually, however.  The C program doesn't have that issue.  Stick it in Startup Applications and forget about it.
I'm told that the DBus object name is different in Ubuntu 14.04 (but VLC has the same issue with screen saver).  org.mpris.MediaPlayer2.vlc.instanceXXXXX on 14.04.  org.mpris.MediaPlayer2.vlc-XXXXX on 12.04.  Thanks Sneetsher.
Bash solution using GDBus (was installed by default on my Ubuntu 12.04):
#VLC Watchdog Bash Script (vlcwd.sh)
while [ 1 -eq 1 ]
do
    if [ "$(pgrep vlc)" != "" ] #if VLC is running
        then #get the playback status and save to variable pbs
        pbs=$(bash -c 'gdbus call --session \
        --dest org.mpris.MediaPlayer2.vlc-$(pgrep vlc) \
        --object-path /org/mpris/MediaPlayer2 \
        --method org.freedesktop.DBus.Properties.Get \
        "org.mpris.MediaPlayer2.Player" \
        "PlaybackStatus"')
        if [ "$pbs" = "(<'Stopped'>,)" ] #if VLC is stopped
        then kill -9 $(pgrep vlc) #then kill it so it doesn't block my screen saver
        fi
    fi
    sleep 5
done

Python
#vlc_watchdog_daemon.py
import time
time.sleep(30)
import dbus
import os
import subprocess
from subprocess import Popen, PIPE
import daemon

def vlc_killer():
    bus = dbus.SessionBus()
    vlc_media_player_obj = bus.get_object("org.mpris.MediaPlayer2.vlc", "/org/mpris/MediaPlayer2")
    props_iface = dbus.Interface(vlc_media_player_obj, 'org.freedesktop.DBus.Properties')
    pb_stat = props_iface.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus')
    if pb_stat == 'Stopped':
        os.system("kill -9 $(pidof vlc)")

def vlc_is_running():
    ps = subprocess.Popen(['ps', '-e'], stdout = PIPE)
    out, err = ps.communicate()
    for line in out.splitlines():
        if 'vlc' in line:
            return True
    return False

def run():
    while True:
        if vlc_is_running():
            vlc_killer()
        else:
            time.sleep(5)

with daemon.DaemonContext():
    run()

A: You could set up a DBus query to get the play state of VLC and kill the process when it's done playing.  That should release its hold on suspend state.

A: After a fresh Ubuntu 12.04 install on a new HDD, this was solved for me by adding this ppa as described here.  I guess the bug is fixed in VLC Player 2.1.3.


text:
Q: How do I shutdown the computer automatically, after bot finishes running from terminal? I would like to know how can I schedule a shutdown in my computer after a bot finishes running totally.
I'm running a instagram bot from my own residential network. It is configured in a way that after all the tasks are done it simply stops running.
And I would like my computer to shutdown after the bot stops running in order to save energy. For example, when the bot is done something like 'Session Ended' shows up on terminal. I would like the computer to shutdown after this.
I've seen questions related to this, but they were according to a torrent or something, and the computer would shutdown after the download is completed.
In this case it's simply something that is running in the terminal and I want the computer to shutdown when that task is totally done.

A: Just append shutdown to the command with the && operator. && would make sure the system shuts down only if the command exits succesfully. So you need to run
your-command && shutdown

A: One way to do this: first, find the PID (process ID) of the running process, using pgrep [name of script, or program].
Then write another script:
#!/bin/bash
while ps -p $PID; do sleep 1; done ; shutdown -h

Replace $PID by the actual process ID.
What the script does is: look if the process with the ID still exists. If so, sleep a second and look again. If not, proceed to shut down the system
Save it (as myscript.sh, say), make it executable (chmod +x myscript.sh) and run it with root permission: sudo myscript.sh. You need root permission to do the shutdown command.


text:
Q: The function PL/SQL doesn't return any value I have the next PL/SQL code:
create or replace FUNCTION NUMBER_PLATES (name VARCHAR2)
RETURN INT
IS

    num_plates INT;

BEGIN

    SELECT count(*) INTO num_plates
    FROM plate p, detail_ped dt
    WHERE dt.plate = p.cod_plate AND p.name = name;

    RETURN (num_plates);

EXCEPTION
    WHEN NO_DATA_FOUND THEN
    DBMS_OUTPUT.PUT_LINE('ERROR');

END NUMBER_PLATES;

The next is execute the function into SQL Commands:
DECLARE a INT;
BEGIN
    a := NUMBER_PLATES('chicken');
    DBMS_OUTPUT.PUT_LINE(a);
END;

But the function returns me 0 when really is 3.
What am I doing wrong?
If I execute my SQL sentence returns 3:
    SELECT count(*)
    FROM plate p, detail_ped dt
    WHERE dt.plate = p.cod_plate AND p.name = 'chicken';

A: You should rename parameter name to avoid name collision:
create or replace FUNCTION NUMBER_PLATES (p_name VARCHAR2)
RETURN INT
IS
    num_plates INT;
BEGIN

    SELECT count(*) INTO num_plates
    FROM plate p
    JOIN detail_ped dt                 -- proper JOIN syntax
      ON dt.plate = p.cod_plate
    WHERE p.name = p_name;

    RETURN (num_plates);
-- exception is dead code, COUNT(*) will return 0 if no records found
-- EXCEPTION
--    WHEN NO_DATA_FOUND THEN
--    DBMS_OUTPUT.PUT_LINE('ERROR');
END NUMBER_PLATES;
/

db<>fiddle demo


text:
Q: Unable to import module and its functions in Python My directory structure is as follows:
-webapps
    --components
        --__init__.py
        --component1.py
        --component2.py
    --functions
        --__init__.py
        --function1.py
        --function2.py

function1.py and function2.py starts with
import sys
sys.path.append("../..")
from components import component1

Both __ init__.py are empty.
I can import component1 and its methods but I cannot import component2 and its methods. Can anyone point out what maybe wrong?

A: I've fixed the above issue. So I've a directory at
/Users/skakani/Library/Caches/PyCharm40/python_stubs/2068767379/

that had these folders 'components' and 'functions' but it doesn't have any 'webapps' folder. Once I deleted those folders, everything started working as expected. These folders again had similar structure but I've no idea why ONLY these folders were created. Also, I don't know how /Users/skakani/Library/Caches/PyCharm40/python_stubs/2068767379/ structure also got created.
If you're facing the similar issue, then you should go to /Users/skakani/Library/Caches/PyCharm40/python_stubs/ folder and see what all subfolders it has.