text:
Q: set popup while theme my login plugin register form submit I am working with theme my login plugin in wordpress. I have created popup after theme my login register. I have written jquery to display popup when register form is submit.The code is like :
$('#registerform').submit(function(){
    var mob = $("#cimy_uef_1").val();
    var email = $("#user_email").val();
    var pass1 = $("#pass1").val();
    var pass2 = $("#pass2").val();

    var len = $(".tml-register").find(".error").length;

    if(email != '' && pass1 != '' && pass2 != '' && pass1 == pass2)
    {
        //alert("nisarg");
        $.ajax
        ({
            type: "POST",
            url: "<?php echo plugins_url()."/invoice-system/send_sms.php"; ?>",
            data: {mob:mob,email:email},
        }).done(function(html){
            $('.cd-popup').addClass('is-visible');

            //close popup
            $('.cd-popup').on('click', function(event){
                if( $(event.target).is('.cd-popup-close') || $(event.target).is('.cd-popup') ) {
                    event.preventDefault();
                    $(this).removeClass('is-visible');
                }
            });
            //close popup when clicking the esc keyboard button
            setTimeout(function(){
                $(document).keyup(function(event){
                if(event.which=='27'){
                    $('.cd-popup').removeClass('is-visible');
                }
            });},10000);

        });
    }

Here the form is also submitted. When I submit form then page is reload so my popup is display for few seconds. Here I want to display popup after registration till I close popup. So what should I have to do?

A: First you need to stop form from submitting, you can do that using:
e.preventDefault();

Then you need to resubmit the form on popup close. You can do that using:
$( "#registerform" ).submit();

Your complete code will look like this:

$('#registerform').submit(function(e){
    e.preventDefault();
    var mob = $("#cimy_uef_1").val();
    var email = $("#user_email").val();
    var pass1 = $("#pass1").val();
    var pass2 = $("#pass2").val();

    var len = $(".tml-register").find(".error").length;

    if(email != '' && pass1 != '' && pass2 != '' && pass1 == pass2)
    {
        //alert("nisarg");
        $.ajax
        ({
            type: "POST",
            url: "<?php echo plugins_url()."/invoice-system/send_sms.php"; ?>",
            data: {mob:mob,email:email},
        }).done(function(html){
            $('.cd-popup').addClass('is-visible');

            //close popup
            $('.cd-popup').on('click', function(event){
                $( "#registerform" ).submit();
                if( $(event.target).is('.cd-popup-close') || $(event.target).is('.cd-popup') ) {
                    event.preventDefault();
                    $(this).removeClass('is-visible');
                }
            });
            //close popup when clicking the esc keyboard button
            setTimeout(function(){
                $(document).keyup(function(event){
                if(event.which=='27'){
                    $('.cd-popup').removeClass('is-visible');
                }
            });},10000);

        });
    }


text:
Q: How to redirect info like "Aborted (core dumped)" when execute "./a.out" There is a .out file, which will cause Aborted (core dumped) infomation when running.
I want to put this information Aborted (core dumped) into a file.
I want to put it into my program actually, but I have redirect problem. Once this problem solved, I can put it in my program by redirect and popen().
I try ./a.out 2>file, but it doesn't work.

A: Redirecting standard error for a.out won't do anything since a.out doesn't actually write the Aborted (core dumped) message. This message is written by the shell itself in response to an abnormal status returned when it calls waitpid or similar on your process.
In order to obtain the same information programmatically, you'll need to check the exit code which will be present in $?. Signal 11 (SIGSEGV) will result in exit code 128+11=139; SIGABRT (signal 6) should result in exit code 134.

redpajama_set_name: RedPajamaStackExchange


text:
Q: C++ inheritance, calling the given classes function instead of its parent? Really bad title, couldn't think of how to word it, sorry.
So say I had the following code:
class A {
    virtual int getSize() {
        return 0;
    }
}

class B : public A {
    int getSize() {
        return 32;
    }
}

void doStuff(A a) {
   std::cout << a.getSize() << std::endl;
}

int main() {
   B b;
   doStuff(b);
}

It would print out 0, however I want it to print out 32. In other words, I want to pass it the class and it prints out that classes function, so I could create a class C, where the size is 64, and if I pass that C instance to the doStuff function, I want it to print 64.
Is there any way I can do this in C++, would I have to use templates or some fancy C++ feature I don't know about?

A: A one-byte patch:
void doStuff(A &a) {
  std::cout << a.getSize() << std::endl;
}

Your version takes the argument by value, which means that the function makes a copy of b (a copy which is an A) and then calls the copy's getSize(). In this version, the function takes the argument by reference, and calls b's own getSize(), which is B::getSize().

A: You should use pointers, or even better: smart pointers! That way, the function of the runtime type gets called. It's a basic example of polymorhpism. If you want to avoid pointers, Beta's slicing approach is equally valid.
#include <iostream>
#include <memory>

class A {
    virtual int getSize() {
        return 0;
    }
}

class B : public A {
    virtual int getSize() {
        return 32;
    }
}

void doStuff(std::shared_ptr<A> a) {
   std::cout << a->getSize() << std::endl;
}

int main() {
   std::shared_ptr<A> b(new B());
   doStuff(b); // Will output '32'.
}

This should correctly call the function as implemented by B.

A: Slicing the object is one approach, and in addition I think you're asking for, I think, a pretty straightforward use of polymorphism in C++. http://www.cplusplus.com/doc/tutorial/polymorphism/
That's almost immediately applicable, just call your class A Shape, and B and C could be Square and Triangle. Your DoStuff function could take a pointer to a Shape, then you can pass it a triangle or a square, and when you deference the Shape in the function, it will call the correct function.
So you'd have (also you need to make the members public, I think):
class A {
public:
    virtual int getSize() {
        return 0;
    }
};

class B : public A {

public:
    int getSize() {
        return 32;
    }
};

void doStuff(A* a) {
    std::cout << a->getSize() << std::endl;
}

int main() {
    B b;
    doStuff(&b);
}


text:
Q: Wordpress WP eCommerce UPS Shipping I am using wordpress and wp eCommerce for my products, I am using UPS for shipping and I created an account with UPS and got the API and information I have entered under shipping is correct and I have checked all the right boxes.
I know that the UPS Shipping only does the calculations, however is there a way so when a user places an order, it goes into My UPS account with a tracking number or something similar. I got an email back from wp-ecommerce saying this
You would ship the product the way you would regardless of having the online store. In most cases this means going to your UPS system and creating a shipping label. At this point you will be provided a tracking number that you can then enter into the store sales log for that order. A notice will then be delivered to the person with the tracking information.
Is that the best way to do my shipping or does anyone have a better idea?
Thanks,
J

A: My two cents:  after beginning to follow @c2h50h's solution (great find, btw!), I realized that PayPal has a print shipping label option and integrates seamlessly with your UPS account.  My client uses PayPal Pro (which is their $30/month white label payment solution), and the shipping information transfers automatically to PayPal, where you can print labels after implementation.  Note:  this should also work with other PayPal (free) platforms.
While I got @c2h50h's solution working in testing, I realized there would be a lot of coding to create a viable plugin for the client.  They love the PayPal solution, though, and I have to admit, I'd be hard pressed to design something better/more reliable for their WordPress admin page.
Here's instructions in case you want to go this route:

*

*Sign up for PayPal Pro

*Next, add your PayPal API info to WP E-Commerce: How to find PayPal API credentials

*After setting this up, log into PayPal Account.

*On account page beside your order, click "Print Shipping Label."

*Add UPS account (or USPS)

*Client can print shipping labels from PayPal and charge to either their PayPal or UPS account.

*Put tracking number into WP E-Commerce.

Pretty easy.

A: This is the only way available for WP eCommerce at the moment:
I am unaware of any WP plugin that does anything but fetching shipping rates from UPS - you'd have to get someone to write you custom plugin that can also generate shipping digest and submit it to UPS to get a shipping label.
Here's some code you could start with to make such a plugin
$xmlRequest1='<?xml version="1.0" encoding="ISO-8859-1"?>
<AccessRequest>
<AccessLicenseNumber>ACCESS LICENCE NUMBER</AccessLicenseNumber>
<UserId>UPS USERNAME</UserId>
<Password>UPS PASSWORD</Password>
</AccessRequest>
<?xml version="1.0" encoding="ISO-8859-1"?>
<ShipmentAcceptRequest>
<Request>
<TransactionReference>
<CustomerContext>Customer Comment</CustomerContext>
</TransactionReference>
<RequestAction>ShipAccept</RequestAction>
<RequestOption>1</RequestOption>
</Request>
<ShipmentDigest>SHIPMENT DIGEST</ShipmentDigest>
</ShipmentAcceptRequest>
';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://wwwcie.ups.com/ups.app/xml/ShipAccept");
// uncomment the next line if you get curl error 60: error setting certificate verify locations
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
// uncommenting the next line is most likely not necessary in case of error 60
// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlRequest1);
curl_setopt($ch, CURLOPT_TIMEOUT, 3600);

//if ($this->logfile) {
//   error_log("UPS REQUEST: " . $xmlRequest . "\n", 3, $this->logfile);
//}
$xmlResponse = curl_exec ($ch); // SHIP ACCEPT RESPONSE
//echo curl_errno($ch);

$xml = $xmlResponse;

preg_match_all( "/\<ShipmentAcceptResponse\>(.*?)\<\/ShipmentAcceptResponse\>/s",
$xml, $bookblocks );

foreach( $bookblocks[1] as $block )
{
preg_match_all( "/\<GraphicImage\>(.*?)\<\/GraphicImage\>/",
$block, $author ); // GET LABEL

preg_match_all( "/\<TrackingNumber\>(.*?)\<\/TrackingNumber\>/",
$block, $tracking ); // GET TRACKING NUMBER
//echo( $author[1][0]."\n" );
}

echo '<img src="data:image/gif;base64,'. $author[1][0]. '"/>';

Code source: http://webcollage.wordpress.com/2011/05/13/ups-label-print-with-php/
And here http://webcollage.wordpress.com/2011/05/10/ups-shipping-confirmation-code-in-php/  you'll find how the shipping digest looks like


text:
Q: Change SATA mode to AHCI before reinstalling Windows on new drive - possible lose of data on non raid drive? Currently I've got 5 HDD connected to my PC: 1 is the OS drive, 2 are connected into raid0 volume0, 2 are connected into raid0 volume1 (the volume numbers might be wrong, I'm writing this from memory, but it's irrelevant here). So basically my OS seems 3 drives (C, D and E). I want to get rid of both raid0 volumes, switch to AHCI and add a new SSD. I've already backup'ed data from those raid volumes (~4TB).
Now since it's backup'ed I want to do this exactly:

*

*Plug the current OS HDD off

*Boot, enter BIOS/RAID management console (don't remember now if I have the CTRL+I console active or disabled)

*Delete both RAID volumes

*(If needed reboot) Switch RAID mode to AHCI mode. (I guess no point to keep RAID mode, even thou the performance difference isn't that drastic like IDE vs AHCI in terms of SSD)

*Turn PC off, plug every HDD off, plug SSD in.

*Boot into SSD, install OS (Windows 7 Pro x64), install drivers, turn PC off after all reboots are done.

*Plug HDD drives, boot, check OS boot order (change 1st to SSD if needed)

*Boot into Windows.

Perfectly when I boot with all those drives plugged in Windows should "see" the old OS HDD with data while the "old raid members" would need to be initiated via Disk Management, but is there a chance that switching to AHCI mode will nuke the data on that non raid drive (old OS HDD) and to keep it safe I should backup it too? (this might be a challenge as I'm almost at zero available backup space and I don't have monster upload speed to cloud-backup a 500GB HDD :/) I read that I can try to change SATA mode after the OS is installed, but since I plan to install it fresh on the SSD (no clone or anything) I might as well switch the SATA mode and not bother with it later (and to skip any BSODs)
Cheers!
No idea if specs aside from the OS is needed so here it is:

*

*MOBO: Gigabyte Z97-D3H-CF

*HDD (current): 1x 500 GB WDC WD5003AZEX-00MK2 (non raid, old OS HDD) + 4x 1TB WDC (don't remember the number but it's the same series as the 500GB one, just larger) - raid volume members

*SSD (new one) 240 GB GoodRam Iridium PRO

*OS: (current) Windows 7 Pro x64, (new) Windows 7 Pro x64

*32 GB of RAM, i7 4790 and an GF GPU

A: Your (non-RAID) data-disks will be fine, data-loss is not supposed to happen.
AHCI vs RAID vs IDE/Legacy mode doesn't have any relevance for the content of the disk. The disk should report the same capacity, block-numbering scheme, etc. to the BIOS and the OS.
The only difference is in the device-type (and capabilities) of the disk-controller that the BIOS will present to the OS.
I've done dozens of such conversions (I lost count, could be well over 100). Never seen any issue.

A: Data will be safe. Changing AHCI only affects Windows boot (AHCI has to be in the same state as of time of Installation - otherwise Windows will fail to boot.  But there is no data loss.


text:
Q: Mostrar una salida en un orden determinado en linux Hola necesito hacer un script que coja el archivo de /etc/group y muestre primero el guid y despues el nombre de cada grupo por ejemplo:
1:root, con esto less /etc/group | cut -d ":" -f 1,3 | sort  me muestra de la siguiente:

gracias
un saludo

A: cut preserva el orden de los elementos que encuentra en cada línea.
Debieras probar aws en vez de cut:
cat /etc/group | awk -v OFS=":" -F":" '{ print $3 ":" $1}' | sort


text:
Q: Xubuntu: Regular Freeze, can be recovered by changing to TTY With my Lenovo Flex 2-14 laptop (Xubuntu 14.04 installed), I'm experiencing regular complete freezes of the system (mouse and most keyboard interaction impossible, mouse pointer doesn't move anymore).
However, I found that the freeze can be resolved by just changing to any TTY and back (without doing anything else, not even logging in on the TTY). After that, I can go on working without any apparent loss of data or crashed applications.
I'm suspecting that there might be an issue related to the X server or window manager, but wasn't able to find any useful information on that so far.
So the question is: Is anybody able to deduce information related to the cause of the freezes (that occur frequently enough to be quite annoying, even though the "solution" seems to be very reliable) from my description of the "magic" remedey? - just change to one of the TTYs and back.
Thanks for any hints!


text:
Q: How find this limit $\lim_{x\to 0}\frac{1}{x^4}\left(\frac{1}{x}\left(\frac{1}{\tanh{x}}-\frac{1}{\tan{x}}\right)-\frac{2}{3}\right)=?$ Find this following limit
$$\displaystyle \lim_{x\to 0}\dfrac{1}{x^4}\left(\dfrac{1}{x}\left(\dfrac{1}{\tanh{x}}-\dfrac{1}{\tan{x}}\right)-\dfrac{2}{3}\right)=?$$
My try: since $$\tanh{x}=\dfrac{e^{x}-e^{-x}}{e^x+e^{-x}}$$
then
$$\dfrac{1}{\tanh{x}}-\dfrac{1}{\tan{x}}=\dfrac{e^{x}-e^{-x}}{e^x+e^{-x}}-\dfrac{1}{\tan{x}}$$
then I can't,Thank you

A: $$
\coth x=\frac{1}{x}+\frac{x}{3}-\frac{x^3}{45}+\frac{2x^5}{945}-\frac{x^7}{4725}+... \\
\cot x =\frac{1}{x}-\frac{x}{3}-\frac{x^3}{45}-\frac{2x^5}{945}-\frac{x^7}{4725}-... \\[0.9cm]
\text{Given limit is}\\ \lim_{x \to 0} \frac{1}{x^4}\left(\frac{1}{x}\left(\frac{2x}{3}+\frac{4x^5}{945} + ...\right)-\frac{2}{3}\right) \\
= \lim_{x \to 0} \frac{1}{x^4}\left(\frac{4x^4}{945} + ...\right) \\
=\frac{4}{945}
$$
Don't worry if you can't remember these power series. You can derive them in a jiffy using Bernoulli numbers. But that's for another day.

A: Take the power series expansion of tanh to fifth order, invert it.  Then take power series expanion of tan to fifth order, invert it.  Take the difference.  The rest is clear sailing. Note that the expansions will only have 3 nonzero terms since the functions are odd.


text:
Q: MongoDb transform timestamp to date IN query I have an application in which I have to make some stats and I m facing problems with the request.
In fact, what I need is :

*

*get the sum of a list item

*between two dates (timestamp format in DB)

*group by year and month

*if the task isDone

Actually, I have this query(that doesnt work for sure) :
db.collection.aggregate([{$match: {timestampentre: {$gt: start}, timestampentre: {$lt: end}}},{$project: {isDone: "$isDone", year: {$year: "$year"}, month: {$month: "$month"}}},{$group: {_id: {year: "$year", month: "$month"}, count: {$sum: 1}}}])

What I need is to translate the "timestampentre" in a MongoDb date during the query.
In fact, I need to get something like this :
{$match: {new Date(timestampentre): {$gt: new Date().getTime()}

With this, I ll be able to group on the month or the year
I dont know if it's correct or possible, but does it exist something that permit me to transform a timestamp in a date with mongodb ?
Thanks for advance


text:
Q: Show that if $A$ is symmetric, then $R$ is symmetric, and hence a diagonal matrix.
Let $P$ be an orthogonal matrix, $R$ be an upper triangular matrix, and $A=PRP^{-1}$. Show that if $A$ is symmetric, then $R$ is symmetric, and hence a diagonal matrix.

My approach:
Suppose $A=PRP^{-1}$. Since $P$ is an orthogonal matrix, it has orthogonal columns, and these columns are linearly independent, so $P$ is invertible and we can express $R$ as $R=P^{-1}AP$.
Since $P$ is orthogonal, $P^{-1}=P^T$ and since $A$ is symmetric $A=A^T$, transposing $R$ we show that $R$ is symmetric:
$$R^T=(P^{-1}AP)^T=P^TA^T(P^{-1})^T=P^TA^T(P^T)^T=P^{-1}AP=R$$
From here how do I show that $R$ is a diagonal matrix?

A: Your proof is so far correct. For the remaining part you just need to consider that $R$ is symmetric and assumed to be an upper diagonal matrix.

A: Since $R$ is an upper matrix then it has the form
$$
R = \left( {\begin{array}{*{20}c}
   {a_{11} } & {a_{12} } &  \cdots  & {a_{1n} }  \\
   0 & {a_{22} } &  \cdots  & {a_{2n} }  \\
    \vdots  &  \vdots  &  \ddots  &  \vdots   \\
   0 & 0 &  \cdots  & {a_{nn} }  \\
\end{array}} \right)
$$
and so that $R^T$ has the form $$
R^T  = \left( {\begin{array}{*{20}c}
   {a_{11} } & 0 &  \cdots  & 0  \\
   {a_{12} } & {a_{22} } &  \cdots  & 0  \\
    \vdots  &  \vdots  &  \ddots  &  \vdots   \\
   {a_{1n} } & {a_{2n} } &  \cdots  & {a_{nn} }  \\
\end{array}} \right)
$$
Now, since $R$ is symmetric $R=R^T$ then by comparing the corresponding terms in $R$ and $R^T$ then we find that
$$ R = \left( {\begin{array}{*{20}c}
   {a_{11} } & {a_{12} } &  \cdots  & {a_{1n} }  \\
   0 & {a_{22} } &  \cdots  & {a_{2n} }  \\
    \vdots  &  \vdots  &  \ddots  &  \vdots   \\
   0 & 0 &  \cdots  & {a_{nn} }  \\
\end{array}} \right) = \left( {\begin{array}{*{20}c}
   {a_{11} } & 0 &  \cdots  & 0  \\
   {a_{12} } & {a_{22} } &  \cdots  & 0  \\
    \vdots  &  \vdots  &  \ddots  &  \vdots   \\
   {a_{1n} } & {a_{2n} } &  \cdots  & {a_{nn} }  \\
\end{array}} \right) = R^T
$$
so that $$
\begin{array}{l}
 a_{12}  = 0,a_{13}  = 0, \ldots ,a_{1n}  = 0 \\
 a_{21}  = 0,a_{23}  = 0, \ldots ,a_{2n}  = 0 \\
  \vdots  \\
 \end{array}
$$ which means that $
R = \left( {a_{ii} } \right)$, $i=1,2,\cdots,n$ is a diagonal matrix.


text:
Q: Is temporary table reusable in MySQL? So my boss gave me a stored procedure that needs to be optimized since it is slow. The procedure is creating a temporary table in the process and it looks weird:
/* pseudocode for brevity */
create temp_table;

insert into temp_table (...)
    select ...
    from other_table
    inner join ...
    inner join ...
    where condition

select * from temp_table

So that is it. The code inserts data into the temporary table only to be retrieved right after. Here's what I did, I removed the temporary table and return directly the selected records:
/* pseudocode for brevity */
select ...
from other_table
inner join ...
inner join ...
where condition

The code before looks wrong, but I want to be sure what a temporary table does. So I read about temporary tables and figured that temporary tables lasts and can only be accessed in a single session. My question:

*

*What does session mean? When I'm in the application side and open a connection, can I reuse the temporary table? I wonder if that's why there is a temporary table here.

A: A session in Database mean a operation between opening an closing of a connection.
Eg. In a application side if i try to call a stored procedure and before that i open a connection to DB.The scope of a temporary table available until i say connection closed

A: As for SQL connection, Session means one connection u create. Once you make a connection to your database,the specified session will be created by database server.
And as an admitted newbie dev on SQL, I always choose temporary table when I need to do a branch of queries through many tables.(PS: my experience shows me that those rows stored in temporary table will no be updated though their value have been changed)
Similar question here.


text:
Q: Hapi.js, Bookshelf.js and a real world example I've been experimenting with Hapi.js recently and although it's a great framework there doesn't seem to be any real-world examples that are of any use.
One thing missing is the best way to load Models / Collections within Hapi (and node in general to be fair).
Is there any recommended best way of loading these with Hapi?
I'm currently separating all my route logic into plugins and I'm simply creating the Models and Collections within that plugin. I then use plugin.method('Models.MyModel', Model); method to make the model available throughout the application. The is fine for a small application but as the app gets bigger I'd like to split thing out more so I can separate routing and storage from the business logic.

A: I've just started to make a Project using Hapi and Boostrap. You can check it here
https://github.com/codetrash/hapi-project


text:
Q: Selecting item with Max count in laravel I have a voting table it have fields id,itemId,votes,voteDate.Vot field have values either 1(up vote)or-1(down vote).
i wants to select the itemId which have maximum up vote and maximum down vote (i mean if my item 1 have 3 upvotes  and my item 2 have 5 upvotes i want to get select item 2)in a specific time period(1 week).
my code is
DB::table('votes')
->leftjoin('items','items.id','=','votes.itemId')
->select('items.title','items.image',DB::raw('sum(votes.votes) as voteSum'))
->whereBetween('voteDate',array($timePeriod,$today))
->get();

I know this query is wrong.Please help me.

A: First you should find $sum_max_vote_in_the_date_interval.
Then use this
DB::table('votes')
->leftjoin('items','items.id','=','votes.itemId')
->select('items.title','items.image',DB::raw('sum(votes.votes) as voteSum'))
->whereBetween('voteDate',array($timePeriod,$today))
->havingRaw("SUM(`votes`.`votes`) = ".$sum_max_vote_in_the_date_interval)
->group_by(`votes`.'id')
->get();

OR
DB::table('votes')
->leftjoin('items','items.id','=','votes.itemId')
->select('items.title','items.image',DB::raw('sum(votes.votes) as voteSum'))
->whereBetween('voteDate',array($timePeriod,$today))
->havingRaw("SUM(`votes`.`votes`) = `votes`.`votes`")
->group_by(`votes`.'id')
->get();

Hope this helps.


text:
Q: (Objective-c/Mac OSX) How to distinguish managed AD users (AD user create mobile card) from local users on Mac OSX <\RESOLVED>, Please see the first reply
My mac(10.9) has joined into a AD domain. In my program, I tried to recognize whether the current login user is local account or AD user. I can successfully distinguish them by using the following code.
+ (bool)isLocalUser:(NSString*)user
{
    NSError *dirSearchError = nil;
    ODRecord *foundUser = findUser(user, &dirSearchError);
    if(foundUser !=nil)
    {
        return YES;
    }else
    {
        return NO;
    }
}

ODRecord *findUser(NSString *user, NSError **error)

{
    NSLog(@"[MacLogonUI] findUser");
    ODNode *searchNode = [ODNode nodeWithSession: [ODSession defaultSession]
                                        type: kODNodeTypeLocalNodes
                                       error: error];

    if (searchNode == nil) {
        return nil;
    }

    NSDictionary *nodeInfo = [searchNode nodeDetailsForKeys:nil error:error];

    /* query this node for the user record we're interested in.
     * We only need one result, which is why maximumResults is set to 1.
     */
    ODQuery *userSearch = [ODQuery queryWithNode: searchNode
                              forRecordTypes: kODRecordTypeUsers
                                   attribute: kODAttributeTypeRecordName
                                   matchType: kODMatchEqualTo
                                 queryValues: user
                            returnAttributes: kODAttributeTypeStandardOnly
                              maximumResults: 1
                                       error: error];

    if (userSearch == nil) {
        return nil;
    }

    /* For this example we'll use a synchronous search. This could take a while
     * so asynchronous searching is preferable.
     */

    NSArray *foundRecords = [userSearch resultsAllowingPartial: NO error: error];

    if (foundRecords == nil || [foundRecords count] == 0) {
        return nil;
    }

    ODRecord *userRecord = [foundRecords objectAtIndex: 0];
   return [[userRecord retain] autorelease];
}

While when the AD user create a mobile card, it is viewed as a managed user(from the System preference -> Users & Groups). The code also recognize this kind of AD user as local. How to deal with this kind of situation?
Do you guys have any idea of this problem?

A: I have solved this problem by myself. Hope the following code helps:
#import "DasUser.h"
#import <OpenDirectory/OpenDirectory.h>
#import <Collaboration/Collaboration.h>

@implementation DasUser

+ (bool)isLocalUser:(NSString*)user
{
    NSError *dirSearchError = nil;
    ODRecord *foundUser = findUser(user, &dirSearchError);
    if(foundUser !=nil)
    {
        return YES;
    }else
    {
        return NO;
    }
}

ODRecord *findUser(NSString *user, NSError **error)

{
    NSLog(@"[MacLogonUI] findUser");

    CSIdentityAuthorityRef defaultAuthority = CSGetManagedIdentityAuthority();
    CSIdentityClass identityClass = kCSIdentityClassUser;

    CSIdentityQueryRef query = CSIdentityQueryCreate(NULL, identityClass,                defaultAuthority);

    CFErrorRef err = NULL;
    CSIdentityQueryExecute(query, 0, &err);

    CFArrayRef results = CSIdentityQueryCopyResults(query);

    int numResults = CFArrayGetCount(results);

    NSMutableArray * managedUsers = [NSMutableArray array];
    for (int i = 0; i < numResults; ++i) {
        CSIdentityRef identity = (CSIdentityRef)CFArrayGetValueAtIndex(results, i);
        CBIdentity * identityObject = [CBIdentity identityWithCSIdentity:identity];
        NSString* posixName = [identityObject posixName];
        [managedUsers addObject:posixName];
    }

    CFRelease(results);
    CFRelease(query);

    ODNode *searchNode = [ODNode nodeWithSession: [ODSession defaultSession]
                                        type: kODNodeTypeLocalNodes
                                       error: error];

    if (searchNode == nil) {
        return nil;
    }

    /* query this node for the user record we're interested in.
     * We only need one result, which is why maximumResults is set to 1.
     */
    ODQuery *userSearch = [ODQuery queryWithNode: searchNode
                              forRecordTypes: kODRecordTypeUsers
                                   attribute: kODAttributeTypeRecordName
                                   matchType: kODMatchEqualTo
                                 queryValues: user
                            returnAttributes: kODAttributeTypeStandardOnly
                              maximumResults: 1
                                       error: error];

    if (userSearch == nil) {
        return nil;
    }

    /* For this example we'll use a synchronous search. This could take a while
     * so asynchronous searching is preferable.
     */

    NSArray *foundRecords = [userSearch resultsAllowingPartial: NO error: error];

    if([foundRecords count]>0)
    {
        NSString *nameStr = [foundRecords[0] recordName];

        NSLog(@"[MacLogonUI] findUser nameStr %@", nameStr);

        int j;
        for( j = 0; j<[managedUsers count]; j++)
        {
            if([nameStr isEqualToString:managedUsers[j]])
            {
                break;
            }
        }

        if(j<[managedUsers count])
        {
            foundRecords = nil;
        }
    }

    if (foundRecords == nil || [foundRecords count] == 0) {
        return nil;
    }

    ODRecord *userRecord = [foundRecords objectAtIndex: 0];
    return [[userRecord retain] autorelease];
}

@end

While when network of the mac is disconnected. The managed user can not be listed. Is there anybody has any idea of this?


text:
Q: Typo3 Command error: Tag "var" does not exist When running a commandcontroller through a scheduler I am getting the following failed message:
Tag "var" does not exist

...The only "var" reference is the @var comments. I've gone through each of those and they all reference variables correctly.
Does anybody know what this error might be referring to?
The entire error from the scheduler was as follows:
[scheduler]: scheduler - Task failed to execute successfully. Class: TYPO3\CMS\Extbase\Scheduler\Task, UID: 2, Code: 1169128255, Tag "var" does not exist.

A: For anybody else who comes across this issue, the problem was as follows:
I was using @inject for one of my protected class variables, like so:
* @var \Softcon\KhsjMitarbeiter\Controller\MitarbeiterController
* @inject

...I then added my other variables @vars BELOW this, like so
*  @var string $email
*  @var string $csvPath
*  @var string $tableName

...which seemed to cause the error. I simply moved these other variable comments/tags/whatever you want to call them ABOVE the injection lines, which solved the problem.


text:
Q: Auto-deduction of reference template argument from not-reference type in C++ In the following program there are

*

*struct A<int> template, and

*function template f<I> having const int& template argument, and A<I> function argument:

template<int>
struct A {};

template<const int & I>
void f(A<I>) {}

int main() {
    const static int a = 0;
    f<a>(A<a>{}); // ok in GCC and Clang
    f(A<a>{});    // ok in GCC
}

The function can be called explicitly specifying template argument <a> in GCC and Clang.
But auto-deduction of template argument works only in GCC, while Clang complains:
error: no matching function for call to 'f'
note: candidate template ignored: could not match 'const int' against 'int'

Demo: https://gcc.godbolt.org/z/G86dxh9jo
Which compiler is right here?

A: I'm pretty sure Clang is right.
According to [temp.deduct.call]/4

In general, the deduction process attempts to find template argument values that will make the deduced A identical to A (after the type A is transformed as described above). However, there are three cases that allow
a difference: [...]

A is the transformed argument type used in the call. The transformations referred to include certain conversions (e.g. array to pointer decay) that are not relevant here. Importantly, only the type A can be considered for the deduction (not the form of the actual argument), and the type A is A<0>. From the type A<0>, how can GCC deduce what the template parameter I (of type const int&) should be?
It can't be a reference to a, because the fact that the 0 came from a is not part of the type of the argument A<a>{}. I think GCC is materializing a temporary and taking I as a reference to that temporary. But [temp.arg.nontype]/3.1 bans this, so the result ought to be a deduction failure.


text:
Q: How to put values over bars in barplot in R This question is related to my previous question. I would like to put values over bars in barplot. I am beginner in plotting in R.

A: Another example of the use of text command
u <- c(3.2,6.6,11.7,16.3,16.6,15.4,14.6,12.7,11.4,10.2,9.8,9.1,9.1,9.0,8.8,8.4,7.7)
p <-c(3737,3761,3784,3802,3825,3839,3850,3862,3878,3890,3901,3909,3918,3926,3935,3948)
     -c(385,394,401,409,422,430,434,437,437,435,436,437,439,442,447,452)
e <- c(2504,2375,2206,2071,2054,2099,2127,2170,2222,2296,2335,2367,2372,2365,2365,2401)

par(mar=c(2,3,1,2),las=1,mgp=c(2.2,1,0))
x <- barplot(u,names.arg=1990:2006,col="palegreen4",space=.3,ylim=c(0,20),
              ylab="%",xaxs="r",xlim=c(.8,21.6))
text(x,u+.4,format(u,T))
lines(x[-17],100*e/p-55,lwd=2)
points(x[-17],100*e/p-55,lwd=2,cex=1.5,pch=1)
axis(4,seq(0,20,5),seq(55,75,5))
text(c(x[1]+1,x[5],x[16]+1),c(100*e/p-55)[c(1,5,16)]+c(0,-1,0),
      format(c(100*e/p)[c(1,5,16)],T,di=3))
box()

A: If you're learning to plot in R you might look at the R graph gallery (original here).
All the graphs there are posted with the code used to build them. Its a good resource.

A: To add text to a plot, just use the text command. From @chl's answer to your previous question:
##Create data
x = replicate(2, sample(letters[1:2], 100, rep=T))
apply(x, 2, table)

##Create plot
barplot(matrix(c(5, 3, 8, 9), nr=2), beside=TRUE,
        col=c("aquamarine3", "coral"),
        names.arg=LETTERS[1:2],
        ylim=range(0,12)))

##Add text at coordinates: x=2, y=6
##Use trial and error to place them
text(2, 6, "A label")
text(5, 10, "Another label")


text:
Q: How to get "Delegation Pattern for Sling Models" working? I'm trying to create a proxy component for AEM Core Component with custom Sling Model which delegates part of functionality back to the Core Component's Sling Model.
I'm following the example from https://github.com/adobe/aem-core-wcm-components/wiki/Delegation-Pattern-for-Sling-Models but it results in java.lang.IllegalArgumentException: Can not set com.example.core.models.Title field.
Setup

*

*AEM version 6.4.4

*core.wcm.components.content version 2.4.0

Sources
/apps/myproject/components/pageHeadline/.content.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
    jcr:primaryType="cq:Component"
    jcr:title="Page Headline"
    jcr:description="Display Page Heading"
    sling:resourceSuperType="core/wcm/components/title/v2/title"
    componentGroup="My Project"/>

com.example.core.models.PageHeadline
package com.example.core.models;

import com.adobe.cq.wcm.core.components.models.Title;
import com.day.cq.wcm.api.Page;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Via;
import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.apache.sling.models.annotations.via.ResourceSuperType;

@Model(adaptables = SlingHttpServletRequest.class, adapters = Title.class, resourceType = "myproject/components/pageHeadline")
public class PageHeadline implements Title {

    @ScriptVariable
    private Page currentPage;

    @Self @Via(type = ResourceSuperType.class)
    private Title delegate;

    @Override
    public String getText() {
        return currentPage.getTitle();
    }

    @Override
    public String getType() {
        return delegate.getType();
    }
}

Result
org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: Identifier com.example.core.models.Title cannot be correctly instantiated by the Use API
...
Caused by: org.apache.sling.scripting.sightly.SightlyException: Identifier com.example.core.models.Title cannot be correctly instantiated by the Use API
    at org.apache.sling.scripting.sightly.impl.engine.extension.use.UseRuntimeExtension.call(UseRuntimeExtension.java:78) [org.apache.sling.scripting.sightly:1.0.54.1_4_0]
    at org.apache.sling.scripting.sightly.impl.engine.runtime.RenderContextImpl.call(RenderContextImpl.java:69) [org.apache.sling.scripting.sightly:1.0.54.1_4_0]
    at org.apache.sling.scripting.sightly.apps.core.wcm.components.title.v2.title.title_html.render(title_html.java:41)
    at org.apache.sling.scripting.sightly.java.compiler.RenderUnit.render(RenderUnit.java:48) [org.apache.sling.scripting.sightly.compiler.java:1.0.26.1_4_0]
    at org.apache.sling.scripting.sightly.impl.engine.SightlyCompiledScript.eval(SightlyCompiledScript.java:61) [org.apache.sling.scripting.sightly:1.0.54.1_4_0]
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:386) [org.apache.sling.scripting.core:2.0.54]
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:184) [org.apache.sling.scripting.core:2.0.54]
    at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:491) [org.apache.sling.scripting.core:2.0.54]
    ... 269 common frames omitted
Caused by: org.apache.sling.models.factory.MissingElementsException: Could not inject all required fields into class com.example.core.models.PageHeadline
    at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:765) [org.apache.sling.models.impl:1.4.10]
    at org.apache.sling.models.impl.ModelAdapterFactory.internalCreateModel(ModelAdapterFactory.java:448) [org.apache.sling.models.impl:1.4.10]
    at org.apache.sling.models.impl.ModelAdapterFactory.createModel(ModelAdapterFactory.java:314) [org.apache.sling.models.impl:1.4.10]
    at org.apache.sling.scripting.sightly.models.impl.SlingModelsUseProvider.provide(SlingModelsUseProvider.java:126) [org.apache.sling.scripting.sightly.models.provider:1.0.6]
    at org.apache.sling.scripting.sightly.impl.engine.extension.use.UseRuntimeExtension.call(UseRuntimeExtension.java:73) [org.apache.sling.scripting.sightly:1.0.54.1_4_0]
    ... 276 common frames omitted
    Suppressed: org.apache.sling.models.factory.MissingElementException: Could not inject private com.example.core.models.Title com.example.core.models.PageHeadline.title
        at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:749) [org.apache.sling.models.impl:1.4.10]
        ... 280 common frames omitted
    Caused by: org.apache.sling.models.factory.ModelClassException: Could not inject field due to reflection issues
        at org.apache.sling.models.impl.model.InjectableField.set(InjectableField.java:48) [org.apache.sling.models.impl:1.4.10]
        at org.apache.sling.models.impl.ModelAdapterFactory.setField(ModelAdapterFactory.java:989) [org.apache.sling.models.impl:1.4.10]
        at org.apache.sling.models.impl.ModelAdapterFactory.access$200(ModelAdapterFactory.java:132) [org.apache.sling.models.impl:1.4.10]
        at org.apache.sling.models.impl.ModelAdapterFactory$SetFieldCallback.inject(ModelAdapterFactory.java:500) [org.apache.sling.models.impl:1.4.10]
        at org.apache.sling.models.impl.ModelAdapterFactory.injectElement(ModelAdapterFactory.java:595) [org.apache.sling.models.impl:1.4.10]
        at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:744) [org.apache.sling.models.impl:1.4.10]
        ... 280 common frames omitted
    Caused by: java.lang.IllegalArgumentException: Can not set com.example.core.models.Title field com.example.core.models.PageHeadline.title to com.adobe.cq.wcm.core.components.internal.models.v1.TitleImpl
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
        at java.lang.reflect.Field.set(Field.java:764)
        at org.apache.sling.models.impl.model.InjectableField.set(InjectableField.java:46) [org.apache.sling.models.impl:1.4.10]
        ... 285 common frames omitted

A: I had the same problem, where the delegation pattern was not working, specifically, the injected attribute was null if I used @Optional, or the same stack trace as posted if @Optional was left out.
The problem for me was that we are using the following Embed-Dependency code:
<Embed-Dependency>
  *;scope=compile|runtime
</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>

in the maven-bundle-plugin. The issue was that the core components dependency got set as an embedded dependency. Once I fixed this, the delegation pattern worked fine.
<Embed-Dependency>
  *;scope=compile|runtime;artifactId=!core.wcm.components.core
</Embed-Dependency>


text:
Q: Chrome extension webRequest fired multiple times I have a Chrome extension in which I want to open a dialog box each time the page is partially (ajax) or fully reloaded.
In my background page I am catching the ajax request like this :
chrome.webRequest.onCompleted.addListener(
    function(details) {
        if (details.frameId == 0) {
            chrome.tabs.executeScript(details.tabId, {
                "file": "/js/Dialog.js"
            });
        }
    },
    {urls: ["https://*/]"}
);

In my Dialog.js I am checking if the dialog box has already been initialized so I do not get multiple dialog boxes but it does not work, it does not seem to be working as I get 2 dialogs. This is what I do to check if it has been initialized :
if (!document.getElementById("my-dialog"))

A: Events onCompleted fires for each resource was loaded on a tab (images, fonts, styles, etc).
You need to improve you event filtering, or use chrome.tabs.onCreatedand chrome.tabs.onUpdated together in order to catch tab's load finish.
And this:
    !document.getElementById("my-dialog")
may not work, because DOM updating is slow operation, so when next event was fired, you DOM may be still not updated.
This simple trick shall work better:
var isLoaded = isLoaded || false;
if(!isLoaded) {
    // ... load you dialog ...
    isLoaded = true;
}


text:
Q: DeserializeObject from JSON to a Dynamic Type In VB.NET, is it possible to deserialize a JSON string to a dynamic / unknown datatype, then read the values from the object?
    Dim js As New System.Web.Script.Serialization.JavaScriptSerializer()
    Dim o As Object = js.DeserializeObject(json)

    Dim s As String = String.Empty

    For Each i As PropertyInfo In o.GetType().GetProperties()
        s = String.Concat(s, i.Name) & "<br>"
    Next

    Response.Write(s)

It lists a bunch of things inside the object, but I can't seem to get to the value of these fields / properties.


text:
Q: Is there a faster way to calculate a pseudo-inverse of a matrix than using SVD that is as numerically stable as with SVD? Is there a faster way to calculate a pseudo-inverse of a matrix than using SVD that is as numerically stable as using SVD?

A: Since the dominant term in the pseudo-inverse is the smallest nonzero singular value of the matrix, this would require stably producing the singular values (or approximate singular values) of the matrix. While this can be done without doing the full SVD, it can never be as stable, since any error in the smallest singular value would lead to large errors in the pseudoinverse.
I should note that there are ways to calculate the pseudoinverse without the SVD, if you know additional structure. For example, if $A$ is invertible, the pseudoinverse is the inverse, so you can just use LU factorization. Or if $A$ has full column rank, then you could use the QR factorization.


text:
Q: RSpec and Capybara setup, have_no_content doesn't seem to be working I'm creating an app where I have a simple delete record on the index of the records once a user logs in.  When I don't have the user logging in under my rspec specs, the delete works.  Meaning that the has_no_content test returns true.  But once I put in place the authentication required to access the index of records, the test fails.  Any thoughts?
before do
  @records = Factory(:record)
  login_user
end

it "should delete a record" do
  visit records_path
  find("#record_#{@records.id}").click_link 'Delete'

  page.should have_content "Record has been deleted"
  page.should have_no_content "Record 1"
end

A: Nevermind - I figured it out with the help of using launchy.
My initial thought was that I was some how losing the "session" and that once the delete link was clicked, then the login page was being displayed again.  That wasn't the case at all.  I did notice though that the header of my app also contained "Record 1" in it.  Therefore the spec would fail for obvious reasons. Head to desk - sorry about that, but I figured I'd post my own stupidity and looking way deeper than I needed to.


text:
Q: chrome.runtime.sendMessage throws exception from content script after reloading Chrome Extension I send messages from the injected content scripts back to my background script in my Chrome Extension as such:
chrome.runtime.sendMessage({action: "myResult"});

This works fine, until I reload my extension (by going to Settings -> Extensions -> "Reload (Ctrl+R)" for my extension.)
In turn when my background script starts up it repeatedly calls chrome.tabs.executeScript for all open tabs to programmatically re-inject my content script (as I showed in this question.)
But after I do that, if I call that first sendMessage line from my content script, it throws this exception:

Error: Error connecting to extension my_extension_id

Any idea why this happens?

A: When the extension runtime is reloaded, which happens in any of the following cases

*

*You've called chrome.runtime.reload().

*You've clicked on Reload extension at chrome://extensions/.

*The extension was updated.

then the most extension API methods in the content script cease to work (including chrome.runtime.sendMessage which causes the error in the question). There are two ways to work around this problem.
Option 1: Fall back to contentscript-only functionality
If your extension can function perfectly without a background page, then this could be an acceptable solution. E.g. if your content script does nothing else besides modifying the DOM and/or performing cross-origin requests.
I'm using the following snippet in one of my extensions to detect whether the runtime is still valid before invoking any Chrome extension API from my content script.
// It turns out that getManifest() returns undefined when the runtime has been
// reload through chrome.runtime.reload() or after an update.
function isValidChromeRuntime() {
    // It turns out that chrome.runtime.getManifest() returns undefined when the
    // runtime has been reloaded.
    // Note: If this detection method ever fails, try to send a message using
    // chrome.runtime.sendMessage. It will throw an error upon failure.
    return chrome.runtime && !!chrome.runtime.getManifest();
}

// E.g.
if (isValidChromeRuntime()) {
    chrome.runtime.sendMessage( ... );
} else {
    // Fall back to contentscript-only behavior
}

Option 2: Unload the previous content script on content script insertion
When a connection with the background page is important to your content script, then you have to implement a proper unloading routine, and set up some events to unload the previous content script when the content script is inserted back via chrome.tabs.executeScript.
// Content script
function main() {
    // Set up content script
}

function destructor() {
    // Destruction is needed only once
    document.removeEventListener(destructionEvent, destructor);
    // Tear down content script: Unbind events, clear timers, restore DOM, etc.
}

var destructionEvent = 'destructmyextension_' + chrome.runtime.id;
// Unload previous content script if needed
document.dispatchEvent(new CustomEvent(destructionEvent));
document.addEventListener(destructionEvent, destructor);
main();

Note that any page that knows the name of the event can trigger destruction of your content script. This is unavoidable, because after the extension runtime is destroyed, there are no proper ways to securely communicate with the extension any more.


text:
Q: SQLite - Updating multiple tables Can anyone help me fixing the problem in my query?
I'm trying to call a function to update multiple tables which have a value of "1" in column "col", but it's not working,
my_function
public long updateNow() {
        mDbHelper = new DatabaseHelper(mContext);
        mDb = mDbHelper.getWritableDatabase();

        int doneClear = 0;
        String base_value = "1"; // update all column "col" where value of 1

        ContentValues initialValues = new ContentValues();
        initialValues.put("col", "0"); // Update all column "col" with 0

        doneClear = mDb.update(SQLITE_TABLE_ONE, initialValues, "col=" + base_value, null);
        doneClear = mDb.update(SQLITE_TABLE_TWO, initialValues, "col=" + base_value, null);
        doneClear = mDb.update(SQLITE_TABLE_THREE, initialValues, "col=" + base_value, null);
        doneClear = mDb.update(SQLITE_TABLE_FOUR, initialValues, "col=" + base_value, null);
        doneClear = mDb.update(SQLITE_TABLE_FIVE, initialValues, "col=" + base_value, null);
        doneClear = mDb.update(SQLITE_TABLE_SIX, initialValues, "col=" + base_value, null);
        Log.w(TAG, Integer.toString(doneClear));
        return doneClear;
    }

This code is not working, i'm can't get why.
Nothing happens in column col.
Anyway, that code is based on my previous query, which is working fine.
working_update_query
public long updates(String recent_value, String _id, String table_name) {
        ContentValues initialValues = new ContentValues();
        initialValues.put("recent_value", recent_value);
        Log.w(TAG, String.valueOf(initialValues) + " WITH ID OF " + _id + " IN TABLE OF " + table_name);
        return mDb.update(table_name, initialValues, "_id=" + _id, null);
    }

I'm stuck here for almost 1 hour, can't figure out the problem.
Can anyone help me please?

A: Try this using wildcards to appropriately inject the update parameters, like this:
int updateCount = db.update(
   TABLE_NAME,
   newValues,
   "col = ?",
   new String[] {String.valueOf(colValue)}
);

For a quick sample check out this tutorial.


text:
Q: Countable subset of an unbounded chain Let $C$ be a chain (i.e. a total order set) with no maximal element. Is always possible to find a countable subset of $C$ with no upper bound?

A: Let $C=\omega_1$, the first uncountable ordinal. Then all elements of $C$ are countable ordinals.
Let $A\subseteq C$ be countable. Then $\bigcup A$ is also a countable ordinal, hence is in $C$ and is an upper bound of $A$.


text:
Q: Ansible Is there any way to make global task for use in all playbooks is there any way to create central function only once and call it from every task playbook needing it?
for example, i have this task :
- name: Download
  get_url:
    url_username: foo
    url_password: foo
    dest: "{{ ansible_env.APP }}/"
    url: "{{ download_url }}"

the same task is copy/paste multiple times in different playbooks
this is very not efficient.
any way define it once and call it from other playbooks?

A: There are two options.
1) Put the task into a file and use include_tasks or import_tasks.
2) Create a role with the file and use include_role tasks_from.

FWIW. See my libraries of tasks ansible_lib and linux_lib.

Q: "What is the difference between all of them?"
A: Imported code is present from the beginning of the playbook's execution. Included code will be loaded when the work-flow reaches the point. This influences

*

*inheritance of the tags

*availability of some variables (e.g. role defaults, ...)

See details

*

*Including and Importing

*Creating Reusable Playbooks

*What's the difference between include_tasks and import_tasks?

(opinion based)

Q: "What is usually used?"
A: include_role is the most powerful and flexible option. See the parameters of the module.

Q: "What about import_playbook?"
A: It's not a module. It's a simple directive to include code. Use import_playbook to simplify (modularize) complex playbooks and to change playbook's parameters on-the-fly (e.g. hosts, become, ...) while keeping the playbook's variables.


text:
Q: jQuery star rating plugin not working in PHP I have tried to integrate jQuery star rating plugin called jQuery master in to my PHP application, but its not working. Can anyone help me? Below is my code:
{literal}

<link rel="stylesheet" type="text/css" href="jRatingmaster/jquery/jRating.jquery.css" media="screen" />

{/literal}

A: Firstly, run your page in Mozilla FireFox, and check if any javascript/CSS file is not getting included.
In the Net tab, it shows a 404 with red color.
In the code, <?php echo CONST_SITE_ADDRESS;?> will not work in Smarty as it is being seen from your code.
From your PHP file, assign this to some variable display it in template.

So, the corrected code:

A: As per the documentation specified, there is no onclick handler in jrating plugin.
Your code should be like,


text:
Q: Test mobile website I am developing a mobile website and so far I have been testing it in Chrome. Now I would like to test it on my phone.
I am using WAMP and in my hosts file I have the following:
127.0.0.1  www.mysite.com
In my httpd.conf:
<Directory />
  AllowOverride All
  Require all granted
</Directory>

<VirtualHost *:80>
  ServerName www.mysite.com
  DocumentRoot "D:/Path/to/website/root"
  DirectoryIndex index.php
</VirtualHost>

What should I type in my mobile browser to hit this website? Do I need to change some WAMP settings or anything else?

A: Add a rule to httpd.conf or to an alias file for your project:
<Directory "D:/Path/to/website/root">
    AllowOverride all
    Order Deny,Allow
    Deny from all
    Allow from 127.0.0.1
    Allow from 192.168.1.
</Directory>

MAke sure you restart apache after chaging configuration to see the effects. You may also need to put WAMP "Online" by clicking on the icon in the system tray and choosing "Put Online".
Then try accessing you page using the host computer's local IP address.


text:
Q: Is Drools applicable in my scenario? If not what else? Scenario-
1. End user should be able to create rules from a front end. The rule would have conditions (I could not figure out a way in Drools to dynamically modify the .drl file on the basis of rules created by users)

*

*Rules should be able to be defined in a hierarchy and the same rule can belong to multiple hierarchies

*The end user should be able to trigger the execution of the rules. The caveat here is that the facts might not be available in the KnowledgeSession, the rules get converted to relevant queries as per the underlying database and then they get triggered on the underlying DB.
So the idea is Rules get created with limited knowledge of the entities -> When rule is triggered it works with the underlying db to create queries relevant to the entities present in the underlying db
Would I be able to do something with Drools, another rules engine instead of building a custom implementation?

A: It looks like what you're going to do is not easy. But drools should be a way to make it easier. I'll assume that by "hierarchy" you mean rule flows, and not rule-flow groups, but I think the answer applies anyway for the other scenario.
I think the tool you might want to check is Drools Guvnor, as it stores rules in the DB and provides a UI to change them.
I think the tricky bit will be to apply those rules in different rule flows, but I'm sure that drools provides a way to do it. Or the worst case scenario is that you'll need to clone the rules and put them in the different rule-flow groups.


text:
Q: DocuSign: Getting a list of all documents a user has access to We are updating an application to allow users to upload/attach files directly from various external sources (DocuSign, Drop Box, Google Drive, etc). I am currently trying to get a list of all files a user has access to in their DocuSign account. I am working in C# with the DocuSign .NET REST API library (DocuSign.eSign.dll).
I can get as far as authenticating as the user and getting their default account id. I am trying to use the FoldersApi.Search method but I get a "404 - File or directory not found error". Can someone familiar with DocuSign review my code and tell me what I might be doing wrong?
var apiClient = new ApiClient("https://demo.docusign.net/restapi");

var code = Request["Code"];
var token = apiClient.GenerateAccessToken(IntegratorKey, SecretKey, code);

var userInfo = DocuSignClient.GetUserInfo(token.access_token);
var accountId = "";
foreach (var account in userInfo.Accounts) {
    if (account.IsDefault == "true") {
        accountId = account.AccountId;
        apiClient = new ApiClient(account.BaseUri);
        break;
    }
}

var configuration =
    new Configuration(apiClient: apiClient, accessToken: token.access_token);

var foldersApi = new FoldersApi(configuration);
var response = foldersApi.Search(accountId, "all");
foreach (var folder in response.FolderItems) {
    Context.Response.Write(folder.FolderId);
}

A: Caveat: I've never used DocuSign before. But having looked at the REST API and the .NET client I've come up with a possible solution.
It looks like you're using the folders search incorrectly. The signature for that API is as follows:
public FolderItemResponse Search (string accountId, string searchFolderId, FoldersApi.SearchOptions options = null)

Where the valid values for the searchFolderId are drafts, awaiting_my_signature, completed, or out_for_signature, but you've provided all which is the one of the search options not one of the search folder IDs.
The correct usage would be something like this:
var response = foldersApi.Search(accountId, "completed", FoldersApi.SearchOptions.all);

where you would replace completed with whatever value it is you need from the valid values I've mentioned above.

A: I think I see an issue with your code though not in a good place to test currently, hopefully you can confirm soon.  On the first line you correctly instantiate an API Client for demo environment with:
var apiClient = new ApiClient("https://demo.docusign.net/restapi");

However after authenticating and getting their user info, you then re-configure the base path with:
apiClient = new ApiClient(account.BaseUri);

I believe this might be leading to the 404 error because this will only contain the domain.  In other words, this has the effect of doing:
apiClient = new ApiClient("https://demo.docusign.net");

You need to add the remaining /restapi/v2/{accountId} to form the proper base request URL, try something like this instead:
apiClient = new ApiClient(account.BaseUri + "/restapi/v2/accounts/" + accountId);

--------------------------------
UPDATE
Just did some testing and got things to work however note that I'm using Node.js not C#.  Still should be same logic though.  Here's my working code for getting all completed envelopes:
docusign.Configuration.default.setDefaultApiClient(apiClient);

var foldersApi = new docusign.FoldersApi(docusign.Configuration.default.getDefaultApiClient());
foldersApi.search(accountId, "completed")
    .then(function(response) {
        console.log("response = " + JSON.stringify(response, null, 2));
        return null;
    })
    .catch(function (error){
    if (error) {
      console.log('Error: ' + JSON.stringify(error));
      return error;
    }
  });


text:
Q: PdfBox embed fonts into existing document I have a pdf file which shows font properties in Okular (or whatever PDF viewer) like that:
Name: Helvetica
Type: Type1
File: /usr/share/fonts/truetype/liberation2/LiberationSans-regular.ttf
Embedded: No

I want to embed Helvetica with PDFBox 2xx without modifying file content (text) itself so it would always available with a file.
Is it possible at all?
I tried something like:
PDDocument document = PDDocument.load(myFile);

InputStream stream = new FileInputStream(new File("/home/user/fonts_temp/Helvetica.ttf"));
PDFont fontToEmbed = PDType0Font.load(document, stream, true);
PDResources resources = document.getPage(pageNumber).getResources();
resources.add(fontToEmbed);
//or use the font from pdfbox:
resources.add(PDType1Font.HELVETICA);

document.save(somewhere);
document.close();

I also tried to call
COSName fontCosName = resources.add(PDType1Font.HELVETICA);
resources.put(fontCosName, font);

What am I doing wrong?
Edit:
@TilmanHausherr thank you for the clue! But I'm still missing something. Currently my code looks like:
PDFont helvetica = PDType0Font.load(document, new FileInputStream(new File("/path/Helvetica.ttf")), false);
...
PDResources resources = page.getResources();
for (COSName fontCosName : resources.getFontNames()){
    if(resources.getFont(fontCosName).getName().equals("Helvetica")) {
        resources.put(fontCosName, helvetica);
    }
}

End result shows
Helvetica CID TrueType Fully Embedded
But the font is not displayed in PDF file at all now. I mean those places where the font is used are literally empty, blank page... Still something is not there.
Font itself was downloaded from here

A: *

*

You'd need to know the name that is currently used in the resources, so check these with resources.getFontNames()
2.
To replace a standard 14 font, use this font object:
PDTrueTypeFont.load(document, file, oldFont.getEncoding() /* or WinAnsiEncoding.INSTANCE which is usually right */ );

this ensures that the same encoding is used as the standard 14 font. (It's different for the Zapf Dingbats and the Symbol font)


text:
Q: UnicodeDecodeError When Opening a tar File in Python 3 I'm using Linux Mint 18.1 and Python 3.5.2.
I have a library that currently works using Python 2.7.  I need to use the library for a Python 3 project.  I'm updating it and have run into a unicode problem that I can't seem to fix.
First, a file is created via tar cvjf tarfile.tbz2 (on a Linux system) and is later opened in the Python library as open(tarfile).
If I run the code as is, using Python 3, I get the following error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc1 in position 11: invalid start byte

My first attempt at a fix was to open it as open(tarfile, encoding='utf-8') as I was under the impression that tar would just use what the file system gave it.  When I do this, I get the same error (the byte value changes).
If I try with another encoding, say latin-1, I get the following error:
TypeError: Unicode-objects must be encoded before hashing

Which leads me to believe that utf-8 is correct, but I might be misunderstanding.
Can anyone provide suggestions?

A: I was going down the wrong path thinking this was some strange encoding problem.  When it was just a simple problem with that fact that open() defaults to read as text (r).  In Python 2 it's a no-op.
The fix is to open(tarfile, 'rb').
The head fake with unicode...should have seen this one coming.  :facepalm:


text:
Q: Fix Warning "Also define the standard property 'box-shadow' for compatibility" I use the MDB scroll library, and VSCode shows the following warning:

Also define the standard property 'box-shadow' for compatibility

How can I fix it or at least ignore the warning on VSCode?
.scrollbar-black::-webkit-scrollbar-thumb {
    border-radius: 10px;
    -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.1);
    background-color: #000;
}

A: It means you should add the standard style rule (box-shadow) in addition to the vendor prefixed version (-webkit-box-shadow)
.scrollbar-black::-webkit-scrollbar-thumb {
    border-radius: 10px;
    -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.1);
            box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.1); // <- Add this to fix.
    background-color: #000;
}


text:
Q: Help us test the advantages of using a CDN We're looking at putting our static content – JavaScript, CSS, images, etc. – on a CDN.
Currently we're serving this content from http://sstatic.net. While this works great, it means that I (sitting in Berlin) have to get my CSS from all the way across the Atlantic, because the servers that run sstatic.net are in New York.
The (main) idea of a CDN is that content should be delivered from a location as close as possible to the user, so they get their data faster.
To check if this idea lives up to its promise, I'd like to ask you to make a quick test: To measure (using Chrome dev tools, Firebug, or something similar) how long it takes to download a file from the CDN, compared to downloading it directly from us.

*

*From us: http://sstatic.net/js/full.js

*From the CDN: http://cdn.sstatic.net/js/full.js
Using the Chrome Developer tools, it looks like this for me:

Please make a few requests to each of the two links above (using Ctrl-F5, so the file is actually redownloaded), and post a typical example of latency and total download time for each file.
Note that the very first request to the CDN may or may not be slower – that's expected. Please also post your (rough) location.
Example result:

*

*From Berlin, Germany

*sstatic: 152ms latency, 576ms total

*CDN: 52ms latency, 201ms total

Thanks in advance!

A: London
http://sstatic.net/js/full.js (SO)
Averages around 140ms
Ranges from 120ms - 180ms
Latency steady around 120ms

http://cdn.sstatic.net/js/full.js (CDN)
Averages around 90ms
Ranges from 50ms - 120ms
Latency variable 40ms - 90ms

A: Sydney:
cdn:

*

*Latency: 176ms - 340ms

*Total: 680ms - 850ms

sstatic:

*

*Latency: 280ms

*Total: 1.05s

A: From Goa, India

http://sstatic.net/js/full.js (SO)
avg around 742ms
Latency around 740ms

http://cdn.sstatic.net/js/full.js (CDN)
avg around 337ms
Ranges from 308ms - 1.06 seconds
Latency around 308ms

A: Austin, Texas
sstatic:

*

*~265 ms total (max 312 ms, min 256 ms)

*~75 ms latency (max 109 ms, min 66 ms)
CDN:

*

*~316 ms total (max 358 ms, min 286 ms)

*~105 ms latency (max 152 ms, min 78 ms)
(Hmm, I'm seeing opposite results compared to folks on the other side of the world. I might have mixed feelings about this proposal...)

Traceroute to sstatic:
Tracing route to sstatic.net [64.34.119.12]
  1     1 ms    1 ms    1 ms  192.168.2.1
  2    14 ms    8 ms    9 ms  10.245.128.1
  3    11 ms   11 ms   14 ms  gtwncmts-A.tex.sta.suddenlink.net [173.219.254.96]
  4    14 ms   14 ms   13 ms  tyrm-10g.tex.sta.suddenlink.net [173.219.254.80]
  5    43 ms   39 ms   41 ms  66-76-232-13.tyrd.suddenlink.net [66.76.232.13]
  6    40 ms   39 ms   41 ms  chicosrc01-10gex1-1.tex.sta.suddenlink.net [66.76.232.6]
  7    41 ms   54 ms   41 ms  peer1-gw.peer1.net [206.223.119.30]
  8    57 ms   55 ms   56 ms  10ge.xe-0-0-0.nyc-telx-dis-2.peer1.net [216.187.114.162]
  9    57 ms   60 ms   56 ms  oc48-po3-0.nyc-75bre-dis-1.peer1.net [216.187.115.134]
 10    59 ms   58 ms   58 ms  gwny01.stackoverflow.com [64.34.41.58]
 11    57 ms   58 ms   60 ms  stackoverflow.com [64.34.119.12]

Traceroute to cdn:
Tracing route to sstatic.stackexchange.netdna-cdn.com [67.201.31.56]
  1     1 ms    1 ms    1 ms  192.168.2.1
  2    10 ms    9 ms    9 ms  10.245.128.1
  3    12 ms    9 ms   14 ms  173-219-254-222-link.tex.sta.suddenlink.net [173.219.254.222]
  4    15 ms   13 ms   13 ms  tyrm-10g.tex.sta.suddenlink.net [173.219.254.80]
  5    47 ms   47 ms   52 ms  ashb-osr01.suddenlink.net [66.76.30.166]
  6    47 ms   46 ms   49 ms  ashbosr03-10gex1-1.atw.sta.suddenlink.net [66.76.219.34]
  7    54 ms   53 ms   53 ms  xe1-0.cr01.iad01.mzima.net [206.223.115.62]
  8     *       *       *     Request timed out.
  9    46 ms   46 ms   45 ms  67.201.31.56

The traceroute results for each are fairly consistent. Running the original test again, I see the CDN clocking in closer to 280 ms total, sstatic remains the same, and the latency for both remains the same.
This may be my ISP's fault. We went through a time when they were apparently routing traffic through a server in Louisiana, causing Google and all the other "auto-detect-your-location" pages to determine that we simply did not live anywhere in Texas. If they're doing the same sort of silliness, that may explain why I'm getting routed to a CDN server that is more geographically less convenient for my location.

A: *

*Manch Vegas, NH

*sstatic: 56ms/105ms

*CDN: 83ms/164ms

A: Willemstad, Curaçao, connected by ARCOS.

sstatic: latency ~90ms, total ~330ms
Tracing route to sstatic.net [64.34.119.12]

  1     1 ms    <1 ms    <1 ms  192.168.1.1
  2     1 ms     1 ms     1 ms  10.0.0.1
  3     6 ms     6 ms     6 ms  190.88.64.1
  4     7 ms     6 ms     6 ms  sub-174ip9.rev.onenet.an [216.152.174.9]
  5    43 ms    42 ms    43 ms  gige3-17.usa.nmi-edge05.columbus-networks.com [63.245.69.85]
  6    43 ms    43 ms    42 ms  xe-0-0-1.usa.nmi-teracore02.columbus-networks.com [63.245.5.84]
  7    43 ms    43 ms    43 ms  xe-1-0-0.usa.nam-core02.columbus-networks.com [63.245.5.141]
  8    44 ms    44 ms    44 ms  nota-exch.gig1-0.peer1.net [198.32.124.125]
  9   150 ms    58 ms    57 ms  10ge-ten1-2.atl-telx-cor-1.peer1.net [216.187.124.70]
 10    58 ms    57 ms    57 ms  10ge-ten1-1.atl-101mar-cor-1.peer1.net [216.187.120.226]
 11    70 ms    70 ms    71 ms  10ge.xe-1-0-0.wdc-eqx-dis-1.peer1.net [216.187.115.37]
 12    71 ms    71 ms    71 ms  10ge.ten1-2.wdc-sp2-cor-1.peer1.net [216.187.115.234]
 13    71 ms    72 ms    71 ms  216.187.120.254
 14    76 ms    75 ms    76 ms  10ge.xe-2-0-0.nyc-telx-dis-1.peer1.net [216.187.115.221]
 15    76 ms    75 ms    75 ms  10ge.ten1-3.nyc-75bre-dis-2.peer1.net [216.187.115.166]
 16    76 ms    76 ms    76 ms  gig2-0.nyc-gsr-b.peer1.net [216.187.123.5]
 17    77 ms    76 ms    77 ms  gwny01.stackoverflow.com [64.34.41.58]
 18    76 ms    76 ms    76 ms  stackoverflow.com [64.34.119.12]

cdn: latency ~65ms, total ~250ms
Tracing route to sstatic.stackexchange.netdna-cdn.com [67.201.31.56]

  1     1 ms    <1 ms    <1 ms  192.168.1.1
  2     1 ms     1 ms     1 ms  10.0.0.1
  3     6 ms     6 ms     6 ms  190.88.64.1
  4     6 ms     6 ms     6 ms  sub-174ip9.rev.onenet.an [216.152.174.9]
  5    43 ms    42 ms    43 ms  gige3-17.usa.nmi-edge05.columbus-networks.com [63.245.69.85]
  6    57 ms    59 ms    43 ms  xe-1-1-3.usa.nmi-teracore02.columbus-networks.com [63.245.5.146]
  7    43 ms    43 ms    46 ms  xe-1-0-0.usa.nam-core02.columbus-networks.com [63.245.5.141]
  8    55 ms    52 ms    53 ms  ge0-2.cr01.mia01.mzima.net [198.32.124.89]
  9    73 ms    70 ms    71 ms  te0-1.cr1.atl1.us.packetexchange.net [69.174.120.46]
 10    60 ms    59 ms    59 ms  69.174.38.2
 11    59 ms    59 ms    59 ms  67.201.31.56

A: *

*From GLOS, UK

*sstatic: 120ms latency, 425ms total

*CDN: 40ms latency, 124ms total

A: *

*From Cologne, Germany

*sstatic: avg. 100ms latency, avg. 400ms total

*CDN: avg. 60ms latency (but 127ms on the very first call), avg. 200ms total

A: Vienna, Austria

*

*sstatic: ~620ms (min: 547ms, max: 687ms)

*cdn: ~330ms (min: 297ms, max: 375ms)

A: *

*From Colombo, Sri Lanka

*sstatic: 250ms latency, 810ms total

*CDN: 205ms latency, 710ms total

A: *

*From UK (East)

*sstatic: ~171-266ms, ~328-438ms total

*CDN: ~18ms, ~35-50ms total

A: *

*From Helsinki, Finland

*sstatic: 140ms latency, 400ms total

*cdn: 40ms latency, 120ms total

A: *

*From Linz, Austria

*sstatic: 132ms latency, 282ms total

*CDN: 121ms latency, 261ms total

A: From East Bay Area, CA:

*

*sstatic: 111ms latency, 314ms receiving

*cdn: 28ms latency, 85ms receiving

A: Prague, Czech Republic:
cdn.sstatic.net:

*

*Latency: 84 ms (73 ms min, 119 ms max)

*Total: 170 ms (152 ms min, 222 ms max)
sstatic.net:

*

*Latency: 205 ms (130 ms min, 265 ms max)

*Total: 459 ms (383 ms min, 524 ms max)

A: Germany:

*

*cdn.sstatic.net: 14 ms (39 ms total)

*sstatic.net: 109 ms (433 ms total)

A: From Ghent, Belgium:
I fetched them 10 times:
sstatic:

*

*Time: 505-832, avg 699

*Latency: 209-332, avg 264

cdn:

*

*Time: 74-259, avg 114

*Latency: 24-222, avg 51
(remark: with the cdn, the first fetch was the max value, and all subsequent runs took only half or less than half of that max time)

A: Bangalore, India

*

*sstatic: latency 744ms, total 1.27s

*cdn: latency ~264ms, total ~720ms

A: From Basingstoke, UK. Using Firebug (and assuming latency = total - download), having pre-loaded DNS1:

*

*sstatic: latency:,217ms total: 548ms

*CDN: latency 92ms; total: 214ms

1 Tracert shows 7 hops to the CDN looking like it ends in Holland in ~32ms compared to 18 hops to NY for for static in ~122ms, so I would have expected the difference to be greater.

A: *

*From London, UK

*sstatic: 102ms/106ms

*CDN: 15ms/16ms

A: From somewhere in the Northwest nearish to Manchester, UK, on a slow link, using apachebench (ab -n20 "http://...:
No CDN:
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:      140  330 676.2    144    3156
Processing:  1200 1410 471.4   1232    3240
Waiting:      168  215 176.5    173     964
Total:       1347 1740 848.7   1388    4364

CDN:
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:       75   87  26.4     80     196
Processing:   416  481 118.8    440     868
Waiting:       88  119  70.9     99     404
Total:        491  568 139.0    519    1064

A: Buenos Aires, Argentina

 sstatic: 657ms latency, 1100ms total
 CDN:     266ms latency,  871ms total

A: Connection 1

*

*From Tokyo, Japan

*sstatic: ~694ms, ~822ms total

*CDN: ~475ms, ~785ms total

Connection 2

*

*From Tokyo, Japan

*sstatic: ~194ms, ~559ms total (ping to 64.34.119.12: ~174ms)

*CDN: ~128ms, ~380ms total (ping to 67.201.31.56: ~124ms)

A: *

*From Cologne, Germany

*sstatic: 127ms latency, 484ms total

*CDN: 21ms latency, 81ms total

A: *

*Warsaw, Poland

*sstatic: ~120ms/~370ms total

*CDN: ~60ms/~160ms total

A: Timisoara, Romania (work):
- sstatic: 668ms/337ms (max. 767/381, min 546/284)
- CDN:     479ms/362ms (max. 969/853, min. 234/116)

Timisoara, Romania (home):
- sstatic: 583ms/189ms (max. 665/272, min. 531/137)
- CDN:     266ms/127ms (max. 500/378, min. 163/41)

A: *

*From Kuwait

*sstatic: 330ms latency, 422ms total

*CDN: 264ms latency, 352ms total

A: France, Strasbourg
sstatic: 506ms total, 306ms latency
CDN: 72ms total, 70ms latency

A: Singapore
sstatic: 245ms latency, 807ms total
CDN: 214ms latency, 630ms total
Firebug does report some weird results for the CDN, with latency ranging from 220ms to 472ms averaging 363ms (number reported for CDN taken from Chrome, whose number seems more consistent). The amount of time taken receiving the file is the approximately the same at around 420ms though

A: Seattle, WA
On Comcast Business:

*

*sstatic: 191ms latency, 379ms time (varying about 15% reload to reload)

*cdn: 10ms latency, 55ms time (varying about 5% reload to reload)

On Speakeasy:

*

*sstatic: ~220ms latency, ~500ms time (varying by nearly 100ms request to request)

*cdn: ~100ms latency, ~190ms time (varying by about 20ms request to request)

A: *

*From St. Louis, Missouri

*sstatic: 56ms latency, 159ms total

*CDN: 53ms latency, 206ms total

):

A: Cleveland, Ohio:

*

*sstatic: 22ms latency, 57ms total

*CDN: 13ms latency, 35ms total

A: Here are the results I get from the Canadian west coast:
http://sstatic.net/js/full.js:

http://cdn.sstatic.net/js/full.js:

Note: originally I was getting 304s so I did a hard refresh.

A: The Hague, The Netherlands

*

*sstatic: 190ms latency, 463ms total

*CDN: 109ms latency, 120ms total

A: Paris, France!

*

*sstatic latency ~95 ms, total ~270 ms

*cdn latency ~25 ms, total ~100 ms

A: Delaware, USA

*

*sstatic:

*

*37.2ms latency (54ms max, 28ms min)

*105.2ms total (125ms max, 81ms min)

*cdn:

*

*19.1ms latency (23ms max, 17ms min)

*81.5ms total (94ms max, 75ms min)

A: Too lazy to do the download, but here are some tracerts:
Location: London, ON, Canada
From work:
Tracing route to sstatic.net [64.34.119.12]
over a maximum of 30 hops:

  1    <1 ms    <1 ms    <1 ms  10.0.0.254
  2     1 ms     1 ms     1 ms  d680.a.ded.execulink.com [69.63.32.125]
  3     *        *        *     Request timed out.
  4     1 ms     1 ms     1 ms  d668.a.ded.execulink.com [69.63.32.113]
  5     4 ms     5 ms     4 ms  i.core2.ip.execulink.net [66.203.176.113]
  6    24 ms    22 ms    21 ms  nyiix.peer1.net [198.32.160.65]
  7    20 ms    20 ms    21 ms  10ge.xe-0-0-0.nyc-telx-dis-2.peer1.net [216.187.115.182]
  8    20 ms    20 ms    22 ms  oc48-po3-0.nyc-75bre-dis-1.peer1.net [216.187.115.134]
  9    21 ms    21 ms    21 ms  gwny01.stackoverflow.com [64.34.41.58]
 10    27 ms    20 ms    25 ms  stackoverflow.com [64.34.119.12]

Tracing route to sstatic.stackexchange.netdna-cdn.com [67.201.31.56]
over a maximum of 30 hops:

  1    <1 ms    <1 ms    <1 ms  10.0.0.254
  2     1 ms     1 ms     1 ms  d680.a.ded.execulink.com [69.63.32.125]
  3     *        *        *     Request timed out.
  4   120 ms   203 ms   203 ms  d668.a.ded.execulink.com [69.63.32.113]
  5     5 ms     6 ms     4 ms  i.core2.ip.execulink.net [66.203.176.113]
  6    51 ms    30 ms    25 ms  ge-6-11-111.car1.Toronto2.Level3.net [4.59.180.5]
  7    33 ms    31 ms    19 ms  ae-8-8.ebr1.Chicago1.Level3.net [4.69.140.245]
  8    25 ms    20 ms    20 ms  ae-1-51.edge3.Chicago3.Level3.net [4.69.138.10]
  9    30 ms    19 ms    18 ms  MZIMA-NETWO.edge3.Chicago3.Level3.net [4.53.96.26]
 10    28 ms    21 ms    18 ms  69.174.120.146
 11    34 ms    34 ms    32 ms  te4-5.cr1.nyc1.us.packetexchange.net [69.174.120.73]
 12    30 ms    30 ms    30 ms  69.174.26.2
 13    30 ms    29 ms    30 ms  67.201.31.56

Edit: for some reason I can't tracert at home. Oh well.

A: Houston, TX

            CDN                 Non-CDN
        Total   Latency     Total   Latency
AVG     102.65  69.1        217.7   163.6
MAX     257     158         555     312
MIN     53      46          141     125

all times in ms

Did 20 runs of each using Chrome, using their Network tab on the dev tools
Total = total transit time
Latency = well, latency

A: *

*From Saarbruecken, Germany

*sstatic: 144ms latency, 511ms total

*CDN: 51ms latency, 177ms total

A: Here are my results from St. Paul, Minnesota. (USA)

*

*sstatic: 155ms (time), 60ms (latency)

*CDN: 186ms (time), 47ms (latency)

A: *

*From Corvallis, OR

*sstatic: 231ms latency, 429ms total

*CDN: 38ms latency, 147ms total

A: Manchester UK

*

*sstatic latency 140 ms, total 290ms

*cdn latency 30 ms, total 142ms

A:

*

*From Tirano(So), Italy

*sstatic: 145ms latency, 420ms total

*CDN: 80ms latency, 250ms total

A: From NY:
static: 264ms (176 latency)
cdn: 449 (284 latency)
But of course, it's from NY...

A: From Los Angeles, California:

*

*sstatic.net: 142ms latency, 470ms total

*CDN: 101ms latency, 220ms total

CDN at some points went as high as 900ms for latency, and sstatic peaked at 600ms, but I posted a typical set of values for both.

A: Iowa City, Iowa
Calculated from the average of 6 loads with full cache refresh between loads.

*

*sstatic: 35ms latency, 72ms total

*cdn: 24ms latency, 31ms total -- if I exclude the first lookup it's 6ms and 13.6ms, respectively

Traceroutes:
sstatic.net
Tracing route to sstatic.net [64.34.119.12]
over a maximum of 30 hops:

  1    <1 ms    <1 ms    <1 ms  rtr-core-lc.net.uiowa.edu [128.255.76.1]
  2    <1 ms    <1 ms    <1 ms  rtr-border-lc.net.uiowa.edu [128.255.2.129]
  3     4 ms     4 ms     4 ms  xe-3-2-0.716.rtr.chic.net.internet2.edu [198.49.
182.7]
  4    21 ms    24 ms    21 ms  xe-0-0-0.0.rtr.wash.net.internet2.edu [64.57.28.
13]
  5    22 ms    22 ms    22 ms  equinixexchange.peer1.net [206.223.115.30]
  6    22 ms    22 ms    24 ms  10ge.ten1-2.wdc-sp2-cor-1.peer1.net [216.187.115
.234]
  7    22 ms    22 ms    23 ms  216.187.120.254
  8    27 ms    27 ms    27 ms  10ge.xe-2-0-0.nyc-telx-dis-1.peer1.net [216.187.
115.221]
  9    28 ms    28 ms    27 ms  10ge.xe-0-0-0.nyc-telx-dis-2.peer1.net [216.187.
115.182]
 10    28 ms    28 ms    27 ms  oc48-po3-0.nyc-75bre-dis-1.peer1.net [216.187.11
5.134]
 11    28 ms    28 ms    27 ms  gwny01.stackoverflow.com [64.34.41.58]
 12    28 ms    28 ms    28 ms  stackoverflow.com [64.34.119.12]

CDN
Tracing route to sstatic.stackexchange.netdna-cdn.com [69.174.57.102]
over a maximum of 30 hops:

  1     6 ms     3 ms    <1 ms  rtr-core-lc.net.uiowa.edu [128.255.76.1]
  2    <1 ms    <1 ms    <1 ms  rtr-border-lc.net.uiowa.edu [128.255.2.129]
  3    19 ms     4 ms     4 ms  xe-3-2-0.716.rtr.chic.net.internet2.edu [198.49.
182.7]
  4    14 ms    17 ms    17 ms  xe1-1.cr01.ord01.mzima.net [206.223.119.62]
  5     8 ms    16 ms    17 ms  69.174.120.150
  6     6 ms     5 ms     5 ms  69.174.37.2
  7     5 ms     5 ms     5 ms  69.174.57.102

Internet2 is a good thing.

A: *

*From Argentina, Buenos Aires.

*sstatic: Latency 165 ms, Total: 169 ms

*cdn: Latency 214 ms, Total 217 ms


text:
Q: How can the potential on a cube's surface replicate the potential of a point particle? If i have a cube (either hollow, or an insulating solid) and i want its surface have a potential such that it looks like a point particle outside of the box does that mean the exact potential on the cube itself is the same as the potential of a point particle?

A: Suppose you have a charged cube as shown below,

Say it holds a charge of $Q$ Coulomb.
Now, for this cube to behave like a point charge, you need to go very $far$ away from it such that at a particular position, your cube appears like a point charge.
In this case, the cube $behaves$ just like a point charge with a charge of $Q$ Coulomb.

It is clear that as you keep going far away from the charged cube, it keeps getting smaller. At one point, it appears like a point charge and it also behaves like a point charge.
So, one can use the same equation for potential at any point due to a point charge in the case where your charged cube appears like a point charge. Any charged geometrical shape would act as a point charge when viewed from a point very $far$ away from it.

A: Yes, the uniqueness theorem guarantees it.  If you find a solution in which the potential on the surface of the cube looks just like the potential of a point particle, then the potential outside the cube must be identical to that of a point particle since there is only one unique solution satisfying this this boundary condition.  (Assuming no external charges, of course.)

A:
if the cube is an insulator or a dielectric, how do I find the surface charge density and the volume charge density?

Since you are working with an insulator, you can have $uniform$ surface and volume charge densities unlike in the case of a conductor( other than a conducting sphere ). The reason is, excess charge cannot redistribute in an insulator as they are not free to do so. There is my advantage! Let me first talk about uniform $surface$ charge density of a cube.
Look at the figure below,

I have displayed all the sides of a charged cube. Here, I have given it a charge of say $Q$ Coulomb. Since it is an insulator, I have succeeded in establishing uniform charge distribution. The total charge available on the $surface$ of the cube is $Q$ Coulomb. The uniform $surface$ $charge$ $density$ in this case is the charge available per unit area given by $\sigma$
$\sigma = \frac{Q}{A}$ where $A$ is the area available.
For the cube,
$\sigma = \frac{Q}{6\times a^{2}}$ where $a$ is the side of the cube.
As a result of uniform charge distribution, $\sigma$ will remain constant. That's because, for any area chosen on the surface of the cube, the value of $Q$ will be such that $\sigma$ remains constant.
Let $A = A1 + A2$  and the available charge in $A1$ is $Q1$ and that in $A2$ is $Q2$
For uniform surface charge distribution, $\frac{Q1}{A1} = \frac{Q2}{A2} = \sigma$
This result always holds for uniform charge distribution.
Now, let us talk about the uniform volume charge density of the cube.
Look at the diagram below,

Once again, I have given a charge of $Q$ Coulomb to the cube in such a way that the charge is uniformly spread in the volume of the insulating cube.
Now, the $volume$ $charge$ $density$ of the cube is given by $\rho$
$\rho = \frac{Q}{V}$ where $V$ is the volume available.
For the cube,
$\rho = \frac{Q}{a^{3}}$ where $a$ is the side of the cube.
As a result of uniform charge distribution, $\rho$ remains constant. That's because for any volume chosen in the cube, the value of $Q$ will be such that $\rho$ remains constant.
Let $V = V1 + V2$  and the available charge in $V1$ is $Q1$ and that in $V2$ is $Q2$
For uniform volume charge distribution, $\frac{Q1}{V1} = \frac{Q2}{V2} = \rho$
This result always holds for uniform charge distribution.
I have explained using uniform charge distribution which is the simplest case in order to make things easy to understand.
But, if you are willing to make the charged cube behave like a point charge, you do not have to worry about the charge densities. All you need to do is to go very far away from it. At such a great distance from the cube, things will appear as though you are working with a point charge. Dimensions of the cube no longer matter. All that matters is the charge $Q$.
If I have not answered your question, it means that I have not fully understood your question and I would request you to add a few more details in your question.
Thank you.


text:
Q: How to join two queries in SQL from 3 tables? I have 3 tables (M:N) - Tests, Tests_Questions, Questions.
Tests
ID
Name

Test_Questions
IDTests
IDQuestions

Questions
ID
Text

What I need is select all from tests and count of question related to this test.
Can you please help me with this query? I am not able to solve it.

A: Use join and grouping:
SELECT t.ID, t.Name, COUNT(tq.IDQuestions) as numberOfQuestions
FROM Tests t INNER JOIN Test_Questions tq ON t.ID = tq.IDTests
GROUP BY t.ID, t.Name

Since you only need counts it is enough to join just Tests and Test_Questions tables, you don't need Questions


text:
Q: How can I solve "You may need an appropriate loader to handle this file type" in Vaadin flow (14) framework? I am working with Vaadin 14.
I am having an issue with an addon.
How do I solve this loader issue since the Vaadin framework is the one that takes care of the webpack in the application.
2021-05-29 03:35:13.750 ERROR 9096 --- [        webpack] dev-webpack                              :
ERROR in ../node_modules/@lrnwebcomponents/simple-icon/lib/simple-icons.js 18:26
2021-05-29 03:35:13.750 ERROR 9096 --- [        webpack] dev-webpack                              : Module parse failed: Unexpected token (18:26)
    2021-05-29 03:35:13.750 ERROR 9096 --- [        webpack] dev-webpack                              : You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
    2021-05-29 03:35:13.750 ERROR 9096 --- [        webpack] dev-webpack                              : |   SimpleIconsetStore.registerIconset(
    2021-05-29 03:35:13.751 ERROR 9096 --- [        webpack] dev-webpack                              : |     i,
    2021-05-29 03:35:13.751 ERROR 9096 --- [        webpack] dev-webpack                              : >     `${pathResolver(import.meta.url)}svgs/${i}/`
    2021-05-29 03:35:13.751 ERROR 9096 --- [        webpack] dev-webpack                              : |   );
    2021-05-29 03:35:13.751 ERROR 9096 --- [        webpack] dev-webpack                              : | });
    2021-05-29 03:35:13.751 ERROR 9096 --- [        webpack] dev-webpack                              :  @ ../target/frontend/generated-flow-imports.js 56:0-59
    2021-05-29 03:35:13.751  INFO 9096 --- [         task-2] dev-webpack                              : Started webpack-dev-server. Time: 5471ms

A: It comes from webpack where it seems to be an open issue. The causes of that issue was identified and recently added to the proposals of the new release for webpack. It could arrive somewhere in 2022 as stated here Class Fields (Private instance methods and accessors
You could either get rid of that addon that fails with webpack or try some of the quick-fixes suggested like this one here

A: This might not be appropriate in this case that looks like it's a problem with webpack itself and no direct relationship to Vaadin, but I'll still briefly answer the other part of this question:

How do I solve this loader issue since the Vaadin framework is the one that takes care of the webpack in the application

Vaadin manages how webpack is started and does also provide a comprehensive default configuration for webpack. The application developer does still have control over the used configuration.
This works so that there's a webpack.generated.js file that is generated by Vaadin and a webpack.config.js file that can be used by the application. By default, the application configuration is simply importing the generated configuration and using it as-is, but it's also possible to supplement the imported configuration before exporting it for webpack to use.


text:
Q: Haskell profiling - clock_gettime I'm running a Haskell program that does a long computation. After some profiling and tracing, I noticed the following:
$ /usr/bin/time -v ./hl test.hl
9000045000050000
Command being timed: "./hl test.hl +RTS"
User time (seconds): 1.43
System time (seconds): 1.15

It was using a lot of system time even though my code does not explicitly invoke any system calls (it reads a file and interprets some code in it).
Running it with strace -ttT shows a lot of calls to a timer:
17:04:52.454513 clock_gettime(CLOCK_THREAD_CPUTIME_ID, {1, 282721271}) = 0 <0.000529>
17:04:52.456223 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 <0.000720>
17:04:52.458749 rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0 <0.000239>
17:04:52.460288 clock_gettime(CLOCK_PROCESS_CPUTIME_ID, {1, 285126436}) = 0 <0.000255>
17:04:52.461650 --- SIGVTALRM {si_signo=SIGVTALRM, si_code=SI_TIMER, si_pid=0, si_uid=0, si_value=0} ---
17:04:52.462242 rt_sigreturn()          = 0 <0.000458>

I thought it might be the RTS clock, so I disabled it and re-run:
$ /usr/bin/time -v ./hl test.hl +RTS -V0
9000045000050000
Command being timed: "./hl test.hl +RTS -V0"
User time (seconds): 1.73
System time (seconds): 0.85

The strace output seems almost identical except for the actual SIGVTALRM:
17:05:16.409729 clock_gettime(CLOCK_PROCESS_CPUTIME_ID, {0, 155881514}) = 0 <0.000378>
17:05:16.410746 clock_gettime(CLOCK_MONOTONIC, {2184631, 597586194}) = 0 <0.000432>
17:05:16.412724 clock_gettime(CLOCK_THREAD_CPUTIME_ID, {0, 156994988}) = 0 <0.000290>
17:05:16.413832 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 <0.000245>
17:05:16.415017 rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0 <0.000305>

I have a few questions:

*

*Why is Haskell calling clock_gettime repeatedly?

*Is there any way to disable this functionality?

A: I took a look at where clock_gettime is called in the GHC RTS and found that it is used in a call to getMonotonicTime that in turn is the basis of the timeouts in the TimerManager of the GHC.Event library that is used by the IO Manager for polling on handles, files, system calls, etc. The MIO paper is a good relatively recent resource on the IO Manager. In any case, I don't imagine you will be able to eliminate those calls.
Also note that while you see lots of those clock calls, that does not mean they are the system calls which are taking the most time, which I imagine relate more to GC, actually performing IO, etc.


text:
Q: Authorise a HTTP Triggered Cloud Function from a (Python 2.7) App Engine instance, using a service worker account We have an HTTP triggered Cloud Function that has permissions set up via IAM. From our Python App Engine, how do we invoke the cloud function using a GCP Service Account?
Using the cloud functions service, we are able to call:
functions_service.projects().locations().functions().call(name=function_name)

This works, as the service adds the Bearer Authentication HTTP header. However, according to the docs (here and here), using the call() method to invoke the cloud function means we have a strict rate limit of 16/100s which is not suitable for production.
If we try calling the cloud function directly, via the https://[region]-[projectId].cloudfunctions.net/[functionName] URL, it does not authenticate (responds with 401), even with the Bearer Authentication HTTP header described above.


text:
Q: Android textView bug? Maximum text size in sp Is there any maximum text size for TextView in Android?
My application has to display some text in around 290sp. However, I found that some of the devices cannot display it and a whole blank page is TextView is shown.
In Samsung Galaxy Note 5 (API 23), it works find.
In Google Nexus 5 (API 19), the maximum text size is 239sp.
In Samsung Galaxy S7 (API 23), the maximum text size is 179sp.
Below is my demo code:
Layout XML
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.example.xxx.texttutorial.MainActivity">
    <Button
        android:id="@+id/buttonPlus"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:text="+10"/>
    <TextView
        android:id="@+id/textViewCurrentTextSize"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/buttonPlus"
        android:text="130"
        android:gravity="center_horizontal"
        android:textSize="40sp"
        />
    <Button
        android:id="@+id/buttonMinus"
        android:layout_width="100dp"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/textViewCurrentTextSize"
        android:text="-10"
        />
    <TextView
        android:id="@+id/currentText"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/textViewCurrentTextSize"
        android:textSize="130sp"
        android:gravity="center"
        android:text="X"/>
</RelativeLayout>

MainActivity JAVA
public class MainActivity extends AppCompatActivity {

  int textSize = 130;

  TextView currentText, textViewCurrentTextSize;

  @Override

  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    currentText = (TextView)findViewById(R.id.currentText);
    textViewCurrentTextSize = (TextView)findViewById(R.id.textViewCurrentTextSize);
    (findViewById(R.id.buttonPlus)).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
        textSize += 10;
        currentText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
        textViewCurrentTextSize.setText(textSize+"");
      }
    });
    (findViewById(R.id.buttonMinus)).setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
        textSize -= 10;
        currentText.setTextSize(TypedValue.COMPLEX_UNIT_SP, textSize);
        textViewCurrentTextSize.setText(textSize+"enter code here");
      }
    });
  }
}

A: Its because of Screen Density Pixel, try to assign different text sizes for different screen resolution in value resource files. Please read more


text:
Q: Let $f: X^{n} \to Y^{n}$ smooth function with $X$ compact $n$-manifold. Show that the set of regular value is open and dense in $Y$. Let $f: X^{n} \to Y^{n}$ smooth function with $X$ compact $n$-manifold, $Y$ $n$-dimensional manifold.  Show that the set of regular value is open and dense in $Y$.
Let $\mathcal{R}$ the set of regular value. By Sard's Theorem, $\mathcal{R}$ is dense. The hard part is to show that $\mathcal{R}$ is open.
Some hint? Thank you.


text:
Q: How to stop my themes CSS changing the Wordpress interface/? I'm currently busy exploring Wordpress theme development. I've made a theme and uploaded it to my Wordpress development site. In a css file of me, I've declared some styles for the h1, h2, h3 etc. The thing is that some of those styles are being applied to header in my Wordpress interface. This is of course not how it should be. Has anyone an idea on how to fix this? Other Wordpress themes that I used never had this weird thing.

A: This can happen if the function for enqueueing stylesheets, wp_enqueue_style() is run inside functions.php outside of a hooked function, like this:
<?php

wp_enqueue_style( 'my-style', get_stylesheet_uri() );

functions.php is loaded on the front-end and back-end when your theme is active, so this will load the stylesheet in both places.
To only load a stylesheet on the front-end you need to run this function inside another function that is hooked to the wp_enqueue_scripts hook:
<?php

function wpse_341512_enqueue_styles() {
    wp_enqueue_style( 'my-style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'wpse_341512_enqueue_styles' );

By doing this, wp_enqueue_style() is only run when wpse_341512_enqueue_styles() is run, and using add_action() like this queues up that function to only run on the front-end.


text:
Q: Caracterization of element in the Galois group of a polynomial Let $f(X)$ be a separable polynomial in $F[X]$ and $\alpha_1,\cdots,\alpha_m$ its roots. Let $T_1,\cdots,T_m$ be symbols. For a permutation $\sigma$ of $\{1,\cdots,m\}$, we let $\sigma_{\alpha}$ and $\sigma_{T}$ respectively denote  the corresponding permutations of $\{\alpha_1,\cdots,\alpha_m\}$ and $\{T_1,\cdots,T_m\}$
Let $$\theta=T_1 \alpha_1 + \cdots + T_m\alpha_m $$
I dont understand why $\sigma_{\alpha}\in G_f $ (Galois group of $f$) if and only if  it maps
$F(T)[\theta]$ isomorphically onto $F(T)[\sigma_{\alpha}\theta]$
It s from the course on Galois Theory of Milne : https://www.jmilne.org/math/CourseNotes/ft.html (page 57)