text:
Q: Generic defined using an interface instead of class How can I specify that I want any object that implements the A interface to be allowed inside of the List in a type-safe manner?  I want to be able to invoke a given method of A over all of the objects, regarding what Class type they are.
public interface A (){}
List<? extends A> myList = new ArrayList<? extends A>();
I am getting: Cannot instantiate the type ArrayList<? extends A>
If I leave the generic off of the instantiation side it works fine, but I have to specify @SuppressWarnings({ "rawtypes", "unchecked" }) to make the compiler hush up about the warnings.

A: To see why it doesn't make sense to instantiate a new ArrayList<? extends A>(), in fact we can equivalently create a new ArrayList<B>() with any arbitrary class or interface B (even one that is not related to any of your objects) that implements A, and the resulting created ArrayList can be safely assigned to a variable of type ArrayList<? extends A>. Then you might wonder, oh, this is stupid, because the objects I want to put into it are not of class B, so how can this be the same? But it is the same, because you cannot put anything into a reference of type Something<? extends A> anyway. This is why it doesn't make sense to create a new ArrayList<? extends A>().

How can I specify that I want any object that implements the A
  interface to be allowed inside of the List in a type-safe manner? I
  want to be able to invoke a given method of A over all of the objects,
  regarding what Class type they are.

That's exactly what ArrayList<A> is. It allows all instances of A (of course all objects that implement A are instances of A) and you can use any methods of A on them. Something like this is what you want:
List<A> myList = new ArrayList<A>();

Something like List<? extends A> is only used in cases when you will get a List object from some other code, and you don't know (or care) what exactly is the generic parameter they created it with. (In such a case you cannot put objects into the List.) This is completely different from your case here, where you are creating the List object, so you decide and therefore know exactly what generic parameter is used.

A: The issue is not related to binding a type parameter to an interface, but that you can't instantiate a parameterized type with a wildcard. new ArrayList<? extends A>() or even new ArrayList<?>() doesn't make sense because you're not telling the compiler what the instantiated List actually holds.  new ArrayList<A>() on the other hand would make sense.

A: just List<A> is fine this allows objects that implement A in the list and that all objects in the list implement A

A: I think you are looking for:
List<? super A> myList = new ArrayList<A>();

*

*List<? extends A> myList ... that is telling the compiler that it is a list of some unspecified type and the unspecified type extends A.  You can't put any A in this list because it might not be the right exact type.  All the compiler knows is that any object in this list must be an A.  I think you want List<? super A> myList.  This is telling the compiler that List is of some unspecified type of which A extends.  Now the compiler can let me put any A in the list.

*new ArrayList<? extends A>(); is just plain wrong.

A: You want
List <A> collection = new ArrayList <A> ();
By using the wildcard you are suppressing information to the compiler. You say you want to be able to both read and write to the 'List'. A generic '? super A' lets you write to the collection but not read from it. A generic '? extends A' lets you read from the collection but not write to it. Putting just 'A' in the generic parameter lets you both read from and write to the collection. See the free chapter from Joshua Bloch's seminal Effective Java on generics at http://java.sun.com/docs/books/effective/generics.pdf.


text:
Q: Join 2 laravel collections I have 2 collections :
$collection1 = [
{ name : "aaa" , score : 10 },
{ name : "bbb" , score : 20 }
];
$collection2 = [
{ name : "aaa" , score : 30 },
{ name : "bbb" , score : 10 }
];

and I want to join them to get the following result :
$collection3 = [
{ name : "aaa" , score : 40 },
{ name : "bbb" , score : 30 }
]

merge() and union() didn't do the job for me .

A: Combine the collections, group by the name and sum the score. This can be done like so with collections in Laravel. Note that group by returns a collection of the grouped data.
$collection1->concat($collection2);

$collection1->groupBy('name')->map(function ($scores) {
    $score = $scores->first();

    $score['score'] = $scores->sum('score');

    return $score;
});

A: it can be achieve by laravel collection map()  and where() function
$collection1 = collect([
    [
        "name" => "aaa",
        "score" => 10
    ],
    [
        "name" => "bbb",
        "score" => 20
    ]
]);
$collection2 = collect([
    [
        "name" => "aaa",
        "score" => 30
    ],
    [
        "name" => "bbb",
        "score" => 10
    ]
]);

$collection3 = $collection1->map(function ($item) use ($collection2) {
        $found = $collection2->where('name', $item['name']);
        if ($found) {
            $item['score'] = $item['score'] + $found->first()['score'];
        }
        return $item;
    });

dd($collection3);

This is the result https://phpsandbox.io/n/soft-flower-ap1e-vo2xy

A: $collection = collect();$collection->merge(['col1' => $col1, 'col2' => $col2 ]);
OR $states = [ 'Delhi', 'Tamil Nadu', 'Uttar Pradesh'];
foreach ($states as $state)
{ $data = DB::table('user')->select('user.*') ->where("user.city", $state)->where('user.status', 1)->get();  if (!empty($data[0]))  $stateUser = $stateUser->merge([$state => $data]);}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Findbugs issues with mutability of Date object in Java This is more of a follow-up to questions 1 & 2.
As told in the questions the below code
public Date getSomeDate() {
   return someDate;
}

will give you the findbug error issue.
The suggested solution was to duplicate the Date object in both getters and setters like
public Date getSomeDate() {
  return new Date(someDate.getTime());
}

Is this a good approach or are there any alternative ways to this?
Is there any Immutable Date library available in java that can overcome this issue?

A: Attention Folks...
besides adapting both the getter and the setter you need to take care about null values:
public Date getSomeDate() {
  if (this.someDate == null) {
    return null;
  }
  return new Date(this.someDate.getTime());
}

public void setSomeDate(final Date someDate) {
  if (someDate == null) {
    this.someDate = null;
  } else{
  this.someDate = new Date(someDate.getTime());
  }
}

A: JodaTime has immutable dates.
Sure, it's okay to use a Date constructor in a getter, why wouldn't it be?
That said, just because FindBugs pegs mutable state as a potential error, it doesn't mean it's intrinsically worth caring about–it depends on how the class is being used. Immutability eliminates one type of bug, which you may or may not need to care a lot about.

A: Depending on you use-case you could return someDate.getTime() without wrapping it in a Date.

A: Wait a minute... by copying the object within the getSomeDate and setSomeDate methods we are not eliminating the security risk since the changed object comes back through the setSomeDate and copies preserve the changed values. It would be necessary to remove setSomeDate in order to solve this kind of security issue, or do not worry at all about it.


text:
Q: Elasticsearch - Repository creation fails (disk quota) I have an issue with creation of snapshot repository.
PUT _snapshot/test-repo
{
  "type": "fs",
  "settings": {
    "location": "test_repo"
  }
}

The reply was this:
{
  "error" : {
    "root_cause" : [
      {
        "type" : "repository_verification_exception",
        "reason" : "[test-repo] path  is not accessible on master node"
      }
    ],
    "type" : "repository_verification_exception",
    "reason" : "[test-repo] path  is not accessible on master node",
    "caused_by" : {
      "type" : "i_o_exception",
      "reason" : "Disk quota exceeded"
    }
  },
  "status" : 500
}

In the Elasticsearch.yml the following line is there on each nodes:
path.repo: /data/backup

The filesystem looks like this:
Filesystem               1K-blocks        Used    Available Use% Mounted on
devtmpfs                  32639224           0     32639224   0% /dev
tmpfs                     32659088           0     32659088   0% /dev/shm
tmpfs                     32659088      141196     32517892   1% /run
tmpfs                     32659088           0     32659088   0% /sys/fs/cgroup
/dev/mapper/sesp-root    204343336     2841068    191052556   2% /
/dev/sdb2                   999320      156228       774280  17% /boot
/dev/sdb1                   613184        6928       606256   2% /boot/efi
/dev/sda1              11625298376  2905961572   8133382964  27% /usr/sxn
tmpfs                      6531816           0      6531816   0% /run/user/0
boostfs               270947533824 74784425472 196163108352  28% /data/backup

This issue happens since the storage size is extended - before that there were no issues with that.
ES version is 7.16.1.
Thanks,
Peter


text:
Q: Update to grails domain don'tpersist I'm working in grails 2.3.8
We have the following domain classes:
abstract class GroupItem {
  static belongsTo = [group:AppGroup]
  static mapping = {
    tablePerHierarchy = false
  }
}

class MyDomain extends GroupItem {
  String name
  String type
  int Identifier

  static hasMany = [attributes:Attribute]

  static mapping = {
    attributes cascade: 'all-delete-orphan'
  }
}

class Attribute {
  String name
  String value
  static belongsTo = [myDomain:MyDomain]
}

In my controller's 'update' method I am trying to update a 'MyDomain' object. I can update the attributes that associate with the domain fine, however when I try and change any of the properties on an instance itself (name, identifier or type) the changes don't persist. The controller code:
def update(Long id) {
  ---
  def myDomain = MyDomain.get(id)
  myDomain.type = 'DIFFERENT TYPE'
  myDomain.save(flush:true, failOnError:true)
}

However the signal in the database still has the same type as when it was created. To try and follow the logic I added a beforeUpdate method to the domain class that prints out the type and I can see that it is getting called and in beforeUpdate it thinks the type is my new value, however the update is never persisted. There are no exceptions, the objects validate, and nothing in any logs. Any clue what could be causing this?
Cheers!

A: Right... Slaps Face
The bits that I didn't include in that post was that they update is actually happening within a service (with the @Transactional annotation, and Im also using a command object to do some validation earlier in the controller. The Command object checks the group id is valid by seeing if it a non-null is returned by
def group = AppGroup.read(id).

I'm not sure why but it seems that since this object is in the session this is the one that's getting saved at the end of the transaction and it isn't dirty. If I discard this group once I am done with it, then everything works fine.
Not sure why this is, but hey ho, fixed my problem. Might try to see if exists() is a better fit...


text:
Q: Does this series converge to a rational function? Consider the series $$\sum_{k=0}^{\infty}\frac{1}{k!(z-k)^k}$$ Is there any domain of the complex plain where this series converges to a rational function?
Any hints will be appreciated


text:
Q: When is [Time to be received] property of msmq message evaluated? When I send a message and set the TTBR property on the message:
    QueuedMessage.TimeToBeReceived = TimeSpan.FromSeconds(10);
When is this property evaluated and the message deleted or deadlettered?

A: The documentation doesn't specify when or how the property is evaluated, that's probably deliberate.  By doing that Microsoft keep their options open.  They are free to change when and how the property is evaluated any time they want to.
There are some hints.  For instance the PROPID_M_TIME_TO_BE_RECEIVED description says:

In each hop, Message Queuing subtracts the time elapsed on the applicable computer from the value of PROPID_M_TIME_TO_BE_RECEIVED when it dispatches the message to the next computer, where a new timer is set.

But we probably shouldn't read too much into that.  The phrase "... where a new timer is set." might be shorthand for some other non-timer related code and not an indication that an actual timer is created.


text:
Q: Symfony FOSUserBundle Override Templates Not Working I have a problem about Symfony FOSUserBundle Override Templates.
I tried

Create A Child Bundle And Override Template

way in this documentation.
I can override Controllers with this way but still can't override templates. I found a github demo about it and we have just 1 difference.
But my project is FOSUserBundle Controllers returning like ;
return $this->render('@FOSUser/Security/login.html.twig', $data);

In his project FOSUserBundle Controllers returning like ;
return $this->render('FOSUserBundle:Security:login.html.twig', $data);

I want to ask :
-If I change it manually and then if there is update for this bundle would it change it back ..
-When installing FOSUserBundle for my project I want it to be like in his project's. How can i achieve it ?

A: You can't change the vendor's controller. If you want to change any code in FOSUserBundle controllers, you have to override it too. Which bundle overriding the FOSUserBundle, you can create own controllers in that bundle. After that you can use that for your own strategy.
Sample Bundle: https://github.com/mertoksuz/symfony2-rest/tree/master/src/RestApi/UsersBundle
Check this UsersBundle.
Thank you.


text:
Q: Persisting record error in ember I'm trying to persist record like in the documentation:
  var record = this.store.createRecord('record',{});
            record.set('record_text',this.get('record_text'));
            record.set('record_time', Math.round(new Date()/1000));
            record.save();

But I receive error:
Error: No model was found for 'content'
    at new Error (<anonymous>)
    at Error.Ember.Error (http://zion-le.work/public/scripts/chat/assets/vendor.js:14061:19)
    at Ember.Object.extend.modelFor (http://zion-le.work/public/scripts/chat/assets/vendor.js:68689:33)
    at JSONSerializer.extend.extractSingle (http://zion-le.work/public/scripts/chat/assets/vendor.js:61641:28)
    at superWrapper [as extractSingle] (http://zion-le.work/public/scripts/chat/assets/vendor.js:14443:16)
    at Ember.Object.extend.extractSave (http://zion-le.work/public/scripts/chat/assets/vendor.js:61161:21)
    at Ember.Object.extend.extractCreateRecord (http://zion-le.work/public/scripts/chat/assets/vendor.js:61090:21)
    at Ember.Object.extend.extract (http://zion-le.work/public/scripts/chat/assets/vendor.js:61018:37)
    at http://zion-le.work/public/scripts/chat/assets/vendor.js:69380:32
    at invokeCallback (http://zion-le.work/public/scripts/chat/assets/vendor.js:23164:19) vendor.js:16672
Uncaught Error: Assertion Failed: Error: No model was found for 'content' vendor.js:13224

I think it's happened because I execute this code in consultation instead record controller

A: When you POST or PUT a record, the server responds with a new copy of the object in question.  Ember will parse this and replace the item in the store with the new copy.  I generally override the extractArray and extractSingle functions in my adapter.  If it is a general pattern, you can do it in your ApplicationAdapter, or if it is specific to your record type, you can do it in the RecordAdapter.


text:
Q: Struts2 Android Upload Image We have an Struts2 Webserver which has the jsp way of accepting the file,
but the problem is using Android client the file upload happens by opening HttpConnection(Rest Api's)
can someone help me identify, How can i upload an File using Android client to Struts2 Webserver

A: Struts2 treats file uploads the same as any Java web app, using multipart/form-data.
Have a look at Ion, it has a good API for POSTing multipart/form-data.


text:
Q: Why does any kind of abstraction use interfaces instead of abstract classes? Heyho,
There´s a question in my mind for some time now, which hopefully can be cleared quickly by some of you:
I am a big fan of MVC, ASP.Net Mvc in my case.
What I have noticed is the hype about interfaces. Every video, tutorial and book seems to solve any kind of abstraction with interfaces. I have adapted these patterns, understood why and how and I am basically very happy with it.
But I just don´t get why interfaces are used everywhere. I´ve almost never seen some abstraction being done with abstract base classes, which I don´t understand. Maybe I miss something? I know that you can only inherit from one base class while multiple interfaces are possible. But interfaces do have disadvantages, especially when some changes need to be done, which breaks your implementations.
In my projects so far, I only used to pick interfaces for completely different classes.
For example, the whole repository pattern could be done with an abstract base class, still providing testability and exchangeability, or did I miss something?
Please point me to the part where my brain laggs  :)

A: Interfaces are used in tutorials, blogs and elsewhere because those authors are particularly influenced by a group of methodology called "design for testability".
Primarily, design for testability school of thoughts used interface every way because they want to be able to mock any component under tests. If you use concrete class, then a lot of mocking tools can't mock those class, and hence will make it difficult to test your code.

A: A Story

I once attended a Java user group
meeting where James Gosling (Java's
inventor) was the featured speaker.
During the memorable Q&A session,
someone asked him: "If you could do
Java over again, what would you
change?" "I'd leave out classes," he
replied. After the laughter died down,
he explained that the real problem
wasn't classes per se, but rather
implementation inheritance (the
extends relationship). Interface
inheritance (the implements
relationship) is preferable. You
should avoid implementation
inheritance whenever possible.

While using only or mostly Interfaces does have code reuse problems(as well as eliminating nice base classes), It makes it a lot easier to do Multiple Inheritance like things. As well as having widely different implementations that will work and where you don't have to worry about the base class changing or even what it does(you do have to implement the whole thing though so its a trade off).
P.S. I think the new Go language is based on interfaces rather then inheritance(looks sort of interesting).

A: If the language doesn't support multiple inheritance or mix-ins abstract base classes are limited in scope compared to interfaces. E.g. in .NET if you must inherit from some other type such as MarshalByRef, you can't use an abstract base class to implement a pattern. Interfaces do not impose this restriction.

A: Besides the fact you mentioned that you can inherit from a single base class only (which is pretty inconvenient if you want to use an existing class that already inherits from some class with the new framework base class), you also avoid the fragile base class problem if you use interfaces instead.

A: Coding against interfaces makes your design more flexible and extensible. For instance, plugin frameworks and dependency injection. Without interfaces, the extensibility of it is pretty much limited.

A: Read about interfaces, abstract classes, breaking changes, and MVC here: http://ayende.com/Blog/archive/2008/02/21/Re-Versioning-Issues-With-Abstract-Base-Classes-and-Interfaces.aspx.
One solution that is presented there (or somewhere else on Ayende's blog) is: do use interface but also provide abstract classes. Those who case about breaking changes can base their implementations on abstract classes. Those who need power of interfaces are also satisfied. But do make sure your methods accept interfaces, not abstract classes, as input.


text:
Q: Update test case outcome status in azure test plans based on robot framework result file Currently we are using Xray Test Management to create, define and execute test cases. We automated them with Robot Framework and import the test results via Xray Rest API. Afterwards the related test execution and the related test cases are updated in their status according to the outcome in the Robot Framework result file. Is there also a similar feature (or app in marketplace) in Azure Test plan? So that we can import our test results from Robot Framework to Azure Test Plans and connect it to an existing test plan?
Thanks,
Andreas


text:
Q: Is there a differentiable function that tends to ∞ at some point such that its derivative doesn't tend to ±∞ at that point? Suppose we have a differentiable function $f:(a,b)\rightarrow\mathbb{R}$ such that $\lim_{x\rightarrow a^+}{f(x) = \infty}$.
Do we necessarily have $\lim_{x\rightarrow a^+}{f'(x) = -\infty}$?
I thought this had to be true until I started trying to prove it using Lagrange's theorem and realized it doesn't work. $f'$ will be unbounded, since the average rate of change of $f$ over $(x,b)$ will tend to -$\infty$ as $x$ tends to $a$ from the right. But we nonetheless could have $f'$ reach as low as we want and return to $0$ (for example) on infinitesimally small intervals.
For example the function $\frac{1}{sin(\frac{1}{x})^2}$ behaves this way — it is unbounded but doesn't tend to $\infty$ as $x$ tends to $0$. So I suppose the antiderivative of some function of this type could tend to $\infty$?
Any insight on why this is possible/impossible is appreciated :)

A: Well if there was a finite $L$ s.t. $\lim_{x\rightarrow a^+}f'(x) = L$, then there is a $\epsilon >0$ s.t. $|f'|$ is bounded in $(a,a+\epsilon]$ and then
\begin{align*}
\lim_{x\rightarrow a^+}f(x) = f(a+\epsilon)-\int_a^{a+\epsilon} f'(x)dx \leq f(a+\epsilon) + \sup_{x\in (a,a+\epsilon]}|f'(x)|\cdot \epsilon \lneq \infty
\end{align*}


text:
Q: Does there exist $\ n,m\in\mathbb{N}\ $ such that $\ \left\lvert \left(\frac{3}{2}\right)^n - 2^m \right\rvert < \frac{1}{4}\ $? Does there exist $\ n,m\in\mathbb{N}\ $ such that $\ \left\lvert \left(\frac{3}{2}\right)^n - 2^m \right\rvert < \frac{1}{4}\ $ ?
I have tried for the first few integers $\ n,m\ $ up until $\ m\approx30\ $ with no $\ n,m\ $ satisfying the inequality. However, I can't think of techniques for trying to prove it False. So I'm stuck.
Edit: To be honest, I'm not even sure, for example, how to try to  find $\ p,q\in\mathbb{N}_{\geq 2}\ $ such that $\ \lvert 5^p - 7^q \rvert < 10,\ $ which might be an easier type of problem (or harder? I'm not sure...).
Edit:
$$\left(\frac{3}{2}\right)^n - 2^m = \left(\left(\frac{3}{2}\right)^{n/m}\right)^m - 2^m = \left(\left(\frac{3}{2}\right)^{n/m} - 2 \right)\left( \left(\left(\frac{3}{2}\right)^{n/m} \right)^{m-1} + \left(\left(\frac{3}{2}\right)^{n/m} \right)^{m-2} \cdot 2 + \left(\left(\frac{3}{2}\right)^{n/m} \right)^{m-3} \cdot 2^2 + \ldots + \left(\left(\frac{3}{2}\right)^{n/m} \right)^{2} \cdot 2^{m-3} + \left(\left(\frac{3}{2}\right)^{n/m} \right) \cdot 2^{m-2} + \left(\left(\frac{3}{2}\right)^{n/m} \right) \cdot 2^{m-1} \right). $$
Since $\left(\frac{3}{2}\right)^{n/m}\ $ is close to $\ 2,\ $ we therefore have:
$$\left(\frac{3}{2}\right)^n - 2^m \approx \left(\left(\frac{3}{2}\right)^{n/m} - 2 \right)\left( 2^{m-1} +2^{m-2} \cdot 2 + 2^{m-3} \cdot 2^2 + \ldots +2^2 \cdot 2^{m-3} +2 \cdot 2^{m-2} + 2 \cdot 2^{m-1} \right) = \left(\left(\frac{3}{2}\right)^{n/m} - 2 \right)\cdot m \cdot 2^{m-1}.$$
I'm not sure if this helps, but maybe it relates to mjqxxxx's answer. Maybe this is what he/she means by "where "very close" means exponentially close as a function of that rational's denominator".
Edit: This is an open problem in number theory, so perhaps this means the question here is also an open problem?

A: I've very recently found a very nice formula giving a lower bound for your difference-term. Copying (& adapted) from my answer in another thread:

(...) Looking at old entries in my literature-database, I found an interesting limiting formula for a lower bound of $2^{n+m}-3^n$. Some short tinkering with it seem to show, that you can prove your conjecture for all $n+m > 27$ with it.
The formula is (W.J.Ellison cited in Stroeker/Tijdeman,'71): $$ \mid 2^x - 3^y \mid \gt \exp(x (\log 2- \frac1{10})) \qquad \text{for all } x,y \in \mathbb N  \quad \text{and } x\gt27 \quad \;^{[1]}\tag 1$$
This can be applied to your equation. By (1) we can write
$$ \mid 3^n - 2^{n+m} \mid \gt \mu ^{n+m} \qquad \text{where } \mu =1.80967483607...  \tag 2$$
(...)

and thus
$$  \underset{\text{for } n+m \gt 27}{ \underbrace{\mid 1.5^n - 2^{m} \mid \gt {\mu^{m+n} \over 2^n}}}    \quad \{\overset?\lt \frac14 \}  \tag 3$$
Now to compare this with your term $\frac14$ we look at logarithms.
For the following steps we assume first, that $m+n$ is such that $2^{m+n} \gt 3^n$ (case 1). (If it is $\lt$ then let us call this case 2 )
We'll write in the following  $ \gamma=\log_2(3) \approx 1.585$

*

*case 1: By logarithms we have $ (m+n ) \log 2 \gt n \log 3 $ and thus we must have $$m \gt n (\gamma-1) \approx n \cdot 0.585 \tag{case 1}$$
Now the logarithm of the rhs in (3) is $ (m+n)(\log2-0.1)-n\log2$
and this can be reduced to
$$  (m+n)(\log2-0.1)-n\log2 = m (\log 2-0.1) - 0.1n \approx 0.593m - 0.1 n \tag 4$$
which - with expanded $m$ - is:
$$  0.593  (0.585 n) - 0.1n \approx (0.347 - 0.1)n = 0.247 n $$
So the rhs in eq (3) is always greater than $0.247 n$ and of course this is for all $n$ larger than the $\log$ of your testvalue: $\log \frac14 \lt 0$.
Of course, since Ellison gave his low bound only for $(m+n) \gt 27$ and thus $n \gt 17$, all the comparision for the remaining cases $n=2..16$ must (and can) be done manually and give the same result: that there is no solution for your inequality.

*case 2: We have that $m$ must be decreased by at least $1$
$$m \lt n (\gamma-1) -1 \approx n \cdot 0.585 -1\tag{case 2}$$
We don't repeat the complete analysis here, just note, that the reduction of $m$ by $1$ gives
$$  0.593  (0.585 n-1) - 0.1n \approx (0.347 - 0.1)n -0.592 = 0.247 n - 0.593 $$
We get the same result, that for all $n \gt 1$ this is larger than $\log \frac14$ and by checking the cases $n=2..16$ we find as well no solution for your inequality.
Result: there are no cases $n \gt 1$ (resp $(n+m)\gt 3$) where your inequality holds, and your difference term in your first equation is for all $n \gt 1$ larger than the rhs.

$\;^{[1]}$The citation of formula (1) is from
R.J.STROEKER & R.TIJDEMAN
Diophantine equations (with appendix by P.L.Cijsouw, A.Korlaar & R.Tijdeman)
in: MATHEMATICAL CENTRE TRACTS 154, COMPUTATIONAL METHODS IN NUMBER THEORY; PART I;
MATHEMATISCH CENTRUM, AMSTERDAM  1982

and they attribute this result to W.J.Ellison in 1970/1971
[25] ELLISON,W.J., Recipes for solving diophantine problems by Baker's method,
Sèm.Th.Nombr.,1970-1971,Exp.No.11, Lab.Thèorie Nombres,
C.N.R.S.,Talence,1971.

A: If this were going to happen, then $\frac{\log 2}{\log {3/2}}$ would need to be very close to a rational number (where "very close" means exponentially close as a function of that rational's denominator).  In turn, that would mean that its continued fraction would need to have a large term early on.  Looking at that continued fraction, it doesn't: it starts with $[1;1,2,2,3,1,5,2,\ldots]$.  This is powerful evidence that there is no such $(m,n)$ pair, but falls short of a proof... I suspect all you can actually prove is that there aren't infinitely many such pairs.
As an example of what a more positive result would look like, suppose you wanted $|(5/2)^m - 2^n|$ to be small instead.  The continued fraction for $\log (5/2) / \log 2$ is $[1;3,9,\ldots]$; the truncation before the large term is $[1;3]=4/3$; and indeed $|(5/2)^3 - 2^4|=3/8$ is pretty small.

A: You can also use this (relies on Baker/Rhin): $2^n<2^l-3^n<3^n-2^n$, where the left inequality holds except for $n$ in $\{1,3,5\}$ and the right inequality holds except for $n$ in $\{2\}$ and $l={\lceil n \log_23\rceil}$ is the smallest exponent of $2$ making $2^l-3^n$ positive.
As stated by blamethelag, we can write your inequality like this:
$$ \lvert 3^n - 2^{m+n} \rvert < 2^{n-2}$$
What is next is similar to what Gottfried exposed in his answer (use of transcendence theory). There are 2 cases:

*

*case 1: $2^{m+n}>3^n$ and since $l$ is the smallest possible exponent "$m+n$" for this case we have
$$2^{m+n}-3^n\geq 2^l-3^n>0$$
and using the inequality from first line
$$2^{m+n}-3^n> 2^n>2^{n-2}$$
Note: that taking $2^{n-2}$ as reference removes the exception list mentioned in the introduction.

*case 2: $3^n>2^{m+n}$ and since $l-1$ is the largest possible exponent "$m+n$" for this case we have
$$3^n-2^{m+n}\geq 3^n-2^{l-1}>0$$
and using the inequality from first line
$$2^l-3^n<3^n-2^n$$
$$2\cdot 2^{l-1}-2\cdot 3^n<-2^n$$
$$3^n-2^{l-1}>2^{n-1}$$
you end up with
$$3^n-2^{m+n}>2^{n-1}>2^{n-2}$$
except for $n=2$ from the exception list where we can have equality
which leads to
$$ \lvert 3^n - 2^{m+n} \rvert \ge 2^{n-2}$$
or $\ \lvert \left(\frac{3}{2}\right)^n - 2^m \rvert \ge \frac{1}{4}\ $

A: This is not an answer but it is too long to be posted as a comment. If you multiply the inequality by $2^n$ it becomes
$$|3^n - 2^{m+n}| < 2^{n-2}.$$
Now fix $n \in \mathbb{N}$ and study $f : x \mapsto 3^n-2^{x+n}$, it is a decreasing function that has a unique zero at $x_* = n\log_2(3/2)$. So the minimum of $|f|$ on $\mathbb{N}$ is realized either at $\lceil x_* \rceil$ or at $\lfloor x_* \rfloor$ and you "only" need to give necessary conditions for it to be less than $2^{n-2}$.

A: Edited from prior incorrect answer:
Summary
At $m=n=2, f=\tfrac{1}{4}$, but it doesn't seem to go below that, and in fact gets large quickly as we count up in $n$ and use the minimizing value of $m$ for that $n$.
I'm relatively confident, but not certain, that there is no such number. See below.
Minimization Attempt
To first approach this, look for any minima in the function on a continuous domain and, if we find any, check the nearest natural numbers.
Find the critical points of $(\frac{3}{2})^n - 2^m$ and of it's inverse. Consider any min's of the former and maxes of the latter for any case $ \tfrac{-1}{4} < f < \tfrac{1}{4} $
$$f_n \equiv \frac{\partial f}{\partial n} = log (3/2) (3/2)^n$$ has no zero point but exists everywhere, so no critical point.
$f_m = -\log (2) 2^m$, same.
(If we had critical points, we'd check the sign of the $D=f_{xx}f_{yy} - f_{xy}^2$ at the m and n of the critical point(s) to see if min or max.)
We have no mins nor maxes in the range of interest.
Looking for Solutions
If the domain were continuous, one solution would be to set $$(\frac{3}{2})^n = 2^m \implies f=0$$
$$n \log(3/2) = m \log2 , m/n = \log(3/2)/\log(2)$$
With our problem, pick natural numbers to approximate that.
For any $n$, the best $m$ is $Round(n \log(3/2)/\log(2))$, where $Round()$ is rounding to the nearest natural number.
So, the best attempt at any $n$ for $f(m,n) is:
$$g(n)= |(\frac{3}{2})^n - 2^{(Round(n \log(3/2)/\log(2))}|$$
This also cannot be minimized or maximized, in this case because $g, g_n$  not continuous. This at least limits the $m,n$ space to search within, but cannot find a solution analytically.
Convergence?
One possible answer would be if this converged to some value less than 1/4. The needed convergence:
$$\lim_{n \to -\infty}  |(\frac{3}{2})^n - 2^{(Round(n \log(3/2)/\log(2))}|<\tfrac{1}{4}$$
If anyone can solve that I'd be impressed? Checking some high values, it appears to get big very fast. In fact, at $m=n=2, f=0.25$, and tends strongly to increase at higher $n$ (but not monotonically in $n$) and appears to diverge in the limit.
But I can't guarantee there isn't some very large, fortuitous $n$ that surprisingly works. Other conjectures in math, such as the Polya Conjecture, have held to very high numbers ($10^{300}$ in that case), only for a surprise nearly knife-edge counterexample to be found (~1.845 E365). And there may yet be an analytical solution out there for this problem.


text:
Q: How do I create a link in Windows 7 home premium as a regular user? I am a Linux guy and as such I am very lost when I try and do anything is Windows. I am trying to create the following link:
mklink /d C:\backup\data \\myth\backup\data

But I do not have sufficient privilege to preform this operation. How do I get sufficient privileges in Windows 7?
UPDATE:
Right clicked on C:\backup\data and changed the permissions to full access for authenticated user, restarted the machine and tried the command again with no luck. Anyone have any further suggestions?

A: The above solutions didn't work for me because not only could I not create a "guest" user on my machine, I can't possibly ask all the users of my tools to do so too on their machines. Nor is it reasonable to require they use Administrator consoles.
My solution is to use: elevate.cmd and elevate.vbs

*

*Download from: http://technet.microsoft.com/en-us/magazine/2008.06.elevation.aspx

*Put those two files on your system path (or somewhere convenient on the network)

*elevate.cmd cmd /c "cd /d LINK_DIR && mklink /D LINK_NAME LINK_TARGET_PATH"
Cons: elevate.cmd returns immediately but answering the UAC dialog takes time. This forced me to add a "did you ok the UAC dialog yet?" question to my script. It is possible to skip "elevate.cmd" by checking the exit code for the following command: whoami /groups | find "S-1-16-12288" (exit code 0 means you have an Adminstrator console).

A: I just discovered that I can create a 'Junction' even when I can't create a symlink:
mklink [/D] /J junctionname filename

where /J indicates 'create a junction', and the /D is, I believe, for if the named file is a directory. (my user is currently an administrator)
However, a junction to a 'bat' file doesn't seem to be executable, so this isn't actually any use.
Does anyone understand why this is, or how it can be fixed to provide an alternative approach to the OP's problem?

A: Came across this problem today as well.  I had a NAnt build task trying to create symbolic links on a computer.  Was getting rejected for lack of privileges. I found this post which helped solve my problem: http://josh.mainelan.net/tag/mklink/.
The relevant section:

*

*Bring up your run box, type "secpol.msc" and click OK.

*Navigate under the Security Settings \ Local Policies \ User Rights Assignment folder.

*Find "Create symbolic links" and add the Users group to it.

I think you need to restart your computer or something after doing this.

A: I found only a non administrator can do it. Add non administrator to create symbolic links and runas non administrator. You'll have to add a person of with non admin privileges. Then you give permission to the target for the non admin, so he can do the runas mklink.

A: As stated here,

Creation of symbolic links requires the SeCreateSymbolicLinkPrivilege ("Create symbolic links"), which is granted only to administrators by default (but you can change that using security policy).

To change the policies:

*

*Right click on Start→Run and launch secpol.msc.

*Open Security Settings → Local Policies → User Rights Assignment and select Create symbolic links (that represents SeCreateSymbolicLinkPrivilege).

*Double-click on the item and add yourself (or the whole Users group) to the list.

The changes will apply when you log out and log in again.

A: Run the command prompt as administrator to execute this command.
Type cmd (or command) in the start menu and right click on it and choose "run as an administrator".
Now any command that you execute will be executed with administrator privileges.

A: I'd recommend Ultimate Windows Tweaker. Use it to Select "Show Take Ownership" to get around the permissions issue, and "Show Open Command Window Here" to open command prompt at the correct folder.


text:
Q: Recent Payments List Problems I have ListView in my app and it shows us last payments. I am using like this in my body
myTransactions array includes last payments.
But when I open the recentpayments page, everytime this function working It adds the same array on top of the existing array and shows it.
T1
T2
T3
and when the T4 process comming and than after open the recent page I see:
T1
T2
T3
T1
T2
T3
T4
How can I solve this problem?
 ListView.separated(
          itemBuilder: (context, index) {
            return TransactionCard(transaction: myTransactions[index]);
          },
          separatorBuilder: (context, index) {
            return SizedBox(height: 10);
          },
          itemCount:
              (myTransactions.length > 5) ? 5 : myTransactions.length,
          shrinkWrap: true,
          physics: NeverScrollableScrollPhysics(),
        ),

And this is transaction card ui:
import "package:flutter/material.dart";
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:qr_code_payment/constants/app_textstyle.dart';
import 'package:qr_code_payment/data/transaction_data.dart';

class TransactionCard extends StatefulWidget {
  final TransactionModel transaction;
  const TransactionCard({Key? key, required this.transaction})
      : super(key: key);

  @override
  State<TransactionCard> createState() => _TransactionCardState();
}

class _TransactionCardState extends State<TransactionCard> {
  @override
  Widget build(BuildContext context) {
    return Container(
      //height: 30, cause of bug
      padding: EdgeInsets.all(10),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(20),
        border: Border.all(color: (Colors.grey[300])!),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Row(
            children: [
              Container(
                height: 60,
                width: 60,
                padding: EdgeInsets.all(5),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(20),
                  color: Color(0xFFFEC9EF),
                ),
                child: Image.asset(widget.transaction.avatar),
              ),
              SizedBox(
                width: 10,
              ),
              Column(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Text(widget.transaction.name,
                      style: ApptextStyle.LISTTILE_TITLE),
                  Text(
                    widget.transaction.month,
                    style: ApptextStyle.LISTTILE_SUB_TITLE,
                  ),
                ],
              )
            ],
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(widget.transaction.currentBalance,
                      style: ApptextStyle.LISTTILE_TITLE),
                  Row(
                    children: [
                      widget.transaction.changePercentageIndicator == "up"
                          ? Icon(FontAwesomeIcons.turnUp,
                              size: 10, color: Colors.green)
                          : Icon(FontAwesomeIcons.turnDown,
                              size: 10, color: Colors.red),
                      SizedBox(
                        width: 5,
                      ),
                      Text(
                        widget.transaction.changePercentage,
                        style: ApptextStyle.LISTTILE_SUB_TITLE,
                      ),
                    ],
                  )
                ],
              )
            ],
          )
        ],
      ),
    );
  }
}

When I add the recent payments in myTransactions, I call the createNewTransactionModel function:
This is TransactionModel:
import 'package:flutter/material.dart';

class TransactionModel {
  String name;
  String avatar;
  String currentBalance;
  String month;
  String changePercentageIndicator;
  String changePercentage;
  Color color;

  TransactionModel({
    required this.avatar,
    required this.changePercentage,
    required this.changePercentageIndicator,
    required this.currentBalance,
    required this.month,
    required this.name,
    required this.color,
  });
}

List<TransactionModel> myTransactions = [];

void addLastPaymentsTransactionModel(String currentBalance, String changedValue,
    String changeState, String changeDate, String productName) {
  createNewTransactionModel(
      currentBalance, changedValue, changeState, changeDate, productName);
}

void createNewTransactionModel(String currentBalance, String changedValue,
    String changeState, String changeDate, String productName) {
  String date = (changeDate.split("T"))[0].trim();
  myTransactions.add(TransactionModel(
    avatar: "assets/icons/avatar1.png",
    currentBalance: currentBalance,
    changePercentage: changedValue,
    changePercentageIndicator: changeState,
    month: date,
    name: productName,
    color: (Colors.deepPurple[100])!,
  ));
}

A: You always .add to your myTransactions list. You never clear it. It's no surprise that every time you get transactions, your list grows and grows and grows.
You have to reset it back to empty before you get the transactions and add them.


text:
Q: Bar of proportion of two variables I am having a pandas dataframe as shown below
import numpy as np

data = {
'id': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],
'baseline': [1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1],
'endline': [1, 0, np.nan, 1, 0, 0, 1, np.nan, 1, 0, 0, 1, 0, 0, 1, 0, np.nan, np.nan, 1, 0, 1, np.nan, 0, 1, 0, 1, 0, np.nan, 1, 0, np.nan, 0, 0, 0, np.nan, 1, np.nan, 1, np.nan, 0, np.nan, 1, 1, 0, 1, 1, 1, 0, 1, 1],
'gender': ['male', 'male', 'male', 'male', 'male', 'male', 'male', 'male', 'male', 'male', 'male', 'male', 'male', 'male', 'male', 'male', 'male', 'male', 'male', 'male', 'male', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'female']

}

df = pd.DataFrame(data)
df.head(n = 5)

The challenge is the endline column may have some missing values. My goal is to have 2 bars for each variable side by side as shown below.

Thanks in advance!

A: Seaborn prefers its data in "long form". Pandas' melt can convert the given dataframe to combine the 'baseline' and 'endline' columns.
By default, sns.barplot shows the mean when there are multiple y-values belonging to the same x-value. You can use a different estimator, e.g. summing the values and dividing by the number of values to get a percentage.
Here is some code to get you started:
import matplotlib.pyplot as plt
from matplotlib.ticker import PercentFormatter
import seaborn as sns
import pandas as pd
import numpy as np

data = {
'id': range(1, 51),
'baseline': [1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1],
'endline': [1, 0, np.nan, 1, 0, 0, 1, np.nan, 1, 0, 0, 1, 0, 0, 1, 0, np.nan, np.nan, 1, 0, 1, np.nan, 0, 1, 0, 1, 0, np.nan, 1, 0, np.nan, 0, 0, 0, np.nan, 1, np.nan, 1, np.nan, 0, np.nan, 1, 1, 0, 1, 1, 1, 0, 1, 1]
}
df = pd.DataFrame(data)

sns.set_style('white')
ax = sns.barplot(data=df.melt(value_vars=['baseline', 'endline']),
                 x='variable', y='value',
                 estimator=lambda x: np.sum(x) / np.size(x) * 100, ci=None,
                 color='cornflowerblue')
ax.bar_label(ax.containers[0], fmt='%.1f %%', fontsize=20)

sns.despine(ax=ax, left=True)
ax.grid(True, axis='y')
ax.yaxis.set_major_formatter(PercentFormatter(100))
ax.set_xlabel('')
ax.set_ylabel('')
plt.tight_layout()
plt.show()


text:
Q: Is there any way to know from which domain the socket.io connection is coming from? I would like to know from which domain a socket.io client is connnected from.
io.on('connection', function(socket) {
    // I want to know from which domain this client is connected from, in here...
});


text:
Q: OpenGL - Draw object with image texture from .obj/.mtl I'm attempting to create a cube with an image texture using OpenGL with Google Cardboard for Android. My code is largely based off of Google's demo code here. I can render the black/texture-less cube just fine, but the texture is what has me stuck.

FILES
Here is the .obj file:
mtllib 9c9ab3c3-ea26-4524-88f5-a524b6bb6057.mtl

g Mesh1 Model

usemtl Tile_Hexagon_White
v 2.16011 0 -2.27458
vt -7.08697 8.39536
vn 0 -1 -0
v 1.16011 0 -1.27458
vt -3.80613 4.70441
v 1.16011 0 -2.27458
vt -3.80613 8.39536
f 1/1/1 2/2/1 3/3/1

v 2.16011 0 -1.27458
vt -7.08697 4.70441
f 2/2/1 1/1/1 4/4/1

vt 7.46254 0
vn 1 0 -0
v 2.16011 1 -1.27458
vt 4.1817 3.69094
vt 4.1817 0
f 1/5/2 5/6/2 4/7/2

v 2.16011 1 -2.27458
vt 7.46254 3.69094
f 5/6/2 1/5/2 6/8/2

vt -7.08697 0
vn 0 0 -1
v 1.16011 1 -2.27458
vt -3.80613 3.69094
vt -7.08697 3.69094
f 1/9/3 7/10/3 6/11/3

vt -3.80613 0
f 7/10/3 1/9/3 3/12/3

vt -4.1817 0
vn -1 0 -0
vt -7.46254 3.69094
vt -7.46254 0
f 2/13/4 7/14/4 3/15/4

v 1.16011 1 -1.27458
vt -4.1817 3.69094
f 7/14/4 2/13/4 8/16/4

vt 3.80613 0
vn 0 0 1
vt 7.08697 3.69094
vt 3.80613 3.69094
f 2/17/5 5/18/5 8/19/5

vt 7.08697 0
f 5/18/5 2/17/5 4/20/5

vt 7.08697 4.70441
vn 0 1 -0
vt 3.80613 8.39536
vt 3.80613 4.70441
f 5/21/6 7/22/6 8/23/6

vt 7.08697 8.39536
f 7/22/6 5/21/6 6/24/6

And here is the .mtl file:
newmtl Tile_Hexagon_White
Ka 0.000000 0.000000 0.000000
Kd 0.835294 0.807843 0.800000
Ks 0.330000 0.330000 0.330000
map_Kd 9c9ab3c3-ea26-4524-88f5-a524b6bb6057/Tile_Hexagon_White.jpg

newmtl ForegroundColor
Ka 0.000000 0.000000 0.000000
Kd 0.000000 0.000000 0.000000
Ks 0.330000 0.330000 0.330000

The texture is just a repeating hexagonal pattern that I want to cover the entire cube:

CODE

*

*Load the OBJ file and separate the data into arrays.

I have Vertices_[108], UV_[72], and Indices_[36]. I am confident that the program is functioning properly at this point, but I can provide the values if necessary.

*I load the image after:

GLuint texture_id;
    glGenTextures(1, &texture_id);

    imageNum = texture_id;

    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, imageNum);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    /*I don't really know how this block of code works but it's supposed to Load an image from the asset manager.
     * env - the JNIEnv* environment
     * java_asset_mgr - AAssetManager for fetching files
     * path - the path and name of my texture
     */
    jclass bitmap_factory_class =
            env->FindClass("android/graphics/BitmapFactory");
    jclass asset_manager_class =
            env->FindClass("android/content/res/AssetManager");
    jclass gl_utils_class = env->FindClass("android/opengl/GLUtils");
    jmethodID decode_stream_method = env->GetStaticMethodID(
            bitmap_factory_class, "decodeStream",
            "(Ljava/io/InputStream;)Landroid/graphics/Bitmap;");
    jmethodID open_method = env->GetMethodID(
            asset_manager_class, "open", "(Ljava/lang/String;)Ljava/io/InputStream;");
    jmethodID tex_image_2d_method = env->GetStaticMethodID(
            gl_utils_class, "texImage2D", "(IILandroid/graphics/Bitmap;I)V");

    jstring j_path = env->NewStringUTF(path.c_str());
    RunAtEndOfScope cleanup_j_path([&] {
        if (j_path) {
          env->DeleteLocalRef(j_path);
        }
    });

    jobject image_stream =
            env->CallObjectMethod(java_asset_mgr, open_method, j_path);
    jobject image_obj = env->CallStaticObjectMethod(
            bitmap_factory_class, decode_stream_method, image_stream);

    env->CallStaticVoidMethod(gl_utils_class, tex_image_2d_method, GL_TEXTURE_2D, 0,
                              image_obj, 0);

    glGenerateMipmap(GL_TEXTURE_2D);

*Draw:

  //obj_program has a vertex shader and fragment shader attached.
  glUseProgram(obj_program_);

  std::array<float, 16> target_array = modelview_projection_target_.ToGlArray();
  glUniformMatrix4fv(obj_modelview_projection_param_, 1, GL_FALSE,
                     target_array.data());

  glActiveTexture(GL_TEXTURE0);
  glBindTexture(GL_TEXTURE_2D, imageNum);

  //DRAW
  glEnableVertexAttribArray(0);
  glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, Vertices_.data());

  glEnableVertexAttribArray(1);
  glVertexAttribPointer(1, 2, GL_FLOAT, false, 0, Uv_.data());

  glDrawElements(GL_TRIANGLES, Indices_.size(), GL_UNSIGNED_SHORT,
                 Indices_.data());

RESULT
I end up with a cube that is oddly textured and I am unsure what is causing it.

I am sure there will be questions so I will do my best to answer and provide any information that will help!

A: The issue was that my texture needed to be repeated. These two lines were changed from
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

to
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);


text:
Q: How does Jorah know who this is? In Game of Thrones season 5 episode 3, "High Sparrow," we see:

 Tyrion and Varys, on their way to see Daenerys Targaryen, stop by a brothel in Volantis where Tyrion is kidnapped by Jorah Mormont. How did Jorah know this was Tyrion Lannister and not some random dwarf? Jorah fled Westeros decades ago, so there is no way he would know what Tyrion would look like.

A: The only possible location where Jorah Mormont could have met

Tyrion Lannister

is the Tourney at Lannisport, where Jorah Mormont came out victorious, in the final he broke nine lances against Ser Jaime Lannister. This event is described in the Books. And in GoT season 5 episode 6, when Jorah and

 Tyrion are taken captive by slavers, Tyrion claims that Jorah unseated Jaime Lannister in a jousting match.

A: Jorah didn't flee Westeros "decades ago". He was a hero in the Greyjoy Rebellion, only nine years before the start of the series. Since the Lannisters also played a major part in that war, it doesn't seem unlikely that Jorah might have seen or even met a younger Tyrion. If Tyrion is the same age as Peter Dinklage, then he was 31 during the Greyjoy Rebellion and 40 at the start of the series.

A: Soft spoiler from the 5. SOIAF book (and the mentioned episode)

 The answer might be that in the series Tyrion is a lot less characteristic than in the books. In the books by this time he literally has no nose and I guess a blonde midget with no nose who drinks a lot, behaves like he owns the place, and speaks the common tongue of Westeros is not a common sight. Also there is a huge bounty on Tyrion's head and he surely fled fron the Seven Kingdoms, so I guess it is just basic logic.

A: Jorah was

expelled from Danaerys' circle for having been an informant to Westeros.

He may have more ties to the West than we're inclined to believe.
Not to mention the points mentioned above:

 the bounty on Tyrion's head across the known world, his disfigurement and his accent when speaking Valyrian.


text:
Q: Ejabberd 16.09 Muc Discovery We're using IOS XMPP Framework and Android Smack Library to connect our ejabberd server in our mobile application.
Both of them has the similar problem.
When we create the room as admin, we add users to member list by sending ejabberd
<item affiliation='member' jid='xxx@yyy.com'>

Then users can send and receive messages to group without any problem.
And if a user removes the app from device and reinstall it, we are using muc discovery protocol to discover which rooms he/she were joined before he/she uninstall the app
However there is a problem at this point, If a user uses the muc discovery when all the participants of the group became offline. Server doesn't return muc discovery result about that group to user as he/she is a participant of it.
And when I check the admin console those groups seems to have 0 participants(Because all the participants are offline, but they are in the memberlist). And I think muc discovery returns only the groups which have more than 0 participants
Does anyone know why does it happen and how can I find a solution to that? @badlop
We're using ejabberd 16.09

A: Muc says if user goes offline then he should left all his group, that is why you are not getting group participant when users goes offline.
See here
http://xmpp.org/extensions/xep-0045.html
Instead of using muc use muc-light
https://xmpp.org/extensions/inbox/muc-light.html
It will help you resolve issue and its very easy to implement.


text:
Q: Boost graph: How to copy the nodes and edges of a graph without copying properties? I am using boost graph with bundled properties. After I build the first reference tree. I would like to have several other trees with the same structure and hierarchy but with different vertex and edge property. I find there is a copy_graph method but don't know how to achieve my purpose using this.
For example, I first create a reference tree, VertexProperty1 and EdgeProperty1 are bundled properties
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VertexProperty1, EdgeProperty1> Graph;
Graph g1;

After some processing, g1 contains some vertices and edges.
Then I would want to have a copied tree with different bundled properties.
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VertexProperty2, EdgeProperty2> Graph2;
copy_graph(g1, g2, ???);

Thanks in advance for any kind help. Example code would be preferred.

A: If you look at the documentation you can see that the parameters vertex_copy and edge_copy are the ones that actually copy the properties. The default value for those parameters copy all the properties in every vertex/edge, you need something that "does nothing" instead:
struct do_nothing
{
    template <typename VertexOrEdge1, typename VertexOrEdge2>
    void operator()(const VertexOrEdge1& , VertexOrEdge2& ) const
    {
    }
};

And then invoke copy_graph like this:
copy_graph(g1,g2,boost::vertex_copy(do_nothing()).edge_copy(do_nothing()));

Running on Coliru
#include <iostream>
#include <string>

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/copy.hpp>
#include <boost/graph/graph_utility.hpp>

struct VertexProp1
{
    int color;
};

struct VertexProp2
{
    std::string name;
};

struct EdgeProp1
{
    double weight;
};

struct EdgeProp2
{
    std::string name;
};

typedef boost::adjacency_list<boost::vecS,boost::vecS,boost::bidirectionalS,VertexProp1,EdgeProp1> Graph1;
typedef boost::graph_traits<Graph1>::vertex_descriptor VertexDesc;

typedef boost::adjacency_list<boost::vecS,boost::vecS,boost::bidirectionalS,VertexProp2,EdgeProp2> Graph2;

struct do_nothing
{
    template <typename VertexOrEdge1, typename VertexOrEdge2>
    void operator()(const VertexOrEdge1& , VertexOrEdge2& ) const
    {
    }
};

void build_graph(Graph1& g)
{
    VertexDesc v0=add_vertex(VertexProp1{1},g);
    VertexDesc v1=add_vertex(VertexProp1{2},g);
    VertexDesc v2=add_vertex(VertexProp1{3},g);
    add_edge(v0,v1,EdgeProp1{1.0},g);
    add_edge(v1,v2,EdgeProp1{2.0},g);
    add_edge(v2,v0,EdgeProp1{3.0},g);

}

int main()
{
    Graph1 g1;
    build_graph(g1);

    std::cout << "Graph1" << std::endl;
    print_graph(g1);

    Graph2 g2;

    copy_graph(g1,g2,boost::vertex_copy(do_nothing()).edge_copy(do_nothing()));

    std::cout << "Graph2" << std::endl;
    print_graph(g2);

}


text:
Q: Rails - how to validate one field against another for dates I think this is a simple question. In my app, I have a model where users select a 'start' date and a 'stop' date when submitting a new record. The dates are only the years, excluding month and day.
I just want to write a validation to ensure that the stop date is greater than the start date, so you can't submit something that started in 2012 and ended in 2008. How would I do that?
My form fields are below:
<%= select_year Date.today, start_year: Time.now.year, end_year: Time.now.year - 95, field_name: :start %>

<%= select_year Date.today, start_year: Time.now.year, end_year: Time.now.year - 95, field_name: :stop %>

A: If you want to do a server side validation, you could add validation to your model
validate :stop_date

def stop_date
  errors.add(:stop, "stop date cannot be older than start date") if stop < end
end

You could populate the errors on the view.


text:
Q: How do I prevent VNC from automatically coping selected text? Whenever I select any text the text is immediately copied to the clipboard without me explicitly issuing copy text command. How do I fix this bug or feature?
I am using RealVNC client. The server is running IceWM.

A: *

*Open ~/.vnc/xstartup

*Change the vncconfig line to include SendPrimary=0 (e.g. vncconfig SendPrimary=0 –nowin &)

*Restart your VNC sessions

How it works:

*

*vncconfig is a program that manages shared functionality between the x11 server and your VNC session, most notably shared clipboard functionality. Without this running in the background, you cannot share a clipboard.

*X11 maintains a concept of a "primary" buffer (for selected text) and a "clipboard" buffer

*SendPrimary defaults to 1 (on) which instructs vncconfig to send the primary (selection) buffer to the clipboard buffer, in effect overwriting anything there


text:
Q: Do Scala Sparc RDDs allow objects with reference members I am in the early stages of designing an application using Sparc RDDs (which I don't understand yet). The RDD will contain a large number of objects which in turn contain references to a small number (100) of somewhat large (0.5MB) objects which are immutable.
The operations to be mapped over the RDD will call member functions on the objects which in turn call member functions on the references.
Is this possible in principle?

A: Spark (not sparc) data will normally be passed around using java serialization (unless you configure it to use kyro). I think this will do the right thing with the large objects. If you're willing to customize your data a bit it might be best to use broadcast variables for the large immutable objects.

A: I think this goes against the ethos of Sparks as distributed functional programming.
I think you would be better served re-tooling your domain model in terms of the primitives of map, filtering and reducing. Reasoning about the effects of calling these functions seems difficult.
Also, if they are immutable what is the side-effect of calling methods on them?


text:
Q: Jmeter and vpn connection I have an app on mobile which runs through VPN connection . I am doing performance testing using jmeter on desktop for which I have done necessary configurations  but http proxy server does not record my http requests
Can anyone help on this

A: JMeter and mobile device need to be on the same network in order for JMeter to be able to capture mobile device traffic. So the easiest option would be connecting desktop to the same VPN and using VPN-originated IP addresses.
You will also need to install JMeter's self-signed certificate, the relevant file is ApacheJMeterTemporaryRootCA.crt, it's being generated in JMeter's "bin" folder when you start HTTP(S) Test Script Recorder. The easiest way to get the certificate installed onto mobile device is sending it to yourself by email, opening the email on the mobile device and following system dialog to install the certificate.
References:

*

*HTTPS recording and certificates

*JMeter Proxy Step by Step

There is also an alternative solution for recording native and hybrid mobile applications traffic. Using it you won't have to bother about proxies and certificates. As a little bonus, this 3rd-party JMeter Cloud recorder has "SmartJMX" mode with automatic correlations of any dynamic parameters so you won't have to extract them yourself. See How to Cut Your JMeter Scripting Time by 80% guide for details.


text:
Q: Trying to install apps directly to SDK with ADB. However, it doesn't detect my galaxy ace. Any advice? I already restarted server in the console, and I installed all SDK tools packages.
It just doesn't detect the phone.
It says:
C:\Program Files <x86>\Android\plataform tools>adb devices
List of devices attached.    (there's nothing here)

Oh, BTW, I'm using Windows 7 64 bit Premiun
UPDATE 1: Installing kies and the usb drivers from samsung. Thanks for the reccommendation
 SuNnY_sYeD
UDATE 2: Finished installing and started running adb console and detected the device. Apparently, it detected SOMETHING at least, because now it says :

0123456789ABCDEF device.

A: I think I had this same issue earlier today with my Nexus 7. I had to download a specific driver for it.  Here is the website that should guide you in the right direction.
http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver
There is also a special note for Galaxy devices on the site:
Note: If your device is one of the Android Developer Phones (ADP), a Nexus One, or a Nexus S, then you need the Google USB Driver, instead of an OEM driver. The Galaxy Nexus driver, however, is distributed by Samsung (listed as model SCH-I515).
Hopefully this helps.
Edit:
Also, if you are using a Google device on Windows, this page is where you might want to start.
http://developer.android.com/sdk/win-usb.html

A: Well step one is downloading the driver for your device which can be found here samsung.com/sg/support/model/… then see if adb is picking up your device


text:
Q: connect not listening to the state update in React Component I'm using React and Redux in my application. I wanted to show confirmationDialog in my app and I want it in such a way that an action is fired from some component, it updates my redux state and then the confirmationDialog would listen to that state and open itself up. The code of confirmationDialog is :
import React from 'react';
import {connect} from 'react-redux';
import PropTypes from 'prop-types';

import Dialog from 'material-ui/Dialog';
import RaisedButton from 'material-ui/RaisedButton';
import {hideConfirmationDialog} from '../../../actions/globalActions';
import {getConfirmationDialogState} from '../../../selectors/globalSelectors';

/**
 * A modal dialog can only be closed by selecting one of the actions.
 */
class DialogBox extends React.Component {
  render() {
    const props = this.props,
      actions = [
        <RaisedButton
          label={props.cancelLabel}
          secondary
          onClick={props.onCancel}
        />,
        <RaisedButton
          label={props.submitLabel}
          primary
          onClick={props.onSubmit}
          className="ml-4"
        />,
      ];

    return (
      <Dialog
        title={props.title}
        actions={actions}
        modal
        autoScrollBodyContent={props.autoScrollBodyContent}
        open={props.show}
      >
        {props.message || props.children}
      </Dialog>
    );
  }
}

DialogBox.propTypes = {
  onCancel: PropTypes.func,
  onSubmit: PropTypes.func,
  show: PropTypes.bool,
  submitLabel: PropTypes.string,
  cancelLabel: PropTypes.string,
  autoScrollBodyContent: PropTypes.bool,
};

DialogBox.defaultProps = {
  submitLabel: __('Submit'),
  cancelLabel: __('Cancel'),
  autoScrollBodyContent: true,
};

const ConnectedConfirmationDialog = connect(getConfirmationDialogState, { hideConfirmationDialog })(DialogBox);

export default ConnectedConfirmationDialog;

export {DialogBox};

Here getConfirmationDialogState is a selector to get the confirmation dialog state from my reducer.
I'd call my confirmation dialog as :
showDialog({
            title: 'Delete Entities',
            message: 'Delete selected entities',
            onSubmit: _.noop,
            onCancel: _.noop,
          });

The showDialog function is defined in a util which would dispatch and action such that:
const buildConfirmationDialogAction = ({ title, message, onSubmit, onCancel }) => (
  Store.dispatch(showConfirmationDialog({
    onSubmit,
    title,
    onCancel,
    message,
  }))
);

export const showDialog = params => buildConfirmationDialogAction(params);

The corresponding action would update the state. the state is getting updated but the getConfirmationDialog in my component is not getting called and show the component is not getting re-rendered. I've no clue now why connect is not listening to mapStateToProps.

A: I hadn't rendered the confirmation dialog in my app file. As the component wasn't rendered, it wouldn't listen to the state updation. So, in the starting file, I did :
 render() {
    const that = this,
      props = that.props,
      alert = props.alert || {};

    return (

        <DocumentTitle title={DOORCERY_TITLE}>
          <MuiThemeProvider muiTheme={doorceryTheme}>

              <ConfirmationDialog
                show={false}
              />
              {props.children}

          </MuiThemeProvider>
        </DocumentTitle>

    );
  }


text: Q: How can i create cicular progress with an icon inside stroke and it will change dynamically with Html CSS or in React I want to create an circular progress bar exactly like this. But how can i create an icon inside progress and put dynamic value? I'm using react for this project.


text:
Q: fontconfig-infinality causes 13.04 boot failure I upgraded my travel notebook (Asus VivoBook X202E 11.6" Touch Screen, but minimal video,  1366x768 as I recall) from ubuntu 12.10 to ubuntu 13.04. Everything worked perfectly, But then I Thought I would make some minor enhancements. did:
sudo add-apt-repository ppa:no1wantdthisname/ppa
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install fontconfig-infinality

no install errors.
rebooted
no mouse cursor
dialog box gives options to run in low resolution
neither keyboard or mouse does anything
There are no other (i.e. Linux, Win8 or Win7 boot partitions on this netbook)
booted with a 12.10 install USB,  tried to remove fontconfig-infinality,  but it seems not to be installed (guess all it showed was packages loaded from the USB)
I need a way to 'get in' and undo the effects of "sudo apt-get install fontconfig-infinality"

A: Boot into recovery mode like this, and then when it gives you root@computername~#, type apt-get purge fontconfig-infinality then add-apt-repository -r ppa:no1wantdthisname/ppa. This should completely remove fontconfig-infinality from your system, along with its PPA.

A: There is a way to solve this, just update the init script for System V for Display Manager in Ubuntu:
sudo update-rc.d -f lightdm remove
sudo update-rc.d lightdm defaults

Original answer is for mdm.

A: I got help from this in Mint17 MATE: just changed "-r " with "-rm" to remove repository. All else was the same as the initial problem was the same.
I looked for some time before i found this and was able to fix the boot problem
and the mdm failure.
I got into the recovery mode and had to get to the 'drop to shell.. and  mount -o remount,rw /. I had been trying to execute the commands from entering them and got the read only error and was stuck till i found this and the ubuntu wiki for recovery.


text:
Q: Unable to save and exit an editor I open new window by typing crontab -e in terminal. After that I placed this line at the bottom.
0 5 * * * /home/myname/scripts/do-every-day.sh

But I cannot save and exit by pressing Esc, :wq and enter!
 I type Esc, then :, I get Unknown command. Then I type wq, the wq display beside .sh. When press enter it goes to new line!!!

A: I managed to solve it. As I'm opening the nano editor, in order to save, it is not using :wq. Instead, it use ctrl+x(exit) and it will ask you to save. Press Y to save.


text:
Q: JavaScript get TextArea input via .value or .innerHTML? Is it ok to get the value of a textarea element in JavaScript with myTextArea.value or should I use myTextArea.innerHTML?
Thank you.

A: You should use .value
myTextArea.value

A: For div and span, you can use innerHTML, but for textarea use value. Please see the example below.

<textarea id="textArea"></textArea>

A: One difference is that you can use HTML entities with .innerHTML

document.getElementById('t1').innerHTML = '<>&';
document.getElementById('t2').value = '<>&';
<textarea id="t1"></textarea>
<textarea id="t2"></textarea>

A: Don't use innerHTML use value e.g. document.getElementById(name).value

A: The answer depends on your situation.
I would personally use .value as that's what the other form inputs provide. It's easier to be in the habit of doing it that way.


text:
Q: Putting info on the right side of a tab in a vertical format I'm using Angular-ui for bootstrap (https://angular-ui.github.io/bootstrap/) and for the tabs, if I want to use the vertical version of it, the text always appears on the bottom. How do I make the text appear on the right side of the tabs?
Code... (taken straight from the website)
<tabset vertical="true" type="pills">
    <tab heading="Vertical 1">Vertical content 1</tab>
    <tab heading="Vertical 2">Vertical content 2</tab>
</tabset>


text:
Q: How do I escape single quotes in a django-widget-tweaks's render_field tag? I'm trying to use django-widget-tweaks to render the following form field:
{% render_field profile_form.bio class+="form-control" id="bio" rows="3" oninput="showBtn('updateProfile')" %}

Into this:
<textarea class="form-control" id="bio" rows="3" oninput="showBtn('updateProfile')"></textarea>

However, I'm getting a parsing error as Django is changing the single quotes in the widget into double quotes.
The showBtn js function is as follows:
// Shows a button given an id
showBtn: function (selector) {
  let btn = document.getElementById(selector);
  btn.classList.remove("btn-hidden");
}

The reason why I use django-widget-tweaks is to keep all html classes and attributes isolated in the templates.
What I already tried:

*

*representing the single quote as text entity '. It renders the template (no parsing error), but does't actually replace the ascii into quotes so the js is never triggered

*escaping with slashes

*using the safe templatetag

*using the autoescape templatetag

For reference, here is the form model:
# forms.py
class ProfileForm(forms.ModelForm):
    class Meta:
        model = Profile
        fields = ["bio"]

And the original model:
# models.py
class Profile(models.Model):
    """ Non-auth related user information about an user"""
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    bio = models.TextField(max_length=500, blank=True)

A: Ok... so this is how I eventually solved it.
Instead of using a syntax similar to plain HTML attributes (which is why I liked django-widget-tweaks in the first place), the packages' templatetags works. But this like a workaround for some bug  django-widget-tweaks has.
{% render_field profile_form.bio|add_class:"form-control"|attr:"id:bio"|attr:"rows:3"|attr:"oninput:showBtn('updateProfile')" %}

This way the oninput attribute is parsed correctly.


text:
Q: Change only the DataValueField of a Listbox? I have a Listbox
dimension.DataSource = provider.DimensionList;
dimension.DataBind();

I want the value to be the ID of these elements
dimension.DataSource = provider.DimensionList;
dimension.DataValueField = "ID";
dimension.DataBind();

But I don't want the text to change to the ID, I want that the dimension.DataTextField gets the object.ToString().
How can this be done?

A: I don't know exactly the type of the DimensionList, but I believe that you could use a select that will return an anonymous type:
dimension.DataSource = provider.DimensionList.Select(d=>new {Id=d.Id,Text=d.ToString()}).ToList();
dimension.DataValueField = "Id";
dimension.DataTextField = "Text";
dimension.DataBind();


text:
Q: How to check the permission whether a friend allow me to post on his wall or not using php sdk I have created an app that needs to check whether a friend allows a user to post on his/her wall or not before posting content on friend's wall. This scenario is required because I need to disable the submit button when the user chooses that friend to post the content if the user doesn't have permission.

A: You need to ask for publish_stream permissions when someone uses your app. These links give more info.
PHP SDK http://developers.facebook.com/docs/reference/php/
FB permissions: http://developers.facebook.com/docs/reference/api/permissions/
Tutorial for connecting to FB including asking for permissions: http://thinkdiff.net/facebook/php-sdk-3-0-graph-api-base-facebook-connect-tutorial/
If you need further help, please ask more specific questions as it is very difficult to give helpful answers to vague questions such as this.


text:
Q: Help me improve my continuous deployment workflow I've been developing a workflow for practicing a mostly automated continuous deployment cycle for a PHP project. I'd like some feedback on possible process or technical bottlenecks in this workflow, suggestions for improvement, and ideas for how to better automate and increase the ease-of-use for my team.

Core components:

*

*Hudson CI server

*Git and GitHub

*PHPUnit unit tests

*Selenium RC

*Sauce OnDemand for automated, cross-browser, cloud testing with Selenium RC

*Puppet for automating test server deployments

*Gerrit for Git code review

*Gerrit Trigger for Hudson

EDIT: I've changed the workflow graphic to take ircmaxwell's contributions into account by: removing PHPUnit's extension for Selenium RC and running those tests only as part of the QC stage; adding a QC stage; moving UI testing after code review but before merges; moving merges after the QC stage; moving deployment after the merge.
This workflow graphic describes the process. My questions / thoughts / concerns follow.

My concerns / thoughts / questions:

*

*Overall difficulty using this system.

*Time involvement.

*Difficulty employing Gerrit.

*Difficulty employing Puppet.

*We'll be deploying on Amazon EC2 instances later. If we're going about setting up Debian packages with Puppet and deploying to Linode slices now, is there a potential for a working deployment on Linode to break on EC2? Should we instead be doing our builds and deployments on EC2 from the get-go?

*Another question re: EC2 and Puppet. We're also considering using Scalr as a solution. Would it make as much sense to avoid the overhead of Puppet for this alone and invest in Scalr instead? I have a secondary (ha!) concern here about cost; the Selenium tests shouldn't be running that often that EC2 build instances will be running 24/7, but for something like a five-minute build, paying for an hour of EC2 usage seems a bit much.

*Possible process bottlenecks on merges.

*Could "A" be moved?
Credits: Portions of this workflow are inspired by Digg's awesome post on continuous deployment. The workflow graphic above is inspired by the Android OS Project.

A: Importent to make your tests extremely fast, i.e. no IO and ability to run parallel and distributed tests. Don't know how applicable it is with php, but if you can test units of code with in memory db and mock the environment you'll be better off.
If you have a QA/QC or any human in the way between the commit and production you would have a problem getting to a full continuous deployment. The key is your trust your testing, monitoring and auto response (immune system) enough to eliminate error prone process evolving humans from your system.

A: All handovers between functions have the effect of slowing things down, and with that, an increase of the amount of change (and hence risk) that goes in to a deployment.
Manual quality gates are by definition an acceptance that quality has not been built in from the start. The only reason code needs to be reviewed later is because there is some belief that the quality is not good enough already.
I'm currently trying to remove formal code review from our pipelines for exactly this reason. It causes feedback delays, and quoting Martin Fowler:
"The whole point of Continuous Integration is to provide rapid feedback. Nothing sucks the blood of a CI activity more than a build that takes a long time. "
Instead I'd like to make code review something that submitters request if required, or otherwise is done at the time of coding by team members, perhaps a la XP pair programming.
I think it should be your goal that once the code is merged to source control, that there is absolutely no more manual intervention.

A: How many people are working on it?  If you only have maybe 10 or 20 developers, I'm not sure it will make sense to put such an elaborate workflow into place.  If you're managing 500, sure...
My personal feeling is KISS.  Keep It Simple, Stupid... You want a process that's both efficient, and more important: simple.  If it's complicated, either nobody is going to do it right, or after time parts will slip.  If you make it simple, it will become second nature and after a few weeks nobody would question the process (Well, the semantics of it anyway)...
And the other personal feeling is always run all of your UNIT tests.  That way, you can skip a whole decision tree in your flow chart.  After all, what's more expensive, a few minutes of CPU time, or the brain cycles to understand the difference between the partial test passing and the massive test failing.  Remember, a fail is a fail, and there's no practical reason that code should ever be shown to a reviewer that has the potential to fail the build.
Now, Selenium tests are typically quite expensive, so I might agree to push those off until after the reviewer approves.  But you'll need to think about that one...
Oh, and if I was implementing this, I would put a formal QC stage in there.  I want human testers to look at any changes that are being made.  Yes, Selenium can verify the things you know about, but only a human can find things you didn't think of.  Feed back their findings into new Selenium and Integration tests to prevent regressions...

A: I don't know whether this is relevant to PHP, but you can replace at least at least some of the code review stage with static analysis.
The quality of code reviews is relying on the quality of the reviewers, while static analysis relies on best practices and patterns, and is fully automatic. I'm not saying that code reviews should be abandoned, I simply think it can be done off-line.
See
http://en.wikipedia.org/wiki/Static_code_analysis
http://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis


text:
Q: add result/count if is_product_tag - woocommerce Hi I'm customizing a wordpress theme which did not have breadcrumbs and sort by functionality on the tag archive pages. i've found a workaround with some custom css/php to make this work but I'm struggling with the result/count loop.
So far I've added following to their custom category.php in my child themes folder which is working fine:

<?php if(is_product_tag()) woocommerce_breadcrumb(); ?>

<?php if(is_product_tag()) woocommerce_catalog_ordering(); ?>

Any suggestions on what code to add in order for the result count also to be visible only when on a tag archive page?

A: Figured it out by adding
<?php if(is_product_tag()) woocommerce_result_count(); ?>


text:
Q: Switch angularjs template based on type I'm showing a grid box based on data and based on property "type"
i'm trying to loop using ng-repeat and load templates based on "type"
For example we have type 1,2,3,4 and html files like 1.html,2.html,3.html,4.html
what is the best way to load the template url based on  "type" value,

A: The best way to do this would be to use $routeProvider, if i understand your question correctly some thing like this:
$routeProvider
    .when('/1', {
        templateUrl: '1.html',
        controller: 1Ctrl
    }).when('/2', {
        templateUrl: '2.html',
        controller: 2Ctrl
    }).when('/3', {
        templateUrl: '3.html',
        controller: 3Ctrl
    }).when('/4', {
        templateUrl: '4.html',
        controller: 4Ctrl
    }).otherwise({redirectTo: '/1'})

Edit Yes I understand that symbol names cant start with a number, however this was stubbed fro OP code specs in question.


text:
Q: 0-N relation using entity framework thanks in advance for your support.
Im using Entity framework in an mvc5 application.
The way im working with database is:
I create a model class with table atributes for example:
 public class Article
    {
        public int ID { get; set; }

        public string Name { get; set; }
    }

Then I use Scaffolding system to generate controller and views.
When I have a foreign key in my table I use this:
 public class Article
    {
        public int ID { get; set; }

        public string Name { get; set; }

        public int ProviderID {get; set;}

        public virtual Provider Providers { get; set; }
    }

Everything is working fine. When I access to the view, tables are being automatically created with relations, keys, foreignkeys properly.
My problem is:
I have an Article table. Each article can be a tool, a consumable, or a machine. But never all of them (one of them must be choosen)
I found that this is a 0 -> N relation and the way to represent in table is the same that
1 -> N relation but im not sure about this info because its a bit stupid to have unused fields in the table.
Assuming that this is the way to work here is my model class:
public class Article
    {
        public int ID { get; set; }

        public string Name { get; set; }

        public int? ToolID {get; set;}

        public int? MachineID {get; set;}

        public int? ConsumableID {get; set;}

        public virtual Tool t { get; set; }

        public virtual Machine m { get; set; }

        public virtual Consumable c { get; set; }
    }

I added the ? sign to make that fields not mandatory but its not working.
I generate the scaffolding views and controller.
When I run the create view to create a new Article. One of the fields is a dropdown menu to select a tool but I cant leave it empty, I have to choose a field.
If this Article is a consumible for example I want to select what consumible but leave tool and machine empty.
Maybe I have to add an empty field in the view in the dropdown list?
In that case how can I do it?. This is the code in the view:
@Html.DropDownList("ToolID", null, htmlAttributes: new { @class = "form-control" })

A: Something like this.
New Property
[NotMapped]
public string Type { get; set; }

Radio Buttons
<label>@Html.RadioButtonFor(m => m.Type, "type-tool", new { @checked = "checked" }) Tool </label>
<label>@Html.RadioButtonFor(m => m.Type, "type-machine") Machine </label>
<label>@Html.RadioButtonFor(m => m.Type, "type-consumable") Consumable </label>

Drop Downs
@Html.DropDownListFor(m => m.ToolId, new SelectList(ViewBag.Tools, "Id", "Text"), new { @class = "hidden type type-tool" })
@Html.DropDownListFor(m => m.MachineId, new SelectList(ViewBag.Machines, "Id", "Text"), new { @class = "hidden type type-machine" })
@Html.DropDownListFor(m => m.ConsumableId, new SelectList(ViewBag.Consumables, "Id", "Text"), new { @class = "hidden type type-consumable" })

Javascript
<script>
    $("input[type=radio][name='Type']").change(function () {
        $('.type').hide();
        $("." + $(this).val()).show();
    }).change();
</script>

After submitted you get the Type, just make other properties null that is not appropriate with the Type.


text:
Q: How to automate publishing .NET web applications There is a Visual Studio solution that has multiple web application projects. All of them are to be published to a common folder - D:\inetpub\wwwroot\FirstSite.
Each project has a publish profile Local.pubxml which imports settings from a global publishsettings.xml, and I use the One-Click Publish feature to publish each project.
Now, I would like to automate this process, which will Rebuild the solution and on success, publish all the projects to the target folder.
I have managed to create a Console application using C#, which can build all the projects in a solution. But, unfortunately could only go that far, as I'm unable to figure out how to get started about the publishing.
I'm not looking for setting up a build server. Just want to save time publishing projects to  local folders.
Can we achieve this in a console application, by passing parameters like 'solution path' & 'target folder path', so that it can work for any such solution with multiple projects.
If not, are there any simple tools for this.

A: When you invoke msbuild for the solution build, you can pass
/p:DeployOnBuild=true /p:PublishProfile=Local /p:SkipInvalidConfigurations=true

which will publish each project with the Local profile for you


text:
Q: how to remove the column with all the same elements in matlab? Suppose the input is:
[1 2 3;
 2 3 3;
 3 4 3;
 3 5 3;]

The expected output would be:
[1 2;
 2 3;
 3 4;
 3 5;]

The reason to remove the third column is because all the elements in the third column is the same. Is there a default matlab function for this?

A: A(:,sum(abs(diff(A)))>0,1)

"Keep the columns where the difference is larger than zero"

A: Both the posted answers are incorrect. Test the edge cases where A only has 1 or 2 rows:
i.e:
A = [1 2 3];

or:
A = [1 2 3;
     2  3 3];

diff and any need to be supplied with the correct dimension:
A = A(:,any(diff(A,1,1),1));

This outputs:
A = [1 2 3; 2 3 3];
EDU>> A(:,any(diff(A,1,1),1))

ans =

     1     2
     2     3

and
A = [1 2 3]
EDU>> A(:,any(diff(A,1,1),1))

ans =

   Empty matrix: 1-by-0

Also, IMO this, semantically, makes the most sense:
A(:,all(bsxfun(@eq,A,A(1,:)),1)) = []

A: How about:
A =

     1     2     3
     2     3     3
     3     4     3
     3     5     3

B = A==repmat(A(1,:),size(A,1),1)

B =

     1     1     1
     0     0     1
     0     0     1
     0     0     1

C = sum(B) == size(A,1)

C =

     0     0     1

A(:,C) =[]

A =

     1     2
     2     3
     3     4
     3     5

In one line:
A(:, sum(A==repmat(A(1,:),size(A,1),1)) == size(A,1)) = []


text:
Q: How do I unit test command line flags in Go? I would like a unit test that verifies a particular command line flag is within an enumeration.
Here is the code I would like to write tests against:
var formatType string

const (
    text = "text"
    json = "json"
    hash = "hash"
)

func init() {
    const (
        defaultFormat = "text"
        formatUsage   = "desired output format"
    )

    flag.StringVar(&formatType, "format", defaultFormat, formatUsage)
    flag.StringVar(&formatType, "f", defaultFormat, formatUsage+" (shorthand)")

}

func main() {
    flag.Parse()
}

The desired test would pass only if -format equalled one of the const values given above. This value would be available in formatType. An example correct call would be: program -format text
What is the best way to test the desired behaviors?
Note: Perhaps I have phrased this poorly, but the displayed code it not the unit test itself, but the code I want to write unit tests against. This is a simple example from the tool I am writing and wanted to ask if there were a good way to test valid inputs to the tool.

A: You can do this
func main() {
    var name string
    var password string
    flag.StringVar(&name, "name", "", "")
    flag.StringVar(&password, "password", "", "")
    flag.Parse()
    for _, v := range os.Args {
        fmt.Println(v)
    }
    if len(strings.TrimSpace(name)) == 0 || len(strings.TrimSpace(password)) == 0 {
        log.Panicln("no name or no passward")
    }
    fmt.Printf("name:%s\n", name)
    fmt.Printf("password:%s\n", password)
}

func TestMainApp(t *testing.T) {
    os.Args = []string{"test", "-name", "Hello", "-password", "World"}
    main()
}

A: You can test main() by:

*

*Making a test that runs a command

*Which then calls the app test binary, built from go test, directly

*Passing the desired flags you want to test

*Passing back the exit code, stdout, and stderr which you can assert on.

NOTE This only works when main exits, so that the test does not run infinitely, or gets caught in a recursive loop.
Given your main.go looks like:
package main

import (
    "flag"
    "fmt"
    "os"
)

var formatType string

const (
    text = "text"
    json = "json"
    hash = "hash"
)

func init() {
    const (
        defaultFormat = "text"
        formatUsage   = "desired output format"
    )

    flag.StringVar(&formatType, "format", defaultFormat, formatUsage)
    flag.StringVar(&formatType, "f", defaultFormat, formatUsage+" (shorthand)")
}

func main() {
    flag.Parse()
    fmt.Printf("format type = %v\n", formatType)
    os.Exit(0)
}

Your main_test.go may then look something like:
package main

import (
    "fmt"
    "os"
    "os/exec"
    "path"
    "runtime"
    "strings"
    "testing"
)

// This will be used to pass args to app and keep the test framework from looping
const subCmdFlags = "FLAGS_FOR_MAIN"

func TestMain(m *testing.M) {
    // Only runs when this environment variable is set.
    if os.Getenv(subCmdFlags) != "" {
        runAppMain()
    }

    // Run all tests
    exitCode := m.Run()
    // Clean up
    os.Exit(exitCode)
}

func TestMainForCorrectness(tester *testing.T) {
    var tests = []struct {
        name     string
        wantCode int
        args     []string
    }{
        {"formatTypeJson", 0, []string{"-format", "json"}},
    }

    for _, test := range tests {
        tester.Run(test.name, func(t *testing.T) {
            cmd := getTestBinCmd(test.args)

            cmdOut, cmdErr := cmd.CombinedOutput()

            got := cmd.ProcessState.ExitCode()

            // Debug
            showCmdOutput(cmdOut, cmdErr)

            if got != test.wantCode {
                t.Errorf("unexpected error on exit. want %q, got %q", test.wantCode, got)
            }
        })
    }
}

// private helper methods.

// Used for running the application's main function from other test.
func runAppMain() {
    // the test framework has process its flags,
    // so now we can remove them and replace them with the flags we want to pass to main.
    // we are pulling them out of the environment var we set.
    args := strings.Split(os.Getenv(subCmdFlags), " ")
    os.Args = append([]string{os.Args[0]}, args...)

    // Debug stmt, can be removed
    fmt.Printf("\nos args = %v\n", os.Args)

    main() // will run and exit, signaling the test framework to stop and return the exit code.
}

// getTestBinCmd return a command to run your app (test) binary directly; `TestMain`, will be run automatically.
func getTestBinCmd(args []string) *exec.Cmd {
    // call the generated test binary directly
    // Have it the function runAppMain.
    cmd := exec.Command(os.Args[0], "-args", strings.Join(args, " "))
    // Run in the context of the source directory.
    _, filename, _, _ := runtime.Caller(0)
    cmd.Dir = path.Dir(filename)
    // Set an environment variable
    // 1. Only exist for the life of the test that calls this function.
    // 2. Passes arguments/flag to your app
    // 3. Lets TestMain know when to run the main function.
    subEnvVar := subCmdFlags + "=" + strings.Join(args, " ")
    cmd.Env = append(os.Environ(), subEnvVar)

    return cmd
}

func showCmdOutput(cmdOut []byte, cmdErr error) {
    if cmdOut != nil {
        fmt.Printf("\nBEGIN sub-command out:\n%v", string(cmdOut))
        fmt.Print("END sub-command\n")
    }

    if cmdErr != nil {
        fmt.Printf("\nBEGIN sub-command stderr:\n%v", cmdErr.Error())
        fmt.Print("END sub-command\n")
    }
}

A: Custom testing and processing of flags can be achieved with the flag.Var function in the flag package.
Flag.Var "defines a flag with the specified name and usage string. The type and value of the flag are represented by the first argument, of type Value, which typically holds a user-defined implementation of Value."
A flag.Value is any type that satisfies the Value interface, defined as:
type Value interface {
    String() string
    Set(string) error
}

There is a good example in the example_test.go file in the flag package source
For your use case you could use something like:
package main

import (
    "errors"
    "flag"
    "fmt"
)

type formatType string

func (f *formatType) String() string {
    return fmt.Sprint(*f)
}

func (f *formatType) Set(value string) error {
    if len(*f) > 0 && *f != "text" {
        return errors.New("format flag already set")
    }
    if value != "text" && value != "json" && value != "hash" {
        return errors.New("Invalid Format Type")
    }
    *f = formatType(value)
    return nil
}

var typeFlag formatType

func init() {
    typeFlag = "text"
    usage := `Format type. Must be "text", "json" or "hash". Defaults to "text".`
    flag.Var(&typeFlag, "format", usage)
    flag.Var(&typeFlag, "f", usage+" (shorthand)")
}

func main() {
    flag.Parse()
    fmt.Println("Format type is", typeFlag)
}

This is probably overkill for such a simple example, but may be very useful when defining more complex flag types (The linked example converts a comma separated list of intervals into a slice of a custom type based on time.Duration).
EDIT: In answer to how to run unit tests against flags, the most canonical example is flag_test.go in the flag package source. The section related to testing custom flag variables starts at Line 181.

A: I'm not sure whether we agree on the term 'unit test'. What you want to achieve seems to me
more like a pretty normal test in a program. You probably want to do something like this:
func main() {
    flag.Parse()

    if formatType != text || formatType != json || formatType != hash {
        flag.Usage()
        return
    }

    // ...
}

Sadly, it is not easily possible to extend the flag Parser with own value verifiers
so you have to stick with this for now.
See Intermernet for a solution which defines a custom format type and its validator.


text:
Q: Classification of compact smooth manifolds of dimension 3. I know classification of compact dimension 2 smooth manifolds. They are diffeomorphic to a sphere with n "ears" (connected sum of n tori) or a sphere with m mobius strips (connected sum of m real projective planes).
I know only that geometric hypothesis proved by Perelman says something about 3 manifolds, but I can't find similar as above precise classification for compact smooth manifolds of dimension 2. Is there a similarsimple classification? IF Yes, could You leave a link to it or write it in comment?

A: A manifold is called prime if whenever it is homeomorphic to a connected sum, one of the two summands is homeomorphic to a sphere.
In dimension two, the closed prime manifolds are $S^2$, $\mathbb{RP}^2$, and $S^1\times S^1$. By the classification of surfaces, every closed two-dimensional manifold is homeomorphic to a connected sum of prime manifolds. In the orientable case, the connected summands are unique up to $S^2$ summands (you can always connected sum with $S^2$ without changing anything). In the non-orientable case, we no longer have uniqueness as $(S^1\times S^1)\#\mathbb{RP}^2$ is homeomorphic to $\mathbb{RP}^2\#\mathbb{RP}^2\#\mathbb{RP}^2$. However, one can recover uniqueness (up to spherical summands) if one prohibits the use of $S^1\times S^1$ summands.
There is a similar story for closed three-manifolds. The prime decomposition theorem for three-manifolds states that every closed three-manifold is homeomorphic to a connected sum of prime manifolds. If the orientable case, the connected summands are unique up to $S^3$ summands. If $M$ is non-orientable, then uniqueness no longer holds, however one can recover uniqueness by prohibiting the use of $S^2\times S^1$ as one of the connected summands.
The key difference between dimensions two and three is that there are infinitely many prime three-manifolds.  In the orientable case, they fit into three categories:

*

*those manifolds covered by $S^3$,

*the manifold $S^2\times S^1$, and

*orientable aspherical manifolds.

These categories can also be characterised via the fundamental group: namely finite, infinite cyclic, and infinite non-cyclic respectively.
In the non-orientable case however, there are too many prime manifolds to admit a classification; see the answer to this question of mine.
In dimension four, we no longer have uniqueness, even in the orientable case. For example, $(S^2\times S^2)\#\overline{\mathbb{CP}^2}$ is homeomorphic to $\mathbb{CP}^2\#\overline{\mathbb{CP}^2}\#\overline{\mathbb{CP}^2}$. Note the similarity to the fact that $(S^1\times S^1)\#\mathbb{RP}^2$ is homeomorphic to $\mathbb{RP}^2\#\mathbb{RP}^2\#\mathbb{RP}^2$.


text:
Q: custom object fields not showing up after deployment I created a changeset and deployed around 40 custom objects to another sandbox. On the destination sandbox, the custom fields dont show up on the page layout when i edit or add a new record for the custom object.
I know it is a permission issue and i am using the system admin profile to login to the destination org. How can i deploy one time all my custom objects, fields, pagelayouts from my current sandbox to destination and ensure all of these show up on the layout?
Could you guys let me know on this?
Thanks
Buyan

A: To make your new custom field visible on the target org after deploy:

*

*Go to your personal "Setup" area - "Manage Users"  - "Profiles" - and select your profile name.

*You will see your profile details (quite a long page with lots of information). In our case we need "Field-Level Security" area (because of our element-type "Custom Field").
Now find the object name your new custom field belongs to and click on the link "[ View ]". You will be redirected to another page with all custom fields of the custom object where you can cange the visibility of custom field.

*If the custom field is not visible - click on the "Edit" button on the top of the page, select the checkbox and save you setting (click on the "Save" button).


text:
Q: Open a post html response like form submit My server render a html file and send that while i send request by jquery post.
when i open string with document.open(res) it doesn't load javascript files and css files that aren't in html.
How can i open that like when submit form opens that?
$.post(url,data).done(function (res){
     //res contains html
});