text:
Q: Separate number from string in smarty I have a string like
$str ='my age is 100';

now I want to separate 100 from above string , how can I do so , using smarty
I am working on Prestashop.
Thanks

A: If there is only a number, you can just remove all non numeric characters from the string with a regular expression with regex_replace:
{$str|regex_replace:"/[^0-9]/":""}

That will print 100 for the first example and 21 for the second. However it will not work fine for strings with different numbers, (i.e. "I have 2 cows and 1 rabbit" will return 21).
That all said, I advise you against extracting a number from a text string if you need it to use in your code, as it's prone to error. better declare a separate variable, instead

A: Assuming that numbers in string are not followed or preceded by coma, brackets but just by spaces, you could use:
{assign var="str" value="my age is 100 Include Couple Name (max 21 letters)"}

{assign var="ar" value= " "|explode:$str}

{foreach $ar as $a}
    {if $a|is_numeric}
        {append var="numbers" value=$a}
    {/if}
{/foreach}

NUMBERS:

{foreach $numbers as $n}
    {$n}

{/foreach}

It will give output:
NUMBERS:
100
21

as expected.


text:
Q: Java compiler error: raw type with method returning Optional I'm trying to understand the Java compiler's thinking (I know, bad idea)...
Consider this program:
import java.util.Optional;
public class xx {

    public static class Foo<T> {
        public interface Bar<T> {
            int getX();
        }
        public Optional<Bar<T>> getBar() {
            return Optional.empty();
        }
    }

    public static void main(String[] args) throws Exception {
        Foo foo = new Foo();             // note raw type
        foo.getBar().get().getX();
    }
}

The java 1.8.0_112 compiler gives:
xx.java:15: error: cannot find symbol
        foo.getBar().get().getX();
                          ^
  symbol:   method getX()
  location: class Object
1 error

The question is: why doesn't the compiler, given the raw type Foo for foo, realize that the return type of foo.getBar() is Optional<? extends Bar> instead of what it apparently thinks, which is Optional<?> ?
Note: I know how to change this program to make it compile, that's not the question.

A: Once you use raw types in conjunction with type inference, the following from JLS 18.5.2 will apply

If unchecked conversion was necessary for the method to be applicable during constraint set reduction in §18.5.1, then [...] the return type and thrown types of the invocation type of m are given by the erasure of the return type and thrown types of m's type.

From this follows, that the return type of foo.getBar() is indeed just Optional with all type arguments erased.
Solution: avoid raw types, always.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Template matching with different template sizes I've already seen questions like this before, but those ones refer to image scaling, which means aspect ratio is same all the time. My goal is to analyze each image (Image 1 Image 2) and determine the template location (X and Y coordinates) and size (width and height of the recognized one as precise as possible) and write them into variables using single not warped reference.
I'm not really into programming, that's just something I need for my project. I know the basics, so there's no need to explain a lot, if there's not big of a deal. I would really appreciate any help. Explanation
UPD:
import cv2
import numpy as np

img1 = cv2.imread('template.png')
img1 = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
img2 = cv2.imread('image.png')
img2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)

orb = cv2.ORB_create(nfeatures=500)
kp1, des1 = orb.detectAndCompute(img1, None)
kp2, des2 = orb.detectAndCompute(img2, None)

bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = bf.match(des1, des2)
matches = sorted(matches, key=lambda x: x.distance)
match_img = cv2.drawMatches(img1, kp1, img2, kp2, matches[:50], None)
cv2.imshow('', match_img)
cv2.waitKey()


text:
Q: If sequences comprised of every nth element converge, does the original sequence converge? For instance, if the sequence made up of all the second elements converge to some N, and all the third elements, and all the fourth elements to some N, etc, does the original sequence converge to N?
I considered using the fact that if subsequences converge then the original sequence converges but I don't know if I can apply that here because this is a nonstandard definition of subsequence.

A: Define the sequence $x_n$ that is $1$ for prime indices and $0$ otherwise.  Then $x_{2n}$, $x_{3n}$, $x_{4n}$, etc all converge to $0$. However, the sequence does not converge.


text:
Q: Unselect and Select Event I am using this fiddle - https://jsfiddle.net/BlackLabel/3tqkjLoh/6/
Here the issue - When I select other point from the previous point of the pie (without unselecting the previous one). It shows the status of unselect event of the previous point. I want the status of both 'selected the current one and unselected the previous one'
const content = document.getElementById('content');
const chart = Highcharts.chart('container', {
  chart: {
    type: 'pie'
  },
  plotOptions: {
    pie: {
      allowPointSelect: true,
      cursor: 'pointer',
      point: {
        events: {
          select: function(event) {
            const selected = this;
            if (selected) {
              content.textContent = selected.options.name
              /* do something */
              // fetch(`/api?id=${ selected.options.id }`)
            } else {
              content.textContent = 'nothing'
            }
          },
          unselect: function () {
            content.textContent = 'unselect event: ' + this.options.name
          }
        }
      }
    },
  },

  series: [{
    data: [{
      y: 20,
      "name": "click me",
    }, {
      y: 60,
      "name": "click me foo",
      selected: true,
      sliced: true,
    }, {
      y: 100,
      "name": "click me bar",
    }, {
      y: 100,
      "name": "click me baz",
    }, ]
  }]
});

A: Here's the problem, selected event triggers before unselect event
So basically, content.textContent is first set to selected.options.name, and then again sets to 'unselect event: ' + this.options.name and then the latest value is appeared onto the DOM.
https://jsfiddle.net/devatquarxps/5yb0wehd/7/

const content = document.getElementById('content');
const chart = Highcharts.chart('container', {
  chart: {
    type: 'pie'
  },
  plotOptions: {
    pie: {
      allowPointSelect: true,
      cursor: 'pointer',
      point: {

        events: {
          select: function(event) {
            const selected = this;
   selected ? content.textContent ='select event: ' + selected.options.name + ' | ' : content.textContent = ''

          },
          unselect: function () {
           content.textContent =content.textContent + '  unselect event: ' + this.options.name
          }
        }
      }
    },
  },

  series: [{
    data: [{
      y: 20,
      "name": "click me",
    }, {
      y: 60,
      "name": "click me foo",
      selected: true,
      sliced: true,
    }, {
      y: 100,
      "name": "click me bar",
    }, {
      y: 100,
      "name": "click me baz",
    }, ]
  }]
});

open console panel

  After clicking, [selected and sliced] status is not synchronized update;

Show to users

You have chosen :


text:
Q: How to force HTML5 appCache to never fail (online, offline, or remote server down) I have an Android web app using a manifest file caching remote resources (html, images, css, js) that work fine for moments but I can't find a way to make it work all the time... A lot of things seems to make the app load fail randomly (not always):

*

*Restarting device

*Stopping WIFI

*Starting WIFI

*Remote server down

*Just waiting some time

Any idea how to make an appCache app running in any situation? Is appCache a mature and stable feature?
Thanks a lot
Etienne


text:
Q: Issue in using PreparedStatement for update query with column name "REORDER" We have been using Ojdbc 14 with hibernate 3x to connect to Oracle database in our application which was deployed in JBoss 4x. Now we have upgraded our application server to JBoss 6x. So we had to upgrade hibernate(4.2.18) and Ojdbc drivers(ojdb7) to be in compatible with the application server.
We are now facing an issue(invalid Column index) with an update operation on a table having a column with name "REORDER", which was woring fine with Hibernate 3x and Ojdbc 14.
The PreparedStatement is calculating incorrect parameter count(276) instead of  the actual number of parameters(277) when the column REORDER is present in the query else it is working fine.
Also the insert statement with column "REORDER" is working fine.
We tried searching the Oracle keywords to see whether this is an Oracle keyword or not, but it is not listed in the Oracle Reserved keywords as well.
We are able to update the table when we name the column "REORDER" to some other name.
Can anyone please help us understanding what went wrong here.

A: It seems to be an issue with some specific versions of JDBC drivers. We are able to resolve the issue by downgrading the JDBC driver used in our environment to OJDBC6(11.2.0.3).
Reference:
http://www-01.ibm.com/support/docview.wss?uid=swg21982951


text:
Q: Flex video stream questions the question is where to start with streaming video over the net with flex.
Please suggest streaming server type (with linux support) . Any examples of source code ?
Thank you.

A: What kind of streaming are you looking to do?  There's different levels and depending on your requirement would need different technologies.
Adobe has their own solution called Flash Media Server (or FMS), but I'm not a fan.  It works fine, but the code that runs it is all Actionscript which most 'server' guys do not appreciate since a lot of them are Java trained.  Plus, FMS costs money;  It's free for 15 connections or less but if you want more, you need to pay a pretty coin.
As a free alternative, there's the Red5 project.  This one uses Java and works pretty much the same way as FMS except it's lacking a few features like some of the newer Adobe streaming protocols (RTMFP).
Another one that I've heard great things about is Wowza server.  It's Java based as well, is free up to a certain amount of connections and is fairly cheap to buy.  They have different pricing models that fits what your business wants to do and it's very easy to scale up.  One big plus of Wowza is that they're also on the Amazon cloud which is a great and cheap way to have your servers running since it's a 'pay as you go' type deal.
BUT, and this is big one, if you just need simple streaming between just a few clients (like a video chat of some sort) you can always use Adobe's new p2p service called Cirrus (formerly known as Stratus).  It helps people (2 or more) connect to each other even if they're behind a firewall (need to have UDP enabled however) and stream live information to each other.  The only limitation on this one is the bandwidth of each client connecting to each other.
Hope this all helps.

A: Red5 server: Java, real-time, free, linux, anything you want :)

A: Some more u can try:
Flash Media Server
ffmpeg
VLC


text:
Q: Ontology: OWL - Creating connections between classes I ve got an Ontology written in OWL with Protege. But I don't find a solution for creating relations between Classes. Of course, there is a "subclass" relation, but I want to define my own relations. So I have a class hierarchy (which consists out of "subclass"-relations) but I want to create a relation, i.e. "has_Relation", to connect two classes.
My aim is to write a java programm in which I can get the information "which class is parentclass of a class?" and "to which class is a has_Relation connection?"
(I am not talking about individuals - I'm just talking about classes)
Thank you very much for your help in advance!
Best Regards
Natan

A: The simplest way to do this is to use an annotation property. In Protégé, select the class you want to relate to another class, then click the + beside "Annotations" in the Annotations tab. Then add the has_Relation property with the second button on the top left of the window. Then select the Entity IRI tab and the Classes subtab, select the other class you want to relate to and you're done.
However, you should rather not do this if has_Relation is an object property or a datatype property. If such is the case, you can use "punning", that is, you can make new individuals in the Individuals tab with the same names as the classes you want to relate. Then you relate them as if they were normal individuals. Note that this is allowed and valid in OWL 2 DL.

A: a bit late, but:
You can also go to the tabs menu and active the object properties tab
(Window> Tabs -> Object Properties )
Then you can create your own object property and assign its domain and range to which ever classes you want ( Description area of the individual property ).


text:
Q: How should I manually add IP addresses to denyhosts? I have a few IP addresses I want to add manually to denyhosts because they're huge sources of inbound spam.  What's the best way to do this?  Or should I not be messing with it?
I want to manually add these to denyhosts, but I don't see a way to do it through any program options.  I see nothing in denyhosts.py --help.
It looks like it could be as simple as adding a line to /etc/hosts.deny, but since the process to delete an IP (see here on ServerFault and the DenyHosts FAQ) involves updating six files, it makes me think it's not "Can't You Just... add the IP to the file?".

A: Denyhosts uses the standard /etc/hosts.deny file; you can add your IPs there.
Whoever told you deleting an IP takes 6 edits was delusional; any entries in hosts.deny not added by denyhosts are not special in any way - you just delete them.


text:
Q: How to get rid of pronoun ambiguity? We are discussing on ELL how to get rid of pronoun ambiguity. The intial sentence with apparent pronoun ambiguity was

When Anne's grandmother died she lit an extra candle for her on her birthday.

An improved version

Anne lit an extra candle for her grandmother, when she died.

is free from the apparent ambiguity but contains still a - let's say - potential one. Provided that afterlife exists and one can celebrate birthdays with birthday cakes and candles on it there, she can also refer to Anne. There certainly exist examples for sentences where there is the same ambiguity created without reference to supernatural things.
The question now is if one can overcome this ambiguity by licit, acknowledged means. The following propositions exist. But are they licit and aren't they disrespectful?

Anne lit an extra candle for her grandmother, when that died.
  Anne lit an extra candle for her grandmother, when that one died.
  Anne lit an extra candle for her grandmother, when the latter died.

Are there better ones?

A: There is still semantical pronoun ambiguity in all of them. It's better to specify "her" with "grandmother" if you truly want to remove pronoun ambiguity.
Initial version:

When Anne's grandmother died (sic) she lit an extra candle for her on her birthday.

Improved version:

When Anne's grandmother died, Anne lit an extra candle for her grandmother's birthday.

Other ways you can say this:

Anne lit an extra candle for her dead grandmother.
  Anne lit an extra candle for her grandmother, when her grandmother died.

A: Different languages use different mechanisms to convey meaning and tie parts of sentences to other parts.
I learnt recently that ancient Greek (and perhaps modern Greek, but I haven't looked into it) used a slew of prefixes and suffixes to modify verbs and nouns, so that a single word carried a lot of information. Word order didn't matter so much because of this.
For example, consider the English sentence "X fought Y". In ancient Greek, you would 'decline' (modify) the nouns X and Y to what amounted to "the subject X of the verb" and "the direct object Y of the verb". So where "X fought Y" and "Y fought X" are different sentences in English, with "X Y fought" and "fought Y X" downright nonsensical, just about any word order would be fine in ancient Greek because you always knew who did the fighting and who the fighting was done to.
The cost of all this richness in the language is that words need to be inflected differently when used in different parts of a sentence. English is a lot less complicated by this measure, but the cost to the simplicity is that word order becomes extremely important. Where word order alone doesn't solve the problem, you may need to pick different words to bring out the intended meaning.
Now, pronouns are typically tied to their actual nouns by context, if not explicitly. But in your examples, the ties are weak to the point of (real or forced) ambiguity. Normally, pronouns refer to the closest relevant noun, but this isn't always the case. Separating them with punctuation weakens this rule of thumb even more.

*

*Mary and Jane entered the room. She lit the candle for her. (completely ambiguous)

*Harry and Jane entered the room. He lit the candle for her. (completely unambiguous)

*Mary entered the room. Jane lit the candle for her. (unambiguous by context)

You ask how to get rid of pronoun ambiguity, giving the following sentence as an example:

When Anne's grandmother died she lit an extra candle for her on her birthday.

The common problem to all the alternatives you suggest is that replacing one ambiguous pronoun with another ambiguous pronoun doesn't resolve the ambiguity. Even deictic terms like that (or more politely, that person) don't work because there is no finger pointing to the thing that that is referencing.
The natural reading of your original example is that Anne did the candle-lighting for her grandmother. It is unclear whose birthday it was, but that information could come from Anne's (sub)culture. If their community lit candles for the dead on the birthdays of the dead, for example, the sentence would likely reference the grandmother's birthday. In a different subculture, one would read the 'extra' candle as being for the grandmother, so the birthday was Anne's.
With less context available, the standard way to remove ambiguity in English is to reword the sentence. For example:

*

*On Anne's birthday, she lit an extra candle to mourn the death of her grandmother.

Here, all the pronouns naturally point to Anne.

A: Summarizing the received comments I conclude that there is no natural (i.e. coming spontaneously to mind of native speakers) replacement for an ambiguous personal pronoun.
There is the workaround of adding a defining appositive. The proposed that and that one are complete mistakes. The proposed latter feels stuffy. This was exactly my apprehension and this is why I have asked for better options.
I'd also like to confirm that common sense and logic are the key to overcome many of the ambiguities we face. But here I deliberately tried to keep them alive in order to tease out possibly existing but rarely used replacements for ambiguous personal pronouns.
Thanks to all contributors.


text:
Q: Use ToDictionary to create a dictionary I have two string lists which have same size.
I want to create a dictionary, the key is from listA, the value is from listB.
What is the fast way?
I used the code:
        List<string> ListA;
        List<string> ListB;
        Dictionary<string,string> dict = new Dictionary<string,string>();
        for(int i=0;i<ListA.Count;i++)
        {
              dict[key] = listA[i];
              dict[value]= listB[i];
        }

I don't like this way, can I use ToDictionary method?

A: You could create an anonymous type with the index which you can use to get the B at this index.
Dictionary<string, string> dict = ListA
    .Select((a, i) => new { A = a, Index = i })
    .ToDictionary(x => x.A, x => ListB.ElementAtOrDefault(x.Index));

Note that the value would be null in case ListB is smaller than ListA.

A: I would not bother (if it is possible) as your version is readable, easy to debug and quicker than any other LINQ solutions (especially if you are working with big list).

A: I wouldn't change your version.
The following piece of code is more readable than LINQ stuff in your case, IMHO.
var ListA = new List<string>();
var ListB = new List<string>();
var dict = new Dictionary<string, string>();

for (int i = 0; i < ListA.Count; i++)
{
    dict.Add(ListA[i], ListB[i]);
}

A: Starting with .NET 4.0, you can do it using LINQ's Zip method, like this:
var res = ListA.Zip(ListB, (a,b) => new {a, b})
               .ToDictionary(p=>p.a, p=>p.b);

[Zip] method merges each element of the first sequence with an element that has the same index in the second sequence.


text:
Q: What's the effect of shorting the wiper terminal with one of the ends of a trim pot? EDIT: I realized I didn't draw the schematic properly. Previously, the 100 Ohm resistor wasn't there.
I thought I'd done the math correctly for this, but clearly something conceptually isn't straight for me. I need a 5K potentiometer, but the sources I've looked through didn't have it in the package I'd like. I did see a 10K pot in the package though. So I thought by shorting the wiper terminal with one of the ends of the trim pot I'd be able to half the maximum possible resistance offerable by the pot.
$$\frac{1}{R_{total}} = \frac{1}{R_{wiper}} + \frac{1}{10000}$$
$$\frac{1}{R_{total}} = \frac{R_{wiper} + 10000}{10000 \cdot R_{wiper}}$$
$$R_{total}=\frac{10000 \cdot R_{wiper}}{R_{wiper} + 10000}$$
Since the highest resistance Rwiper can reach is 10K, the resulting highest value would be
$$R_{total}=\frac{10K \cdot 10K}{10K + 10K} = \frac{10K \cdot 10K}{2 \cdot 10K} = 5K$$
I could also make a graph by plotting the function of Rtotal.
By this point I was convinced. I tried to measure the resistance on a spare 10K pot lying around, but I saw that maximum value remained 10K. Why is this?

simulate this circuit – Schematic created using CircuitLab

A: If the wiper is at the bottom of the resistance element in your schematic, the whole 10K resistance element is in circuit.
At any point in the wiper's travel, you will only have one part of the resistance element in the circuit.  There is no way to get two parts of the resistance element in parallel, as your calculation would require.

A: The formulas do not match the picture. In the picture, the resistance between ground and 5V can be set between 0R where the wiper bypasses the resistance and 10k where the wiper selects full resistance.
To whatever position you set the wiper, it will short out the unused portion of the resistance when it is connected like in the picture, so it will have no effect.

A: If you connect to the top and wiper, you can use the potentiometer as a simple variable resistor.
If you connect to the top and wiper, AND short wiper to bottom, you are still using it as a variable resistor, but with one important difference : if the wiper goes open circuit, the resistance value is 10K rather than infinity.
That can:

*

*reduce crackling noises in an audio circuit when the track is old or dirty

*prevent loss of signal or things blowing up due to wiper failure

*prevent gain (and volume) attempting to reach infinity in circuits
where gain is proportional to resistance

If you have to design circuits to tolerate component failure, this is worth remembering.


text:
Q: Cordova alerts repeat on navigation I have trouble with repeating alerts in Cordova (phonegap), javascript looks like this:
navigator.notification.alert(
                'Something is amiss',  // message
                function(){},         // callback
                'DatabaseManager error processing SQL',            // title
                'Ok'                  // buttonName
            );

When i navigate to another page, like using back button, the alert is shown again. If i navigate further, the alerts are repeated x2 and so forth.
Note: It happens even when i try different navigation methods e.g.:
$.mobile.changePage("LogOn.html");
window.location.href = "LogOn.html";
back

I'f found that scripts generally runs twice (alerts are just an example) when i navigate away from a page (but only on some occasions). I suspect that this happens because there's an error which i display in an alert, and the error cause the scripts run again in some magic way. Any ideas about what could be the cause?
Bonus info:
I use single page model (one page pr html file), load init and run my scripts from the html like this:

A: This problem was due to callback methods getting run again, which is especially a problem when callbacks are nested - which cause a complex debugging scenario. An example I found was a bug in jquery mobile popup (on android). I put a changePage navigation in the callback (on popup dismiss or something like that). The callback called the changePage like it should, but seemingliy there was a callback that caused the browser to return to where the popup occured.


text:
Q: Create SCD type 2 table from change log table using SQL I have a change log table, which captures the transition of a state with its time, for example:
user_id,user_status_from,user_status_to,  created_date
 7cc4d      A2               A1       2019-11-03 23:04:26
 7cc4d      A1               A6       2019-11-03 23:05:28
 7cc4d      A6               I4       2019-11-16 10:00:34
 7cc4d      I4               A1       2020-03-16 10:00:36

Basically this table records the transition from one status to another, here it says that transition from
A2--> A1 occurred at 2019-11-03 23:04:26 (1st row) and then it moved from
A1 --> A6 at 2019-11-03 23:05:28 and so on.
Now I want to write a SQL through which I should be able to create table in such a way that tells the history of any status, for example: in particular status user was from this date to that date, basically a life of any status, I want to create a table like below:
   userId status statrtingdatetime  endingdatetime
   7cc4d   A1   2019-11-03 23:04:26 2019-11-03 23:05:28
   7cc4d   A6   2019-11-03 23:05:28 2019-11-16 10:00:34
   7cc4d   I4   2019-11-16 10:00:34 2020-03-16 10:00:36
   7cc4d   A1   2020-03-16 10:00:36 2020-04-02 08:24:50

If you see this table, it is nothing but some sort of logical table from above table, it says that a particular status life was from one date to another.
How can write SQL to create this final table.(please note that LAG/LEAD function doesn't work in my version of MySql Server)


text:
Q: mod_rewrite accept only dashes & alphanumeric, otherwise throw 404 I'm using mod_rewrite to transfer the end of the URL to my php script which will act as a microcms. My url will look something like this:
mysite.com/articles/some-article-about-css
That will pass the following to my PHP script index.php:
index.php?action=read&article=some-article-about-css
I have questions:

*

*I'm unsure how the best way to only accept alphanumeric w/ dashes using mod_rewrite. I found this rule on the internet ((?:[a-z]+)?(?:[0-9]+)?-?)+ and it apparently doesn't allow double dashes which is even better, but its long and confusing. Is there another (shorter, faster) rule I can use?

*I'd like to verify that this rule is valid for what I'm trying to accomplish. I'm not very good with mod_rewrite:
RewriteRule ^/articles/((?:[a-z]+)?(?:[0-9]+)?-?)+ /index.php?action=read&article=$1

*What rule can I use so that if the url after /articles/ is not a valid alphanumeric /w dashes url, automatically throw a 404 rather than passing to my script?

A: RewriteRule ^/articles/([a-zA-Z0-9-]*) /index.php?action=read&article=$1 [QSA,L]
RewriteRule ^/articles/ - [R=404]
For alphanumeric and dashes only

A: You dont need that complex regex i believe. Try this
RewriteRule ^articles/([^a-zA-Z0-9-]*) /index.php?page=$1 [L]
RewriteRule ^articles(.*) [R=404]


text:
Q: "Add a domain" not visible after sandbox refresh The first picture is of the production -> Setup-> Domains

The second picture is of the sandbox-> Setup-> Domains. The add domain button disappeared after sandbox refreh

Is there anyway i can make the button apprear again for System administrator?

A: Sandboxes created or refreshed since Spring '21, the domain list is read-only and is kept up-to-date with the list in production. Changes made to the domain list in production are propagated to the sandboxes and 'Add a Domain button will not be available in the sandbox.
If you're trying to set up a custom domain in a sandbox, add it to the production org and choose that sandbox from the Associated Org drop-down field. Be sure to activate
the change to have it take effect.
Check more details here along with Test Your Custom Domains in a Sandbox.


text:
Q: CPU cooler installation thermal paste I was installing a brand new i3-4330 with the stock CPU cooler. I couldn't get the CPU cooler push pins to click the first time. I removed the CPU cooler for just a few seconds and put it back on and the thermal paste was still wet. Do I need to apply more thermal paste or will the CPU be okay without it?

A: You will be fine as long as there is no chance of contaminates getting into the thermal paste while they were separated. it is a good time to check its coverage, and see if it is needing tidying up. Try to keep it from oozing over too far beyond the heat sink of the CPU.

A:
I was installing a brand new i3-4330 with the stock CPU cooler. I couldn't get the CPU cooler push pins to click the first time. I removed the CPU cooler for just a few seconds and put it back on and the thermal paste was still wet.

That's normal, it should be wet (though depending on the paste and heat exposure, it may dry out after a couple of years, at which time you will want to clean it off and re-apply).

Do I need to apply more thermal paste or will the CPU be okay without it?

Why? Did you rub it off? If not, then it should be fine. You actually want to avoid putting too much on because then it will stop acting like a thermal conductor and become more of a thermal insulator.
Some people suggest smoothing the paste out with a plastic card or something, but usually the pressure from just squeezing the heatsink down should cause it to evenly spread out in a thin and uniform layer after a while (especially once the heat softens the paste a little).
You're likely fine, but you can watch your temperatures (especially while under and under load) to have peace of mind. If you find the temperatures are too high (which can be a challenge to determine thresholds in and of itself), then you can always just wipe it off and re-apply; with the paste that's already on there and the heatsink and fan, you almost certainly won't get it hot enough to damage the CPU immediately, especially if you check the unloaded temperatures first.

A: This probably won't cause issues for you unless you plan to over-clock your CPU, but it's also not ideal either.
By removing the heat sink you allow more air to get between the CPU and the heat sink, decreasing the thermal conductivity of the heat sink and increasing overall CPU temperatures.
The only way to really know for sure your CPU will be okay is to monitor the temperatures under load. Typically you will want to aim for below 60 degrees with most CPUs, but this can vary from CPU to CPU.
If you're running windows:
prime95 is great for stress testing CPUs.
Coretemp is a nice tool for monitoring the temperature.
There's plenty of other tools for stress testing and measuring CPU temperature, but these are just the first that came to mind that are simple and easy to use.


text:
Q: Degrees of comparison I believe, both variants are possible:

*

*friendlier / more friendly; and

*the friendliest / the most friendly.

I'd like to know what is used in every day speech more often and which is more formal.

A: Though grammatically both friendlier and more friendly are correct. But formally since friendly is a 2- syllable word, more friendly is more acceptable.
However, if we go by figures, Google's survey for published works can help you.
https://books.google.com/ngrams/graph?content=friendlier%2Cmore+friendly&year_start=1800&year_end=2008&corpus=6&smoothing=3&share=&direct_url=t1%3B%2Cfriendlier%3B%2Cc0%3B.t1%3B%2Cmore%20friendly%3B%2Cc0
According to this survey, friendlier has become more popular after mid-80s

A: Those whom grew up speaking or around one of the romantic languages like Spanish will often use the [most] and [more], which are superalative and comparative adverbs, because they don't have the comparative, superlative morphemes: [mas bonita] is [more pretty].
I recently spoke to some linguistics students who said that at a conference, someone presented a paper that claims the superlative/comparative morphemes [-est] and [-er] are becoming less common in language in certain regions in comparison to their adverbial cousins [more] and [most] with the exception of most adjectives that are single syllable and don't end with a vowel, words like [tall] or [nice].
I must note that the adverbial words usually get attached to adjectives that are three or more syllables.


text:
Q: Load customer by ID in Helper/Class or Model/Class | Magento 2 I can load in controller with:
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepositoryInterface,

as:
$customer = $this->_customerRepositoryInterface->getById(1);

and using CustomerFactory:
\Magento\Customer\Model\CustomerFactory $customerFactory,

as:
$customer=$this->_customerFactory->create();
        $customer->setWebsiteId(1);
        $customer->load(1);
        $data= $customer->getData();
        print_r($data);exit;

But both of them are not working in Model/MyClass and Helper/Myclass
Errors is
Fatal error: Uncaught Error: Call to a member function getById() on null
Please mention the missing or other way!!
Update
Here is my full constructor for this class:
public function __construct(
\Magento\Customer\Model\Customer $customerModel,
\Magento\Customer\Model\CustomerFactory $customerFac,
\Zend\Http\Client $zendClient,
\Magento\Customer\Model\Session $customerSession,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepositoryInterface,
\Magento\Customer\Api\AddressRepositoryInterface $addressRepositoryInterface,
\Magento\Customer\Model\Group $customerGroupCollection,
\Magento\Customer\Model\ResourceModel\CustomerFactory $customerFactory) {
    $this->customerModel = $customerModel;
    $this->customerFactory = $customerFactory;
    $this->zendClient = $zendClient;
    $this->_storeManager = $storeManager;
    $this->_customerFac = $customerFac;
    $this->_customerSession = $customerSession;
    $this->_customerRepositoryInterface = $customerRepositoryInterface;
    $this->_customerGroupCollection = $customerGroupCollection;
    $this->_addressRepositoryInterface = $addressRepositoryInterface;
}


text:
Q: Testing Graphene-Django Currently I am investigating using graphene to build my Web server API. I have been using Django-Rest-Framework for quite a while and want to try something different.
I have figured out how to wire it up with my existing project and I can test the query from Graphiql UI, by typing something like
{
   industry(id:10) {
      name
      description
   }
}

Now, I want to have the new API covered by Unit/integration tests. And here the problem starts.
All the documentation/post I am checking on testing query/execution on graphene is doing something like
result = schema.execute("{industry(id:10){name, description}}")
assertEqual(result, {"data": {"industry": {"name": "Technology", "description": "blab"}}}

My point is that the query inside execute() is just a big chunk of text and I don't know how I can maintain it in the future. I or other developer in the future has to read that text, figure out what it means and update it if needed.
Is that how this supposed to be? How do you guys write unit test for graphene?

A: I've been writing tests that do have a big block of text for the query, but I've made it easy to paste in that big block of text from GraphiQL.  And I've been using RequestFactory to allow me to send a user along with the query.
from django.test import RequestFactory, TestCase
from graphene.test import Client

def execute_test_client_api_query(api_query, user=None, variable_values=None, **kwargs):
    """
    Returns the results of executing a graphQL query using the graphene test client.  This is a helper method for our tests
    """
    request_factory = RequestFactory()
    context_value = request_factory.get('/api/')  # or use reverse() on your API endpoint
    context_value.user = user
    client = Client(schema)  # Note: you need to import your schema
    executed = client.execute(api_query, context_value=context_value, variable_values=variable_values, **kwargs)
    return executed

class APITest(TestCase):
    def test_accounts_queries(self):
        # This is the test method.
        # Let's assume that there's a user object "my_test_user" that was already setup
        query = '''
{
  user {
    id
    firstName
  }
}
'''
        executed = execute_test_client_api_query(query, my_test_user)
        data = executed.get('data')
        self.assertEqual(data['user']['firstName'], my_test_user.first_name)
        ...more tests etc. etc.

Everything between the set of ''' s ( { user { id firstName } } ) is just pasted in from GraphiQL, which makes it easier to update as needed. If I make a change that causes a test to fail, I can paste the query from my code into GraphQL, and will often fix the query and paste a new query back into my code.  There is purposefully no tabbing on this pasted-in query, to facilitate this repeated pasting.


text:
Q: How to get an UITableView working with CAShapeLayer mask? I would like to mask an UITableView in a shape of an triangle. My first approach was to setup a CAShapeLayer and add it as a mask directly on the table view. But then, I got the triangle shape scrolling together with the table view.
My next approach was to put the table view in an UIView as a superview with exactly the same position and size. In the code snippet below, self.triangleView is the superview.
- (void)viewDidLoad
{
    [super viewDidLoad];

    CAShapeLayer *mask = [[[CAShapeLayer alloc] init] autorelease];
    mask.frame = _tableView.bounds;
    mask.fillColor = [[UIColor blackColor] CGColor];

    CGFloat width = self.triangleView.frame.size.width;
    CGFloat height = self.triangleView.frame.size.height;

    CGMutablePathRef path = CGPathCreateMutable();

    // draw the triangle
    CGPathMoveToPoint(path, NULL, 0, height);
    CGPathAddLineToPoint(path, NULL, width, 0);
    CGPathAddLineToPoint(path, NULL, width, height);
    CGPathCloseSubpath(path);

    mask.path = path;
    CGPathRelease(path);

    self.triangleView.layer.mask = mask;
}

This works so far, cause I now have an table view shaped like a triangle. But I now have the problem, that I can't scroll the table view. The superview doesn't route the touches to the table view inside. Any ideas?

A: TableView subclasses UIScrollView. And UITableViewDelegate conforms to UIScrollViewDelegate, so you can override scrollViewDidScroll and move your mask layer according to UIScrollView contentOffset

A: The solution was to use one more UIView in the hierarchy to then mask the the top of them. Sounds strange, but works for me.


text:
Q: Pidgin - Error "SSL peer presented an invalid certificate" on gtalk connection Pidgin can't connect to gtalk and offers to accept an unknown certificate.
this is the pidgin error: SSL peer presented an invalid certificate
i saw another question that has been solved, but it was related to system date, i checked it and date is totally synced and correct.
connecting over VPN wasn't helpful. error was same.
this is the certificate fingerprint:
Common name: gmail.com
Fingerprint (SHA1): 28:dd:89:d3:0a:a6:f0:a2:b9:f8:77:fc:55:fc:ab:85:18:de:13:ff
Activation date: Tue Jul 23 18:07:27 2013
Expiration date: Wed Jul 23 18:07:27 2014

i rejected the certificate, is it reliable?
i runned pidgin in debug mode by pidgin.exe -d shortcut. this is the log:
purple\certificates\x509\tls_peers\login.yahoo.com
(14:58:38) util: Writing file C:\Users\XMo\AppData\Roaming\.purple\certifica
tes\x509\tls_peers\login.yahoo.com
(14:58:38) certificate: Successfully verified certificate for login.yahoo.com
(14:58:38) proxy: No Windows proxy set.
(14:58:38) util: request constructed
(14:58:39) util: Writing file blist.xml to directory C:\Users\XMo\AppData\Ro
aming\.purple
(14:58:39) util: Writing file C:\Users\XMo\AppData\Roaming\.purple\blist.xml

(14:58:39) util: Response headers: 'HTTP/1.1 200 OK
Date: Tue, 03 Sep 2013 10:28:38 GMT
Set-Cookie: B=e63111t92beem&b=3&s=4i; expires=Fri, 04-Sep-2015 10:28:39 GMT; pat
h=/; domain=.yahoo.com
Set-Cookie: Y=v=1&n=9hc5v9t26bofb&l=cehjtp0/o&p=m2pvvir012000000&iz=&r=rv&lg=en-
US&intl=us&np=1; path=/; domain=.yahoo.com
Set-Cookie: T=z=XnbJSBXtwJSBIyN9r3k6ixSNjE2MwY2NDI2N083MzZONU9PTj&a=QAE&sk=DAAtA
aOOm3R8Pn&ks=EAAaE80vMWHU1XvmIrWbNLYPQ--~E&d=c2wBTVRZeE5BRXhNelV4TURnd05ERTVNamc
0T1RFeE1BLS0BYQFRQUUBZwFQWVZSU0pINUZSMLKJJEI3T0w3TVpMR01BWQFzY2lkAWRSS1ZKbVA2dWx
veWVUSEhOcm9MVnZYLkpjOC0BYWMBQUlQUW81cDR1ZTh2AXNjAXltc2dyAXp6AVhuYkpTQmdXQQF0aXA
BdUV1ZGZB; path=/; domain=.yahoo.com
Set-Cookie: SSL=v=1&s=EbrNF3L9lSHOT7r4A6BzQkMf9Z5icsr.1DVUwkP0fPZI9xHt03bWPCmlJ.
wNwlW.kOFuArTlkGmI6WNbstxN_g--&kv=0; path=/; domain=.yahoo.com; secure; httponly

P3P: policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV
TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UN
I PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
Cache-Control: private
Pragma: no-cache
Expires: Thu, 05 Jan 1995 22:00:00 GMT
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html

'
(14:58:39) yahoo: Authentication: In yahoo_auth16_stage2
(14:58:39) yahoo: Got needed part of B cookie: e63111t92beem&b=3&s=4i
(14:58:39) yahoo: Got auth16 stage 2 response code: 0
(14:58:39) yahoo: Authentication: In yahoo_auth16_stage3
(14:58:39) yahoo: yahoo status: 0
(14:58:39) yahoo: 249 bytes to read, rxlen is 269
(14:58:39) yahoo: Yahoo Service: 0x55 Status: 0
(14:58:39) proxy: No Windows proxy set.
(14:58:39) util: requesting to fetch a URL
(14:58:39) proxy: No Windows proxy set.
(14:58:39) dnsquery: Performing DNS lookup for address.yahoo.com
(14:58:39) proxy: No Windows proxy set.
(14:58:39) dnsquery: IP resolved for address.yahoo.com
(14:58:39) proxy: Attempting connection to 98.138.5.227
(14:58:39) proxy: Connecting to address.yahoo.com:80 with no proxy
(14:58:39) proxy: Connection in progress
(14:58:39) proxy: Connecting to address.yahoo.com:80.
(14:58:39) proxy: Connected to address.yahoo.com:80.
(14:58:39) util: request constructed
(14:58:40) yahoo: 102 bytes to read, rxlen is 439
(14:58:40) yahoo: Yahoo Service: 0xf1 Status: 0
(14:58:40) proxy: No Windows proxy set.
(14:58:40) util: requesting to fetch a URL
(14:58:40) proxy: No Windows proxy set.
(14:58:40) dnsquery: Performing DNS lookup for address.yahoo.com
(14:58:40) yahoo: Authentication: Connection established
(14:58:40) connection: Activating keepalive.
(14:58:40) yahoo: 8 bytes to read, rxlen is 317
(14:58:40) yahoo: Yahoo Service: 0xf0 Status: 0
(14:58:40) yahoo: 204 bytes to read, rxlen is 289
(14:58:40) yahoo: Yahoo Service: 0xef Status: 1
(14:58:40) yahoo: Unhandled service 0xef
(14:58:40) yahoo: 18 bytes to read, rxlen is 65
(14:58:40) yahoo: Yahoo Service: 0x12 Status: 1
(14:58:40) yahoo: Unhandled service 0x12
(14:58:40) yahoo: 7 bytes to read, rxlen is 27
(14:58:40) yahoo: Yahoo Service: 0x0b Status: 1
(14:58:40) proxy: No Windows proxy set.
(14:58:40) dnsquery: IP resolved for address.yahoo.com
(14:58:40) proxy: Attempting connection to 98.138.5.227
(14:58:40) proxy: Connecting to address.yahoo.com:80 with no proxy
(14:58:40) proxy: Connection in progress
(14:58:40) util: Response headers: 'HTTP/1.1 200 OK
Date: Tue, 03 Sep 2013 10:28:40 GMT
P3P: policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV
TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UN
I PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
x-frame-options: sameorigin
Vary: Accept-Encoding
Content-Type: text/xml; charset=utf-8
Cache-Control: private
Age: 0
Transfer-Encoding: chunked
Connection: keep-alive
Server: YTS/1.19.11

'
(14:58:40) proxy: Connecting to address.yahoo.com:80.
(14:58:40) proxy: Connected to address.yahoo.com:80.
(14:58:40) util: request constructed
(14:58:40) util: Response headers: 'HTTP/1.1 200 OK
Date: Tue, 03 Sep 2013 10:28:40 GMT
P3P: policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV
TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UN
I PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
x-frame-options: sameorigin
Vary: Accept-Encoding
Content-Type: text/xml; charset=utf-8
Cache-Control: private
Age: 0
Transfer-Encoding: chunked
Connection: keep-alive
Server: YTS/1.19.11

'
(14:58:43) account: Connecting to account m.zixxxxxxxx@gmail.com/.
(14:58:43) connection: Connecting. gc = 0534E4E0
(14:58:43) proxy: No Windows proxy set.
(14:58:43) dnssrv: querying SRV record for gmail.com: _xmpp-client._tcp.gmail.co
m
(14:58:43) wpurple: This version of dnsapi.dll contains DnsQuery_UTF8
(14:58:43) wpurple: This version of dnsapi.dll contains DnsRecordListFree
(14:58:43) dnssrv: found 5 SRV entries
(14:58:43) proxy: No Windows proxy set.
(14:58:43) dnsquery: Performing DNS lookup for xmpp.l.google.com
(14:58:43) proxy: No Windows proxy set.
(14:58:44) dnsquery: IP resolved for xmpp.l.google.com
(14:58:44) proxy: Attempting connection to 173.194.70.125
(14:58:44) proxy: Connecting to xmpp.l.google.com:5222 with no proxy
(14:58:44) proxy: Connection in progress
(14:58:44) proxy: Connecting to xmpp.l.google.com:5222.
(14:58:44) proxy: Connected to xmpp.l.google.com:5222.
(14:58:44) jabber: Sending (m.zixxxxxxxx@gmail.com): <?xml version='1.0' ?>
(14:58:44) jabber: Sending (m.zixxxxxxxx@gmail.com): <stream:stream to='gmail.com
' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version=
'1.0'>
(14:58:44) jabber: Recv (138): <stream:stream from="gmail.com" id="29377D07DDD6A
095" version="1.0" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber
:client">
(14:58:44) jabber: Recv (241): <stream:features><starttls xmlns="urn:ietf:params
:xml:ns:xmpp-tls"><required/></starttls><mechanisms xmlns="urn:ietf:params:xml:n
s:xmpp-sasl"><mechanism>X-OAUTH2</mechanism><mechanism>X-GOOGLE-TOKEN</mechanism
></mechanisms></stream:features>
(14:58:44) jabber: Sending (m.zixxxxxxxx@gmail.com): <starttls xmlns='urn:ietf:pa
rams:xml:ns:xmpp-tls'/>
(14:58:45) jabber: Recv (50): <proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"/>

(14:58:45) nss: subject=CN=gmail.com,O=Google Inc,L=Mountain View,ST=California,
C=US issuer=CN=Google Internet Authority G2,O=Google Inc,C=US
(14:58:45) nss: subject=CN=Google Internet Authority G2,O=Google Inc,C=US issuer
=CN=GeoTrust Global CA,O=GeoTrust Inc.,C=US
(14:58:45) nss: subject=CN=GeoTrust Global CA,O=GeoTrust Inc.,C=US issuer=CN=Geo
Trust Global CA,O=GeoTrust Inc.,C=US
(14:58:45) certificate/x509/tls_cached: Starting verify for gmail.com
(14:58:45) certificate/x509/tls_cached: Checking for cached cert...
(14:58:45) certificate/x509/tls_cached: ...Found cached cert
(14:58:45) nss/x509: Loading certificate from C:\Users\XMo\AppData\Roaming\.
purple\certificates\x509\tls_peers\gmail.com
(14:58:45) certificate/x509/tls_cached: Peer cert did NOT match cached
(14:58:45) certificate: Checking signature chain for uid=CN=gmail.com,O=Google I
nc,L=Mountain View,ST=California,C=US
(14:58:45) certificate: ...Good signature by CN=Google Internet Authority G2,O=G
oogle Inc,C=US
(14:58:45) certificate: ...Good signature by CN=GeoTrust Global CA,O=GeoTrust In
c.,C=US
(14:58:45) certificate: Chain is VALID
(14:58:45) certificate/x509/tls_cached: Checking for a CA with DN=CN=GeoTrust Gl
obal CA,O=GeoTrust Inc.,C=US
(14:58:45) certificate/x509/tls_cached: Also checking for a CA with DN=CN=GeoTru
st Global CA,O=GeoTrust Inc.,C=US
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\AddTrust_External_Root.pem
(14:58:45) certificate/x509/ca: Loaded AddTrust External CA Root from C:\Program
 Files (x86)\Pidgin\ca-certs\AddTrust_External_Root.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\America_Online_Root_Certification_Authority_1.pem
(14:58:45) certificate/x509/ca: Loaded America Online Root Certification Authori
ty 1 from C:\Program Files (x86)\Pidgin\ca-certs\America_Online_Root_Certificati
on_Authority_1.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\AOL_Member_CA.pem
(14:58:45) certificate/x509/ca: Loaded AOL Member CA from C:\Program Files (x86)
\Pidgin\ca-certs\AOL_Member_CA.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\CAcert_Class3.pem
(14:58:45) certificate/x509/ca: Loaded CAcert Class 3 Root from C:\Program Files
 (x86)\Pidgin\ca-certs\CAcert_Class3.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\CAcert_Root.pem
(14:58:45) certificate/x509/ca: Loaded CA Cert Signing Authority from C:\Program
 Files (x86)\Pidgin\ca-certs\CAcert_Root.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\Deutsche_Telekom_Root_CA_2.pem
(14:58:45) certificate/x509/ca: Loaded Deutsche Telekom Root CA 2 from C:\Progra
m Files (x86)\Pidgin\ca-certs\Deutsche_Telekom_Root_CA_2.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\DigiCertHighAssuranceCA-3.pem
(14:58:45) certificate/x509/ca: Loaded DigiCert High Assurance CA-3 from C:\Prog
ram Files (x86)\Pidgin\ca-certs\DigiCertHighAssuranceCA-3.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\Entrust.net_Secure_Server_CA.pem
(14:58:45) certificate/x509/ca: Loaded Entrust.net Secure Server Certification A
uthority from C:\Program Files (x86)\Pidgin\ca-certs\Entrust.net_Secure_Server_C
A.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\Equifax_Secure_CA.pem
(14:58:45) certificate/x509/ca: Loaded (unknown) from C:\Program Files (x86)\Pid
gin\ca-certs\Equifax_Secure_CA.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\Equifax_Secure_Global_eBusiness_CA-1.pem
(14:58:45) certificate/x509/ca: Loaded Equifax Secure Global eBusiness CA-1 from
 C:\Program Files (x86)\Pidgin\ca-certs\Equifax_Secure_Global_eBusiness_CA-1.pem

(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\Go_Daddy_Class_2_CA.pem
(14:58:45) certificate/x509/ca: Loaded (unknown) from C:\Program Files (x86)\Pid
gin\ca-certs\Go_Daddy_Class_2_CA.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\GTE_CyberTrust_Global_Root.pem
(14:58:45) certificate/x509/ca: Loaded GTE CyberTrust Global Root from C:\Progra
m Files (x86)\Pidgin\ca-certs\GTE_CyberTrust_Global_Root.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\Microsoft_Internet_Authority.pem
(14:58:45) certificate/x509/ca: Loaded Microsoft Internet Authority from C:\Prog
ram Files (x86)\Pidgin\ca-certs\Microsoft_Internet_Authority.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\Microsoft_Internet_Authority_2010.pem
(14:58:45) certificate/x509/ca: Loaded Microsoft Internet Authority from C:\Prog
ram Files (x86)\Pidgin\ca-certs\Microsoft_Internet_Authority_2010.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\Microsoft_Secure_Server_Authority.pem
(14:58:45) certificate/x509/ca: Loaded Microsoft Secure Server Authority from C:
\Program Files (x86)\Pidgin\ca-certs\Microsoft_Secure_Server_Authority.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\Microsoft_Secure_Server_Authority_2010.pem
(14:58:45) certificate/x509/ca: Loaded Microsoft Secure Server Authority from C:
\Program Files (x86)\Pidgin\ca-certs\Microsoft_Secure_Server_Authority_2010.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\StartCom_Certification_Authority.pem
(14:58:45) certificate/x509/ca: Loaded StartCom Certification Authority from C:\
Program Files (x86)\Pidgin\ca-certs\StartCom_Certification_Authority.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\StartCom_Free_SSL_CA.pem
(14:58:45) certificate/x509/ca: Loaded Free SSL Certification Authority from C:\
Program Files (x86)\Pidgin\ca-certs\StartCom_Free_SSL_CA.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\Thawte_Premium_Server_CA.pem
(14:58:45) certificate/x509/ca: Loaded Thawte Premium Server CA from C:\Program
Files (x86)\Pidgin\ca-certs\Thawte_Premium_Server_CA.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\Thawte_Primary_Root_CA.pem
(14:58:45) certificate/x509/ca: Loaded thawte Primary Root CA from C:\Program Fi
les (x86)\Pidgin\ca-certs\Thawte_Primary_Root_CA.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\ValiCert_Class_2_VA.pem
(14:58:45) certificate/x509/ca: Loaded http://www.valicert.com/ from C:\Program
Files (x86)\Pidgin\ca-certs\ValiCert_Class_2_VA.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\VeriSign_Class3_Extended_Validation_CA.pem
(14:58:45) certificate/x509/ca: Loaded VeriSign Class 3 Extended Validation SSL
CA from C:\Program Files (x86)\Pidgin\ca-certs\VeriSign_Class3_Extended_Validati
on_CA.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\Verisign_Class3_Primary_CA.pem
(14:58:45) certificate/x509/ca: Loaded (unknown) from C:\Program Files (x86)\Pid
gin\ca-certs\Verisign_Class3_Primary_CA.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\VeriSign_Class_3_Public_Primary_Certification_Authority_-_G2.pem
(14:58:45) certificate/x509/ca: Loaded (unknown) from C:\Program Files (x86)\Pid
gin\ca-certs\VeriSign_Class_3_Public_Primary_Certification_Authority_-_G2.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\VeriSign_Class_3_Public_Primary_Certification_Authority_-_G5.pem
(14:58:45) certificate/x509/ca: Loaded VeriSign Class 3 Public Primary Certifica
tion Authority - G5 from C:\Program Files (x86)\Pidgin\ca-certs\VeriSign_Class_3
_Public_Primary_Certification_Authority_-_G5.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\VeriSign_Class_3_Public_Primary_Certification_Authority_-_G5_2.pem
(14:58:45) certificate/x509/ca: Loaded VeriSign Class 3 Public Primary Certifica
tion Authority - G5 from C:\Program Files (x86)\Pidgin\ca-certs\VeriSign_Class_3
_Public_Primary_Certification_Authority_-_G5_2.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\VeriSign_International_Server_Class_3_CA.pem
(14:58:45) certificate/x509/ca: Loaded (unknown) from C:\Program Files (x86)\Pid
gin\ca-certs\VeriSign_International_Server_Class_3_CA.pem
(14:58:45) nss/x509: Loading certificate from C:\Program Files (x86)\Pidgin\ca-c
erts\Verisign_RSA_Secure_Server_CA.pem
(14:58:45) certificate/x509/ca: Loaded (unknown) from C:\Program Files (x86)\Pid
gin\ca-certs\Verisign_RSA_Secure_Server_CA.pem
(14:58:45) certificate/x509/ca: Lazy init completed.
(14:58:45) certificate/x509/tls_cached: No Certificate Authorities with either D
N found found. I'll prompt the user, I guess.
(14:58:47) certificate/x509/tls_cached: User REJECTED cert
(14:58:47) certificate: Failed to verify certificate for gmail.com
(14:58:47) connection: Connection error on 0534E4E0 (reason: 15 description: SSL
 peer presented an invalid certificate)
(14:58:47) account: Disconnecting account m.zixxxxxxxx@gmail.com/ (00926D38)
(14:58:47) connection: Disconnecting connection 0534E4E0
(14:58:47) connection: Destroying connection 0534E4E0
(14:58:49) util: Writing file accounts.xml to directory C:\Users\XMo\AppData
\Roaming\.purple
(14:58:49) util: Writing file C:\Users\XMo\AppData\Roaming\.purple\accounts.
xml

A: I received the same error this morning and found a similar complaint here: http://comments.gmane.org/gmane.comp.gnome.pidgin.user/13678 .
I updated my Pidgin client to 2.10.7 as suggested and everything appears to work fine now.
I hope that helps.


text:
Q: Assign/add input form data with relevant file and upload to server angular 2 I am new to angular 2. I have a form input table which list a number of file names when files are uploaded/selected. After entering data for each files, I want to assign/add the selected files with respective form data and send it to server.

*

*How do I assign/add respective file to its form data?

*How do I send these files with their respective form data to server?

Below is my code. Any help or solution will be really appreciated. Thanks.
Template

Manage Documents

    <input type="file" id="uploadFile" style="display: none" (change)='onClickUploadDocument($event)' multiple>
      Select Documents to Upload

<form [ngFormModel]="uploadDocumentForm" (ngSubmit)="sendDocumentsToTruck(uploadDocumentForm.value, i)">

Document Name	Document Type
Document Date	Notes	Fleet ID	Action

    <input type="text" class="form-control" style="display: none" [(ngModel)]="file.name"  ngControl="fileName{{i}}" >
            {{file.name}}

    <input type="text" class="form-control" ngControl="type{{i}}" >
    <input type="date" class="form-control" ngControl="date{{i}}" >
    <input type="text" class="form-control" ngControl="notes{{i}}" >

         <input type="button"  value="Select Truck" class="btn btn-primary"
          data-toggle="modal" data-target="#selectTruckModalID"  (click)="selectTruck(i)">
         <input type="text" class="form-control" style="display: none"
           ngControl="fleetId{{i}}" [(ngModel)]="selectedTruckId[i]" >

<button type="submit" class="form-group" class="btn  btn-primary " >Send</button>
 </form>

Component
import {Component, OnInit, OnChanges, Output, EventEmitter} from '@angular/core';
import {NgClass, FORM_DIRECTIVES, Control, ControlGroup, FormBuilder } from '@angular/common';
import {ROUTER_DIRECTIVES} from '@angular/router-deprecated';
import {FleetService} from '../../fleet/fleetControlPanel/fleetControlPanelService';

@Component({
    selector: 'documentManagement',
    templateUrl: 'app/dashboard/features/documents/documentManagement/documentManagementTemplate.html',
    directives: [ROUTER_DIRECTIVES, NgClass, FORM_DIRECTIVES ]
})

export class DocumentManagementComponent implements OnInit, OnChanges {

    uploadDocumentForm: ControlGroup;
    file: any;
    files: any[] = [];
    errorMessage: any;
    trucks: any[];
    truckId: any;
    documentIndex: number;
    selectedTruckId: any[] = [];

    @Output() refreshDocumentList: EventEmitter<any> = new EventEmitter<any>();

    // constructor to loop the products in product service file and disply in html
    constructor( private _fleetService: FleetService,
                 private _formBuilder:  FormBuilder){

        this.uploadDocumentForm = _formBuilder.group({

        });

    }

    ngOnInit(): void {
               //  load list of trucks
        this._fleetService.getFleets()
             .subscribe(
                 fleets => {
                     this.trucks = fleets
                     console.log("total trucks in list:..", this.trucks)
                 },
                 error => this.errorMessage = <any>error)
    }

    ngOnChanges(): void {
    }

    //
    onClickUploadDocument(event){
        console.log("clicked")
        let fileList: FileList = event.target.files;

   // console.log("file: ",fileList);
    for (let i = 0; i < fileList.length; i++) {
        this.file = fileList[i];
         console.log("files are: ",this.file);
         this.files.push(this.file);

    }

         this.files.forEach((value, index) => {
             this.uploadDocumentForm.addControl('fileName' + index, new Control()),
            this.uploadDocumentForm.addControl('type' + index, new Control()),
            this.uploadDocumentForm.addControl('date' + index, new Control()),
            this.uploadDocumentForm.addControl('fleetId' + index, new Control()),
            this.uploadDocumentForm.addControl('notes' + index, new Control())
        })
        console.log("total files in list:..upload..", this.files)
    }

    // send document and related form details to server on click SEND
    sendDocumentsToTruck (documents: any) {
         console.log("file:..", documents)
   }
}


text:
Q: How to get the window width in blazor I'm trying gu get the window width for responsive stuff.
Thanks!
I have tryied
@code{ public WindowState State { get; set; } = WindowState.Default;}
`@code{private Window myWindow = ?}`

A: Check this link for a tutorial
https://blazor.tips/blazor-how-to-ready-window-dimensions/
basically you need to register the IJSRuntime to invoke a JS getDimensions() function
using Microsoft.JSInterop;
using System.Threading.Tasks;

public class BrowserService
{
    private readonly IJSRuntime _js;

    public BrowserService(IJSRuntime js)
    {
        _js = js;
    }

    public async Task<BrowserDimension> GetDimensions()
    {
        return await _js.InvokeAsync<BrowserDimension>("getDimensions");
    }

}

public class BrowserDimension
{
    public int Width { get; set; }
    public int Height { get; set; }
}

JS Details
<script type="text/javascript">
    window.getDimensions = function() {
        return {
                width: window.innerWidth,
                height: window.innerHeight
            };
    };
</script>

A: Create a JavaScript file, e.g. scripts/getwindowsize.js:
export function getWindowSize()
{
    return {
        width: window.innerWidth,
        height: window.innerHeight
    };
};

In your .razor file:
@inject IJSRuntime JsRuntime

Displaly the Window size: @windowWidth, @windowHeight
<button class="btn btn-primary" @onclick="OnButtonClick">Get Dimensions</button>

@code {
    private IJSObjectReference jsModule;

    public int windowHeight, windowWidth;

    public class WindowDimensions
    {
        public int Width { get; set; }
        public int Height { get; set; }
    }

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            jsModule = await JsRuntime.InvokeAsync<IJSObjectReference>("import", "./scripts/getwindowsize.js");
        }
    }

    private async Task OnButtonClick()
    {
        var dimension = await jsModule.InvokeAsync<WindowDimensions>("getWindowSize");
        windowHeight = dimension.Height;
        windowWidth = dimension.Width;
    }

}

Don't forget to tell you browser to do a hard reload, and empty the cache, if you changed the contents of getwindowsize.js, such as if you used an answer from a previous answer or web site.
This is for Blazor WebAssembly, .Net Core 5.

A: C# Code :
using Microsoft.JSInterop;
public class BrowserService
{
    private readonly IJSRuntime _jsRuntime;

    public BrowserService(IJSRuntime jsRuntime)
    {
        _jsRuntime = jsRuntime;
    }

    private async Task<DeviceType> GetDeviceType()
    {
        var dimension = await _jsRuntime.InvokeAsync<BrowserDimension>("getBrowserDimension");
        return dimension.Width switch
        {
            < 600 => DeviceType.Mobile,
            < 960 => DeviceType.Tablet,
            _ => DeviceType.Desktop
        };
    }

    public async Task<bool> IsMobile() => await GetDeviceType() == DeviceType.Mobile;
    public async Task<bool> IsTablet() => await GetDeviceType() == DeviceType.Tablet;
    public async Task<bool> IsDesktop() => await GetDeviceType() == DeviceType.Desktop;
}

public class BrowserDimension
{
    public int Width { get; set; }
    public int Height { get; set; }
}

public enum DeviceType
{
    Mobile = 1,
    Tablet = 2,
    Desktop = 3
}

Service Install :
builder.Services.AddSingleton<BrowserService>();

Js Code :
window.getBrowserDimension = function() {
    return {
        width: window.innerWidth,
        height: window.innerHeight
    };
};


text:
Q: Max&min of a sinus DF ; TypeError: 'function' object does not support item assignment I try to get the min & max spots of a Dataframe that is sinusoidal. The Frequency is in 400er steps.
I wanted to define the function amplitude and collect the data in an array. Amp1 is an abs max value that should be collected and added to the list.
After trying this code :
node1 = np.load( '1_v2_n.npy')
node2 = np.load( '2_v2_n.npy')
node3 = np.load( '3_v2_n.npy')
node4 = np.load( 'T_v2_n.npy')

At this part I get the failure :
def amplitude(array):
    for i in range (0,len(array),400):
        amp1[array]= abs(max(array[i:i+400]))
    return amp1[array]

print(amplitude(node1[0]))

I get the following output
TypeError                                 Traceback (most recent call last)
<ipython-input-132-d803767af22f> in <module>
      9     return amp1[array]
     10
---> 11 print(amplitude(node1[0]))
     12
     13

<ipython-input-132-d803767af22f> in amplitude(array)
      6 def amplitude(array):
      7     for i in range (0,len(array),400):
----> 8         amp1[array]= abs(max(array[i:i+400]))
      9     return amp1[array]
     10

TypeError: 'function' object does not support item assignment

I tried to vary the return on different spots but it does not help.


text:
Q: Add gem to gemfile with bundler from command line When using node package manager you can specify npm install --save mynodemodule which automatically pops the module in package.json
I was wondering if there is a command for bundler that allows you to add the gem and version to the gemfile from the command line?
For example bundle install --save nokogiri

A: as @zocoi described, you can use bundle and specify the group:
bundle add rails --group "development, test"

More information
bundle add --help

A: If you visit this question in 2018, bundler now has a cli to do this:

bundle add <gem-name> <version>

Version string could be your typical gem version including >= and ~

A: Just wrote Gemrat to do this.
    $ gem install gemrat
    $ gemrat nokogiri

    #=> gem 'nokogiri', '1.6.0' added to your Gemfile.
    #=> Bundling...

A: echo 'gem "nokogiri"' >> Gemfile


text:
Q: Magento: fetch value of "disable module output" The Magento backend allows you to disable module output per site.  I've done some Google searches but can't figure out how to grab this value through my code.  Basically when my module's output is disabled that works just fine.  But I've discovered (the hard way) that Magento doesn't prevent the module from loading per-site.
Because I'm extending some core classes, some constructors are still being executed.  My thought is to check if the module output is disabled.  If so, have my constructor call the parent's constructor.  If the module output is enabled, proceed with my custom code.
I just can't figure out how to grab this value for the current site (I am multi-sited, BTW).  Ideally it would be something like this:
$isThisEnabled = Mage::app()->getCurrentStore()->isOutputEnabled('myModule');
Basically have a single line that fetches the current site's value (or the default, if not specified for the current site).
Any help would be greatly appreciated!
EDIT: I found the table core_config_data, which appears to store this information.  I could manually query it if I had to, but I feel like Magento would have something built-in to return the current store's value, falling back to the default value.

A: It is a standard config setting, so accessing it should be no different than accessing any other config setting. You just need to know what is the path to this value. Analysing the DB I believe this should do the trick:
Mage::getStoreConfig('advanced/modules_disable_output/Namespace_Module');

A: The other option is that the Mage_Core_Helper_Abstract has an isModuleEnabled($moduleName = null) method, which means that you should be able to call:
Mage::helper('core/data')->isModuleEnabled('Namespace_Module')

There is also a isModuleOutputEnabled() method. Looking at the code, these don't seem to be filtered by store/view, whereas @silvo's method is.

A: <?php
public function mycontrollerAction()
{
    $moduleName = 'Namespace_Modulename';//eg Mage_Cms
    if(Mage::getConfig()->getModuleConfig($moduleName)->is('active', 'true'))
    {
        echo "Module Enable";
    }
    else
    {
      echo "Module Disable";
    }
}
?>


text:
Q: can we update a document in mongodb using _id in java? I am trying update document with object id but not getting result. Here is my code please help me
DBCollection patients= db.getCollection("Patients");
    BasicDBObject doc = new BasicDBObject();
            doc.put("name","seshu");

DBObject update=`new` BasicDBObject().append("_id",ObjectId("534e1c8e40a8af540cd01ff4"));

    patients`enter code here`.update(update, doc);

A: When you say "not getting result", I assume you mean that the document is not being updated?
Are you sure that you have the collection name, database name, and ObjectId correct? And that a document exists in that collection with that ObjectId. You should double check all of this via your program or the mongo shell.
Why don't you also try adding some extra checks/debugging in your code, something like this:
DBCollection patients = db.getCollection("Patients");
DBObject update = new BasicDBObject().append("_id", new ObjectId("..."));

long collectionCount = patients.count();
System.out.println(String.format("Collection count: %s", collectionCount));
long count = patients.count(update);
System.out.println(String.format("Count for query: %s", count));

BasicDBObject doc = new BasicDBObject();
doc.put("name", "seshu");

WriteResult writeResult = patients.update(update, doc);
System.out.println(String.format("Updated %s records", writeResult.getN()));

DBObject updated = patients.findOne(update);
System.out.println(updated);


text:
Q: Creating a path shortcut? This may seem like a simple question but I was wondering if you can create an easily accessible shortcut to a program file instead of having to navigate through C every time.

A: Right-click on an application, select Send to:, and choose a destination for the shortcut.


text:
Q: ElasticSearch - Exact whole words matching for Equal to operations I am looking for a way to get the result by matching EXACT WHOLE WORDS from Elasticsearch. This is for "EQ" ("=") operations from UI.
{
    "_index": "docs",
    "_type": "_doc",
    "_id": "1",
    "_score": 1.0,
    "_source": {
        "DocId": 1,
        "DocDate": "2020-07-24T10:16:44.0000000Z",
        "Conversation": "I just need to know how frequently I should remind you"
    }
},
{
    "_index": "docs",
    "_type": "_doc",
    "_id": "2",
    "_score": 1.0,
    "_source": {
        "DocId": 2,
        "DocDate": "2020-07-25T10:16:45.0000000Z",
        "Conversation": "Building a work culture in your firm"
    }
}

in here, when querying with "I just need to know how frequently I should remind you" for Conversation, then only ES should return DocId 1 data.
Even the query is like "I just need to know how frequently I should remind", then it should return empty.
I tried these ES queries, but not able to figure it out.
GET docs/_search
{
  "query": {
    "bool": {
      "must": [
        {"match_phrase": {
          "Conversation": "just need to know"
        }}
      ]
    }
  }
}

GET docs/_search
{
  "query": {
    "query_string": {
      "default_field": "Conversation",
      "query": "\"just need to know\""
    }
  }
}

GET docs/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "Conversation": {"query": "just need to know",
              "operator": "and"
            }
          }
        }
      ]
    }
  }
}

A: You need to add .keyword to the Conversation field. This uses the keyword analyzer instead of the standard analyzer (notice the ".keyword" after the Conversation field).
When using standard analyzer
GET /_analyze
{
  "analyzer" : "standard",
  "text" : "I just need to know how frequently I should remind you"
}

The following tokens are generated :
{
  "tokens": [
    {
      "token": "i",
      "start_offset": 0,
      "end_offset": 1,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "just",
      "start_offset": 2,
      "end_offset": 6,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "need",
      "start_offset": 7,
      "end_offset": 11,
      "type": "<ALPHANUM>",
      "position": 2
    },
    {
      "token": "to",
      "start_offset": 12,
      "end_offset": 14,
      "type": "<ALPHANUM>",
      "position": 3
    },
    {
      "token": "know",
      "start_offset": 15,
      "end_offset": 19,
      "type": "<ALPHANUM>",
      "position": 4
    },
    {
      "token": "how",
      "start_offset": 20,
      "end_offset": 23,
      "type": "<ALPHANUM>",
      "position": 5
    },
    {
      "token": "frequently",
      "start_offset": 24,
      "end_offset": 34,
      "type": "<ALPHANUM>",
      "position": 6
    },
    {
      "token": "i",
      "start_offset": 35,
      "end_offset": 36,
      "type": "<ALPHANUM>",
      "position": 7
    },
    {
      "token": "should",
      "start_offset": 37,
      "end_offset": 43,
      "type": "<ALPHANUM>",
      "position": 8
    },
    {
      "token": "remind",
      "start_offset": 44,
      "end_offset": 50,
      "type": "<ALPHANUM>",
      "position": 9
    },
    {
      "token": "you",
      "start_offset": 51,
      "end_offset": 54,
      "type": "<ALPHANUM>",
      "position": 10
    }
  ]
}

Whereas the keyword analyzer returns the entire input string as a single token.
If you have not defined any explicit mapping, then your modified search query will be :
{
  "query": {
    "match": {
      "Conversation.keyword": "I just need to know how frequently I should remind you"
    }
  }
}

You can even change your index mapping, in the following way :
{
  "mappings": {
    "properties": {
      "Conversation": {
        "type": "keyword"
      }
    }
  }
}


text:
Q: Using data keyword to define types but getting Multiple declaration error I'm in the process of laying out all of the data types for an API wrapper I'm writing. I want to create each type separately, and then combine them under a group so that I can refer to them ambiguously.
E.g.
data Bookmark = Bookmark {
  url :: T.Text,
  title :: T.Text
} deriving (Show)

data Note = Note {
  author :: T.Text,
  text :: T.Text
} deriving (Show)

data APIObject = Bookmark | Note

This way, I could define something like the following:
retrieveFromAPI :: APIObject a => String -> a

Where String is a URL.
However, when I try to compile this, I get two errors:
[1 of 1] Compiling Main             ( API.hs, interpreted )

API.hs:28:16:
    Multiple declarations of `Bookmark'
    Declared at: API.hs:22:17
                 API.hs:28:16

API.hs:28:27:
    Multiple declarations of `Note'
    Declared at: API.hs:27:13
                 API.hs:28:27
Failed, modules loaded: none.

What should I be doing differently?
Thanks!

A: The problem is with APIObject, you have its constructors as Bookmark and Note, but those are also constructors for the Bookmark and Note data types!  Instead you could do something like
data APIObject = BM Bookmark | NT Note

So now you have a constructor BM :: Bookmark -> APIObject and a constructor NT :: Note -> APIObject.

Alternatively, if you aren't planning on adding more types to APIObject, you could just do
type APIObject = Either Bookmark Note

Since Either is defined as
data Either a b = Left a | Right b

so it's isomorphic (the same as) what you are trying to do.


text:
Q: Set $myVar as a variable with wildcard I have the below script which I had help with from here, one quick question how do you I set $MyVar as  variable, and a wildcard so partial name can be selected.
Select-AzureRmSubscription -SubscriptionName "MySubscription"
Get-AzureRmResourceGroup | Where-Object {$_.ResourceGroupName -like '$MyVar'} | ForEach-Object {
    $VMs = Get-AzureRmVM -ResourceGroupName $_.ResourceGroupName
    ForEach ($vm in $vms) {
        $tags2 = $VM.tags
        $tags2 += @{ShutdownSchedule_AllowStart="True"; ShutdownSchedule_AllowStop="True" }

        Set-AzureRmResource -ResourceName $vm.Name -ResourceGroupName $vm.ResourceGroupName -ResourceType "Microsoft.Compute/virtualMachines" -Tag $tags2 -Force -Verbose
    }
}

Not sure how to set it as a variable. Was thinking maybe {$_.ResourceGroupName -like $('$MyVar')}
Or do I need to set it as a parameter, as in a workflow, but not sure how to do that outside a workflow..

A: Use double quotes so the variable can be expanded (see about_quoting_rules), then add * to either end (or both) you want to wildcard:
{$_.ResourceGroupName -like "*$MyVar*"}


text:
Q: Caching the result of MethodHandles.lookup()? I am working in a situation where the MethodHandles.Lookup class is utilized often. In this situation, is it a wise idea to keep the value of MethodHandles.lookup() between multiple lookups? (Specifically, the only lookup method I am using is unreflect(java.lang.reflect.Method).)
Would this speed anything up, or would it be irrelevant? Or, would it actually slow it down for some reason?

A: As always with performance, the only good answer is test, measure, test again, measure again ...
That being said, yes caching will probably be faster, the question is will it be significantly faster in your context.
The drawback of caching is memory usage and thread safety. MethodHandle itself seems to be immutable (not explicitly documented but looking at the contract, this is most probably the case). MethodHandles.Lookup is used to check for security constraints, so caching might allow you to bypass, or at least change the behaviour regarding security constraints. This might or might not be a concern to you.
Memory usage comes into play if you cache lots of different MethodHandle. You need to make sure your cache is bounded and sized correctly. My guess is that you will not cache a lot of different instances, but that's only a guess...


text:
Q: How to declare element I'm looking for validate an XML document with xrm prefix as you can read here :
I wrote the following XML Schema :
     </xsd:extension>

  </xsd:complexContent>

</xsd:complexType>

</xsd:schema>

However, when I check my XML document, I get the following error:

'xrm:plugin' is not a valid value for 'NCName'

I understand I can't put xrm: in my name, but how can I validate my xrm:plugin and xrm:header ?
Because, if I try to validate my XML document, I get this error:

Cannot find the declaration of element 'xrm:plugin'.

A: xrm is a namespace prefix, an abbreviation for the namespace.  As the syntax error indicates, a namespace prefix is not declared via xsd:element/@name.  Instead, declare only the local name (plugin) and handle the namespace prefix declaration at the XSD level...
Here is a simplified set of your XML and XSD where the XML validates successfully against the XSD:
XML
<?xml version="1.0" encoding="UTF-8"?>
<xrm:plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.moss.fr/2011/connecteur_xrm result.xsd"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:xrm="http://www.moss.fr/2011/connecteur_xrm">
  <xrm:header>
    <xrm:tracabilite>
      <xrm:reference_moss>MPD_4.1.1.0</xrm:reference_moss>
      <xrm:document_lie> </xrm:document_lie>
      <xrm:document_interface>SC-DIF-OT3402-0002-MOSS 1.8 - DIF COSCA Inc.2.doc</xrm:document_interface>
      <xrm:intervention>
        <xrm:auteur>Générateur de mapping v1.0</xrm:auteur>
        <xrm:date>14/01/2013</xrm:date>
        <xrm:commentaire>Génération du fichier de mapping</xrm:commentaire>
      </xrm:intervention>
    </xrm:tracabilite>
  </xrm:header>
</xrm:plugin>

XSD
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:xrm="http://www.moss.fr/2011/connecteur_xrm"
            xmlns:SCCOAMCD="urn:SCCOA-schemaInfo"
            xmlns:SBEGestionZonesAeriennesSYSCA="urn:SBEGestionZonesAeriennesSYSCA-schema"
            SCCOAMCD:desc="  implémentation du MCD pivot du SCCOA 3.2.1ec  production par SCCOA mcd2mpd 4.1.1, le 11/12/2007  règles spécifiques production schémas 1.2  diagramme : A-SC.SBE GestionZonesAeriennes SYSCA  entité racine      : A-SC.ZoneAerienne "
            attributeFormDefault="unqualified"
            elementFormDefault="qualified"
            targetNamespace="http://www.moss.fr/2011/connecteur_xrm"
            version="3.2.1ec">
  <xsd:complexType name="header">
    <xsd:sequence>
      <xsd:any minOccurs="1" processContents="lax"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:element name="plugin">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="header" type="xrm:header"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>


text:
Q: Динамические поля формы в Bitrix Доброе время суток. Нужно сделать форму, в которой поле содержит два варианта ответа типа Radio Да/Нет и в случае Нет позволяет самому ввести ответ в появившийся инпут типа textbox. Своего рода пункт Другое как в бумажных анкетах. Мануал курил, понял мало. PHP и иже с ним знаю, не знаю только Bitrix. Как проще реализовать, через свой валидатор или есть нативный способ в расширенном режиме. И да - потом форма отправляется почтой, поэтому поле должно выдать или ДА или ДРУГОЕ %usertext%. Заранее спасибо.

A: Можно сделать через jQuery. Если выбран ответ ДА то скрывать поле, если НЕТ то показывать. Отправляться оно будет в любом случае.
$('input:radio[name="postage"]').change(
function(){
    if ($(this).val() == 'Yes') {
        $('#text').hide();
    }
    else {
        $('#text').show();
    }
});

Пример кода - https://jsfiddle.net/hcj2nja9/


text:
Q: Get user input from input field in react similar to getElementById in react native using props I am doing a loan calculation app and i run into the trouble since i am new to react native and previously i have been manipulating the DOM using querySelector or getElementById functions. However this does not work in react, and i am using state to store the value from the user, but i just can't seem to get it right, What am i doing wrong?
I've inserted the calculation element that is later rendered in app.js. All elements are showing up with no error, but the problem is to get user input data and then be able to use that data and do calculations.

Here is my Class

class LanKalkylElement extends React.Component {

constructor(props) {
    super(props);
    this.state = {
        loanAmount: 20000,
        loanInterest: 2.5,
        loanYear: 10,
    };
  }

  changeAmount(loanAmount) {
    this.setState(() => {
      return {
        loanAmount: parseFloat(loanAmount),
      };
    });
  }

  changeInterest(loanInterest) {
    this.setState(() => {
      return {
        loanInterest: parseFloat(loanInterest),
      };
    });
  }

  changeYear(loanYear) {
    this.setState(() => {
      return {
        loanYear: parseFloat(loanYear),
      };
    });
  }

calcButton() {
    Alert.alert(this.props.loanAmount);
}

buttonHomeFunc() {
    this.props.navigation.navigate('Start');
}

render() {
    const {loanAmount, loanInterest, loanYear} = this.state;
    return(
        <View  style={styles.contentStyle}>

            <Text style={styles.text}> Lånebelopp </Text>
            <TextInput  style={styles.numericInput}
                        onBlur={Keyboard.dismiss}
                        keyboardType={'numeric'}
                        value={loanAmount}
                        onValueChange={this.changeAmount.bind(this)} />

            <Text style={styles.text}> Ränta </Text>
            <TextInput  style={styles.numericInput}
                        onBlur={Keyboard.dismiss}
                        keyboardType={'numeric'}
                        value={loanInterest}
                        onValueChange={this.changeInterest.bind(this)} />

            <Text style={styles.text}> Antal år: {String(loanYear)}</Text>
            <Slider step={1}
                    maximumValue={15}
                    value={loanYear}
                    onValueChange={this.changeYear.bind(this)} />

            <Button title='Kalkylera' onPress={() => this.calcButton()}/>
            <Text style={styles.textResult}>Total summa att återbetala:</Text>
            <Text style={styles.textResult}>varav räntekostnad:</Text>
            <Button title='Tillbaka' onPress={() => this.buttonHomeFunc()}/>

        </View>
    )
}
}
export default withNavigation(LanKalkylElement);

A: When a user changes a value in a text input, onValueChange is called. You have bound this prop to functions that modify the state for this component.
This means the value in the text input will always match the value in the state. Therefore, if you need to access the value in a text input you would simply retrieve it from the state, like this:
const loanAmount = this.state.loanAmount;
doSomethingWithLoanAmount(loanAmount);


text:
Q: Salesforce1 Mobile SSO with OpenID Connect, possible? Reading through the SSO possibilities, I found nothing related to SalesforceApp SSO with the OpenID Connect
I got documentation related only to implementation with SAML
Is is possible by any chance to make Salesforce1 to use SSO with OpenID Connect?

A: Yes, it is possible to use SSO with OpenID connect. Follow these steps to configure OpenID connect external auth provider:
https://developer.salesforce.com/docs/atlas.en-us.mobile_sdk.meta/mobile_sdk/sso_provider_openid_connect.htm

To configure it on Salesforce App (aka Salesforce1), you will need to restrict the org to login exclusively through SSO (this is done on 'My Domain Configurations') and then set up a connection on SF1 with your custom domain. With these steps done, the login page of SF1 will be the login page of your configured IDP


text:
Q: CSS Precedence strange behaviour I was researching precedence in CSS and reading some articles, including this: http://www.w3.org/TR/CSS2/cascade.html. According to him, attributes like classes have higher precedence over pseudo-elements. However, when I did a simple test, the opposite happened. Below, my code:
HTML:

Item

CSS:
ul li.item { font-size: 12px; }
ul li:first-letter { font-size: 20px; }

See it here. Why the font-size of the first letter has 12 pixels instead of 20 pixels if the class has higher precedence than pseudo-elements? Thanks in advance.

A: I have just looked at your fiddle in Firefox, and you don't have a problem, it is working correctly. The font size of the word is 12px as asked for. But the first-letter pseudo element is all about identifying the first letter as a separate entitiy, and giving it a different style to that used for the rest of the word. As such, the specificity of the first letter is entirely separate from the specificity of the whole word; they do not override each other.
So your first letter in the fiddle is correctly 20px.


text:
Q: Sum Value in foreach loop every 3 time looping @foreach($group as $key=>$data)
{{$data->value}}
@endforeach

For example:
value1 = 1
value2 = 2
value3 = 3
value4 = 4
value5 = 5
value6 = 6
value7 = 7
value8 = 8
value9 = 9
value10 = 10
value11 = 11
value12 = 12
I want to count $data every 3 time loop, so the result is
result lopping1 =6
result lopping2 =15
result lopping3 =24
result lopping4 =33
note:
6 = 1+2+3
15 = 4+5+6
24 = 7+8+9
33 = 10+11+12
What should i do?

A: This is Blade Syntax answer:
@foreach(array_chunk($group, 3) as $value)

        @php
            echo array_reduce($value, function($sum, $item) {
                    $sum +=$item->value;
                    return $sum;
                })
        @endphp

@endforeach

or pure PHP:
<?php
$groupSum = [];
foreach (array_chunk($group, 3) as $value) {
    $groupSum[] = array_reduce($value, function ($sum, $item) {
        $sum += $item->value;
        return $sum;
    });
}

print_r($groupSum);

All this because there are objects in author question.

A: you need to count iteration and save it.something like this.
$collection=array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
$count=1;
$result=array();
foreach ($collection as $value) {
    $result[]=$value;
    $count++;
    if ($count==4) {

    $data=array_sum($result);
    $result = array_map(function($v){ return 0; }, $result);
    $count=1;
    echo $data;
    echo '
';
}
}

A: You can use array_chunk and array_sum
$array_number = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);

$test = array_chunk($array_number, 3);
$i = 0;
while($i < count($test)){
    echo array_sum($test[$i]);
    $i++;
}

For you, maybe below option works
@foreach ($group->chunk(3) as $chunk)
    {{$chunk->sum()}}
@endforeach

A: You can loop your array for i+3 and add the values accordingly.
If your array has elements in multiples of 3 then you can do this
for($i=2; $i<count($arr); $i+=3) {
    $data = ($arr[$i] + $arr[$i-1] + $arr[$i-2]);
    echo "".$data."	";
}

If your array has elements less than 3 then you can do this
for($i=0; $i<count($arr); $i++) {
    $data += $arr[$i];
}
echo "".$data."	";

If your array has elements more than 3 but not in multiples of 3 then you can do this
$post = count($arr) % 3;
for($i=2; $i<(count($arr) - $post); $i+=3) {
    $data = ($arr[$i-1] + $arr[$i-2] + $arr[$i]);
    echo "".$data."	";
}
$last = "";
for($i=(count($arr) - $post); $i<count($arr); $i++) {
    $last += $arr[$i];
}
echo "".$last."	";

By combining all conditions
if (count($arr) < 3) {
    $data = "";
    for($i=0; $i<count($arr); $i++) {
        $data += $arr[$i];
    }
    echo "".$data."	";
}else if (count($arr) % 3 == 0) {
    for($i=2; $i<count($arr); $i+=3) {
        $data = ($arr[$i-1] + $arr[$i-2] + $arr[$i]);
        echo "".$data."	";
    }
}else{
    $post = count($arr) % 3;
    for($i=2; $i<(count($arr) - $post); $i+=3) {
        $data = ($arr[$i-1] + $arr[$i-2] + $arr[$i]);
        echo "".$data."	";
    }
    $last = "";
    for($i=(count($arr) - $post); $i<count($arr); $i++) {
        $last += $arr[$i];
    }
    echo "".$last."	";
}


text:
Q: Proguard Change String Request Variable name when send to Server I am Using string Request when I create a Signapk Proguard Change name of the variable is in a b c d e f How I can handle it
it is only an issue in one request all other requests working fine in this request I am using GSON
Here is my Code
senditems_ is an array list that contains 5 records of students
String studentBatchListString = new Gson().toJson(send_items_);
@Override
protected Map<String, String> getParams() throws AuthFailureError {
   Map<String, String> parameters = new HashMap<String, String>();
   Log.i("timessendreq","send");
   parameters.put("list_items",studentBatchListString);
   return parameters;
}

I am using volley string request My Class name is (Checkoutinfo)
pakege name is com.app.trasfer

A: You have two options to solve it

*

*Use the annotations in the code and add proper proguard configuration

Field serialized name
@SerializedName("keyType")
String keyType;

proguard configuration
-keepclassmembers,allowobfuscation class * {
    @com.google.gson.annotations.SerializedName <fields>;
}
-keep,allowobfuscation @interface com.google.gson.annotations.**

*If you dont want to use the annotation, then you need to exclude the class from obfuscation
-keepclassmembers class com.example.app.YourClass{
     public protected private *;
     #Keep default members & functions
     !public !protected !private *;
 }

A: Keep User Student Object By add @Keep annotation Top of yor class, Something like below
@Keep
class Student{
int id;
}


text:
Q: how can i write the code for iphone 3.5 inches screen and 4 inches screen for ios6 & ios7 I am developing an app. In the app I wrote the code for a 3.5-inches screen and 4-inches screen for ios7&ios6. I took one view controller; in this view controller I want to display two images, one for the top and another for the bottom. On the ios7 3.5-inch screen and 4 inches screen there is no problem with the display. But on the ios6 screen for 4-inches screen and 3.5 inches screen, there is a display problem. The two images are not displayed properly. I don't know how to write the same code for both the ios6 and ios7 for  4-inches& 3.5 inches screen. Please give me ideas, anyone. I am new to programming. Thanks in advance.
The below is my code.
Viewcontroller.m (3.5 inches and 4-inches screen for ios7 & ios6).
if ([[UIScreen mainScreen] bounds].size.height == 568)
{
    imgLogo=[[UIImageView alloc]initWithFrame:CGRectMake(75, 65, 162, 57)];

    imgLogo.image=[UIImage imageNamed:@"Logo-01.png"];

    [self.view addSubview:imgLogo];

    imgBuilding=[[UIImageView alloc]initWithFrame:CGRectMake(8, 415, 300, 153 )];

    imgBuilding.image=[UIImage imageNamed:@"image-02.png"];

    imgBuilding.alpha=0.4;

    [self.view addSubview:imgBuilding];
}
else
{
    imgLogo=[[UIImageView alloc]initWithFrame:CGRectMake(75, 70, 162, 57)];

    imgLogo.image=[UIImage imageNamed:@"Logo-01.png"];

    [self.view addSubview:imgLogo];

    imgBuilding=[[UIImageView alloc]initWithFrame:CGRectMake(0, 345, 320,140 )];

    imgBuilding.image=[UIImage imageNamed:@"image-02.png"];

    imgBuilding.alpha=0.4;

    [self.view addSubview:imgBuilding];
}

A: You have to check whether os is IOS 7 or Earlier and depending upon that you have set your imageView.
    UIImageView *imgLogo;
    UIImageView *imgBuilding;
    if ([[UIScreen mainScreen] bounds].size.height == 568)
    {
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
        {
            imgLogo=[[UIImageView alloc]initWithFrame:CGRectMake(75, 65, 162, 57)];
            imgBuilding=[[UIImageView alloc]initWithFrame:CGRectMake(8, 415, 300, 153 )];
        }
        else
        {
            imgLogo=[[UIImageView alloc]initWithFrame:CGRectMake(75, 45, 162, 57)];
            imgBuilding=[[UIImageView alloc]initWithFrame:CGRectMake(8, 395, 300, 153 )];

        }
        imgLogo.image=[UIImage imageNamed:@"icon.png"];

        [self.view addSubview:imgLogo];
        imgBuilding.image=[UIImage imageNamed:@"icon.png"];

        imgBuilding.alpha=0.4;

        [self.view addSubview:imgBuilding];
    }
    else
    {
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
        {
            imgLogo=[[UIImageView alloc]initWithFrame:CGRectMake(75, 70, 162, 57)];
            imgBuilding=[[UIImageView alloc]initWithFrame:CGRectMake(0, 345, 320,140 )];
        }
        else
        {
            imgLogo=[[UIImageView alloc]initWithFrame:CGRectMake(75, 50, 162, 57)];
            imgBuilding=[[UIImageView alloc]initWithFrame:CGRectMake(0, 325, 320,140 )];
        }
        imgLogo.image=[UIImage imageNamed:@"icon.png"];

        [self.view addSubview:imgLogo];
        imgBuilding.image=[UIImage imageNamed:@"icon.png"];

        imgBuilding.alpha=0.4;

        [self.view addSubview:imgBuilding];
    }

Hope this will help you.

A: You can do this via autoResizing aka 'Spring and Struts' or by utilizing the latest 'Autolayout' feature.
Either way allows you to maintain a single xib file while the positioning and sizing of the subViews remains the same (depending on the way you have set it up)
They can be set up via xib/storyboard as well as programmatically.

Springs and Struts was the previous method but it's still available:

*

*Spring is the stretching ability of the subView

*Strut is the placement or you can say, the hugging ability. (i.e. it hugs the top bound or the bottom bound or left or right)

Links:

*

*UIView autoresizingMask - Interface Builder to Code - Programmatically create struts and springs - Swift or Objective-C

*iPhone UIView set resisting/position struts/springs programmatically

Autolayout requires you to be comfortable with the concept of constraints
It's a tad bit more effort but hey, if apple says it's better, it sure is.
Links"

*

*http://matthewmorey.com/creating-uiviews-programmatically-with-auto-layout/

*https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/AutoLayoutinCode/AutoLayoutinCode.html

NOTE: You can't use both together. You have to disable Autolayout feature on the view if you want to use Springs & Struts


text:
Q: Angular uib-popover displays in wrong position when set on overflowed text I have a working example of my issue here:
http://plnkr.co/edit/vwZS5e?p=preview
Here's the problem span:

        MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe

I'm trying to display a popover above the center of this span when I mouseover it. I'm using text-overflow to cut off my text when it's too long. But it seems like uib-popover doesn't account for the overflow.. the popover appears way too far to the right.
Here's my css:
.test-container {
    text-overflow:ellipsis;
    overflow:hidden;
    width:100px;
    border:1px solid red;
    margin-top:50px;
    margin-left:50px;
}

I know I can place the popover on the test-container div, but I'd prefer the popover be in the center of the span.
Does anyone have an idea on how to fix this?

A:  is an inline element and width of an inline element depends on its content. If you will add more content, its width will increase and vice versa.
In above situation, you have very long string of text even without spaces. If you will inspect your  you will see that the width of  is much larger than the width of its parent .test-container.
uib-popover is taking its position according to the width of . If you will increase or decrease content of  element you will see change in position of uib-popover as well.
You can fix this by making  a block element and moving text clipping properties on it.

(function(){
  'use strict';

  angular
    .module('app', ['ui.bootstrap', 'ngAnimate']);
})();

(function(){
  'use strict';

  angular
    .module('app')
    .controller('appController', AppController);

  AppController.$inject = ['$log', '$timeout'];

  function AppController($log, $timeout) {
    var vm = this;

    return vm;
  }
})();
html,
body {
  background-color:darkgray;
}

.test-container {
  width:100px;
  border:1px solid red;
  margin-top:50px;
  margin-left:50px;
}

.test-container span {
  text-overflow:ellipsis;
  overflow:hidden;
  display: block;
}
<link data-require="bootstrap@*" data-semver="3.3.5" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />

      MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe..MouseoverMe