text:
Q: how to fix xcode warning "Expression result unused" in xcode 4 for UIActivityIndicatorView i am getting a warning for
    spinner.hidesWhenStopped;

warning : Expression result unused
hope any one know this
Thank you very much

A: Well hidesWhenStopped is a property of spinner and you don't do anything with it. Try setting a value as in
spinner.hidesWhenStopped = YES;

or
spinner.hidesWhenStopped = NO;

A: It seems you are trying to set the activity indicator to hide when stopped animating. The line spinner.hidesWhenStopped doesn't call the setter method. If you want to call the setter method you have to either use,
spinner.hidesWhenStopped = YES;

or,
[spinner setHidesWhenStopped:YES];


text:
Q: Context Values not passing to a field with onchange property I am trying to pass context values to a form 'A'. The fields on form 'A ' have property as onchange. Now if I delete the onchnaghege propert from that field , the values gets passed otherwise the values are unable to pass. I have no idea how to p[ass the values to fields haviung onchnge propperty. I do need to retain the ionchnege property with the fields to avoid the frlaws. My python code is below:
 def creates(self,cr,uid,ids,context=None):
        for id in ids:
            deg_obj=self.pool.get('deg.form').browse(cr,uid,id)
            my_id=int(deg_obj.my_products)
        prr= int(deg_obj.categg_temp)
        pch= int(deg_obj.categ_temps)
        cch= int(deg_obj.categ_temp2)
        print pch
        print prr
        ctx = dict(context)
        ctx.update({'default_ch':pch,'default_pr':prr})
        return{
              'view_type': 'form',
              'view_mode': 'form',
              'res_model': 'product.product',
              'context':ctx,
              'type': 'ir.actions.act_window',
              'nodestroy':False,
              'target': 'current',
              }

My xml code contains tyhose fields where I am trying to set tyhe values :
   <label for="pr" string="Parent"  />
            <field name="pr" domain="[('parent_id','=',False)]" on_change="myTop_Category_OnChange(pr)"/>

   <label for="ch" string="Category" />
        <field name="ch" domain="[('parent_id','=',1)]" on_change="myProduct_Category_OnChange(ch)" />

I need guidance on this .

A: I fear I don't understand you question but I'll try to answer it ;)
If you try to get the value of 'pr' field in the 'myProduct_Category_OnChange' method, you need to declare the on_change statement like this:
on_change="myProduct_Category_OnChange(ch, pr)"

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to discover the service packs applied to my SQL Server Management Studio? I'm running SSMS 2008, and I can see the version numbers in Help -> About. But how do I know from these version numbers if the SP2 have been installed in my machine?
Here are my version numbers from SSMS:
Microsoft SQL Server Management Studio      10.50.4000.0
Microsoft Analysis Services Client Tools        10.50.4000.0
Microsoft Data Access Components (MDAC)     3.85.1132
Microsoft MSXML                 2.6 3.0 4.0 5.0 6.0
Microsoft Internet Explorer             8.0.6001.18702
Microsoft .NET Framework                2.0.50727.3623
Operating System                    5.1.2600

A: See the SQL Server version number post here:
http://sqlserverbuilds.blogspot.com/
It contains a list of all SQL Server versions and service packs and which four-part version number those refer to.
Your 10.50.4000.0 is SQL Server 2008 R2 with SP2.
To get the version number of the database engine (not the management tool or the analysis services), use
SELECT @@VERSION

This output will look something like this:

Microsoft SQL Server 2012 - 11.0.2218.0 (X64)
  Jun 12 2012 13:05:25
  Copyright (c) Microsoft Corporation
  Developer Edition (64-bit) on Windows NT 6.1  (Build 7601: Service Pack 1)

would also include the service pack level that's applied to your system.

A: You're actually running SQL Server 2008 R2, and you have the SP2 installed, according to this:
http://support.microsoft.com/kb/321185


text:
Q: error creating a stacked bar chart with Google Sheets API v4 using python I am trying to create a stacked bar chart using the Google Sheets API v4.  I have successfully created the chart without stacking (i.e. the two series in the chart are displayed side by side).  But when I try to add the option for it to be stacked, I get an error.  I am following the documentation found at https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#BasicChartSpec.
When I add the option stackedType to the passed parameters in json (with the value "STACKED"), I get the following error:
"Invalid requests[0].addChart: chartSpec.basicChart.stackedType not supported when chartSpec.basicChart.chartType is BAR."
I don't understand this error message, because the documentation says that stackedType applies to Bar charts.  Has anyone else encountered this issue?
I have my request I am sending (in json format) below:
chart_request = {
    "requests": [
        {
            "addChart": {
                "chart": {
                    "spec": {
                        "title": title,
                        "basicChart": {
                            "chartType": "BAR",
                            "legendPosition": "RIGHT_LEGEND",
                            "axis": [
                                {
                                    "position": "BOTTOM_AXIS",
                                    "title": "Revenue ($)"
                                    },
                                {
                                    "position": "LEFT_AXIS",
                                    "title": "Channel"
                                    }
                                ],
                            "domains": [
                                {
                                    "domain": {
                                        "sourceRange": {
                                            "sources": [
                                                {
                                                    "sheetId": sheetId,
                                                    "startRowIndex": 0,
                                                    "endRowIndex": nrows,
                                                    "startColumnIndex": 0,
                                                    "endColumnIndex": 1
                                                    }
                                                ]
                                            }
                                        }
                                    }
                                ],
                            "series": [
                                {
                                    "series": {
                                        "sourceRange": {
                                            "sources": [
                                                {
                                                    "sheetId": sheetId,
                                                    "startRowIndex": 0,
                                                    "endRowIndex": nrows,
                                                    "startColumnIndex": 2,
                                                    "endColumnIndex": 3
                                                    }
                                                ]
                                            }
                                        },
                                    "targetAxis": "BOTTOM_AXIS"
                                    },
                                {
                                    "series": {
                                        "sourceRange": {
                                            "sources": [
                                                {
                                                    "sheetId": sheetId,
                                                    "startRowIndex": 0,
                                                    "endRowIndex": nrows,
                                                    "startColumnIndex": 5,
                                                    "endColumnIndex": 6
                                                    }
                                                ]
                                            }
                                        },
                                    "targetAxis": "BOTTOM_AXIS"
                                    }
                                ],
                            "headerCount": 1,
                            "stackedType": "STACKED",
                            }
                        },
                    "position": {
                        "overlayPosition": {
                            "anchorCell": {
                                "sheetId": sheetId,
                                "rowIndex": 15,
                                "columnIndex": 0,
                                },
                            "widthPixels": 600,
                            "heightPixels": 300,
                            },
                        }
                    }
                }
            }
        ]
    }

Thank you in advance.

A: If you check the BasicChartSeries it does say that it is only valid for chartType COMBO:

enum(BasicChartType)
The type of this series. Valid only if the chartType is COMBO. Different types will change the way the series is visualized. Only
  LINE, AREA, and COLUMN are supported.

I suggest you check if what you're doing works with COMBO chartTypes. If it does, then that confirms your problem, only COMBO chart type is supported.

A: I'm an engineer on the Google Sheets team.  We've found a bug when creating stacked charts via the API that will be fixed very shortly.
Thank you for posting this!

*

*Michael


text:
Q: Form in Laravel don't send data I try to make a form with multiples date inputs, I copy the model from the register / login blade template but it don't work, here is what I do in my template:
<form method="POST" action="{{ route('createDispo') }}">
    @csrf

        Date de début

            <input type="date" name="date_debut" class="form-control" required>

        Heure de début

            <input type="date" name="date_debut_heure" class="form-control" required>

        Date de fin

            <input type="date" name="date_fin" class="form-control" required>

        Heure de fin

            <input type="date" name="date_fin_heure" class="form-control" required>

            <button type="submit" class="btn btn-primary">
                Ajouter
            </button>

</form>

But the form doesn't return a $data array like the register or login one, but only the first value (date_debut and not in an array, how to properly do a form with Laravel ?
EDIT:
Here is my controller
public function createDispo(array $data){
    $disponibilite = new Disponibilite();
    $disponibilite->date_debut = $data["date_debut"];
    $disponibilite->date_fin = $data["date_fin"];
    //$user->disponibilites()->save($disponibilite);
}

The problem is that I don't receive this 'data' array but only one value (the first datepicker)

A: You can access submitted data using the $request.  The docs describe it well.  In your case:
use Illuminate\Http\Request;

public function createDispo(Request $request){
    $disponibilite = new Disponibilite();
    $disponibilite->date_debut = $request->date_debut;
    $disponibilite->date_fin = $request->date_fin;
    // ...
}

A: When you send HTTP requests as this form, the method that should get this information should receive the Illuminate/Http/Request class.
The controller login does that differently because the controller send the $request->all() (this is an array) to the method login after the validation.
So what you have to do, is to change:
public function createDispo(array $data){

To
public function createDispo(Request $data){

Or to be more consistent to variables:
public function createDispo(Request $request){

Then you can access the data with:
public function createDispo(Request $request){

    $disponibilite = new Disponibilite();
    $disponibilite->date_debut = $request->date_debut;
    $disponibilite->date_fin = $request->date_fin;
    //$user->disponibilites()->save($disponibilite);
}

Remember to import the class of Illuminate\Http\Request when using Request


text:
Q: Why does R require a return inside of {} when using inside of with statement? I could not find a reason why the code below would not work.
with(df, {a<-plot(x,y) b<-lines(x1,x2)})

Then I found some examples that used the following syntax.
with(df, {a<-plot(x,y)
          b<-lines(x1,x2)})

When I used the second syntax I received no errors. What am I missing?

A: If you want two commands on the same line, separate them with a semicolon
with(df, {a<-plot(x,y); b<-lines(x1,x2)})

This isn't unique towith or {}. You can't just do
a <-5   b<-3   a+b   # syntax error if on the same line.

in R and have it run. You either need semicolons or new line characters between separate statements that you want R to run.

A: From An Introduction to R section 1.8

Commands are separated either by a semi-colon (';'), or by a newline.
  Elementary commands can be grouped together into one compound
  expression by braces ('{' and '}').

Below codes are equivalent
with(df1, {a<-plot(x,y) ; b<-lines(x1,x2)})

with(df1, {a<-plot(x,y)
           b<-lines(x1,x2)})


text:
Q: A mapping that does not preserve convergence in distribution I'm trying to come up with a map $H: \mathbb{R}^k\to \mathbb{R}^k$ and a sequence of random vectors $X_n\Rightarrow X$ in $\mathbb{R}^k$ for which $H(X_n)$ does not converge in distribution to $H(X)$. Any ideas?
I want to use an example for the section I'm teaching tomorrow (I'm covering convergence).

A: Convergence in distribution is preserved by continuous maps, or more generally by maps for which the measure of discontinuity points are of null measure for the limiting law.
Without this assumption, the result may fail.
If we consider the case $k=1$, then we can take a simple example: $X_n:=1/n$, $X=0$ and $H(x):=\chi_{(0,1)}(x)$, where $\chi_S$ is the characteristic function of the set $S$. We have $H(X_n)=1$ for each $n$ and $H(X)=0$.


text:
Q: Selectors for content based routing in WMQ where the payload has a namespace This question is related to Websphere MQ. I have a requirement where in I have to route messages based on the content of the message.
I know about the concept of selectors in WMQ subscriptions and I have also been successful in doing this based on the Message Headers (using MQRFH2 )
I now need to filter messages based on the payload which are XMLNSC and have a valid namespace associated with it.
Eg:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:test xmlns:ns0="abc.com/is/2009/schemas/envelope/">
  <flag>Y</flag>
</ns0:test>
If I have to accept messages if the flag is 'Y' only, then how do I set the selector in my subscriptions?
Please let me know.
Thanks in advance.

A: Any WebSphere MQ selection information must either be in the message header or a message property.  WMQ is tuned to move messages as far downstream as possible, as quickly as possible, and does not do anything with message payloads other than to deliver them. Any functionality based on data in the message body requires one of IBM's ESB solutions such as IIB, or else to write code to inspect the payload and take the appropriate action.
If at all possible, the application creating the messages should place the selection field into a message property.  If that isn't possible, a program can intercept the message, evaluate the payload and set the property, then re-queue the message.


text:
Q: Unity ScrollViewScope horizontal scroll not working with EditorGUILayout I need to use EditorGUI.IndentLevelScope and it only work with EditorGUILayout like LabelField, Foldout, not in GUILayout like Label.
here is my code
                using (var midScroll = new EditorGUILayout.ScrollViewScope(midSPos, true, true))
                {
                    using (new EditorGUI.IndentLevelScope(1))
                    {
                        midSPos = midScroll.scrollPosition;
                        for (int i = 0; i < 50; i++)
                        {
                            EditorGUILayout.LabelField("This is a EditorGUILayout.LabelField. This is a EditorGUILayout.LabelField.", GUI.skin.GetStyle("LinkLabel"));
                        }
                    }
                }

Vertical work but not Horizontal
Pic: https://gyazo.com/70382d83222dc7fc2db54c4745836dfc
same code with GUILayout.Label work both
what do i miss

A: End up I found a solution for Label by adding an empty PrefixLabel in front and back to GUILayout again, the scroll now works.
HorizontalScope
    EditorGUILayout.PrefixLabel("");
    GUILayout.Label("content");

But still, have some issues with my foldout like this since I can't add HorizontalScope to it.
InitRow(row row)
{
    if (isShowing = EditorGUILayout.Foldout(isShowing, "Foldout"))
    {
        InitRow(child);
    }
}


text:
Q: Consider an election. Candidate A has 60% of the vote and Candidate B has 40% of the vote (binomial distribution). There are no undecided voters. Candidate A = 60%
Candidate B = 40%
Say that the pollster samples 400 people. What is the probability that, among the first three individuals sampled, exactly two will favor Candidate A?
400 people are sampled, among the first three that are sampled, exactly two favor candidate A. What is the probability that this will happen?
I did try the problem. I did a combination problem (3 chose 2) times .60 raised to the second times .40. I do not know if this is right though. Looking for confirmation.

A: ${3 \choose 2}\,0.6^2\, 0.4 = 0.432$ is a correct application of the binomial distribution
If the $60\%$ and $40\%$ come from the sample of $400$ so $240$ for candidate A and $160$ for candidate B then you have a hypergeometric distribution and the answer would be $ {3 \choose 2}\frac{240 \times 239 \times 160}{400 \times 399 \times 398} \approx 0.4334$


text:
Q: How to set expire time for CookieService in Angular app I m using the ngx-cookie-service package . I can set, get, delete, deleteall cookie but how I set the expire time for cookie so that it automatically expire/delete after that time interval.
Thanks for reply

A: Have a look at its github link example of set method.
Which is
set( name: string, value: string, expires?: number | Date, path?: string, domain?: string, secure?: boolean ): void;
So you have the third optional parameter of expiry

A: I have coding for setting expire time:
@Injectable()
export class AuthService {

   private cookieExpireTime: Date;

   constructor(private cookieService: CookieService) {
   }

   // Set time expired
   setCookieExpireTime() {
       let expireTime = 'your_time';
       this.cookieExpireTime = new Date(expireTime * 1000);
   }

   // Get time expired
   getCookieExpireTime(): Date {
       return this.cookieExpireTime;
   }

   // Delete
   deleteTimeExpired(){
      this.cookieService.delete('expiredtime');
   }

   // Set time expired for token
   setTokenCookie(data: any) {
       this.cookieService.set('token_store', JSON.stringify(data), this.getCookieExpireTime());
   }

}

I hope that this code can help you.


text:
Q: Ping to home computer results in 'Request Timed Out', although computer is connected & online I've assigned a static IP address to my computer. From my computer, when I browse to WhatIsMyIP, I can check my IP & verify that it hasn't changed.
Now, when I ping my computer from another network, most of the times, everything is fine & I get responses; but occasionally I get 'Request Timed Out' messages (4 out of 4 attempts on:
CMD> ping <IP>

will result in the request timing out).
So far, I have not been able to identify why sometimes it works, but times out at other times. At the times it has timed out, I've used TeamViewer to connect to my computer & check WhatIsMyIP to verify that it's the same. So I know it's connected & online & everything is accessible from the computer atleast.
Normally this would not be a problem, but I'm trying to host a small website form my computer & for the most part, its online, but now & then it goes offline - even though the host computer is up & running with no change in it's IP address.
I'm on Google Fiber, if that helps. Also, under the Advanced Settings', I have reserved an IP address (192.168.1.4) for my computer so I know that will not change. And as I've mentioned my outward facing IP has been made static so I know that is always the same.
Another thing to mention, I have never faced any problems when browsing, gaming online (No disconnects or time-outs or anything)
I would like some insight as to how this can be resolved or at the very least, if the root cause can be identified.

A: So the problem turned out to be multiple Port Forwarding rules. I had two rules set up, one was setup to use 'Any' service & the other was setup to use only the HTTP - Port 80. I removed the 'Any' service & it's been working fine just since - I assume there was a Port Forwarding Rule conflict.


text:
Q: PCF8574 relay glitches on HA IoT Recently I designed a board to control the lights in my home remotely via HomeAssistant (ESPHome using a WeMos D1 Mini). Due to the lack of pins, I am using a PCF8574 to actuate the relays. The main issue I am facing is that when switching off fluorescent lights (be in PL-C 2 pin or tubular), the entire circuit (all the relays on the board) glitches to "ON".
Here is a circuit diagram of my board:

As requested the .pdf files for the board and schematic.
A video of the problem I am facing can be found here. Between 0:00-0:27 of the video, I cycle through all LED lights in the room (using the remote app) and they work fine. at 0:27, I turn on the problematic fluorescent light. At 0:31, I attempt to turn it off but it doesn't turn off and causes all the lights in the room to suddenly turn on. Checking the logs shows that the ESP8266 did not reset nor did any of the PCF8574 pins go to "HIGH" during the period of the malfunction.
Hence I likely suspect that this issue is caused either by the PCF8754 glitching out or perhaps caused by some form of interference caused by the circuit design.
Interestingly, I had tried the board out before installing it on similar PL-C 2 pin bulbs which can be found here. As such, it's really perplexing as to why the circuit would have failed when being installed.
Currently, I have the following hypotheses (in order of likelihood:

*

*The PCF8574 glitches out when fluorescent lights are switched off on the relay. The cause behind this is unknown as I lack a proper oscilloscope and the know-how to troubleshoot the PCF8574.
Solution: Redesign the board and switch the relay pins to the ESP8266 and leave the PCF8574 to do the sensing on the button and the outputs on the light

*Magnetic interference caused by the tangled nature of the wires could be causing the PCF8574 to glitch out. For reference, here is an image of the board being installed in the switch box:

Solution: Better wire management (which has been done, greatly reducing the amount of wire clutter); possibly isolating the wires from the circuit board using an aluminium foil?

*Lack of isolation between load circuit and signal circuit.
Solution: Redesign the board with optocouplers to switch the relay with a separate power supply for the relays and the IC components.
I have written about this in greater detail in my blog here and have linked the relevant eagle files  here if it is helpful.
As I am still a beginner when it comes to circuit design, I would be greatly appreciative of anyone who could point me in the right direction! Thanks everyone in advance!

A: If you want people to view your pcb and schematic, then make it available as a pdf.
First thing that jumps out at me is no pullup resistors on the i2C. Should be two 2k2 resistors. Any bypass caps?
With the fluoro, I'd suggest placing a varistor (MOV) across the fluoro supply. Something like a S20K270 if the mains is 230VAC or a S20K140 if 110. You could scavenge some movs from a dead PC power supply. A bit of Googling should assist if you are unsure.
The root cause is most likely a transient when the mains is removed from the fluoro. This transient probably finds it way via the relay, across your circuit and back around via your power supply. Adding a mov provides a preferential path for the transient and soaks it up.
Other possible solutions are a snubber across the relay contacts using a 100nF mains rate cap and a 100R 2W metal film resistor.
Having not seen your pcb design, my guess is you don't have enough creepage distance with your relay pins. The cheapy relays have the common pun between the low voltage coil pins. You need to ensure your pcb has slots to isolate the common from low voltage and that your lhigh voltage tracks do not come close to low voltage circuits.
Omron G2R style relays are much easier as they have sufficient distance between the coil and contacts.
I also hope you have adequate pcb track thickness and correct fusing so you don't have a fire risk.
Keep your mains wiring away from the low voltage side.

A: I found that the culprit to the problem was the PCF8574 and so I decided to go with hypothesis 1 and turns out the circuit functions without a hitch by driving the relays with the ESP8266's GPIO.
The PCF8574 still glitches and so occasionally I the lights on the buttons will all go out, but that's ok as the core functionality of the switches in switching the lights remains intact.
Thanks everyone for the help! I will be looking to replace the ESP8266 with an ESP32 with more IOs so I can drive everything from the IOs instead of using the finnicky I2C IO expander.

A: You are using N-FET to make it a Active High relay. PCF8574 has very weak current sourcing capability(about 300 microamps). It is best suitable to drive Active Low loads by sinking current. A PNP transistor or P-FET would have been a better choice.


text:
Q: How to create a linked list with a void function? So I want to know would I make a linked-list using a void function. So I would have a struct
typedef struct linked{
  int i;
  struct linked *next;
}linked;

with the node starting as
linked *head = NULL;

and I want to create it with a function
void createLL(linked *head, int i)

I am familiar with the way of using
linked *createLL(linked *head, int i)

but I am curious on how would it be done with a void function.

A: Pass head in as a pointer to a pointer:
void createLL(linked** head, int i)
{
    linked* pNewHead = (linked*)malloc(sizeof(linked));
    pNewHead->i = i;
    *head = pNewHead;
}

Then to invoke:
linked* head = NULL;
createLL(&head);


text:
Q: Importing Qt Objects into Java - How? I wish to use the Qt GUI framework in my java program.
I've downloaded and installed the QJambi executable, which has made a lovely directory at C:\qtjambi-4.7.1.
I can't for the life of me, figure out how to actually import the Qt API into my java program.
The Qt Jambi wikipedia page wikipedia page on Qt Jambi gives a brief example, with the import statement import com.trolltech.qt.gui.*;, which does not work in my program.
This is obviously because my program can't find the appropriate files; neither can I!
I'm assuming I must have certain files from the Qt Jambi API in my program directory, but I'm not sure which!
So which files should I put where so that I can use the Qt Jambi API?
(I wish to wrap my program as an executable when deploying)
Thanks!
(Sorry for such a rookie problem)

A: Are you using eclipse? You have to set the jar file (presumably there's a library jar file somewhere inside the qtjambi directory) on your classpath.


text:
Q: Symfony2 & Twig, getting user variable I'm having problems getting a user variable, in Twig.
When i'm doing a var_dump(app.user) i get the following:
object(App\Bundle\CoreBundle\Entity\Employee)[1233]
  protected 'id' => int 1
  private 'group' => int 0
  protected 'fullName' => string 'Daniel Mensing' (length=14)
  protected 'username' => string 'dm' (length=2)
  protected 'usernameCanonical' => string 'dm' (length=2)

I've added the "fullName", which was not a part of the FOSUSerbundle.
Now, when i try to output the new variable (fullName) in twig, it tells me it does not exist(??) While the standard variables work fine(username, email..) at first i thought it was because i made fullName private, but doesnt work when protected either. Also in the vardump, they look exactly the same
I'm outputting the variables like this: {{ app.user.username }} or {{ app.user.fullName }}
Any1 can point me in the right direction? Or help explain what i'm doing wrong.
Any help is much appreciated :-) Thanks

A: In Twig you can access object variables by several methods:

*

*Public variable. user.fullName points directly to user object variable, like if you call $object->fullName in php

*Public method. user.fullName points to getFullName() method of user object, like if you call $object->getFullName() in php.
So either make fullName public or add getFullName() method (recommended).

A: protected means that the variabile is available just to same class AND subclasses instances, but not from anywhere else.
Provide you class with a proper public getter, e.g. public function getFullname(){ return $this -> fullName; }.

A: You have to add getter for fullName field in App\Bundle\CoreBundle\Entity\Employee entity:
public function getFullName() {
    return $this->fullName;
}


text:
Q: deploy a machine (with qcow2 image) on KVM automatically via Terraform I am new to terraform and i am trying to deploy a machine (with qcow2 image) on KVM automatically via Terraform.
i found this tf file:
provider "libvirt" {
  uri = "qemu:///system"
}

#provider "libvirt" {
#  alias = "server2"
#  uri   = "qemu+ssh://root@192.168.100.10/system"
#}

resource "libvirt_volume" "centos7-qcow2" {
  name = "centos7.qcow2"
  pool = "default"
  source = "https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2"
  #source = "./CentOS-7-x86_64-GenericCloud.qcow2"
  format = "qcow2"
}

# Define KVM domain to create
resource "libvirt_domain" "db1" {
  name   = "db1"
  memory = "1024"
  vcpu   = 1

  network_interface {
    network_name = "default"
  }

  disk {
    volume_id = "${libvirt_volume.centos7-qcow2.id}"
  }

  console {
    type = "pty"
    target_type = "serial"
    target_port = "0"
  }

  graphics {
    type = "spice"
    listen_type = "address"
    autoport = true
  }
}

my questions are:

*

*(source) the path of my qcow file has to be localy on my computer ?

*I have a KVM machine ip that i connected it remotely by its ip. where should i put this ip in this tf file?

*when i did it manually, i run "virt manager", do i need to write it here anywhere?

thank's a lot.

A: *

*No. It can be https also.

*Do you mean a KVM host that VMs will be created ? Then you need to configure remote kvm access on that host and in the uri section of provider block you need to write its ip.
uri   = "qemu+ssh://username@IP_OF_HOST/system"

*You dont need virt-manager when you use terraform. You should use terraform resources for managing VM.

https://registry.terraform.io/providers/dmacvicar/libvirt/latest/docs
https://github.com/dmacvicar/terraform-provider-libvirt/tree/main/examples/v0.13


text:
Q: class constructor that calculates input using C# Hello and thanks for checking my post. New to C# and Oop in general. Learning has been smooth so far but I'm running into issues when I try to create (and call) a constructor that calculates data input by user.
If possible: I would like to create 3 classes.
MainDisplay class that displays information and gets user input.
BMIBlueprint class that "only" does the calculation for bmi.
BFPBlueprint class that calculates bfp (needs to use bmi total).
I've accomplished this task using one class, But I'd really like to know/comprehend how to do this using multiple classes. I've watched/read/studied every source I could find over the past 2 weeks before posing this but I haven't been able to make sense of creating a constructor that does a calculation, then calling it in main to use user input data for the variables..
The very bottom code is how I've done it in one class (but not quite finished). You can disregard all of that though, I just don't want to come off like I'm completely hopeless or trying to cheat.
This is what I have so far. The first is my BMIBlueprint class that I created just to use as a calculator for bmi based on input from the user, which I plan to call on in my MainClass. also, this is about my 200th different version while trying to make it work and It's probably very far from what it could/should actually look like...
class BMIBlueprint {

    public double bmiBefore;
    public double bmiAFter;

    public BMIBlueprint() { }

    public BMIBlueprint(double height, double weight) {

        bmiBefore = (height * height) * weight;
    }

    public BMIBlueprint(double bmiConst) {

        bmiAFter = bmiBefore * 703;

    }
}

How do I "use" the above class constructor to calculate what the user inputs in my main class ? or am I way off track with it ? My main class is below where I ask for user input then place those values in my constructor.
static void Main() {

    Write("Enter weight: ");
    double weight = double.Parse(ReadLine());

    Write("Enter height: ");
    double height = double.Parse(ReadLine());

    BMIBlueprint calcBmi = new BMIBlueprint(newBmiOne, newBmiTwo);

    //then display after calculated
    WriteLine("The finished cal should be shown here: {0:N2}", calcBmi);

I've tried this many many different ways but this is where I'm at right now; If anyone has the time or kindness to post what the code should be with a couple notes so I could study it, would be absolutely great, but also probably asking for too much. If not any kind of help/advice/metaphors/analogies would be greatly appreciated.
The code below is where I did it all in one class -almost done, but is not part of the question and should be ignored.
static void Main() {

    EntranceBlueprint entrance = new EntranceBlueprint();

    WriteLine(entrance);

    BMIBlueprint bmiCalculator = new BMIBlueprint();

    Write("First, enter your weight in lbs: ");
    double newWeight = double.Parse(bmiCalculator.weight = ReadLine());

    Write("\nGreat, now enter your height in inches: ");
    double newHeight = double.Parse(bmiCalculator.height = ReadLine());

    bmiCalculator.bmiVar = 703;
    double totalBmi = ((newWeight * bmiCalculator.bmiVar) /
                      (newHeight * newHeight));

    WriteLine("\nPerfect! Your bmi is: {0:N2}. With just a few more
              inputs we'll have your bfp. ", +totalBmi);

    Write("\npress any key to continue");
        ReadKey();

    BFPBlueprint bfpCalculator = new BFPBlueprint();

    Write("According to _ your bfp is more accurate because it takes
    into account your age and gender. So enter your age first: ");

    double newAge = double.Parse(bfpCalculator.age = ReadLine());
    Write("\nGreat, now enter your sex, like this (male or female): ");

    string newSex = ReadLine();

        if (newAge >= 13 && newSex.ToLower() == "male") {
            double totalAdultMale =
                (1.20 * totalBmi) - (0.23 * newAge) - (10.8 * 1) - 5.4;
                Write("\nYour bfp is: {0:N2} ", totalAdultMale);
                    if (totalAdultMale > 1 && totalAdultMale < 13)
                    Catagories(); }

        else if (newAge <= 12 && newSex.ToLower() == "male") {
            double totalYouthMaleBfp =
            (1.51 * totalBmi) - (0.70 *newAge) - (3.6 * 1) + 1.4;
            Write("Perfect! Your bfp is: {0:N2}",

        else if (newAge >= 13 && newSex.ToLower() == "female") {
            double totalAdultFemaleBfp =
            (1.20 * totalBmi) - (0.23 * newAge) - (10.8 * 0) - 5.4;
            Write("Perfect! Your bfp is: {0:N2} ",totalAdultFemaleBfp); }

        else if (newAge <= 12 && newSex.ToLower() == "female") {
            double totalYouthFemaleBfp =
            (1.51 * totalBmi) - (0.70 * newAge) - (3.6 * 0) + 1.4;
            Write("Perfect! Your bfp is {0:N2} ", totalYouthFemaleBfp); }

        else { Write("\nYou must have typed something wrong, Try
               again"); }

        ReadKey();

A: You can go about this a number of ways, but from a pure OOP standpoint, using a class is a good idea.
Build your object using the constructor by initializing the members of your class through your construction parameters:
    public class BMIBlueprint {

    private const double BMI_CONST = 703;

    public double Height {get; private set;}
    public double Weight {get; private set;}

    public BMIBlueprint(double height, double weight) {

        this.Height = height;
        this.Weight = weight;
    //instead of passing in variables to perform a function in your constructor
    //use them to initialize your member variables
    //bmiBefore = (height * height) * weight;
    }

    public double GetBMIBefore(){

        double bmiBefore = (this.Height * this.Height) * this.Weight;
        return bmiBefore;
    }

    public double GetBMIAfter() {

        double bmiBefore = this.GetBMIBefore();
        double bmiAfter = bmiBefore * BMI_CONST;
        return bmiAfter;
    }

Then call the method(s) contained in this class to do your calculation(s) from the object:
static void Main() {
    Write("Enter weight: ");
    double weight = double.Parse(ReadLine());

    Write("Enter height: ");
    double height = double.Parse(ReadLine());

    BFPBlueprint bmiCalculator = new BFPBlueprint(height, weight);

    double bmiBefore = bmiCalculator.GetBMIBefore();
    double bmiAfter = bmiCalculator.GetBMIAfter();
    //etc...

The point here is to encapsulate all your bmi calculation logic and values in one class so it is easy to use.
OR
You could instead use a static class that implements these methods and doesn't contain any member variables:
public static class BmiCalculator
{
    private const double BMI_CONST = 703;

    public double static GetNewBMI(double height, double weight)
    {
        double newBMI = (height * height) * weight;
        return newBMI;
    }

    public double GetAdjustedBMI(double oldBMI)
    {
        double adjustedBMI = oldBMI * BMI_CONST;
        return adjustedBMI;
    }

To implement in your Main:
static void Main() {
    Write("Enter weight: ");
    double weight = double.Parse(ReadLine());

    Write("Enter height: ");
    double height = double.Parse(ReadLine());

    double bmiBefore = BmiCalculator.GetNewBMI(height, weight);
    double bmiAfter = BmiCalculator.GetAdjustedBMI(bmiBefore);
    //etc...

A: Here's a simple example:
using System;

namespace ConsoleApplication
{
    class BMIBlueprint
    {
        private const int BMI_VAR = 703;

        public double Bmi { get; private set; }

        public BMIBlueprint(double height, double weight)
        {
            Bmi = height * height * weight;
        }

        public void Adjust()
        {
            Bmi *= BMI_VAR;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Enter weight: ");
            double weight = double.Parse(Console.ReadLine());

            Console.Write("Enter height: ");
            double height = double.Parse(Console.ReadLine());

            BMIBlueprint calcBmi = new BMIBlueprint(height, weight);

            calcBmi.Adjust();

            //then display after calculated
            Console.WriteLine("The finished cal should be shown here: {0:N2}", calcBmi.Bmi);

            Console.Write("\nPress any key...");
            Console.ReadKey();
        }
    }
}

A: your problem is this code:
WriteLine("The finished cal should be shown here: {0:N2}", calcBmi);

The WriteLine function will not take calcBmi, which is a BMIBlueprint, as a parameter. Also {0:N2} is a wrong syntax. You could do this however:
WriteLine("The finished cal.bmiBefore should be shown here: {0}", calcBmi.bmiBefore);
WriteLine("The finished cal.bmiBefore should be shown here: {0}", calcBmi.bmiBefore);

A: Here's a more advanced example of an OOP approach, complete with input validation. Note, you may need to modify Person based on the exact functionality you want to have. The calculators/history tracking may be objects themselves. I simply showed how the excerpt you posted could be written in a C#/OOP fashion.
using System;
using System.Linq;

namespace BMI_StackOverflow
{
    class Program
    {
        static void Main(string[] args)
        {
            PersonValidator inputValidator = new PersonValidator();
            Person person = new Person();
            person.Weight = CollectUserInput<double>("First, enter your weight in lbs: ",
                inputValidator.IsValidWeight, "Please enter a positive number: ");
            person.Height = CollectUserInput<double>("\nGreat, now enter your height in inches: ",
                inputValidator.IsValidHeight, "Please enter a positive number: ");

            double bmi = person.GetBmi();
            Console.WriteLine("\nPerfect! Your bmi is: {0:N2}. With just a few more inputs we'll have your bfp. ", +bmi);
            Console.Write("\nPress any key to continue");
            Console.ReadKey();

            person.Age = CollectUserInput<int>("According to _ your bfp is more accurate because it takes into account your age and gender. So enter your age first: ",
                inputValidator.IsValidAge, "Please enter a positive, non-decimal number.");
            string sex = CollectUserInput<string>("\nGreat, now enter your sex, like this (male or female): ",
                inputValidator.IsValidSex, $"That sex is not recognized. Please input one of: {string.Join(", ", Enum.GetNames(typeof(Person.BiologicalSex)).Select(x => x.ToLower()))}");
            person.Sex = inputValidator.ParseSex(sex).Value;

            double bfp = person.GetBfp();
            Console.WriteLine("Perfect! Your bfp is {0:N2} ", +bfp);
            Console.ReadKey();
        }

        /// <summary>
        /// Prompts user for console input; reprompts untils correct type recieved. Returns input as specified type.
        /// </summary>
        /// <param name="message">Display message to prompt user for input.</param>
        private static T CollectUserInput<T>(string message = null)
        {
            if (message != null)
            {
                Console.WriteLine(message);
            }
            while (true)
            {
                string rawInput = Console.ReadLine();
                try
                {
                    return (T)Convert.ChangeType(rawInput, typeof(T));
                }
                catch
                {
                    Console.WriteLine($"Please input a response of type: {typeof(T).ToString()}");
                }
            }
        }

        /// <summary>
        /// Prompts user for console input; reprompts untils correct type recieved. Returns input as specified type.
        /// </summary>
        /// <param name="message">Display message to prompt user for input.</param>
        /// <param name="validate">Prompt user to reenter input until it passes this validation function.</param>
        /// <param name="validationFailureMessage">Message displayed to user after each validation failure.</param>
        private static T CollectUserInput<T>(string message, Func<T, bool> validate, string validationFailureMessage = null)
        {
            var input = CollectUserInput<T>(message);
            bool isValid = validate(input);
            while (!isValid)
            {
                Console.WriteLine(validationFailureMessage);
                input = CollectUserInput<T>();
                isValid = validate(input);
            }
            return input;
        }
    }

    public class Person
    {
        public double Weight { get; set; }
        public double Height { get; set; }
        public int Age { get; set; }
        public BiologicalSex Sex { get; set; }

        private const int bmiVar = 703;

        public double GetBmi()
        {
            return ((Weight * bmiVar) /
                   (Math.Pow(Height, 2)));
        }

        public double GetBfp()
        {
            double bmi = GetBmi();
            switch (Sex)
            {
                case BiologicalSex.MALE:
                    if (Age >= 13)
                    {
                        return (1.20 * bmi) - (0.23 * Age) - (10.8 * 1) - 5.4;
                    }
                    return (1.51 * bmi) - (0.70 * Age) - (3.6 * 1) + 1.4;
                case BiologicalSex.FEMALE:
                    if (Age >= 13)
                    {
                        return (1.20 * bmi) - (0.23 * Age) - (10.8 * 0) - 5.4;
                    }
                    return (1.51 * bmi) - (0.70 * Age) - (3.6 * 0) + 1.4;
                default:
                    throw new Exception($"No BFP calculation rule for sex: {Sex}");
            }
        }

        public enum BiologicalSex
        {
            MALE,
            FEMALE
        }
    }

    public class PersonValidator
    {
        public bool IsValidWeight(double weight)
        {
            return weight >= 0;
        }

        public bool IsValidHeight(double height)
        {
            return height >= 0;
        }

        public bool IsValidAge(int age)
        {
            return age >= 0;
        }

        public bool IsValidSex(string sex)
        {
            return ParseSex(sex) != null;
        }

        /// <summary>
        /// Attempts to parse sex from string. Returns null on failure.
        /// </summary>
        public Person.BiologicalSex? ParseSex(string sex)
        {
            int temp;
            bool isNumber = int.TryParse(sex, out temp);
            if (isNumber)
            {
                return null;
            }
            try
            {
                return (Person.BiologicalSex)Enum.Parse(typeof(Person.BiologicalSex), sex, ignoreCase: true);
            }
            catch (ArgumentException ex)
            {
                return null;
            }
        }
    }
}


text:
Q: How to get mailto on interactive grid in sql (apex oracle) on column Kontakti there is email lets say info@example.com how to make in mailto in sql.and all others will appear in this section Kontakti so how to make them mailto

A: Use appropriate HTML tag with the mailto keyword. For example:
SQL> with kontakti (ime, adresa) as
  2    (select 'Little', 'little@gamil.com' from dual union all
  3     select 'Foot'  , 'foot@hotmial.com' from dual
  4    )
  5  select ime,
  6    'Send email' mailto
  7  from kontakti
  8  /

IME    MAILTO
------ ------------------------------------------------
Little Send email
Foot   Send email

SQL>

In Apex, you'll have to set "Escape special characters" to No for the mailto column.

A: Change the column Type to HTML Expression. Set the attribute HTML Expression on the column to:
&KONTAKTI.

(I'm assuming your column name is KONTAKTI).


text:
Q: (Common Table Expressions) CTE as part of WHERE clause... possible? Is it possible to use CTE in a WHERE clause e.g.
SELECT *
  FROM Table1
 WHERE Table1.PK IN (
   WITH Cte AS (
    -- root selection (dynamic, generated in code)
    SELECT Bla FROM Table2
    -- recursive part
    UNION ALL
    SELECT …..)
  SELECT Bla FROM Cte)

The reason I'm asking is that I need to use a recursive query and the only way of doing it at the moment without updating our framework is to place it in the where clause.

A: No, WITH clauses need to be defined before the main SELECT.  Like this:
WITH recursive_cte AS (
   -- root selection (dynamic, generated in code)
   SELECT Bla FROM Table2
   -- recursive part
   UNION ALL
   SELECT …..)
SELECT t.*
  FROM TABLE1 t
  JOIN recursive_cte rc ON rc.key = t.pk

I also tweaked the query to use a JOIN instead, but you'll have to watch for duplicates.

A: Yes you can apply WHERE CLAUSE with CTE. You have to make Table-Valued Function and return result in Table.
then you can use this result set in any query with WHERE Clause.
Go to the link and find example:
http://muhammadnaveed.info/use-cte-query-in-where-clause/
Hope this will help you.


text:
Q: Runtime Error with Vim Omnicompletion I was trying to use Vim's omnicompletion with my Python code, but whenever I try C-x + C-o, it prompts the following error message:

Runtime Error!
Program E:\Vim\vim73\gvim.exe
R6034
An application has made an attempt to load the C runtime library incorrectly.
Please contact the application's support team for more information.

Could anybody please tell me how to solve this problem!  Many many thanks!

A: I had the same problem (Windows 7) and I could solve it by removing paths from my PATH variable that contain msvcr90.dll.
After removing several entries the error stopped popping up. Unfortunately I didn't make a note of which entries I removed. But It was C:\Program Files (x86)\OpenVPN\bin and several others including Windows Live.
I got the hint about looking for the problem in the path from here (bottom of the page): https://bitbucket.org/Haroogan/vim-youcompleteme-for-windows/src

A: I have the same issue which cause by gvim not able to load python pyd dll. There are some tips to solve the .pyd dll which cause the above issue. I'm not sure is there any way to solve the Runtime Error for all dll.
Refere to Not embed the correct manifest for the msvc runtimes on windows link on how to solve your issue.
Update:
Instead of updating manifest for the .pyd file. I tried to update manifest for gvim directly by updating the original gvim manifest with some changes from python.exe manifest.
# dump manifest from gvim.exe
>> mt.exe -inputresource:gvim.exe;#1 -out:gvim.manifest

# dump manifest from python.exe
# *I use python26 for gvim, default gvim come with python27
>> mt.exe -inputresource:c:\python26\python.exe;#1 -out:python.manifest

# manually edit gvim.manifest, just change the line with dependentAssembly with
# line from the python.manifest which will depend on VC90.CRT
# Then, update the edited manifest into gvim.exe
>> mt.exe -manifest gvim.manifest -outputresource:gvim.exe;1

Below are my edited gvim.manifest:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
  <assemblyIdentity processorArchitecture="*" version="7.3.0.0" type="win32" name="Vim"></assemblyIdentity>
  <description>Vi Improved - A Text Editor</description>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    </dependentAssembly>
  </dependency>

  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
      </requestedPrivileges>
    </security>
  </trustInfo>

  <asmv3:application>
    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
      <dpiAware>true</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>
</assembly>


text:
Q: Cutting a specific column from a space delimited file I run a hmmscan analysis using a FASTA file asking for tabular output format with --tblout option, which is deliberately space-delimited (rather than tab-delimited) and justified into aligned columns.
The file looks like this (this is just a format example)
targetname accession queryname    accession  e-value score bias
x_x_x      PFyyyy.y  ContigXXX_0  -          x.xe-xx yy.y  x.x
x          PFyyyy.yy COntigXXX_1  -          xe-x    yy.y  x.x
x_x        PFyyyy.y  COntigXXX_2  -          xe-xx    y.y  x.x
x_x_x      PFyyyy.yy COntigXXX_3  -          x.xe-x  yy.y  x.x
.
..

where target name are for example: Methyltransf or Dimer_tnp_hAT or Nucleotide_trans
where accession are for example: PF13847.1 or PF03407.11 or PF01958.13;
where query name are for example: Contig244_1 or Contig44245_3 or Contig12345_6
where the second accession column is: -
where e.value are for example: 4.0e-10 or 3.5e-15, etc..
and score and bias are numbers in this format: xx.x
What I'd like to do is to cut the queryname column where all the ContigXXX_X with significant hits to protein domains are.
After this I'll be able to sort them and keep only the first occurence of each Contig and I can compare the file with the results from BlastP and BlastX (where I was already able to get the list of my Contigs that have hits to nr database)
So my question is: How can I cut the column where all my Contigs are?
I've been try with grep,sed,cut commands but I haven't found the right one yet.
I'm new to Unix language and I'm still learning so every suggestions will be really appreciate.
And if my question is not clear just tell me, I can modify it!

A: Superficially, if you have GNU cut, you can use:
cut -i -f 3 tblout-file

The -i option means that one or blanks will be taken as the field delimiters (whereas without it, each blank is a field delimiter).  Non-GNU versions of cut typically do not support -i.  (You can check whether it is GNU cut by running cut --version; if you get a meaningful version number, it's (probably) GNU, and if you get invalid option messages, it isn't.)
Does that not work for you?  Obviously, you substitute the name of the file you created for tblout-file.
If there's a problem (such as not having GNU cut), then consider awk instead:
awk '{print $3}' tblout-file

Both these include the first line in the output too; there are multiple possible ways of removing the first line.
cut -i -f 3 tblout-file | sed 1d
awk 'NR>1 { print $3 }' tblout-file

A: awk 'NR!=1{print $3}' your_file

or
perl -F -lane 'if($.!=1){print $F[2]}' your_file


text:
Q: how can one Unit test a non deterministic encryption function? I am trying to reimplement a non deterministic encryption function from javascript to java. I noticed however that the output of the function is different every time. However, whenever I decrypt the output, it always returns the original text.
For example:
word: hello
encrypted: ?HX?631ffe50353ddda632a7e8fa11136d6ffaa584eb43b34c96005b6256f9dc 4121c7a8545d79887b900672e5870d702441?H
decrypted: hello
word: hello
encrypted: ?HX?dfea4d1d30ebd5fc871c7c92d0230baf9e5298b19c3cfa0770fe2d2035f8 dad0116f2963b115c85c9d4725be505fca54?H
decrypted: hello
and so on....
To unit test this, one way I can think of is to also implement the decrypt function in java and then decrypt the output of the encryption function. If the decryption yields the original text then the encryption is correct.
For example:
encrypted = Encrypt_text(word);
assertEquals(word,Decrypt_text(encrypted);

Any other suggestions...?

A: Better to use the original decrypt function to validate your encrypt function, rather than a new decrypt routine. If you write both and use them to test each other you will have validated that the data round-trips correctly but you will not have validated the intermediate result.
You could use Mozilla Rhino to run the Javascript decrypt routine: http://www.mozilla.org/rhino/

A: If you are not interested in the encrypted form then the assertions are just perfect.


text:
Q: Sourcetree not detecting changes to a .dll file I have a .dll file that is tracked and added to source control (so it's not being ignored anywhere).
The problem is that I recently updated it but Sourcetree is not detecting that it changed.

A: *

*Try adding it again using
git add -f
One reason is "*.dll" might be in your global ignore.
We can use git check-ignore to find out where the global gitignore file is.

*We can use the below command to check the files which are ignored by the gitignore:
git ls-files . --ignored --exclude-standard --others

A: First, switch to command-line, using the latest Git for Windows, in a CMD session with a simplified PATH.
There, go to your repo root folder, and type, using git check-ignore :
git check-ignore -v -- path/to/your/file.dll

If that returns nothing, you are sure it is not ignored, and should be tracked.
Type, using git check-attr:
git check-attr --all -- path/to/your/file.dll

If that returns nothing, that means no .gitattributes directive would be influencing the diff which should be detected.
Make sure git status mentions that you are on a branch (instead of a detached HEAD)

Update Feb. 2019 for Git 2.21: Asking "git check-attr" about a macro (e.g. "binary") on a specific path did not work correctly, even though "git check-attr -a" listed such a macro correctly.  This has been corrected.
See commit 7b95849 (18 Jan 2019) by Jeff King (peff).
(Merged by Junio C Hamano -- gitster -- in commit 02bf766, 05 Feb 2019)
That means, with Git 2.21, git check-attr binary file should return file: binary: set. (instead of file: binary: unspecified)

A: Look into nuget to get the 3rd-party dll out of git.
Does the 3rd-party vendor provide a nuget feed for this assembly?
If not, It's worth asking them to start. If not, you can make one
https://learn.microsoft.com/en-us/nuget/create-packages/creating-a-package
Do you already have private nuget feeds? If not it's worth looking into.
https://learn.microsoft.com/en-us/nuget/hosting-packages/overview
You're going to be so much happier getting the derived artifacts out of source.


text:
Q: FORCE_SSL_ADMIN only for the admin area I have a wordpress site
i would like to change only the admin area to https.
i try to add define('FORCE_SSL_ADMIN', true); in wp-config.php but it is changing the site and the admin area is changing to https
any ideas?

A: That constant is used to transfer the connection to HTTPS when entering wp-admin, but it is not used to transfer the connection to plain HTTP when leaving wp-admin. The problem here is that you leave HTTPS wp-admin and end up on HTTPS frontend.
You can use server rewrite directives or PHP header redirects to switch the protocol. Example (not tested) for Apache rewrite:
<IfModule mod_rewrite.c>
    RewriteEngine On

    # Are we on HTTPS?
    RewriteCond %{HTTPS} on

    # Are we _not_ on wp-admin or login?
    RewriteCond %{REQUEST_URI} !(/wp-admin|/wp-login)

    # Simple redirect to your domain and the requested URL.
    RewriteRule ^(.*)$ http://www.yourdomain.abc/$1 [L,R=301]
</IfModule>

Example (not tested) for using wp_redirect:
add_action('template_redirect', function () {
    global $pagenow;

    // Not a HTTPS connection.
    if ($_SERVER['HTTPS'] !== 'on') {
        return;
    }

    // We are either in wp-admin or on login.
    if (is_admin() || strpos($pagenow, 'wp-login') !== false) {
        return;
    }

    // Grab the current request URL.
    $requestUri = $_SERVER['REQUEST_URI'];

    // Get non-HTTPS WP url.
    $newUrl = str_replace('https://', 'http://', home_url($requestUri));

    wp_redirect($newUrl);
    exit;
});

A: you can do it by modifying .htaccess file
Add this code in top of htaccess file
 RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)\ HTTP/ [NC]
  RewriteCond %{HTTPS} !=on [NC]
  RewriteRule ^/?(wp-admin/|wp-login\.php) https://example.com%{REQUEST_URI}%{QUERY_STRING} [R=301,QSA,L]

Hope this will work for you.


text:
Q: Re-sign IPA (iPhone) I currently build all my applications with hudson using xcodebuild followed by a xcrun without any problems
I've received a couple of IPA files from different people that I would like to re-sign with a enterprise account instead of the corporate account (for the app store, or sometimes ad-hoc distributed).
My problem is that when I try to resign the app, it won't install on my device (and it should since it's a Enterprise build). The error message is on the device (not in iTunes) and it tells me simply that it couldn't install the app. No more information is given.
I've found some information, ( http://www.ketzler.de/2011/01/resign-an-iphone-app-insert-new-bundle-id-and-send-to-xcode-organizer-for-upload/ )
And this might be possible. The problem I'm facing is that it doesn't seem to embed the mobile provisioning profile as I do with my normal builds (using xcrun) is this possible to control with the codesign tool, or is it possible to re-sign with xcrun?
With my resign script i currently do

*

*unzip app.ipa

*appname=$(ls Payload)

*xcrun -sdk iphoneos PackageApplication -s "$provisioning_profile" "$project_dir/Payload/$appname" -o "$project_dir/app-resigned.ipa" --sign "$provisioning_profile" --embed "$mobileprovision"

I've looked in the resulting ipa file and it seems to be very similar to the original app. What files should really change here? I initially thought the the _CodeSignature/CodeResources would change, but the content looks pretty much exactly the same.
Pointers are much appreciated.

A: The answers to this question are a little out of date and missing potentially key steps, so this is an updated guide for installing an app from an external developer.
----- How to Resign an iOS App -----
Let's say you receive an app (e.g. MyApp.ipa) from another developer, and you want to be able to install and run it on your devices (by using ideviceinstaller, for example).
Prepare New Signing Assets
The first step is to attain a Provisioning Profile which includes all of the devices you wish to install and run on. Ensure that the profile contains a certificate that you have installed in your Keychain Access (e.g. iPhone Developer: Some Body (XXXXXXXXXX) ). Download the profile (MyProfile.mobileprovision) so you can replace the profile embedded in the app.
Next, we are going to prepare an entitlements file to include in the signing. Open up your terminal and run the following.
$ security cms -D -i path/to/MyProfile.mobileprovision > provision.plist

This will create an xml file describing your Provisioning Profile. Next, we want to extract the entitlements into a file.
$ /usr/libexec/PlistBuddy -x -c 'Print :Entitlements' provision.plist > entitlements.plist

Replace The Provisioning Profile and Resign App
If you are working with a .ipa file, first, unzip the app (if you have a .app instead, you can skip this step).
$ unzip MyApp.ipa

Your working directory will now contain Payload/ and Payload/MyApp.app/. Next, remove the old code signature files.
$ rm -rf Payload/MyApp.app/_CodeSignature

Replace the existing provisioning profile (i.e. embedded.mobileprovision) with your own.
$ cp path/to/MyProfile.mobileprovision Payload/MyApp.app/embedded.mobileprovision

IMPORTANT: You must also resign all frameworks included in the app. You will find these in Payload/MyApp.app/Frameworks. If the app is written in Swift or if it includes any additional frameworks these must be resigned or the app will install but not run.
$ /usr/bin/codesign -f -s "iPhone Developer: Some Body (XXXXXXXXXX)" --entitlements entitlements.plist Payload/MyApp.app/Frameworks/*

Now sign the app with the certificate included in your provisioning profile and the entitlements.plist that you created earlier.
$ /usr/bin/codesign -f -s "iPhone Developer: Some Body (XXXXXXXXXX)" --entitlements entitlements.plist Payload/MyApp.app

You can now rezip the app.
$ zip -qr MyApp-resigned.ipa Payload

Done
You may now remove the Payload directory since you have your original app (MyApp.ipa) and your resigned version (MyApp-resigned.ipa). You can now install MyApp-resigned.ipa on any device included in your provisioning profile.

A: Checked with Mac OS High Sierra and Xcode 10
You can simply implement the same using the application iResign.
Give path of
1).ipa
2) New provision profile
3) Entitlement file (Optional, add only if you have entitlement)
4) Bundle id
5) Distribution Certificate
You can see output .ipa file saved after re-sign
Simple and powerful tool

A: In 2020, I did it with Fastlane -
Here is the command I used
$ fastlane run resign ipa:"/Users/my_user/path/to/app.ipa" signing_identity:"iPhone Distribution: MY Company (XXXXXXXX)" provisioning_profile:"/Users/my_user/path/to/profile.mobileprovision" bundle_id:com.company.new.bundle.name

Full docs here - https://docs.fastlane.tools/actions/resign/

A: None of these resigning approaches were working for me, so I had to work out something else.
In my case, I had an IPA with an expired certificate. I could have rebuilt the app, but because we wanted to ensure we were distributing exactly the same version (just with a new certificate), we did not want to rebuild it.
Instead of the ways of resigning mentioned in the other answers, I turned to Xcode's method of creating an IPA, which starts with an .xcarchive from a build.

*

*I duplicated an existing .xcarchive and started replacing the contents. (I ignored the .dSYM file.)

*I extracted the old app from the old IPA file (via unzipping; the app is the only thing in the Payload folder)

*I moved this app into the new .xcarchive, under Products/Applications replacing the app that was there.

*I edited Info.plist, editing

*

*ApplicationProperties/ApplicationPath

*ApplicationProperties/CFBundleIdentifier

*ApplicationProperties/CFBundleShortVersionString

*ApplicationProperties/CFBundleVersion

*Name

*I moved the .xcarchive into Xcode's archive folder, usually /Users/xxxx/Library/Developer/Xcode/Archives.

*In Xcode, I opened the Organiser window, picked this new archive and did a regular (in this case Enterprise) export.
The result was a good IPA that works.

A: Finally got this working!
Tested with a IPA signed with cert1 for app store submission with no devices added in the provisioning profile. Results in a new IPA signed with a enterprise account and a mobile provisioning profile for in house deployment (the mobile provisioning profile gets embedded to the IPA).
Solution:
Unzip the IPA
unzip Application.ipa

Remove old CodeSignature
rm -r "Payload/Application.app/_CodeSignature" "Payload/Application.app/CodeResources" 2> /dev/null || true

Replace embedded mobile provisioning profile
cp "MyEnterprise.mobileprovision" "Payload/Application.app/embedded.mobileprovision"

Re-sign
/usr/bin/codesign -f -s "iPhone Distribution: Certificate Name" --resource-rules "Payload/Application.app/ResourceRules.plist" "Payload/Application.app"

Re-package
zip -qr "Application.resigned.ipa" Payload

Edit: Removed the Entitlement part (see alleys comment, thanks)

A: I think the easiest is to use Fastlane:
sudo gem install fastlane -NV
hash -r # for bash
rehash # for zsh
fastlane sigh resign ./path/app.ipa --signing_identity "Apple Distribution: Company Name" -p "my.mobileprovision"

A: I successfully followed this answer, but since entitlements have changed, I simply removed the --entitlements "Payload/Application.app/Entitlements.plist" part of the second to last statement, and it worked like a charm.

A: With Fastlane sigh's resign option you can do this very easily.
sigh resign -p <path-to-profile-with-mobileprovision-ext> -i <code-sighning-identity-of-your-app>

You can download the profile using sigh also, just before the command.

A: I tried all the Solution but finally I am able to create resign ipa with these commands
Resign Certificates

*

**is the ipa name and also app name
$PROVISION is the path of the provision profile
$CERTIFICATE is the name of the certificate in key chain full name (Common name when double click on the certificate)

*

*Go the Directory where want to create the new ipa with resign certificates . Pase all the files there ipa, certificate and
mobileprovision and also install the certificate

*security cms -D -i path/to/MyProfile.mobileprovision > provision.plist (Call this command and replace mobile provision with
path of the file)

*/usr/libexec/PlistBuddy -x -c 'Print :Entitlements' provision.plist > entitlements.plist (Hit this command)

*unzip -q *.ipa

*rm -rf Payload/*.app/_CodeSignature/

*/usr/libexec/PlistBuddy Payload/*.app/Info.plist  (After this command we have to add new bundle ID if we don't need to change bundle
id Then we can ignore these 3 steps)

7.  Set :CFBundleIdentifier "com.mycompany.newbundleidentifier" (This should be new bundle ID)
8.  save
9.  quit

*cp $PROVISION Payload/*.app/embedded.mobileprovision

*codesign -d --entitlements :entitlements.plist Payload/*.app/ (Try to ignore this command if app doesn't work then next time use
this command)

*codesign -f -s "$CERTIFICATE" --entitlements entitlements.plist Payload/.app/Frameworks/

*codesign -f -s "$CERTIFICATE" --entitlements entitlements.plist Payload/*.app/

*zip -qr resigned.ipa Payload

https://stackoverflow.com/a/37172815
https://stackoverflow.com/a/50392448
https://coderwall.com/p/qwqpnw/resign-ipa-with-new-cfbundleidentifier-and-certificate

A: If your APP is built using Flutter tools, please examine the codesign info for all pod extensions:
codesign -d --verbose=4 Runner.app/Frameworks/xxx.framework |& grep 'Authority='

The result should be the name of your team.
Run the shell script below to codesign all extensions:
IDENTITY=<prefix of Team ID number>
ENTITLEMENTS=<entitlements.plist>
find Payload/Runner.app -type d -name '*framework' | xargs -I '{}' codesign -s $IDENTITY -f --entitlements $ENTITLEMENTS {}

And finally don't forget to codesign the Runner.app itself

A: You can use XReSign app (a simple GUI tool) for re-signing your ipa, i used it for re-signing my enterprise distribution app and it worked fine
https://github.com/xndrs/XReSign
All you need is

*

*ipa to resign

*mobileprovision

*entitlements (to generate entitlements please check the below steps)

*enterprise distribution certificate

To generate entitlements:
Open up terminal
$ security cms -D -i "your_path/Enterprise_Distribution.mobileprovision" > provision.plist

then
$ /usr/libexec/PlistBuddy -x -c 'Print :Entitlements' provision.plist > entitlements.plist

Thanks

A: If you have an app with extensions and/or a watch app and you have multiple provisioning profiles for each extension/watch app then you should use this script to re-sign the ipa file.
Re-signing script at Github
Here is an example of how to use this script:
./resign.sh YourApp.ipa "iPhone Distribution: YourCompanyOrDeveloperName" -p <path_to_provisioning_profile_for_app>.mobileprovision -p <path_to_provisioning_profile_for_watchkitextension>.mobileprovision -p <path_to_provisioning_profile_for_watchkitapp>.mobileprovision -p <path_to_provisioning_profile_for_todayextension>.mobileprovision  resignedYourApp.ipa

You can include other extension provisioning profiles too by adding it with yet another -p option.
For me - all the provisioning profiles were signed by the same certificate/signing identity.


text:
Q: is there a way to get the full path of a result in a jmespath query? As an example, I have this json
{
  "machines": [
    {"name": "a", "state": "running"},
    {"name": "b", "state": "stopped"},
    {"name": "b", "state": "running"}
  ]
}

and my query is machines[?state=='stopped'].name which gives the result of ["b"]
but instead I want to get the path of that result e.g. machines[1] or machines[1].name
I know this can be done with jsonpath-ng in python, but I want to use jmespath.


text:
Q: Package Drive Connect Install Failed I'm having this problem while trying to install Drive Connect in my Sandbox env.
Your request to install package "Drive Connect 2.85" was unsuccessful. None of the data or setup information in your salesforce.com organization was affected.
If your install continues to fail, contact Salesforce CRM Support through your normal channels and provide the following information.
Problem:

*

*Missing Organization Feature: ApiAndPlatformEvents
null

*Missing Organization Feature: ApiAndHighVolumePlatformEvents
null
How do I enable ApiAndPlatformEvents and ApiAndHighVolumePlatformEvents in my Org?


text:
Q: lsof: WARNING: can't stat() fuse.gvfsd-fuse file system What exactly is happening here?
root@bob-p7-1298c:/# ls -l /tmp/report.csv && lsof | grep "report.csv"
-rw-r--r-- 1 mysql mysql 1430 Dec  4 12:34 /tmp/report.csv
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
      Output information may be incomplete.

A: FUSE and its access rights
lsof by default checks all mounted file systems including FUSE - file systems implemented in user space which have special access rights in Linux.
As you can see in this answer on Ask Ubuntu a mounted GVFS file system (special case of FUSE) is normally accessible only to the user which mounted it (the owner of gvfsd-fuse). Even root cannot access it. To override this restriction it is possible to use mount options allow_root and allow_other. The option must be also enabled in the FUSE daemon which is described for example in this answer ...but in your case you do not need to (and should not) change the access rights.
Excluding file systems from lsof
In your case lsof does not need to check the GVFS file systems so you can exclude the stat() calls on them using the -e option (or you can just ignore the waring):
lsof -e /run/user/1000/gvfs

Checking certain files by lsof
You are using lsof to get information about all processes running on your system and only then you filter the complete output using grep. If you want to check just certain files and the related processes use the -f option without a value directly following it then specify a list of files after the "end of options" separator --. This will be considerably faster.
lsof -e /run/user/1000/gvfs -f -- /tmp/report.csv

General solution
To exclude all mounted file systems on which stat() fails you can run something like this (in bash):
x=(); for a in $(mount | cut -d' ' -f3); do test -e "$a" || x+=("-e$a"); done
lsof "${x[@]}" -f -- /tmp/report.csv

Or to be sure to use stat() (test -e could be implemented a different way):
x=(); for a in $(mount | cut -d' ' -f3); do stat --printf= "$a" 2>/dev/null || x+=("-e$a"); done

A: lsof always tries to obtain some basic information about all filesystems, even if the arguments happen to imply that no result will come from a particular filesystem. If it's unable to access a filesystem (specifically, to call stat at its mount point, as the message says), it complains.
As root, you would normally have permission to access filesystems. However, due to the inner workings of FUSE, root does not automatically have all powers on a FUSE filesystem. This isn't a security feature (root can become the user who owns the filesystem and get access that way), it's a technical limitation.
GVFS-FUSE is a FUSE interface to GVFS, which is a mechanism that allows Gnome applications to access virtual filesystems implemented by Gnome plugins: GVFS grants non-Gnome applications access to these virtual filesystems via the regular filesystem interface.


text:
Q: Immutable.js getters for invoking functions in object literal notation I'm trying to pass a function into a Map in the same way you would using object literal notation.  Is there any way native to Immutable that could invoke the function as though you were using a getter method on an enumerable?
var person = {
  firstName: 'John',
  lastName: 'Smith',
  format: function() {
    return this.lastName + ', ' + this.firstName;
  }
};

person.format(); // 'Smith, John'

var personMap = new Immutable.Map(person);

personMap.get('format'); // function() {return ... // doesn't work

A: I am not familiar with Immutable.js, but you can always bind the function to the proper this before it goes into the collection.
Simplest case:
person.format.bind (person);
// create immutable here

More generally, if I may presume that the collection is the only way you intend to reference the object and inherited methods are not an issue:
function objectAsCollection (object) {
    var key;
    for (key of Object.keys (object)) {
        if (typeof object [key] == "function") {
            object [key] = object [key].bind (object);
       }
    }
    return new Immutable.Map (object);
}

This does modify the original object, but in a way that calling person.format () is not affected, and mapYouMade.get ("format")() will have this pointing at person.  Some problems may arise depending on the rest of your code:

*

*If person becomes the prototype of an object or class, the function will always behave as if this.format still refers to the prototype instead of the derived object.

*If person.whateverProperty is modified, the change is not reflected in the immutable map, but theMap.get ("format")() will use the new values since it is bound to the original object, not the entries in the map, meaning that methods in the immutable would be quite mutable.

It sounds like what you want is not actually an immutable map but an immutable object; after all, collections are for homogeneous value types and methods belong on objects to which they pertain.  My advise in this case would be to forget about Immutable.js and use:
Object.freeze (person);

Which makes the object itself immutable without the hazards inherent to the collection.  If you simply must have a collection for some reason, you must extend the collection class and/or use proxies to get format to fetch other entries from its containing collection so that person may be mutated independently. Please comment if this is the case, I can show you how to do it, but I am not familiar with Immutable.js classes, and proxies are a complicated beast.


text:
Q: Why does OctoberCMS lack a visual editor Page & Post content? As a Content Management System I expected non-developers could edit Page content in a visual editor. I'm unclear why this was not included.
But Laravel and OctoberCMS is still slightly abstract for me, as I come from WordPress - like many.
Note, I am a programmer, not a front end user. But I build websites and applications for non-programmers.

A: Content Management System is designed to programmer. The programmer can edit without a text editor or edit with the site in live server.
For non-programmer users we has another Plugins, like Static Pages. With this plugin the user has more tools to edit any content without coding.

A: There are a few plugins like Wysiwyg Editors, Static Pages, and Content Editor which can help bring your platform closer to WordPress. I have used one of these for numerous clients.
Though I have gotten to the point to where I have started making my own front end plugins that allow my clients to create, update, and delete pages. Add them to a menu etc. They can choose the layout, add sidebar(s) content and images. The plugins are all unique depending on what the client wants.
I think this is where OctoberCMS shines for developers and ultimately for your client. They don't need to be overwhelmed by everything in WordPress. You as a developer create a system (and hopefully foolproof it) that the client needs then hand it over to the client.


text:
Q: Altair Y-Axis Label Left-Alignment & Spacing Edits Possible? I'm trying to recreate this chart in Altair but can't figure out how to make a few minor edits: https://datawrapper.dwcdn.net/E0jaK/1/
Here's my current progress: https://imgur.com/RMuTU7h
The three edits I'm trying to figure out are:

*

*How to left-align y-axis labels

*How to add spacing between the labels and the y-axis

*How to move bar number labels to the base of the bars instead of the ends
Any insight on how to implement these edits would be great.
Here's the raw data:
Crime,Count
Larceny/Theft,739
Assault,177
Burglary/Breaking & Entering,133
Destruction of Property/Vandalism,128
Drugs,107
Motor Vehicle Theft,95
Fraud,71
Sex Offenses,57
Suspicious Activity,45
Trespassing,23
Family Offenses,22
Weapons Violations,21

This is the theme I used:
def chart_theme():
    font = "Calibri"
    return {
        "width": 700,
        "height": 300,
        "background": "white",
        "config": {
            "title": {
                "fontSize": 20,
                "anchor": "start"
            },
            "axisY": {
                "labelFont": font,
                "labelFontSize": 13,
                "labelLimit":200,
                "ticks": False,
                "titleFont": font,
                "titleFontSize": 12,
                "titleAlign":"right",
                "titleAngle": 0,
                "titleY": -10,
                "titleX": 25,
            },
            "view":{"stroke": "transparent",
            },
}
    }

And here's the chart code:
base = alt.Chart(df, title='San Francisco Crime (11/05 - 11/11)').encode(
    x=alt.X('Count', axis=None),
    y=alt.Y('Crime', title='Crimes reported to SFPD, by top complaint',
    sort=list(df.Crime.values)))

bars = base.mark_bar(size=22).encode(color=alt.condition(
    alt.datum.Count > 700,
    alt.value('#e17700'),
    alt.value('#00648e')))

text = base.mark_text(
    color='white',
    align='right',
    size=12,
    dx=-3
).encode(
    text='Count')

chart = bars + text
chart

Any guidance/suggestions would be greatly appreciated.

A: How about something like this
import pandas as pd
import altair as alt

data = {'Larceny/Theft':739,
'Assault':177,
'Burglary/Breaking & Entering':133,
'Destruction of Property/Vandalism':128,
'Drugs':107,
'Motor Vehicle Theft':95,
'Fraud':71,
'Sex Offenses':57,
'Suspicious Activity':45,
'Trespassing':23,
'Family Offenses':22,
'Weapons Violations':21}

df = pd.DataFrame(list(data.items()), columns=['Crime', 'Count'])

base = alt.Chart(df, title='San Francisco Crime (11/05 - 11/11)').encode(
    x=alt.X('Count', axis=None),
    y=alt.Y('Crime', title='Crimes reported to SFPD, by top complaint',
    sort=list(df.Crime.values)))

bars = base.mark_bar(size=22).encode(color=alt.condition(
    alt.datum.Count > 700,
    alt.value('#e17700'),
    alt.value('#00648e')))

text = alt.Chart(df).mark_text(
    color='white',
    align='left',
    x=3
).encode(alt.Text('Count:N'), alt.Y('Crime',   sort=list(df.Crime.values)))

chart = bars + text
chart.properties(width=700).configure_axisY(
    titleAngle=0,
    titleY=-10,
    titleX=-60,
    labelPadding=160,
    labelAlign='left'
)


text:
Q: What is the point of nuking this mosquito in Real Analysis by Shakarchi and Stein? I have tried to read volume 3 of Shakarchi and Stein more than a few times now and I keep getting stuck in chapter one in the same place.
After going through a bunch of basic concepts from analysis we finally come to a lemma, which says that if a given rectangle is the almost disjoint union of other rectangles, then the area of the given rectangle is equal to the sum of the area of the inner rectangles.  Ok duh.
So at this point I assume we are going to have a rigorous proof which is going to explain why drawing lines of area 0 in a rectangle doesn't decrease the area of the rectangle.  Unfortunately the first sentence of the proof is "we consider the grid formed by extending the sides of all rectangles indefinitely."
Is that supposed to be rigorous? I can think of three different ways to extend the sides of all the inner rectangles indefinitely, and I still can't figure out which one they mean because the picture is pretty strange, and so now I figure I am wrong about why the authors feel the need to prove such an obvious statement.
The next sentence is "This construction yields finitely many rectangles...and a partition of the integers between 1 and M".  I'm sorry, but is this a joke, or is this just a weak part of the book that I should skip over?
By the end of the proof I am left very confused as to what the point of this section is.  Can someone please explain what I am missing here?
Thanks!

A: The emphasis in the Lemma is on the word finite. The Lemma fails if you allow infinitely many rectangles. For example, by the Stein and Shakarchi definition, a degenerate rectangle is a rectangle of 0 volume. Now consider a given rectangle $R = [0,1]\times [0,1]$. It can be written as a union of infinitely many almost disjoint rectangles
$$ R = \cup_{x\in [0,1]} [0,1]\times [x,x] $$
Each of the degenerate rectangles on the right hand side has 0 volume. The rectangle on the left hand side as positive volume.
The proof shows two steps that are useful in measure theory:

*

*A process of refining the rectangles while maintaining the finiteness of the total number. If you have taken a rigorous course of calculus dealing with Riemann or Darboux sums, you will recognize this process as similar to something you have seen before.

*An indication why finiteness is important: as it turns out that the importance of finiteness is manifest already at the level of the real line! (Zeno's paradox!) It shows how once we understand finiteness on the level of one dimension, going to higher dimensions is nothing different at all.

The proof does leave a few things to be desired: in particular it implicitly uses a two step argument which would be better spelled out.

*

*Implicitly the first step is to show that a decomposition of the rectangle into a finite rectangular grid preserves area.

*The second step is to show that by the refinement process, a decomposition of a rectangle into a finite almost-disjoint union of rectangles can be refined into a decomposition into a finite rectangular grid, such that each of the original rectangles are made up of finitely many of the "grid" rectangles.

Later on in the book you will read about a lot more of these types of ideas, the basic form of which goes like this:

We are given $U$ a set such that it is a union $\cup_\alpha V_\alpha$ of some sets. The $V_\alpha$ may not be the best sets, so we may not know much about the volume $|V_\alpha|$ and how it relates to the volume $|U|$. But it turns out that there is a deterministic procedure that replaces $V_\alpha$ by a collection $W_\beta$ such that $U\subset \cup_\beta W_\beta$, and that the $W_\beta$ are very well chosen, so that not only do we have control on how large $|W_\beta|$ is, we also know the relationship between $|U|$ and $|W_\beta|$. The deterministic procedure allows us to related $|W_\beta|$ to $|V_\alpha|$, and this in turn finally gives us what we really wanted: a relation between $|U|$ and $|V_\alpha|$.

In the proof, $U$ is the big rectangle $R$, the $V_\alpha$ are the almost-disjoint collection of smaller rectangles $R_i$, and $W_\beta$ are the small grid rectangles.

Let me re-write the proof in a way that is slightly less graphical and more precise, which may help the OP.
Step 1:
Suppose $R$ is a rectangle $[a,b]\times[c,d]$. Let
$$a = s_0 < s_1 < s_2 \ldots < s_m = b $$
and
$$c = t_0 < t_1 < t_2 \ldots < t_n = d $$
We write $R_{ij}$ for $i = 1\ldots m$ and $j = 1\ldots n$ for the small rectangles
$$ R_{ij} = [s_{i-1}, s_i] \times [t_{j-1}, t_j] $$
A little bit of algebra shows you that
$$ |R| = (s_m - s_0) \cdot (t_n - t_0) = \sum_{i = 1}^m\sum_{j = 1}^n (s_i - s_{i-1})\cdot(t_j - t_{j-1}) = \sum_{ij} |R_{ij}| $$
Step 2:
Let $R = [a,b]\times [c,d]$ and let $R_k$ be a finite collection of almost disjoint rectangles whose union is $R$. Write $R_k = [a_k, b_k]\times [c_k,d_k]$. Consider the set
$$ S = \{ a_1, b_1, a_2, b_2, \ldots, a_K, b_K\} $$
and the set
$$ T = \{ c_1, d_1, c_2, d_2, \ldots, c_K, d_K\} $$
(where by convention the sets $\{0,0\} = \{0\}$ [we can cancel repeated numbers]).
Order $S$ and $T$ increasingly and label the points $s_0 = a < s_1 \ldots s_m = b$ and $t_0 = c < t_1 \ldots t_n = d$. We now have a large rectangular grid. What is useful is that for each rectangle $R_k$, we can find $a_k,b_k\in S$ and $c_k,d_k\in T$, so by step 1, the volume $|R_k|$ can be written as the sum of the volumes of some numbers of the grid rectangles $[s_{i-1}, s_{i}] \times [t_{j-1}, t_{j}] = R_{ij}$.  Similarly the big rectangle $R$ can also have its volume written as a sum of $|R_{ij}|$. It remains to conclude that each of the $R_{ij}$ is used exactly once in both of the counts. This last step follows from the "almost disjoint" property: that is, if $R_{ij} \subseteq R_k$ and $R_{i'j'} \subseteq R_{k'}$ where $k' \neq k$, then the ordered pairs $(i,j) \neq (i',j')$.

A: This is an example of a fact which is obvious. Now, there are lots of "obvious" statements in mathematics whose proofs are important to understand, at least at an introductory level, since the subtleties involved in the proofs often illustrate basic applications of a new technique.
In my opinion, this is not one of those proofs. In other words, this proof is simply a tedious verification of an easily understandable fact, and the methods are basic and have no relation to the techniques in the rest of the text. If you were to simply say "I understand that the sum of volumes of an almost disjoint union of rectangles should equal the volume of their union when their union is also a rectangle" and move on, you would be completely fine.
That the author(s) spend so much time on the proof is unfortunate, though I understand their desire not to bypass details in an introductory text.

A: A few comments before I answer the mathematical question. Yes, this is intuitively obvious. But mathematics is about finding rigorous ways to justify your intuitions, and given the strange beasts one encounters in analysis (nowhere differentiable functions, etc) we need a formal foundation. Stein's aim is to proceed purely formally and build a rigorous concept of measure that does not rely on intuitive arguments.
Now for the math. Let's work in $\mathbb R^2$ to keep things simple. We have a rectangle $[a_1, a_2]\times [b_1,b_2]$ that is the union of some smaller rectangles $[a_{i1}, a_{i2}]\times [b_{i1},b_{i2}]$ By extend all the boundaries, he means consider all lies of the form $y=a_{i1}$ and $x=b_{i2}$ and so forth. Order the vertical lines from left to right and the horizontal lines from bottom to top. For each consecutive pair of horizontal lines and each consecutive pair of vertical lines formed this way, we get a rectangle. These are precisely the rectangles that are drawn in the picture on the right in figure 2. Now, we can prove that these lie in the original rectangle. One such generic rectangle is $[a_{i1}, a_{i2}]\times [b_{j1},b_{j2}]$. Since $a_1 \le a_{i1}< a_{i2} \le a_2$ and likewise for the $b$ coordinates, $[a_{i1}, a_{i2}]\times [b_{j1},b_{j2}]$ is a subset of $[a_1, a_2]\times [b_1,b_2]$.
In a similar fashion, we can prove each of the new cut up rectangles lies in a unique original smaller rectangle. And going back to the definition of almost disjoint, we can prove the unions forming the original smaller rectangles are almost disjoint. You should be able to follow Stein at this point. Let me know if you need more detail.
The point is that while this argument seems handwavey, it can be made completely rigorous if you choose to do so. That is the important thing.

A:
Unfortunately the first sentence of the proof is "we consider the grid formed by extending the sides of all rectangles indefinitely."

Here is a construction of the grid in dimension $3$ (the general case being an obvious modification).
One starts from a rectangle $R=[x,y]\times[z,t]\times[u,v]$ which is the almost disjoint union of finitely many rectangles $R_k=[x_k,y_k]\times[z_k,t_k]\times[u_k,v_k]$.
Consider all the coordinates $x_k$ and $y_k$ involved and order them as $x=a_0\lt a_1\lt\cdots\lt a_N=y$. Likewise, consider all the coordinates $z_k$ and $t_k$ involved and order them as $z=b_0\lt b_1\lt\cdots\lt b_P=t$ and consider all the coordinates $u_k$ and $v_k$ involved and order them as $u=c_0\lt c_1\lt\cdots\lt c_Q=v$.
Now, fix a bijection from $\mathfrak J=[NPQ]$ to $[N]\times[P]\times[Q]$, say $j\mapsto(n(j),p(j),q(j))$. For every $j$ in $\mathfrak J$, define
$$
\tilde R_j=[a_{n(j)-1},a_{n(j)}]\times[b_{p(j)-1},b_{p(j)}]\times[c_{q(j)-1},c_{q(j)}].
$$
Then the rectangle $R$ is the almost disjoint union of the $M=NPQ$ rectangles $\tilde R_j$ and each original rectangle $R_k$ is the union of some $\tilde R_j$, that is, $R_k=\bigcup\limits_{j\in J(k)}\tilde R_j$, where the sets $J(k)$ are disjoint and their union is $\mathfrak J$.
Is all this preferable to Shakarchi and Stein's presentation? I am not sure.


text:
Q: Fetch Raw frames from capturing video Android Camera I do not know much about Camera API, though i need to use frames from a capturing video with more then 30fps with a good quality camera(S9).
Can anybody suggest code for the same.
I tried to find fit code for this but i am failed.
Thanks in Advance
Mohit

A: You are lucky, since not so long ago a component of android JetPack was released, called CameraX. Sadly it is still in alpha stage, meaning that you should avoid using it in production since it might have breaking changes in the future. This component was built on top of Camera 2 API, witch is a low level API for working with camera.
If you plan to use your app in production I highly recommend to use Camera 2 API, it is low level, however you have the full control over the camera.
Here is an example to get you started.


text:
Q: Get images from directory  I'm trying to get all images from a directory in WP7. I already use
var temp = Directory.GetFiles(@"\Pictures");

but it doesn't seem to work.
by the way i also tried the isolated storage solution. but none of those solution seems to work.
Is i a wp7 limitation?

A: you shoud use following code for images from the resources:
            Uri uri = new Uri(uriString, UriKind.Relative);

            String originalUriString = uri.OriginalString;
            Uri resourceStreamUri = originalUriString.StartsWith("/", StringComparison.Ordinal) ? new Uri(originalUriString.TrimStart('/'), UriKind.Relative) : uri;
            StreamResourceInfo streamResourceInfo = Application.GetResourceStream(resourceStreamUri);

            if (null != streamResourceInfo)
            {
                stream = streamResourceInfo.Stream;

                BitmapImage bitmapImage = new BitmapImage();
                bitmapImage.SetSource(stream);

                Image image = new Image();
                image.Source = bitmapImage;
            }

A: Probably, you should use IsolatedStorageFile.GetFileNames instead.
Good tutorial: How to: Find Existing Files and Directories in Isolated Storage

A: You probalby have your pictures as Resource and not as Content. Right click on images in your solution and change the Build Action to Content.


text:
Q: Detecting API Support through SecureWindow proxy object with Lightning Components LockerService When using device access APIs via Javascript, best practice would dictate to detect whether supported by the browser/webview and fail gracefully if not supported.
For instance, I have a component that I created to play with device orientation. So I have to add a function to the deviceorientation event handler like so:
window.addEventListener('deviceorientation', doOrientation);

This works just fine with locker service on or off. Meaning apparently the window.addEventListener proxy function is A-OK.
However, normally for device access features I would test for support before actually executing that logic. That would look something like this:
if (window.DeviceOrientationEvent ||){
  ...all the stuff I want to do now that the API is there...
}

Unfortunately, SecureWindow, the proxy API that LockerService surfaces in place of the real-DOM window object appears to not have that, or in any case, I end up with a falsy value.
So generally I'm looking for suggestions for how to test whether an API exists, when detecting whether that API exists is abstracted away because of LockerService. But I'd take an answer for how to detect how this API exists, if that's all you've got.


text:
Q: Unable to CREATE DATABASE via PyODBC connection I am using pyodbc in python 2.7 with MS SQL Server 2008R.
Here is my code for creating a database (the SQL code which works fine in SQL alone, but crash when executed in python)
SQL_command = """
                IF EXISTS(SELECT * FROM sys.databases WHERE [name] = 'NewDatabase')
                    DROP DATABASE NewDatabase
              """

conn.cursor.execute(SQL_command)

SQL_command = """
                CREATE DATABASE NewDatabase
                ON
                (
                     NAME = 'NewDatabase_data'
                ,    FILENAME='D:\MSSQL\DATA\NewDatabase_data.mdf'
                ,    SIZE = 4096KB
                ,    FILEGROWTH = 4096KB
                )
                LOG ON
                (
                    NAME = 'NewDatabase_log'
                ,   FILENAME='D:\MSSQL\LOG\NewDatabase_log.ldf'
                ,    SIZE = 4096KB
                ,    FILEGROWTH = 10%
                )
                COLLATE SQL_Latin1_General_CP1_CI_AS
              """

conn.cursor.execute(SQL_command)

SQL_command = """
                ALTER DATABASE
                    NewDatabase
                SET RECOVERY SIMPLE
              """

conn.cursor.execute(SQL_command)

However, I've got following error message:

pyodbc.ProgrammingError: ('42000', '[42000] [Microsoft][ODBC SQL
  Server Driver][SQL Server]CREATE DATABASE statement not allowed within
  multi-statement transaction. (226) (SQLExecDirectW)')

May I know what is wrong with my code?
Many thanks.
====================================================================================
So, after taking the advice from @Matthias, I've executed commit after the drop database, then the error message became:

pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL
  Server Driver][SQL Server]CREATE FILE encountered operating system
  error 123(failed to retrieve text for this error. Reason: 15105) while
  attempting to open or create the physical file
  'D:\MSSQL\DATA\NewDatabase_data.mdf'. (5123)
  (SQLExecDirectW); [42000] [Microsoft][ODBC SQL Server Driver][SQL
  Server]CREATE DATABASE failed. Some file names listed could not be
  created. Check related errors. (1802)")