text:
Q: Change value of data-val=true dynamically I have multiple tabs in which un-obstrusive validations are used, tabs are show and hide on dropdown value, Problem is when i false the data-val value of div tabs which are hide, they can not be true again, help me for change true and false of data-val value dynamically, here is my script
<script>
    $(document).ready(function () {
        var myItem = $('#@Html.IdFor(m => m.INDUSTRY_ID)');
        if (myItem.val() == '41') {
            debugger;
                $("#tab_1_1 [data-val]").attr("data-val", true);
                $("#tab_1_5 [data-val]").attr("data-val", true);
                $("#tab_1_6 [data-val]").attr("data-val", true);
                $("#tab_1_2 [data-val]").attr("data-val", false);
               $("#tab_1_7 [data-val]").attr("data-val", false);

                $("#ind").show();
                $("#ind1").show();
                $("#ind2").show();
                document.getElementById("ind").click();
                //$("#business").data("validator").settings.ignore = "";
                $("#business").hide();
                $("#business1").hide();

            }
            else {
                $("#tab_1_2 [data-val]").attr("data-val", true);
                $("#tab_1_7 [data-val]").attr("data-val", true);
                $("#tab_1_1 [data-val]").attr("data-val", false);
                $("#tab_1_5 [data-val]").attr("data-val", false);
                $("#tab_1_6 [data-val]").attr("data-val", false);

                $("#business").show();
                $("#business1").show();
                document.getElementById("business").click();
                $("#ind").hide();
                $("#ind1").hide();
                $("#ind2").hide();

            }

    });

    $(document).ready(function () {
        $('#INDUSTRY_ID').on('change', function () {
            if (this.value == '41') {
                debugger;
                $('form').removeData('unobtrusiveValidation');
                $('form').removeData('validator');
                $.validator.unobtrusive.parse('form');

                $("#tab_1_1 [data-val]").attr("data-val", true);
                $("#tab_1_5 [data-val]").attr("data-val", true);
                $("#tab_1_6 [data-val]").attr("data-val", true);

                $("#tab_1_2 [data-val]").attr("data-val", false);
                $("#tab_1_7 [data-val]").attr("data-val", false);

                $("#ind").show();
                $("#ind1").show();
                $("#ind2").show();
                document.getElementById("ind").click();
                $("#business").hide();
                $("#business1").hide();

            }
            else {
                $("#tab_1_2 [data-val]").attr("data-val", true);
                $("#tab_1_7 [data-val]").attr("data-val", true);
                $("#tab_1_1 [data-val]").attr("data-val", false);
                $("#tab_1_5 [data-val]").attr("data-val", false);
                $("#tab_1_6 [data-val]").attr("data-val", false);
                $("#business").show();
                $("#business1").show();
                document.getElementById("business").click();
                $("#ind").hide();
                $("#ind1").hide();
                $("#ind2").hide();

            }
        });
    });
    </script>


text:
Q: CocoaPod Storyboard error: I made a cocoapod to include in my main project, it was the splash screen animations which would be used while the app was loading which page to go to. Everything builds fine in the cocoapod project, but when I include the local copy in my other projects local folder, i get the following error on the storyboard...
error: Not enough arguments provided; where is the input document to operate on?

Any idea on what is going on here?

A: It ended up being an issue with my .podspec file. I had my .source_files spec including not only my swift file, but also my storyboard.. which apparently xcode is not cool with (shown below)..
spec.source_files = 'cocoaPodProjectFolder/Source/*.{swift, storyboard}'

To fix this I had to move the storyboard file to its correct spec: resource_bundle...
spec.source_files = 'cocoaPodProjectFolder/Source/*.{swift}'
spec.resource_bundle = {'CocoaPodProject' => 'cocoaPodProjectFolder/Source/*.{storyboard}'}

redpajama_set_name: RedPajamaStackExchange


text:
Q: Events being bound twice or more jquery I'm trying to generate html on the fly with javascript. I'm binding on the click of buttons on my page. There are multiple buttons on my page which are causing my elements to be bound multiple times which produces the desired results to appear in the amount of times the button has been clicked.
My question is there something that can check if a element is already bound in jquery? If so, how do I incorporate that with the .live() function in jquery.
Here is my code:
$(document).ready(

    function () {
        $(':button').live("click", ".textbox, :button", function () {
            alert("binding");
            $(".textbox").click(function () {
                defaultVal = this.defaultValue;
                if (this.defaultValue) {
                    this.value = "";
                }
            });
            $(".textbox").blur(function () {
                if (this.value == "") {
                    this.value = defaultVal;
                }
            });
            $('[name="numsets"]').blur(function () {
                if (!parseInt(this.value)) {
                    $(this).val("you need to enter a number");
                }
            });
            $('[name="weightrepbutton"]').click(function () {
                var $numsets = $(this).parent().children('[name="numsets"]');
                if ($numsets.val() != "you need to enter a number" && $numsets.val() != "Number of Sets") {
                    var numbersets = parseInt($numsets.val())
                    repandweight.call(this, numbersets)
                    $(this).hide();
                    $numsets.hide();
                }
            })
        });
    });

The problem is line 4, every time a button is clicked, all functions that were previous bound seem to be bound to the same function twice, which is a problem.
Thanks for the help!

A: You are doing it twice ! One inside another. Take out the outer binding  and it should work
$(document).ready(function () {

      $(document).on("click",".textbox",function () {
          defaultVal = this.defaultValue;
          if (this.defaultValue) {
               this.value = "";
          }
      });

      $(document).on("blur",".textbox",function () {
          var item=$(this);
          if (item.val() == "") {
               item.val(defaultVal);
          }
      });

      $(document).on("blur","input[name='numsets']",function () {
          var item=$(this);
          if (!parseInt(item.val())) {
                item.val("you need to enter a number");
          }
      });

      $(document).on("click","input[name='weightrepbutton']",function () {
                var $numsets = $(this).parent().children('[name="numsets"]');
                if ($numsets.val() != "you need to enter a number" && $numsets.val() != "Number of Sets") {
                    var numbersets = parseInt($numsets.val())
                    repandweight.call(this, numbersets)
                    $(this).hide();
                    $numsets.hide();
                }
      })
    });

if you are using jQuery 1.7+ version, consider switching to jQuery on instead of live.
EDIT: Updated live to on as OP mentioned it in the comment.


text:
Q: A specific improper integral I have been given the following improper integral to evaluate

$$ \int_{0}^{1} \frac{x^2-1}{\log{x}} dx $$

I tried substituting $ u = \log{x} $ which gives the following improper integral
$\displaystyle \int_{-\infty}^{0} \frac{e^{3u}-e^{u}}{u} du $
This integral can be evaluated by software like Wolfram but I am interested in the method. How does one solve the integral analytically? I have no real idea on this. Thanks to all helpers.

A: $$\int_{-\infty}^{0} \frac{e^{3u}-e^{u}}{u} du=\int_{-\infty}^{0} \int_1^3 e^{xu}\ dx\ du=\int_1^3 \int_{-\infty}^{0}  e^{xu}\ du\ dx=\int_1^3 \dfrac1x\ dx=\ln3$$


text:
Q: Restrict vim auto completion to search current file only? ctrl+n and ctrl+p is very convenient completion for Vim, but sometimes it is very slow which may be caused that too many included header file in the current sources. Is there an option to restrict auto completion to search current source file (or opened streams) only?

A: You have to play around with the complete option.
From the help file,
The default is ".,w,b,u,t,i", which means to scan:
   1. the current buffer
   2. buffers in other windows
   3. other loaded buffers
   4. unloaded buffers
   5. tags
   6. included files

Personally, I have noted that removing included files was really helpful, so, in my .vimrc, I use:
set complete-=i

But you can remove (or add) other lists as well.
See :help 'complete' for more information.

A: If you have a feeling for when this "sometimes" is (a large project, a complex C file with many includes, ...), you can also use the <C-x><C-n> local file completion, see :help i_CTRL-X_CTRL-N. This way, you still have the default completion available and don't need to mess with the 'complete' option.

A: :help i_ctrl-n says:
Find next match for words that start with the
keyword in front of the cursor, looking in places
specified with the 'complete' option. The found
keyword is inserted in front of the cursor.

The next step is rather obvious, isn't it?


text:
Q: Need to sum from array object value in mongodb I am trying to calculate total value if that value exits. But query is not working 100%. So can somebody help me to solve this problem. Here my sample document. I have attached two documents. Please these documents & find out best solution
Document : 1
{
    "_id" : 1"),
    "message_count" : 4,
    "messages" : {
        "data" : [
            {
                "id" : "11",
                "saleValue": 1000
            },
            {
                "id" : "112",
                "saleValue": 1400
            },
            {
                "id" : "22",

            },
            {
                "id" : "234",
                "saleValue": 111
            }
        ],

    },
    "createdTime" : ISODate("2018-03-18T10:18:48.000Z")
}

Document : 2
 {
        "_id" : 444,
        "message_count" : 4,
        "messages" : {
            "data" : [
                {
                    "id" : "444",
                    "saleValue" : 2060
                },
                {
                    "id" : "444",
                },
                {
                    "id" : 234,
                    "saleValue" : 260
                },
                {
                    "id" : "34534",
                }
            ]
        },

        "createdTime" : ISODate("2018-03-18T03:11:50.000Z")
    }

Needed Output:
{
   total : 4831
}

My query :
db.getCollection('myCollection').aggregate([
    {
        "$group": {
            "_id": "$Id",

            "totalValue": {
                $sum: {
                    $sum: "$messages.data.saleValue"
                }
            }

        }
    }
])

So please if possible help me to solve this problem. Thanks in advance

A: It's not working correctly because it is aggregating all the documents in the collection; you are grouping on a constant "_id": "tempId", you just need to reference the correct key by adding the $ as:
db.getCollection('myCollection').aggregate([
    { "$group": {
        "_id": "$tempId",
        "totalValue": {
            "$sum": { "$sum": "$messages.data.saleValue" }
        }
    } }
])

which in essence is a single stage pipeline version of an aggregate operation with an extra field that holds the sum expression before the group pipeline then calling that field as the $sum operator in the group.
The above works since $sum from MongoDB 3.2+ is available in both the $project and $group stages and when used in the $project stage, $sum returns the sum of the list of expressions. The expression "$messages.data.value" returns a list of numbers [120, 1200] which are then used as the $sum expression:
db.getCollection('myCollection').aggregate([
    { "$project": {
        "values": { "$sum": "$messages.data.value" },
        "tempId": 1,
    } },
    { "$group": {
        "_id": "$tempId",
        "totalValue": { "$sum": "$values" }
    } }
])

A: You can add a $unwind before your $group, in that way you will deconstructs the data array, and then you can group properly:
db.myCollection.aggregate([
{
    "$unwind": "$messages.data"
},
{
    "$group": {
        "_id": "tempId",
        "totalValue": {
            $sum: {
                $sum: "$messages.data.value"
            }
        }
    }
}
])

Output:
{ "_id" : "tempId", "totalValue" : 1320 }

A: db.getCollection('myCollection').aggregate([
   {
     $unwind: "$messages.data",
     $group: {
        "_id": "tempId",
        "totalValue": { $sum: "$messages.data.value" }
     }
   }
])

$unwind

A: According to description as mentioned into above question, as a solution please try executing following aggregate query
db.myCollection.aggregate(

    // Pipeline
    [
        // Stage 1
        {
            $unwind: {
                path: '$messages.data'
            }
        },

        // Stage 2
        {
            $group: {
                _id: {
                    pageId: '$pageId'
                },
                total: {
                    $sum: '$messages.data.saleValue'
                }
            }
        },

        // Stage 3
        {
            $project: {
                pageId: '$_id.pageId',
                total: 1,
                _id: 0
            }
        }

    ]

);

A: You can do it without using $group. Grouping made other data to be managed and addressed. So, I prefer using $sum and $map as shown below:
db.getCollection('myCollection').aggregate([
 {
   $addFields: {
      total: {
          $sum: {
            $map: {
              input: "$messages.data",
              as: "message",
              in: "$$message.saleValue",
            },
          },
        },
      },
    },
  }
])


text:
Q: PHP Injection in MySQL works when hardcoded I have the following SQL query that I can successfully test in Workbench:
        $interviewInfo = $this->db->fetchAll("
            SELECT
                c.s,
                c.t,
                i.u,
                i.v,
                qa.w,
                i.x
            FROM
                XXX AS i,
                YYY as ip,
                ZZZ AS qa,
                BBB AS c
            WHERE
                c.s = :CompanyId AND ip.r = i.Id
                    AND i.s = c.s
                    AND ip.t = qa.p
                    AND i.h > 0
            ORDER BY i.q DESC
            LIMIT 3", array("CompanyId"=>$companyId));

But with the associative array dependency injection in my SQL statement, it returns an empty array.
I have tried directly inserting CompanyId in place of :CompanyId and then it works.
I have no idea what is going on here because there is:

*

*No error from MySQL.

*The query is correct and I can verify that.

*I can also verify CompanyId exists and is a valid integer.

A: This is not how PDOStatement::fetchAll works. You must first prepare your query, then execute it, and then you can call fetchAll to get the results. Something like this should work:
$stmt = $this->db-prepare("SELECT
                c.s,
                c.t,
                i.u,
                i.v,
                qa.w,
                i.x
            FROM
                XXX AS i,
                YYY as ip,
                ZZZ AS qa,
                BBB AS c
            WHERE
                c.s = :CompanyId AND ip.r = i.Id
                    AND i.s = c.s
                    AND ip.t = qa.p
                    AND i.h > 0
            ORDER BY i.q DESC
            LIMIT 3");
$stmt->execute(array("CompanyId"=>$companyId));
$interviewInfo = $stmt->fetchAll();

Note that you should also check that the prepare and execute statements succeeded by checking that $stmt is not false and that execute does not return false.


text:
Q: Distributing beta iPhone app without UUIDs At first I thought that in order to do an ad-hoc deployment of a beta iPhone app, you had to burn the device's UUID of the target user into the app.  (I use TestFlight to do it)
But a few days ago I came across http://retraceapp.com/, and you're able to download their app straight from their website.
I did get several security warnings, but I didn't think this was possible at all.  Does someone know how they did this?
Update: The link is no longer available on the website.

A: This looks like a Enterprise account app, which actually is not allowed to be distributed outside a company.
One can find the key ProvisionsAllDevices set to true in its provisioning profile. See here about that ProvisionsAllDevices vs ProvisionedDevices in embedded.mobileprovision

A: I'm one of the Co-Founders of Retrace. We used an Enterprise developer account.
Here's a link that explains more.
IOS Enterprise Distribution Through OTA
Apple contacted us after about 2 weeks and forced us to shut down the link and move to the App Store.


text:
Q: Sparql identifying Powerstations more precisely I would like to get all powerstations and also the type of powerstation (Nuclear, Water, Coal etc...) from DBpedia.
I recognized that there are no specific types of powerstations, so I am query all powerstations and try to figure out the type of powerstation from the name. ( I will not catch all of them, but a lot enough).
My query so far :
PREFIX dbpedia: <http://dbpedia.org/resource/>
PREFIX dbp-ont: <http://dbpedia.org/ontology/>
#PREFIX georss: <http://www.georss.org/georss/>

select distinct *
{
?name rdf:type dbp-ont:PowerStation .
?name geo:lat ?lat .
?name geo:long ?long
OPTIONAL { ?name  dbo:installedCapacity ?installedCapacity }
OPTIONAL { ?name  dbo:openingDate ?openingDate }
OPTIONAL { ?name  dbo:closingDate ?closingDate }
} limit 100

Is there a way to have a new field named 'nuclear' that has a value of '1' if its name contains 'nuclear' ?

A: First thing is to remember that DBpedia data is a moving target, just like the Wikipedia data from which it is derived. Updates to Wikipedia will eventually (typically, in 3-9 months) be part of DBpedia. More quickly (typically in a few hours, if not minutes or seconds; sometimes days, for various reasons), they'll be part of DBpedia-Live.
The long-term solution for giving every powerstation a type as you wish, is to edit Wikipedia.
For your specific immediate workaround, note that a large number of OPTIONAL clauses can make your query take much longer, and so may eventually mean that DBpedia will not return the data you want.  You may need to spin up your own mirror (such as DBpedia or DBpedia-Live in the Amazon EC2 Cloud).
Finally, as @AKSW noted in comments, the line below should deliver your ?nuclear variable with a 1 if that string appeared in the ?name.  Just put it after your OPTIONAL lines.
BIND ( IF ( CONTAINS ( LCASE ( STR ( ?name ) ), "nuclear" ), 1, 0 ) AS ?nuclear )


text:
Q: Larger simulation of adding and removing items from queue in PHP My friend got the next test assignment. Implement a class Item as part of a larger simulation of adding and removing items from queue.
The add method adds the number at the end of queue, get method removes first number from the queue and returns it.
class Item
{
    public function __construct(){
    }

    public function add($number){
    }

    public function get(){
    }
}

We tried everything that came to our mind, but the execution time does not fall below 15sec for 50.000 iterations. Does anyone know a better solution to this problem?
Test case:
$n = 50000;

for ($i=0; $i < $n ; $i++) {
    $item->add("Test".$i);
}

for ($i=0; $i < $n ; $i++) {
    echo $item->get()."\n";
}

Here's what we've tried:
With array_shift:
$this->numbers[] = $number;
return array_shift($this->numbers);

times elapsed in secs:
22.661945819855 |
23.122117042542 |
21.985857009888 |
22.498090982437
array_shift and array_push:
array_push($this->numbers, $number);
return array_shift($this->numbers);

times elapsed in secs: 25.500070095062 |
 22.558148860931 |
 21.946757078171 |
 22.031461000443
unset:
    array_push($this->numbers, $number);
    $key = key($this->numbers);
    $n = $this->numbers[$key];
    unset($this->numbers[$key]);
    return $n;

times elapsed in secs: 18.401049852371 |
 14.445369958878 |
 15.184392929077 |
 16.063473939896
array_splice:
    array_push($this->numbers, $number);
    $key = key($this->numbers);
    $n = $this->numbers[$key];
    array_splice($this->numbers, $key, 1);
    return $n;

times elapsed in secs: 49.540771007538 |
 47.315555810928 |
 46.451086997986 |
 46.475464820862
SplDoublyLinkedList:
    $this->numbers = new SplDoublyLinkedList();
    $this->numbers->push($passportNumber);
    return $this->numbers->shift();

times elapsed in secs: 18.166617155075 |
 17.268024921417 |
 15.621854066849 |
 18.711433887482
Linked lists:
class ListNode
{
    public $data;
    public $next;
    function __construct($data)
    {
        $this->data = $data;
        $this->next = NULL;
    }
}

class Item
{
    $this->firstNode = null;
    $this->lastNode = null;
    public function add($number)
    {
        $link = new ListNode($number);

        if ($this->firstNode === null) {
            $this->firstNode = &$link;
            $this->lastNode = &$link;
        } else {
            $this->lastNode->next = &$link;
            $this->lastNode = &$link;
        }
    }

    public function get()
    {
        if ($this->firstNode === null) {
            return null;
        }

        $n = $this->firstNode->data;
        $this->firstNode = $this->firstNode->next;

        return $n;
    }
}

times elapsed in secs: 19.694635868073 |
 17.934485912323 |
 18.973595142365 |
 18.013978004456

A: the main part the time is taken on is the get method and it's array_shift. you can use array_slice instead on 1000 elements for example:
<?php
class Item
{
    protected $numbers = [];

    public function add($number){
        $this->numbers[$number] = true;
    }

    public function get(){
        $x = key($this->numbers);
        unset($this->numbers[$x]);
        return $x;
    }
}

ob_start();

$n = 50000;
$item = new Item();

$start = microtime(true);

for ($i=0; $i < $n ; $i++) {
    $item->add("Test".$i);
}

echo microtime(true)-$start;
echo "\r\n";
$start = microtime(true);

for ($i=0; $i < $n ; $i++) {
    echo $item->get() . "\r\n";
}

echo microtime(true)-$start;

ob_end_flush();


text:
Q: Python-crontab module I'm trying to use Python-crontab module over Linux OS (CentOS 7)
My config file is as follows:
{
  "ossConfigurationData": {
    "work1": [
      {
        "cronInterval": "0 0 0 1 1 ?",
        "attribute": [
          {
            "rules": [
                {
                    ......
                }
               ]
            }
            ],
    "work2": [
      {
        "cronInterval": "0 0 0 1 2 ?",
        "attribute": [
          {
            "rules": [
                {
                    ......
                }
               ]
            },
            ]
      }

}
The file contain many work items. Each work item has it own cron expression. I want my Python script to be able to schedule each cron separately, set it in my OS & run it. When running, the purpose is running each work item separately according to it cron expression
I did step-by-step according to this tutorial. After many tests it's writing the cron, but I'm not sure it's what I need
Using this module, I can't create reference to the relevant work item. It's just adding a new line to the OS crontab with any execution I want to put there. I can't describe what I wish to run (i.e. - work1 or work2)
Any suggestions?
10x in advance :)

A: A common error is not using the cron.save() function after editing. Given the limited information in the question, this is the most likely answer.


text:
Q: A simple question on $SU(2)$ gauge transformations in Wen's papers on projective symmetry group (PSG)? Recently I am studying the projective symmetry group (PSG) and the associated concept of quantum order first proposed by prof.Wen.
In Wen's paper, see the last line of Eq.(8), the local SU(2) gauge transformation for spinor operators is defined as $\psi_i\rightarrow G_i\psi_i$, where $\psi_i=(\psi_{1i},\psi_{2i})^T$ are fermionic operators and $G_i\in SU(2)$. Why we define it like this?
Since as we know, the Shcwinger fermion representation for spin-1/2 can be written as $\mathbf{S}_i=\frac{1}{4}tr(\Psi_i^\dagger\mathbf{\sigma}\Psi_i)$, where $\Psi_i=\begin{pmatrix}
 \psi_{1i} & -\psi_{2i}^\dagger \\
 \psi_{2i} & \psi_{1i}^\dagger
\end{pmatrix}$, and $G_i\Psi_i$ which is the same as the above transformation $\psi_i\rightarrow G_i\psi_i$ is in fact a spin rotation of $\mathbf{S}_i$, while $\Psi_iG_i$ does not change spin $\mathbf{S}_i$ at all.
So in Eq.(8), why we define the SU(2) gauge transformation as $G_i\Psi_i$ rather than $\Psi_iG_i$?

A: a) For a rotation of axis $\vec n$ and angle $\theta$, the transformation for a spin $1/2$ representation is :
$$\psi \to e^{i \frac{\theta}{2}  \vec\sigma. \vec n}\psi = G(\vec n,\theta)\psi\tag{1}$$
where $\psi$ is a 2-component row complex spinor. Here $G(\vec n,\theta)$ is a member of $SU(2)$. The action of a matrix on a 2-component row object is always at the left of the object.
b) Beginning with : $\vec S=\frac{1}{4}tr(\Psi^\dagger \vec \sigma\Psi)$, suppose we have a transformation $\Psi \to \Psi G$. As you noticed, it would not change the value of $\vec S$, because :
$$tr(G^\dagger\Psi^\dagger \vec \sigma\Psi G)=tr(\Psi^\dagger \vec \sigma\Psi GG^\dagger) = tr(\Psi^\dagger \vec \sigma\Psi) \tag{2}$$
But $\vec S$ is a vector (it is in the fundamental or vectorial representation of $SO(3)$, or, if you prefer, in the adjoint representation of $SU(2)$), so it has to change under a rotation. So the transformation $\Psi \to \Psi G$ is non-valid and irrelevant.

A: God, I just found that I made a very foolish misunderstanding of prof.Wen's paper. In fact, the operator $\psi_i=(\psi_{1i},\psi_{2i})^T=(f_{1i},f_{2i}^\dagger)^T$ and $\mathbf{S_i}=\frac{1}{2}f_i^\dagger\mathbf{\sigma}f_i$, but I misunderstood  $\mathbf{S_i}=\frac{1}{2}\psi_i^\dagger\mathbf{\sigma}\psi_i$ before(Please see Eq.(8) in this paper http://prb.aps.org/abstract/PRB/v65/i16/e165113 at the very beginning).
Now everything goes well. In fact, the $SU(2)$ gauge transformations $\psi_i \rightarrow G_i\psi_i$ are totally equivalent to $\bigl(\begin{smallmatrix}
 f_{1i} & -f_{2i}^\dagger\\
f_{2i}  & f_{1i}^\dagger
\end{smallmatrix}\bigr)\rightarrow \bigl(\begin{smallmatrix}
 f_{1i} & -f_{2i}^\dagger\\
f_{2i}  & f_{1i}^\dagger
\end{smallmatrix}\bigr)G_i$. And the $SU(2)$ matrices being on the left or right depends on the notation of spinon operartors that you define, which is not the key point here.
Note: The operators $\psi_i$ that appear in all of Wen's papers on PSG in 2002 are not the direct annihilation operators for Schwinger-fermions $f_i$, so please be very careful!


text:
Q: WCF Socket Error 10045 My colleague has an app that hosts a simple WCF service with a net.tcp endpoint.  I can add the service reference to any app I create using the address net.tcp://192.168.0.22:9999/GSS-POS/QueryDispatcher/mex
However, when he tries to add the service reference to an app running on his machine he immediately gets a socket error 10045.  We've tried using both net.tcp://localhost:9999/GSS-POS/QueryDispatcher/mex
and
net.tcp://192.168.0.22:9999/GSS-POS/QueryDispatcher/mex
He's tried re-installing Visual Studio 2008, Service Pack 1 and XP Service Pack 3 all to no avail.  Can anybody provide any pointers?
UPDATE: This appears as though it is related to Visual Studio.  By using the WCF Client test app, it is possible to see the service.  It seems as though VS is having the problem adding the service reference.
UPDATE 2: Adding a reference with VS 2008 works with named pipe and http transport.  The problem only manifests itself when trying to add a service reference which utilises a net.tcp endpoint.
Best regards,
Simon

A: I don't have an answer for you, but the code 10045 represents WSAEOPNOTSUPP (operation not supported) which, according to MSDN, means:

The attempted operation is not
  supported for the type of object
  referenced. Usually this occurs when a
  socket descriptor to a socket that
  cannot support this operation is
  trying to accept a connection on a
  datagram socket.

A: The book by Juval Lowy says that tcp communications are "optimised" for WCF->WCF comms only. Maybe that has something to do with your problem.


text:
Q: Visual Studio Cordova cannot build on android I got the following error at output when I build the code to android device.
1>------ Clean started: Project: Shhh...ItWorks, Configuration: Debug Android ------
1>  ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
1>  JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_55
1>  Running: C:\app\TW Secret\11232015\Shhh...ItWorks_\Shhh...ItWorks\platforms\android\gradlew clean -b C:\app\TW Secret\11232015\Shhh...ItWorks_\Shhh...ItWorks\platforms\android\build.gradle -Dorg.gradle.daemon=true
1>
1>  FAILURE: Build failed with an exception.
1>
1>  * What went wrong:
1>  A problem occurred configuring root project 'android'.
1>  > Could not resolve all dependencies for configuration ':_debugCompile'.
1>     > Could not find any version that matches com.android.support:support-v13:23+.
1>       Searched in the following locations:
1>           https://repo1.maven.org/maven2/com/android/support/support-v13/maven-metadata.xml
1>           https://repo1.maven.org/maven2/com/android/support/support-v13/
1>       Required by:
1>           :android:unspecified
1>     > Could not find any version that matches com.google.android.gms:play-services-gcm:+.
1>       Searched in the following locations:
1>           https://repo1.maven.org/maven2/com/google/android/gms/play-services-gcm/maven-metadata.xml
1>           https://repo1.maven.org/maven2/com/google/android/gms/play-services-gcm/
1>       Required by:
1>           :android:unspecified
1>
1>  * Try:
1>  Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
1>
1>  BUILD FAILED
1>
1>  Total time: 2.267 secs
1>  Picked up _JAVA_OPTIONS: -Xmx512M
1>
1>  C:\app\TW Secret\11232015\Shhh...ItWorks_\Shhh...ItWorks\platforms\android\cordova\node_modules\q\q.js:126
1>                      throw e;
1>                            ^
1>  Error code 1 for command: cmd with args: /s /c ""C:\app\TW Secret\11232015\Shhh...ItWorks_\Shhh...ItWorks\platforms\android\gradlew" clean -b "C:\app\TW Secret\11232015\Shhh...ItWorks_\Shhh...ItWorks\platforms\android\build.gradle" -Dorg.gradle.daemon=true"
1>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\ApacheCordovaTools\vs-mda-targets\Microsoft.MDA.FileMirroring.targets(354,5): error MSB3073: The command "platforms\android\cordova\clean.bat" exited with code 1.
========== Clean: 0 succeeded, 1 failed, 0 skipped ==========

And when I tried to clean the solution it shows this error:
Severity    Code    Description Project File    Line
Error   MSB3073 The command "platforms\android\cordova\clean.bat" exited with code 1.   Shhh...ItWorks  C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\ApacheCordovaTools\vs-mda-targets\Microsoft.MDA.FileMirroring.targets

I'm using Cordova 5.3.3
Does anyone knows how to fix this?

A: After removing and reinstalling plugins one by one, I found out it's the push plugin that is conflicting with the local notification plugin, remove one or another fix the problem : )


text:
Q: How to increase the x-axis plot size in seaborn? I am trying to plot a graph using seaborn for different professions and I cannot identify the labels on the x-axis. Here's the image of the graph

A: as @Karthik mentioned in the comment, I have tried rotating labels
ax = sns.countplot(x="Profession", data=df)

ax.set_xticklabels(ax.get_xticklabels(), rotation=40, ha="right")
plt.tight_layout()
plt.show()

This worked

A: Just use:
plt.figure(figsize=(25,7)

*

*#25 is Width

*#7 is Height


text:
Q: Font awesome icons doesn't change by onclick method of blazor I have a simple method SortClass(column) that change the css class when the user clicks on the icon, I checked the method and it works fine but blazor doesn't regenerate the SVG after assigning the value of the class.
 <th  @onclick="@(() => SortData(col))" scope="col">
      @col.Caption
      <i class="@SortClass(col)"></i>
  </th>

SortClass:
private string SortClass(ColumnDefinition col)
{
    if (col._SortDirection != SortDirection.NotSet)
    {
        return $"{col._SortDirection.ToString().ToLower()}"; // SortDirection is enum has value {"fas fa-sort-up", "fas fa-sort-down"}
    }
    return "invisible";

}

Onclick method:
 private void SortData(ColumnDefinition sortByCol = null)
        {
            if (sortByCol is null)
            {
                sortByCol = Columns.FirstOrDefault(x => x._SortDirection != SortDirection.NotSet);
                if (sortByCol is null) return;
            }
            if (sortByCol._SortDirection != SortDirection.NotSet)
            {
                switch (sortByCol._SortDirection)
                {
                    case SortDirection.NotSet:
                        sortByCol._SortDirection = SortDirection.Asc;
                        break;
                    case SortDirection.Asc:
                        sortByCol._SortDirection = SortDirection.Desc;
                        break;
                    case SortDirection.Desc:
                        sortByCol._SortDirection = SortDirection.Asc;
                        break;
                    default:
                        sortByCol._SortDirection = SortDirection.Asc;
                        break;
                }

                if (sortByCol._SortDirection == SortDirection.Asc)
                {
                    DataItems.Sort((x, y) => typeof(TItem).GetProperty(sortByCol.DataField).GetValue(x).ToString()
                        .CompareTo(typeof(TItem).GetProperty(sortByCol.DataField).GetValue(y).ToString()));
                }
                else
                {
                    DataItems.Sort((x, y) => typeof(TItem).GetProperty(sortByCol.DataField).GetValue(y).ToString()
                        .CompareTo(typeof(TItem).GetProperty(sortByCol.DataField).GetValue(x).ToString()));
                }
            }

        }

A: I think your component is not aware of the changes you want to made, since the icon class is not bound to a class property and the changes or not made in a predefined lifecycle method such as OnInitialized etc..
Thus either bind the icon class to a property that is changed when you execute your sorting or explicitly communicate your changes to be rendered by using the StateHasChanged()-method.


text:
Q: Cucumber test results not showing up in SimpleCov report Edit: I am now using a .simplecov file in the root of my directory as per the SimpleCov directions. I have also added some groups including "app/views". However, Cucumber tests are still not being logged into SimpleCov. I even used the launchy gem to see if the code is executing and it is... I am a bit stumped at this point.
I am trying to integrate Cucumber into my Rails 5 app for the first time. I am also using RSpec and SimpleCov. I am using Cucumber to test a simple user registration and user sign in feature. The tests pass with Cucumber and I am told that a Coverage report was generated for Cucumber. However, the Coverage report doesn't actually show any "Log In" or "Sign Up" feature was covered.
user.feature File:
# /features/user.feature

Feature: User Features
As a user I want to be able to Sign Up or Log In when I visit the home page so that I can use the website.

Scenario: Create a user account
When I go to the index
Then I should see "Sign Up"

Scenario: Sign In as a user
When I go to the index
Then I should see "Sign In"

user_steps.rb file:
# /features/step_definitions/user_steps.rb
When(/^I go to the index$/) do
  visit root_path
end

Then(/^I should see "([^"]*)"$/) do |arg1|
  click_on "Sign Up"
  fill_in "Email", with: "user1@example.com"
  fill_in "Password", with: "password1"
  fill_in "Password confirmation", with: "password1"
  click_button "Sign up"

  expect(page).to have_content("Welcome! You have signed up successfully.")
end

Terminal output from running $ cucumber to show it's passing:
ANTONIOs-MacBook-Pro:reddit_clone Tony$ cucumber
Using the default profile...
Feature: Create User
As a user I want to be able to sign up when I visit the home page so that they can use the website.

  Scenario: Create a user account # features/user.feature:4
    When I go to the index        #  features/step_definitions/user_steps.rb:1
    Then I should see "Sign Up"   # features/step_definitions/user_steps.rb:5

  Scenario: Sign In as a user   # features/user.feature:8
    When I go to the index      # features/step_definitions/user_steps.rb:1
    Then I should see "Sign In" # features/step_definitions/user_steps.rb:5

2 scenarios (2 passed)
4 steps (4 passed)
0m0.897s
Coverage report generated for Cucumber Features to     /Users/Tony/Documents/projects/rails/reddit_clone/coverage. 18 / 185 LOC (9.73%) covered.

My Coverage Report:

# /spec/spec_helper.rb top of the file.
require 'simplecov'
SimpleCov.start
require 'database_cleaner'
RSpec.configure do |config|
  config.before(:suite) do
    DatabaseCleaner.strategy = :transaction
    DatabaseCleaner.clean_with(:truncation)
  end

  config.around(:each) do |example|
    DatabaseCleaner.cleaning do
      example.run
    end
  end

  ...

end

Cucumber env.rb file:
# /features/support/env.rb
require 'simplecov'

SimpleCov.start 'rails'

require 'cucumber/rails'

What steps do I need to take to show the cucumber test coverage in the coverage report?

A: it is in the documentation to how to merge results
https://github.com/colszowka/simplecov#using-simplecov-for-centralized-config
https://github.com/colszowka/simplecov#merging-results


text:
Q: Prevent clearing password field if wrong credentials entered I have noticed on some sites that, when we enter the wrong credentials the password fields becomes encrypted instead of clearing, mean if user enters password *** it will becomes like ********** and password fields doesn't cleared, what is the technique they are using, I am looking for below solution, but didn't find out relevant info:

*

*Prevent browser to clear the password field if wrong credentials.

*Encrypt the password before submitting to server in simple JS, and
decrypt in server side(I am using JSF), and if  wrong credentials
the encrypted password should be displayed in field

A: They are likely just putting the word "password" in the value. As for sending it secure I suggest using SSL. SSL is designed for this thing exactly. It encrypts the entire webpage and all post data.
If they enter an incorrect value it is best to clear the password field. You can leave the username/email but should clear the password field. This is just standard security practice.


text:
Q: Mass virtualization of corporate desktops I am looking into virtualizing desktops for a large office, and I haven't been able to figure out how I would accomplish access to a VM instance per user.
We are considering using sunrays as our point of access, from which I assume we would launch a VNC connection into a VM. At this point I'm at a bit of a loss -- how would I ensure that we either launch a VM if it is not already running, or connect to their existing VM if it is already running? Or would the solution here be to make sure that all possible instances are already running, but 'paused' until someone tries to connect to them?
We are are still considering our options in terms of virtualization -- Hyper-V, KVM, Xen, or other.. on one hand we're enthusiastic about open-source products so KVM and Xen are attractive choices, but on the other hand we want administrator training to be as painless as possible so products like Hyper-V have their allure too.
I know this is a fairly sprawling topic I've put up, but I'd appreciate any advice anybody has to offer on the topic.
Thanks!

A: http://www.linux-kvm.com/content/redhat-announces-kvm-upcoming-rhel-54-and-rhev-h-stateless-hypervisor
http://www.linux-kvm.com/content/redhat-rhev-m-virtualization-management-tool-demo
http://www.virtualization.info/2009/08/some-details-about-red-hat-new-platform.html
http://www.theregister.co.uk/2009/02/23/redhat_revs_kvm_up/page2.html
Check out the VDI features of the product.

A: You should consider desktop virtualization with specific applications such as Citrix XenDesktop. They deliver the applications to the user's desktop while being executed on the servers.

A: Look into VMware View.  They are working on version 4 which should greatly improve performance.  I am looking at this product for a small number of desktops.
Also Windows Server 2008 R2 has some new VDI features to take a look at.

A: That's what Qumranet used to sell before being bought by Redhat.
For this, they developed KVM as open source (and quickly got included in the Linux kernel), of course, the rest of the stack was closed source, including the remote display protocol which they claim is the best there is.  They also had an admin console, simple clustering of hardware and load-balancing by live-migration of VMs
The website is still up, and the product (SolidICE) seems to be available.
I haven't used the product, but would be my first stop if I wanted to virtualize desktops.

A: There are several layers that you need to understand and separate,

*

*Access point (your sunray)

*Connection broker, this is a service that the access point connects to, to retrieve either a list of desktops, or to auto launch a desktop

*Connection protocol the protocol the client will use to intimate the connection to the VM, e.g. RDP, ICA, PCoIP.

*Hypervisor, the host with VMs running ontop.

*Application Virtualisation, this layer is optional, and realistically unrelated to VDI.  This just allows you to make your VMs relatively stateless by allowing users to connect to any VM to run their applications without a lengthy install.

*Profile management, another optional layer to allow user settings and preferences to roam with them.

You can generally mix and match solutions from different vendors.  E.g. Hyper-V with XenDesktop for broker and protocol.
Some brokers allow you to spin up VMs on the fly, keeping a list of idle machines, rebooting / re-building on logoff etc...
Keep in mind the significant 'porting' effort you'd need to undertake to virtualise your applications (re-package everything), and profile management if you go down the stateless route.


text:
Q: WCF provide incorrect urls in wsdl behind a load balancer i've a wcf installed on a cluster of web servers behind a load balancer.
The pubblic address is: http://externaldomain/mywcf.svc and  it is the unique endpoint where the users should access.
So, when i paste this url in the browser to see "the helper page"(the page where it shows me the url of its "wsdl" file)
the address isn't as i  expect:  "http://externaldomain/mywcf.svc?wsdl" but "http://server1/mywcf.svc?wsdl" (server1 is the name of the server where the wcf are running on and the user has been routed by the load balancer)
this make impossible to add the services to visualstudio because the suggested address "http://server1/mywcf.svc=wsdl"  is a private url
so, how i should configure the wcf settings to make "aspnet" to generare the helper page with the "correct" address?
is there some "proxy" node  or something similar to set in the web.config
  #### public url ####           #### private url ####

                                (http://server1)
                                 ----------------
                            -->  -- webserver1 --
                           /     ----------------
                          /
 (http://externaldomain) /
 ---------------------- /
 --- load balancer ----
 ---------------------- \
                         \
                          \
                           \     (http://server2)
                            -->  ----------------
                                 -- webserver2 --
                                 ----------------

A: WCF has special behavior for cases like this useRequestHeadersForMetadataAddress.

<serviceBehaviors>

  <behavior>

    <useRequestHeadersForMetadataAddress/>

  </behavior>

</serviceBehaviors>

This behavior makes service replace urls with url used in request, so it avoids problem you mentioned. More info: http://zamd.net/wcf/2010/01/14/using-request-headers-for-metadata-address.html


text:
Q: Why didn't Zion build more hovercraft and try to invade Machine City? If I am correct, Zion had nine hovercraft at the time the One was about to go to the Architect. Five of them got destroyed by an EMP by Smith/Bane, the Nebuchadnezzar and the Vigilant were destroyed by other means, and finally there remained Niobe's Logos and Roland's Hammer. I guess if all ships survived, the battle of Zion could have been won by the humans and Zion be successfully defended (without Anderson's intervention).
If Zion built even more hovercraft, would they have enough EMPs to invade and destroy Machine City? How many EMPs would be needed to attack Machine City, assuming the invader hovercraft go up above the clouds at first and then restart them when falling towards Machine City, like the Logos did it?

A: The range of the EMPs is relatively limited. The hovercraft are able to see things (on their scanners and visual) that they can't zap.

Link: What are they doing?
Trinity: They're just out of EMP range.
Neo: It's a bomb. We have to get out of here. Now.

It stands to reason that if the range is only a globe a few hundred feet in diameter (and assuming the machine city hasn't grown dramatically since it was first founded, which seems a really big and unlikely assumption), you'd need thousands of ships to cover the city, and that assumes that the tens of thousands of squiddies and other machines that are outside the city (tending to the City's defences, managing the Matrix towers and the Fetus Fields, for example) wouldn't just come and kill them afterwards.

Not to mention that the whole point of Zion City is that it's a trap designed to collect malcontents. Presumably the resources that are made available in the near vicinity of Zion are very closely controlled by the Machines to prevent precisely what you're suggesting.

A: Short answer: It would require too many resources from Zion and not be able to render the desired outcome.
Sending a large number of hovercrafts to blast some EMPs is pretty much a suicidal mission, mainly for the hovercrafts. Getting close enough to the center of the Machine City would most likely bring casualties among both the crafts and their crews.
Keep in mind that the EMPs will also affect the hovercrafts if they aren't all precisely synchronized. This is where I would guarantee the loss of many crafts.
Most importantly, do we know that Deus Ex Machina isn't prepared for a possible EMP attack?
A much easier alternative would've been to detonate a nuclear weapon just above Zero-One. A high-altitude detonation can create a very large radius EMP. For example, a 1.4Mt at 400km altitude can create an EMP radius of up to 1500km (900miles). This is a much more effective approach to EMP the machines out of existence. The only problem would be to successfully deliver the payload.
Possible risks:

*

*Deus Ex Machina could be protected against such an EMP attack resulting into a more aggressive war conducted by the machines.

*How do we know that there are not multiple copies of the Deus Ex Machina's code? Even though Deus controls all the machines, we see what resembles the Borg, a hive behavior. Its code could be backed up throughout the machines.

*What if the destruction of Deus Ex Machina or the majority of the Machine City would result in the failure of the fetus fields and/or the power plant? This failure will lead to the death of all those people who are plugged in and still part of the Matrix. We can see that Zion and the free people are not actually willing to accept that kind of outcome since Neo and Deus Ex Machina come to an agreement to save the machines, Zion, and the ones that are still in.

From my observation, the people are aware they cannot defeat the machines through a "ground war" by attacking their headquarters. The machines have superiority in numbers and technology. Reason why the humans have engaged in a cyberwarfare.
Ultimately, a full on attack on Zero One, with or without EMPs, is not something that Zion can engage in.


text:
Q: Load two jqgrids in order ( sequence ajax calls) I have two jqgrids in my page. when page load i will popup a modeldialogwindow to the user that use a ajax call. i will populate jqgrids by using the value from the popup window that user selected. can i delay the jqgrid load ajax calls ? ( by giving timeout?)my issue is sometimes grids ajax calls fires before the popup. so that from the back end it will throw an error. ( since the value that user select is not exists. i need to do the following in a sequence manner.

*

*show the popup window . wait for user response( this will automatically happens when using the window.showModalDialog) get the value that user selects and post to back end.

*send ajax call to load the first grid.

*send ajax call to load the second grid.
since jqgrids are populating just after the '$(document).ready' i was unable to delay it.
appreciate your help. Thank you in advance.

A: You should set datatype parameter of the both grids to 'local' at the initialization. It will prevent any ajax calls. After the user select all parameters needed for the ajax request you should set the datatype to 'json' (or 'xml' depend on your requirements) and trigger reloadGrid:
$("#list").setGridParam({datatype:'json',page:1}).trigger('reloadGrid');

A: Instead of calling the jqgrid function on $(document).ready move it to an event that gets fired after the user makes a selection in the modal box.


text:
Q: Render raw HTML from Razor view I have a ASP.NET MVC4 controller function that returns dynamic html using a StringBuilder as a Json result.
This is an quality issue, because I don't want dynamic HTML being returned as a string property in a JSON result.
My goal is to make use of ASP.NET MVC to use .cshtml for example with a viewmodel so that I make an instance of the viewmodel, passing in the results and in the end, return the raw HTML of the view as a JSON result.
How can this be achieved ?

A: Instead of returning an HTML string inside of a JSON object, you may want to consider an action that returns a PartialView directly.
If you can't do this, because you need to return MULTIPLE html strings in one call, then I would advise taking a look at this thread which has a nice static method to turn a rendered view into a String:  Render a view as a string.


text:
Q: Export all subsites I am looking for a quick way to export all sub-sites from a web application and exclude the root url, is there a quick way to accomplish this?

A: maybe this can help :
Get-SPSite http://yourwabapp/sites/sitecol | Get-SPWeb | Where-Object  { $_.ParentWeb -Ne $null } | ForEach-Object { Export-SPWeb -Identity $_ -Path $_.ID }

you will need to adjust the export params according your needs


text:
Q: PyGame image save colors distorted So I have implemented the following screenshot functionality into my game just to log progress and stuff like that. This is my code:
pygame.image.save(screen, save_file)

Pretty basic. I recently upgraded to python 3.3 and have since been having the issue of distorted colors using this function. Here is what I mean:
Distorted Color:

So it looks quite nice, but it isn't how it supposed to be. This is the actual image:

Is this a known issue or is it just me? Are there any fixes to it or is it just a broken function at the moment. I am using pygame 1.9.2pre and I am assuming it is just a bug with the pre release but I was having issues using any other versions of pygame with python 3.3.

A: Some users have reported difficulty with saving images as pngs:

I only get .tga files even when I specify .png.  Very frustrating.
If you use .PNG (uppercase), it will result in an invalid file (at least on my win32).  Use .png (lowercase) instead.
PNG does not seem to work, I am able to get a preview of it in Thunar, but everywhere else It says that it is not a valid PNG.

Saving in a different format may be helpful. For example, BMP is a simple format, so it's unlikely that Pygame's implementation will be buggy.
If you really want to save as PNG, you can reverse the distortion by swapping the red channel with the green one. This is fairly easy. For example, using PIL:
from PIL import Image
im = Image.open("screenshot.png")
width, height = im.size

pix = im.load()
for i in range(width):
    for j in range(height):
        r,g,b = pix[i,j]
        pix[i,j] = (g,r,b)

im.save("output.png")

Or you can save as BMP and convert to PNG after the fact:
from PIL import Image
im = Image.open("screenshot.bmp")
im.save("screenshot.png")

A: for future reference, this trick worked for me:
from PIL import Image
imgdata = pygame.surfarray.array3d(screen).transpose([1,0,2])[:,:,::-1]
Image.fromarray(imgdata).save('output.png')


text:
Q: A particular Diophantine equation of degree 4 in two variables Did someone met the equation of type $$a^4 + (1 - 4 b)^2 b^2 + a^2 (3 + 4 b - 16 b^2) =0$$
somewhere in practice?
I met this one in a notes on Diophantine geometry, where the equation remains unsolved.
The question there is to find at least one solution $a,b\in \mathbb{N}$ with $a>7$.

Is something  known  about the natural solutions of the equation?

Any suggestions on the subject are appreciated as well.

A: Remark: for $b=2$ the equation becomes
$$
(a+7)(a+2)(a-2)(a-7)=0.
$$
It looks like that this Diophantine equation has been constructed, e.g., perhaps for a contest, or another challenge.
The equation is biquadratic in $a$, so we obtain that
$$
3(64b^4-32b^3-28b^2+8b+3)
$$
needs to be a perfect square.

A: Idea how to aproach:
$$a^4 + (1 - 4 b)^2 b^2 + 4a^2 b(1 - 4 b)+3a^2 =0$$
Put $c=b(1-4b)$ and $d=a^2$ so we get $$d^2+c^2+4cd+3d=0$$
So $$ d^2+d(4c+3)+c^2=0$$
Now the discriminat must be perfect square:
$$ (4c+3)^2-4c^2 = e^2$$


text:
Q: What unit scope do I need for this? I am trying to install a 3rd party package and I get a compile error:
[DCC Error] fiile/line : E2003 Undeclared identifier: 'Windows'

which refers to this line:
wnd := Windows.GetFocus;

It seems fairly obvious that I don't have my Unit Scopes right - but which do I need (and is there a general approach to find which use clause I need)?
I currently have
Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;System;Xml;Data;Datasnap;Web;
Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;Winapi;System.Win

[Update]
interface
uses
SysUtils, winapi.windows, Classes, Controls, ExtCtrls, Graphics, StdCtrls,
Dialogs, IniFiles, winapi.messages, Forms, Math
{$IFDEF DELPHI6_LVL}
, Variants
{$ENDIF}
;

No uses in the impementation section.
[Upate]
I forgot to mention. I failed (in the same way) to install it on one laptop. Then I succeeded on a second. The trouble is that I'd rather have it on my desktop and after a fresh install of XE2 starter I get these problems.

A: You unit scope looks fine, so try these two options
declare in your uses section Windows instead of Winapi.Windows
or modify your code like so
wnd :=  Winapi.Windows.GetFocus;

A: Assuming that your uses names the Windows unit at all, it would appear to do so by naming the unit as Winapi.Windows. And so your code must also do so and be written as
wnd := Winapi.Windows.GetFocus;

When you use a unit by naming the fully scoped unit name, you must also use the fully scoped name in subsequent code in that unit.
Now, if you want to use the name Windows then you must name the unit as Windows in the uses clause and let the unit alias setting do its job. If you imported the unit by naming it Windows then your original code will work.
To be very clear:
uses
  Winapi.Windows;

is what you have now but you would need:
uses
  Windows;

for your code to compile.


text:
Q: alloy predicate calculus post production As I'm new to alloy, this is most likely a simple question.  I've been through the on-line tutorials and am now reading the Software Abstractions, revised edition.  On page 34 there is an example at the bottom of the page:
r' = {b:B, a:A, c:C | a->b->c in r}

where the text says that this defines a new relation of B->A->C.  I don't see how an explicit order for r' is achieved by this statement.

A: It's the property of set comprehension

*

*{a: A | somePredicate1[a]} is of type A and returns a set containing all atoms for which somePredicate1 holds;

*{a: A, b: B | somePredicate2[a, b]} is of type A->B and returns a relation containing all a->b tuples for which somePredicate2 holds;

*and so on

The syntax of set comprehension basically consists of two parts (1) type declaration (before the | character), and (2) predicate which must hold for every element in the returned set.


text:
Q: MIPS Pipelining logic to solve data hazards The code below runs on a 5-stage pipelined datapath. I am having a hard time knowing whether my understanding of how pipelining works is correct or not. In my attempt below, I try to solve a data hazard in a datapath with no data forwarding unit, by inserting 'bubbles' in the oppropriate places. My first question is, is my pipelining logic below correct?
My second question is assuming there IS a forwarding unit in the datapath, from MEM->EX and from WB->EX, how would that change my logic from the first question?
add t0, s1, s2
add t1, t0, s3
sub t2, t0, t1
xor t3, t2, a0
lw t4, 0(t7)
slt t5, t4, t3

This is my attempt for question 1:
add t0, s1, s2 //IF add1 instruction
nop            //ID add1 instruction
nop            //EX add1 instruction
add t1, t0, s1  //MEM add1 instruction,  IF add2 instruction
nop             //WB add1 instruction,  ID add2 instruction
nop            //EX add2 instruction
nop            //MEM add2 instruction
nop            //WB add2 instruction
sub t2, t0, t1 //IF sub instruction
nop            //ID sub instruction
nop            //EX sub instruction
nop            //MEM sub instruction
xor t3, t2, a0 //WB sub instruction, IF xor instruction
lw t4, 0(t7)   //ID xor instruction, IF lw instruction
nop            //EX xor instruction, ID lw instruction
nop            //MEM xor instruction, EX lw instruction
nop            //WB xor instruction, MEM lw instruction
slt t5, t4, t3 //WB lw instruction, IF slt instruction

A: Take a look at the pipeline diagrams illustrated here: https://www.student.cs.uwaterloo.ca/~cs251/S12/a4.pdf and map your instructions to similarly staggered pipelines, and it will help you visualize the data hazards.
In addition, the exact data-forwarding implementation will depend on the design of the questions on your assignments, which will affect how many nops you need.


text:
Q: Water conductivity measurement AC, interfacing with arduino I want to implementate this device, mentioned in the title.
The problem is how to correctly build the " read out device" that is clearly a wheatsone bridge?
But in AC, the problem is the signal conditioning for a frecuency between 1-20khz probably I suppose that I need to use an OP AMP stage and an AC to DC meter after it.
Nevertheless the whole thing needs to be very acurrate. Any advices?

The final goal is to interface with arduino.
Thanks!

A: Sure the TIA (trans-impedance amp) converts a current to a voltage.

simulate this circuit – Schematic created using CircuitLab
V-water is not a battery,  it's the electro-chemical response of the water/electrode.  I'm not sure exactly what it is... you'll have to play around with the frequency.


text:
Q: How lo load dynamic CSS variables from a file? I want to add to my home dashboard a day/night color mode which will be switched depending on some external conditions.
In the example code below, the "external condition" is a press on the button, which computes new values for CSS variables, which are then used in the


text:
Q: CODECHEF: Runtime Error (NZEC) I attempted a problem from codechef and made my code on java which runs perfectly on eclipse on my laptop.But everytime i try to submit the code it gives me this NZEC error.
Can anyone tell why am i getting  the non zero exit code error (NZEC) while i am executing this code.
Problem to this code: https://www.codechef.com/problems/STRPALIN
    import java.util.*;
import java.io.*;
public class Palindrome {

    public boolean check() throws IOException{
        String A;
        String B;
        BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
        A=inp.readLine();
        B=inp.readLine();
        for(int i=0;i<A.length();i++)
        {
            for(int j=0;j<B.length();j++)
            {
                if(A.charAt(i)==B.charAt(j))
                    return true;
            }
        }
        return false;
    }

    public static void main(String[] args)throws NumberFormatException, IOException {
        Palindrome M = new Palindrome();
        boolean[] array = new boolean[10];
        BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
        int T = Integer.parseInt(in.readLine());
        for(int i=0;i<T;i++)
        {
            array[i]=M.check();
        }
        for(int j=0;j<T;j++){
            if(array[j])
                System.out.println("Yes");
            else
                System.out.println("No");

        }
    }
}

A: The problem with your code is that while taking input from user for String A and B, the readline() method returns null, and when you try to access String A or B, a NullPointerException is thrown. Hence the non-zero exit code .
Now, the readline() method returned null value because you created a BufferedReader object twice, which led to leakage of memory.
Refer to this link: readline() returns null in Java

A: Regarding the NZEC error:
import java.util.*;
import java.io.*;
 class Codechef {

    public boolean check() throws IOException{
        String A;
        String B;
        BufferedReader inp = new BufferedReader (new InputStreamReader(System.in));
        A=inp.readLine();
        B=inp.readLine();
        for(int i=0;i<A.length();i++)
        {
            for(int j=0;j<B.length();j++)
            {
                if(A.charAt(i)==B.charAt(j))
                    return true;
            }
        }
        return false;
    }

    public static void main(String[] args)throws NumberFormatException, IOException {
        try {
            Codechef M = new Codechef();
        boolean[] array = new boolean[10];
        BufferedReader in = new BufferedReader (new InputStreamReader(System.in));
        int T = Integer.parseInt(in.readLine());
        for(int i=0;i<T;i++)
        {
            array[i]=M.check();
        }
        for(int j=0;j<T;j++){
            if(array[j])
                System.out.println("Yes");
            else
                System.out.println("No");

        }
        } catch(Exception e) {
        } finally {
        }
    }
}


text:
Q: Can't use facebook to login because user model setting in local passport I am trying to build a login system with Facebook, Google and local passport, I am using Node.js, passport.js, and ORM to finish it, but I faced one problem now, my user model is like below
const User = connection.define('user', {   googleID: {
    type: Sequelize.STRING,   },   facebookID: {
    type: Sequelize.STRING,   },   firstname: {
          type: Sequelize.STRING,
          notEmpty: true,
        },

  lastname: {
          type: Sequelize.STRING,
          notEmpty: true,
        },

  username: {
          type: Sequelize.TEXT,
        },

  email: {
          type: Sequelize.STRING,
          validate: {
              isEmail: true,
            },
        },

  password: {
          type: Sequelize.STRING,
          allowNull: false,
        },

  last_login: {
          type: Sequelize.DATE,
         }, });

After this setting, whenever I want to log on my website through Facebook, it kept showing SEQUELIZE ERROR, password required! I know it the reason is I don't have password while signing in with Facebook, but what can I do with this issue? I saw this page on GitHub https://github.com/feathersjs/authentication/issues/168
but I still have no clue in using this feathers-joi tool, can anyone give me some advice? Thank you
Here is my Facebook.js code
const passport = require('passport');
const cookieSession = require('cookie-session');
const FacebookStrategy = require('passport-facebook').Strategy;
const User = require('../models/User');
const keys = require('../secret/keys.js');

passport.serializeUser((user, done) => {
  done(null, user.id);
});
passport.deserializeUser((id, done) => {
  User.findById(id).then(user => {
    done(null, user);
  });
});

passport.use(new FacebookStrategy({
  clientID: keys.facebookClientID,
  clientSecret: keys.facebookClientSecret,
  callbackURL: '/auth/facebook/callback',
}, (accessToken, refreshToken, profile, done) => {
  User.findOne({ where: { facebookID: profile.id } }).then(existinguser => {
    if (existinguser) {
      //Nothing will happen, the ID already exists
      done(null, existinguser);
    }else {
      User.create({ facebookID: profile.id }).then(user => done(null, user));
    }
  });
}));

My passport.js would be like below(Still need some fix)
var bCrypt = require('bcrypt-nodejs');

module.exports = function(passport, user) {

    var User = user;

    var LocalStrategy = require('passport-local').Strategy;

    passport.use('local-signup', new LocalStrategy(

        {

            usernameField: 'email',

            passwordField: 'password',

            passReqToCallback: true // allows us to pass back the entire request to the callback

        },

        function(req, email, password, done) {

            var generateHash = function(password) {

                return bCrypt.hashSync(password, bCrypt.genSaltSync(8), null);

            };

            User.findOne({
                where: {
                    email: email
                }
            }).then(function(user) {

                if (user)

                {

                    return done(null, false, {
                        message: 'That email is already taken'
                    });

                } else

                {

                    var userPassword = generateHash(password);

                    var data =

                        {
                            email: email,

                            password: userPassword,

                            firstname: req.body.firstname,

                            lastname: req.body.lastname

                        };

                    User.create(data).then(function(newUser, created) {

                        if (!newUser) {

                            return done(null, false);

                        }

                        if (newUser) {

                            return done(null, newUser);

                        }

                    });

                }

            });

        }

    ));

}

A: try this
passport.use(new FacebookStrategy({
  clientID: keys.facebookClientID,
  clientSecret: keys.facebookClientSecret,
  callbackURL: '/auth/facebook/callback',
}, (accessToken, refreshToken, profile, done) => {
  User.findOne({ where: { facebookID: profile.id } }).then(existinguser => {
    if (existinguser) {
      //Nothing will happen, the ID already exists
      done(null, existinguser);
    }else {
        var object = {
            facebookID: profile.id,
            password: ""
        }
      User.create(object).then(user => done(null, user));
    }
  });
}));


text:
Q: Instrumentation amplifier noise amplified I built a simple circuit with an instrumentation amplifier (PGA204AP) in order to clean a differential signal from noise. The signal is generated few meters away from the acquiring point and the cable (twisted pairs shielded) pass through a very noisy environment.
The circuit is the following :

The shield of the cable is grounded in the Op.Amp side, and in the other side it is not connected. As you can see, the input of the Op amp is filtered through a differential mode filter (R1 R4 and C2) with the cut-off frequency set to  ~60kHz, and a common mode filter (R1-C1 and R4-C3) with the cut-off frequency set to ~1MHz.
At the output of the PGA204 I put a 2nd order low pass filter with the cut-off frequency set to ~500kHz.
I tested the circuit with no input, just to see if the noise from the environment would have been attenuated: the noise present in the environment was the following (measured with the scope directly from the cable) :

250ns/div

5us/div
So clearly there was a very strong noise a 2MHz, but once I connected the instrumentation amplifier, the noise was amplified (more than doubled). So I decided to put this 2nd order filter just to see if this 2MHz noise would have been eliminated. But the result was the same, and this seems very strange to me because two completely independent devices have the same issue.
In addition, I tested the device with some noise produced with the signal generator at the input (noise applied at one input, and the other input had it as well thanks to the twisted pairs cable) and the result was the following:

Upper ones are the two inputs, lower one is output. It seems pretty good.

*

*What I'm not sure about this 10k resistor (R5) between V- input and ground. I've been told to put it for the bias current but doesn't it interfere with the LP filters at the input?

*Is there something else I should pay attention to with these filters? Suggestion for the next tests I should do in order to solve the problem?

A: LM358 has very low gain-bandwidth product (1MHz) therefore the Sallen-Key filter topology you used might not work well as a lowpass above a few tens of kHz. What happens is the HF jumps over the opamp through C5, and at HF it doesn't have enough feedback to keep its output pin low impedance, so the HF just goes on to the output. Also as Scott says in the comments, the slow opamp can slew limit on the HF noise, and distort the LF signal.
I recommend simulating its transfer function. See Fig.8 on this document.
Now, looking at the PGA204 datasheet page 6, your 2MHz noise is outside of the PGA204 bandwidth, so it should be attenuated a little bit (or a lot depending on gain, which you don't mention). Also on page 6, note how CMRR depends a lot on frequency and gain setting, CMRR at high frequency isn't very good, so you do need a passive filter at the input to get rid of the HF common mode noise.
If your noise is common mode you have to be careful about common mode to differential mode (CM to DM) conversion at the input of your amp. This occurs when the input impedance between the two halves of the differential pair is unbalanced. It can also occur anywhere on the signal path if an impedance imbalance occurs between the two halves of the pair, for example in the sensor (aka "source impedance"), so you need to check this.
The 10k resistor will play a part, but the most likely culprits would be C1 and C3 if they are low-precision parts like X7R ceramics. A difference in the values of C1 and C3 will create an impedance imbalance at HF between the two inputs, and convert CM noise to DM, which the PGA204 will then amplify.
So, I suggest trying this:

*

*Use a common mode choke on the input, it should have enough inductance to raise the impedance significantly at the noise frequency and above. Or increase R1/R4 to a higher value, decreasing the capacitors value accordingly.

*Make sure the filter caps are precision (1%) like C0G ceramics.

*Duplicate R5, one resistor per input.

*Check your shield connection

*If substantial current flows in the shield, make sure it doesn't go through a sensitive ground node on your PCB.


text:
Q: Formating by column header instead of alphabet I want to do some column formatting but column position is changing every time so how can i use column header instead of Column Alphabet ?
Sub Excel_Format()
    Columns("J:J").Select
    Selection.NumberFormat = "0"
    Selection.Columns.AutoFit
End Sub

A: You need to start defining a Name for your column. The quickest way to do it is to select the column (Column J in this case) and enter a name in the range/cell selector on the top-left part of your Workbook. See image below:

I have named the column to "MyColumn". You can now use this as a reference in your code, like this:
Sub Excel_Format()
    Dim Rng As Range

    Set Rng = ActiveSheet.Range("MyColumn")
    Rng.NumberFormat = "0"
    Rng.Columns.AutoFit
End Sub

Even if you add or remove columns to the left of column J, the reference to MyColumn will remain correct

A: Please, try the next way. You can use it for any header, only adapting the used constant:
Sub Excel_Format()
    Dim ws As Worksheet, RngH As Range
    Const myColName As String = "ColumnX" 'your column header

    Set ws = ActiveSheet 'use here your necessary sheet

    Set RngH = ws.rows(1).Find(myColName)
    If Not RngH Is Nothing Then
        With RngH.EntireColumn
            .NumberFormat = "0"
            .AutoFit
        End With
    Else
        MsgBox myColName & " could not be found in the sheet first row..."
    End If
End Sub

The header should exist in the first sheet row. If not, you should adapt ws.rows(1).Find( writing the necessary row, instead of `...
Selecting, activating in such a context only consumes Excel resources, not bringing any benefit.


text:
Q: Animated bar chart race, a popular data visualization
Recently I see more and more data-viz called "Animated bar chart race". Some random examples, and note, how smoothly and organically everything changes in these videos.:

*

*https://flourish.studio/visualisations/bar-chart-race

*https://www.reddit.com/r/dataisbeautiful/comments/qmklqh/oc_how_dangerous_cleaning_the_chernobyl_reactor

*https://towardsdatascience.com/creating-an-animated-bar-chart-race-with-tableau-6a7839f703af
I hope there is a trick to adopt BarChart for this. But nothing comes to mind than quite direct and elaborate hijacking of rectangles from BarChart
Cases[BarChart[{1,2,3}],_Rectangle,Infinity]

{Rectangle[{0.548798,0.},{1.4512,1.},RoundingRadius->0], Rectangle[{1.5488,0.},{2.4512,2.},RoundingRadius->0], Rectangle[{2.5488,0.},{3.4512,3.},RoundingRadius->0]}

and doing some tedious time dependent moving of coordinates. It is not clear to me how one can very comprehensively select a speed of rectangle motion and what is the best data structure to be fed into BarChartRace function. Do I provide just "frames" of data samples (which seems ideal, with a lot of automation figuring out the animation rates and looks) or do I need to provide some time stamps etc.? Also, note, not only the bars length is affected, but the identity of each bar and plot range need to be tracked, for example here are two sequential frames where lengths changed and bars moved which is the elementary thing that needs to be animated:
{BarChart[{1,2,3},ChartStyle->{Red,Green,Blue},PlotRange->7],
BarChart[{3.5,4,7},ChartStyle->{Blue,Green,Red},PlotRange->7]}

I did not try yet to deep, because I keep thinking that maybe there is a package already somewhere or a few neat tricks to make this work easily that folks here are aware of. Any solution is highly-highly appreciated.
Tentative basic scenario
Questionable, but in mind mind it looks something like... At a given moment we have some example data (like number of animals) - called data-frame. We got more dogs than cats, so dog bar is 1st by rank in the data-viz:
<|"cat"->5,"dog"->7|>

Some growth or decrease happens. Event 1 leading to swapping of bars is that rankings changed, now we got more cats than dogs and the cat's bar is 1st in data-viz:
<|"cat"->11,"dog"->8|>

Another type of event is introduction of a new player (bird):
<|"cat"->13,"dog"->11,"bird"->23|>

So I assume we have a sequence of data-frames:
{<|"cat"->5,"dog"->7|>,
<|"cat"->11,"dog"->8|>,
<|"cat"->13,"dog"->11,"bird"->23|>}

fed into the function BarChartRace that figures out the animation automatically.
I also think that at least 2 ways of animation is possible: via GIF/MP4-like and via Dynamic/Manipulate-like things.
Again this is just a (questionable) thought, anything else along these lines is welcome. Thank you!
Real data
If one wants to try this on real data, there are many examples. From GDP of countries to currencies to stocks to movie rankings etc. A very clean sample dataset where there is no missing values is WikipediaData for colors:
data={WikipediaData["Red","DailyPageHits"],
WikipediaData["Blue","DailyPageHits"],
WikipediaData["Green","DailyPageHits"],
WikipediaData["Black","DailyPageHits"],
WikipediaData["White","DailyPageHits"]};

One can easily see where swapping action will happen:
DateListPlot[(MeanFilter[#1, Quantity[1, "Months"]] & ) /@ data,
  PlotStyle -> {Red, Blue, Green,Black,White},PlotTheme->"Marketing"]

Note the data are absolutely uniform and easy to use - daily basis, nothing missing, all equal length:
Length/@Normal/@data

{2320,2320,2320,2320,2320}

A: The simple switching of the lider can be done easy:
values = Table[RandomReal[{0, i}, 5], {i, 1, 35}];
labels = RandomWord["Noun", 5];

anim = Table[
   data = Sort@Thread[values[[i]] -> labels];
   BarChart[data[[All, 1]],
    BarOrigin -> Left,
    ChartStyle -> "Rainbow",
    LabelingFunction -> After,
    ChartLabels -> Placed[data[[All, 2]], Before],
    PlotRange -> {{Automatic, 5 + Max@values[[i]]}, All},
    Axes -> False,
    ImageSize -> 500, GridLines -> Automatic],
   {i, 1, Length@values, 1}];

However, it works without any nice effects like fading etc..

A: Update 2: if we pass ranks, labels and starting values as metadata for each data element we can combine sortBars and a slightly modified version of growingBar to get a ChartElementFunction that gives the desired result:
ClearAll[growingBar, sortBars, racingBars]

growingBar[t_, cedf_: Automatic,  o : OptionsPattern[]] :=
   {EdgeForm[],
    ChartElementData[cedf /. Automatic -> "Rectangle", o][
     {{#[[1, 1]], (1 - t) #3[[1, 3]] + t #[[1, 2]]}, #[[2]]}, ##2],
    Text[Style[NumberForm[Round[(1 - t) #3[[1, 3]] + t #[[1, 2]], .01], {3, 2}], 16],
     Offset[{10, 0}, {(1 - t) #3[[1, 3]] + t #[[1, 2]], Mean @ Last @ #}], {-1, 0}],
    Text[Style[#3[[1, 2]], 16],
      Offset[{-10, 0}, {t, 1} {First @ First @ #, Mean @ Last @ #}], {1, 0}]} &;

sortBars[t_, cedf_: Automatic, o : OptionsPattern[]] :=
 Module[{minmaxy = (1 - t) #[[2]] +
      t (#3[[1, 1]] + {0, Subtract @@ Reverse @ #[[2]]})},
  {EdgeForm[],
   ChartElementData[cedf /. Automatic -> "Rectangle", o][{#[[1]], minmaxy}, ##2],
   Text[Style[NumberForm[Round[ N@#2, .01], {3, 2}], 16],
     Offset[{10, 0}, { Last@First@#, Mean[minmaxy]}], {-1, 0}],
   Text[Style[#3[[1, 2]], 16],
     Offset[{-10, 0}, { First@First@#, Mean[minmaxy]}], {1, 0}]}] &

racingBars[t1_, sortspeed_: 1, rest___] :=
  If[t1 >= 1, sortBars[sortspeed (t1 - 1), rest][##], growingBar[t1, rest][##]] &;

Examples:
SeedRandom[1];
labels = RandomWord["Noun", 5];
values = RandomSample[Range[10], 5];
starts = ConstantArray[0, 5];

data = Thread[values -> Transpose[{Ordering@Ordering@values, labels, starts}]];

Dynamic @ BarChart[data,
  BarOrigin -> Left,
  "BarStartingValue" -> 1,
  ChartStyle -> "Rainbow",
  ChartElementFunction -> racingBars[Clock[{0, 2, 1/100}, 10, 1]],
  PlotRange -> {{Automatic, 1 + Max@values}, All},
  Axes -> False,
  ImageSize -> 600]

Use sortspeed = 10; and racingBars[Clock[{0, 1 + 1/sortspeed, 1/100}, 10, 1], sortspeed] to make sorting 10 times faster than growing:

If we replace starts = ConstantArray[0, 5] with start = RandomSample[Range @ 10, 5] (to give each bar its own starting value) we get

Update: A custom chart element function to sort the bars:
ClearAll[sortBars]
sortBars[t_, cedf_: Automatic, o : OptionsPattern[]] :=
 Module[{minmaxy = (1 - t) #[[2]] + t (#3[[1, 1]] + {0, Subtract @@ Reverse@#[[2]]})},
   {EdgeForm[],
    ChartElementData[cedf /. Automatic -> "Rectangle", o][{#[[1]], minmaxy}, ##2],
    Text[Style[NumberForm[Round[ N @ #2, .01], {3, 2}], 16],
     Offset[{10, 0}, { Last @ First @ #, Mean[minmaxy]}], {-1, 0}],
    Text[Style[#3[[1, 2]], 16],
       Offset[{-10, 0}, { First @ First @ #, Mean[minmaxy]}], {1, 0}]}] &

Example:
SeedRandom[1];
labels = RandomWord["Noun", 5];

values = RandomSample[Range[10], 5];

Attach to values the ranks and labels as metadata :
data2 = Thread[values -> Transpose[{Ordering @ Ordering @ values, labels}]];

clock2 := Clock[{0, 1, 1/100}, 3, 1]

Dynamic @ BarChart[data2,
  BarOrigin -> Left,
  ChartStyle -> "Rainbow",
  ChartElementFunction -> sortBars[clock2],
  PlotRange -> {{Automatic, 1 + Max@values}, All},
  Axes -> False,
  ImageSize -> 500,
  "BarStartingValue" -> 1]

TODO: (Hoping that we have not painted ourselves into a corner) find a way to combine growingBar and sortBars with two synchronized clocks.
Original answer:
For starters, for the easier part, we can use a custom ChartElementFunction:
ClearAll[growingBar]
growingBar[t_, cedf_: Automatic, o : OptionsPattern[]] :=
   {EdgeForm[],
    ChartElementData[cedf /. Automatic -> "Rectangle", o][
      {{#[[1, 1]], t #[[1, 2]]}, #[[2]]}, ##2],
    Text[Style[NumberForm[Round[t N@#2, .01], {3, 2}], 16],
      Offset[{10, 0}, {t, 1} {Last@First@#, Mean@Last@#}], {-1, 0}],
    Text[Style[#3[[1]], 16],
     Offset[{-10, 0}, {t, 1} {First@First@#, Mean@Last@#}], {1, 0}]} &;

Examples:
SeedRandom[1];
labels = RandomWord["Noun", 5];
values = RandomSample[Range[10], 5];

data = Thread[values -> labels];

We can use Clock + Dynamic to dynamically update the parameter passed to growingBar:
clock1 := Clock[{0, 1, 1/100}, 15, 1]

Dynamic[BarChart[data,
  BarOrigin -> Left,
  ChartStyle -> "Rainbow",
  ChartElementFunction -> growingBar[clock1],
  PlotRange -> {{Automatic, 1 + Max @ values}, All}, Axes -> False,
  ImageSize -> 500]]

Use growingBar[clock1, "FadingRectangle", "GradientOrigin" -> Right] to get

TODO: I think we can extend this approach by (1) passing the ranks of data elements as metadata, (2) adding another argument to growingBar to indicate the vertical positions of the rectangles, and (3) controlling the second argument using a second Clock.

A: Using Graphics with parametrized Rectangle primitives:
ClearAll[racingRectangles, ranks]

ranks = Ordering @* Ordering;

racingRectangles[t_, spacing_: .1][starts_, ends_, labels_, cd_: "Rainbow"] :=
 Module[{ord = Ordering @ starts},
  MapThread[{#4, EdgeForm[Darker @ #4],
     Rectangle[{0, #3}, {(1 - t) # + t #2, #3 + 1 - spacing}],
     Text[Style[NumberForm[Round[(1 - t) # + t #2, .01], {3, 2}], 16],
       Offset[{10, 0}, { (1 - t) # + t #2, #3 + (1 - spacing)/2}], {-1, 0}],
     Text[Style[#5, 16], Offset[{-10, 0}, { 0, #3 + (1 - spacing)/2}], {1, 0}]} &,
    {Sort @ starts,
     ends[[ord]],
     ranks[(1 - t) starts + t ends][[ord]],
     ColorData[cd] /@ Rescale[ends[[ord]]],
     labels[[ord]]}]]

Examples:
SeedRandom[1];
labels = RandomWord["Noun", 5];
starts = RandomReal[{0, 2}, 5];
ends = RandomSample[Range[10], 5];

Dynamic @ Graphics[
  racingRectangles[Clock[{0, 1, 1/100}, 15, 1]][starts, ends, labels],
  ImageSize -> 600,
  PlotRange -> {{Automatic, 1 + Max @ ends}, {0, Automatic}},
  PlotRangePadding -> Scaled[.05]]

Manipulate[
 Graphics[racingRectangles[t][starts, ends, labels],
  ImageSize -> 600,
  PlotRange -> {{Automatic, 1 + Max @ ends}, Automatic},
  PlotRangePadding -> Scaled[.05]],
{t, 0, 1, Appearance -> "Open"}]

TODO: Make sorting smoother when rankings change.


text:
Q: informatica generate session with default values Is it possible to set a default session parameter in Informatica?
I want to set the target, the source, default database and set the target schema on the prefix and default schema.

A: You can create a shared parameter file for all the workflows and provide default values for your parameters in the parameter file in the below format:
[Global]
$DBConnection=DB_NAME
$Source=SRC_NAME
$Target=TGT_NAME
$PMMergeSessParamFile=TRUE

Then you can override these values for any specific workflow that you need.


text:
Q: Where do "shenanigans" come from? Shenanigans, or shenanigan, also with several variant spellings, can be dated to 1855 USA in both the OED and Etymonline, but the OED simply says "Origin obscure" and Etymonline throws a few guesses into the ring:

Suggestions include Spanish chanada, a shortened form of charranada "trick, deceit;" or, less likely, German Schenigelei, peddler's argot for "work, craft," or the related German slang verb schinäglen. Another guess centers on Irish sionnach "fox."

Can anyone provide anything more concrete?
(Note: Another question asks specifically about "I call shenanigans" but not shenanigans itself.)

A: This word is commonly used in the UK, and my Irish friend says its origin is from Erse (Irish Gaelic), spelt differently, but meaning the same thing - tricksy, fox like, etc. There is no proof of this, but it is a fact that many Irishmen working as navvies were present in California at the time this word appeared in the States.
UPDATE: Original gaelic Irish word 'sionnachuighm' meaning to play tricks - rough pronunciation at that time 'shinnuckeem'.

A: Irish speaker here. Sionnachaíonn makes some amount of sense alright, the literal translation would be something akin to "to fox". Totally irrelevant but this has been pretty interesting

A: Wentworth & Flexner, Dictionary of American Slang (1960) suggests an extended Irish term:

shenanigans n.pl. Tricks, pranks, nonsenses; petty cheating or deception. Since c1870; may be from the Irish "sionnochwigham" = I play tricks.

The same source lists "shenanannygag" (also meaning a trick or prank) as being based on shenanigans and "not common."
Chapman & Kipfer, Dictionary of American Slang, Third Edition (1995) bump the origin to "by 1855" and retain the Wentworth/Flexner suggestion that the word perhaps comes from sionnachuighim "play tricks, be foxy."
The Facts on File Dictionary of Word and Phrase Origins (1997) begins its entry with this sentence:

shenanigans. Though now it is always used in the the plural, this Americanism for "mischief" or "trickery" was first recorded as shenanigan in 1855 in California.

I suspect that the citation in question involves a story from the California Herald cited in numerous Google Books periodicals, such as this one from the Merchants' Magazine and Commercial Review, volume 40 (1859), in which the following sentence occurs:

Jim took his bill, and eyeing the puzzled landlord as though he suspected some "shenanigan," he broke out—
"I want to see them 'ar books."

The earliest Google Books occurrence of this anecdote is in Yankee-Notions, vol. 5 (1856), but unfortunately the snippet view of this version of the story doesn't include the relevant term within its window. [Note (added 7 October 2015): As Hugo points out in a comment below, the relevant text from the December 1856 issue of Yankee-Notions appears in a Hathi Trust copy of that periodical.]

ADDED TO ANSWER (1/3/14):
Not surprisingly—considering its date of publication—John Russell Bartlett, Dictionary of Americanisms (1848) doesn't include an entry for shenanigan or shenanigans. But I was somewhat surprised that the second edition of this book (1859) has no such entry either. I haven't been able to find a copy of the third edition. The fourth edition (1877) does have shenanigan, along with this interesting discussion of the equivalence of shenanigan, skullduggery, and hornswoggle:

The "Philadelphia Times" (Nov. 5. 1877), in defining the word skullduggery [which Bartlett calls "a very good and very common word in the West"], says, "Its best Eastern equivalent is shenanigan, although the less complicated word hornswoggling [which Bartlett also identifies as "Western"] rather directly translates it."

This quotation suggests that shenanigan had become popular enough in the Eastern United States by 1877 for Easterners to consider it commonplace in (and perhaps even native to) their region.
Another early discussion of shenanigan (though spelled with a fourth n) occurs in Maximilian Schele De Vere, Americanisms: The English of the New World (1872):

Shenannigan, probably a purely fictitious word (though a Dutch origin has been claimed for it), frequently heard in the South and West, and denoting groundless bragging for the purpose of getting the better of another. "Shenannigan means any kind of chaff, foolery, nonsense, advanced to cover some little scheme or game." Hence Miss Vinnie Ream, the artist, whose skill was said to have been largely measured by her personal charms, was recently admonished by a writer in the Chicago Evening Post to "go to work and try better next time, instead of fooling members of Congress by a pair of black eyes and a mass of beautiful curls. No shenannigan, Vinnie!" (January 1871.)

FURTHER UPDATE (7/30/16):
An Elephind search turns up four occurrences of shenanigan in a California newspaper between July 10, 1854, and January 1, 1855. From "By Telegraph to the Union" in the Sacramento [California] Daily Union (July 10, 1854):

San Joaquin Democratic Convention. Stockton, July 9th, 1854. The Democratic Convention held in this city yesterday passed off with considerable jarring, and no few discordant notes. There was considerable "shenanigan" going on amongst them, and it is hardly supposable that the ill-feelings engendered are yet quieted down.

From "Postscript: San Francisco Correspondence," in the Sacramento [California] Daily Union (November 16, 1854):

After a few important preliminaries, a committee consisting of the following gentlemen were named to superintend the drawing, to see, as it was facetiously expressed by one of the "gods," that there was no "Shenanigan" about it, namely: Geo. H. Hoasefross, J. L Van Bokkelen, T. K. Battelle, Marshal McKenzie. W. H. Patten, F. M. Pixley, F. E. R. Whitney, R. B. Quayle, ...

From "The City: Pedestrianism" in the Sacramento [California] Daily Union  (December 26, 1854):

The rival pedestrians, Wheeler and peeler, are making a great ado about walking a plank for one hundred and two consecutive hours. We can point to some clothiers on J street, in this city, who have been walking the planks in front of their stores, for a customer, for the past month. The exercise—they so regard it—is taken in full view of the populace, and conducted without any "shenanigan."

From "The City: Pastime" in the Sacramento [California] Daily Union (January 1, 1855):

Purse, ten dollars. Match, the horse to pull a lock-wheeled wagon weighing 2,390 pounds, and four persons more than the mare could. The preliminaries were arranged, after much confab, as follows: "Get away from that wheel we don't want any shenanigan—wheel ain't chucked—lift and see—stand back in front—here's four big men in the wagon (from an insider)—get in the center—two behind and two before—even on heels—turn that wheel up—take off that chain—don't let that horse run off with us (inside again)—&c."

The term also appears as a verb, in "Law Report: Twelfth District Court," in the [San Francisco, California] Daily Alta California (June 19, 1855):

A. D. Brown, witness for plaintiff, testified that he had had a conversation with the defendant, Zane, in which Zane said that the plaintiff had been trying to "shenanigan" him; that if he, Zane, failed in the action, he intended to have some satisfaction anyhow; that he had employed Judge Heslep as his counsel; that Heslep was an enemy of Satterlee's and hated him; that if Heslep could not gain the suit, he would at least give Satterlee a good "blackguarding."

It thus appears that shenanigan may first have been used in print in 1854 in a string of articles in the Sacramento Daily Union, where it seems consistently to have had a meaning along the lines of "fraud, deceit, or dirty trick playing."

A: This can't be Irish at all -- I'm an Irish speaker and I've never come upon this phrase or idiom -- "sionnach" is fox but tricks would be something like cleasanna -- and the idea than anyone pronounced it "shinnuckeem" is pure nonsense. The Irish soft /ch/ is more fronted, very unlikely to give way to a glottal stop like /k/ or /g/. I think the word just "sounds Irish" to those who don't know the language.

A: Interesting to me that the rise and fall in popularity (using Google's Ngram Viewer) seems to follow the major World Wars.
https://books.google.com/ngrams/graph?content=shenanigan&year_start=1850&year_end=2000&corpus=15&smoothing=3&share=&direct_url=t1%3B%2Cshenanigan%3B%2Cc0
Maybe Rumpelstiltskin is involved, after all. :)


text:
Q: How can I login to Ubuntu via ssh and automatically sudo su? From my Mac Terminal I can login via ssh to my various Ubuntu servers without entering a password. That's fine. But the work I do in Ubuntu requires me to have root access, so immediately after login I always execute sudo suwhich is an extra step and requires manually entering my password at that point.
What's a good way to avoid that extra step so I login with my user name as I do now, but immediately have the sudo su executed for me (or anything with an equivalent result)?
Thanks.

A: What you are trying to do seems very insecure; essentially you are providing root privs to anyone who logs in as you. However, it can be done.
On the Ubuntu machine that you are ssh'ing into:

*

*Grant yourself passwordless sudo permissions. You can do this for all commands, or you can be a little more secure and define a specific command. First, launch the sudo configuration editor:
$ sudo visudo
Then define what user you want to be able to run the su command without a password. I'll assume your username is doug (based on your stackoverflow handle), and that the server hostname is ubuntubox:
doug ubuntubox = (root) NOPASSWD: /bin/su

Now you should be able to execute this command without a password:
sudo su

*In order for that command to occur immediately upon login, add the command to the very top of your ~/.bash_profile. If you have no such file, create one:

$ touch ~/.bash_profile
$ echo "sudo su -" > ~/.bash_profile

*Log out of your ubuntu server, because bash_profile only gets sourced upon login.

*Log into your server. As soon as your shell opens, it should sudo su you into a root shell.
If ~/.bash_profile isn't getting sourced at login:
$ echo ". $HOME/.bash_profile" >> ~/.bashrc

A: Suggestion: if you're doing this, at least disable password login for SSH, and use keys instead. Otherwise, as others have already observed, your system is a single password away from being wide open. With keys, at least the attacker needs to filch your identity key first.
Securing SSH: in /etc/ssh/sshd_config, set the lines
PermitRootLogin         no
RSAAuthentication       yes
PubkeyAuthentication    yes
PasswordAuthentication  no

To automatically run sudo, you can put the command in your .loginrc or .bashrc file (or .profile if you're running other shells; Ubuntu also has dash in addition to bash. See this article).
# This is my .bashrc. There are many like it, but this is mine.

# You can also set some variables if you ever need them.
#export LC_ALL=en_US.utf-8
#export SVN_EDITOR=/usr/bin/vim
#export VISUAL=/usr/bin/vim

sudo su

Then to also remove the password from su, you need to run visudo on each server and add, say,
Cmnd_Alias  INSECURE_ROOTSHELL   = /bin/su

ubuntu      ALL=(ALL)   NOPASSWD: INSECURE_ROOTSHELL


text:
Q: GDAL raster calculator I have a series of raster data (GeoTIFF) with 5 bands (B / G / R / rededge / NIR).
I would like to calculate different indices by using the gdal raster calculator. I would like to use the batch process at the end.
I don't know what to do, because I can't set the GDAL raster calculator to produce reasonable results.
What's wrong with the following syntax settings:

A: You can try to write the code like below:
gdal_calc.py -A input.tif --A_band=1 -B input.tif --B_band=2 -C input.tif --C_band=3 -D input.tif --D_band=4 --outfile=output.tif --calc="((A-B)/(C+D))"


text:
Q: Command that mentions a user upon join that says who they were invited by? I've been looking around and can not work out how to make command that mentions a user upon join that says who they were invited by.
I've provided a picture with what I'm trying to do; if anyone could help that would be great.

A: There is no direct way to find who invited a specific person.
However there is a way to achieve this by caching the invites and checking which invite use increased when the new user joined. The invite creator will definitely be the inviter!
The Discord.js team provides a very good guide on this at https://github.com/AnIdiotsGuide/discordjs-bot-guide/blob/master/coding-guides/tracking-used-invites.md  :)


text:
Q: Is "to choose" right in this sentence? I've got a sentence from a friend:

There has been an increasing number of people to choose to use cell
  phones in daily life.

Is the sentence grammatically right?
Why is it "to choose" instead of "choosing"?

A: To choose and choosing would mean different things.
Your sentence implies that someone/group can choose from an increasing number of people to make use of cell phones. It carries the sense of to choose from.... So the head of a telecoms company might tell his staff that there are now more people to choose (from) to use cell phones. Although this scenario is unlikely, it's quite grammatical.
Choosing would mean that the people themselves would be making the choice rather than having it made for them by a third party.


text:
Q: Django static file inclusion
Below is my folder structure for django project. The remaining files are working well. When I load the polls app in chrome then I get the message 'going to be affected'. As you can see I have also included a css file to the project and in that css file I am doing nothing but giving normal styling.
p{
    background-color:red;
}

But when I load the app in the browser it is not showing background color as red.
In short there is no effect of the css file.
What I am doing wrong