text:
Q: Possible dijit.Tree Cookie issue (SaveStateCookie) So our app is set up like the standard left frame with the tree, right frame has the main content (loaded from clicking the tree).
Our web app inconsistently displays a blank page in the main frame in Firefox. By inconsistent I mean everyday for a few, rarely for others, never for most. Once we get this, going to any other page through our tree results in a blank page. We found that deleting the "aTreeSaveStateCookie" restores normal operation. "aTree" is the name of our Div. I found "SaveStateCookie" strings in dijit/Tree.js.
This also happens in IE, except I would get a browser error page which I can't recall right now. I would then delete the only cookie I could find for our app (not sure how to do the Firefox steps in IE)
Any ideas on why this would happen?
Thanks
Dojo 1.3 through http://ajax.googleapis.com/ajax/libs/dojo/1.3/dojo/dojo.xd.js
Firefox 3.1x
IE 8
Windows XP
In my case, I don't recall ever changing browser settings around Private Data.

A: Please check to see if the response code is 413 (413 = request entity too large), usually this happens when the cookie(s) used to store the tree(s) expansion state (aTreeSaveStateCookie) exceed(s) the maximum request size for your server
You could try increasing the maximum request size (follow instructions for your specific web app server) or at least display a meaningful error message like "please clear your browser cache" when the 413 error code is encountered

A: If the persist property is set to a truthy value, dijit.Tree is persisting its state to remember which nodes were expanded, and expand them after a page reload. If you need to persist the tree state in presence of a very large data structure, I recommend overriding Tree to use localStorage instead of dojo.cookie.
This is Dojo v. 1.9, but similar changes can be done to the non-AMD version 1.3
_saveExpandedNodes: function(){
   if(this.persist && this.cookieName){
      var ary = [];
      for(var id in this._openedNodes){
         ary.push(id);
      }
      // Was:
      // cookie(this.cookieName, ary.join(","), {expires: 365});
      localStorage.setItem(this.cookieName, ary.join(","));
   }
},

And:
_initState: function(){
   // summary:
   //    Load in which nodes should be opened automatically
   this._openedNodes = {};
   if(this.persist && this.cookieName){
      // Was:
      // var oreo = cookie(this.cookieName);
      var oreo = localStorage.getItem(this.cookieName);
      if(oreo){
         array.forEach(oreo.split(','), function(item){
            this._openedNodes[item] = true;
         }, this);
      }
   }
},


text:
Q: Inserting a combobox in a datagrid in wpf C#
 MainDataContext db = new MainDataContext();
var cat = from p in db.Categories
                      select p;
categoriesComboBox.ItemsSource = cat;
            categoriesComboBox.SelectedValuePath = "ID";
            categoriesComboBox.DisplayMemberPath = "CatName";

XAML
<Custom:DataGridComboBoxColumn
Width="1*"                                  x:Name="categoriesComboBox"
Header="Category"
ItemsSource="{Binding}"
SelectedValueBinding="{Binding Path=Category}"
SelectedValuePath="ID"
DisplayMemberPath="CatName"
/>

Now the thing is i can see the name in the comobox when it loads... when i click on the combobox the dropdown shows me MainDataContext.Category for each and every item...
when i click on any of the drop down items.. its select the correct value and.. showing me in the combobox...

A: You should not set categoriesComboBox.ItemsSource = cat; yourself, try doing it with the data context: categoriesComboBox.DataContext = cat. Anyway, you've got the needed bindings in your XAML.
Hope that this is your actual problem (since I didn't manage to understand what the problem is from your question).

Edit: from your images, you need to specify a DataTemplate for your type MainContext.Category. Without it, the default template is used, which just outputs the string representation.

redpajama_set_name: RedPajamaStackExchange


text:
Q: split array where there are big differences I have an array which gives me a plot like this:

(this image plots the points in my array, and as you can see there are 6 clear zones where the total amount in y is different than the adjacent one.)
What I would like to do is split the array which gave me this plot in different subsets. What I am trying to achieve is count the lengths of this subarrays

A: A simple attempt, you can adjust this for your specific case:
def split_list(list, difference, min_size=None):
    i = 0
    accumulators = [[list[0]]]
    for i in range(1, len(list)):
        if abs(list[i-1] - list[i]) > difference:
            if min_size is not None and len(accumulators[-1]) < min_size:
                continue
            accumulators.append([list[i]])
        else:
            accumulators[-1].append(list[i])

    return accumulators

print(split_list(
    [1,2,3,4,5, 10000, 10001, 10002, 10003, 10005, 60, 64, 67, 100], 100, 4
))

# out: [[1, 2, 3, 4, 5], [10000, 10001, 10002, 10003, 10005], [60, 64, 67, 100]]


text:
Q: How to place a Jquery object to html element and vice-versa I am trying to convert my pure JavaScript code to a jQuery code block as per requirements of my professor. The only thing missing is the below.
When I try to use the "thumbs" variable it does not work while in jQuery format. Any light? Please!
Working...
It is:
$(document).ready(function(){
function displayThumbFound(found){ // for week lab 4
    htmlStrFound = "";
    var thumbs = document.getElementById('thumbnails');
    var count = 0;

    // Print columns content
    for(var i = 0; i < 3; i++){
        // Print lines' content
        for(var j = 0; j < found.length; j++){
            [...]
            }
        thumbs.innerHTML = htmlStrFound;
    }
}
});

NOT Working...
It should be:
$(document).ready(function(){
function displayThumbFound(found){ // for week lab 4
    htmlStrFound = "";
    var thumbs = $('#thumbnails');
    var count = 0;

    // Print columns content
    for(var i = 0; i < 3; i++){
        // Print lines' content
        for(var j = 0; j < found.length; j++){
            [...]
            }
        thumbs.html= htmlStrFound;
    }
}
});

A: You need to change
thumbs.html= htmlStrFound;

to
thumbs.html(htmlStrFound);

A: .html is not a property it is a function
hence use it as
thumbs.html('String');


text:
Q: Sorting file contents numerically by field I am trying to write a BASH script to sort the contents of a file numerically according to a specific field in the file.
The file is under /etc/group. All of the fields are colon-separated :. I have to sort the contents of /etc/group numerically based on the 3rd field.
Example field: daemon:*:1:root
What I'm trying so far:
#!/bin/bash
sort /etc/group -n | cut -f 3-3 -d ":" /etc/group

This is getting me really close, but it only prints out a sorted list of 3rd field values (since cut literally cuts out the rest of the line). I'm trying to keep the rest of the line but still have it sorted by the 3rd field contents.

A: You can use sort -t like this:
sort -t : -nk3 /etc/group

-t : tells sort to use field delimiter as :
-nk3 tells sort to sort data numerically on field #3


text:
Q: Understanding what mono memory is used where I am trying to understand how to use the profiler to inspect c# objects that are not related to the scene. In my application, after parsing a bunch of xml and creating a bunch of objects that persist via a static dictionary, I can see the mono memory value jump up on the profiler. However I cannot seem to see the breakdown of what memory is where, how many instances of objects exists etc. It would seem the profiler only knows about GameObjects and mono behaviours. Is this accurate?

A: if your main concern is to see the memory size of your static dictionary, you can do so by using the profiler class:
public static int GetRuntimeMemorySize(Object o);
http://docs.unity3d.com/ScriptReference/Profiler.GetRuntimeMemorySize.html
you can also use the profiler class functions:
public static void BeginSample(string name, Object targetObject);
public static void EndSample();
to profile a piece of code with a custom label.


text:
Q: Launch smart on FHIR app outside launchpad Requirement: Open smart on FHIR app from out custom website when clicking on button without using any launchpad.
On button click event I tried to call launch url as like "https://localhost:44309/launch?launch=xyz123&iss=https://open-ic.epic.com/Argonaut/api/FHIR/Argonaut"" . But i'm getting error message saying "error=invalid_grant&error_description=Invalid+launch+token&state=45373359". Is this correct way of launching smart on  FHIR app without using LaunchPad? or Is there any way? Please Advice

A:
A user selects an app from outside the EHR, for example by tapping an
  app icon on a mobile phone home screen (or your website). This app will launch from its
  registered URL without a launch id.

In your case this would be launching the app from your website and you can generate the launch parameter value. In this example xyz123
https://app/launch?iss=https%3A%2F%2Fehr%2Ffhir&launch=xyz123

In order to obtain launch context and request authorization to access
  FHIR resources, the app discovers the EHR authorization server's OAuth
  authorize and token endpoint URLs by querying their
  .well-known/smart-configuration.json file.

At this point your app should capture the iss and launch URL parameters and would then fetch the FHIR server's conformance statement, usually /metadata at the end of the FHIR endpoint provided in the iss URL parameter.
https://ehr/fhir/metadata

The app then can declare its launch context requirements by adding
  specific scopes to the request it sends to the EHR's authorization
  server. The authorize endpoint will acquire the context the app needs
  and make it available.

Here you would use the authorize endpoint provided in the /metadata conformance statement as well as the required parameters to request a code.

https://ehr/authorize?response_type=code&client_id=app-client-id&redirect_uri=https%3A%2F%2Fapp%2Fafter-auth&launch=xyz123&scope=launch+patient%2FObservation.read+patient%2FPatient.read+openid+fhirUser&state=98wrghuwuogerg97&aud=https://ehr/fhir

When calling the authorize endpoint I have run into FHIR servers that provide a patient lookup screen to allow a user to select a patient if the scope is requesting patient access.
Now you will need to use the code returned to your redirect URI to send a request to the token endpoint provided in the /metadata conformance statement to retrieve an access token which would be used to authenticate any subsequent FHIR endpoint calls.

https://ehr/token?grant_type=authorization_code&code=123abc&redirect_uri=https%3A%2F%2Fapp%2Fafter-auth

The response here will contain the access code

{
  "access_token": "i8hweunweunweofiwweoijewiwe",
  "token_type": "bearer",
  "expires_in": 3600,
  "scope": "patient/Observation.read patient/Patient.read",
  "intent": "client-ui-name",
  "patient":  "123",
  "encounter": "456"
}

Quotes and examples above are taken from SMART App Launch Framework on HL7.org website

A: What you are trying to do is the standalone launch, but you are confusing it with EHR Launch.
You don't need to provide the iss and launch query params when launching your SMART app from your website.

Apps using the standalone launch flow won't have a launch id at this point. These apps can declare launch context requirements by adding specific scopes to the authorization request: for example, launch/patient to indicate that the app needs a patient ID, or launch/encounter to indicate it needs an encounter. The EHR's "authorize" endpoint will take care of acquiring the context it needs (making it available to the app).
For example, if your app needs patient context, the EHR may provide the end-user with a patient selection widget.

You may refer to the Standalone Launch Sequence.


text:
Q: MSAL / AAD gives "Are you trying to sign in to [AppName]" message when using different (Edge-like) user-agent string We have a windows application that uses MSAL.NET AcquireTokenInteractive.  We've registered the application in Azure to get a token for use with EWS.  Everything works fine, and the user will not see any prompts, just a flash as the MSAL window will open and close quickly - presuming the Azure admin authorized the app, and the user is logged in or has a valid cached token.
We have a user-agent override setting for our application, and we applied the override to MSAL, and when we pass a different user-agent string (for example, to mimic Edge), everything still works EXCEPT the user does get a prompt -- in the MSAL window it will say "Are you trying to sign in to [app name]?  Only continue if you downloaded the app from a store or website that you trust.  Cancel / Continue "  We suspect this prompt is coming from AAD.
Does anyone know why changing the user-agent string in MSAL would cause this kind of prompt?


text:
Q: split a double into parts - matlab I have a date vector in form
20140117
20130325
20130530
etc.
There are 5,000,000 lines in the double vector.
How can I transfer it to a datevector recognized by matlab?
I don't like changing it to string and putting the parts in separately. It takes too long!
Please Help!

A: a combination of fix and mod let's you extract the digits you want:
%Matrix Columns YY,MM,DD,hh,mm,ss
[mod(fix(x/10000),100000),mod(fix(x/100),100),mod(x,100),zeros(size(x,1),3)]
%datenum
datenum(mod(fix(x/10000),10000),mod(fix(x/100),100),mod(x,100))

A: If you really want to avoid casting to string then back to number then you can use this method:
D = [20140117; 20130325; 20130530];

YY = fix( D./10000 ) ;
MM = fix( (D-YY.*10000) /100 ) ;
DD = fix( (D-YY.*10000-MM.*100 ) );

DateInMatlabformat = datenum( YY , MM , DD ) ;

You can package that in a one liner if you want, but basically what it does is:

*

*Divide by 10000 to get the year in the variable YY

*Remove this part from your original date ((D-YY.*10000)), then divide by 100 to get the month.

*remove all of that, you obtain the day.

The last line merge all of that in a Matlab standard time serial format. Read the doc on datenum and datestr for more information.


text:
Q: three c# concurrent queue's - how can I pause them while a particular action needs to happen? I have a question, and I could do with some code examples to help me, and I feel it may help to give some background.
I have the need to create an engine of 3 Queues (in C#, winforms). The 3 Queues merely contain an "action" object. Actions get thrown into the engine, and stick themselves to the "most available" Queue (basically, the Queue with the lowest count). Almost all of the time the Queues can run discretely and asynchronously with no harm. However there is one "Action" situation which may happen, and when that type of "Action" occurs and does bubble to the front of a Queue, it must :

*

*wait for the other queues to stop their current actions

*lock/pause them when they are finished on their current Action

*run the Action alone until it finishes

*release the lock on the other 2 queues.

With the added issue that any of the 3 queues can lock the other 2.
Does anyone have any experience of this?
I hope so, it seems a bit painful :-) Thanks in advance

A: First off, I wouldn't suggest using three queues.  I'd suggest using one queue and just have 3 different tasks reading from it.  I'd also suggest using BlockingCollection<T> (which is just a wrapper for a ConcurrentQueue as it's easier to work with.
As for the rest, a ReaderWriterLockSlim (Thanks Casperah) should handle it easy enough.  A Writer requires an exclusive lock, and a reader only locks out other writers, which is exactly your use case.
var queue = new BlockingCollection<Action>();

int numWorkers = 3;
ReaderWriterLockSlim throttler = new ReaderWriterLockSlim();

for (int i = 0; i < numWorkers; i++)
{
    Task.Factory.StartNew(() =>
    {
        foreach (Action nextAction in queue.GetConsumingEnumerable())
        {
            if (mustBeExectutedSerially(nextAction))
            {
                try
                {
                    throttler.EnterWriteLock();
                    nextAction();
                }
                finally
                {
                    throttler.ExitWriteLock();
                }
            }
            else
            {
                try
                {
                    throttler.EnterReadLock();
                    nextAction();
                }
                finally
                {
                    throttler.ExitReadLock();
                }
            }
        }
    });
}

A: This is a combination of the single queue approach recommended by Servy and the ReaderWriterLock suggestion by Casperah.
ReaderWriterLockSlim throttler = new ReaderWriterLockSlim();
for (int i = 0; i < numWorkers; i++)
{
    Task.Factory.StartNew(() =>
    {
        foreach (Action nextAction in queue.GetConsumingEnumerable())
        {
            if (mustBeExectutedSerially(nextAction))
            {
                try
                {
                    throttler.EnterWriteLock();
                    nextAction();
                }
                finally
                {
                    throttler.ExitWriteLock();
                }
            }
            else
            {
                try
                {
                    throttler.EnterReadLock();
                    nextAction();
                }
                finally
                {
                    throttler.ExitReadLock();
                }
            }
        }
    });
}

A: It seems that a  System.Threading.ReaderWriterLock will do the job for you.
A normal task should do this:
readerWriterLock.AcquireReaderLock(timeout);
try
{
    RunNormalAction();
}
finally
{
     readerWriterLock.ReleaseReaderLock();
}

And the advanced task should do this:
readerWriterLock.AcquireWriterLock(timeout);
try
{
    RunSpecialAction();
}
finally
{
     readerWriterLock.ReleaseWriterLock();
}

You can start as many ReaderLocks as you want, and they will keep running as expected.
When a WriterLock is Acquired all the ReaderLocks has been released and only one WriterLock will run at a time.

A: My humble sugestion:
Create three objects
object threadlock1 = new object();
object threadlock2 = new object();
object threadlock3 = new object();

Each thread acquires lock over one object before running any action.
lock (threadlock1)  // On thread 1, for example
{ //Run Action }

When THE action comes, the thread with THE action must acquire lock over the three objects, thus waiting for the other threads to finish their work, and preventing them from doing any more.
lock (threadlock1)  // On thread 1, for example
{
 lock (threadlock2)
 {
  lock (threadlock3)
  {
    //Run THE Action
  }
 }
}

When THE action is finished, you release all three locks, and all is back to normal, with each thread holding it's own lock, and resuming actions.


text:
Q: Create a buffer for polygons that meet a condition with QGIS I have a layer with polygons, and I want to make a buffer but only for the ones that meet a condition ("MUNICIPIO"=5). When I make a fixed distance buffer, it makes a buffer for all the polygons in the layer. Is there a way to make a buffer only for the polygons I want?

A: Use Select by Expression from the attribute table to select polygons of "MUNICIPIO"=5 and use Fixed Distance Buffer for the selected polygons.
Use Fixed Distance Buffer from SAGA tools which you can find it from Processing toolbox -> SAGA -> Vector General tools -> Fixed Distance Buffer. It should work.
Make sure that Use only selected features option is checked from the Processing Option. It should be checked by default.

A: For this you can use a Virtual Layer.
Choose Add/Edit Virtual Layer in the Manage Layers Toolbar, import your layer and use a query like:
SELECT ST_Buffer(geometry, 100) FROM your_layer WHERE MUNICIPIO=5


text:
Q: Contact form from ubuntu to Zoho email address I would like some support in order to get my Postfix configuration working with my Zoho email account. What I am trying to do is to send a message from my contact form in http://www.g3eo.com/#!/page_Contacts to my Zoho email account. For that I configured Postfix in my ubuntu box in this way (based on http://emanuelesantanche.com/configuring-postfix-to-relay-email-through-zoho-mail/):

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
      biff = no
append_dot_mydomain = no

readme_directory = no

mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = loopback-only
inet_protocols = all

# TLS parameters
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_header_checks = pcre:/etc/postfix/smtp_header_checks

myhostname = xxxxxxxxxx
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = xxxxxxxxxx, localhost.com, localhost
relayhost = smtp.zoho.com:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/password
#smtp_sasl_security_options =
smtp_generic_maps = hash:/etc/postfix/generic
smtp_sasl_security_options = noanonymous
smtp_always_send_ehlo = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks,permit_sasl_authenticated,defer_unauth_destination

In my website contact form things seem to be working fine, you can test it by sending a message with the Firebug open (press F12) in the Network tab. After sending the email it appears this message "mail sent" in the response tab. However, that message does not reach my email address in my Zoho email account. After checking the /var/log/mail.log it shows:

Jul 4 21:46:42 xxxxxxxxxx postfix/qmgr[9100]: D9B2E5E0292:
  from=, size=549, nrcpt=1 (queue active)
Jul 4 21:46:45 xxxxxxxxxx postfix/smtp[27824]: D9B2E5E0292: to=, relay=smtp.zoho.com[165.254.168.48]:587, delay=114224,
  delays=114222/0.01/2.6/0, dsn=4.0.0, status=deferred (SASL authentication failed; server smtp.zoho.com[165.254.168.48] said: 535 Authentication Failed)

I understand that the authentication problem is because my message could get into the Zoho smtp server, so it was rejected, not sure if it is the case. I would appreciate if someone could help to understand what is going on here and how to fix it.
My contact form uses the following files:
- http://www.g3eo.com/extras/js/forms.js
and http://www.g3eo.com/extras/bin/MailHandler.php (see below)

  if($_POST['name']!='nope'){
      $messageBody .= '
Visitor: ' . $_POST["name"] . '
' . "\n";
      $messageBody .= '
' . "\n";
  }
  if($_POST['email']!='nope'){
      $messageBody .= '
Email Address: ' . $_POST['email'] . '
' . "\n";
      $messageBody .= '
' . "\n";
  }else{
      $headers = '';
  }
  if($_POST['state']!='nope'){
      $messageBody .= '
State: ' . $_POST['state'] . '
' . "\n";
      $messageBody .= '
' . "\n";
  }
  if($_POST['phone']!='nope'){
      $messageBody .= '
Phone Number: ' . $_POST['phone'] . '
' . "\n";
      $messageBody .= '
' . "\n";
  }
  if($_POST['fax']!='nope'){
      $messageBody .= '
Fax Number: ' . $_POST['fax'] . '
' . "\n";
      $messageBody .= '
' . "\n";
  }
  if($_POST['message']!='nope'){
      $messageBody .= '
Message: ' . $_POST['message'] . '
' . "\n";
  }

  if($_POST["stripHTML"] == 'true'){
      $messageBody = strip_tags($messageBody);
  }

  try{
      if(!mail($owner_email, $subject, $messageBody, $headers)){
          throw new Exception('mail failed');
      }else{
          echo 'mail sent';
      }
  }catch(Exception $e){
      echo $e->getMessage() ."\n";
  }

EDIT#1:
after changing /etc/postfix/password from smtp.zoho.com:587 to [smtp.zoho.com] I receiced in /var/log/mail.log:

Jul 4 23:46:24 xxxxxxxxxx postfix/pickup[2926]: 8BC545E0261:
  uid=33 from=
       Jul 4 23:46:24 xxxxxxxxxx postfix/cleanup[2933]: 8BC545E0261:
  message-id=<20160705044624.8BC545E0261@xxxxxxxxxx>
Jul 4 23:46:24 xxxxxxxxxx postfix/qmgr[2927]: 8BC545E0261:
  from=, size=588, nrcpt=1 (queue active)
Jul 4 23:46:26 xxxxxxxxxx postfix/smtp[2930]: 8BC545E0261:
  to=, relay=smtp.zoho.com[165.254.168.48]:587,
  delay=2.1, delays=0.13/0/1.8/0.16, dsn=5.5.1, status=bounced (host
  smtp.zoho.com[165.254.168.48] said: 530 5.5.1 Authentication Required.
  (in reply to MAIL FROM command))
Jul 4 23:46:27 xxxxxxxxxx postfix/cleanup[2933]: 098835E026E:
  message-id=<20160705044627.098835E026E@xxxxxxxxxx>
Jul 4 23:46:27 xxxxxxxxxx postfix/bounce[2932]: 8BC545E0261:
  sender non-delivery notification: 098835E026E
Jul 4 23:46:27 xxxxxxxxxx postfix/qmgr[2927]: 098835E026E:
  from=<>, size=2494, nrcpt=1 (queue active)
Jul 4 23:46:27 xxxxxxxxxx postfix/qmgr[2927]: 8BC545E0261:
  removed
Jul 4 23:46:27 xxxxxxxxxx postfix/local[2934]: 098835E026E:
  to=, relay=local, delay=0.09,
  delays=0.05/0/0/0.04, dsn=2.0.0, status=sent (delivered to mailbox)
Jul 4 23:46:27 xxxxxxxxxx postfix/qmgr[2927]: 098835E026E:
  removed

is 587 the problem here?

A: Solved!, here the solution:
I had in /etc/postfix/smtp_header_checks:
/^From:.*/ REPLACE From: LOCALHOST System <info@g3eo.com>;

and now I have:
/^From:.*/ REPLACE From:info@g3eo.com

check that I had to delete the semi-colon at the end as well as the whole "LOCALHOST SYTEM" plus blank spaces, and that was it!! hope this helps someone else out there, cheers!


text:
Q: Fortran matrix with different data types or mixed precision according to different columns (or rows) In short, what I want is:
custom_2d_matrix(n, m) where 1..x are arrays of integers with size n and x+1..m are arrays of real numbers with size m. (1 <= x <= m)

For example, I want to create a custom type, which is a mixed precision matrix, or you can call it a matrix with different data types.

*

*The custom_2d_matrix has n rows and m columns.

*Column number from 1 to x are column vectors with integer data type.

*Column number from x to m are column vectors with real data type.

*Note that 1 <= x <= m

*The custom_2d_matrix must be accessible through index only. For example, custom_2d_matrix(i, j) will bring up the i-th array (can be either integer array or real array) and then the j-th element in the said array. So for this reason, derived type is not good enough.


text:
Q: Sigma algebra generated by the stopped process. Let $(X_n)_{n \geq 0}$ be a sequence of random variables. Let $\mathcal{F}_n = \sigma (X_0, \dots, X_n)$ be a filtration and $T$ is a $(\mathcal{F}_n)_{n\geq 0}$-stopping time. I want to understand whether $$\sigma (X_{n \wedge T}, n \geq 0) =^? \sigma \left( \mathcal{F}_{n \wedge T}, n \geq 0 \right).$$ My intuition tells me that   $\sigma \left( \mathcal{F}_{n \wedge T}, n \geq 0 \right)$ must be larger, but I can't find an example showing it.

A: Yes, the two $\sigma$-algebras coincide.
For any discrete stopping time $\tau: \Omega \to \mathbb{N}_0$ the random variable $X_{\tau}$ is $\mathcal{F}_{\tau}$-measurable, and this implies that
$$\sigma(X_{n \wedge T}; n \geq 0) \subseteq \sigma(\mathcal{F}_{n \wedge T}; n \geq 0).$$
Moreover, we have $\mathcal{F}_{n \wedge T} \subseteq \mathcal{F}_T$ (as $ T \wedge n \leq T$), and therefore
$$\sigma(X_{n \wedge T}; n \geq 0) \subseteq \sigma(\mathcal{F}_{n \wedge T}; n \geq 0) \subseteq \mathcal{F}_T.$$
Consequently, we are done if we can show that
$$\mathcal{F}_T \subseteq \sigma(X_{n \wedge T}; n \geq 0).\tag{1}$$
Let $A \in \mathcal{F}_T$. We show by induction that $$\forall k \geq 0: \quad A \cap \{T = k\} \in \sigma(X_{n \wedge T}; n \geq 0). $$

*

*$k=0$: $$A \cap \{T=0\} \in \mathcal{F}_0 = \sigma(X_0) = \sigma(X_{0 \wedge T}) \subseteq \sigma(X_{n \wedge T}; n \geq 0)$$

*$k-1 \to k$: We have $A \cap \{T =k\} \in \mathcal{F}_k$, and therefore there exists by the factorization lemma a Borel measurable function $f$ such that $$1_{A \cap \{T=k\}} = f(X_1,\ldots,X_k).$$ As $1_{\{T =k\}} = 1_{\{T=k\}} 1_{\{T \geq k\}}$ we find $$1_{A \cap \{T=k\}} = f(X_1,\ldots,X_k) 1_{\{T \geq k\}} = f(X_{1 \wedge T},\ldots,X_{k \wedge T}) 1_{\{T \geq k\}}. \tag{2}$$ Because of the induction hypothesis, we have $$\{T \geq k\} = \{T \leq k-1\}^c \in \sigma(X_{n \wedge T}; n \geq 0),$$ and therefore it follows from $(2)$ that $1_{A \cap \{T=k\}}$ is $\sigma(X_{n \wedge T}; n \geq 0)$-measurable; this is equivalent to $A \cap \{T =k\} \in \sigma(X_{n \wedge T}; n \geq 0)$.


text:
Q: How to play video using json web service data in iOS I using the below code to play video file using web service,but it is not work.please correct the code to play video.
NSBundle *bundle = [NSBundle mainBundle];
NSString *url = [NSString stringWithFormat:@"http://tnhd.in/load/2014/Anjaan/Oru%20Kan%20Jaadai%20BRrip%20-%20Anjaan%20HD.mp4"];
NSString *moviePath = [bundle pathForResource:url ofType:@"mp4"];
NSURL *movieURL = [NSURL fileURLWithPath:moviePath];

moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
moviePlayer.view.transform = CGAffineTransformConcat(moviePlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2));
UIWindow *backgroundWindow = [[UIApplication sharedApplication] keyWindow];
[moviePlayer.view setFrame:backgroundWindow.frame];
[backgroundWindow addSubview:moviePlayer.view];
[moviePlayer play];

A: Just make the url like so:
NSString *path = @"http://tnhd.in/load/2014/Anjaan/Oru%20Kan%20Jaadai%20BRrip%20-%20Anjaan%20HD.mp4";
NSURL *url = [NSURL URLWithString:path];

Or better so:
NSURL *url = [NSURL URLWithString:@"http://tnhd.in/load/2014/Anjaan/Oru%20Kan%20Jaadai%20BRrip%20-%20Anjaan%20HD.mp4"];

and send it to your player


text:
Q: Adding a border to a Google PlaceAutocompleteFragment I am using a Google Places Autocomplete fragment in an Android app.  When I use the fragment directly in the top level of a LinearLayout, everything works:
<LinearLayout ...>
    <fragment
        android:id="@+id/findRidePlaceAutocompleteFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"/>
</LinearLayout>

This layout leads to this UI:

As you can see, there is no border around the widget, whereas the TextView below it has a black border.  From what I read, one trick to get a border around a fragment is to embed that fragment within a CardView.  This method is actually recommended by Google's official documentation.  Consider the following modified layout:
<LinearLayout ...>
    <android.support.v7.widget.CardView
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:id="@+id/card_view"
        android:layout_gravity="left"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/main_border">

        <fragment
            android:id="@+id/findRidePlaceAutocompleteFragment"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"/>
    </android.support.v7.widget.CardView>
</LinearLayout>

The trick here is to give the CardView a background with the Google Places fragment above it, such that the former will appear as a border around the latter.
But this modified layout causes the app to crash.  Does anyone know why this is crashing, or how I might place a border around a Google PlaceAutocompleteFragment ?

A: You can set a custom background for the enclosing LinearLayout:
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/main_border">
    <fragment
        android:id="@+id/findRidePlaceAutocompleteFragment"
        android:name="com.google.android.gms.location.places.ui.PlaceAutocompleteFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
</LinearLayout>

I'm using the same android:background="@drawable/main_border" that you have defined for your CardView. In my case main_border.xml (which lives on the res/drawable folder) looks like this:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
    <solid android:color="#ffffff" />
    <stroke android:width="1dip" android:color="#000000"/>
</shape>


text:
Q: Proof regarding the genus of a topological space Intuitively, I would think that if there exists a continuous mapping $f:X\rightarrow Y$ between 2 topological spaces $X$ and $Y$, then the genus of $Y$ must be smaller that the Genus of $X$ (as during the mapping, holes in $X$ can be eliminated but no new holes may be made). However, I am finding it difficult to prove this formally. I was thinking of using the transformation of loops in $X$ to $Y$ by applying $f$, but I cannot continue from this. As such, how can one prove this formally?

A: This is not true. An easy and concrete counterexample would be the quotient map (which is also the universal covering map)
$f\colon \mathbb{R}^2\to \mathbb{R}^2/\mathbb{Z}^2 \cong T$ to the torus, where we identify $(x,y)\sim(\tilde x,\tilde y)$ iff $x-\tilde x \in \mathbb Z$ and $y-\tilde y \in \mathbb Z$.
This yields a continous surjective map, which is locally even a homeomorphism. But the genus of $\mathbb R^2$ is $0$, where the genus of the torus $T$ is $1$.


text:
Q: Aws Boto3 Client (Low level) vs Resource (High Level) I'm working on some automation using AWS Boto3 SDK. I Couldn't get to know what is the difference between the Client(low-level) and Resource(high-level)
What is the difference between Low-Level(Client) and High-Level(Resource) here?

A: The references made here, as per my understanding is towards low-level and high-level interfaces used in API programming. Here it goes,
high-level interface, are designed to enable the programmer to write code in shorter amount of time and to be less involved with the details of the software module or hardware device that is performing the required services. Which is in direct contrast with the other one.

low-level interface, are more detailed allowing the programmer to manipulate functions within a software module or within hardware at very granular level.

In AWS, when you use Boto3 for API programming, Clients provide the low-level interface as closely with service APIs. Which means, all service operations will be supported by clients.Whereas, the Resources provide a hig-level interface which means differently than the raw low-level calls provided by Clients.

A: *

*Clients provide a low-level interface to the AWS service. Their definitions are generated by a JSON service description present in the botocore library. The botocore package is shared between boto3 as well as the AWS CLI.
Retrieve the list of existing buckets
s3 = boto3.client("s3")
response = s3.list_buckets()
Output the bucket names
print("Existing buckets:")
for bucket in response['Buckets']:
print(f'{bucket["Name"]}')

*Resources are a higher-level abstraction compared to clients. They are generated from a JSON resource description that is present in the boto library itself. E.g. this is the resource definition for S3.
Resources provide an object-oriented interface for interacting with various AWS services. Resources can be instantiated like the following:
# S3 bucket identifier
s3 = boto3.resource("s3")
bucket = s3.Bucket(name="my_bucket")

To summarize, resources are higher-level abstractions of AWS services compared to clients. Resources are the recommended pattern to use boto3 as you don't have to worry about a lot of the underlying details when interacting with AWS services. As a result, code written with Resources tends to be simpler.
However, Resources aren't available for all AWS services. In such cases, there is no other choice but to use a Client instead.


text:
Q: ASP.NET MVC C# change code from accessing a mySQL database to a MSSQL database I have an application that I used to connect to a mySQL database.  I have installed the MySQL.Data package and I use this code to build my connection:
services.AddScoped<System.Data.IDbConnection>((s) =>
        {
            IDbConnection conn = new MySqlConnection(Configuration.GetConnectionString("databasename"));
            conn.Open();
            return conn;
        });

This works fine as I am able to read/write data from the database.
Now, I need to have the same application access a MS SQL database.  The tables are all the same and the fields on each table are the same as well.  I am having a hard time finding what I should change my code to (or what package I should include).  When I remove the MySQL.Data package, the MySqlConnection function becomes invalid (as would be expected).
Any idea what package to include and what function to use to establish the connection?
Any assistance is greatly appreciated.
Thank you!
EDIT #1
I found an old stackoverflow post (I should have referenced it here but I closed the window) that talks about this very issue.  The suggestion was to add
using System.Data.SqlClient;

and then change the assignment code to
IDbConnection conn = new SqlConnection(Configuration.GetConnectionString("databasename"));

I made these changes and now I get this error within the code:

Im at a loss as to how to resolve this.  I verified that my project is in framework .NET core 3.1

A: Not sure about size of your project and detailed requirements but I would suggest to use libraries like:
Entity Framework - no SQL knowledge needed, can connect to any Db technology, almost no code changes required when switching between Db providers
or
Dapper - fast lightweight also supports multiple Db providers but you need to write correct SQL commands yourself specific for each Db technology you use


text:
Q: cast CFTypeRef to Boolean in objective c++ I want to convert an objective c code to objective cpp and use it in my application. Given the following code:
        CFTypeRef dynamicValue = (__bridge CFTypeRef)([[NSBundle bundleWithPath:aStr] objectForInfoDictionaryKey: @"CFPlugInDynamicRegistration"]);

        BOOL removeFlag = NO;

        if(dynamicValue == nil)
        {
            removeFlag = NO;
        }
        else if( CFGetTypeID(dynamicValue) == CFBooleanGetTypeID()  )
        {
            removeFlag = CFBooleanGetValue(dynamicValue);
        }
        else if( CFGetTypeID(dynamicValue) == CFStringGetTypeID()  )
        {
            removeFlag = ( [[(__bridge NSString*)dynamicValue lowercaseString] isEqualToString:@"yes"] ? YES:NO);
        }

        if( removeFlag )
        {
            [unloadedArray addObject:aStr];
            [sortedArray removeObjectAtIndex:hoge];
        }

I get an error when changing the file name from file.m to file.mm and  building: "no matching function for call to 'CFBooleanGetValue'"
I tried to #include <CoreFoundation/CFNumber.h> but I get the same error (I guess it's an ifdef issue).
Do you know any way I can cast without the missing function? Should I try to use the same function anyway?

A: Objective-C++ doesn't have automatic framework linking.
You need #include <CoreFoundation/CoreFoundation.h> and manually link CoreFoundation framework.

A: you can use this CFNumberGetTypeID()
 NSString *aStr = @"";

    CFTypeRef dynamicValue = (__bridge CFTypeRef)([[NSBundle bundleWithPath:aStr] objectForInfoDictionaryKey: @"CFPlugInDynamicRegistration"]);

    BOOL removeFlag = NO;

    if(dynamicValue == nil)
    {
        removeFlag = NO;
    }
    else if( CFGetTypeID(dynamicValue) == CFNumberGetTypeID()  )
    {
        removeFlag = [(__bridge NSNumber *)dynamicValue boolValue];
    }
    else if( CFGetTypeID(dynamicValue) == CFStringGetTypeID()  )
    {
        removeFlag = ( [[(__bridge NSString*)dynamicValue lowercaseString] isEqualToString:@"yes"] ? YES:NO);
    }

    if( removeFlag )
    {
        [unloadedArray addObject:aStr];
        [sortedArray removeObjectAtIndex:hoge];
    }

A: In C++ a conversion from a void *  (here: CFTypeRef) to a
pointer of a different type (here: CFBooleanRef aka __CFBoolean *) requires an explicit
cast. So this would solve the issue:
removeFlag = CFBooleanGetValue(static_cast<CFBooleanRef>(dynamicValue));

But actually I would forget about the CF types and bridging, and change the code to
id dynamicValue = [[NSBundle bundleWithPath:@"path"] objectForInfoDictionaryKey: @"CFPlugInDynamicRegistration"];
BOOL removeFlag = NO;
if ([dynamicValue isKindOfClass:[NSNumber class]]) {
    removeFlag = ((NSNumber *)dynamicValue).boolValue;
} else if ([dynamicValue isKindOfClass:[NSString class]]) {
    removeFlag = [((NSString *)dynamicValue).lowercaseString isEqualToString:@"yes"];
}

This compiles in Objective-C and Objective-C++.


text:
Q: Navigation doesn't look right in IE (CSS problem?) Can somebody tell me why the navigation (about, snow areas, condition alerts) doesn't work in IE?
http://snow.solspot.com/conditions/north-america/us-east/vermont/okemo/
I have been trying to fix this for days now...
Thanks!

A: On your <a id="dd1" style="width: 170px;"> this inline style is creating the huge gap between the elements. I removed this in IE8's developer tools and it looked similar to how it appears in Chrome.
Remove this width from the inline style on each of the links.:)

A: Are you aware of this error on IE?
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR
2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.2) Timestamp: Wed, 19 Jan 2011 04:52:03 UTC

Message: 'this.tabs[...]' is null or not an object Line: 26 Char: 4 Code: 0 URI: http://snow.solspot.com/wp-content/themes/solspot_snow/js/mootools-tabs.js

Message: Object doesn't support this property or method Line: 3086 Char: 3 Code: 0 URI: http://snow.solspot.com/wp-content/themes/solspot_snow/js/mootools-1.2.4-core.js

Message: Object expected
Line: 61
Char: 1
Code: 0
URI: http://snow.solspot.com/

Please check. Maybe it will point you to the right direction on how to fix it.


text:
Q: How can I make ADB behave like real deeplink? I can verify my deeplink if it is properly verified. I can use
adb shell pm get-app-links --user cur <package name>

Which provides various data. But to be fully ascertained, I want to try deeplink and see it works (go directly into the app without asking).
However, I notice when I use adb as below,
adb shell am start -d https://www.airbnb.co.uk/rooms/48033927

It will always prompt which App to use (eg shown below), both for deeplink url that is successful verified or not

I can't find any way to deeplink using adb to behave like actual deeplink from a URL clicked.
I mean I want to find an adb command when triggered (that behave like normal deeplink)

*

*it will deeplink without need to ask for which app to open if the url has been verified, or

*reject and go to browser if it is not verified, even if it is in the manifest.

Is there any parameter I can give to adb to emulate the actual deeplink behavior?

A: Looks like I'll have to add -a android.intent.action.VIEW
e.g.
adb shell am start -a android.intent.action.VIEW -d https://www.airbnb.co.uk/rooms/48033927


text:
Q: Adjust navbar based on the number of menus inside Very new to CakePHP, trying to make a navbar that adjust itself based on the number of menu it has.
To elaborate here's an image:

The navbar changes dynamically based on the person who is logged in. For example, When person A logs in the navbar has 6 menus, when person B logs in it has 4 menus, same for person C when he logs in.
How can I do this? Not familiar with the term that's why my research could have been inadequate, but so far a friend told me that it could be done with CSS and jQuery.

A: A good way to do this is using display: table and width: 100% for the menu, and display: table-cell for the menu items. This will make the items be displayed horizontally.
Then you should use javascript (or in you case, jQuery) to set the items width.
I made a fiddle where I show a simple solution: http://jsfiddle.net/8Qh8h/


text:
Q: Conditional formatting of footline, depending on whether footnotes are present I know this question has been asked in a similar fashion before, but I have not seen an elegant solution using \addtobeamertemplate yet. I am using the beautiful metropolis style, in which the footline contains only the slide number in the very right corner. This leaves a lot of white space at the bottom. For most slides that is fine, but it looks a bit odd if I add the source of a data set into the footnote.

I would like to shift the footnote vertically. If I have a single footnote per slide, this can be accomplished very simply with the code:
\addtobeamertemplate{footnote}{}{\vskip-7mm}

Of couse it doesn't work for multiple footnotes on the same slide since the negative space is added for each footnote. I thought it should be simple enough to add negative space to the beginning of the footline template using a global counter that is set to 1, whenever a footnote is added, and then set to 0 at the end of the slide. To my surprise, however, the following did not work:
\documentclass{beamer}
\usetheme[outer/progressbar=foot]{metropolis}

\newcount\footinput
\global\footinput 0\relax

\addtobeamertemplate{footnote}{}{\global\footinput 1\relax}

\addtobeamertemplate{footline}{%
\ifnum\footinput>0%
  \vskip-7mm%
  \global\footinput 0\relax%
\fi%
}{}

\begin{document}

\begin{frame}
\frametitle{Important Findings}

\begin{enumerate}
\item Description of data set 1\footnote{Source of data set 1}
\item Description of data set 2\footnote{Source of data set 2}
\end{enumerate}
\end{frame}

\end{document}

What am I missing? The reason why I am surprised is that the \footnoterule is essentially defined in the same way in beamerbaseframesize.sty (using boxes instead of a counter).

A: Is this what you're looking for?
\documentclass{beamer}
\usetheme[outer/progressbar=foot]{metropolis}

\newcount\footinput
\global\footinput 0\relax

\addtobeamertemplate{footnote}{}{\global\footinput 1\relax}

\setbeamertemplate{footline}{\vspace{6.7pt}}
\setbeamertemplate{logo}{%
\usebeamercolor[fg]{footline}%
\usebeamerfont{page number in head/foot}%
\vspace{-7pt}
\usebeamertemplate*{frame numbering}\hspace{5pt}%
}

\begin{document}

\begin{frame}
\frametitle{Important Findings}

\begin{enumerate}
\item Description of data set 1\footnote{Source of data set 1}
\item Description of data set 2%\footnote{Source of data set 2}
\end{enumerate}
\end{frame}

\begin{frame}
\frametitle{Important Findings}

\begin{enumerate}
\item Description of data set 1\footnote{Source of data set 1}
\item Description of data set 2\footnote{Source of data set 2}
\end{enumerate}
\end{frame}

\end{document}


text:
Q: Center a absolute positioned div vertical? I have this:

.ce_text.forward {
position: relative;
overflow: hidden;
padding: 20px;
background-color: #F8F8F8;
color: #2d353c;
}
.ce_text.forward p {
position: relative;
}
.ce_text.forward .fill_bottom {
width: 500px;
height: 500px;
bottom: 0;
left: -865px;
position: absolute;
margin: auto;
background-color: #ecedee;
top: 0px;
right: 0;
transition: left 0.3s linear 0s;
transform: rotate(45deg);
}
.ce_text.forward:hover .fill_bottom {
left: 0;
}

HeadlineTest Test test testLesen Sie mehr

It works in chrome but not in firefox, can some one help me with the css?
Fiddle

A: The problem in Firefox seems to be caused by the usage of margin: auto. I have completely re-built your example to eliminate this.
New and Improved

*

*No fixed height. Height is controlled by a percentage (which can be modified) and a min-height.

*No extra markup. The triangle is created with a pseudo element and rotated. The text is centered with its  wrapper.

*Centered triangle. The triangle is centered at any height with bottom: 50% and a negative bottom margin of half its height.

*No gaps - The triangle is large enough to eliminate any spacing in the corners. If you need it to be even larger, it can be as large as required; just keep the height to width ratio 1:1 and increase the size of the negative bottom margin.

* {
    margin: 0;
    padding: 0;
}
html, body {
    height: 100%;
}
h1 {
    background: #333;
    height: 40%;
    min-height: 140px;
    position: relative;
    overflow: hidden;
    z-index: 0;
}
h1 a {
    display: block;
    height: 100%;
    position: absolute;
    top: 50%;
    margin-top: -0.56em;
    left: 100px;
}
h1:before {
    content:'';
    display: block;
    position: absolute;
    bottom: 50%;
    margin-bottom: -1000px;
    left: -2000px;
    height: 2000px;
    width: 2000px;
    background: #F00;
    transform: rotate(45deg);
    transition: left 0.3s;
    z-index: -1;
}
h1:hover:before {
    left: 0;
}

Text

Old Solution
Archived - fixed height option (no transform, should work back to IE8)
I have approached this differently:

*

*The right triangle and the bar are made with pseudo elements and are positioned with percentages

*z-index: -1 keeps the pseudo elements behind the text.

*overflow: hidden prevents the scroll bar when the triangle is pushed outside.

* {
 margin: 0;
 padding: 0;
}

.headline {
 height: 100px;
 background: #333;
 color: #FFF;
 position: relative;
 z-index: 2;
 display: inline-block;
 width: 100%;
 height: 0;
 padding: 30px 0 70px 50px;
        overflow: hidden;
}
.headline:before {
 width: 30%;
 content:'';
 display: block;
 height: 100px;
 background: #F00;
 position: absolute;
 top:0;
 left: 0;
 transition: all 0.3s linear 0s;
 z-index: -1;
}
.headline:after {
 content: '';
 display: block;
 border-bottom: solid 50px transparent;
 border-top: solid 50px transparent;
 border-left: solid 50px #F00;
 height: 0;
 width: 0;
 left: 30%;
 position: absolute;
 top:0;
 transition: all 0.3s linear 0s;
 z-index: -1;
}
.headline:hover:before {
 width: 100%;
}
.headline:hover:after {
 left: 100%;
}

Text


text:
Q: Best way of calling a long running process asynchronously in .net core web api I am trying to call a long running task from web api like this
    [HttpGet]
    public async Task<IActionResult> Get()
    {
        await Task.Run(()=>_report.TestFunctionAsync());

        return Accepted();

    }

And this is the task
    public async Task TestFunctionAsync()
    {
        ProcessStatus = 0;
        Task.Delay(TimeSpan.FromSeconds(30));
        ProcessStatus = 1;//wrting to DB
        Task.Delay(TimeSpan.FromSeconds(10));
        ProcessStatus = 2;//Fetching from Excel
        Task.Delay(TimeSpan.FromSeconds(20));
        ProcessStatus = 3;//Processing
        Task.Delay(TimeSpan.FromSeconds(50));
        ProcessStatus = 9;//Finished
    }

But when googling I found from UI perspective, its async and UI never be blocked. But its not the correct way.
So please suggest a better way of implementing this. Also is there is any way to understand what is the status of the asyn task (using the ProcessStatus property)

A: Since ASP.NET MVC does not itself provide the ability to process long-running tasks, you have to create an external solution.

*

*Create a Durable Queue in which to place your requests for long-running operations.  RabbitMQ as an example.  Alternatively, write your requests to a requests table in your data store/database.

*Create a Backend Service to execute your long-running tasks.  It should read the requests from your Durable Queue or database table, and act on them accordingly.  This can be a Windows Service, Linux Daemon or AWS Lambda, etc.

*Create a notification mechanism so that the UI can be notified when the task completes, such as a web socket connection or polling.  Or, provide an endpoint on the ASP.NET Web API that allows your web page to retrieve task status.

A: Microsoft suggests the following options in ASP.NET Core Performance Best Practices docs:

*

*Handle long-running requests with background services. In ASP.NET Core, background tasks can be implemented as hosted services. A hosted service class with background task logic that implements the IHostedService interface.

*Also, you can use an Azure Function to complete work out-of-process. This scenario is especially beneficial for CPU-intensive tasks.

*To notify your clients using real-time communication options, such as SignalR, to communicate with clients asynchronously.


text:
Q: How to compile php with sqlite3 support I want to compile php sqlite3 with custom compile option. to do that I followed following steps

*

*wget http://be.php.net/distributions/php-5.3.10.tar.gz

*tar -xvf php-5.3.10.tar.gz

*cd php-5.3.10/ext/sqlite3

*Run phpize

But I am getting error:
Cannot find config.m4.
Make sure that you run '/usr/bin/phpize' in the top level source directory of the module

How can I solve this problem ?

A: Seems like already reported bug
https://bugs.php.net/bug.php?id=53571&edit=1.


text:
Q: How to calculate the transition between a transient and a steady state for a MG1 queue simulation? I need some help to give an output for the queue simulator I'm building.
Everything is ready, but I can't find a numerical method to discover in which piece of data the transient state ends and the steady state begins from data generated by the simulator.
I've already tried to calculate the variance of T1+T2 through the time and to calculate least-square approximation for the data function. Neither of them seems to be working well.
I have 2 queues FCFS and 1 server. All clients enter the first queue, and after being fully served they enter the second queue. First queue has higher priority than second. The info I get from the process is: T1 and T2 (time on queue + server for each queue), N1 and N2 (Number of clients in each queue).
Are there well-documented methods to do that?
Thanks!

A: This is known as the initial transient problem, and was first identified by Conway back in 1963.  You can get very thorough discussions of a variety of options in any modern simulation text book—search Google, Amazon, or Barnes & Noble for "discrete event simulation" and you'll get lots of hits.  Alternatively, this paper gives a reasonable overview of the variety of methods that have been proposed in the intervening half-century.  I recommend the MSER estimator by Pres White, which combines simplicity with analytical rigor.


text:
Q: Regex to find all the img tags with http url I have is javascript regex to extract all the  tags that have the src as http://....  from a string.
regex = /]+src="?(http:\/\/[^">]+)"?\s*\/>/g;

My question is how to do this in Java, and secondly the above regex only gives the content of src, I want to extract and replace the whole  with blank spaces.

PS. The may have many other properties also along with the src, like 'class', 'alt' etc.

A: //Try this solution:

//This answer was tested I hope it is what you're looking for :

Pattern p = Pattern.compile("");
Matcher m = p.matcher("");

if(m.find())
System.out.println(m.group(1));

A: try this one:
regex = /(]+src="?http:\/\/[^">]+"?[^>]+\/>)/g
it should get all img tags. (changed the end of regexp and moved brackets around img tag)

A: Please try the below segment
.*().*
here it will create two matches
1. Match 1 would be the complete img tag
2. Match 2 will hold the URL of image only.
Example
package com.company;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) {
String htmlFragment = "Videocon Mobile Phones has launched three new Android smartphones - Z55 Delite, Z45 Dazzle, and Z45 Amaze with prices starting at Rs 4,599.";

    Pattern pattern =
            Pattern.compile( ".*().*" );
    Matcher matcher = pattern.matcher( htmlFragment );
    if( matcher.matches()) {
        String match =  matcher.group(1);
        String match1 =  matcher.group(2);

        //match.replaceAll("'","");
        System.out.println(match);
        System.out.println(match1);
        //System.out.println(match2);

        String newString = htmlFragment.replaceAll(match,"");
        System.out.println(newString);

    }

}

}
The example is with a single quote image url , but the provided regex at the top is for your case with double inverted quotes.


text:
Q: How do ink droplets passing through two charged metal plates become charged as well? In the working mechanism of an inkjet printer, I came to know that ink droplets in the form of a stream pass through two charged parallel metal plates ( like a parallel plate capacitor) and while passing they acquire charge. I wonder, How?
I could not figure out how do they get charged? do they touch the plates? or something else?
 ( I have searched on internet but could not find a specific answer)

A: An electron gun is used to shoot electrons at the ink which then gives the ink droplets a negative charge, varying based on where the ink needs to go. Then, the charged ink droplet passes between two metal plates, which deflect the ink to its appropriate location on the paper. The ink does not acquire charge from the metal plates, but from the electron gun.
Here is a link to a website with more information: https://thetartan.org/2011/9/12/scitech/htw.
Hope this helps!


text:
Q: All the 7-digit numbers containing each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once, and not divisible by 5 All the 7-digit numbers containing each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once, and not
divisible by 5, are arranged in the increasing order. Find the 2000-th number in this list.
My try:
The number of 7-digit numbers with 1 in the left most place and containing
each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once is 6! = 720.The number of 7-digit numbers with 1 in the left most place and containing
each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once is 6! = 720.

A: Observe the following:

*

*There are $6!-5!=600$ numbers starting with $1$

*There are $6!-5!=600$ numbers starting with $2$

*There are $6!-5!=600$ numbers starting with $3$

*There are $6!-5!=600$ numbers starting with $4$

So your number is the $200$th number which starts with $4$:

*

*There are $5!-4!=96$ numbers starting with $41$

*There are $5!-4!=96$ numbers starting with $42$

*There are $5!-4!=96$ numbers starting with $43$

So your number is the $8$th number which starts with $43$:

*

*There are $4!-3!=18$ numbers starting with $431$

So your number is the $8$th number which starts with $431$:

*

*There are $3!-2!=4$ number starting with $4312$

*There are $3!-2!=4$ number starting with $4315$

So your number is the last number which starts with $4315$.
Therefore your number is $4315762$.

A: The number of 7-digit numbers with 1 in the left most place and containing
each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once is 6! = 720. But 120 of these end in 5 and
hence are divisible by 5. Thus the number of 7-digit numbers with 1 in the left most place
and containing each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once but not divisible by 5 is 600.
Similarly the number of 7-digit numbers with 2 and 3 in the left most place and containing
each of the digits 1, 2, 3, 4, 5, 6, 7 exactly once but not divisible by 5 is also 600 each. These
account for 1800 numbers. Hence 2000-th number must have 4 in the left most place.
Again the number of such 7-digit numbers beginning with 41,42 and not divisible by 5 is
120 − 24 = 96 each and these account for 192 numbers. This shows that 2000-th number
in the list must begin with 43.
The next 8 numbers in the list are: 4312567, 4312576, 4312657, 4312756, 4315267, 4315276,
4315627 and 4315672. Thus 2000-th number in the list is 4315672.
Thanks for the hint @almagest

A: 1 at extreme left and rest 6 numbers can be arranged in 6!=720 ways
But 120 numbers end with 5 so 720-120=600
Similarly
Starting with 2, 600 numbers
Starting with 3, 600 numbers
Starting with 41, 96 numbers
Starting with 42, 96 numbers
Starting with 4312, 4 numbers
Total 1996 numbers and
Next 4 numbers are
4315267,
4315276,
4315627,
4315672,
so 2000th number is 4315672

A: There will be 6 numbers with 4315 _ _ _ instaed of 4 cause you can fill the remaining three places in 3! ways and as 5 is used earlier only then you don't have to neglect 2 case in which 5 comes last


text:
Q: Google Sheets custom function bug "Unknown function" after successful run In a Google Sheet cell, a custom function is being called through =sheetName() to run the following script (that will return current sheet name):
function sheetName() {
  return SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getName();
}

On first edit (code insertion in cell) the function works properly, but since the sheet is renamed the function won't work as the cell (calling the custom function) content is not updated. Editing again the cell will show the error "Unknown function":

At this point, some editing in the "offending" cell, will correctly run again the custom function...
Any idea why the function will only work when cell content is edited and wont run when sheet "tab" is renamed?

A: Google sheets is optimised so that recalculations are done as efficiently as possible. One of the main ways that this is done is through looking at the parameters of functions and only recalculating cells that have dependencies that have changed.
This mostly doesn't cause problems, but for your function which has no parameters you will find that the function is run once and never gets run again. Surprisingly the original result remains even if you close and open the sheet again.
A hacky solution is to put in a dummy parameter with a reference to another cell.
=sheetName(A1)

If you want to recalculate just change the contents of A1 and it will force your function to be recalculated.

A: I am getting the exact same error with functions that DO have parameters. As per the docs I opened Extensions/Apps Script and wrote a function called myFunction that takes one param and displays the param. I added test code that calls myFunction(55) and console.logs the result. This runs correctly without error. So then I saved the project, and according to the docs I should now be able to use myFunction. So I type the following into a cell, to call myFunction with the value of cell D2 as parameter:
=myFunction(D2)
The cell says #NAME and the context help says "myFunction" is an unknown function.


text:
Q: Generating a numpy array of ones and zeros with weighted chance for ones equal 0.11 How can I generate a size 10000 Numpy array of 1's and 0's where getting 1's is weighted by a chance of 0.11?

A: Use numpy's random choice.
from numpy.random import choice
ratio = 0.11
draw = choice([0,1], 10000, p=[1-ratio, ratio])

# Evaluate
sum(draw)
# 1119


text:
Q: sql timediff function What is the proper way to use mysql TIMEDIFF, (or something similar)? In database I have a column called date, and it is setup  CURRENT_TIMESTAMP. I'm trying to calculate the differene between the CURRENT_TIMESTAMP and right now in a row, and than echo that to all the rows.. here's my script
  <?php
  mysql_connect("localhost","root","");//database connection
  mysql_select_db("beyondmotors");

  $result = mysql_query("SELECT * FROM currentrentals");

  echo "

  ID
  Year
  Make
  Model
  First Name
  Last Name
  Insurance
  Date
  Notes

";

  while($row = mysql_fetch_array($result))
    {
    echo "
";
    echo "" . $row['id'] . "	";
    echo "" . $row['year'] . "	";
    echo "" . $row['make'] . "	";
    echo "" . $row['model'] . "	";
    echo "" . $row['firstname'] . "	";
    echo "" . $row['lastname'] . "	";
    echo "" . $row['insurance'] . "	";
    echo "" . $row['date'] . "	";
    echo "" . $row['notes'] . "	";
      echo ("Edit
");
      echo "
";
      }
    echo "
";

Thanks in advance

A: This can be heavily dependent on your output.
For example, TIMEDIFF() outputs is hours, minutes, seconds. As such, it is limited to the data type TIME.
Given a unit of SECOND, TIMESTAMPDIFF() is a more robust solution.
All of this is well documented in MySQL Date and Time functions.
In the end, you typically see these calculations done with code. That is not with SQL. In your case PHP. You could do simple arithmetic by subtracting the timestamps from strtotime(). Or if you are using PHP >= 5.3, you could use DateTime::diff.
As an aside, avoid naming your columns keywords, i.e. date.

A: I would do like this:
SELECT (fields), UNIX_TIMESTAMP(date) as date FROM currentrentals

And then you can access date with $row['date']. Now you can easily subtract these dates.
$timesince = date(format, time() - $row['date']);

Hope that helps.


text:
Q: It's safe to access to the database and querying from it directly if it's on the server side, if not what should i do? I made WPF application for a client-side and hosting database in a server side ,
I know there is something called REST API to transfer data between a client and server
I don't know this method and also i don't have a time to learn it because the project should finish less than one month,
I am thinking to make client access to database directly by stored procedures.
I don't know if it's safe method or not, if it's not secure what should i do then?....any suggestion please!

A: Yes you need an API.
If your WPF app connects directly to the database server then the users of that app will have the same permissions, and be able to connect to the database themselves and do things that the app would not normally let them do.
You could grant the logged in windows user limited permission to the db, but you will find that the access permissions are not fine grained enough for most apps.
An API allows you to authenticate each user and allow them to only do specific tasks.
If you do not have time to learn a REST technology, perhaps WCF would work for you?

A: Do you need a REST API?
These become useful when you want to publish your data to many client applications.  At the moment, you only have one client application so worry about that one.  Look into Entity Framework, Linq-to-SQL or even old-school SQL statements and DataSets / DataTables; all of these will probably serve you better, given the short timescale you have to work with.
When you have a need to write a REST API, only then worry about how to do so.


text:
Q: Scala - Retry HTTP request with timeout I wish to create a service where it makes an HTTP request to a specific URL, and if it doesn't get a result in 1 second, that request will timeout and then it will retry with another request, for maximum of 3 retries.
How to implement this in scala?
I'm looking in the documentation of Akka HTTP and Play's WSClient but I can't find it gets mention anywhere.
Note: In the case that if the request makes a side-effect on the server, I want the unsuccessful request to produce NO side-effect. How can this behavior be achieved? Is it even possible?

A: You can also use retry from akka patterns:
import akka.pattern.{ask, pipe, retry}
import akka.actor.{Actor, ActorSystem, Props, Scheduler}
import akka.util.Timeout
import scala.concurrent.duration._
import scala.concurrent.{Await, ExecutionContext, Future}

class ClientActor extends Actor { //actor which times out 2 times and succeeds 3rd time

    var attempts = 0

    def receive = {
      case "request" =>
        this.attempts = attempts + 1
        if (attempts < 3) {
          Thread.sleep(2000)
          Future.failed(new Exception("timed out")) pipeTo sender
        } else {
          Thread.sleep(500)
          Future.successful(s"Successful in $attempts attempt") pipeTo sender
        }
        println(s"Attempt: $attempts")
    }
}

val system = ActorSystem("system") //actor system and needed implicits
implicit val ec: ExecutionContext = system.dispatcher
implicit val timeout: Timeout = Timeout(1 seconds)
implicit val scheduler: Scheduler = system.scheduler

val client = system.actorOf(Props[ClientActor], "client-actor")

val future = retry(() => client ? "request", 3, 1 second) //create future which would retry 3 times

println(Await.result(future, 10 seconds)) //Would write "Successful in 3 attempt"

A: As i understand your question what you need to do is:
steps

*

*End point to access some API via HTTP call.

*If the response is not coming within 1 second you need to get an exception.

*In the case of exception you need to restart the service and again send the request.

you can do that in collaboration of Akka Http and Akka Actors.
With the use of Akka actors you can tell your service what need to be done when you are getting TimeoutException. You can make your API call via Akka ask pattern.
If you will see the documnetation of Akka ask pattern here. it takes Akka ask timeout which you can set to any value you want, In case when you are not getting the response back in timeout you will get AkkaAskTimeOutException, which will be catched by your child actor and then it will be passed to the supervisor actor, While Supervisor actor catchs an exception we can use the supervison strategy and can specify what needs to be done Like (restart, shutdown, resume etc).
Supervison strategy: you can read about it here. Actually following is basic structure of an akka actor based application.
Supervisor Actor (we write supervison strategy in supervisor) and it has child actors.
child1(business logic)   child2 (business logic)


text:
Q: Room: Handling a list of child entities I have json received from a rest service which is comprised of some persons with each having a list of ids referencing some skills with each having a list of ids referencing some skill types:
{
    "person": [{
            "id": 1,
            "name": "Biatrix",
            "age": 29,
            "skillIndices": [
                1,
                2
            ]
        },
        {
            "id": 2,
            "name": "Oren",
            "age": 27,
            "skillIndices": [
                1,
                2
            ]
        },
        {
            "id": 3,
            "name": "Bill",
            "age": 52,
            "skillIndices": [
                1,
                2
            ]
        }
    ],
    "skill": [{
            "id": 1,
            "name": "Sword",
            "typeIndices": [
                1,
                2
            ]
        },
        {
            "id": 2,
            "name": "Kong fu",
            "typeIndices": [
                3,
                4
            ]
        }
    ],
    "type": [{
            "id": 1,
            "name": "Hattori"
        },
        {
            "id": 2,
            "name": "Hanzō"
        },
        {
            "id": 3,
            "name": "Shaolin"
        },
        {
            "id": 4,
            "name": "Tai Chi Quan"
        }
    ]
}

For persisting this data to a Room database I have three entities and three dao's.
I need to somehow translate the ids to the real objects so when retrieving the data as LiveData using my repository I'll get something like that, which I can use in my UI:
{
    "person": [{
            "id": 1,
            "name": "Biatrix",
            "age": 29,
            "skills": [
                [{
                    "id": 1,
                    "name": "Sword",
                    "types": [
                        "Hattori",
                        "Hanzō"
                    ]
                },
                {
                    "id": 2,
                    "name": "Kong fu",
                    "types": [
                        "Shaolin",
                        "Tai Chi Quan"
                    ]
                }
            ]
        },
        {
            "id": 2,
            "name": "Oren",
            "age": 27,
            "skills": [
                [{
                    "id": 1,
                    "name": "Sword",
                    "types": [
                        "Hattori",
                        "Hanzō"
                    ]
                },
                {
                    "id": 2,
                    "name": "Kong fu",
                    "types": [
                        "Shaolin",
                        "Tai Chi Quan"
                    ]
                }
            ]
        },
        {
            "id": 3,
            "name": "Bill",
            "age": 52,
            "skills": [
                [{
                    "id": 1,
                    "name": "Sword",
                    "types": [
                        "Hattori",
                        "Hanzō"
                    ]
                },
                {
                    "id": 2,
                    "name": "Kong fu",
                    "types": [
                        "Shaolin",
                        "Tai Chi Quan"
                    ]
                }
            ]
        }
    ]
}

This needs of course (?) to happen under the Entity class as a Pojo, right? Tried to do this using the @Relation annotation, but can't seem to understand how to do.
Here is the Entity for Person:
package com.myapp.data.db.entity

import androidx.room.*

@Entity(tableName = "person")
data class Person(
    @PrimaryKey(autoGenerate = false)
    var id: Int = 0,
    var name: String = 0,
    var age: Int = 0,
    var skillIndices: List<Int> = arrayListOf()
)

How do I manipulate this Entity so when asking for Person data, I'll get something like the above (second) dataset?

A: skillIndices should be its own inner-Entity, so that you could reference var skillIndices: List<Skill> inside Person.
Also do not forget to @SerializeName("skill") the field skillIndices as it doesn't have the same name.
@Entity(tableName = "person")
data class Person(
    @PrimaryKey(autoGenerate = false)
    var id: Int = 0,
    var name: String = 0,
    var age: Int = 0,
    var skills: List<Skill> = arrayListOf()
)

@Entity(tableName = "skill")
data class Skill(
    @PrimaryKey(autoGenerate = false)
    var id: Int = 0,
    var name: String = 0,
    var types: List<String> = arrayListOf()
)


text:
Q: Are there infinitely many finite sets $S$ of primes where $\sum_{p\in S} {1/(p_i-1)}=1$? For example, $S = \{3,5,7,13\}$ gives $\frac{1}{2}+\frac{1}{4}+\frac{1}{6}+\frac{1}{12}=1$.
A few other such sets: $\{2\},\{3,5,7,19,37\},\{3,5,7,29,31,71\}$.
Are there infinitely many of these?

A: I believe the answer to this is actually yes.
See Erdős–Graham problem.
This problem asked: if you partition all natural numbers larger than 1 into finitely many subsets, must the reciprocals of one of the subsets sum to 1? It was apparently proven in the affirmative in 2003.
By my reasoning, you could put all composite numbers in one subset, which already sums to more than 1 after taking the composites through 16, then divide up the remaining numbers (all primes) into any partitioning you like and be assured that at least one of those subsets will sum to 1. There are clearly infinitely many ways one could do that partitioning so as to obtain infinitely many different valid solution subsets.
Among other things, this would yield infinitely many distinct covering sets for Sierpinski numbers, which would therefore have infinitely many distinct possible coverage periods.

As pointed out below, I read this mistakenly so this isn't actually a solution. I'll leave this here as a potential jumping-off point for a solution, however; if one could assign the composites systematically into subsets in such a way that none of those subsets could contain a reciprocal sum to unity, then this would still work.


text:
Q: Different top-margins in a div-based table I want to emulate the following behaviour in a div/css-based table

        a
        a

Margin for a single cell seems to get ignored

x

x

Padding applies to all cells even if only specified for a single one

x

x

Same goes for workarounds by adding inner divs with padding/margin

x

x

x

x

Can be seen in: http://jsfiddle.net/RXRBm/19/

A: Padding is not being applied to all cells- dont forget cell contents are vertically aligned by default and fit to the height of the row as determined by the cell with the greatest height. As such, margins cannot be applied and are ignored, and ensuring you have (e.g):
td{
   vertical-align:top;
}

Will ensure you clearly see the impact of any applied padding without any additional vertical alignmnet changing the positioning of contents in other cells.
Demo Fiddle
If you look at the default HTML4 CSS style spec proposition, you can see this vertical-align in play

A: table-cell divs aren't affected by margins, but some of your workarounds can work, if you force vertical alignment on the other cell:

x

x


text:
Q: Simple animation with Tao.Framework (C# - Open GL) update buffer not work Hello I'm starting with OpenGL using C#, Tao.Framework and Tao.Plataform.Windows SimpleOpenGlControl, so far I came with this snippet:
// in Form.Load handler
Gl.glOrtho(0, 10, 0, 10, -1, 1);

Gl.glClearColor(0f, 0f, 0f, 0f);
Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);

Gl.glBegin(Gl.GL_POLYGON);

Gl.glVertex2f(0f, 0f);
Gl.glVertex2f(0f, 1f);
Gl.glVertex2f(1f, 1f);
Gl.glVertex2f(1f, 0f);

Gl.glEnd();

So far, so good. Now I'm trying to add some animation effect. I'm trying to move the square like a ball that bounce in extremities of my client area. My code is this:
Gl.glOrtho(0, 10, 0, 10, -1, 1);

new Thread(() =>
{
    int x = 3, incX = 1;
    int y = 7, incY = 1;

    while (true)
    {
        Gl.glClearColor(0f, 0f, 0f, 0f);
        Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);

        Gl.glBegin(Gl.GL_POLYGON);

        Gl.glVertex2f(x + 0f, y + 0f);
        Gl.glVertex2f(x + 0f, y + 1f);
        Gl.glVertex2f(x + 1f, y + 1f);
        Gl.glVertex2f(x + 1f, y + 0f);

        Gl.glEnd();

        simpleOpenGlControl1.SwapBuffers();

        if (x == 0 || x == 9) incX *= -1;
        if (y == 0 || y == 9) incY *= -1;

        x += incX;
        y += incY;

        Thread.Sleep(1000);
    }
}).Start();

But there is something very wrong. My picture keep switching between two specific frames. I printed the two frames. Check it out:
http://www.jonataspiazzi.xpg.com.br/outpost/example_frame.png
Still has a following detail. As much as the first frame above is correct it shows no variation, I mean the square doesn't move.
How can I fix it? Or how to build a simple animation?

A: You may not issue OpenGL commands from a thread that does not have an OpenGL context.
You have two options:

*

*use wglMakeCurrent to move the OpenGL context to your new thread. (In that case, the main thread may no longer issue OpenGL commands.)

*Hook the Application.Idle event and loop within that. Break from the loop whenever a new windows message arrives.

Tao SimpleOpenGlControl does not offer a way to check for incoming windows messages. As one of the original maintainers of the Tao framework, I would suggest switching to OpenTK.GLControl instead. In that case, you would write:
// in Form.Load handler - separate thread
glControl.Context.MakeCurrent(null);
Thread thread = new Thread(() =>
{
    glControl.MakeCurrent();
    while (!exit)
    {
        GL.ClearColor(0f, 0f, 0f, 0f);
        GL.Clear(ClearBufferMode.ColorBufferBit);

        GL.Begin(PrimitiveType.Quads);

        GL.Vertex(x + 0f, y + 0f);
        GL.Vertex(x + 0f, y + 1f);
        GL.Vertex(x + 1f, y + 1f);
        GL.Vertex(x + 1f, y + 0f);

        GL.End();

        glControl.SwapBuffers();

        if (x == 0 || x == 9) incX *= -1;
        if (y == 0 || y == 9) incY *= -1;

        x += incX;
        y += incY;
    }
};

or (if you do not wish to use a separate thread):
// in Form.Load handler - main thread
Application.Idle += (sender, e) =>
{
    while (glControl.IsIdle)
    {
        GL.ClearColor(0f, 0f, 0f, 0f);
        GL.Clear(ClearBufferMode.ColorBufferBit);

        GL.Begin(PrimitiveType.Quads);

        GL.Vertex(x + 0f, y + 0f);
        GL.Vertex(x + 0f, y + 1f);
        GL.Vertex(x + 1f, y + 1f);
        GL.Vertex(x + 1f, y + 0f);

        GL.End();

        glControl.SwapBuffers();

        if (x == 0 || x == 9) incX *= -1;
        if (y == 0 || y == 9) incY *= -1;

        x += incX;
        y += incY;
    }
};

Edit: in both cases, you need the following using directives.
using OpenTK;
using OpenTK.GLControl;
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
using OpenTK.Input;

You can ask Visual / Xamarin Studio to add the missing using directives by right-clicking the unknown identifier and selecting "Resolve".

A: If your SimpleOpenGlControl is smpl then, you can call,
smpl.SwapBuffers();

which works very fine


text:
Q: NetworkError: 405 Method Not Allowed I receive the above error no matter what link I go to in my current development project, using CodeIgniter 3.0.6, and MaterializeCSS.
Searches for this error on SO and Google does not bring up any answers for me.
There does not seem to be any way to trace this further. My Apache 2.4.x error logs is not showing errors, only Firebug.
Any idea what could be wrong?
Edit: This does not seem to have any effect on the functionality of my site besides the error in Firebug...

A: I think its because you enabled CSRF protection.
If the hash expires on server side, your client sends the wrong hash to the server.
If the client hash and the server hash are not the same CI will send this error message to the client.
This may will help you:
codeigniter CSRF error

A: The jQuery plugin that dealt with the onepage navigation caused it. When I removed that plugin, the error disappeared.


text:
Q: Connectedness for stacks Let $X$ be a stack for the Zariski (or etale) site over an arbitrary field $k$. The functor $\pi_0(X) : Alg_k \to Sets$ of path-components of $X$ is defined as the composition
$$Alg_k \overset{X}{\to} Grpd \overset{\pi_0}{\to} Sets,$$
where $Grpd$ is the $2$-category of (small) groupoids and the functor $\pi_0$ sends a groupoid $G$ to its set of isomorphism classes.
What is the relationship between $\pi_0$ and more topological definitions of connectedness? For example, suppose $R$ and $S$ are affine schemes over $k$ with $S$ topologically connected. Let $f: S \to X$ be an $S$-point of $X$, and assume we have two $R$-points $g$ and $h$ of $X$ that factor through $f$. Then do $g$ and $h$ become identified after passing to $\pi_0(X(R))$?


text:
Q: How to update Angular model with $http response? I'm building an http request in Angular using $http and trying to update a model located in '$scope' with the data return in the response. When I receive the response from my node backend, I'm setting '$scope.data = data;' within the success callback. When I step through the javascript, I can see that the response is correct and the status code is present.
Here's a sample of what I'm trying to do:
angular.module("Sample").controller('MainCtrl', ['$http', '$scope', function($http, $scope) {

this.testcall = function (url) {

  $http.post(url).success(function (data, status) {
    console.log(data);
    $scope.data = data;
    $scope.status = status;
    console.log($scope.data);
  }).error(function (data, status) {
    console.log('failed');
    $scope.response = 'failed call';
    $scope.status = status;
  });
};
}

And in my html template I have the controller set in the div and I'm trying to display that response.

  {{data}}

I can set a value to data and have it appear on load, but when the value changes it's not being redrawn. It was my understanding that '$http' causes '$digest' to be called which should redrawn any modified models.

A: To get it working you need to bind scope variable to controller this context
write this.data = data; instead of $scope.data because you are using controllerAs syntax.
Code
  $http.post(url).success(function (data, status) {
    console.log(data);
    this.data = data;
    this.status = status;
    console.log(this.data);
  }).error(function (data, status) {
    console.log('failed');
    this.response = 'failed call';
    this.status = status;
  });

Markup

  {{main.data}}

A: I've recreated nearly your exact scenario in this plunker and everything is working as expected.
function MainCtrl($scope, $http) {
 this.testcall = function(url) {
   $http.get(url).success(function(data, status) {
     console.log(data);
     $scope.data = data;
     $scope.status = status;
     console.log($scope.data);
   }).error(function(data, status) {
     console.log('failed');
     $scope.response = 'failed call';
     $scope.status = status;
   });
 };
}

MainCtrl.$inject = ['$scope', '$http'];

angular.module('sample', [])
 .controller('MainCtrl', MainCtrl);

index.html

  <button type="button" class="btn btn-primary"
          ng-click="main.testcall('data.json')">Test Call</button>
  {{data}}

There may be a problem in the larger example you aren't showing us.

A: I believe my initial problem was the $scope. I ended up solving the problem by creating a new directive in an attempt to isolate the scope as well as the problem.
Below is my button-directive.js and markup respectively.

(function() {
  var app = angular.module('Sample', []);

  app.directive('submitButton', function() {
    return {
      restrict: 'E',
      scope: {}
    };
  });

  app.controller('SubmitCtrl', ['$http', '$scope',
    function($http, $scope) {
      this.submit = function() {
        console.log('hit');
        $http.get('http://ip.jsontest.com/').success(function(data, status) {
          $scope.data = data;
          $scope.status = status;
          console.log(data);
        }).error(function(data, status) {
          $scope.status = status;
          $scope.data = data;
        });
      };
    }
  ]);
})();

    <button type="submit" ng-click="controller.submit()">Submit</button>

    Response Data: {{data}}

Status Code: {{status}}


text:
Q: Dealing with "underdispersion" in binomial GLMM I try to fit several binomial glmms. My interest is wheather historic and recent samples differ in their climatic conditions.
My data is organized as follows, where rand.factI has 62 levels and is nested within rand.factII (9 levels). Binary variable hist_rec is the target variable; it indicates "historic sample" (=0) or "recent sample" (=1). Variables temp.5years and prec.5years are "studentized" (scaled). The table has 379 rows (of which 221 are hist_rec == 1):
my.data
           rand.factI rand.factII temp.5years  prec.5years   hist_rec
                    3           A   2.7762497 -3.178499380          1
                   27           B   2.0817516 -2.457070449          0
                   27           B   2.0233063 -2.369078844          0
                   35           B   2.0315846 -2.229418671          1
                   41           A   1.5080735 -1.700811294          1
                   93           C   0.4385099  0.162621195          0
                   93           C   0.5894258  0.064214693          0
                   94           C   0.8763280 -0.044050165          1
                   94           C   0.7988891  0.005925186          0
                   94           C   0.5989886  0.104371339          0
                   94           C   0.3690310  0.230485075          1
                  ...         ...         ...          ...        ...

I use the packages
library(lme4)
library(pROC)

My models look like this:
my.model <- glmer(hist_act ~ temp.5years +
    (1|rand.factI/rand.factII), data=my.data,
    family=binomial)

Outcomes look ok for precipitation, but I have my doubts with the temperature model. Here is a summary of mean values ± standard error for recent and historic sample, p-value of the model, direction of the indicated effect, residual.deviance/residual.degrees.of.freedom (dev_resid) and AUC value.
    variable    mean.rec    r.SE mean.hist    h.SE      p  direction  dev_resid signif        AUC
    temp.5years     0.77 ± 0.051     -0.55 ± 0.056 0.0000          +       0.29    ***  0.9991122
    prec.5years    -0.35 ± 0.089      0.25 ± 0.055 0.0000          -       1.22    ***  0.7806862

dev_resid is << 1 for the temperature model, so I assume that there is some relevant underdispersion. At the same time, the AUC is extremely good - somewhat misleading, I suppose.
The QQ-Plot for the temperature data looks like this:
qqnorm(residuals(my.model, type="deviance"),
    main=names(compare.data[i]))
qqline(residuals(my.model, type="deviance"),
    col="green")
abline(a=0, b=1, col="red")

I understand that underdispersion is not possible with binary response variables. In How to handle underdispersion in GLMM (binomial outcome variable), it says:

If you have truly binary, ungroupable outcomes (e.g. one of your
response variables is a continuous predictor that is unique to
individuals, as would be typical in an observational study), then (1)
you can't estimate the degree of overdispersion and (2) you can't
really worry about it (i.e., there may be additional sources of
variability you don't know about, but they just go to inflate your
uncertainty, but they don't bias your inference).

However, the low residual.deviance/residual.degrees.of.freedom - ratio in conjunction with the excellent AUC value make me wonder weather this model is erroneous.
My question is: how should I treat the temperature model? glmer doesn't allow for quasi-families, so I am kind of stuck here. Does it seem promising to transform the temperature variable? Or is there something else I can do to obtain a valid model?


text:
Q: Android Service which displays toast message of KeyPress How to display toast message from android service which is running at the background? Basically I need to display all the KeyPress actions to be displayed as a toast message from background running service (Over all apps / Home).
@Override
public boolean dispatchKeyEvent(KeyEvent KEvent)
{
    int keyaction = KEvent.getAction();
    if(keyaction == KeyEvent.ACTION_DOWN)
    {

       int keycode = KEvent.getKeyCode();
       Toast.makeText(this," KEYCODE=" + keycode, Toast.LENGTH_SHORT).show();
    }
    return super.dispatchKeyEvent(KEvent);
}

I am using the above set of code to toast the keypress.
Thanks in advance

A: If your service is running on a background thread, you'll have to use runOnUIThread or a handler like below:
new Handler(Looper.getMainLooper()).post(new Runnable() {
    @Override
    public void run() {
        // toast here
    }
});


text:
Q: Error in setting job.setInputFormatClass in Mapreduce I am running a MapReduce program. I need to give input text file in the format of KEYVALUE pair. so that If I write
job.setInputFormatClass(KeyValueTextInputFormat.class);

The eclipse compiler is showing error that I cant use InputFormat.
anyhow I need to set the Input's format as KeyValueTextInputFormat
 How do I do this ?? Any IDea ?????
My Code is
`
package com.iot.dictionary;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.KeyValueTextInputFormat;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;

import com.iot.dictionary.Dictionary.AllTranslationsReducer;
import com.iot.dictionary.Dictionary.WordMapper;
public class Driver2 {
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
    Configuration conf = new Configuration();

        String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
        if (otherArgs.length != 2) {
          System.err.println("Usage: wordcount <in> <out>");
          System.exit(2);
        }
        Job job = new Job(conf, "dictionary");
        System.out.println("Job-> "+job.toString());
        job.setJarByClass(Dictionary.class);
        job.setMapperClass(WordMapper.class);
        job.setReducerClass(AllTranslationsReducer.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(Text.class);
        job.setInputFormatClass(KeyValueTextInputFormat.class);
        FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
        FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
}

`

A: If you are using new Hadoop API (Hadoop 0.20.2 and above), you have to import the KeyValueTextInputFormat.class class from package org.apache.hadoop.mapreduce.lib.input.KeyValueTextInputFormat and if you are using the old Hadoop API, you have to import it from org.apache.hadoop.mapred.KeyValueTextInputFormat
You see that line in your code:
import org.apache.hadoop.mapred.KeyValueTextInputFormat;

Change it to
import org.apache.hadoop.mapreduce.lib.input.KeyValueTextInputFormat;

Hope this helps.
Thanks


text:
Q: Datalabel placement - Opposite of of chart data (positive and negative values) I'm creating a bar chart with positive and negative values and display the xAxis (category name) of each data point (See Fiddle: https://jsfiddle.net/bej8j/75/).
Here's what I have for plot options but I'm not sure what else I need (Really only putting this code in here because I need to include some code to link to a jsfiddle)
plotOptions : {
            series : {
                dataLabels: {
                    formatter: function() {
                        return this.x
                    },
                    enabled: true
                }
            }
        },

I'm trying to place the label so that it's aligned with the start of each bar on the chart. I photoshoped my desired result: http://i.imgur.com/0I1jSHW.png
Any help would be greatly appreciated.

A: You can iterate on each datalabel and use translate() function to move SVG element.
http://jsfiddle.net/eMjGg/7/
$.each(chart.series[0].data,function(i,data){

        position = chart.yAxis[0].toPixels(0);

        console.log(data);
        if(data.y < 0)
            position-=10;
        else
            position-=70;

        data.dataLabel.attr({
            x:position
        });
    });

A: I think this would help you: http://jsfiddle.net/42dRt/5/
Here's more info: high-charts datalabel position needs to change when value is too small
You must play with the X value:
plotOptions : {
                series : {
                    dataLabels: {
                        formatter: function() {
                            return this.x
                        },
                        x: ?,
                        enabled: true
                    }
                }
            }


text:
Q: How to launch spring batch remote partitioned job through cron? I am using spring batch and spring batch admin for our daily batch processing work. I have tested it using tomcat 7 by launching jobs through spring batch admin UI.
My job has remote partitioned steps which runs across different servers, I am using rabbitmq as a middleware, spring batch integration for remote partitioning.
While testing, I deploy application on all servers, start tomcat on all servers so that all listeners (inbound gateways concurrent threads) starts, all beans are initiated.
Now I want to move it to production so want to add it in cron which should automatically launch job at 4 am daily.
1) Is there any way to launch the job using cron?
2) In that case do we need to start tomcat on all servers or it can run without it?
3) If I launch job on one server (master), how beans, consumers etc will be initiated on all servers so that steps will run as partioned steps on all servers?
In spring batch admin sample, in launch-context.xml there is
<description><![CDATA[
  A convenient aggregating config file for running the jobs in this project
  from the command line instead of from the web application.  E.g.

  $ MAVEN_OPTS="-Dbatch.jdbc.url=jdbc:hsqldb:hsql://localhost:9005/samples -Dbatch.data.source.init=false" \
    mvn exec:java -Dexec.classpathScope=runtime \
    -Dexec.mainClass=org.springframework.batch.core.launch.support.CommandLineJobRunner \
    -Dexec.args="classpath:launch-context.xml job1 fail=false run.id=1"

  ]]>
</description>

<import resource="classpath*:/META-INF/spring/batch/bootstrap/**/*.xml" />
<import resource="classpath*:/META-INF/spring/batch/override/**/*.xml" />

<bean id="jobLauncherTaskExecutor" class="org.springframework.core.task.SyncTaskExecutor"/>

Can I use it for my use case?

A: The process needs to be running on all servers.
One solution is to continue to use Tomcat (and leave them running all the time). You can launch the batch job using spring-batch-admin's ReST API (e.g. using curl from cron).
The Spring XD Project (which will be released soon) also provides a ReST API for launching batch jobs.


text:
Q: Background position offset from bottom: opposite behaviour in Chrome and Firefox I found an opposite result in Firefox and Chrome when rendering a gradient background with offset set.
Here my css code:
html
{
   background:linear-gradient(to bottom, rgba(245,245,245,1) 0%,rgba(255,255,255,0) 8%);
   background-position: center top 30px;
}

body
{
   background:linear-gradient(to bottom, rgba(255,255,255,0) 92%,rgba(245,245,245,1) 100%);
   background-position: center bottom 100px;
}

The idea is to apply a sort of "Sliding doors" of background applying 2 opposite gradient onto html and body elements.
The problem rises when I set the bottom offset in Body tag: Firefox translates up with positive values, while Chrome translate up with negative values (or bottom with positive). So two major browsers  have opposite behaviour.
How to solve this?

A: I found solution for Chrome!
It is sufficient to add
 background-repeat:no-repeat;

to BODY tag css declaration, as showed in this updated JsFiddle: