text:
Q: Swift 3: Be able to tap view behind a collectionViewCell? I am working on a new feature in my app where I want a user to have an image and then be able to swipe through a collectionView on top of that image, adding "filters". The issue that I have is that I want the user to still be able to interact with the image, but it is behind the collectionView. If I set the collectionViews inUsersInteractionEnabled to false, of course I then cannot use the collectionView at all. I am going for a similar functionality to Snapchats "scroll through filters" feature. Any help will be highly appreciated. Thank you guys. Code is below:
import UIKit

class FirstCell: UICollectionViewCell {

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupViews()
    }

    func setupViews() {
        backgroundColor = .clear
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

class SecondCell: UICollectionViewCell {

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupViews()
    }

    let cellView: UIView = {
        let view = UIView()
        view.backgroundColor = .red
        view.alpha = 0.25
        return view
    }()

    func setupViews() {
        backgroundColor = .clear
        addSubview(cellView)

        cellView.frame = CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height)
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

class SecondController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {

    lazy var collectionView: UICollectionView = {
        let layout = UICollectionViewFlowLayout()
        layout.minimumLineSpacing = 0
        layout.minimumInteritemSpacing = 0
        layout.scrollDirection = .horizontal
        let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
        cv.backgroundColor = .clear
        cv.dataSource = self
        cv.delegate = self
        cv.translatesAutoresizingMaskIntoConstraints = false
        cv.isPagingEnabled = true
        return cv
    }()

    override func viewDidLoad() {
        super.viewDidLoad()

        collectionView.register(FirstCell.self, forCellWithReuseIdentifier: "firstCell")
        collectionView.register(SecondCell.self, forCellWithReuseIdentifier: "secondCell")

        view.backgroundColor = .white

        setupViews()
    }

    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
        return CGSize(width: view.frame.width, height: view.frame.height)
    }

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 2
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

        if indexPath.item == 0 {
            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "firstCell", for: indexPath) as! FirstCell
            return cell
        } else {
            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "secondCell", for: indexPath) as! SecondCell
            return cell
        }
    }

    lazy var imageView: UIImageView = {
        let iv = UIImageView()
        let image = UIImage(named: "img")
        iv.image = image
        iv.contentMode = .scaleAspectFill
        iv.translatesAutoresizingMaskIntoConstraints = false
        iv.isUserInteractionEnabled = true
        iv.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleTap)))
        return iv
    }()

    func handleTap() {
        print(123)
    }

    func setupViews() {
        view.addSubview(imageView)
        view.addSubview(collectionView)

        imageView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
        imageView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
        imageView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
        imageView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true

        collectionView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
        collectionView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true
        collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
        collectionView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
    }

}

A: There is a hitTest(_::) method available to override in any of the UIView subclass, which you can implement in your custom UICollectionView subclass and forward taps from it to any other view (the image behind collection view in your case).
override func hitTest(_ point: CGPoint,
                               with event: UIEvent?) -> UIView? {

    let hitView = super.hitTest(point, with: event)

    if self.parentViewController.forwardTapToImageIfNeeded(point) {
        return nil
    }

    return hitView
}

Where parentViewController is a reference to your SecondController instance, which should have forwardTapToImageIfNeeded(_) function to check if user's tap is on top of the image frame, and if it is — automatically pass tap event to it.
func forwardTapToImageIfNeeded(_ p: CGPoint) -> Bool {
    /* Convert point to local coordinates */
    let pointInSuperView = self.convert(p, from: collectionView)
    /* Check if tap is on top of the image frame */
    if imageBehindCollection.frame.contains(pointInSuperView) {
        // Forward tap to the image `imageBehindCollection`
        return true
    }

    return false
}

Note: I didn't test this particular code by myself, so it might need a few fixes in Xcode.


text:
Q: using if/case in sql server where clause I'm trying to add a column in where clause in SQL Server 2005, but issue is I have to add it for a given condition like
where condition  1
and condition 2
if(@val !=null and @val = 'test')
begin
and condition 3
end

but when I try this SQL Server gives me error:
Incorrect syntax near the keyword 'and'. Severity 15 Procedure Name
Incorrect syntax near 'END'. Severity 15 Procedure Name

I did some R&D and found that I should use case statement instead and then I tried this
where condition  1
    and condition 2
    CASE @val
    WHEN 'test' THEN AND condition 3
END

but now it's giving error:
Incorrect syntax near the keyword 'CASE'. Severity 15 Procedure Name

Can any one help me to sort out the problem? Thanks.
EDIT
select *
from Tables with joins
where ac_jd_date_closed >= convert(VARCHAR(10),dateadd(dd, -@period, getdate()), 101)
and ac_jd_date_closed <= convert(VARCHAR(10),dateadd(dd, 0, getdate()), 101)
and lo_pc_last_name not in ('Shroder')
and lm_ap_pr_id NOT IN (4743, 2683)

I want to add this condition when spm David otherwise this condition should not be there.

A: You can remove the CASE statement and substitute AND (@Val<> 'test' OR (@Val = 'test' AND condition 3)):
WHERE <condition  1>
AND <condition 2>
AND (@Val<> 'test' OR (@Val = 'test' AND <condition 3>))

A: where condition  1
and condition 2
and ((@val='test' and condition 3) Or (@val!='test'))

A: Thanks for all to answer the question, but I used a little trick to solve the problem in this way
if(@spm='David')
begin

select *
    from Tables with joins
    where ac_jd_date_closed >= convert(VARCHAR(10),dateadd(dd, -@period, getdate()), 101)
    and ac_jd_date_closed <= convert(VARCHAR(10),dateadd(dd, 0, getdate()), 101)
    and lo_pc_last_name not in ('Shroder')
    and lm_ap_pr_id NOT IN (4743, 2683)
end
else
begin
select *
    from Tables with joins
    where ac_jd_date_closed >= convert(VARCHAR(10),dateadd(dd, -@period, getdate()), 101)
    and ac_jd_date_closed <= convert(VARCHAR(10),dateadd(dd, 0, getdate()), 101)
    and lo_pc_last_name not in ('Shroder')
end

means i used the same full query with condition, hope this trick will help someone to solve his issue.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Formula for text object? I'm looking a Crystal Report that someone else wrote (I'm very new to Crystal) and can't work out what a particular field is doing!
I see that you can look at the formula for a field by right clicking and looking at 'edit formula'. However, the option isn't there for this field (it's a text object I think). However, I know that that its value does change - but I can't find what it depends on.
How do I find this out? The text in the template starts with a '@' if that means anything.
Thanks!

A: Well, you seem to be off to a good start with Crystal, at least.  3 Possibilities come to mind:

*

*You are looking at a "Field" object.  In this case, you can try Right-click->Edit Formula. (except you already did that, so we can skip this step).

*You are looking at a "Text Object" into which the previous designer dragged & dropped a Formula. In this case, Double-click the text object to find the complete name of the formula and look it up in the Field Explorer.

*Many objects (including the 2 I just mentioned) allow you to overwrite the standard text based on whatever condition you like.  I try to avoid this myself, but you can right-click->Format Field/Text/Whatever->Common and see if there is a custom formula for Display string.
Based on your description, #2 seems the most likely. Try that one first.


text:
Q: Configuring the MaxMind license in Sitecore The client has purchased a MaxMind license and I have received a license number.  I have also been able to verify the license by hitting the MaxMind webservice directly.  However, I have not been able to find anywhere in the configuration to put the license number.
I found the following line in Sitecore.Analytics.config which looks promising but am not sure if I should simply replace the {1} with my license number.  Is this the right place to do this?
<setting name="MaxMind.Url" value="http://sitecore1.maxmind.com/app/sc?i={0}&l={1}" />

For reference, some of my custom business logic is based on the visitor's geolocation, here is some sample code:
var cv = Sitecore.Analytics.Tracker.CurrentVisit;
var lat = cv.Latitude;
var lng = cv.Longitude;

However lat and lng almost come out as 0 - which is when I realized we need the license.
Sitecore.NET 6.5 (rev. 121009)

A: There is a setting in sitecore/includes/Sitecore.Analytics.config
<!--  MAXMIND SECURITY TOKEN
    Security token from MaxMind.
    Default: "00000000"
-->
<setting name="MaxMind.SecurityToken" value="00000000" />

Set the value to your purchased license (using a patch:config).
http://www.theinsidecorner.com/en/Marketers/SitecoreDMS/EngagementAnalytics/MaxMindSettings


text:
Q: C printf float rounding I have to reimplement printf(3) with C without using any function that would do the conversion for me.
I'm nearly done I just need %a and it's also nearly done thanks to you guys : How %a conversion work in printf statement?
The man says:

The double argument is rounded and converted to hexadecimal notation
  in the style[-]0xh.hhhp[+-]d, where the number of digits after
  the hexadecimal-point character is equal to the precision specification.

So my question is rounded how ?
I found: printf rounding behavior for doubles
And it explains that printf is using banker round or Round half to even but I have no idea how to implement it I have tried this:
a_double = round(a_double * pow(10, precision)) / pow(10, precision)

But on 1000000 tests starting from 0.000001 and adding 0.000001 each time it fails 405201 times, for example with 0.000011:
printf("%.6a", 0.000011) => 0x1.711948p-17
myprintf("%.6a", 0.000011) => 0x1.711947p-17

The rounding 'failed' and I didn't get the same value as the real printf.
I don't think that the algorithm that transforms the double to hexa notation is wrong because with a precision of 13 I have absolutely no errors.
So I just would like to know how I could do the same rounding that printf does on the double.

A: Ok, so I guess my previous algorithm didn't fully implement rounding so let's take a look how the result could be rounded. I'll use your example number as my example number too. First, we find that 0.000011/(2^(-17)) = 0.000011*(2^17) = 1.441792 so the power is -17. Then, we output "1.", subtract 1 from 1.441792 and multiply it by 16, giving 7.068672. We output 7, subtract 7 from it and multiply by 16, giving 1.09875199999999. We output 1, subtract 1 from it and multiply by 16, giving 1.58003199999985. We output 1, subtract 1 from it and multiply by 16, giving 9.28051199999754. Then output 9, subtract 9, multiply by 16, the result is 4.48819199996069. We output 4, subtract 4, multiply by 16, the result is 7.81107199937105.
Now, we're going to output the last character. Now we do the magic. Because 7.81107199937105 is closer to 8 than to 7, we output "8". This magic is done only for the last character. For the non-last characters, the integral part is always used and the fractional part is not used at all in determining which character to output. Then, after this, we output "p-17" because the power was -17.
Note that the usual rounding rules say that 7.5 which is equally close to both 7 and 8 is rounded to 8, not to 7 and 6.5 would be rounded to 7, not to 6. However, if you want to implement the round half to even and you encounter e.g. 6.5 then it is rounded down to 6 because 6 is even and 7 is not. I'm not sure if what you found about the banker round applies also to %a, the only thing you can do is to test implementing various rounding algorithms and see which gives the same results as the real %a of printf. Shouldn't be that hard because the different rounding algorithms just differ on how half is handled. The rest is rounded to the closest number.
By the way, I was wrong in your previous question (How %a conversion work in printf statement?) in saying that for 3.2 which has the non-rounded representation 1.999999....p+1 and the rounded representation 1.99999ap+1 the last "a" would occur due to limited floating point precision. Of course it occurs due to rounding and not due to limited floating point precision, as you probably have realized by now.


text:
Q: How to configure nginx reverse proxy to work during Oauth2 redirect? Disclaimer: I am a real beginner in networking in general and nginx in particular. I set it up for the first time a few days ago.
I have a set up a domain which redirects to a virtual server set up with nginx, on which runs a webapp. This webapp requires me to use SSO (Oauth2 with Google).
After authorizing the service through SSO, I get redirect to an URI starting with http://localhost:8069/google_gmail/confirm?
The webapp is odoo. I would like to know how to configure nginx or the webapp for a successful redirection after logging in with Oauth2.
Thanks!
Contents of /etc/nginx/conf.d/odoo.conf
    bart@odoo-droplet:/opt/odoo15/odoo/debian$
bart@odoo-droplet:/opt/odoo15/odoo/debian$ sudo nano /etc/nginx/conf.d/odoo.conf
  GNU nano 4.8                                                                                /etc/nginx/conf.d/odoo.conf
# Odoo Upstreams
upstream odooserver {
server 127.0.0.1:8069;
}

server {
server_name domain.com;
access_log /var/log/nginx/odoo_access.log;
error_log /var/log/nginx/odoo_error.log;

# Proxy settings
proxy_read_timeout 720s;
proxy_connect_timeout 720s;
proxy_send_timeout 720s;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;

# Request for root domain
location / {
proxy_redirect off;
proxy_pass http://127.0.0.1:8069;
}

# Cache static files
location ~* /web/static/ {
proxy_cache_valid 200 90m;
proxy_buffering on;
expires 864000;
proxy_pass http://127.0.01:8069;
}

# Gzip
gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript;
gzip on;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
    if ($host = domain.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

listen 80;
server_name domain.com;
    return 404; # managed by Certbot

}


text:
Q: How to print input text field in-front drop-down list? How to print drop-down list and input for text and date-range
on same line in this code drop-down list and input field is different line but i want to same line mean input field in-front of drop-down list
please help me i am new in jQuery

function showinput() {
  var value = $("#S1value").val();
  var txt= value.replace(/\_/g, " ");
  var label = $("").attr("for", value).html(txt + ": ");
  switch (value) {
    case "Application_Date":
      var input = $("<input />").attr("type", "text").attr("name", value);
      var input2 = $("<input />").attr("type", "text").attr("name", value + "_2");
      label.append("From: ")
      label.append(input);
      label.append(" To: ");
      label.append(input2);
      $('#beforeSelect').html('').append(label);
      break;
  default:

      var input = $("<input />").attr("type", "text").attr("id", value);
      label.append(input);

 }
  $('#beforeSelect').html('').append(label);

}

$("#S1value").on("change", function() {
   showinput();

});
 showinput();

<select id="S1value" name="S1value">
<option value="Claim"  >Claim - C</option>
<option value="Title"  >Title - T</option>
<option value="Description"  >Description - D</option>
<option value="Abstract" >Abstract - A</option>
<option value="Application_No"  >Application_Number - APN</option>
<option value="Priority_Number"  >Priority_Number - PN</option>
<option value="Record_Number"  >Record_Number - RN</option>
<option value="Priority_Date" >Priority_Date - PD</option>
<option value="Application_Date"  >Application_Date - APD</option>
<option value="Publication_Date"  >Publication_Date - PD</option>
<option value="US_Class" >US_Class - USC</option>
<option value="IPC_Class"  >IPC_Class - IPC</option>
<option value="CPC_Class"  >CPC_Class - CPC</option>
<option value="Priority_Country_Code"  >Priority Country Code - PCC</option>
<option value="Designate_States"  >Designate_States - DS</option>
<option value="Legal_Status_Current"  >Legal_Status_Current - LSC</option>
</select>

A:

    <select id="S1value" name="S1value">
    <option value="Claim"  >Claim - C</option>
    <option value="Title"  >Title - T</option>
    <option value="Description"  >Description - D</option>
    <option value="Abstract" >Abstract - A</option>
    <option value="Application_No"  >Application_Number - APN</option>
    <option value="Priority_Number"  >Priority_Number - PN</option>
    <option value="Record_Number"  >Record_Number - RN</option>
    <option value="Priority_Date" >Priority_Date - PD</option>
    <option value="Application_Date"  >Application_Date - APD</option>
    <option value="Publication_Date"  >Publication_Date - PD</option>
    <option value="US_Class" >US_Class - USC</option>
    <option value="IPC_Class"  >IPC_Class - IPC</option>
    <option value="CPC_Class"  >CPC_Class - CPC</option>
    <option value="Priority_Country_Code"  >Priority Country Code - PCC</option>
    <option value="Designate_States"  >Designate_States - DS</option>
    <option value="Legal_Status_Current"  >Legal_Status_Current - LSC</option>
    </select>

    : <input type="text" id="Application_No">

A:

$(document).ready(function(){
 var newEl = $("<input>");
 newEl.name = $("#S1value");
 $("body").append(newEl);
 $("div").text($("#S1value").val()+":");
$("#S1value").on("change",function(){

$("#beforeSelect").text($(this).val()+":");

});
});

<select id="S1value" name="S1value">
<option value="Claim"  >Claim - C</option>
<option value="Title"  >Title - T</option>
<option value="Description"  >Description - D</option>
<option value="Abstract" >Abstract - A</option>
<option value="Application_No"  >Application_Number - APN</option>
<option value="Priority_Number"  >Priority_Number - PN</option>
<option value="Record_Number"  >Record_Number - RN</option>
<option value="Priority_Date" >Priority_Date - PD</option>
<option value="Application_Date"  >Application_Date - APD</option>
<option value="Publication_Date"  >Publication_Date - PD</option>
<option value="US_Class" >US_Class - USC</option>
<option value="IPC_Class"  >IPC_Class - IPC</option>
<option value="CPC_Class"  >CPC_Class - CPC</option>
<option value="Priority_Country_Code"  >Priority Country Code - PCC</option>
<option value="Designate_States"  >Designate_States - DS</option>
<option value="Legal_Status_Current"  >Legal_Status_Current - LSC</option>
</select>


text:
Q: Geting value from NSMutableArray after using sortedArrayUsingDescriptors I have made a NSDictionary HospitalDictionary which holds latitude,longitude and distances
NSMutableArray *HospitalArray = [NSMutableArray array];
NSDictionary *HospitalDictionary = [[NSDictionary alloc]init];

NSString *LATITUDE = @"latitude";
NSString *LONGITUDE = @"longitude";
NSString *DISTANCE = @"distance";

for (int i=0; i<=100; i++) {
// calculations for coordinates and distance are done ....
HospitalDictionary = [NSDictionary dictionaryWithObjectsAndKeys:latitude, LATITUDE,
        longitude, LONGITUDE,[NSNumber numberWithInt:distanceInKm], DISTANCE, nil];

[HospitalArray addObject:HospitalDictionary];
{

Then data is short using following code
// These line are added to short the Dictionary added to Array List with the Key of Distance
    NSSortDescriptor *distanceDescriptor = [[NSSortDescriptor alloc] initWithKey:DISTANCE ascending:YES];
    id obj;
    NSEnumerator * enumerator = [HospitalArray objectEnumerator];
    NSArray *descriptors = [NSArray arrayWithObjects:distanceDescriptor, nil];
    NSArray *sortedArray = [HospitalArray sortedArrayUsingDescriptors:descriptors];

    enumerator = [sortedArray objectEnumerator];
    // this will print out the shorted list for DISTANCE
    while ((obj = [enumerator nextObject])) NSLog(@"%@", obj);

    // this will return the object at index 1
    NSLog(@"Selected array is %@",[sortedArray objectAtIndex:1]);

Output of this is -
2012-05-30 08:24:42.784 Hospitals[422:15803]
sorted array is
{
    distance = 1;
    latitude = "27.736221";
    longitude = "85.330095";
}

I want to get only Latitude or Longitude for the ObjectAtIndex:1 for the sortedArray. How can i get the particular value ie. latitude out of sortedArray not the complete list.

A: To access a property/method of an object in an array, you can use something like this:
NSLog(@"Latitude for object at index 1 is %@",[[sortedArray objectAtIndex:1] latitude]);


text:
Q: Applescript saving each item from a list as text I have a list of numbers (the number of numbers is random)
for example here is my current result :
Result:
{"1024343495", "84734348416", "100434439171", "86343425", "13434290", "83434946", "81711343497", "43534347319", "863434490"}

I would like to print them in a text file, or save in the clipboard, but this is not working
set the clipboard to myList

so I tried to convert the all as a string :
set the clipboard to myList as string

but then I have just a huge number :
1024343495847343484161004344391718634342513434290834349468171134349743534347319863434490

A: try
set myString to ""
set i to 0
repeat (number of items in myList) times
    set i to i + 1
    set myString to myString & ((item i of myList)as string) &  ", "-- this last bit here is what goes in between each list item
end repeat
return myString

result "1024343495, 84734348416, 100434439171"-etc

A: You can use your code after setting text item delimiters accordingly.
set myList to {"1024343495", "84734348416", "100434439171", "86343425", "13434290", "83434946", "81711343497", "43534347319", "863434490"}
set {TID, text item delimiters} to {text item delimiters, ", "}
set the clipboard to myList as text
set text item delimiters to TID


text:
Q: POI previsualization error with table I've a problem with the visualization of MS Word tables in my Alfresco Share. The tables are always showing outside of the margin, I think it's a problem with OpenOffice (default suite in Alfresco Share). Please find attached  a picture with the error and my source code:
int nCols = 4;
XWPFTable table = doc.createTable(numeroPropuestas+1, nCols); // se le suma uno para añadr la cabecera
// Set the table style. If the style is not defined, the table style
// will become "Normal".
CTTblPr tblPr = table.getCTTbl().getTblPr();

CTTblWidth width = table.getCTTbl().addNewTblPr().addNewTblW();
width.setType(STTblWidth.DXA);
width.setW(BigInteger.valueOf(9072));

CTString styleStr = tblPr.addNewTblStyle();
styleStr.setVal("StyledTable");

// Get a list of the rows in the table
List<XWPFTableRow> rows = table.getRows();
int rowCt = 0;
int colCt = 0;
int filasArrays = 0;
for (XWPFTableRow row : rows) {

    //
    ArrayList<String> alFila = new ArrayList<String>();
    if (rowCt != 0){
        alFila.add(lDescripcion.get(filasArrays));
        alFila.add(lTipo.get(filasArrays));
        alFila.add(lClasificacion.get(filasArrays));
        alFila.add(lResponsable.get(filasArrays));

        filasArrays ++;
    }
    // get table row properties (trPr)
    CTTrPr trPr = row.getCtRow().addNewTrPr();
    // set row height; units = twentieth of a point, 360 = 0.25"
    CTHeight ht = trPr.addNewTrHeight();
    ht.setVal(BigInteger.valueOf(360));

    // get the cells in this row
    List<XWPFTableCell> cells = row.getTableCells();
    // add content to each cell
    for (XWPFTableCell cell : cells) {
        // get a table cell properties element (tcPr)
        CTTcPr tcpr = cell.getCTTc().addNewTcPr();
        // set vertical alignment to "center"
        CTVerticalJc va = tcpr.addNewVAlign();
        va.setVal(STVerticalJc.CENTER);

        // create cell color element
        CTShd ctshd = tcpr.addNewShd();
        ctshd.setColor("auto");
        ctshd.setVal(STShd.CLEAR);
        if (rowCt == 0) {
            // header row
            ctshd.setFill("A7BFDE");
        }
        else if (rowCt % 2 == 0) {
            // even row
            ctshd.setFill("D3DFEE");
        }
        else {
            // odd row
            ctshd.setFill("EDF2F8");
        }

        // get 1st paragraph in cell's paragraph list
        XWPFParagraph para = cell.getParagraphs().get(0);
        // create a run to contain the content
        XWPFRun rh = para.createRun();
        // style cell as desired
        if (colCt == nCols - 1) {
            // last column is 10pt Courier
            rh.setFontSize(10);
            rh.setFontFamily("Courier");
        }
        if (rowCt == 0) {
            // header row
            rh.setText(cabecera[colCt]);
            rh.setBold(true);
            para.setAlignment(ParagraphAlignment.CENTER);
        }
        else if (rowCt % 2 == 0) {
            // even row
            rh.setText( alFila.get(colCt) );
            para.setAlignment(ParagraphAlignment.LEFT);
        }
        else {
            // odd row
            rh.setText(alFila.get(colCt));
            para.setAlignment(ParagraphAlignment.LEFT);
        }
        colCt++;
    } // for cell
    colCt = 0;
    rowCt++;
} // for row


text:
Q: Write Microsoft Forms data to Azure SQL I need to create a data entry form for my users, writing to an existing table in my Azure SQL Server.
At present I'm using Microsoft Forms, exporting the data as an Excel spreadsheet each week and manually loading this in to Azure SQL Server. Can this be achieved using Flow, or is there a better method for data entry forms on Azure?

A: Yes, you can use the Flow. Microsoft Forms connector is available in the Logic Apps、Flow and PowerApps.

For more details, please reference: Introducing the Microsoft Forms connector for Flow.
Here is a tutorial: Building flows from scratch that handle Microsoft Forms responses, It also says: you can route the response to your favorite database service or create a new record in Google Sheet or Excel.
Flow gives you the template: Store Microsoft Forms responses in a SQL Server table:
When a response is submitted through Microsoft Forms, store the submitted form data in a SQL Server table. The table must have the columns: SubmittedBy and SubmitttedDtm.
Hope this helps.


text:
Q: It there any way to get GoogleDriveAPI supported export MIME types list in python or ruby? Before upload a file to GooogleDrive via GoogleDriveAPI, I want to check whether the file's mime type is supported by GoogleDriveAPI.
https://developers.google.com/drive/api/v3/ref-export-formats
We can do that by using an array which contains all mime types inputted manually, but if there are any smart ways, I want to use that.

A: I believe your goal as follows.

*

*You want to retrieve the values of export formats of Google Drive.

*You want to achieve this using googleapis for ruby and python.

In this case, I would like to use the method of "About: get" in Drive API. The sample scripts for ruby and python are as follows.
Sample script: Ruby
service = Google::Apis::DriveV3::DriveService.new
service.authorization = authorize
res = service.get_about(fields: '*')  # or service.get_about(fields: 'exportFormats')
export_formats = res.export_formats
puts export_formats

Sample script: Python
service = build('drive', 'v3', credentials=creds)
res = service.about().get(fields='*').execute()  # or service.about().get(fields='exportFormats').execute()
export_formats = res['exportFormats']
print(export_formats)

Note:

*

*This sample scripts use Drive API v3.

*In this case, you can also use the value of exportFormats instead of * as the fields.

*In this answer, it supposes that you have already been able to get the values from Google Drive using Drive API. Please be careful this.

*By the way, for example, when you want to retrieve the values of importFormats, please modify export_formats = res.export_formats and export_formats = res['exportFormats'] to import_formats = res.import_formats and import_formats = res['importFormats'], respectively.

Reference:

*

*About: get


text:
Q: Is it possible to make more than one Pokémon save file? Is there a way to get a second save file in the game Pokemon Y? I got the game for Christmas and want to share the game with my brother, but I can't without deleting my save file because there is only one save file available.
I've heard some things about having a second SD card to do it, would it be possible with multiple SD Cards? If so, any tips on how to get a second one? How do I install it?

A:
6 Saving and Erasing Data
You can only keep one saved-game file.
6 Saving and Erasing Data (Notes regarding the downloadable version)
You can copy or move your data to a different SD Card, but you cannot use such data as a backup of your save.

Source: The electronic instruction manual accessible before or during play. You can access it by pressing the Home button, and while you have Pokémon X/Y highlighted choose Manual instead of Open/Resume.
While I have not tried personally, I assume there is some way the game prevents multiple save files.
There may be illegitimate ways to gain a second save file, but these could damage your game and/or save. The easiest way is purchasing a second copy. I recommend getting X so you and your brother can help complete each other's Pokédexes.

A: Actually, both games (download+cartridge) save to the sd card. In other words, hell yeah you can have two save games!!! You just need a second sd card. Nice and convenient! ;)


text:
Q: Importing CSV file in Julia : ArgumentError: provide a valid sink argument, like `using DataFrames; CSV.read(source, DataFrame)` I am new to Julia, when i am trying to import csv file
using CSV
CSV.read("C:\\Users\\...\\loan_predicton.csv")

I am getting below error
Error : ArgumentError: provide a valid sink argument, like `using DataFrames; CSV.read(source, DataFrame)`

A: Use:
using CSV
using DataFrames
df = CSV.read("C:\\Users\\...\\loan_predicton.csv", DataFrame)

After you will get some more experience with Julia you will find out that you can read a CSV file into different tabular data formats. That is why CSV.read asks you to provide the type of the output you want to read your data into. Here is a small example:
julia> write("test.csv",
       """
       a,b,c
       1,2,3
       4,5,6
       """)
18

julia> using CSV, DataFrames

julia> CSV.read("test.csv", DataFrame)
2×3 DataFrame
 Row │ a      b      c
     │ Int64  Int64  Int64
─────┼─────────────────────
   1 │     1      2      3
   2 │     4      5      6

julia> CSV.read("test.csv", NamedTuple)
(a = [1, 4], b = [2, 5], c = [3, 6])

and you can see that in the first case you stored the result in a DataFrame, and in the second a NamedTuple.


text:
Q: jQuery - Get value of hyperlink.navigateurl I bind click to a series of asp:hyperlink via the following jquery
$(".dummyIdentifier").click(function () {
            $("#divLineItemComments").dialog("open");
            return false;
        });

This works fine.  Now, I need to pass the value of Hyperlink.NavigateUrl OnClick.  So that I may include the values with ajax $.get()
How can I get the value of a clicked hyperlink?  I do not know it's ID as the hyperlinks are generated dynamically along with their names by ASP.NET.
        <asp:TemplateField HeaderText="Notes" ItemStyle-CssClass="NoMargin NoPadding" SortExpression="lineNotes">
            <ItemTemplate>
                <asp:HyperLink id="notesHl" runat="server" text='<%# Bind("lineNotes") %>' Font-Underline="true" Font-Bold="true" CssClass="dummyPhysicalNoteIdentifier"></asp:HyperLink>
            </ItemTemplate>
            <ItemStyle Font-Size="Smaller" Height="10px" Width="10px" Wrap="True" />
        </asp:TemplateField>

A: You can do it like this:
$(".dummyIdentifier").click(function () {
    $("#divLineItemComments").dialog("open");

    var url = $(this).attr('href');

    return false;
 });


text:
Q: How can I find the current position of the stack without a stack pointer? I was asked in an interview how will you find stack position without using stack pointer you were given with upper bound of stack and depth of stack. I couldn't give the answer. Later I googled the same, but couldn't get one. Can anybody please help me finding the answer.

A: Just create a variable on the stack (i.e. with 'automatic storage') and take its address.
void f() {
    int x;
    printf("Current stack position: %p\n", &x);
}

A: I think is a way to listen the several solution you would give.
So let us start with a fully pointer stack of int:
struct stack{
  int *pos;
  int *start;
  int *end;
}
struct stack new_stack(size_t size)
{
   struct stack * res=malloc(sizeof(struct stack));
   res->start=malloc(sizeof(int)*size);
   res->pos=res->start;
   res->end=res->start+size-1;
}

than the position is gave by:
  return res->pos-res->start;

But I think it was vorbidden;
So let us define a index (this is not pointer):
  struct stack{
  int ix;
  int *array;
  int n;
}
struct stack *new_stack(size_t size)
{
   struct stack * res=malloc(sizeof(struct stack));
   res->array=malloc(sizeof(int)*size);
   res->ix=0;
   res->n=size;
   return res;
}

 //you return
 return res->ix;

Other solution is a placeholder with a not valid value. But is dumb since each time you should score the whole array. (it is like the null terminating strings)
Or otherwise if these two answer where not satisfing the right answer were "it is not possible"
The stack upperbound is possible only if the array is declared static array[100].
than you get upperbound as sizeof(array)/sizeof(*array). But if you are going to write the code for a stack you write it dinamic


text:
Q: SQL Server 2008: FileStream Insertion Failure w/ .NET 3.5SP1 I've configured a db w/ a FileStream group and have a table w/ File type on it. When attempting to insert a streamed file and after I create the table row, my query to read the filepath out and the buffer returns a null file path. I can't seem to figure out why though. Here is the table creation script:

    /****** Object:  Table [dbo].[JobInstanceFile]    Script Date: 03/22/2010 18:05:36 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[JobInstanceFile](
    [JobInstanceFileId] [int] IDENTITY(1,1) NOT NULL,
    [JobInstanceId] [int] NOT NULL,
    [File] [varbinary](max) FILESTREAM  NULL,
    [FileId] [uniqueidentifier] ROWGUIDCOL  NOT NULL,
    [Created] [datetime] NOT NULL,
 CONSTRAINT [PK_JobInstanceFile] PRIMARY KEY CLUSTERED
(
    [JobInstanceFileId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY] FILESTREAM_ON [JobInstanceFilesGroup],
UNIQUE NONCLUSTERED
(
    [FileId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] FILESTREAM_ON [JobInstanceFilesGroup]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[JobInstanceFile] ADD  DEFAULT (newid()) FOR [FileId]
GO

Here's my proc I call to create the row before streaming the file:

    /****** Object:  StoredProcedure [dbo].[JobInstanceFileCreate]    Script Date: 03/22/2010 18:06:23 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

create proc [dbo].[JobInstanceFileCreate]

    @JobInstanceId int,
    @Created datetime

    as

    insert into JobInstanceFile (JobInstanceId, FileId, Created)
    values (@JobInstanceId, newid(), @Created)

    select scope_identity()
GO

And lastly, here's the code I'm using:

    public int CreateJobInstanceFile(int jobInstanceId, string filePath)
        {
            using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConsumerMarketingStoreFiles"].ConnectionString))
            using (var fileStream = new FileStream(filePath, FileMode.Open))
            {
                connection.Open();

                var tran = connection.BeginTransaction(IsolationLevel.ReadCommitted);

                try
                {
                    //create the JobInstanceFile instance
                    var command = new SqlCommand("JobInstanceFileCreate", connection) { Transaction = tran };
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@JobInstanceId", jobInstanceId);
                    command.Parameters.AddWithValue("@Created", DateTime.Now);

                    int jobInstanceFileId = Convert.ToInt32(command.ExecuteScalar());

                    //read out the filestream transaction context to stream the file for storage
                    command.CommandText = "select [File].PathName(), GET_FILESTREAM_TRANSACTION_CONTEXT() from JobInstanceFile where JobInstanceFileId = @JobInstanceFileId";
                    command.CommandType = CommandType.Text;
                    command.Parameters.AddWithValue("@JobInstanceFileId", jobInstanceFileId);

                    using (SqlDataReader dr = command.ExecuteReader())
                    {
                        dr.Read();

                        //get the file path we're writing out to
                        string writePath = dr.GetString(0);

                        using (var writeStream = new SqlFileStream(writePath, (byte[])dr.GetValue(1), FileAccess.ReadWrite))
                        {
                            //copy from one stream to another
                            byte[] bytes = new byte[65536];
                            int numBytes;
                            while ((numBytes = fileStream.Read(bytes, 0, 65536)) > 0)
                                writeStream.Write(bytes, 0, numBytes);
                        }
                    }

                    tran.Commit();

                    return jobInstanceFileId;
                }
                catch (Exception e)
                {
                    tran.Rollback();
                    throw e;
                }
            }
        }

Can someone please let me know what I'm doing wrong. In the code, the following expression is returning null for the file path and shouldn't be:
//get the file path we're writing out to
string writePath = dr.GetString(0);
The server is different then the computer the code is running on but the necessary shares appear to be in order and I have also run the following:
EXEC sp_configure filestream_access_level, 2
Any help would be greatly appreciated. Thanks!

A: You cannot open SqlFileStream on a NULL value. Change the INSERT statement to set File = 0x and it should start working.
PS.
Some performance considerations:

*

*You can avoid the additional round-trip to the server by issuing an INSERT with OUTPUT clause that returns transaction context and file path of the newly inserted blob.

*If you don't intend to read from SqlFileStream, open it for Write only. In this particular case this may not be a big deal, because the file you're opening is empty. But if you're updating a large file, opening it for ReadWrite will have Sql copy the whole file first, and only then let you play with it.


text:
Q: Shuffling an array of strings in vb.net I am developing a webpage in vb.net that will generate a number of multiple choice questions to the user. I need to shuffle the four answers which are already put in an array. Lets assume that I have to following array:
array = {"Correct", "Wrong1", "Wrong2", "Wrong3"}

I tried to use the following method:
Public Shared Function Shuffle(ByVal items() As String) As Array
        Dim max_index As Integer = items.Length - 1
        Dim rnd As New Random(DateTime.Now.Millisecond)
        For i As Integer = 0 To max_index
            ' Pick an item for position i.
            Randomize()
            Dim j As Integer = rnd.Next(i, max_index)
            ' Swap them.
            Dim temp As String = items(i)
            items(i) = items(j)
            items(j) = temp
        Next i
        Return items
    End Function

The function is working really fine, but my problem is that if I have four questions, the answers will be shuffled for each question but the correct answer will be in one position like:
    array = {"Wrong1", "Correct", "Wrong2", "Wrong3"}
    array = {"Wrong2", "Correct", "Wrong3", "Wrong1"}
    array = {"Wrong3", "Correct", "Wrong1", "Wrong2"}
    array = {"Wrong1", "Correct", "Wrong3", "Wrong2"}

What I need is the correct answer to change its location from one question to another.
Your help is appreciated.

A: There are several issues with your your Shuffle method and use of Random.

*

*Randomize is for use with the old, legacy VB Rnd function.  It has no impact on the shiny new NET Random class.

*There is rarely a need to provide a custom seed; in fact this can work against you.

*Create one Random for the entire app to use rather than each time you shuffle (or click something).  And never create them in a loop - this almost guarantees repeated numbers.

*The max argument to Random.Next(min, max) is exclusive, so your range is actually 1 element smaller than it should be.

*Your Shuffle is pretty close, but has a few flaws:

*

*Generally the NET version of the Fisher-Yates Shuffle is an in place shuffle (Sub) making it very efficient (rather than returning a new collection)

*It is important to loops backwards thru the list or array.1
The Standard Fisher-Yates Shuffle:
' form/class level var
Private rnd As New Random()

Public Sub Shuffle(items As String())
    Dim j As Int32
    Dim temp As String

    For n As Int32 = items.Length - 1 To 0 Step -1
        j = rnd.Next(0, n + 1)
        ' Swap them.
        temp = items(n)
        items(n) = items(j)
        items(j) = temp
    Next n
End Sub

Output from 4 shuffles of the same starting array:
Shuffle #1    Wrong3   Correct  Wrong2   Wrong1
Shuffle #2    Correct  Wrong2   Wrong1    Wrong3
Shuffle #3    Wrong2   Correct  Wrong3    Wrong1
Shuffle #4    Correct  Wrong1   Wrong2    Wrong3
Shuffle #5    Correct  Wrong1   Wrong3    Wrong2

Variations
Rather than a global Random generator, you can pass it (useful as an extension method):
Public Sub Shuffle(items As String(), RNG As Random)

Generic method for shuffling many types:
' Generic shuffle for basic type arrays
Public Sub Shuffle(Of T)(items As T(), rng As Random)
    Dim temp As T
    Dim j As Int32

    For i As Int32 = items.Count - 1 To 0 Step -1
        ' Pick an item for position i.
        j = rng.Next(i + 1)
        ' Swap
        temp = items(i)
        items(i) = items(j)
        items(j) = temp
    Next i
End Sub

Examples:
Shuffle(intArray, myRnd)
Shuffle(strArray, myRnd)
Shuffle(colors, myRnd)
Shuffle(myButtons, myRnd)

Simple Reordering
Finally, for something simple where you might only reorder them once, a simple and usually-good-enough version using an extension method:
Dim ShuffledItems = myItems.OrderBy(Function() rnd.Next).ToArray()

This has less code and is easy to dash off, but is much less efficient.
1 The reason that you want to loop backwards is to limit each array element to one swap.  Once "X" is moved to items(j) in the last step, that position is removed from consideration because rnd.Next(0, n + 1) will only pick up to the last element/loop index.  Many implementations get this wrong.


text:
Q: Why callback from wcf service is so slow (especially the first time) I have a service that sends several callbacks per second to connected clients. Why when the service sends a message do the clients get them a few or more seconds later?
Here are the configuration details:
        <bindings>
                  <wsDualHttpBinding>
                    <binding name="WSDualHttpBinding_IMyService" receiveTimeout="00:30:00"
    sendTimeout="00:30:00" useDefaultWebProxy="false" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">

                      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                      <security mode="None"/>
                    </binding>
                  </wsDualHttpBinding>
                </bindings>
                <behaviors>
                  <serviceBehaviors>
                    <behavior name="Service1Behavior">
                      <serviceMetadata httpGetEnabled="True"/>
                      <serviceDebug includeExceptionDetailInFaults="True"/>
                      <serviceThrottling maxConcurrentCalls="10"
                                maxConcurrentInstances="10"
                                maxConcurrentSessions="5" />
                    </behavior>
                  </serviceBehaviors>
                </behaviors>

A: What you describe could be related to thread creation time.
See here: WCF service may scale up slowly under load
"Depending on the execution time and number of requests received you may notice the WCF execution time increase linearly by approximately 500ms for each request received until the process has created sufficient IOCP threads to service the requests or sustain the incoming load."
A workaround is provided in the article.

A: I'm dealing with the same problem, looking at these links to address the issue.
The overview seems that, out-of-the-box, WCF is 'locked down' to prevent DoS vulnerabilities. Essentially, you need to un-throttle the service as described in the links below.
http://theburningmonk.com/2010/05/wcf-improve-performance-with-greater-concurrency/
http://blogs.msdn.com/b/wenlong/archive/2010/02/11/why-are-wcf-responses-slow-and-setminthreads-does-not-work.aspx
http://weblogs.asp.net/sweinstein/archive/2009/01/03/creating-high-performance-wcf-services.aspx


text:
Q: Defect of subnormality and repeated normalizer series Let $G$ be a a finite group and $S$ a subnormal subgroup of $G$. The lenght of a fastest chain of subgroups $(U_i)_{1\le i\le n}$ such that $U_1=S$, $U_i$ normal in $U_{i+1}$ and $U_n=G$ is called the defect of subnormality of $S$. Examples in $S_4$ Show that the series of repeated normalizers can be stable and is not reaching the whole group for a subnormal subgroup. But for nilpotent groups this series reaches $G$. My question: Is the length of this series exactly the defect of subnormality for nilpotent groups?

A: Let H be a cyclic group of order 2 and let K be the dihedral group of order 8 with y a non-central element of order 2. Then let G be the wreath product of H by K with base group B.
Then $J = \langle H,Hy\rangle$ is normal in B which is normal in G. But the normalizer of J in G is $B\cdot \langle y \rangle$, which is not normal in G.


text:
Q: Proof for solving linear congruence
Show that the equation $$
  a x \equiv b \bmod{n} \; \quad a, b \in \mathbb{Z}\, , n \in \mathbb{N}
$$ with $d:= \gcd(a,n)$ has no solution if $d \nmid b$. But if $d \mid b$, it is equivalent to $$
  x \equiv y \frac{b}{d} \bmod{\frac{n}{d}}
$$ with $y\in \mathbb{Z}$ chosen so, that $y a + z n = d$ for a $z \in \mathbb{Z}$.

Proof: $d \nmid b \Rightarrow d \nmid (a x - b) \Rightarrow n \nmid (a x - b)$, so there can be no solution.
Now $d \mid b$, then Bézout's identity guarantees the existence of $y$. Also we see that $$a x \equiv b \bmod{n} \Leftrightarrow \frac{a}{d} x \equiv \frac{b}{d} \bmod{\frac{n}{d}}\, .$$
Since $\frac{a}{d}$ and $\frac{n}{d}$ are coprime, $\frac{a}{d} \in \Bigl(\mathbb{Z}/\bigl(\frac{n}{d}\bigr)\mathbb{Z}\Bigr)^{\times}$ and its inverse is obviously $y$.
Multiplication with the unit $y$ is injective (this is in general not true for all elements — the ring might not be an integral domain), which means the following equations are equivalent:
$$\frac{a}{d} x \equiv \frac{b}{d} \bmod{\frac{n}{d}} \Leftrightarrow y \frac{a}{d} x \equiv y \frac{b}{d} \bmod{\frac{n}{d}}\, .$$ With $y\frac{a}{d} \equiv 1 \bmod{\frac{n}{d}}$ we're done. $\square$

Could you please check if my proof is correct? Thank you!


text:
Q: How to check if a page is ghosted We are trying to resolve some performance issues at a remote site.
One thing that we suspect could be causing the performance problem is page ghosting.
Is there some way to see if the pages that are being called are ghosted?

A: In my experience, the ghosted/unghosted thing is a total SharePoint myth.  If you're having significant performance issues with a page, I sincerely doubt that this is the problem.  I'd look more at what Web Parts are on the page and what you're asking them to do.

A: Solving performance issues in SharePoint by second guessing what the problem could be could be a very long and tedious process.
What you should do is give the site a thorough check-up for issues that could affect performance (and yes closed web parts is one on a probably very long list).
Other candidates:

*

*large site collections(>100gb), large lists (>2000 items ) etc (read
Plan for Software Boundaries on
TechNet)

*is caching enabled? Output caching, BLOB caching, HTTP compression

*custom code. Probably the worst contributor for bad performance. Is
specific pages slow or is the pages
slow in general? Does your code
dispose its SPRequest objects (watch
memory consumption). Read this
and this.

*alerts in eventlog or 12 hive logs. low disk space? low on memory? are
you using 32-bit?

*sql server is the heart beat of a well performing SharePoint. Check for
alerts in event log.

*faulty NIC. I have seen this wreck performance on an otherwise well
performing site.

*how large is the footprint of your pages? If you need to load tons of
CSS, JS and images by every request
(without caching them) this could
kill performance as well.

*in general: is your servers set up according to best practices? Read
more on technet
This was a few of the issues i would consider, again depending on what kind of patterns for bad performance you experience (you dont describe this in your question).

A: I asssume by 'called' you mean by the browser.
If you just want to see if a given page is customised then you can look at the pages in SharePoint Designer as this will show you quickly which ghosted pages have subsequently been customised.
customized file in SPD http://www.code-storm.co.uk/resources/pb/Customized.png
Of course if you need to do it via code then this is not a viable approach.
Have you checked out the site with Fiddler to see what is happening under the covers?

A: As Marc said the issue may not be the ghosted/unghosted status of the page but...if you do want to check the status of the page then SharePoint Manager is a really useful tool for looking at properties of SharePoint objects. This should save any time writing code to do the check and if the page is unghosted then 'customizedpagestatus' will show customized.

A: As Marc said above, check the number of web parts and what they are doing.  Especially check if there are a large number of 'Closed' web parts hiding behind the scenes from power users not understanding the difference between Delete and Close.  They are not visible but will continue to consume all those resources.  Almost every time I assist someone with a performance issue on a site, its due to >= 10 Closed web parts.

A: Another issue to check and this may seem strange is to find out if you have custom built webparts that have code. It is possible that some of them may not be properly releasing the resources they used. This is just an addition to the other points already mentioned.

A: My 5 cents: If that's an option at all, you could check the ASP.NET trace timing to see the shares of each control rendering or not rendering in the page's control tree. See web.config/system.web/trace for the application pool in question and add trace.axd in the url (or set the pageOutput attribute to 'true' for the trace element in the web.config).


text:
Q: grails render list of checkboxes I've scoured the web for almost a day and can't seem to find a solution to my problem.
I have a lookup table called Hobby which has a bunch of hobbies in it (camping, hiking, biking, etc).  The hobbies table is populated during the bootstrap.  Grails creates a hobby table with an id, and description field.
I have a domain object called Applicant.  An applicant can have zero or more hobbies.  I've declared the domain like this:
class Applicant {

    static hasMany = [hobbies:Hobby]
List <Hobby> hobbies = LazyList.decorate(new ArrayList(), FactoryUtils.instantiateFactory(Hobby.class));

}
In my controller I'm using a command object for the page that will allow the applicant to select their hobbies.  It is defined as:
class LifestyleCommand {

    List <Hobby> hobbies = LazyList.decorate(new ArrayList(), FactoryUtils.instantiateFactory(Hobby.class));
}

My gsp looks like this:
                <g:each var="item" in="${Hobby.list()}" status="i">

                    <g:set var="newline" value="${(i % 3) == 0 ? 'newline' : ''}" />

                        <g:checkBox name="hobbies_${item.id}" optionKey="id" value="${item.id}" />
                        ${item.description}

                </g:each>

The page will display all of the hobbies in the page correctly.  However when I try to submit the form back to the controller the list in the LifeStyleCommand object is null.  I'm not sure if my gsp has the g:checkBox variables set correctly, and I'm not sure if I declared the List in the command object correctly either.  Once I get the data to be sent back to the controller, my next problem to overcome will be copying the data from the command object to the Applicant.  Any help would be appreciated.
I've tried using just a plain List in the command but grails complains about type conversions when the form is submitted.
EDIT:
Here is what I got to work:
class Applicant {

    static hasMany = [hobbies:Hobby]
//I removed the List <hobby>... code
...
}

My command object:
class LifestyleCommand {
    Set <Hobby> hobbies;
}

gsp:
            <g:each in="${Hobby.list()}" var="hobby">
                <g:set var="checked" value="${ command?.hobbies.find{h->h.id == hobby.id } != null }" />
                <g:checkBox value="${checked}" name="${ 'hobby' +'[' + hobby.id + ']'}"/>${hobby.description}
            </g:each>

And my new controller code:
Hobby.list().each{hobby->
    if (params["hobby[${hobby.id}]"] == 'on') {
        applicant.addToHobbies(hobby)
    }
    else if (applicant.getHobbies().contains(hobby)) {
        applicant.removeFromHobbies(hobby)
    }
}

Everything is working.  There may be better ways, and I haven't done any refactoring yet but having it work is a starting point.

A: The problem is with your GSP. When you need a list of objects, you have to maintain a standard name for your checkbox:
<g:checkBox name="hobbies[$i].id" ... />

This will be mapped correctly to your command list.


text:
Q: Using sequential observations to perform online prediction I'm trying to perform predictions from a sequence of events. My problem is this:
Data collection:
Suppose you can continuously observe a person sitting in a library. You take note of every time that the person checks his smartphone, goes to the restroom, or is reading. At some point after several hours, the person then gets up and leaves. Assume that you can do this for several days to get a lot of data.
Problems to be solved:
Now, suppose I can perform observations only at sparse discrete points in time (e.g. once every 10 or 20 minutes). I would like to perform online (in real-time, with a short window) the following two computations:
Given a sequence of sparse online observations of either (a) using smartphone, (b) going to restroom, or (c) reading, I would like to know the probability that the user will next be reading for more than t minutes. For example, if the user has a habit of checking his smartphone and then starts reading uninterrupted for 20 minutes, then if I make an online observation that he is indeed checking his smartphone, then I would say that the probability he will read for more than 10 minutes is, say, 0.90. I would as few needed observations as possible.
If I want to determine when the user will get up and leave within the next t minutes with some threshold probability, how would I schedule the minimal number of needed observations?
I have been reading up on Markov chains, HMMs, and random walks, but my problem seems to be a bit different from what I've read.
Any help would be appreciated.


text:
Q: Constantly Run a Service and check a value of a Variable I had created some code that would tell me if the users window scrolled beyond a certain point. I quickly realised that this needed to be a service as other components needed this info as well.
I had used @HostListener in the logic and would get results. Now that this is all in a service, I only know if the window was scrolled beyond a certain point when I call the service.
The issue is, how do I constantly call the service? The service has a Boolean in it that I need real-time info on.
Service
import { Injectable, OnInit, HostListener, Inject } from '@angular/core';
import { DOCUMENT } from '@angular/platform-browser';

@Injectable()
export class WindowScrollService {
  public navIsFixed: boolean = false;
  constructor(@Inject(DOCUMENT) private document: Document) {

   }
   @HostListener("window:scroll", [])
  onWindowScroll() {
    let number = this.document.body.scrollTop;
    if (number > 20) {
      this.navIsFixed = true;
      console.log(this.navIsFixed);
    } else if (this.navIsFixed && number < 10) {
      this.navIsFixed = false;
      console.log(this.navIsFixed);
    }
  }
}

Component
import { Component, OnInit } from '@angular/core';
import { WindowScrollService } from '../window-scroll.service';

@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.scss']
})
export class HeaderComponent implements OnInit {
  public navIsFixed: boolean;

  constructor( private windowscrollservice  : WindowScrollService) {
  this.navIsFixed = this.windowscrollservice.navIsFixed;

  }
  ngOnInit(){
    this.windowscrollservice.onWindowScroll()
  }
}

A: Use setInterval to repeatedly run some code. One possible implementation
import { Component, OnInit } from '@angular/core';
import { WindowScrollService } from '../window-scroll.service';

@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrls: ['./header.component.scss']
})
export class HeaderComponent implements OnInit {
  public navIsFixed: boolean;
  public interval;

  constructor( private windowscrollservice  : WindowScrollService) {
  this.navIsFixed = this.windowscrollservice.navIsFixed;

  }
  ngOnInit(){
    // run every 500ms
    this.interval = setInterval(() => this.windowscrollservice.onWindowScroll(), 500);
    // use clearInterval(this.interval) to stop
  }
}


text:
Q: React anti pattern? Is the following an anti pattern in React? I like the pattern because it gives me context in static functions when a component has been instantiated. Then later I can import the class and call a static method to modify state. Or can this be done in a better way?

// componentA.js

function bleedContext() {
  ComponentA.staticMethod = ComponentA.staticMethod.bind(this)
}

export default class ComponentA {
  static staticMethod() {
    this.setState({foo: 'bar'})
  }

  constructor() {
    this.state = {}
    bleedContext.call(this)
  }

  render() {
    return (
      ...
    )
  }
}

// componentB.js

import ComponentA from 'path/to/componentA'

export default class ComponentB {
  handleClick() {
    ComponentA.staticMethod()
  }

  render() {
    return (
      <button onClick={this.handleClick} />
    )
  }
}

A: This is clearly an antipattern and possibly a mistake, depending on conditions. Static class method shouldn't operate with class instance. staticMethod is bound to specific component instance and uses setState, this could be only justified a class is a singleton (though a singleton is often an antipattern, too). This will result in bugs and memory leaks if more than one class instance is expected, and every React component is expected to have more than one instance, at least for testing.
A proper way for two independent components to interact with each other in React is to have a common parent component that provides this interaction, e.g.:
class ModalContainer extends Component {
  modalRef = React.createRef();

  render() {
    return <>
      <Modal ref={this.modalRef} />
      <SomeComponentThatUsesModal modalRef={this.modalRef} />
    </>;
  }
}

The problem with example above is that this will require to pass modalRef prop deeply if <SomeComponentThatUsesModal> is nested.
This problem is solved with React context or other third-party global state solutions like Redux.
This can be done with React 16.3 context API, considering that Modal class instance has open method:
const ModalContext = React.createContext();

function getModal(modalRef) {
  return {
    open: data => modalRef.current.open(data);
    close: () => modalRef.current.close();
  }
}

class ModalContainer extends Component {
  modalRef = React.createRef();

  render() {
    return <>
      <Modal ref={this.modalRef} />
      <ModalContext.Provider value={getModal(this.modalRef)}>
        {this.props.children}
      </ModalContext.Provider>
    </>;
  }
}

Then for any deeply nested component modal object with open and close methods will be available via context:
const SomeComponentThatUsesModal = props => <div>
  <ModalContext.Consumer>
    {modal => <button onClick={() => modal.open('foo')} />}
  </ModalContext.Consumer>
</div>;

<ModalContainer>
  ...deeply nested component
  <SomeComponentThatUsesModal />
  ...
</ModalContainer>

Here's a demo.


text:
Q: g++ and clang++ different behaviour inferring the template return type of a function Another "who's right between g++ and clang++?" question for C++ standard gurus.
The following program
#include <iostream>

void foo (int v)
 { std::cout << "foo(), int version (" << v << ')' << std::endl; }

void foo (double v)
 { std::cout << "foo(), double version (" << v << ')' << std::endl; }

template <typename T, typename R>
void bar (T v, R(*fn)(T))
 { fn(v); }

int main ()
 { bar(1, foo); }

compile and run with g++ (6.3.0, but also with 8.0.0 according Wandbox) but compiling it with clang++ (3.9.1, but also with 6.0.0 according Wandbox) I get the following error
tmp_002-11,14,gcc,clang.cpp:29:4: error: no matching function for call to 'bar'
 { bar(1, foo); }
   ^~~
tmp_002-11,14,gcc,clang.cpp:25:6: note: candidate template ignored: couldn't
      infer template argument 'R'
void bar (T v, R(*fn)(T))
     ^
1 error generated.

As usual the question is: who's right? g++ or clang++?

A: Clang is correct, but for a subtle reason: an overload set is allowed during template deduction, but deduction on that one argument must be able to select one of them for anything to be deduced.  (If zero match, the overall deduction fails; if more than one does, deduction ignores that argument.)  Here, both foos match R(*fn)(T), so R cannot be deduced from that argument (even though they would both agree on it), and thus not at all.


text:
Q: Realtek and USB Wi-Fi Adapters not Found in Ubuntu 18.04 Folks,
I have a Lenovo Legion Y7000 with dual boot system (Win10 and Ubuntu 18.04). The internal wireless card is Realtek 8822be and I have also attached a Panda wireless USB drive (as I was unable to get the internal wireless card working). When I go to Wi-Fi Settings in Ubuntu, I see "No Wi-Fi Adapter Found" for both internal and USB Wi-Fi drives. But the following commands actually show that Ubuntu has detected my Wi-Fi chips:
o-vh@o-vh:~$ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 04ca:7070 Lite-On Technology Corp.
Bus 001 Device 003: ID 046d:c52f Logitech, Inc. Unifying Receiver
Bus 001 Device 005: ID 0bda:b023 Realtek Semiconductor Corp.
Bus 001 Device 002: ID 148f:5372 Ralink Technology, Corp. RT5372 Wireless Adapter
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Also,
o-vh@o-vh:~$ iwconfig
wlp7s0    IEEE 802.11  ESSID:off/any
          Mode:Managed  Access Point: Not-Associated   Tx-Power=20 dBm
          Retry short limit:7   RTS thr=2347 B   Fragment thr:off
          Power Management:on

enp8s0    no wireless extensions.

wlx7cdd90764d5b  IEEE 802.11  ESSID:off/any
          Mode:Managed  Access Point: Not-Associated   Tx-Power=0 dBm
          Retry short  long limit:2   RTS thr:off   Fragment thr:off
          Power Management:off

lo        no wireless extensions.

which is not clear to me, as it seems that two wireless cards are detected, but I still see two no wireless extensions. messages. Finally, when I run lshw -C network, I see:
  *-network
       description: Wireless interface
       product: RTL8822BE 802.11a/b/g/n/ac WiFi adapter
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:07:00.0
       logical name: wlp7s0
       version: 00
       serial: 48:5f:99:b2:fd:e7
       width: 64 bits
       clock: 33MHz
       capabilities: bus_master cap_list ethernet physical wireless
       configuration: broadcast=yes driver=r8822be driverversion=4.15.0-50-generic firmware=N/A latency=0 link=no multicast=yes wireless=IEEE 802.11
       resources: irq:143 ioport:4000(size=256) memory:a4300000-a430ffff
  *-network
       description: Ethernet interface
       product: RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
       vendor: Realtek Semiconductor Co., Ltd.
       physical id: 0
       bus info: pci@0000:08:00.0
       logical name: enp8s0
       version: 15
       serial: e8:6a:64:c1:75:66
       size: 100Mbit/s
       capacity: 1Gbit/s
       width: 64 bits
       clock: 33MHz
       capabilities: bus_master cap_list ethernet physical tp mii 10bt 10bt-fd 100bt 100bt-fd 1000bt 1000bt-fd autonegotiation
       configuration: autonegotiation=on broadcast=yes driver=r8169 driverversion=2.3LK-NAPI duplex=full firmware=rtl8168h-2_0.0.2 02/26/15 ip=192.168.88.187 latency=0 link=yes multicast=yes port=MII speed=100Mbit/s
       resources: irq:17 ioport:3000(size=256) memory:a4204000-a4204fff memory:a4200000-a4203fff
  *-network DISABLED
       description: Wireless interface
       physical id: 1
       bus info: usb@1:1
       logical name: wlx7cdd90764d5b
       serial: 7c:dd:90:76:4d:5b
       capabilities: ethernet physical wireless
       configuration: broadcast=yes driver=rt2800usb driverversion=4.15.0-50-generic firmware=N/A link=no multicast=yes wireless=IEEE 802.11

Note that for the USB Wi-Fi I see *-network DISABLED while I don't see this for the Realtek Wi-Fi.
Can anyone give me some hints on what the problem is and how I can fixed the "No Wi-Fi Adapter Found" issue? I appreciate your help very much!
I have tried many of the approaches suggested for similar (but not identical) problems without any success.


text:
Q: how to use one function of a script in another script in unity using c# i am making a game in unity with c#
i wanted to use a function of a script in another script
1st script name player controller
using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {

public Vector2 moving = new Vector2();
public int Bulletlimit = 0;
public int MaxBulletlimit = 3;

public Bullet bullet;
// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

    moving.x = moving.y = 0;

    if (Input.GetKey ("right")) {
        moving.x = 1;
    } else if (Input.GetKey ("left")) {
        moving.x = -1;
    }

    if (Input.GetKey ("up")) {
        moving.y = 1;
    } else if (Input.GetKey ("down")) {
        moving.y = -1;
    }

    if (Input.GetKey ("s")) {

        BulletShot();
}

}

public void BulletShot(){
    if(Bulletlimit < MaxBulletlimit)
    {
        Bullet clone = Instantiate (bullet, transform.position, Quaternion.identity) as Bullet;
        Bulletlimit = Bulletlimit + 1;
    }
}

public void BulletCount()
{
    Bulletlimit = Bulletlimit - 1;
}
}

2nd script name Bullet Destroy
using UnityEngine;
using System.Collections;

public class BulletDestroy : MonoBehaviour {

private Player player;
private PlayerController playerController;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}

public void OnTriggerEnter2D(Collider2D target){
    if (target.gameObject.tag == "Deadly") {
        Destroy (gameObject);
    }

}

public void OnCollisionEnter2D(Collision2D target){
    if (target.gameObject.tag == "Deadly") {
        Destroy (gameObject);
        }
}
}

how do i call the BulletCount function from playercontroller script to BulletDestroy Script in the if condition

A: You can do this the efficient C# way or the Mono Way which is recommended for beginners if they don't know all the C# procedures.
1st is by inhering from another Class. Which I will not discuss because it may give you some problem in the future, if you don't know how to it works.
2nd is one is by Getting the Component from the Player. If in your game, the player is tagged as a Player then let us use that reference. Or at lease the name of the Player GameObject.
PlayerController myCharactersScript;
void Start(){
     myCharactersScript = GameObject.Find("myCharactersName").GetComponent<PlayersController>();

}

public void OnTriggerEnter2D(Collider2D target){
if (target.gameObject.tag == "Deadly") {
    Destroy (gameObject);
   myCharactersScript.BulletCount();
}

}

I suggest for you to read about Inheritance for good coding practice as it is one of the Main Core of C#. FYI you can only Inherit once.


text:
Q: wp_set_object_terms() return invalid_taxonomy i tried to set the taxonomy of  a post but it always return invalid_taxonomy error.
$categorys_ids = wp_set_object_terms($post_id, $categorys, 'categorie-video');
            error_log('categorys brut = ' . $data['category'] .'postid '.$post_id.'categorys = ' . json_encode($categorys_ids));

            //byme
            if (is_wp_error($categorys_ids)) {
                error_log('categorys =There was an error somewhere and the terms couldn\'t be set');
            } else {
                error_log('categorys =Success! The post\'s categories were set.');
            }


text:
Q: Using the keys of an object literal as a Typescript type? I have an object which contains some predefined data for my application, which is stored in a const variable like this:
const data:{[key:string]:any} =Object.freeze({
    some: 123,
    long: {"a":"b"},
    list: ["c"],
    of: "",
    arbitrary: null,
    things: 1.2,
});

The keys of this object are known to the rest of the application. Consider this function which accesses the data object:
function doWork(k) {
    if(!data.hasOwnProperty(k)) throw Error();
    let value = data[k];
    //...
}

This is called with strings like
doWork("things");

I would like to replace that runtime error for invalid keys with a Typescript compile-time check. I would like to be able to write
function doWork(k: keyof data) {
    let value = data[k];
    //...
}

But apparently the keyof operator does not work that way. I get an error TS2304: Cannot find name 'data'.

My workaround:
I can extract the keys of the object with something like this:
console.log("\""+Object.keys(data).join("\"|\"")+"\"");

Which I can then copy/paste and define as a type.
type data_key = "some"|"long"|"list"|"of"|"arbitrary"|"things"
export function doWork(k:data_key) {
    let value = data[k];
    //...
}

This feels like a silly hack and is quite inconvenient whenever I have to make a change, because I have to remember to put in this statement at the right place, run the program, and manually copy in the values back into the source code (or realistically, just type in the changes myself).

I am open to a better solution. Is there a language feature that provides the functionality I am looking for?

A: Let TypeScript infer the type of data, then extract the keys from the type it infers by using type data_key = keyof typeof data;:
const data = Object.freeze({
    some: 123,
    long: {"a":"b"},
    list: ["c"],
    of: "",
    arbitrary: null,
    things: 1.2,
});

type data_key = keyof typeof data;

function doWork(k: data_key) {
    let value = data[k];
    //...
}

On the playground.
How that works:

*

*TypeScript has advanced type inference and so is able to infer the type of the object initializer passed into Object.freeze with the keys some, long, list, etc. Object.freeze is defined as freeze<T>(o: T): Readonly<T>¹ so it returns a Readonly version of that same inferred type.

*keyof gets the keys of a type.

*typeof in this context is TypeScript's typeof, not JavaScript's. In TypeScript, there are places it expects runtime value, and other places it expects compile-time types. keyof's operand is a place where a compile-time type is expected, so typeof data returns the compile-time type of data, which is the Readonly version of the inferred type from freeze (with the keys some, long, list, etc.). (If you had x = typeof data, that would be typeof in a context where a runtime value is expected, so it would be JavaScript's typeof, and x would get the runtime value "object".)

¹ There are actually three definitions of freeze in lib.es5.d.ts (one for arrays, one for functions, and one for all other kinds of objects; this is that last one).


text:
Q: finding extreme points for Lagrangian with multiple inequality constraints I am trying to find maximum of
\begin{equation}
f(x, y) = x^2 - xy + y - 4x
\end{equation}
\begin{equation}\label{constraints}
\text{s.t. } 0 \leq x \leq  2 \text{ and } 0 \leq y \leq 1
\end{equation}
I got an advice to first check for the interior solution (it has none there is one saddle point at [1,-2] and afterwards check each constraint separately, but I am not sure if what I did is correct and how to proceed with finding extreme points at the boundaries
\begin{equation}
\begin{aligned}
0=x; 0=y \\
0=x; 1=y \\
2=x; 0=y \\
2=x; 1=y \\
\end{aligned}
\end{equation}
Now we can set up 4 Lagrangians to check for each boundary:
\subsubsection*{First Lagrangian:}
\begin{equation}
\mathcal{L} = x^2 - xy + y - 4x - \lambda_1(-x) - \lambda_2 (-y)
\end{equation}
with FOCs
\begin{equation}
\begin{aligned}
\frac{\partial \mathcal{L} }{\partial x} & =  2x - y -4 + \lambda_1 = 0\\
\frac{\partial \mathcal{L}}{ \partial y} & =  -x + 1 + \lambda_2 = 0 \\
x&=0\\
y&=0
\end{aligned}
\end{equation}
hence here $x=y=0$ and $\lambda_1 = 4$ and $\lambda_2=-1$
\subsubsection*{Second Lagrangian:}
\begin{equation}
\mathcal{L} = x^2 - xy + y - 4x - \lambda_1(-x) - \lambda_2 (-y)
\end{equation}
with FOCs
\begin{equation}
\begin{aligned}
\frac{\partial \mathcal{L} }{\partial x} & =  2x - y -4 + \lambda_1 = 0\\
\frac{\partial \mathcal{L}}{ \partial y} & =  -x + 1 + \lambda_2 = 0 \\
x&=0\\
y&=1
\end{aligned}
\end{equation}
hence here $x=y=0$ and $\lambda_1 = 3$ and $\lambda_2=-1$
\subsubsection*{Third Lagrangian:}
\begin{equation}
\mathcal{L} = x^2 - xy + y - 4x - \lambda_1(-x) - \lambda_2 (-y)
\end{equation}
with FOCs
\begin{equation}
\begin{aligned}
\frac{\partial \mathcal{L} }{\partial x} & =  2x - y -4 + \lambda_1 = 0\\
\frac{\partial \mathcal{L}}{ \partial y} & =  -x + 1 + \lambda_2 = 0 \\
x&=0\\
y&=1
\end{aligned}
\end{equation}
hence here $x=y=0$ and $\lambda_1 = 3$ and $\lambda_2=-1$
\subsubsection{Fourth Lagrangian}
\begin{equation}
\mathcal{L} = x^2 - xy + y - 4x - \lambda_1(-x) - \lambda_2 (-y)
\end{equation}
with FOCs
\begin{equation}
\begin{aligned}
\frac{\partial \mathcal{L} }{\partial x} & =  2x - y -4 + \lambda_1 = 0\\
\frac{\partial \mathcal{L}}{ \partial y} & =  -x + 1 + \lambda_2 = 0 \\
x&=2\\
y&=1
\end{aligned}
\end{equation}

A: Since $f$ is a quadratic function having a saddle point it is not convex.
In order to find the maximum of $f$ on the boundary $\partial R$ of the given rectangular domain $R$ just pull back $f$ to the four edges of $R$, i.e., consider the four auxiliary functions
$$\eqalign{&\phi_0(y):=f(0,y)=y,\quad\phi_2(y)=f(2,y)=-y-4\qquad\qquad(0\leq y\leq 1),\cr &\psi_0(x):=f(x,0)=(x-2)^2-4,\quad \psi_1(x):=f(x,1)=(x-2.5)^2-5.25\qquad(0\leq x\leq2)\ .\cr}$$
Since all four of these functions are monotone on the relevant intervals we can conclude that
$$\max_{(x,y)\in R}f(x,y)=\max\bigl\{f(0,0),f(2,0),f(0,1),f(2,1)\bigr\}=1\ .$$


text:
Q: I cant remove duplicate post from mn_postmeta, need SQL advice I ran the provided SQL command on my websites SQL database
and accidentally posted the same data twice, now I want to remove what I posted
I tried using a Delete From command but it did not work, maybe my syntax was wrong
INSERT INTO `mn_postmeta` (`post_id`,`meta_key`,`meta_value`) VALUES (24410,'_clinician-publications-year','2019~~~Umer A, Loudin S, <b>Maxwell S</b>, Lilly C, Stabler ME, Cottrell L, Hamilton C, Breyel, Mullins C, John C. Capturing the statewide incidence of neonatal abstinence syndrome in real-time: the West Virginia experience. Pediatr Res. 2019 Apr. https://www.ncbi.nlm.nih.gov/pubmed/30287893');

I want to remove the duplicate post-data so that the post data shows once on the website.

A: i never selected the correct table
i was able to delete the duplicate, the above DElETE FROM command works for removing duplicate post data


text:
Q: Совместимость разных версий java Приложения, скомпилированные на более старой версии jdk, будут ли гарантированно работать на машине с более новой версией jdk, или нет? И наоборот, приложения, скомпилированные на более новой версии jdk, будут ли гарантированно работать на машине с более старой версией jdk, или нет?

A: У Java гарантирована бинарная совместимость снизу вверх. Т.е. код сrопилированный на более ранней версии будет работать на более поздней. Но есть некоторые несовместимости и они задокументированы.
При компиляции кода вы можете указать под какую версию вы компилируете. Т.е. используя компилятор 1.8 вы можете скомпилировать код под 1.6, но исходный код должен быть для 1.6.


text:
Q: Batch IF command that has multiple varia So I wanted to create a code in batch that can make both C and c valid to go to :color
This is the only way I was able to do it, but I was wondering if there is a more "efficient" way.
I'm new to coding and the programming world, so I'm not a Batch expert.
echo Choose again (C) or go back to Main Menu (M)?
set /p choice=Your choice:
if %choice%==C goto :color
if %choice%==c goto :color
if %choice%==M goto :menu
if %choice%==m goto :menu

my idea was something like
if %choice%==C,c goto :color

or
if %choice%==C& c goto :color

I will appreciate any and all help.
Thanks in advance

A: read HELP IF ... the /I switch, if specified, says to do case insensitive string
compares....
and try at the command line
IF /I %choice%==m @echo Menu

A: In addition to @PA.'s answer, batch doesn't support implicit logical operators (AND/OR) but you can emulate them as described in: How can I use multiple conditions in "If" in batch file?
Taking a look into powershell may be a good idea if you want to go further with logical programming while keeping the familiar feel of the cmd environment.


text:
Q: MS Graph create onlineMeeting: "onlinemeeting cannot be null." I'm currently trying to create online meetings using the Graph Explorer and facing a similiar problem like in this question: onlinemeeting-cannot-be-null-error-when-creating-new-meeting-with-beta-api.
Whenever I'm sending a Post request to https://graph.microsoft.com/v1.0/me/onlineMeetings the answer is a 400 Bad Request error with message: onlinemeeting cannot be null. The body looks like the example from the official documentation:
{
  startDateTime:"2020-09-09T14:33:30.8546353-07:00",
  endDateTime:"2020-009-09T15:03:30.8566356-07:00",
  subject:"test"
}

No matter what, I can't get this to work. Other endpoints work well and the API permissions fit the requirements. Any thoughts on this?

A: The participants should be provided in the onlineMeeting resource, participants is one of properties in onlineMeeting object, you can also add other properties of onlineMeeting.
So you need to add it to your request body, here is a sample for your reference:
{
  "startDateTime":"2019-09-09T14:33:30.8546353-07:00",
  "endDateTime":"2019-09-09T15:03:30.8566356-07:00",
  "subject":"Application Token Meeting",
  "participants": {
    "organizer": {
      "identity": {
        "user": {
          "id": "550fae72-d251-43ec-868c-373732c2704f"
        }
      }
    }
  }
}


text:
Q: Problem with finding the GCD for the elements of a list using max and lambda So this is my code, and i've used a lambda function as a key to find the max of the result list, but it wont work. I don't want to use any other built in functions or methods, just modify the KEY if possible. The result for this given list should be 6, but my code returns 1!
def find_gcd(my_list):
    result = []
    for item in my_list:
        for divs in range(1, item+1):
            if item % divs ==0:
                result.append(divs)

    result.sort()

    x = max(result, key = lambda x : result.count(x))
    return x
print(find_gcd([12, 24, 6, 18]))

A: change your key to this:
max(result, key = lambda x : (result.count(x), x))

your result in your scenario (find_gcd([12, 24, 6, 18])) is this:
[1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 6, 6, 6, 6, 8, 9, 12, 12, 18, 24]

we have same number of 1s , 2s ,3s and 6s in the result as you see.(both have 4 occurrence). but we want the greatest one.
NOTE: We can use two element tuple for these problem. the first element for number of occurrence (e.g: 4 occurrence for number 1) and the second one is the number itself. between (4, 1) and (4, 6), the (4, 6) is greater and it will return.


text:
Q: How can I restore files when my account isn't granted access? I had a heavily corrupted MySQL database, so I tried to restore the files from a recent backup (a local time machine snapshot), but that failed with the error:

The operation can't be completed because you don't have permission to access some of the items.

How can I restore these files?
In trying, I added my account to the "_mysql" group with dseditgroup (groups now lists me as being in the "_mysql" group), which is supposed to be granted read/write access to all files and folders, and tried restoring from Time Machine again with the same result. The folders also still display the "inaccessible" icon overlay (⛔) in Finder. I can copy (slightly) older versions of the files stored on an external Time Machine drive from a shell with a sudo ditto, but get a permissions error from MySQLd when it tries to read one of the files (the binary log index).
The computer is running OS X 10.12.6.

A: I was able to access the local snapshots in "/.MobileBackups/Computer/" via a command line. Unfortunately, I disabled automatic Time Machine backups, not knowing that this would delete all local snapshots.
The files from the external Time Machine backup had an ACL that disallowed all write access to the database directories and files (revealed with ls -le). Removing the ACL with chmod -RN $dir granted access (no more permission errors when MySQLd runs).


text:
Q: Atlas search on an ObjectId field doesn't work I was trying to implement an Atlas search query on an ObjectId field but nothing is being matched. Here's the index definition.
{
  "mappings": {
    "dynamic": false,
    "fields": {
      "hscode": {
        "foldDiacritics": true,
        "maxGrams": 4,
        "minGrams": 1,
        "tokenization": "edgeGram",
        "type": "autocomplete"
      },
      "title": {
        "foldDiacritics": true,
        "maxGrams": 10,
        "minGrams": 2,
        "tokenization": "edgeGram",
        "type": "autocomplete"
      },
      "type._id": {
        "type": "objectId"
      }
    }
  }
}

The query details are as follows
db.categories.aggregate([
    {
        $search:{
            index:"categorySearch",
            equals:{
                path:"type._id",
                value:ObjectId("61711b4275e9397ec79bdfed")
            }
        }
    }
])

Note : The autocomplete queries are working without a problem. Thanking you in advance.

A: For those looking for a fix, try changing the index to look like this. The document type should be added for it to work.
type:{
  _id:{
    type:"objectId"
  }
  type:"document"
}


text:
Q: How to remove repeatedly failing driver update in Windows 10? I recently upgraded a laptop from Windows 8.1 Pro to Windows 10 Pro. Since then, an Intel graphics driver update pulled down by Windows Update keeps trying and failing to install.
Is there a way I can remove this update?
I've tried https://support.microsoft.com/en-us/kb/3073930 - it doesn't list any updates available in my case, probably because it hasn't installed successfully.
I've also tried clearing C:\Windows\SoftwareDistribution\Download.
It's a big nuisance to have it keep prompting me about the failed update every time I use the computer.
NOTE: I don't want to disable ALL driver updates, I just want a way to remove one that keeps failing to install. This may also apply to cherry-picking a non-driver failing update, but I'm not sure (as I said, KB3073930 does not help in my case)

A: This has happened to me previously, What i ended up doing was reinstalling the os, But you can also disable the windows updates if you really have to, Search "How to disable windows updates" and it will come up with a reg edit program (i think) that will disable them. Hope this helps


text:
Q: Special expression for solution of heat equation Let us consider the heat equation on the quarter plane
\begin{align*}
\frac{\partial u}{\partial t}=\frac{\partial^2u}{\partial x^2},\quad t>0,\;x>0
\end{align*}
with boundary condition $u(0,t) = A$ and initial condition $u(x,0) = 0$.
Now we introduce $w(x,t) = u(x,t)-A$ where $A\in\mathbb{R}$, $u(x,t)$ is a solution to the heat equation and I've shown that $w(x,t)$ is also a solution to the heat equation. Also we have boundary and initial conditions
\begin{align*}
w(0,t)&=u(0,t)-A=A-A=0\\
w(x,0)&=u(x,0)-A=0-A=-A.
\end{align*}
By some formula from the book we have that
\begin{align*}
w(x,t)&=\frac{1}{2\sqrt{\pi t}}\int_0^{\infty}w(s,0)\left(e^{-(x-s)^2/4t}-e^{-(x+s)^2/4t}\right)ds\\
&=\frac{-A}{2\sqrt{\pi t}}\int_0^{\infty}\left(e^{-(x-s)^2/4t}-e^{-(x+s)^2/4t}\right)ds.
\end{align*}
Furthermore, I've shown that
\begin{align*}
u(x,t)=A\left(1+\frac{1}{2\sqrt{\pi t}}\int_0^{\infty}\left(e^{-(x+s)^2/4t}-e^{-(x-s)^2/4t}\right)ds\right).
\end{align*}
Now I want to prove that $u(x,t) = 2AN\left(\frac{-x}{\sqrt{2t}}\right)$.
Let's begin with noting that
\begin{align}\label{inte1}
\frac{1}{2\sqrt{\pi}}\int_{-\infty}^{\infty}e^{-s^2}ds=\frac{1}{4}\frac{2}{\sqrt{\pi}}\int_{-\infty}^{\infty}e^{-s^2}ds\overset{\text{def}}{=}\frac{\text{erf}(x)}{4}+C\quad(1)
\end{align}
and since $y=e^{-s^2}$ is symmetric in the $y$-axis, we also say
\begin{align}\label{inte2}
\frac{1}{2\sqrt{\pi}}\int_{0}^{\infty}e^{-s^2}ds=\frac{1}{2\sqrt{\pi}}\int_{-\infty}^{0}e^{-s^2}ds=\frac{\text{erf}(x)}{8}+C.
\end{align}
Let us choose $C=0$ for a moment. So far, so good, I hope.
Moreover, we note that in the integral equation (1) we can replace $s$ by $(x-s)$ or $(x+s)$ without the integral changing its value because whether $s$ ranges from $-\infty$ to $\infty$, for exmaple, or $(x-s)$ ranges from $-\infty$ to $\infty$ does not give another value to the integral; i.e.
\begin{align}\label{inte3}
\frac{1}{2\sqrt{\pi}}\int_{-\infty}^{\infty}e^{-s^2}ds=\frac{1}{2\sqrt{\pi}}\int_{-\infty}^{\infty}e^{-(x-s)^2}ds=\frac{1}{2\sqrt{\pi}}\int_{-\infty}^{\infty}e^{-(x+s)^2}ds.
\end{align}
I do not know whether this equation above is right.
Now I try to go to the desired result and end up with question marks:
\begin{align*}
u(x,t)&=A\left(1+\frac{1}{2\sqrt{\pi t}}\int_0^{\infty}\left(e^{-(x+s)^2/4t}-e^{-(x-s)^2/4t}\right)ds\right)\\
&=A\left(\frac{1}{2}+\frac{1}{2\sqrt{\pi t}}\int_0^{\infty}e^{-(x+s)^2/4t}ds+\frac{1}{2}-\frac{1}{2\sqrt{\pi t}}\int_0^{\infty}e^{-(x-s)^2/4t}ds\right)\\
&=A\left(\frac{1}{2}+\frac{1}{2\sqrt{\pi t}}\int_0^{\infty}e^{-(x+s)^2/4t}ds+\frac{1}{2}+\frac{1}{2\sqrt{\pi t}}\int_0^{\infty}e^{-(x+s)^2/4t}ds\right)\quad(??)\\
&=
\end{align*}
I have no idea how to turn that $1$ into some integral. Maybe it is true that
\begin{align*}
\frac{1}{2\sqrt{\pi}}\int_{-\infty}^{\infty}e^{-s^2}ds=\frac{1}{2}?
\end{align*}
Does anyone have some suggestion?

A: Let $u(x,t)=X(x)T(t)$ ,
Then $X(x)T'(t)=X''(x)T(t)$
$\dfrac{T'(t)}{T(t)}=\dfrac{X''(x)}{X(x)}=-s^2$
$\begin{cases}\dfrac{T'(t)}{T(t)}=-s^2\\X''(x)+s^2X(x)=0\end{cases}$
$\begin{cases}T(t)=c_3(s)e^{-ts^2}\\X(x)=\begin{cases}c_1(s)\sin xs+c_2(s)\cos xs&\text{when}~s\neq0\\c_1x+c_2&\text{when}~s=0\end{cases}\end{cases}$
$\therefore u(x,t)=\int_0^\infty C_1(s)e^{-ts^2}\sin xs~ds+\int_0^\infty C_2(s)e^{-ts^2}\cos xs~ds$
$u(0,t)=A$ :
$\int_0^\infty C_2(s)e^{-ts^2}~ds=A$
$C_2(s)=A\delta(s)$
$\therefore u(x,t)=\int_0^\infty C_1(s)e^{-ts^2}\sin xs~ds+\int_0^\infty A\delta(s)e^{-ts^2}\cos xs~ds$
$u(x,t)=\int_0^\infty C_1(s)e^{-ts^2}\sin xs~ds+A$
$u(x,0)=0$ :
$\int_0^\infty C_1(s)\sin xs~ds+A=0$
$\mathcal{F}_{s,s\to x}\{C_1(s)\}=-A$
$C_1(s)=\mathcal{F}^{-1}_{s,x\to s}\{-A\}=-\dfrac{2A}{\pi s}$ (according to http://eqworld.ipmnet.ru/en/auxiliary/inttrans/FourSin2.pdf)
$\therefore u(x,t)=A-\dfrac{2A}{\pi}\int_0^\infty\dfrac{e^{-ts^2}\sin xs}{s}~ds=A~\text{erfc}\left(\dfrac{x}{2\sqrt t}\right)$


text:
Q: MVC3 - View is not updating with new data on Viewmodel I am trying to update my view with new viewmodel data, but everytime I load the viewmodel, it shows correct data in viewmodel, even in the data in jquery success call, but it won't update the view.
I am pasting the code below, kindly check and let me know, what I am doing wrong?
I am pissed off with this, since two days.
ViewModel
namespace CRMTest.Models.ViewModels
{
public class ContactViewModel
{
    private Xrm.Contact item;

    public string ContactName { get; set; }
    public string Address1 { get; set; }
    public string Address2 { get; set; }
    public string Address3 { get; set; }
    public string Town { get; set; }
    public string County { get; set; }
    public string Postcode { get; set; }
    public string CompReg { get; set; }
    public string OurRef { get; set; }
    public string RefType { get; set; }
    public string Contact { get; set; }
    public string Salutation { get; set; }
    public string Position { get; set; }
    public string Telephone { get; set; }
    public string Fax { get; set; }
    public string Mobile { get; set; }
    public string ClientServices { get; set; }
    public bool ContactByTel { get; set; }
    public bool ContactByEmail { get; set; }
    public bool ContactByLetter { get; set; }
    public bool ContactByFax { get; set; }
    public string Email { get; set; }
    public string Website { get; set; }
    public string Notes { get; set; }
    public DateTime UpdatedDate { get; set; }
    public string UpdatedBy { get; set; }

    public ContactViewModel(Xrm.Contact item)
    {
        ContactName = item.Address1_Name;
        Address1 = item.Address1_Line1;
        Address2 = item.Address1_Line2;
        Address3 = item.Address1_Line3;
        Town = item.Address1_City;
        County = item.Address1_County;
        Postcode = item.Address1_PostalCode;
        OurRef = item.NickName;
        Contact = item.Salutation+" "+item.FullName;
        Salutation = item.Salutation+" "+item.LastName;
        Position = item.JobTitle;
        Telephone = item.Address1_Telephone1;
        Fax = item.Address1_Fax;
        Mobile = item.Address1_Telephone2;
        Email = item.EMailAddress1;
        Website = item.WebSiteUrl;
    }
}

Controller
 public ActionResult Index()
    {
        //CRM Start
        Session.Add("ServiceProxy", serviceProxy);

        //CRM End

        var service = Session["ServiceProxy"] as Microsoft.Xrm.Sdk.IOrganizationService;
        service = (IOrganizationService)serviceProxy;

        if (service != null)
        {
            using (var context2 = new XrmServiceContext(service))
            {
                var contacts = context2.ContactSet.FirstOrDefault();
                    ModelState.Clear();
                    var contactsViewModel = new ContactViewModel(contacts);

                return View(contactsViewModel);
            }
        }
        else
        {
            ModelState.AddModelError("", "Service proxy is missing is session state. Did you log in?");
            return RedirectToAction("LogOn", "Account");
        }
    }

    [HttpPost]
    public ActionResult Index(string strSearchParam)
    {
        if (!ModelState.IsValid)
        {
            if (Request.IsAjaxRequest())
                return PartialView("FindCustomer", strSearchParam);

            return View(strSearchParam);
        }

        if (service != null)
        {
            ModelState.Clear();
            using (var context2 = new XrmServiceContext(service))
            {
                var contacts = context2.ContactSet.Where(c => c.NickName.Equals(strSearchParam)).FirstOrDefault();

                if (contacts != null)
                {
                    var contactsViewModel = new ContactViewModel(contacts);
                    ModelState.Clear();

                    return View("Index",contactsViewModel);
                }
                else
                    return View();
            }
        }
        return View();
    }

View
@model CRMTest.Models.ViewModels.ContactViewModel

@{
ViewBag.Title = "Index";
 }

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/base/jquery-ui.css"    type="text/css" media="all" />

 @using (Html.BeginForm("frmContactForm"))
 {
  @Html.ValidationSummary(true);

            @Html.LabelFor(x => x.ContactName)	@Html.TextBoxFor(model => model.ContactName)
            @Html.Label("Our Ref/Type")	@Html.DisplayFor(x => x.OurRef)	<input id="Contact" name="Contact" type="text" value="Mrs Lakhbir">

            @Html.LabelFor(model => model.Address1)	@Html.TextBoxFor(model => Model.Address1)
            @Html.Label("Contact/Salu'n")	@Html.TextBoxFor(model => model.Contact)	@Html.TextBoxFor(model => model.Salutation)

             	@Html.TextBoxFor(model => model.Address2)
            @Html.Label("Position")	@Html.TextBoxFor(model => model.Position)

             	@Html.TextBoxFor(model => model.Address3)
            @Html.Label("Tel/Fax")	@Html.TextBoxFor(model => model.Telephone)	@Html.TextBoxFor(model => model.Fax)

            @Html.Label("Town/City")	@Html.TextBoxFor(model => model.Town)
            @Html.Label("Mobile")	@Html.TextBoxFor(model => model.Mobile)

            @Html.LabelFor(model => model.County)	@Html.TextBoxFor(model => model.County)
            @Html.Label("Client Services")	@Html.TextBoxFor(model => model.ClientServices)

            @Html.LabelFor(model => model.Postcode)	@Html.TextBoxFor(model => model.Postcode)
            @Html.Label("Contact by")	@Html.CheckBoxFor(model => model.ContactByTel) Tel @Html.CheckBoxFor(model => model.ContactByEmail) Email @Html.CheckBoxFor(model => model.ContactByLetter) Letter @Html.CheckBoxFor(model => model.ContactByFax) Fax

            @Html.LabelFor(model => model.CompReg)	@Html.TextBoxFor(model => model.CompReg)
            @Html.Label("Email")	@Html.TextBoxFor(model => model.Email)

            @Html.Label("1 of 5906")	<input type="button" id="btnFind" value="Find" /> <input type="submit" name="btnEdit" value="Edit" /> <input type="button" name="btnNew" value="New" disabled="disabled" /> <input type="button" name="btnAccount" value="Account" disabled="disabled" />
            @Html.Label("Website")	@Html.TextBoxFor(model => model.Website)

}

                @Html.Label("OurRef")
                @Html.TextBox("txtOurRef")

                @Html.LabelFor(model => Model.ContactName)
                @Html.TextBoxFor(model => Model.ContactName, new { @class = "form_input radius" })

                @Html.LabelFor(model => Model.CompReg)
                @Html.TextBoxFor(model => Model.CompReg, new { @class = "form_input radius" })

                @Html.LabelFor(model => Model.Address1)
                @Html.TextBoxFor(model => Model.Address1, new { @class = "form_input radius" })

                @Html.LabelFor(model => Model.Address2)
                @Html.TextBoxFor(model => Model.Address2, new { @class = "form_input radius" })

                @Html.LabelFor(model => Model.Telephone)
                @Html.TextBoxFor(model => Model.Telephone, new { @class = "form_input radius" })

                @Html.LabelFor(model => Model.Postcode)
                @Html.TextBoxFor(model => Model.Postcode, new { @class = "form_input radius" })

            @*

                <input type="button" id="btnSearch" value="Search" class="submit submit_green fltl">
                <input type="button" id="btnClose" value="Cancel" class="submit submit_green fltl">

*@