text:
Q: Android Switch button color not changing in 4.0.4 I have used Switch button, everything works fine when the app run it on 4.2 and above, but the text color not at all changed to white in 4.0.4 i have tried all possible solution
My Switch :
<Switch
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_below="@+id/facilityassetdescription"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="7dp"
        android:background="@drawable/offbuttonbg"
        android:textColor="@style/toggle_text"
        android:textOff="OFF"
        android:textOn="ON"
        android:thumb="@drawable/switchselector" />

My style file
<style name="toggle_text">
        <item name="android:textColor">@color/toggle</item>
    </style>

res/color/toggle_text.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:state_checked="true" android:color="#ffffff"/>
    <!-- Default State -->
    <item android:color="#ffffff"/>

</selector>

Kindly give any idea to get rid of this problem

A:
You can use Switch-Compat intend of Switch using support v7
  library.Try new concept
my.xml
<android.support.v7.widget.SwitchCompat
    android:id="@+id/sc_push"
    style="@style/switchStyle"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"
    android:theme="@style/switchStyle"
    app:theme="@style/switchStyle" />

style.xml
<style name="switchStyle">
    <item name="colorControlActivated">@color/red</item>
    <item name="android:colorForeground">@color/gray</item>
</style>

Best of luck

A: Use below style:
<style name="toggle_text" parent="@android:style/TextAppearance.Small">
    <item name="android:textColor">@color/toggle</item>
</style>

And, In xml file for switch mention android:switchTextAppearance attribute instead of using android:textColor:
<Switch
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_below="@+id/facilityassetdescription"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="7dp"
    android:background="@drawable/offbuttonbg"
    android:switchTextAppearance="@style/toggle_text"
    android:textOff="OFF"
    android:textOn="ON"
    android:thumb="@drawable/switchselector" />

A: Use support 7 SwitchCompat
and put <item name="colorSwitchThumbNormal">#E21D1D</item> in your style
and   <item name="colorSwitchThumbNormal">#E21D1D</item> in your theme
<android.support.v7.widget.SwitchCompat
                    android:id="@+id/switch_options"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_centerVertical="true"
                    android:padding="5dp"
                    app:showText="false" >
                </android.support.v7.widget.SwitchCompat>

Gud Luck!!

A: for anyone if the above answers did not work try this..
 <androidx.appcompat.widget.SwitchCompat
                android:id="@+id/switch_is_in_stock"
                style="@style/proximaNovaNormalColorBlack.size14"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:maxLines="1"
                android:padding="4dp"
                android:textColor="@color/switch_thumb_selector"/>

answer is on this xml line ->  android:textColor="@color/switch_thumb_selector"


text:
Q: RVM throws gems directory permission error during bundle install / rake assets:precompile On an EC2 ubuntu t1.micro instance, using RVM to manage ruby. When cucumber was added to the Gemfile and bundler was ran to install , it installs some dependent gems like gherkin.
Subsequently, when rails assets:precompile is ran , rvm throws the following permissions error. Any directions from here would be helpful
 $ rake assets:precompile RAILS_ENV=production --trace
/home/ubuntu/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/fileutils.rb:245:in `mkdir': Permission denied - /home/ubuntu/.rvm/gems/ruby-2.0.0-p353/extensions/x86_64-linux/2.0.0/gherkin-2.12.2 (Errno::EACCES)
    from /home/ubuntu/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/fileutils.rb:245:in `fu_mkdir'
    from /home/ubuntu/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/fileutils.rb:219:in `block (2 levels) in mkdir_p'
    from /home/ubuntu/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/fileutils.rb:217:in `reverse_each'
    from /home/ubuntu/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/fileutils.rb:217:in `block in mkdir_p'
    from /home/ubuntu/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/fileutils.rb:203:in `each'
    from /home/ubuntu/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/fileutils.rb:203:in `mkdir_p'
    from /home/ubuntu/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/ext/builder.rb:210:in `write_gem_make_out'
    from /home/ubuntu/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/ext/builder.rb:132:in `build_error'

ON subsequent trouble shooting by removing the gem and installing it natively also throws permission error.
$ gem install gherkin
Fetching: gherkin-2.12.2.gem (100%)
ERROR:  While executing gem ... (Errno::EACCES)
Permission denied - /home/ubuntu/.rvm/gems/ruby-2.0.0-p353/gems/gherkin-2.12.2/.gitattributes

A: This was resolved by running blunder as sudo user
$rvmsudo bundle install

Still not sure why the permission issue was coming for non super user.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Why does boost::numeric::interval::widen not behave the same as manually applying the same logic I have the following test code
#include <boost/numeric/interval.hpp>
#include <iostream>
#include <limits>

int main() {
    using Interval = boost::numeric::interval<double>;
    using dbl = std::numeric_limits< double >;

    std::cout  << std::setprecision(dbl::max_digits10) << std::endl ;

    for (int j = 0; j < 100; j++) {
        double lower = -j;
        double upper = j;
        double tol = 0.1;// 1e-12;

        Interval i{lower, upper};

        double lower_ = lower + tol;
        double upper_ = upper - tol;

        Interval i_ = widen(i, -tol);
        if (lower_ != i_.lower() || upper_ != i_.upper()) {
            std::cout
            << " error "
            << lower_ << "," << upper_
            << "     "
            << i_.lower() << "," << i_.upper()
            << std::endl;
        }
    }
}

and the output is
error -1.8999999999999999,1.8999999999999999     -1.9000000000000001,1.9000000000000001
 error -2.8999999999999999,2.8999999999999999     -2.9000000000000004,2.9000000000000004
 error -3.8999999999999999,3.8999999999999999     -3.9000000000000004,3.9000000000000004
 error -16.899999999999999,16.899999999999999     -16.900000000000002,16.900000000000002
 error -17.899999999999999,17.899999999999999     -17.900000000000002,17.900000000000002
 error -18.899999999999999,18.899999999999999     -18.900000000000002,18.900000000000002
 error -19.899999999999999,19.899999999999999     -19.900000000000002,19.900000000000002
 error -20.899999999999999,20.899999999999999     -20.900000000000002,20.900000000000002
 error -21.899999999999999,21.899999999999999     -21.900000000000002,21.900000000000002
 error -22.899999999999999,22.899999999999999     -22.900000000000002,22.900000000000002
 error -23.899999999999999,23.899999999999999     -23.900000000000002,23.900000000000002
 error -24.899999999999999,24.899999999999999     -24.900000000000002,24.900000000000002
 error -25.899999999999999,25.899999999999999     -25.900000000000002,25.900000000000002
 error -26.899999999999999,26.899999999999999     -26.900000000000002,26.900000000000002
 error -27.899999999999999,27.899999999999999     -27.900000000000002,27.900000000000002
 error -28.899999999999999,28.899999999999999     -28.900000000000002,28.900000000000002
 error -29.899999999999999,29.899999999999999     -29.900000000000002,29.900000000000002
 error -30.899999999999999,30.899999999999999     -30.900000000000002,30.900000000000002
 error -31.899999999999999,31.899999999999999     -31.900000000000002,31.900000000000002
 error -32.899999999999999,32.899999999999999     -32.900000000000006,32.900000000000006
 error -33.899999999999999,33.899999999999999     -33.900000000000006,33.900000000000006
 error -34.899999999999999,34.899999999999999     -34.900000000000006,34.900000000000006
 error -35.899999999999999,35.899999999999999     -35.900000000000006,35.900000000000006
 error -36.899999999999999,36.899999999999999     -36.900000000000006,36.900000000000006
 error -37.899999999999999,37.899999999999999     -37.900000000000006,37.900000000000006
 error -38.899999999999999,38.899999999999999     -38.900000000000006,38.900000000000006
 error -39.899999999999999,39.899999999999999     -39.900000000000006,39.900000000000006
 error -40.899999999999999,40.899999999999999     -40.900000000000006,40.900000000000006
 error -41.899999999999999,41.899999999999999     -41.900000000000006,41.900000000000006
 error -42.899999999999999,42.899999999999999     -42.900000000000006,42.900000000000006
 error -43.899999999999999,43.899999999999999     -43.900000000000006,43.900000000000006
 error -44.899999999999999,44.899999999999999     -44.900000000000006,44.900000000000006
 error -45.899999999999999,45.899999999999999     -45.900000000000006,45.900000000000006
 error -46.899999999999999,46.899999999999999     -46.900000000000006,46.900000000000006
 error -47.899999999999999,47.899999999999999     -47.900000000000006,47.900000000000006
 error -48.899999999999999,48.899999999999999     -48.900000000000006,48.900000000000006
 error -49.899999999999999,49.899999999999999     -49.900000000000006,49.900000000000006
 error -50.899999999999999,50.899999999999999     -50.900000000000006,50.900000000000006
 error -51.899999999999999,51.899999999999999     -51.900000000000006,51.900000000000006
 error -52.899999999999999,52.899999999999999     -52.900000000000006,52.900000000000006
 error -53.899999999999999,53.899999999999999     -53.900000000000006,53.900000000000006
 error -54.899999999999999,54.899999999999999     -54.900000000000006,54.900000000000006
 error -55.899999999999999,55.899999999999999     -55.900000000000006,55.900000000000006
 error -56.899999999999999,56.899999999999999     -56.900000000000006,56.900000000000006
 error -57.899999999999999,57.899999999999999     -57.900000000000006,57.900000000000006
 error -58.899999999999999,58.899999999999999     -58.900000000000006,58.900000000000006
 error -59.899999999999999,59.899999999999999     -59.900000000000006,59.900000000000006
 error -60.899999999999999,60.899999999999999     -60.900000000000006,60.900000000000006
 error -61.899999999999999,61.899999999999999     -61.900000000000006,61.900000000000006
 error -62.899999999999999,62.899999999999999     -62.900000000000006,62.900000000000006
 error -63.899999999999999,63.899999999999999     -63.900000000000006,63.900000000000006

Can somebody please explain why widen is not doing exactly the same as manually applying the widening to the limits.
See https://godbolt.org/z/fonMrGj74 for a live demo

A: Root Cause
The problem is floating point inexact representation. If we simplify the test program and use a decimal representation, there is no issue:
Live On Coliru
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <iostream>
#include <limits>

int main() {
    using T = boost::multiprecision::cpp_dec_float_50;
    using Interval = boost::numeric::interval<T>;
    using LIM      = std::numeric_limits<T>;

    std::cout << "Precision: " << LIM::max_digits10 << "\n"
              << std::setprecision(LIM::max_digits10);

    const T tol("0.1"); // 1e-12;

    for (int j = 0; j < 100; j++) {
        T lower = -j;
        T upper = j;

        Interval const manual(lower - tol, upper + tol);
        Interval       library{lower, upper};
        library = widen(library, tol);

        using namespace boost::numeric::interval_lib::compare::lexicographic;

        if (library != manual)
            std::cout << " error " << manual << " vs " << library << "\n";
    }
    std::cout << "Done\n";
}

Prints
Precision: 80
Done

Interval Policies & Rounding Modes
It looks like the naive manual implementation results in boundaries that are closest to the intended representation if the representation cannot be exact.
By contrast it looks like widen makes sure that if the result cannot be represented exactly, the widening is guaranteed to be at least the requested amount, never accidentally slightly less due to representation issues. This means that in these situations

*

*the widened lower bound may be lower than the manually calculated one

*the widened upper bound may be higher than the manually calculated one

The behaviour can be adjusted, because it comes from the rounding policy which supplies sub_down and add_up primitives.
I would suggest not to change it, though:

if you need precise computations with the float or double types, use the default rounded_math;

rounded_math<T> is already the default.
If you insist on having identical results as the manual method (even if they are inferior):
using T        = double; // boost::multiprecision::cpp_dec_float_50;

namespace I    = boost::numeric::interval_lib;
using Interval = I::change_rounding<boost::numeric::interval<T>,
                                    I::rounded_arith_exact<T>>::type;

Prints Live On Coliru
Precision: 17
Done

Further Caveats
There's a documentation warning:

Warning! Guaranteed interval arithmetic for native floating-point format is not supported on every combination of processor, operating system, and compiler.

There is a list of specific compiler quirks/flags you have to keep in mind.

A: TL;DR
Boost is complicated and somewhere it sets the mode of the floating-point unit (FPU) which changes rounding behavior.
The answer by sehe is spot on but in case you are interested in a more technical answer then read on.

The lines of interest in your example are
  using Interval = boost::numeric::interval<double>;
  Interval i{lower, upper};
  Interval i_ = widen(i, -tol);

Let's go down the rabbit hole and try to understand how boost implements these lines.

The main class is
// boost/numeric/interval/interval.hpp:l.37
template<class T, class Policies>
class interval;

The template argument Policies gets its default value defined at
// boost/numeric/interval/detail/interval_prototype.hpp:l.27
template<class T>
struct default_policies
{
  typedef policies<rounded_math<T>, checking_strict<T> > type;
};
// <truncated>
template<class T, class Policies = typename interval_lib::default_policies<T>::type >
class interval;

The general rounded_math template is defined at
// boost/numeric/interval/rounding.hpp:l.93
template<class T>
struct rounded_math: save_state_nothing<rounded_arith_exact<T> >
{};

but we actually need to look at the explicit template specialization
// boost/numeric/interval/hw_rounding.hpp:l.59
template<>
struct rounded_math<double>
  : save_state<rounded_arith_opp<double> >
{};

The save_state template is a derived class from its argument, i.e.
// boost/numeric/interval/rounding.hpp:l.75
template<class Rounding>
struct save_state: Rounding
{
  typename Rounding::rounding_mode mode;
  save_state() {
    this->get_rounding_mode(mode);
    this->init();
  }
  ~save_state() { this->set_rounding_mode(mode); }
  typedef detail::save_state_unprotected<Rounding> unprotected_rounding;
};

Note here that Rounding::init() will be called (as well as Rounding::set_rounding_mode(mode) at destruction)!
Then lets have a look at rounded_arith_opp
// boost/numeric/interval/rounded_arith.hpp:l.78
template<class T, class Rounding>
struct rounded_arith_opp: Rounding {
  void init() { this->upward(); }
  // <truncated>
# define BOOST_UP(EXPR) return this->force_rounding(EXPR)
# define BOOST_UP_NEG(EXPR) return -this->force_rounding(EXPR)
  T sub_down(const T& x, const T& y) { BOOST_UP_NEG(y - x); }
  T add_up  (const T& x, const T& y) { BOOST_UP(x + y); }
  // <truncated>
};

Its default Rounding argument is defined at
// boost/numeric/interval/rounding.hpp:l.46
template<class T, class Rounding = rounding_control<T> >
struct rounded_arith_opp;

The rounding control is defined at
// boost/numeric/interval/rounding.hpp:l.20
template<class T>
struct rounding_control
{
  // <truncated>
  static const T& force_rounding(const T& x) { return x; }
};

It also has explicit template specializations which vary by platforms, e.g.
// boost/numeric/interval/detail/c99_rounding_control.hpp:l.28
template<>
struct rounding_control<double>:
  detail::c99_rounding_control
{
  static double force_rounding(double const &r)
  { volatile double r_ = r; return r_; }
};

The c99_rounding_control class implements the change of rounding modes, i.e.
// boost/numeric/interval/detail/c99sub_rounding_control.hpp:l.23
struct c99_rounding_control
{
  static void set_rounding_mode(rounding_mode mode)  { fesetround(mode); }
  static void get_rounding_mode(rounding_mode &mode) { mode = fegetround(); }
  static void upward()      { set_rounding_mode(FE_UPWARD);     }
  // <truncated>
};

Now we understand the interval class and can have a look at the widen function
// boost/numeric/interval/detail/c99_rounding_control.hpp:l.82
template<class T, class Policies> inline
interval<T, Policies> widen(const interval<T, Policies>& x, const T& v)
{
  if (interval_lib::detail::test_input(x))
    return interval<T, Policies>::empty();
  typename Policies::rounding rnd;
  return interval<T, Policies>(rnd.sub_down(x.lower(), v),
                               rnd.add_up  (x.upper(), v), true);
}

It creates the rnd object which will call in the end c99_rounding_control::upward and together with rounded_arith_opp::{add_up,sub_down} one gets the observed results.

I will supply a simple example to show how the rounding takes place (godbolt-link)
#include <boost/numeric/interval.hpp>
#include <iomanip>
#include <iostream>
#include <limits>

using namespace std;

double force_rounding(const double& r) {
  volatile double r_ = r;
  return r_;
}

int main() {
  cout << setprecision(numeric_limits<double>::max_digits10) << endl;

  auto tol = 0.1;
  const auto lower = -2;
  const auto upper = 3;

  cout << "default rounding:\t" << lower + tol << ", " << upper - tol << '\n';

  {
    using Interval = boost::numeric::interval<double>;
    const auto i = widen(Interval{lower, upper}, -tol);
    cout << "widen:\t\t\t" << i.lower() << ", " << i.upper() << '\n';
  }

  {
    boost::numeric::interval_lib::detail::c99_rounding_control::upward();
    const auto lower_ = -force_rounding(-lower - tol);
    const auto upper_ = force_rounding(upper - tol);
    cout << "set rounding:\t\t" << lower_ << ", " << upper_ << '\n';
  }

  return 0;
}

Output:
default rounding:       -1.8999999999999999, 2.8999999999999999
widen:                  -1.9000000000000001, 2.9000000000000004
set rounding:           -1.9000000000000001, 2.9000000000000004

See also

*

*boost doc about interval's rounding: boost.org

*boost version: 1.79.0 (for line numbers)


text:
Q: if statement without the inner scope? Afaik, every pair of { } in the code creates a new scope. Even if it's used just for the sake of it without any if, for, function or other statement that demands it:
void myFun(void)
{
    int a;
    {
        int local;
    }
}

I started wondering - when the if statement is written without using the braces (with 1-line body) does it still create a new scope?
voidmyFun(int a)
{
    int b;
    if (a == 1)
        int tmp;   // is this one local to if?
    else
        int tmp2;   // or this one?
    b = 2;   // could I use tmp here?
}

A: N4140 [stmt.select]/1 reads:

The substatement in a selection-statement (each substatement, in the else form of the if statement) implicitly defines a block scope

So, the code
if (a == 1)
    int tmp;   // is this one local to if?
else
    int tmp2;   // or this one?

is equivalent to
if (a == 1)
{
    int tmp;   // yes, this one is local to if
}
else
{
    int tmp2;   // and this one as well
}

A: Yes, even if the if and for do not have {}, the variables declared in it are local to it.
So, if you try something like
if ( something )
    int a = 3;
std::cout << a;  // there is no other identifier called a in your program

it will not compile, because it is the same as
if ( something )
{
    int a = 3;
}
std::cout << a;

and you will get a variable not declared in this scope error.
So,
voidmyFun(int a)
{
    int b;
    if (a == 1)
        int tmp;   // is this one local to if?   Ans:-  Yes
    else
        int tmp2;   // or this one?          Ans:- It is local to else block
    b = 2;   // could I use tmp here?      Ans:-  No
}

So, the variable inside the else ( tmp2 ) is local to else and not to if.

A: In short - yes. It's a single line scope.
In other words, writing:
if (someCondition)
    int i = 7;

Is identical, scope-wise, to writing:
if (someCondition)
{
    int i = 7;
}

A: Yes! tmp are local to if and tmp2 is local to else. If you try using tmp or temp2 outside, you should get variable not defined error. It is because,
if(<condition>) <my-statment>
if(<condition>)
{
  <my-statment>
}

For compiler, both of them are equal.


text:
Q: How to use selectall-hashref for all columns I would like to implement this subroutine using selectall_hashref:
sub query {
    use SQL::Abstract;
    my $sql = SQL::Abstract->new;
    my ($table, $fields, $where) = @_;
    my ($stmt, @bind) = $sql->select($table, $fields, $where);
    my $sth = $dbh->prepare($stmt);
    $sth->execute(@bind);
    my @rows;
    while(my @row = $sth->fetchrow_array() ) {
        my %data;
        @data{ @{$sth->{NAME}} } = @row;
        push @rows, \%data;
    }
    return \@rows;
}

Unfortunately selectall_hashref requires a list of wanted columns. Is there a way to write something similar my first subroutine?
Obviously this doesn't work:
sub query {
   return $dbh->selectall_hashref(shift, q/*/);
}

The expected output could be an array of hashes or an hash of hashes:
{ '1' => { column1 => 'foo', column2 => 'bar' },
  '2' => { column1 => '...', column2 => '...' },
  ... }

or
[ { column1 => 'foo', column2 => 'bar' },
  { column1 => '...', column2 => '...' },
  ... ]

A: What you want is selectall_arrayref, not selectall_hashref. That does this exactly.
use DBI;
use Data::Printer;

my $dbh = DBI->connect('DBI:mysql:database=foo;', 'foo', 'bar');

my $foo = $dbh->selectall_arrayref(
  'select * from foo',
  { Slice => {} }
);

p $foo

__END__

\ [
    [0]   {
        id    1,
        baz   "",
    },
    [1]   {
        id    2,
        baz   "",

    },
]


text:
Q: Java get variable of old activity ionic cordova I have an issue, let me explain.
I created an ionic cordova plugin to handle payment via an ionic application.
The application procced like this:
ionic application => cordova activity => Payment activity
I use cordova.getActivity().startActivityForResult(intent, 100); to get variable results.
The first time I do the payment every thing works fine.
But the second time the payment activity received the good variable, the payment sdk do a login like the first one.
After the login a callback function named loginEnded is called but with the variable of the old activity.
The variable that I mean is private global variable.

public class  NameOfClass extends Activity implements UICallback, View.OnClickListener{

private String paymentRequestAmount = "0";

I put a log in both onStop and onDestroy activity function and the activity is well stop and destroy.
I also put singleInstance in android manifest for both cordova activity and Payment activity.
Please can you help me?


text:
Q: Find the following limit, $\lim_{x\to {\infty}} x\ln((x+1)/(x-1))$ Find the following limit,
$$\lim_{x\to {\infty}} x \ln\left(\frac{x+1}{x-1} \right)$$
I tried this way, that is  $$\lim_{x\to {\infty}} x\ln\left(\frac{1+\frac{1}{x}}{1-\frac{1}{x}} \right)=\infty \times \ln1= \infty \times 0=0$$
Noticed my logic is horribly wrong. Tested it out on a calculator and the limit should be near $0.8$.
My second try involves $$\lim_{x\to {\infty}} x\ln\left(\frac{x+1}{x-1} \right)=\lim_{x\to {\infty}} x(\ln(x+1)-\ln(x-1))$$
Where I still have no idea how to proceed.
Any hints? Thanks in advance! List them as solutions. I am looking for hints only.

A: Update: Upps, noticed too late, that only hints were wished. I can't make the solution after the first reformulation at the lhs (which were the hint then) invisible, don't know the latex-trick - sorry; somebode else may edit?
If I'm not too dense at the moment I think it is
 $$ \begin{eqnarray} \lim_{x \to \infty } \ln\left( \left( 1+{2\over x-1 }\right)^x\right)
 &=&\lim_{x \to \infty } &\ln\left(  \left( 1+{2\over x }\right)^{x+1}  \right) \\
 &=&\lim_{x \to \infty } &\ln \left(  \left( 1+{2\over x }\right)^x \left( 1+{2\over x }\right) \right) \\
 &=& &\ln \left(  e^2 \left( 1+ 0\right) \right) \\
 &=& 2
 \end{eqnarray}$$

A: Hint: Our expression is equal to
$$\ln\left(\left(\frac{x+1}{x-1}\right)^x\right).$$
Note that
$$\frac{x+1}{x-1}=1+\frac{2}{x-1}.$$
Another approach that will work is to rewrite the expression as
$$\frac{\ln\left(\frac{x+1}{x-1}\right)}{\frac{1}{x}},$$
use L'Hospital's Rule once, and then a little algebra.
Remark: Any solution that attempts to calculate "$\infty \cdot 0$" is automatically incorrect.

A: Rewrite it as $$x \ln \left(\dfrac{1+1/x}{1-1/x}\right) = x \left( \ln(1+1/x) - \ln(1-1/x)\right) = x \left( \left( \dfrac1x - \dfrac1{2x^2} + \dfrac1{3x^3} - \cdots\right) - \left( -\dfrac1x - \dfrac1{2x^2} - \dfrac1{3x^3} - \cdots\right)\right) = 2 + \dfrac2{3x^2} + \cdots$$

A: $0 \cdot \infty$ is not $0$ is an undeterminate form. Write it as fraction, move one of them to the denominator (careful it matters which one).
Another small hint for later: when you need to derivare the $\ln$ of a  fraction, what is the $\ln (\frac{a}{b})$?


text:
Q: shape file contour label values I tried making shape files of pressure from netcdf files using the following commands using gdal:
gdal_contour -a pressure -i 4 -off 0 pressure.nc pressure.shp
I noticed that when displaying the graph in mapserver I get label values such as 1010.00000000 whereas I want the labels to be whole numbers. How do I tweak this code to get whole numbers for pressure contour labels in map server?
I have noticed that in the netcdf file pressure.nc that the pressure values have three trailing decimal points after them so a pressure value in the netcdf file will be 1010.000 instead of 1010.  I also noticed that viewing the dbf file.  Do I need to fix the netcdf file to display intergers?  If so how do I do this?

A: This is a tweak you'd do in the MapServer layer itself by defining a CLASS element with a tostring expression (Mapserver >= 6.0) as the LABEL TEXT field, e.g.
LAYER
  NAME "pressure_contours"
  DATA pressure
  ...
  CLASS
    ...
    LABEL
      TEXT tostring([ELEV],"%.0f") + "m"
    END
    ...
  END
END

This should provide you with a label that looks like "1010m". You can always drop the '+ "m"' if you're not worried about units.


text:
Q: WPF Tab item sliding on mouse hover I want the tab item to be displayed by sliding effect as given in VS 2010, eg. when we point docked objects like toolbox, solution explorer, properties it is shown immediately. In that way i want my tabcontrol to display items by sliding effect. is it possible? Please Help...

A: you can achieve similar things by making use of AvalonDock, its opensource.


text:
Q: How to create component for static navigationOptions in React Navigation? I want create navigationOptions in all component is same with props like below but not work:
static navigationOptions = ({ navigation }) => {
    return (<NavigationOptions title: 'Sales Report'/>)
};

class NavigationOptions extends Component {
    render() {
        return ({ title: this.props.title })
    }
}


text:
Q: How do I load Large JSON Array files into Azure Data Lake Analytics (ADLA) I am stuck on an Azure Data Lake Analytics challenge, and am looking for assistance.
Issue
I need to load a file from Azure Data Lake that contains about 150m rows of JSON data, stored as an Array of JSON Objects.  The file is ~110G in size.  When I try to load the file, ADLA appears to hang, giving "0%" progress for hours and no status updates to the algebra.xml or other files.
Searching through online documentation, it appears that ADLA is limited to "a single vertex" for extracting files from storage.  This seems odd, but the job graph does consistently say 1 vertex for input nodes.  I tried a 32 AU job just in case and that did nothing.  I also let a 1 AU job run for about 3.5 hours, and that also did nothing (i.e. never progressed).
Question
Do you know how to enable ADLA to read UTF-8 JSON Array files of large size with millions of member objects?
If so, how?
And, it would be wonderful if the answer uses U-SQL without need for code-behinds.  I can do that, but the rest of my team can't and I'm evaluating ADLA "out-of-the-box" capabilities right now.
Many Thanks,
J
ps. Additional Details
I need to use the Array of JSON format due to JsonExtractor, as far as I know (plmk if that is not the case).
I need to use UTF-8 and JSON since my input data contains delimiters, largely due to human entry text fields that online folks "love" to play around with to give us data folks extra things to do :)
The below is the input file format, with special characters removed, since the file is UTF-8 format.
[{'key':'car'},{'key':'bar'},....,{'key':'yar'}]

By load, I mean use the EXTRACT statement with the open source assembly that provides JSONExtractor().  Please Note that the JsonExtractor currently expects an Array of JSON objects (at least it did the last time I looked at the source code).
The below is a code snippet to demonstrate the extract method.
#...The below assumes the assembly is loaded to a database named [SOMEDB]

USE DATABASE [SOMEDB];

REFERENCE ASSEMBLY [SOMEDB].[Newtonsoft.Json];
REFERENCE ASSEMBLY [SOMEDB].[Microsoft.Analytics.Samples.Formats];

USING Microsoft.Analytics.Samples.Formats.Json;

@input_dataset = EXTRACT
                   [ThereAreManyMoreColumnsThanThis]  decimal?
                  ,[HundredsOfColumns]                string
                  ,[YouGetTheIdea]                    DateTime
  FROM '/a/file/path/where/file/resides.json'
  USING new JsonExtractor()

#...Other stuff

A: Given the size of your JSON document, the example extractor is not designed for your use case. Here are some suggestions:

*

*Change the input format from an array to a sequence of row-delineated JSON documents. Assuming each row/document is less than 4MB, you can parallelize the extraction.

*Split your JSON array into smaller arrays in many files.

*Write your own custom extractor. Assuming you can identify each top element in your array, you could possibly even implement a parallel extractor (although that is going to be an advanced topic, since you need to handle the first and last parts of the file specially and make sure that you can handle the case where your end of element does not align with the extent boundary, similar to what the built-in Text Extractors do). In this case, make sure that you use the reader interface of your JSON parser instead of loading the document all into memory.


text:
Q: ¿Cómo descomprimir un .zip desde linea de comando windows? Estoy tratando de descomprimir un archivo .zip por consola pero siempre me sale el mensaje de "No files to extract", esto es lo que pongo en:
C:\Users\Administrador>"C:\Program Files (x86)\WinRAR\unrar.exe" x -r C:\Users\A
dministrador\Downloads\Formato IV 05.09.18-900.zip C:\Users\Administrador\Downlo
ads\

Que es lo que falta o esta mal?
Yo se que el archivo esta en la carpeta que especifico y que contiene un archivo.


text:
Q: New Instance Spring Scope I'm using Spring boot and I would like to know if there is a way to create a new instance each time I call a specific method.
I mean, I have a singleton object dedicated to creates new instances of an autowired class and I want that each time I call the function init and only when I call it a new instance of that object is created.
@Component
public class PlatformFactoryManager {

    @Autowired
    private JiraFactory jiraFactory;

    /**
     * Obtain new factory instance of specified platform.
     */
    public IPlatformFactory getNewInstance(UserAccount userAccount, AuthenticationService authService, PlatformBean platform) {
        switch (platform.getPlatformName()) {
            case "Jira Restaurantes":
                jiraFactory.init(authService.getBy(userAccount.getUserId(), Platforms.JIRA_RESTAURANTES), platform);
                return jiraFactory;
            case "Jira Yapiko":
                jiraFactory.init(authService.getBy(userAccount.getUserId(), Platforms.JIRA_YAPIKO), platform);
                return jiraFactory;
            case "Jira FDJGS":
                jiraFactory.init(authService.getBy(userAccount.getUserId(), Platforms.JIRA_FDJGS), platform);
                return jiraFactory;
            default:
                return null;
        }
    }

}

@Component
public class JiraFactory implements IPlatformFactory {

    @Autowired
    private JiraBroker jiraBroker;

    private String platformName;
    private String url;

    public void init(UserAuthentication credentials, PlatformBean platform) {
        this.platform = platform;
        this.credentials = credentials;
        jiraBroker.init(platform.getUrl());
    }

...

}

I want a new instance of JiraFactory each time I call init and to be the same object when I use other methods.
Is there any way to do it?

A: You can add @Scope(scopeName = ConfigurableBeanFactory.SCOPE_PROTOTYPE) annotation to component also

A: Take a look at the @Prototype scope.
You can refactor your JiraFactory component to look something like this:
public class JiraFactory implements IPlatformFactory {

    private final JiraBroker jiraBroker;

    private String platformName;
    private String url;

    public JiraFactory(final JiraBroker jiraBroker, UserAuthentication credentials, PlatformBean platform) {
        this.jiraBroker=jiraBroker;
        this.platform = platform;
        this.credentials = credentials;
        jiraBroker.init(platform.getUrl());
    }
}

And in a @Configuration class, you could create the JiraFactory bean as a prototype bean
@Configuration
class JiraConfig {
   @Bean
   @Scope("prototype")
   public IPlatformFactory iPlatformFactory(final JiraBroker jiraBroker, final JiraBroker jiraBroker, UserAccount userAccount, AuthenticationService authService, PlatformBean platform) {
        switch (platform.getPlatformName()) {
            case "Jira Restaurantes":
                return new JiraFactory (jiraBroker, authService.getBy(userAccount.getUserId(), Platforms.JIRA_RESTAURANTES), platform);
            case "Jira Yapiko":
                return new JiraFactory (jiraBroker, authService.getBy(userAccount.getUserId(), Platforms.JIRA_YAPIKO), platform);
            case "Jira FDJGS":
                return new JiraFactory (jiraBroker, authService.getBy(userAccount.getUserId(), Platforms.JIRA_FDJGS), platform);
            default:
                return null; // maybe better throw exception?
        }
    }
}

Prototype beans behave like "normal" (singleton) beans, you will be able to @Autowire other services in them. However, keep in mind that Spring does not manage the life-cycle of those beans, which means it's a possible memory leak.

In some respects, you can think of the Spring containers role when talking about a prototype-scoped bean as somewhat of a replacement for the Java 'new' operator. All life-cycle aspects past that point have to be handled by the client.

Meaning, you will have to keep track of those beans somehow, and make sure that at some point, no reference to them will exist in order for them to be garbage collected.

Side note, it is usually recommended to avoid init() methods. In most cases, one can replace them with constructors. If there's no way around using them, you could try using the @PostConstruct instead of manually calling them.
@Component
class MyComponent {
   @PostConstruct
   public void init(){ // will be called by Spring once the bean/component is created
      System.out.println("Component created!");
   }
}


text:
Q: Office 2013 apps: How to get the name of the file using Office 2013 Javascript API I am creating a Office Task Pane app and running it using MS Word 2013. As i run the app it opened a task pane in Word with a document named "Document1.docx". How can i get this file name "Document1.docx" using Office 2013 Javascript API? If this is not achieve by Office Javascript API, is there any other technique to achieve this with in a Office 2013 task pane app for word?

A: I found solution of this problem here.
http://social.msdn.microsoft.com/Forums/en-US/appsforoffice/thread/2cf80790-7088-4568-813b-7b645a8ebd2e?prof=required
You can use the Javascript API and get the Office.context.document.url property, but this comes with caveats - see the link for more details.


text:
Q: C++ Adding elements to an Array of Pointers to a Struct Issue So I have a Struct called Person:
struct Person {
    char *name;
    int initialMoney;
    int currentMoney;
};

I have made it so my main() reads a file called gift1.in containing:
5
dave
laura
owen
vick
amr

And a little bit more. What is important are these lines.
The first line represents how many people there are, then the rest are the people's names.
As you may have guessed, these names will become the char *name in the structs for Person.
Now for the problem:
int main ()
{
    struct Person *peopleArray[MAXFRIENDSNUM];
    int index = 0;
    int maxIndex = 0;

    std::ofstream fout ("gift1.out");
    std::ifstream fin ("gift1.in");

    // Obtain max number of names!
    fin >> maxIndex;

    // Create a person for every name...
    for (index = 0; maxIndex != index; index++) {
            char newName[MAXNAMECHAR+1];
            fin >> newName;
            std::cout << "Inserting " << index << ": " <<newName << std::endl;
            makePerson(peopleArray, index, newName);
    }

    std::cout << "Checking if the proper person's name is there: \n";
    // Check to see if the person's name is being read correctly
    for (index = 0; maxIndex != index; index++) {
            std::cout << "Reading " << index <<  ":" << peopleArray[index]->name << std::endl;
    }

    std::cout << "Changing a single element of an array: \n";
    peopleArray[1]->name = (char *)"John";

    for (index = 0; maxIndex != index; index++) {
            std::cout << "Reading " << index <<  ":" << peopleArray[index]->name << std::endl;
    }

    return 0;
 }

void makePerson(Person *peopleArray[], int insertIndex, char *name)
{
    peopleArray[insertIndex] = (Person *)malloc(sizeof(peopleArray[insertIndex]));
    peopleArray[insertIndex]->name = name;
    peopleArray[insertIndex]->initialMoney = 0;
    peopleArray[insertIndex]->currentMoney = 0;
    peopleArray[insertIndex] = peopleArray[insertIndex];
}

From my understanding, each element in peopleArray[] has a pointer to a Struct Person. However, since I create the Struct in another scope, I have to allocate it (hence the use of malloc()).
So my understanding is that I should get:
Inserting 0: dave
Inserting 1: laura
Inserting 2: owen
Inserting 3: vick
Inserting 4: amr
Checking if the proper person's name is there:
Reading 0:dave
Reading 1:laura
Reading 2:owen
Reading 3:vick
Reading 4:amr
Changing a single element of an array:
Reading 0:dave
Reading 1:John
Reading 2:owen
Reading 3:vick
Reading 4:amr

However, from running the actual C++ script I get:
Inserting 0: dave
Inserting 1: laura
Inserting 2: owen
Inserting 3: vick
Inserting 4: amr
Checking if the proper person's name is there:
Reading 0:amr
Reading 1:amr
Reading 2:amr
Reading 3:amr
Reading 4:amr
Changing a single element of an array:
Reading 0:amr
Reading 1:John
Reading 2:amr
Reading 3:amr
Reading 4:amr

Which makes it seem like I am getting complete duplicates from using malloc() rather than allocating new memory.
So my question is:
Why does this happen? What is going on inside memory to cause this
What can I do to fix this? I know for sure an alternative is to just make an array of structs, but I'm curious to see what a solution could be to keep using an array of pointers to structs.
Disclaimer: Sorry if my C++ does not look much like C++! I've been using more C and I'm slowly making the transition, so my C++ looks a lot like C, (use of char *name instead of string).
Additonal hardware information (if that is the issue): I am using clang++ from macports on a Mac OS X Mavericks (newest version)

A: You assign Person.name the same pointer over and over again which is why they all just "take" the changes you do on the original adress.
To alter this behaviour you have to create a new instance for each entry (by using strcpy for example)
after that you get your expected behaviour.

Also here you go with some saver way of doing it by using std::string and std::vector:
http://pastebin.com/Ftt5FKeX

A: As @Ben stated, bite the bullet and use only C++ conventions.  Your problem is here with your delcaration of newName.  you are declaring it on the stack, locally in scope to the for loop, and it most likely has the same address every time.  So the last entry in your file you read, "amr" is then assigned to that address.  You then copy that pointer arount in makePerson, and assign to the char *name element in that struct.
for (index = 0; maxIndex != index; index++) {
         char newName[MAXNAMECHAR+1];
        makePerson(peopleArray, index, newName);
}

You can fix that (badly) by allocating the memory for the name:
char * newName = new char[MAXNAMECHAR+1];

But then you also have to clean-up after yourself and delete the memory.  Start using "real" C++, and avoid all this malloc garbage.

A: // Create a person for every name...
for (index = 0; maxIndex != index; index++) {
        char newName[MAXNAMECHAR+1];

Here you allocate memory on the stack to store a name. You haven't told the compiler that there needs to be one of these per loop, so either you will allocate/free the stack space each iteration or your compiler will treat it as this:
char newName[MAXNAMECHAR+1];
for (index ... ) {
    ...

Each name you read goes into this variable, which is very likely at the same location in memory/the stack. You pass the address of this memory to your create function:
       makePerson(peopleArray, index, newName);

which then stores that address in your Person objects. So they all point to the same address - a temporary location on the stack.
You should consider either making the entry in Person a std::string or making name copy the string it is being passed.
struct Person {
    std::string name;
    int initialMoney;
    int currentMoney;

    Person(const char* name_) : initialMoney(0), currentMoney(0) {}
};

and makePerson becomes
void makePerson(Person *peopleArray[], int insertIndex, char *name)
{
    peopleArray[insertIndex] = new Person(name);
}

Remember, though, you will need to delete these objects (just as you should have been freeing them before) when you are done with them, on consider std::unique_ptr http://en.cppreference.com/w/cpp/memory/unique_ptr
Here is a C++ implementation:
#include <string>
#include <vector>
#include <iostream>

using std::cout;
using std::cin;
using std::vector;
using std::string;

struct Person {
    string m_name;
    int    m_initialMoney;
    int    m_currentMoney;

    Person(const std::string& name_, int money_=0)
        : m_name(name_)
        , m_initialMoney(0), m_currentMoney(0)
        {}
};

int main ()
{
    vector<Person> people;

    // Obtain max number of names!
    size_t maxIndex = 0;
    cin >> maxIndex;
    if (maxIndex <= 0) {
        cout << "Nothing to do.\n";
        return 1;
    }

    // Create a person for every name...
    for (size_t index = 0; maxIndex != index; index++) {
            std::string newName;
            cin >> newName;
            cout << "Inserting " << people.size() << ": " << newName << std::endl;
            people.emplace_back(newName);
    }

    // Check to see if the person's name is being read correctly
    cout << "Checking if the proper person's name is there: \n";
    for (auto& person : people) {
            cout << "Reading " << person.m_name << std::endl;
    }

    cout << "Changing a single element of an array: \n";
    people[1].m_name = "John";

    for (auto& person : people) {
            cout << "Reading " << person.m_name << std::endl;
    }

    return 0;
}

see http://ideone.com/jjfPda


text:
Q: What does the idiom "looking through a prism" mean? Just a few hours ago, I came across the idiom "through the prism of sth/sb" and looked up said phrase on the internet. I only managed to find one entry entitled "Through The Prism of The Prism?"on englishforums.com.
User "Blue Jay" responded to the OP's question with this:

*

*If you look at something through a prism, it will change how you see
it. Here it is used figuratively, to indicate that her view or
opinion of the past was affected by the circumstances, ideas,
opinions etc. of the present. She viewed the past from the point of
view of someone in the present.

Before I continue on, I should provide the original poster's sentence:

*

*"Could you please explain the meaning of the phrase in bold? [original sentence] She
looked back at the past through the prism of the present. Thank you"

I still fail to understand this idiom's meaning. Would someone please elaborate on this idiomatic phrase?
Additionally, would someone explain what contexts it would be appropriate to use this phrase and which contexts is it not appropriate to use this phrase?

A: In the phrase "Looking through a prism", the word prism here is being used differently from the prism we use normally (being used metaphorically). Here the prism is being referred to the idea of distortion and different perspectives (as a light would do as it hits a prism), so the idiom is talking about looking at something in a completely different perspective.
This can also mean that someone has been affected by some other influence and by that the person looks at something differently from before. This idiom can also be rephrased as "seen through a prism", "looked through a prism"... etc.
An example:

"Issues are seen through the prism of religion and region."

However, we won't use this idiom when we are referring to something that wasn't changed by perspective- after all, the "looking" part can be changed by tense and the meaning is still the same, however make sure that the idiom comes after the main thing that we are talking about and precedes before what we see through.

Issues are seen through the prism of religion and region.

A: According to Collins Dictionary:

If you see something through a prism of something such as time or memory, your idea of it is affected by that thing.
Through the smoky prism of time, I could just barely make out my father as a young man.

And this example from Longman Dictionary:

He is a decent, intelligent human being who happens to see the world through a very narrow prism.

And this from Cambridge Dictionary:

Seen under this prism, the terrain vague can be thought of as an alternative public space.

A: Historically, a prism was used to break light up into a spectrum to perform spectral analysis. By breaking up the light emitted or reflected from an object into a spectrum, you can see precisely what the object is made from.

This is a spectrum of the light from our sun. The black lines are called absorption lines. These are wavelengths that are absorbed by the elements in the sun's atmosphere. Since these wavelengths can be precisely mapped to specific elements, you can use a spectral analysis to determine what elements are present in the light.
These days we use machines called spectrometers to measure spectra more precisely, and there is no need for a human to look directly through a prism; nonetheless, the idiom remains.
A prism is a tool used to break down a problem and look at it in detail. Idiomatically, a prism is a particular piece of information or perspective that one uses to understand something larger.


text:
Q: Как осуществить динамическое добавление ImageView в RecyclerView? Есть RecyclerView, в который добавляются элементы (cardView).
CardView может содержать в себе неопределенное количество изображений, поэтому ImageView создается динамически и происходит это в методе addData(), который в свою очередь вызывается из переопределенного метода onBindViewHolder().
Код метода onBindViewHolder():
//--Метод onBind--//
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
    if (holder instanceof ViewHolderPost) {
        holder.itemView.setTag(mData.get(position));
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
            }
        });
        addData((ViewHolderPost) holder, mData.get(position));
    } else {
        ((ProgressViewHolder) holder).progressBar.setIndeterminate(true);
    }
}

Часть метода addData():
 //--Добавляет изображения--//
private void addData(PostAdapter.ViewHolderPost holder, Posts post, int countImage) {
    ImageView postImage;
    switch (countImage) {
        case 1:
            postImage = new ImageView(activity);
            postImage.setScaleType(ImageView.ScaleType.CENTER_CROP);
            postImage.setAdjustViewBounds(true);
            Picasso.with(activity.getApplicationContext())
                    .load(post.getURLImage(MainActivity.SCREEN_WIDTH, 0))
                    .into(postImage);
            holder.mPostImageLayout.addView(postImage);
    }
}

Количество элементов в RecyclerView = 10 (для примера).
При скроллинге списка, начиная с шестого элемента, метод onCreateViewHolder() перестает вызываться, вызывается только onBindViewHolder(), тем самым, изображение, которое загрузилось в шестом элементе добавляется к нулевому, изображение седьмого элемента добавляется к первому (контейнером для ImageView является LinearLayout), и так далее.
В конечном итоге у каждого элемента появляется невообразимое количество изображений (постоянное создание ImageView).
Каким образом можно решить данную ситуацию?


text:
Q: DialogFragment with Navigation Component (Orientation Issue)
Navigation Component 2.3.0-aplha06

I am having a dialog fragment in the navigation graph along with few fragment.

Scenario - Happy

Fragment A opens and on click of button navigate to DialogFragment
Dialog Fragment simulates some progress and after it completes it performs
findNavController().popBackStack()

Then Fragment A perform some action and navigate to Fragment B.

Scenario - Sad

Fragment A opens and on click of button navigate to DialogFragment
Dialog Fragment simulates some progress
User change orientation of the device from portrait to landscape
findNavController().popBackStack()

Then Fragment A perform some action and navigate to Fragment B.
2020-05-13 10:53:32.436 15140-15140/com.demo.example E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.demo.example, PID: 15140
    java.lang.IllegalStateException: Fragment ProgressDialogFragment{1765f4f} (7df114f6-88cf-4d24-9b07-54c0ff9edcb0)} not associated with a fragment manager.
        at androidx.fragment.app.Fragment.getParentFragmentManager(Fragment.java:945)
        at androidx.navigation.fragment.NavHostFragment.findNavController(NavHostFragment.java:107)
        at androidx.navigation.fragment.FragmentKt.findNavController(Fragment.kt:29)
        at com.demo.example.ProgressDialogFragment$PaymentTimer.onFinish(ProgressDialogFragment.kt:61)
        at android.os.CountDownTimer$1.handleMessage(CountDownTimer.java:127)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7682)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

Code of ProgressDialogFragment
class ProgressDialogFragment : DialogFragment() {

private lateinit var txtProgressBar: DxpTextView

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
    return super.onCreateDialog(savedInstanceState).apply {
        window?.requestFeature(Window.FEATURE_NO_TITLE)
        window?.setLayout(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
        )
        window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        isCancelable = false
    }
}

override fun onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
): View? {
    return inflater.inflate(R.layout.fragment_progress_dialog, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    txtProgressBar = view.findViewById(R.id.txt_progress_text)

    val timer = PaymentTimer(5000, 2500)
    timer.start()
}

inner class PaymentTimer(
    millisInFuture: Long,
    countDownInterval: Long
) : CountDownTimer(millisInFuture, countDownInterval) {

    override fun onFinish() {
        findNavController().previousBackStackEntry?.savedStateHandle?.set("progress", true)
        findNavController().popBackStack()
    }

    override fun onTick(millisUntilFinished: Long) {
        if (millisUntilFinished < 2500 && isAdded) {
            txtProgressBar.text = getString(R.string.progress_msg_2)
        }

    }
}}


text:
Q: Rails Active Record Query Finding Item Out Of Scope I'm not sure I fully understand active record querying, but I am running into a very peculiar issue where my active record conditionals seem to be pulling in items outside my current scope. Here is an example of what I am seeing:
In Rails 2.3 console
>> Transaction.single_card.find(:all).map(&:id)
=> [0, 1, 2, 3, 4, 5]
>> Transaction.single_card.find(:all, :conditions => "cards.number = '1234'").map(&:id)
=> [9]

<this line added because the [9] was being cut in half by scroll bar>

How is this happening? Why, when I add extra conditions to my query, do I pull a record that should not be there at all? From my understanding, the extra conditional should check Transactions 0..5 (the transactions with a single card) and see if the card number is 1234. But the query pulls Transaction 9, which has 2 cards associated with it, which is why it did not appear in the initial query. What is going on?
Extra note: The single_card named scope :includes the cards reference


text:
Q: Date field validation I have a custom field "Requested Delivery Date" and the requirement is

*

*When user enters date it should be more than 10 days from Today

*This rule will only apply to 2 record types which are Demonstration and Evaluation.

A: Here is sudo code for your validation rule:
AND(
     Requested_Delivery_Date__c <  TODAY() + 10 ,
     OR(
          RecordTypeID = 'ID OF Demonstration',
          RecordTypeID = 'ID OF Demonstration',
     }
   )

If this formula /rule return true then show error message that Requested Delivery Date must be latter than today + 10 when record type is Demonstration OR Evaluation.


text:
Q: 3.3.0 NoClassDefFoundError: Could not initialize class kafka.server.KafkaRaftServer$ I'm trying to upgrade from 3.2.1 to 3.3.0, I have this stack error:
java.lang.NoClassDefFoundError: Could not initialize class kafka.server.KafkaRaftServer$
    at kafka.log.LogManager.$anonfun$loadLogs$11(LogManager.scala:359)
    at kafka.log.LogManager.$anonfun$loadLogs$11$adapted(LogManager.scala:358)
    at scala.collection.ArrayOps$.filter$extension(ArrayOps.scala:559)
    at kafka.log.LogManager.$anonfun$loadLogs$2(LogManager.scala:358)
    at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:563)
    at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:561)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:926)
    at kafka.log.LogManager.loadLogs(LogManager.scala:320)
    at kafka.log.LogManager.startupWithConfigOverrides(LogManager.scala:458)
    at kafka.log.LogManager.startup(LogManager.scala:418)
    at kafka.server.KafkaServer.startup(KafkaServer.scala:269)
    at com.consol.citrus.kafka.embedded.EmbeddedKafkaServer.start(EmbeddedKafkaServer.java:128)
    at com.github.cameltooling.lsp.internal.completion.KafkaTopicCompletionTest.testNoConnectionUrlSpecified(KafkaTopicCompletionTest.java:83)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:217)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:213)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:138)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:95)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:91)
    at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:60)
    at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:98)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)

Do I need to configure something?
i'm wondering if the 3.3.0 is usable given that the tag and artifact are pushed on Mabven Central but there is no entry on the website. Should I continue to try upgrade or better to wait for another version?
We can see the error on https://github.com/camel-tooling/camel-language-server/pull/808 https://github.com/camel-tooling/camel-language-server/runs/8184313559?check_suite_focus=true#step:5:1760

A: The problem was that the Kafka Client I was using was 2.8.0. Upgrading to 3.2.1 did the trick.


text:
Q: Java, инструменты для парсинга текстового файла Задача в следующем:
Требуется из текстового файла большого объема удалять персональные данные (например IP адреса), подскажите библиотеку/метод для парса .txt файлов большого объема.
Аналогично jsoup, только для .txt )

A: *

*StringTokenizer

*Scanner

*Pattern

*String#split(...)

Нашел вот такие варианты


text:
Q: How to work locally on a copy of my wordpress? I would like to redesign my wordpress site. I thought I do that first locally to get a feeling for it. So I compressed my live wordpress directory and transfered it locally. And took a backup of the database and transfered it locally as well.
I restored from both files the exact copy of my live wordpress on my lcoal machine. Going to 127.0.0.1 works fine. But all the links still point to my BlogSite.com rather than 127.0.0.1.
Is there any quick "fix" for that? Or any other strategy how I could achieve working locally on my website?
Thanks,

A: You may first need to modify the wp-config.php file for using the local database.
Then use the Search and Replace plugin to replace all your live site links with the localhost links. Example: If your live site url is: http://mysite.com/, replace it with http://localhost/mysite/. This will also replace the urls for pages and posts like: http://mysite.com/post with http://localhost/mysite/post.
Note: You'll still need to manually update any links (and image urls) in the widgets, because S and R doesn't replace them.

A: You may also want to add a line in your /etc/hosts file, like this:
1.2.3.4 www.myblog.example.org

The first line should be the IP of tour TEST machine, the second one is your blog's DNS name.
After adding this line in /etc/hosts "everyone" in your test machine will "know" that www.myblog.example.org is at 1.2.3.4.
You need to change nothing in the database or wordpress settings.
And you can comment/uncomment this line at any time.

A: You should replace all occurences of live website for the local path in your DB dump and in template files (if there are any hardcored urls, i hope not ;) ). Moving WP from server to server goes quite fine, I always copy everything from FTP, then do the database dump (*.sql file for example, you can use for instance phpmyadmin or whatever you prefer), replace all urls for the local ones, import this file in your local DB and change wp-config.php to use correct database settings. So having a "snapshot" of live page can be done in a few minutes.


text:
Q: Could not build Objective-C module '_SwiftUIKitOverlayShims' In the Xcode8.3.3 project will not be a problem, but after upgrading to xcode9, the compiler has a problem!
Showing Recent Issues
CompileSwift normal arm64
/Users/leekexi/Documents/macsrc/mtom/modules/ScrollerRefresh/RefreshConst.swift
    cd /Users/leekexi/Documents/macsrc/mtom
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -filelist /var/folders/cz/jq8bwvds0j52yy2j0p7_2kf40000gn/T/sources-86be14 -primary-file /Users/leekexi/Documents/macsrc/mtom/modules/ScrollerRefresh/RefreshConst.swift -target arm64-apple-ios8.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk -I /Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Products/Debug-iphoneos -F /Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Products/Debug-iphoneos -F /Users/leekexi/Documents/macsrc/mtom/Pods/RongCloudIM/RongCloudIM -F /Users/leekexi/Documents/macsrc/mtom/modules -F /Users/leekexi/Documents/macsrc/mtom/modules/Live/IJKMediaPlayer -F /Users/leekexi/Documents/macsrc/mtom -enable-testing -g -module-cache-path /Users/leekexi/Library/Developer/Xcode/DerivedData/ModuleCache -swift-version 4 -enforce-exclusivity=checked -D DEBUG -serialize-debugging-options -Xcc -I/Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Intermediates.noindex/mtom.build/Debug-iphoneos/mtom.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Intermediates.noindex/mtom.build/Debug-iphoneos/mtom.build/mtom-generated-files.hmap -Xcc -I/Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Intermediates.noindex/mtom.build/Debug-iphoneos/mtom.build/mtom-own-target-headers.hmap -Xcc -I/Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Intermediates.noindex/mtom.build/Debug-iphoneos/mtom.build/mtom-all-target-headers.hmap -Xcc -iquote -Xcc /Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Intermediates.noindex/mtom.build/Debug-iphoneos/mtom.build/mtom-project-headers.hmap -Xcc -I/Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Products/Debug-iphoneos/include -Xcc -I/Users/leekexi/Documents/macsrc/mtom/Pods/Headers/Public -Xcc -I/Users/leekexi/Documents/macsrc/mtom/Pods/Headers/Public/RongCloudIM -Xcc -I/Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Intermediates.noindex/mtom.build/Debug-iphoneos/mtom.build/DerivedSources/arm64 -Xcc -I/Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Intermediates.noindex/mtom.build/Debug-iphoneos/mtom.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -DCOCOAPODS=1 -Xcc -working-directory/Users/leekexi/Documents/macsrc/mtom -emit-module-doc-path /Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Intermediates.noindex/mtom.build/Debug-iphoneos/mtom.build/Objects-normal/arm64/RefreshConst~partial.swiftdoc -serialize-diagnostics-path /Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Intermediates.noindex/mtom.build/Debug-iphoneos/mtom.build/Objects-normal/arm64/RefreshConst.dia -import-objc-header /Users/leekexi/Documents/macsrc/mtom/mtom-bridging.h -pch-output-dir /Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Intermediates.noindex/PrecompiledHeaders -pch-disable-validation -Onone -module-name mtom -emit-module-path /Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Intermediates.noindex/mtom.build/Debug-iphoneos/mtom.build/Objects-normal/arm64/RefreshConst~partial.swiftmodule -emit-dependencies-path /Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Intermediates.noindex/mtom.build/Debug-iphoneos/mtom.build/Objects-normal/arm64/RefreshConst.d -emit-reference-dependencies-path /Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Intermediates.noindex/mtom.build/Debug-iphoneos/mtom.build/Objects-normal/arm64/RefreshConst.swiftdeps -o /Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Build/Intermediates.noindex/mtom.build/Debug-iphoneos/mtom.build/Objects-normal/arm64/RefreshConst.o -index-store-path /Users/leekexi/Library/Developer/Xcode/DerivedData/mtom-aecafhlecijtaebzvztitxjcabvr/Index/DataStore -index-system-modules

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "UIKitOverlayShims.h"
        ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/shims/UIKitOverlayShims.h:24:11: error: use of undeclared identifier 'UIFocusSystem'
  return [UIFocusSystem environment:environment containsEnvironment:otherEnvironment];
          ^
<unknown>:0: error: could not build Objective-C module '_SwiftUIKitOverlayShims'

A: For me on Xcode 9.0.1 the solution has been the typical engineer solution:

*

*Clean the project

*Erase DerivedData

*Reboot computer

A: This fix from the mentioned forum thread fixed it for me: Just delete the offending code!

*

*Open the file the error points to (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/shims/UIKitOverlayShims.h for most people).

*Delete the method _swift_UIKit_UIFocusEnvironmentContainsEnvironment, plus the surrounding compiler directives.

I rebuilt after that just to be sure, but that might not be necessary.
This is definitely a workaround; hopefully this will be fixed in a future version of Xcode.


text:
Q: :after element's content not taking background:inherit; in IE8 I have a link in html and i am using :after pseudo element to insert some content and style that content.
It is working fine in FF & IE9. but not working in IE8.
when i click on "Click" link, container div's background color changes.
but content inserted by :after not takes that color as background in IE8.
<!DOCTYPE html>

     linkTextHere

  click

Any expert advice would be appreciated.
thanks in advance..

A: Take a look at the browser support of inherit for IE8
http://www.w3schools.com/cssref/pr_background-color.asp

Note: The value "inherit" is not supported in IE7 and earlier. IE8
  requires a !DOCTYPE. IE9 supports "inherit".

So they seem to have a general problem with it considering the Doctype. Maybe try a different one than html5 just to make sure?


text:
Q: FancyBox gallery launched in iframe from main site affects only iframe? I got a website with a basic structure of six main sites, each of those having a number of submenues.
These subsites are loaded into the current main page via an iframe and javascript.
I have a lot of pictures on these submenu sites and I thought I'd give the Fancybox a try.
I loaded the css and javascript file into the submenu site, defined the picture as stated:

and included the launch script on the site also:

It works fine, but it only affects the iframe, I would like my gallery to affect the entire parent window, so that the entire windows fades out, not only the small iframe compartement.
I have tried to call the function like this:
$(parent.document.ready(function() {

and many other similar forms, but unfortunately, none of those did the trick.
I'd really appreciate any tips on this.
Best regards,
Alex

A: Yes. FancyBox is available inside document that is loaded into IFRAME. The same occurs to frames. So you need to initialize it everywhere.


text:
Q: How to load ace/mode/javascript and theme js files for Ace Editor in IIS Server? This is my code

var app = angular.module('editorApp', ['ui.ace']);
app.controller('appCtrl', function($scope){
    window.define = ace.define;
    $scope.aceOptions = {
          workerPath: '../../Scripts/app/vendor/',
          useWrapMode: true,
          showGutter: true,
          theme: 'chrome',
          firstLineNumber: 1,
          onLoad: function (_editor) {
              $scope.onLoadSaveCode = "";
              var _session = _editor.getSession();
              _session.setMode('ace/mode/javascript');
              var _renderer = _editor.renderer;

              _session.on('changeAnnotation', function () {
                  $scope.annotations = [];
                  $scope.annotations = _editor.getSession().getAnnotations();
              }),
              _editor.$blockScrolling = Infinity;
              // Editor Events
              var shouldRevert = false;
              _session.on("change", function (e) {
                  var currentValue = _editor.getSession().getValue();
                  $scope.clientScriptFunction.json_meta_data = currentValue;
              });
          },
          require: ['ace/ext/language_tools'],
          advanced: {
              enableSnippets: false,
              enableBasicAutocompletion: true,
              enableLiveAutocompletion: true
          }
      };
});
<div class="e1" ui-ace="aceOptions">

  </div>

BundleConfig.cs :-
bundles.Add(new ScriptBundle("~/bundles/scripts/dashboard").Include(
           "~/Scripts/app/vendor/angular.min.js",
           "~/Scripts/app/vendor/angular-sanitize.js",
           "~/Scripts/app/vendor/ace.js",
           "~/Scripts/app/vendor/ui-ace.min.js",
            "~/Scripts/app/vendor/ext-language_tools.js",
           "~/Scripts/app/vendor/angular-animate.js",
           "~/Scripts/app/vendor/angular.ui-router.min.js",
            "~/Scripts/app/dashboard/app.js"
        ));

In the above code is worked in local . When i publish the code into IIS Server and run the project. Two Errors are occured  Failed to load Resources theme-chrome.js and mode-javascript.js files . I tried to created ace folder place these two files but also same issue raised so how to resolve errors , how to load these files.

A: Finally I got answer.
bundling these two mode-javascript and theme-chrome js files . Then define the define in these two files like open mode-javascript and theme-chrome js files instead of define(  use ace.deine(


text:
Q: The symplectic transvection group is isomorphic to what $A^1$, $A^2$? The transvections generate the symplectic group, but to demonstrate its connectedness I need to establish their connectedness.  I was thinking of doing this through an isomorphism of alg. groups with $A^1$, but this seems wrong since I disregard t; but then if I take it with $A^2$ it is no longer an injection!!!
In short, how do I establish the connectedness of each symplectic transvection group?  Have I approached the problem incorrectly?


text:
Q: Parametric3D inconsistencies i wanted to plot a surface of the form
thickcurvee[t_, th_] =
 Simplify[curve[t] + eps *RotationMatrix[{{0, 0, 1}, curved2[t]}].{Cos[th], Sin[th], 0},
   Assumptions -> t \[Element] Reals]

With curve and curved2 being maps of R to R^3.
if i plot this surface parametricplot3D plots an empty space, however if i copy paste the result of
Simplify[curve[t] + eps *RotationMatrix[{{0, 0, 1}, curved2[t]}].{Cos[th], Sin[th], 0},
   Assumptions -> t \[Element] Reals]

directly and define the surface that way parametricplor3D does work.
Does anyone know what causes the difference?


text:
Q: Error installing meteor accounts-entry package Been trying to install the meteor accounts-entry package and I've got the following error.
Anyone know how I can sort this?  I've tried googling but didn't find anything.  I tried installing the node underscore.string package but that didn't make any difference.

$ mrt add accounts-entry
Done installing smart packages
Stand back while Meteorite does its thing
Done installing smart packages
Ok, everything's ready. Here comes Meteor!
=> Errors while scanning packages:
While building package underscore-string-latest:
     error: File not found: lib/underscore.string/lib/underscore.string.js
/usr/local/lib/node_modules/meteorite/lib/command.js:41
     throw "Command exited with " + code + "/" + signal;
                                                       ^
     Command exited with 1/null

When the app is run I get the following on the browser:
Your app is crashing. Here's the latest log.

=> Errors prevented startup:

While building the application:
node_modules/underscore.string/test/test_underscore/index.html:1: Can't set
DOCTYPE here.  (Meteor sets <!DOCTYPE html> for you)
node_modules/underscore.string/test/test.html:1: Can't set DOCTYPE here.
(Meteor sets    <!DOCTYPE html> for you)
node_modules/underscore.string/test/test_standalone.html:1: Can't set DOCTYPE here.
(Meteor sets <!DOCTYPE html> for you)

I've not looked into the doctype error much yet, going to have a look into this a bit later on.
Thanks again in advance :)

A: You've added npm modules to your meteor project.
Delete the npm folder (in the current directory)
rm -rf node_modules

To use npm modules in your project see this instead: http://meteorhacks.com/complete-npm-integration-for-meteor.html


text:
Q: Iperf TCP test variations I am using iperf to test the connection between two machines (WiFi+AP), one runs Ubuntu14, and the other is Win7. Both are on the same subnet.
The problem is that the results varies very much over time, and varies from run to run! and I couldn't figure out the exact reasons?
results snip:
[  4] local 192.168.0.135 port 5001 connected with 192.168.0.147 port 42003
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0- 5.0 sec  2.77 MBytes  4.64 Mbits/sec
[  4]  5.0-10.0 sec  3.68 MBytes  6.17 Mbits/sec
[  4] 10.0-15.0 sec  3.42 MBytes  5.74 Mbits/sec
[  4] 15.0-20.0 sec  1.23 MBytes  2.07 Mbits/sec
[  4] 20.0-25.0 sec  1.10 MBytes  1.85 Mbits/sec
[  4] 25.0-30.0 sec  1.04 MBytes  1.74 Mbits/sec
[  4] 30.0-35.0 sec  1.51 MBytes  2.54 Mbits/sec

command @ Win Server

iperf -c IP -i 5 -t 60

Command @ Ub Client

iperf -s -i 5

Could anyone help me explaining why it varies that much? and how to correctly probe the connection between the two machines for later comparisons?

A: Your results draw expected variation.
Anyway, this fluctuation would be due to different factors:

*

*Network traffic. Are those nodes alone on the switch/router/network or they are influenced by other nodes?

*Processors traffic. Are you running processes/services/daemons that may slow down your processors so that your processor may lag your transmission?

Indeed, several factors would be behind.


text:
Q: Div tags and iframes Im looking for a way to make the content div expandable on click of the iframe to display the iframe content correctly, the code is:

CSS is
#content
{
  width: 790px;
  height:auto;
  padding: 5px 55px 0;
}

#outerdiv
{
  width:790px;
  height:446px;
  overflow:hidden;
  position:relative;
}

#inneriframe
{
  position:absolute;
  top:-268px;
  left:-230px;
  width:1280px;
  height:1198px;
}

Any suggestions would be appreciated.

A: At first we must cleanup your CSS code:
#iframe{
    position: absolute;
    width: 100px;
    height: 100px;
}

Now we must wrote some in Jquery:
var iframeDoc = $('#iframe').contents().get(0);

var start = "big";
$(iframeDoc).bind('click', function( event ) {
    if(start == "big"){
        $("#iframe").animate({width:"100%", height:"100%"}, 1000);
        return start = "small";
    } else if(start == "small") {
        $("#iframe").animate({width:"100px",height:"100px"},1000);
        return start = "big";
    }
});

Use:

JSFiddle: http://jsfiddle.net/YuWSy/


text:
Q: How many quotas does a LiveChatMessage insert request cost to the Youtube Live Streaming API? How many quotas does a LiveChatMessage insert request cost to the Youtube Live Streaming API ?

A: The LiveChatMessage insert request cost 20 quota


text:
Q: BooleanField to checkboxinput in django won't work as it should I have the following model that has a Boolean field among others
class Prb(models.Model):
    #other fields
    disabled = models.BooleanField(default=False)

and a modelform for the model
class PrbModelForm(ModelForm):

    class Meta:
        model=Prb

In my view I render prbmodelform with a prb as instance
prb = get_object_or_404(Prb, pk=4)
prb_model_form = PrbModelForm(request.POST or None, instance=prb)

prb.disabled field for this model is 0 (using SQLite database)
but when I render the form although disabled field is 0 checkbox is checked. How can I solve this problem? I want to add here that disabled is an SQLite Boolean field, and that the data schema was transformed in to models using inspectdb. Why doesn't it render the checkbox status correctly?
EDIT: Queries work as they should, that is when I do this
Prb.objects.filter(disabled=True)

it return the correct prb's. The all have disabled equal to 1.
EDIT#2: value of prb.disabled inside view is 0
form renders as follows(providing only the checkbox field)
<input checked="checked" id="id_disabled" name="disabled" type="checkbox" value="0">

A: Just for others to know...The problem was with SQLite. Turns out that when user has not set the field to be not null Django must use a NullBooleanField instead of a plain BooleanField. Migrated from BooleanField to NullBooleanField (to agree with database) and then migrated back to BooleanField to change db's schema. I want everything to be done from the orm and django that's why I went the long way(that is using migrations rather than just altering the field using sql from sqlite command line)
Thank you all...


text:
Q: Python runs smoothly until an error with scraping occurs tried to fix it using try and except but it doesn't seem to work Python newbie here practicing my skills. I came across a roadbump and would be very happy to receive some help. What i'm trying to do is to get a list of links from a spreadsheet. From there, Python will get the data, extract a specific class and paste the data to ColB. Problem is, there are instances when the link is broken, hence there will be no data scraped. I used try and except to get around this but it seems like it's not working. What it seems to do is that when an error occurs, it just skips writing the data and proceeds to write the data on the wrong cell. here is my code:
credentials = ServiceAccountCredentials.from_json_keyfile_name('Te....4e.json', scope)

gc = gspread.authorize(credentials)

#selects the spreadsheet
sh = gc.open_by_url('https://docs.google.com/spreadsheets/d/1u7....0')

worksheet = sh.worksheet('Keywords')
colvalue = "A"
rownumber = 2
updaterowvalue = 2

while rownumber <100:
    try:
        val = worksheet.acell(colvalue +str(rownumber)).value
        rownumber += 1
        url = val
        #scrape elements
        response = requests.get(url)
        soup = BeautifulSoup(response.content, "html.parser")
        #print titles only
        h1 = soup.find("h1", class_= "sg-text--headline")
        updatecolvalue = "B"
                worksheet.update_acell(updatecolvalue +str(updaterowvalue), h1.get_text())
        updaterowvalue +=1
    except AttributeError:
        pass

print('DONE')

A: I assume that the extra indentation on the line starting worksheet.update_acell is an error, since your code is invalid as given.
The problem is that when an exception occurs, updaterowvalue +=1 is not executed, which causes the results to get out of sync with the URLs.
Fixing this is simple, just stop using updaterowvalue and just use rownumber in the worksheet.update_acell() call.  Since you want the result to be in the same row as the URL, updaterowvalue is unnecessary.
A more pythonic way of writing the loop would be:
for rownumber in range(2,100):

which allows you to eliminate the rownumber += 1 line too.


text:
Q: Taking and skipping groups of strings? I worked with strings in a couple of languages and then something bothered me about how we can select characters or slices (substrings) from the strings. Like we can get substrings from a string or a character from a particular position, but I was not able to find any method or operator which returns certain slices of a particular length skipping particular characters. Below is the explanation.
So suppose I have the following string: I am an example string. From this string, I want to be able to get groups of string of let's say length 2 and skip certain characters, let's say 3. Now to make things more interesting let's say I can start at any index, which for this example we'll take 5. So the string which I should get from the above conditions should be the following: anam sng. Illustration below (* for take, ! for skip).
                                    **   **   **   **
                               I am an example string.
                                    | !!!  !!!  !!!  !
                   Start Position --+

I know you could implement that using counting variables which keep track of each character whether to take or not using if condition. But I was thinking of a mathematical way or maybe even an inbuilt method or operator in some languages that could do the job.
I also searched whether Regex could do the job. But couldn't come up with anything.

A: Generic solution: skip first start characters, when replace all occurrences of regex (.{0,n}).{0,m} by the first group.
Python:
import re

input = 'I am an example string.'
n = 2
m = 3
start = 5

print(re.sub('(.{0,%d}).{0,%d}' % (n, m), "\\1", input[start:]))

Java:
final String input = "I am an example string.";
final int n = 2;
final int m = 3;
final int start = 5;

final String regex = String.format("(.{0,%d}).{0,%d}", n, m);
System.out.println(input.substring(start).replaceAll(regex, "$1"));

C++11:
string input = "I am an example string.";
int n = 2;
int m = 3;
int start = 5;

stringstream s;
s << "(.{0," << n << "}).{0," << m << "}";
regex r(s.str());
cout << regex_replace(input.substr(start), r, "$1");

A: Regex can do. You only need to try a little harder :)
public static void main(String[] args) {
    String s = "I am an example stringpppqq";
    Pattern p = Pattern.compile("(.{1,2})(?:.{3}|.{0,2}$)");
    int index = 5;
    Matcher m = p.matcher(s);
    StringBuilder sb = new StringBuilder();
    while (index < s.length() && m.find(index)) {
        System.out.println(m.group(1));
        sb.append(m.group(1));
        index = index + 5;
        System.out.println(index);
    }
    System.out.println(sb);
}

O/P :
anam sngqq

A: Python don't have this kind of slicing, you must use a loop. But you can do it with a comprehension list:
text = 'I am a sample string'

s = 5  # start position
l = 2  # slice length
d = 3  # distance between slices

chunks = [text[p:p + l] for p in range(s, len(text),  l + d]
result = ''.join(chunks)

With a RegEx you can match a two-length string in a group and a three-length string.
import re

regex = r'(..)...'

found = re.findall(regex, text[s:])  # list of tuples
result = ''.join(f[0] for f in found)


text:
Q: email sends whole html page(instead of email body) in laravel 5.1 I'm making a contact form. If someone fills in the form, the data (text,subject) should be sent to my mail. Everything works, but when I fill in form and send the email, it sends the whole HTML page (not just the text from the form).
Here's how it looks like

Here's my controller where I send the mail
 public function sendEmail(Request $request)
{

    $data["username"] = $request->username;
    $data["email"] = $request->email;
    $data["subject"] = $request->subject;
    $data["mail_text"] = $request->mail_text;

    Mail::send('contact', ["data" => $data], function ($mail) use ($data){

        $mail->to("leribobo@gmail.com")->from($data["email"])->subject($data["subject"]);

    });

    return redirect()->back();
}

as I guess it sends 'contact' page, which is first parameter in method
 Mail::send('contact' ....

A: You are actually sending the contact.blade.php file. This is not how we should send a mail.
Mail::send('emails.contact', $data, function ($message) {
    //

     $message->from('us@example.com', 'Laravel');

     $message->to('foo@example.com')->cc('bar@example.com');
});

You've to make a file in emails.contact.blade.php and pass $data to the blade file as showed above.
Check here: https://laravel.com/docs/5.1/mail#sending-mail


text:
Q: Three20 navigation by openURLAction; self.navigationController is nil in pushed VC? The navigation commences with [[TTNavigator navigator] openURLAction:theUrl]; from one UIviewController controller and another UIViewController is the target of that URL. The map is set with set with the following code and there is no doubt navigation goes to the right place:
TTURLMap* map = navigator.URLMap;
[map from:@"tt://goToMyViewController" toViewController:[MyViewControllerClass class]];

In the pushed view controller i want to manipulate the image on the Back button but don't want to change the title. It should always be the title of the view controller this one was pushed on top of, or localized "Back" if no title was set.
Problem:
In this pushed view controller's viewDidLoad I'm starting with
NSArray* viewControllers = self.navigationController.viewControllers;

to get the navigation stack so I can look at the title of the appropriate view controller. But viewControllers is nil...
However if I do nothing the default back button does have the correct title. I thought of looking at the leftBarButtonItem and backBarButtonItem title properties but there is nothing meaningful there either...
Anyone know what is going on, why this is happening or how it can be worked around?

A: This is one of those things where viewDidLoad is the wrong place to do it - after comparing various view controllers and finding no real difference in how they were invoked (yet had nil viewControllers while others didn't) it struck me that if it was really nil, popViewControllerAnimated shouldn't work either. I found viewControllers was NOT nil where I was calling popViewControllerAnimated and from there experiment showed I could get the title I was after in viewWillAppear:.
So, viewWillAppear: seems to be a reliable place to touch self.navigationController while viewDidLoad is not.


text:
Q: How I can return a value from function after store is loaded in ExtJs? I have a function with a store load. That is:
function PdCtrl_Posicionamiento_RegistrarPosicion(numeroPrograma, tren, fechaTren, ramal, secuenciaEstacion, kilometraje, hora, minuto, tipoOrigen, eliminaDependencia) {

storePdCtrl_Posicionamiento_RegistrarPosicion.load({
    params: {
        numeroPrograma: numeroPrograma,
        tren: tren,
        fechaTren: fechaTren,
        ramal: ramal,
        secuenciaEstacion: secuenciaEstacion,
        kilometraje: kilometraje,
        hora: hora + ":" + minuto,
        tipoOrigen: tipoOrigen,
        eliminaDependencia: eliminaDependencia,
        usuario: NOMBRE
    },
    callback: function () {

        var estado = new Array();
        var err = storePdCtrl_Posicionamiento_RegistrarPosicion.getAt(0).get('ESTADO');
        var mensaje = storePdCtrl_Posicionamiento_RegistrarPosicion.getAt(0).get('MENSAJE');

        estado.push(err);
        estado.push(mensaje);

        return estado;
    },

});

}
And I need to get the returned value (the array) in other place (in the function call) but for the way that ExtJs works (async), I can't get the array. The following lines don't work:
var vl_estado = PdCtrl_Posicionamiento_RegistrarPosicion(numeroPrograma, tren, fechaTren, ramal, secuenciaEstacion, kilometraje, hora, minuto, tipoOrigen, eliminaDependencia);
    console.debug("estado:" + vl_estado);

When I debug the variable "estado" I don't have any value. Maybe I don't explain the situation in a good way. Sorry and thanks.

A: you thinking on wrong way. you just call a method at the end of your callback method with your variable.
Just like this;
var doSomeThingWithVariable = function(passedVariable){
     alert(passedVariable);
};
storePdCtrl_Posicionamiento_RegistrarPosicion.load({
        params: {
            numeroPrograma: numeroPrograma,
            tren: tren,
            fechaTren: fechaTren,
            ramal: ramal,
            secuenciaEstacion: secuenciaEstacion,
            kilometraje: kilometraje,
            hora: hora + ":" + minuto,
            tipoOrigen: tipoOrigen,
            eliminaDependencia: eliminaDependencia,
            usuario: NOMBRE
        },
        callback: function () {

            var estado = new Array();
            var err = storePdCtrl_Posicionamiento_RegistrarPosicion.getAt(0).get('ESTADO');
            var mensaje = storePdCtrl_Posicionamiento_RegistrarPosicion.getAt(0).get('MENSAJE');

            estado.push(err);
            estado.push(mensaje);

            doSomeThingWithVariable(estado);
        },
    });

A: Have you tried:
callback: function (records) {
    if (records.length > 0) {
        var estado = new Array();
        var err = records[0].get('ESTADO');
        var mensaje = records[0].get('MENSAJE');
        estado.push(err);
        estado.push(mensaje);
        return estado;
    } else {
        return null;
},


text:
Q: Gsuite DMARC SPF Setup Failure I'm using Gsuite with our own domain name "audacy.space". I've setup DMARC, DKIM and SPF, and both DMARC Analyzer and Google's Mx Tool report no problems for the domain. However, our weekly DMARC reports from Postmark still show 70% of messages as not aligned. Especially one Google server at 209.85.550.69 shows a very high failure rate.
DMARC Report
I've tried adding that IP explicitly in our SPF records (as 209.85.220.0/24), but it hasn't improved anything. Any idea where I'm going wrong? Thanks!

A:
However, our weekly DMARC reports from Postmark still show 70% of
  messages as not aligned.
I've tried adding that IP explicitly in our SPF records (as
  209.85.220.0/24), but it hasn't improved anything.

Since the issue here is alignment, adding IPs to your SPF is not going to solve the issue.
DMARC is there to demand that the domains used in your authentication methods, SPF and DKIM, align with the domain used in the email address that is shown to the recipient of your emails, namely the Header.From field.
Since your DMARC policy allows for relaxed SPF and DKIM alignment, this means the smtp.mailfrom address (a.k.a. Return-Path / Bounce address / envelope from) should use a domain that shares the same organizational domain, for example bounces@newsletters.audacy.space. This is similar for DKIM.
Forwarders generally rewrite the bounce address to an address in order to receive the bounces themselves and PASS their own SPF policy. However, they do not change the Header.From address and thus these forwarded messages end up as "SPF misaligned" in your DMARC reports.
Apart from forwarding rules, Google uses Groups for Business as distribution groups to forward email to the members of that group. Google then also includes the results from these forwarded emails in the DMARC reports they send back to you.
If you can look in the raw data for your DMARC report, you may find that:

*

*the sender of the report is Google, meaning that the recipient mailbox is hosted on Google.

*The sending IP address is owned by Google.

*And, the bounce address is rewritten to a domain that is hosted on the Google platform.

This last bit is not always crystal clear, because it could be an external domain. But if you look up the MX records for that domain, you might find that it points to Google servers.
To conclude: Based on the information you provided my best guess would be, since the sender IP belongs to Google, that this situation involves forwarders and probably Google's Groups for Business.