Loose bathroom wall tiles

Question: So after hosing down the bathroom, I started to hear some cracking. I looked at the tiles and they were bulging out from the center. I guess water got into the top and loosened the tiles.

I started to gently remove the very loose tiles by hand, so they wouldn't fall and break. The wall is concrete and the remaining adhesive is pretty rock hard. Not sure if I should remove it all and re tile or is this fixable?
Comment: It looks like the installers let the thinset dry too much before sticking on the tiles. For walls, it is a good practice to apply a thin layer of thinset to both the backing and the tile. This is called back buttering. It will help prevent them from coming off again.
Comment: It is fixable. Try to pull any tile from the wall. It shouldn't budge. Scrape dried thinset off the wall and mix a  correctly proportioned water to thinset batch. It should remain on a trowel when turned upside down or have the consistency of peanut butter.
Comment: The thinset on the wall is pretty hard. The tiles that came off didn't seem to stick very well since the back was pretty clean. What do you recommend I use to scrape the thinset on the concrete wall since it is pretty much rock hard.
Comment: Also check the backing material. I noticed a crack running vertically under the window corner. If the backing was floated with a cement mix check that it hasn't been compromised. The crack may not be the primary reason for the tile not adhering, but it may have contributed. Look for bulges and large gaps in the backer (small hairline cracks can be normal)  I hope it was just those few tiles that came loose and not the whole wall.
Comment: The dried thinset should be fairly easy to remove from the wall (at least the trowel ridges will). I've used: a margin trowel. an old wood chisel, wide flat-head screw driver, pry bar... It may be difficult to only remove the thinset and not gouge the backer, but once you're in the flow it will be easy.
Answer: I can see the ridges left by the installers notched trowel. Look at the back of any loose tiles. It should have thinset on at least 80% of it's back. I'm guessing the thinset wasn't mixed correctly. If it is to dry the tile does not get pressed into the notched adhesive so as to form a mechanical bond. You can check if the tiles are affixed properly by giving them a slight rap with your knuckle. You should hear a dull sound. A hollow or "ting" reverberation indicates a void or low spot were the thinset isn't fully supporting the tile.
Comment: Most of the tiles that came off were pretty clean on the back. There is a lot of hollow reverberation.
Comment: no dried thinset on the back of the tile means they weren't affixed properly and/or the thinset  wasn't mixed correctly.
Comment: The tiles that are bulging out are held on by the grout. is there an easy way to remove them without having to having the other come out?
Comment: @Rick- the fact is that if the grout is the only material keeping the tiles on the wall it may be wise to remove them regardless of whether they appear securely fastened to the wall.
Comment: @Rick- And to remove any tiles that are about to fail try a margin (square shape) trowel or a pointing trowel. The off set handle makes it easy to pry the tile away. Also a putty knife or any wide bladed hand tool.

Loose bathroom wall tiles


Simple example of the "atoi" function in c++

Question: Can someone please give a very simple example on how to use the atoi function? I know how it is  supposed to work, but most of the examples are in objective C... Which  I have trouble reading with since I haven't really learned it yet                                                                                .
      Thanks, in advance!
Comment: Google....? http://en.cppreference.com/w/cpp/string/byte/atoi
Comment: Note that `atoi` causes undefined behaviour if the value cannot be represented in an `int`.  The `strtol` and `strtoul` functions have well-defined behaviour and error recovery; of course you could also use C++ stringstreams which are designed for this task.
Answer: #include <cstdlib>        // wraps stdlib.h in std, fixes any non-Standard content

std::string t1("234");
int i1 = std::atoi(t1.c_str());
int i1b = std::stoi(t1);  // alternative, but throws on failure

const char t2[] = "123";
int i2 = std::atoi(t2);

const char* t3 = "-93.2"; // parsing stops after +/- and digits
int i3 = std::atoi(t3);   // i3 == -93

const char* t4 = "-9E2";  // "E" notation only supported in floats
int i4 = std::atoi(t4);   // i4 == -9

const char* t5 = "-9 2";  // parsing stops after +/- and digits
int i5 = std::atoi(t5);   // i5 == -9

const char* t6 = "ABC";   // can't convert any part of text
int i6 = std::atoi(t6);   // i6 == 0 (whenever conversion fails completely)

const char* t7 = "9823745982374987239457823987";   // too big for int
int i7 = std::atoi(t7);   // i7 is undefined

Because behaviour in this last case is undefined (probably so some implementations can loop adding the next digit to ten times the previous value without spending time checking for signed integer overflow), it's recommended to use std::stoi or std::strtol instead.
See also: cppreference atoi for documentation including examples; stoi
Comment: don't forget `stoi` :D


Proof that union of powersets equals powerset of union of two sets if one is subset of another

Question: I need to prove that:
$$(A\subseteq B \vee B \subseteq A )\Leftrightarrow P(A) \cup P(B) = P(A\cup B) $$
Now I have already been able to prove that for any set A and B
$$ P(A)\cup P(B)\subseteq P(A\cup B)  $$
The next thing I tried to do then is proving:
$$(A\subseteq B \vee B \subseteq A )\Leftrightarrow P(A\cup B)\subseteq P(A)\cup P(B)  $$
But this is where I get stuck. I started with the proof from left to right, so in case 1 I assume A is a subset of B and try to prove the right side. Unfortunately, I cant come up with a prove that seems logically consistent without jumping to conclusions too quickly.
Thank you in advance.
Answer: If $A\subseteq B$ then $A\cup B=B$ so that $\wp(A\cup B)=\wp(B)\subseteq\wp(A)\cup\wp(B)$
If $B\subseteq A$ then $A\cup B=A$ so that $\wp(A\cup B)=\wp(A)\subseteq\wp(A)\cup\wp(B)$
So in both cases we have:$$\wp(A\cup B)\subseteq\wp(A)\cup\wp(B)$$

Backwards: $$A\cup B\in\wp(A\cup B)\subseteq\wp(A)\cup\wp(B)$$ so that $$A\cup B\subseteq A\vee A\cup B\subseteq B$$ or equivalently $$B\subseteq A\vee A\subseteq B$$
Comment: Thank you very much! Everything is clear now... I simply overlooked the fact that If A⊆B then A∪B=B
Comment: You are welcome.


Incomprehensible Django Runserver Error

Question: I have had many problems in Django (not all of them solved), but this is by far the weirdest and most incomprehensible one. It happens when I load a page:

>python manage.py runserver

Validating models...

0 errors found
Django version 1.3.1, using settings 'ponysite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[01/Nov/2011 01:21:49] "GET / HTTP/1.0" 500 102747

Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 284, in run
    self.finish_response()
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 324, in finish_response
    self.write(data)
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 420, in write
    self._write(data)
  File "C:\Python27\lib\socket.py", line 324, in write
    self.flush()
  File "C:\Python27\lib\socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 63095)
Traceback (most recent call last):
  File "C:\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock
    self.process_request(request, client_address)
  File "C:\Python27\lib\SocketServer.py", line 310, in process_request
    self.finish_request(request, client_address)
  File "C:\Python27\lib\SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 570, in __init__
    BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
  File "C:\Python27\lib\SocketServer.py", line 641, in __init__
    self.finish()
  File "C:\Python27\lib\SocketServer.py", line 694, in finish
    self.wfile.flush()
  File "C:\Python27\lib\socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 284, in run
    self.finish_response()
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 324, in finish_response
    self.write(data)
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 420, in write
    self._write(data)
  File "C:\Python27\lib\socket.py", line 324, in write
    self.flush()
  File "C:\Python27\lib\socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 63099)
Traceback (most recent call last):
  File "C:\Python27\lib\SocketServer.py", line 284, in _handle_request_noblock
    self.process_request(request, client_address)
  File "C:\Python27\lib\SocketServer.py", line 310, in process_request
    self.finish_request(request, client_address)
  File "C:\Python27\lib\SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 570, in __init__
    BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
  File "C:\Python27\lib\SocketServer.py", line 641, in __init__
    self.finish()
  File "C:\Python27\lib\SocketServer.py", line 694, in finish
    self.wfile.flush()
  File "C:\Python27\lib\socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10054] An existing connection was forcibly closed by the remote host
----------------------------------------

[01/Nov/2011 01:21:53] "GET / HTTP/1.0" 500 102391

I have tried wiping and recreating the database, stripping down views.py and models.py to the bare minimum to no avail. I have also tried running the same project on another computer with the same result. Both are running Windows x64. Actually, I think the one computer is running Django 1.3.x and the ther 1.2.x, but the error looks the same regardless.
Here is the full traceback:

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/

Django Version: 1.3.1
Python Version: 2.7.2

Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'forum',
 'django.contrib.markup']

Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')

Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
  101.                             request.path_info)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in resolve
  250.             for pattern in self.url_patterns:
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in _get_url_patterns
  279.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in _get_urlconf_module
  274.             self._urlconf_module = import_module(self.urlconf_name)
File "C:\Python27\lib\site-packages\django\utils\importlib.py" in import_module
  35.     __import__(name)
File "C:\Users\kiwi\Dropbox\Programming Projects\Django Projects\ponysite\..\ponysite\urls.py" in
  3. admin.autodiscover()
File "C:\Python27\lib\site-packages\django\contrib\admin\__init__.py" in autodiscover
  26.             import_module('%s.admin' % app)
File "C:\Python27\lib\site-packages\django\utils\importlib.py" in import_module
  35.     __import__(name)
File "C:\Users\kiwi\Dropbox\Programming Projects\Django Projects\ponysite\forum\admin.py" in
  1. from forum.models  import Category, Thread, Post, Report, Subscription, Ban

Exception Type: ImportError at /
Exception Value: cannot import name Ban

Ban was a model in models.py (imported in views.py) I played around with for a while, but it is currently commented out everywhere in my model, view, and controller. I don't know if it has anything at all to do with the problem.
Thanks in advance, guys.
Comment: Well, this says you don't have defined class Ban in forum/models.py.
Can you double check for it.
Answer: Based on this line:
File "C:\Users\kiwi\Dropbox\Programming Projects\Django Projects\ponysite\forum\admin.py" in
1. from forum.models  import Category, Thread, Post, Report, Subscription, Ban

Django is finding in forum/admin.py
from forum.models  import Category, Thread, Post, Report, Subscription, Ban

Note the Ban at the end that is not defined in models. Remove it and the error should be gone.
Comment: Can't believe that went under the radar. Thanks a million, digivampire.

Incomprehensible Django Runserver Error


how to store some styles in one css variable?

Question: I am new at web, I am working on a side project just building a simple website, so my question is next: how can I store some styles in one variable for example:
<code>font-family: acumin-pro, sans-serif;
font-weight: 400;
font-style: normal;
</code>
I know how to store one style in variable, like this:
<code>:root{
   --main_font: Helvetica, sans-serif;
}
</code>
so, can you give me some examples or advises about that?
Comment: *how can I store some styles in one variable for example:* --> this is what classes are made for, they contain a set of styles and you use the class when you want to apply them
Answer: As far as I know, there isn't a way to do this with CSS and the variables are only for values. However, if you are able to use SASS in your website then you would be able to use mixins which are a set of defined styles that can be reused throughout your stylesheet.
You can read more about SASS and mixins here
Comment: Thanks, I was thinking same, but I decided to go with only CSS for now.


How does this result of the "positive square root" of a quadratic follow?

Question: I have a problem which is to compute a simplified form for the eighth root of a polynomial of the form $x^2-ax+1$. In the solution here, it says that:

Notice that if $x$ satisfies the quadratic $x^2-ax+1=0$, then we have
  $$\begin{split}
0&=(x^2-ax+1)(x^2+ax+1)\\
&=x^4-(a^2-2)x^2+1.
\end{split}$$
  Clearly, then, the positive square roots of the quadratic $x^2-bx+1$ satisfy the quadratic $x^2-(b^2+2)^{1/2}x+1=0$....

What even are the "positive square roots" of a quadratic? Is this simply $\sqrt{x^2-bx+1}$? And how does the assertion in the last line follow?
Answer: The author presumably intended to write "the positive square roots of the roots of the quadratic $x^2-bx+1$ satisfy ...", a minor omission.

As far as the assertion, if $x$ satisfies $x^2-ax+1=0$, then $x^2$ satisfies $y^2-by+1=0$, where $b=a^2-2$.

Thus, squaring the roots leads to an equation of the same form (with $a$ replaced by $b=a^2-2$).

Reversing the process allows for "square-rooting" the roots.

Thus, the positive square roots of the roots of $y^2-by+1=0$ satisfy $x^2-ax+1=0$, where $a^2-2=b$, or equivalently (in the context where $a,b$ are positive), $a=\sqrt{b+2}$.

Note that the author wrote it incorrectly as $a=\sqrt{b^2+2}$, but it should be $a=\sqrt{b+2}$.


How to set application name when creating .deb, using Quickly

Question: When I open created .deb package , my application name is UNKNOWN . Please help, how to fix it...
Comment: Is it in the control file, http://www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/How-to-make-deb-packages/ I've never done it before, there is a section on it there.
Answer: You need to fill in and uncomment the description and long_description in the setup.py file before you run any Quickly packaging command. This is where Quickly gets the short and long descriptions for your app shown in the Ubuntu Software Centre.


Creating workbook based on two cell value

Question: I have a workbook "Report.xlsx" where in i have 70 sheets (The name of all 70 sheets are present on a list in a workbook called "list.xlsx"). now i need to create workbook based on a list present in "list.xlsx".
I have a list some what like this.
Sheet Name  Person name
Fax            Tom
Tax            Tami
Rax            Tom
Max            Sara
Sax            Tom

What i need is a code which can move the sheets of workbook "Report.xlsx" and create another workbook based on the above list
For Eg:
Fax, Rax & Sax should be copied to a new workbook from "Report.xlsx" and renamed it as Tom.
like wise Tax should be copied to a new workbook and renamed it as Tami.
and same Max should be copied to a new workbook and renamed it as Sara.
Thanks for all your help in advance.

Dear Team,
Below is the code what i tried, but i am still unable to get what i needed, can anyone help on this.
Sub Copysheets()
Dim thisWB  As String
Dim newWB As String
Dim endofprocess As String
Dim m As Integer
        thisWB = ActiveWorkbook.Name
        On Error Resume Next
         Application.DisplayAlerts = False
        Sheets("tempsheet").Delete
        Application.DisplayAlerts = True
        On Error GoTo 0
        Sheets.Add
        ActiveSheet.Name = "tempsheet"
        Sheets("list").Select
        If ActiveSheet.AutoFilterMode Then
            Cells.Select
            On Error Resume Next
            ActiveSheet.ShowAllData
            On Error GoTo 0
    End If
    Columns("A:C").Select
    Selection.Copy
    Sheets("tempsheet").Select
    Range("A1").Select
    ActiveSheet.Paste
    Columns("b").Delete
    Application.CutCopyMode = False
        If (Cells(1, 1) = "") Then
            LastRowx = Cells(1, 1).End(xlDown).Row
            If LastRowx <> Rows.Count Then
                Range("A1:A" & LastRowx - 1).Select
                Selection.Delete Shift:=xlUp
            End If
        End If

    Cells.Select
    Selection.Sort _
            Key1:=Range("b2"), Order1:=xlAscending, _
            Header:=xlYes, OrderCustom:=1, _
            MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal

    lMaxSupp = Cells(Rows.Count, 1).End(xlUp).Row
    For suppno = 2 To lMaxSupp
    Windows(thisWB).Activate
    supname = Sheets("tempsheet").Range("B" & suppno)

        If supname <> "" Then
        Workbooks.Add
        ActiveWorkbook.SaveAs "Balance Sheet Review - " & supname
            newWB = "Balance Sheet Review - " & supname
        Windows("Balance Sheet Review Dec 13 - APJ.xlsm").Activate

For i = 2 To 100

Windows(""Report.xlsx"").Activate
Worksheets("tempsheet").Activate
            FldrName = Left(Cells(i, 1).Value, 30)
            Worksheets(FldrName).Activate

            Sheets(FldrName).Select

           Sheets(FldrName).Copy Before:=Workbooks( _
        newWB & ".xlsx").Sheets(1)

Next i

        End If

    Next

End Sub

Answer: Try to put the following code into your list.xlsx.  The code you've wrote does not seems to do it so I rewrite the whole thing:
Sub Test()
Dim twb As Workbook
Dim nwb As Workbook
Dim rpt As Workbook
Dim tws As Worksheet
Dim sh As Worksheet
Dim bcnt As Integer
Dim wbn As String
Dim wsn As String
Dim wsexist As Boolean
Dim createnwb As Boolean
Dim SFile as string
Dim Spath as string

Set twb = ThisWorkbook ' list.xlsx
Set tws = twb.Sheets("list") ' assume your worksheet called list in list.xlsx

Spath = "C:\" ' or where your source files stored
SFile = Dir(Spath & "*.xlsx")
do while len(Sfile) > 0
Set rpt = Workbooks.Open(Spath & SFile) 'or where the file sits

twb.Activate
tws.Activate

Range("A1", Range("B1").End(xlDown)).Select
bcnt = Selection.Count
Selection.Sort _
            Key1:=Range("b2"), Order1:=xlAscending, _
            Header:=xlYes, OrderCustom:=1, _
            MatchCase:=False, Orientation:=xlTopToBottom, _
            DataOption1:=xlSortNormal

For i = 2 To bcnt
    wbn = Cells(i, 2).Value
    wsn = Cells(i, 1).Value
    wsexist = False
    createnwb = False
    If Cells(i, 2).Value <> Cells(i - 1, 2).Value Then
        createnwb = True
    End If

    rpt.Activate
    For Each sh In Worksheets
        If sh.Name = wsn Then
            If createnwb = True Then
                Set nwb = Workbooks.Add()
            End If
            'rpt.Activate
            sh.Copy before:=nwb.Sheets(1)
            wsexist = True
            Exit For
        End If
    Next sh
    twb.Activate
        If wsexist = True Then
            If Cells(i, 2).Value <> Cells(i + 1, 2).Value Then
            nwb.SaveAs Filename:="C:\" & wbn
            nwb.Close
            End If
        End If

Next i
SFile = Dir
Loop
End Sub

Customize with your local path / file name and such.  It is based on your sample where sheet name sits at column A (with a col header) and Person (workbook) name sits at column B (with a col header)
Comment: Thanks Alex, How ever i still have one small problem, Workbooks are been created even if it is not in "Report.xlsx". I mean if there is a sheet name in List.xlsx say "Jerry" but the sheet "Jerry" do not exist in "Report.xlsx" it is creating Blank workbook, can we avoid doing that.
Comment: Thanks a lot Alex, One more thing say i have 10 report.xlsx files(like rpt1.xlsx, rpt2.xlsx...so on) in a folder is there a possibility to loop these files one by one and do the above thing. I mean Instead of defining the workbook name "Set rpt = Workbooks.Open("C:\Report.xlsx")" can it be made to loop across all the files in the folder and do the same thing.
Comment: Please find edited code.  You should also google on how it's done.  I have been warned that Stackoverflow is for help with coding issue, not writing code for free, thanks


Error when trying to load data from Data Fusion to Salesforce

Question: I`m getting this error when trying to load data from Data Fusion to Salesforce:
java.lang.RuntimeException: There was issue communicating with Salesforce
    at io.cdap.plugin.salesforce.plugin.sink.batch.SalesforceOutputFormat.getRecordWriter(SalesforceOutputFormat.java:53) ~[1599122485492-0/:na]
    at org.apache.spark.internal.io.HadoopMapReduceWriteConfigUtil.initWriter(SparkHadoopWriter.scala:350) ~[spark-core_2.11-2.3.4.jar:2.3.4]
    at org.apache.spark.internal.io.SparkHadoopWriter$.org$apache$spark$internal$io$SparkHadoopWriter$$executeTask(SparkHadoopWriter.scala:120) ~[spark-core_2.11-2.3.4.jar:2.3.4]
    at org.apache.spark.internal.io.SparkHadoopWriter$$anonfun$3.apply(SparkHadoopWriter.scala:83) ~[spark-core_2.11-2.3.4.jar:2.3.4]
    at org.apache.spark.internal.io.SparkHadoopWriter$$anonfun$3.apply(SparkHadoopWriter.scala:78) ~[spark-core_2.11-2.3.4.jar:2.3.4]
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87) ~[spark-core_2.11-2.3.4.jar:2.3.4]
    at org.apache.spark.scheduler.Task.run(Task.scala:109) ~[spark-core_2.11-2.3.4.jar:2.3.4]
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:345) ~[spark-core_2.11-2.3.4.jar:2.3.4]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_252]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_252]
    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_252]
Caused by: com.sforce.async.AsyncApiException: InvalidJob : Invalid job id: null
    at com.sforce.async.BulkConnection.parseAndThrowException(BulkConnection.java:182) ~[na:na]
    at com.sforce.async.BulkConnection.doHttpGet(BulkConnection.java:753) ~[na:na]
    at com.sforce.async.BulkConnection.getJobStatus(BulkConnection.java:769) ~[na:na]
    at com.sforce.async.BulkConnection.getJobStatus(BulkConnection.java:760) ~[na:na]
    at io.cdap.plugin.salesforce.plugin.sink.batch.SalesforceRecordWriter.<init>(SalesforceRecordWriter.java:69) ~[1599122485492-0/:na]
    at io.cdap.plugin.salesforce.plugin.sink.batch.SalesforceOutputFormat.getRecordWriter(SalesforceOutputFormat.java:51) ~[1599122485492-0/:na]
    ... 10 common frames omitted
2020-09-03 08:41:28,595 - WARN  [task-result-getter-0:o.a.s.ThrowableSerializationWrapper@192] - Task exception could not be deserialized
java.lang.ClassNotFoundException: Class not found in all delegated ClassLoaders: com.sforce.async.AsyncApiException
    at io.cdap.cdap.common.lang.CombineClassLoader.findClass(CombineClassLoader.java:96) ~[na:na]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_252]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_252]
    at io.cdap.cdap.common.lang.WeakReferenceDelegatorClassLoader.findClass(WeakReferenceDelegatorClassLoader.java:58) ~[na:na]

What does this error mean? I have assured the input fields match with the SObject definition.
Comment: "Invalid job id" sounds like the bulk api job failed. Skim through the bulk api concepts in https://trailhead.salesforce.com/en/content/learn/modules/api_basics/api_basics_bulk. Check in Setup -> Bulk... if the job was submitted OK, maybe there's a better error message. Has it managed to log in to SF OK?
Comment: The job appears in the "Monitor Bulk Data Load Jobs" page, but the status is still "Open" and there is no error message shown.
Comment: Then it might be that Java library is buggy? SF needs instruction that file upload is finished (because you might have decided to load multiple files with up to 10K record chunks, SF has no way of knowing) and then it can start processing. In that link I posted it's mentioned as "Close the Job".
Comment: Thanks for the link. I`m not using workbench, though. I use a Data Fusion pipeline that loads, transforms the data and then uses the Salesforce sink to send it.
Answer: I looked at the stacktrace, and I think I might know what the problem is.
The property mapred.salesforce.job.id is undefined, and when the code executes, it goes to grab the value of this key, and as it is not defined, the job errors out. I think you need to set the mapred.salesforce.job.id flag as a runtime property. To do that in Data Fusion, do the following:

In the Pipeline Studio, navigate to the detail page of the pipeline you would like to configure.
Click on the drop-down next to the Run button.
Set your desired cluster properties, prefixing all property names with system.profile.properties.. For our case, I think the name would be system.profile.properties.mapred:mapred.salesforce.job.id and the value is a number you'd want to use as your ID
Comment: Hey @SophieSepp - a fix has been deployed for the plugin on the Hub. It is now v.1.2.1!
Comment: Thank you for your answer. Is there a specific format you have to use for the id or a fixed size? I tried with the following runtime argument and I`m still getting the same error.
system.profile.properties.mapred:mapred.salesforce.job.id 123444556781234567
Comment: Can you pass in the argument as a string? Here's the line in the code that obtains the info:

[`String jobId = conf.get(SalesforceSinkConstants.CONFIG_JOB_ID);`](https://github.com/data-integrations/salesforce/blob/f2dfcc850df96567fbdd5352d53bc6a54ba5ae96/src/main/java/io/cdap/plugin/salesforce/plugin/sink/batch/SalesforceOutputFormat.java#L97)
Comment: I passed in the argument as a string, it still gives the same error mentioned above. Moreover, I could see in the logs that even before passing a job id in the runtime arguments, one got created automatically:
"Started Salesforce job with jobId='7503O000004ORtCQAW'."
Comment: Hey Sophie - I shared this issue internally and we found a bug in the Salesforce plugin. Thanks for pointing this out! Here is a tracking link to the bug: https://issues.cask.co/browse/PLUGIN-406


What is the meaning behind "Congratulations, I hope you have a wonderful life together"?

Question: This isn't about a glitch or bug, I really just want to know the meaning of Constance's over-used term, "Congratulations, I hope you have a wonderful life together." Does it mean anything? I'm not married in the game and haven't adopted children from her.
Comment: Define over-used.  From what I gather, [*this is a bug*](http://elderscrolls.wikia.com/wiki/Thread:832262), unless you are able to have other dialogue from her as well.
Comment: I guess it is a bug? I haven't been able to adopt children from her. It's all she says so I thought it meant something.
Answer: That is her quote for when you adopt a child.When i got a child she said "congragulations, i hope you have a wonderful life together" which indicates you adopted a child.This is more likely a bug for this can also happen to different npc's repeating the exact same quote over and over.
Comment: inb4 "arrow in the knee" jokes.


Is it possible to run multiple apps with different angular versions on one page?

Question: I want to run multiple angular2 applications on one page. Additionally they should run in different versions.
I know: Angular is designed to be a single page application framework and so the use case I described is pretty exotic. Nevertheless I want to know if it is theoretically possible?
I've already managed to get it run, my only problem was, that zone-js has a variable on the global namespace and throws an error when getting loaded more than once. When I load zone-js only once, the two angular applications run side-by-side. You can see the different angular versions in the dom.

But now my question(s) in more detail: Do I have to worry when running two angular applications running side-by-side on one page? Does it make sense to load other dependencies only once? What when maybe angular major version 4 depend on another zone-js major version - I can't load them both on one page? Is it OK to load all webpack bundles twice (inline.bundle.js, vendor.bundle.js, main.bundle.js)?
Comment: I think you'll have quite some difficulties with the router part of both versions. Both apps would change and read the browser URL. I don't think that's going to be pretty.
Comment: you can surely find ways to make this work by hacks or workarounds, but your solution would likely be *very brittle*.  It doesn't really make sense to do this anyway;  You are likely to have issues, where updating something in one of the apps causes something unexpected to happen in the other. If this is the same project, why would you not take the time to integrate the multiple pieces?   and if you are just trying to re-use some components, then there are ways to design re-usable components....
Comment: the ideal would be: different apps on a platform which are isolated from each other and therefore run regardless of the dependencies of the other apps

but that's why I've asked: does have angular other "global" dependencies which would interfere each other apart from zone-js? if not you wouldn't have the problem "where updating something in one of the apps causes something unexpected to happen in the other"

.. the goal would be, that you can develop new apps with new angular version and don't necessarily have to migrate the other (finished) apps to the newer angular version immediately
Comment: based on the question and the comments you've made, you seem to have an unusual idea about what an "app" is.... and what do you mean by "platform", exactly?  angular is a browser framework, and it isn't really possible to make more than one JavaScript script be "isolated" from another, in the sense you are trying to suggest....
Comment: and yes, angular has, in context of what you are describing here, many "global" dependencies on things like the DOM, browser history, network services, and more.  @DavidWalschots provided one of many examples which would make two apps on one browser page very challenging.
Comment: ultimately, the more you describe, the more this *feels like* an XY Question.  You aren't really describing a problem to be solved, you are describing a potential solution to an unknown problem.  "different apps on a platform" doesn't really make sense in context of how angular works, so it's more likely that you are trying to approach your problem by applying some understanding of some other environment which isn't equatable here.  Perhaps describing *why* you think you need to have multiple different apps would help?
Comment: I mean, "develop other apps without migrating other finished apps" makes sense, but I don't see how that relates to "hosting two apps on a single page".
Comment: From my point of view this questions is perfectly clear and valid. Is it possible to run serveral angular apps with different angular version on one page - e.g. header, main content and sidebar of a page are implemented as different angular apps (composite ui in a microservice environment)? Especially in the context of the angular labs project "Angular Elements" this questions should get more importance. With vue and react it seems possible to scope the framework version per application instance. A answer on this question would be great.
Answer: We are trying to solve a similar problem and we found a meta-framework that we found satisfactorily manages micro front end (SPAs) In fact, we were able to bring in other SPAs that were built by different teams with different JS frameworks with little to no effort.
There may be a lot of reasons against doing this as such an app may not exactly be referred to as performant. I would say the reason for undertaking such a thing in our case was need for federated development: we have lots of small teams not which are not co-located and independent as far as delivery timelines that contribute to our gargantuan app which was earlier built on .net platform as a monolithic MV* webapp.


Comparing #define giving incorrect result

Question: I have defined one variable which gives me output as below.
iPhone 4 >> 4
iPhone 5 >> 5
iPad >> 999

Function used is as below.
#define iPhone4Or5 [[UIScreen mainScreen] bounds].size.height == 568 ? 5 :
        ([[UIScreen mainScreen] bounds].size.height == 480 ? 4 : 999)

When I NSLog variable iPhone4Or5, it gives me correct result for iPhone 5, however when I make compare it gives me wrong result...
if (iPhone4Or5==999) {
    NSLog("Its iPad version");
} else {
    NSLog("Its iPhone version");
}

When I run above with iPhone 5 or above, it always gives me NSLog as Its iPad version.
Any idea why I am getting WRONG compare result?
I am defining variable in prefix.pch
Note:
If I execute NSLog("iPhone4Or5==%d", iPhone4Or5), I get output as iPhone4Or5==5
Comment: Don't use macros here. The way you are using them is an anti pattern. ;)
Comment: What do you do when the device/simulator is in landscape mode? Wouldn't the height be something else? I.e. the width of portrait mode..
Comment: And if you insist on using macros, make sure you use enough parentheses to avoid operator precedence problems and other pitfalls.
Comment: @matsr : My App is potrait mode only :D :P
Answer: You are having problems with operator precedence - your macro needs parentheses:
#define iPhone4Or5 ([[UIScreen mainScreen] bounds].size.height == 568 ? 5 : \
        ([[UIScreen mainScreen] bounds].size.height == 480 ? 4 : 999))

Better still, avoid this and other common macro-related problems and use a function instead:
int iPhone4Or5(void)
{
    const int height = [[UIScreen mainScreen] bounds].size.height;
    if (height == 568) return 5;
    if (height == 480) return 4;
    return 999;
}

Comment: just curious, what parenthesis is making problem? My concern is when I get value as 5, why compare gives wrong result?
Comment: its working perfectly, but just curious what parenthesis is making difference?
Comment: When you expand your macro for `if (iPhone4Or5==999)` the `== 999` term gets evaluated as part of the second ternary expression, instead of being applied to the whole compound expression as defined in the macro - that's why you need parentheses. This is really basic C stuff which you should know if you plan to do any serious programming in the future.
Answer: Log the value of [UIScreen mainScreen] bounds].size.height and check if it 480.
Or you can use these.
#define IS_IPAD ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] && [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)

#define IS_IPHONE5 ((( !IS_IPAD && [[UIScreen mainScreen] bounds].size.height == 568))?YES:NO)


Strengthening of a theorem about filters vs a counter-example

Question: Let $S$ be a non-empty set of filters on a meet-semilattice.
If our semilattice is a distributive lattice, then the supremum (on the poset of filters ordered by set-theoretic inclusion) of $S$ is the filter corresponding to the filter base generated by $\bigcup S$. You can finds a proof of such a theorem for example in my article: http://ijpam.eu/contents/2012-74-1/6/index.html
Can this statement be strengthened for a more general case than distributive lattices?
I would like to see a counter-example for the case is our semilattice is not a lattice, or better for the more specific case when it is a lattice but not a distributive lattice.
Answer: Oh, I've found an answer myself.
For every $\mathcal{A} \in S$ we have $\bigcup S \supseteq \mathcal{A}$ thus
$\left[ \bigcup S \right]_{\cap} \supseteq \mathcal{A}$.
If filter $\mathcal{A} \supseteq \mathcal{X}$ for every $\mathcal{X} \in S$ then then $\mathcal{A} \supseteq \bigcup S$
then $\mathcal{A} \supseteq \left[ \bigcup S \right]_{\cap}$.
So $\left[ \bigcup S \right]_{\cap}$ is the least upper bound of $S$.


Decoding LinkedList implementation

Question: Just to understand the implementation, operation etc., I copied LinkedList class from JDK and modified in non-generic(String only) way. You can find the actual code here. Relevant to the question, here's addLast()
public void addLast(String e){
    System.out.println("Invoked:addLast()");
    linkLast(e);
}

Node inner class
private static class Node {
     String item;
     Node next;
     Node prev;
     Node(Node prev, String element, Node next) {
         this.item = element;
         this.next = next;
         this.prev = prev;
    }
    @Override   public String toString() {
        return "Node [item=" + item + ", next=" + next + ", prev=" + prev+ "]";
    }
}

linkLast()
void linkLast(String e) {
    System.out.println("Invoked:linkLast(" + e + ")");
    final Node l = last;
    final Node newNode = new Node(l, e, null);
    System.out.println("\tCreatd new node as:" + newNode);
    last = newNode;
    System.out.println("\tSetting this node as last");
    if (l == null){
        // Applicable for 1st node. Last & First point to newNode
        first = newNode;
        System.out.println("\tLast was null, setting this node as first.");
    }
    else{
        // Set newNode as next of previous Last.
        System.out.println("\tLast was not null, seting this node as next node of previous Last.");
        l.next = newNode;
    }
    size++;
    //System.out.println("Size of list:" + size);
    modCount++;
    System.out.println("\tMod Count:" + modCount + "\n");
}

I get a stackoverflow error, when I execute this class as,
public static void main(String args[]){
    LinkedListDemo obj = new LinkedListDemo();
    obj.add("B");
    obj.addFirst("A");
    obj.addLast("C");
}

Output
Invoked:add(B)
Invoked:linkLast(B)
    Creatd new node as:Node [item=B, next=null, prev=null]
    Setting this node as last   Last was null, setting this node as first.
    Mod Count:1
Invoked:addFirst()
Invoked:linkFirst(A)
    Creatd new node asNode [item=A, next=Node [item=B, next=null, prev=null], prev=null]
    Seting this node as first
    First was not null, seting this node as next node of previous First.
    Mod Count:2
Invoked:addLast()
Invoked:linkLast(C)
Exception in thread "main" java.lang.StackOverflowError
    at java.lang.String.getChars(String.java:826)
    at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:416)at java.lang.StringBuilder.append(StringBuilder.java:132)
    at java.lang.StringBuilder.<init>(StringBuilder.java:110)
    at collections.LinkedListDemo$Node.toString(LinkedListDemo.java:570)
    at java.lang.String.valueOf(String.java:2847)
    at java.lang.StringBuilder.append(StringBuilder.java:128)
    at collections.LinkedListDemo$Node.toString(LinkedListDemo.java:570)

And then last 3 lines keep repeating. I am not able to figure out what is causing such a scenario.
UPDATE - based on replies received
So, if the understanding is correct,
Invoked:add(A)
Invoked:linkLast(A)
    Creatd new node as:Node [item=A, next=null, prev=null]
    Setting this node as last
    Last was null, setting this node as first.
    Mod Count:1
Invoked:add(B)
Invoked:linkLast(B)
    Creatd new node as:Node [item=B, next=null, prev=Node [item=A, next=null, prev=null]]
    Setting this node as last
    Last was not null, seting this node as next node of previous Last.
    Mod Count:2
At, this stage "Node B" has been created with one sided link(prev) only, where toString() is invoked. Only, after that other side link(next) is linked. And this double link is the cause of infinite-recursion, at the time of next insertion.
Maybe this is the reason why toString() method is not implemented in neither of it's two superclasses AbstractSequentialList, AbstractList but in AbstractCollection. The implementation extracts an Iterator, which iterates to print the colletcion.
So, why does it happen only on the 3rd insertion. Two insertions do not cause this problem.
Answer: The problem is your toString method, which calls itself recursively when it attempts to print the prev and next Nodes.
If next of the current printed Node is not null, next.toString() will be called, and when the prev of that Node is printed, toString() of the original Node is called again, so there is no end to the recursion.
Possible solution :
@Override
public String toString()
{
    return "Node [item=" + item + ", next=" + (next==null?"null":next.item) + ", prev=" + (prev==null?"null":prev.item) + "]";
}

Regarding the comments :
After adding the first Node, the list looks like this :
prev             next
null <- Node1 -> null

first and last both refer to Node1
There's no risk of infinite recursion in toString.
After adding the second Node, the list looks like this :
null <- Node1 -> <- Node2 -> null

first refers to Node1 and last refers to Node2
As you can see, Node1 and Node2 refer to each other (Node1 is Node2's prev and Node2 is Node1's next). Therefore, trying to print one of those nodes with your original toString() method after the second insertion will lead to infinite recursion.
However, since you print the new node before the line l.next = newNode; is executed, you don't get an infinite recursion in the second insertion, only in the third. If you move System.out.println("\tCreatd new node as:" + newNode); to the end of linkLast, the second insertion will cause the infinite recursion.
Comment: `next` and `prev` are never null.
Comment: @cadrian I didn't follow the code closely enough to be sure of that, so I added the null checks to be safe. That said, based on the output the OP got before getting the StackOverflowError, they can be null.
Comment: Indeed you are right. I did not read carfully enough. Nodes are null at each end of the list.
Comment: Shouldn't they be so ? If so, where will next/prev of extremities will point ?
Comment: So, why is it that the problem only occurs after 2nd insertion ?
Comment: Convinced. By the way, I forgot to inform you @Eran that the ``toString()`` you proposed, is working fine.

Decoding LinkedList implementation


Usability: mupltiple colored logos for a single site?

Question: My client asked me to create a site for our company and sent 5 different logos in 5 different colors. He wants to add different color logo on each page. Say user will open about page then he'll get green color logo, contact page then blue color logo, home will have orange color logo and so on.
Personally I don't want to use multiple logos in this website, but to convince him I need reasons why this is not a good practice.
So, I wanted to know about the usability guidelines for website logo. I googled a lot but didn't able to find such blog post or articles.
Please help, thanks!
Answer: Well, if the logo doesn't rely on color much and is strong enough to take this kind of beating, then it might actually work.
Anyway, here's a few arguments against changing colors:

The logo needs to integrate well with the rest of the site to be aesthetically pleasing, so the colors of the stylesheet need to be in synch with the logo. If the logo's colors change, then the rest of the style must follow - this will increase the cost for development and maintenance.
Maintaining the logos themselves also takes more time - we can't simply make a single template with the logo and a menu; instead, we need 5 dedicated templates, or we need to make the logo part dynamic. Again, increased cost for development and maintenance. Also, if the logo ever needs to change, the graphic designer in charge will have to do the same thing 5 times instead of once.
Color is one of the most basic things humans recognize, and it has a strong connection with the subconscious. Using one logo and one color set consistently throughout the entire presence leads to a stronger sense of familiarity.
Changing colors might produce a short moment of confusion to the user, a feeling of accidentally having left the site, a second of "oh, I must have done something wrong" - not good feelings anyway. You don't want to confuse the user, you want a slick, coherent, comfortable, no-surprises experience.
Answer: It is more like a marketing question than a usability.
Web site branding needs a permanent visual sign. This is the logo. Permanence means to color also. Changing color page by page strongly confuse visitors.


React: how to structure routes for admin, user and public

Question: Im trying to figure out how to structure a Router to use different routes for admin, user and public.
I have seen this post and the answer describing a key cloak - but I haven't been able to make sense of it.
I've seen this code sandbox which looks logical to me, but I'm having trouble incorporating it.
I have a constants file where I and defining routes as:
export const NEWBLOG = '/admin/newblog';
export const VIEWBLOG = '/viewblog';

I'm importing that into my App.js and then wanting to define different consts for Admin, User and Public as follows:
import * as ROUTES from '../../util/constants/Routes';
import NewBlog from '../../components/blog/admin/New';

// admin routes
const Admin = ({ match }) => (
  <React.Fragment>
    <Route path={`${match.path}/${ROUTES.NEWBLOG}`} component={NewBlog} />
    <Route path={`${match.path}/2`} render={() =>
test
} />
  </React.Fragment>
);

// authenticated user routes
const Other = ({ match }) => (
  <React.Fragment>
    <Switch>
      <Route path={`${match.path}/2`} render={() =>
one
} />
      <Route path={`${match.path}/2`} render={() =>
two
} />
    </Switch>
  </React.Fragment>
);

// public routes
const Public = ({ match }) => (
  <React.Fragment>
    <Switch>
      <Route path={`${match.path}/2`} render={() =>
one
} />
      <Route path={`${match.path}/2`} render={() =>
two
} />
    </Switch>
  </React.Fragment>
);

Then inside the router statement I have:
const App = () => (

    <Router>
        <Navigation />
        <Switch>

            <Route path="/a" component={Admin} />
            <Route path="/u" component={Other} />
            <Route path="/p" component={Public} />

            <Route
                component={({ location }) => {
                  return (

                      <ErrorMessage />

                  );
                }}
              />
        </Switch>

    </Router>

);

export default App;

This all works until I try to use the routes constants inside the back ticks part of the Admin constant.
I can't seem to use that approach.
Can anyone help with a source of reference materials to find a way through this?
Comment: How it doesn't work? Why don't you define just the specific route part for the `NEWBLOG` constant like `const NEWBLOG = 'newblog'` instead of `const NEWBLOG = '/admin/newblog'`?
Comment: I am defining like that in the code, but just trying to make it clearer in the example. The part that stops it working is the ROUTES.NEWBLOG inside the back ticks
Comment: It works, you can check it [here](https://codesandbox.io/s/react-const-routes-vke31) and it has `ROUTES.NEWBLOG` inside curly brackets string literal. The issue I see is that you define the whole route in the `NEWBLOG` variable like `/admin/newblog`.
Answer: There are few things you need to know

Child Routes will render only when the Parent route path is matched
For the Child Route the path needs to be the path that matched the parent + the child route path
You can write wrappers over route which are responsible for deciding if the user is authenticated or an admin
In all such scenarios you need to store the user authentication state within state, context or redux store.
When you render the Route in Admin like

<Route path={`${match.path}/${ROUTES.NEWBLOG}`} component={NewBlog} />

The path to the component actually becomes /a/admin/newBlog which is actually incorrect
Overall you can change your code to something like this
App.js
const App = () => (
    <Router>
        <Navigation />
        <Switch>
            <Route path="/admin" component={Admin} />
            <Route path="/user" component={Other} />
            <Route path="/public" component={Public} />
        </Switch>
    </Router>
);

AuthRoute.js
const AuthRoute = (props) => {
   const {path, match, component: Component, render, ...rest} = props;
   const {user, isLoading} = useContext(AuthContext); // Assuming you use context to store route, you can actually get this values from redux store too.
   return (
      <Route
          {...rest}
          path={`${match.path}${path}`}
          render={(routerProps) => {
               if(isLoading) return
Loading...

                if(!user) return
Not Authenticated

               return Component? <Component {...rest} {...routerProps} /> : render(routerProps)
          }}
      />

}

An adminRoute needs to both check whether the user is admin as well as check if he is authenticated or not so you component would look like
AdminRoute.js
const AdminRoute = (props) => {
   const {path, match, ...rest} = props;
   const {user, isLoading} = useContext(AuthContext); // Assuming you use context to store route, you can actually get this values from redux store too.
   return (
      <Route
          {...rest}
          path={`${match.path}${path}`}
          render={(routerProps) => {
               if(isLoading) return
Loading...

               if(!user) return
Not Authenticated

               if(user.role !== "admin") return
Need to be an admin to access this route

               return Component? <Component {...rest} {...routerProps} /> : render(routerProps)
          }}
      />

}

Now you can use the above two components to separate out the Admin and Auth Routes
Also keep in mind that AuthRoutes and public routes paths cannot be the same
Route constants
export const NEWBLOG = '/newblog';
export const VIEWBLOG = '/viewblog';

Routes
import * as ROUTES from '../../util/constants/Routes';
import NewBlog from '../../components/blog/admin/New';

// admin routes
const Admin = (props) => (
  <React.Fragment>
    <AdminRoute {...props} path={ROUTES.NEWBLOG} component={NewBlog} />
    <AdminRoute {...props} path='/2' render={() =>
test
} />
  </React.Fragment>
);

// authenticated user routes
const Other = (props) => (
  <React.Fragment>
    <Switch>
      <AuthRoute {...props} path={'/3'} render={() =>
one
} />
      <AuthRoute {...props} path={'/4'} render={() =>
two
} />
    </Switch>
  </React.Fragment>
);

// public routes
const Public = ({ match }) => (
  <React.Fragment>
    <Switch>
      <Route path={`${match.path}/5`} render={() =>
one
} />
      <Route path={`${match.path}/6`} render={() =>
two
} />
    </Switch>
  </React.Fragment>
);

Comment: Thank you very much for this. I'll try it in the morning. Meanwhile, I'd be really grateful if you could give me a reference to look into to try to understand what: 1. component: Component 2. const {path, match, ...rest} = props; and 3.<Route {...rest} are doing. Thank you
Comment: 1,2 are concepts of object destructing and rest parameters. In one you destructure from an object and assign a different variable name to it. Second is the rest spread syntax wherein ...rest means all the rest elements i nthe props. In the third case we are actually passing all the rest parms to the Route component.

Refer MDN for [Rest](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters) and [Object Destructuring](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Object_destructuring) here
Comment: Thank you for this help. I'm still trying to make sense of these lines. I'm really slow to learn and have a lot of trouble making sense of documentation. I'm slower than the bounty period allows, so I've given the points and I'll come back to accept this answer when I have worked this through.


Preventing re-entering observeValueForKeypath recursively when KVO fired from model setter

Question: I have a whole host of models that watch themselves for changes. When a setter is triggered, the observer in the model is called and within that model I make a call to a web server and update information in the web server so it correctly has the data it should.
However, in my call to the web server I can get back an error for anything from connection being dropped, server reset etc to the server saying the update wasn't allowed (e.g. some other parameter changed by another user prevented the update).
Oh the joys of a disconnected data store...
Is there any way that I can update self (i.e. the model) without it re-triggering a KVO action?
I could turn off the observer when I get back the response, but another user action to the same object is possible while the background server request is being performed. This would then break the other call.
See the post here for an explanation of what I was trying to do to get the observation happening in the first place and a code example of the full model.
The portion where I am making the call would be in the observer as follows:
-(void)observeValueForKeyPath:(NSString *)keyPath
                 ofObject:(id)object
                   change:(NSDictionary *)change
                  context:(void *)context {

  if ([keyPath isEqual:@"firstName"]) {

    if !([serverCall value:[change objectForKey:NSKeyValueChangeNewKey]
                    forKey:@"firstName"]) {

        // Notify the user of the problem and somehow do a
        // [self setFirstName:[change objectForKey:NSKeyValueChangeOldKey]]
        // without firing off a KVO which would only loop this process
    }
  }

  if ([keyPath isEqual:@"lastName"]) {
    // Do whatever I need to do
  }
}

You guys always seem to come through on some good advice and I am always grateful for any suggestions you may have.
Comment: Hi, How much do you know about KVO? do you understand what triggers a notification to be sent?
Comment: I am pretty sure I do understand what triggers a notification, but I'm not sure how that is relevant to my question.
Comment: Well, it's just a thought - you could have an additional setter per  property that didn't trigger a notification. I can see that you might not want to do that tho.
Comment: Well I guess feeding off your comment I could do a direct change of the variable in the method where I am observing the changes (without doing a `[self setFirstName:value]` or using `setValue:forKey:`or using a key path), but then I would need to also fire off my own observer to tell the other observers outside the model that something changed on this object. Because I have to do this with some 200 or so properties I was trying to write as generic a method as I could...
Comment: So you do want to trigger a notification, but only for some observers?
Comment: I want to trigger an observer for every time a property gets set (which I can do using the regular methods), but as soon as the change to the property is made, I want to update a SQL DB with exactly the same setting (hence observing my own object model) and if the server doesn't allow the change, change the property back and fire a notification to let any other observers in the app reflect the correct state of the model. My `observerValueForKeypath` method  could, in theory, be generic enough just to pass the observer values straight to the server call. I think that description makes sense :-)
Comment: And on (almost) all properties in every model.
Comment: Yes I get it. It's just your question title is "undo a set on a model without triggering kvo", but you do want to trigger kvo, because there are other observers. You just don't want to re-enter your observeValueForKeypath: method, right?
Comment: You got it - I should probably edit my question title
Comment: So you could use a flag to keep track of when you have entered observeValueForkeypath: and if you enter it recursively you could return immediately, huh?
Comment: Doh! Ockham's razor (http://en.wikipedia.org/wiki/Occams_razor) strikes again. Yes - I could do that and it is probably the simplest approach. Over-thinking the problem me thinks...
Comment: So

`[serverCall value:[change objectForKey:NSKeyValueChangeNewKey] forKey:@"firstName"]`

is where you synchronously update the server?
Comment: Yes. It is a method in a custom class (serverInterface) that handles any object with the given key. This way as long as my key being passed in is know, the call goes out to the server. The intent was to not have to write one of these methods in every model object.
Answer: Well I ended up taking a different tack. Instead of relying on the object model to post the updates, I took everything up one level and let the controller handle the updates.
Essentially the process was as follows:

Create the objects in the model when required
Have a setter in the controller that held in a method variable the current state of the object settings
Passed the new settings up to the server, but only those that changed between the existing and the new settings (all the delta values)
If the call passed, update the model or, if it failed, notify the user and do nothing more

It worked out being a little more code in each controller, but by dynamically comparing the current values with the new values and only passing up the ones that had changed to the server I accomplished the same net result.
This allows me to pass up one of more values based upon how many changed without having to hard-code setters and getters with a call to a common server-API method over and over again.
The net effect was that I keep all my KVC/KVO notification without worrying about bypassing it or not doing KVC/KVO updates on some calls and not on others.


What are my options for temperature equalization between two rooms?

Question: Ideally a bi-directional through-wall vent + fan would be great with built in thermostats measuring both sides.
I haven't found that nor am I entirely sure what to search for. Are there components that I could buy that provide this functionality?
Edit:
So all fans AFAIK are bi-directional components. The issue is the controller and I don't care about controlling speed as much as the direction + on/off.
One solution I have in mind is something like this:
[through-wall fan/vent system] -> [some sort of inline polarity switcher] -> [wall plugin thermostat controlled relay]
The issue is the polarity switcher. A manual polarity switch would be fine since I'd only maybe need to change it seasonally for the most part. What can I look for that does that?
PS: I am not looking to cut anymore than a single whole in the wall (and no more than 4-9" diameter) and simple set up is a plus. Long term I may loop back and do a custom job with an arduino but for now I'm looking for cheap, easy & off-the-shelf.
Comment: Could you back up and describe the situation?
Comment: Two rooms with different temperatures side by side. One room is presently generating excess heat that could be better used elsewhere in the house.
Comment: Like a server room or something?
Comment: Yeah essentially.
Answer: Here's a dead-simple idea: use a PTAC unit to air condition the room with excess heat, and dump it into the adjacent room.
That's the general idea behind how companies with huge server rooms recycle heat during wintertime. Their systems are much more sophisticated, of course, inevitably involving heat exchangers, water cooling, thermostats, multiple zones for the heat so conditioned areas don't get too hot, etc.
There are many other ways to do this, depending on the details of your house. If you have ducted heat, you could rig up an air or water-based heat exchanger attached to a new coil in your HVAC air handler. If you have hydronic heat, you could use a similar heat exchanger to put the heat into that system. Etc. It's probably beyond the scope of this website to design such a system for you, but hopefully I've given you some ideas. There are many ways to move heat from one place to another. Get creative!
Answer: I am not aware of any professional products for this, but you could get an arduino or rasberry pi device with two temperature sensors, and hook it up to a bi-directional fan and write some code to have it automatically start at a certain temperature difference.
Answer: Simply exchanging the air between the rooms will equalize the temperatures because the air will mix. I would just cut two vents in the wall, one high and one low. Natural airflow probably won't be enough to balance the temperature, so put a fan in one or both of the vents. If you do both, point the fans in opposite directions.
Again, it doesn't really matter which way the air moves because it will mix.


How to set Table Row height and the Cell Options as Fit Text with Content Control in word Addin | Officejs

Question: I have existing word plugin in C# and I'm converting it to Office.js. My requirement is to Add Table in word with 1 row and 1 column. The Cell text would be Content Control of table and text should fit to entire row and also Specify the Row height as mentioned in below Expected results snapshots.
Below is my code in react.
Code in react
Actual Result:(output of the new implementation i.e. Office.js)
Actual Result
Expected Result:(Existing Plugin result i.e. C#)
Exptected Result
Please guide/provide me sample code to achieve this in Office.js
Answer: Try using TableRow.preferredHeight to set the height and set TableCell.horizontalAlighnment to Justified to get the contents to fill the cell.
Comment: Thanks for the solution. 1st one is worked i.e. **preferredHieght** but the 2'nd one  Alignment issue didn't work. As you suggested, i have tried as follows `context.document.body.tables.getFirst().rows.getFirst().cells.getFirst().horizontalAlignment = "Justified"` but didn't work. is there any other way to achieve the **Fit Text** option enabling for table Cell ?


Use custom form to upload multiple files to Google Drive and record form response on spreadsheet

Question: For the organisation of a large scout camp, I am currently trying to build a web form where requests for services (security, infrastructure, materials, etc.) can  be made. For this I would like the following:

upload (multiple) files to a google drive folder
write the remaining input (text, names, etc.) to a google spreadsheet
If possible, write the url of the file location to that same spreadsheet

So far, I have been utterly unsuccesful in combining the first two functions. Over the course I have tried combining the methods as described in:
https://script.google.com/d/1x3p9ZAv-SafEK06r_Vr7fVuUNtEfBg1SGhmSYWjQ0kuPTk-y55a7Nink/edit?usp=sharing
Uploading Multiple Files to Google Drive with Google App Script
HTML form file upload to Google Drive and save URL to google sheet
Google Forms: Send data to spreadsheet
Google Forms file upload complete example
https://gist.github.com/xtman/060edd76c27b7fcb343dfb8e08252693
As per request, I am trying to achieve this the following way:
Code to make two functions both happen:
frm.submit(function () {
    allFiles = document.getElementById('supportingFiles').files;
    if (!frm.checkValidity || frm.checkValidity()) {
      if (allFiles.length == 0) {
        alert('Error: Please choose at least 1 file to upload.');
        google.script.run.record_Data(frm);
        return false;
      } else {
        frm.hide();
        alert('Step 1');
        var subfolderName = document.getElementById('requesterSubject').value;

        $.ajax({
          url: '',//URL of webhook endpoint for sending a Slack notification
          data: {
            title: subfolderName + ' is uploading screenshots',
            message: ''
          }
        });
        alert('Step 2');
        //google.script.run.withSuccesHandler(record_Data(transformedData).transformData('myForm');
        google.script.run.withSuccessHandler(afterSubfolderCreated).createSubfolder(subfolderName);
        alert('Step 3');
        return false;
      }
    } else {
      alert('Invalid form');
      return false;
    }
});

This is where the error occurs. It is able to run the code as-is, but when I try to also run the recordData function, it doesn't do  anything.
The code of the functions is as follows:
Submit the data
function dataTransform(form){
  var transformedData = JSON.stringify( $(form).serializeArray() ); //  <-----------
  console.log( data );
  return transformedData; //don't submit
}

function recordData(e) {
  Logger.log(JSON.stringify(e)); // log the POST data in case we need to debug it
  try {
    var doc     = SpreadsheetApp.openById('some id');
    var sheet   = doc.getSheetByName('responses'); // select the responses sheet
    var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0];
    var nextRow = sheet.getLastRow()+1; // get next row
    var row     = [ new Date() ]; // first element in the row should always be a timestamp
    // loop through the header columns
    for (var i = 1; i < headers.length; i++) { // start at 1 to avoid Timestamp column
      if(headers[i].length > 0) {
        row.push(e.parameter[headers[i]]); // add data to row
      }
    }
    // more efficient to set values as [][] array than individually
    sheet.getRange(nextRow, 1, 1, row.length).setValues([row]);
  }
  catch(error) {
    Logger.log(e);
  }
  finally {
    return;
  }
}

Submit the files
function uploadFileToDrive(base64Data, fileName, subfolderId) {
  Logger.log(subfolderId);
  try{
    var splitBase = base64Data.split(','),
        type = splitBase[0].split(';')[0].replace('data:','');

    var byteCharacters = Utilities.base64Decode(splitBase[1]);
    var ss = Utilities.newBlob(byteCharacters, type);
    ss.setName(fileName);
    var subfolder = DriveApp.getFolderById(subfolderId);
    var file = subfolder.createFile(ss);
    Logger.log(file);
    return file.getName() + ' at ' + file.getUrl();
  } catch(e) {
    return 'createFile Error: ' + e.toString();
  }
}

function createSubfolder(subfolderName) {
  var dropbox = Utilities.formatDate(new Date(), "Europe/Amsterdam", "yyyy-MM-dd_hh.mm_") + subfolderName ;
  Logger.log(dropbox);
  var parentFolderId = "some folder id";
  var parentFolder = DriveApp.getFolderById(parentFolderId);
  var folder;
  try {
      folder = parentFolder.getFoldersByName(dropbox).next();
  }
  catch(e) {
      folder = parentFolder.createFolder(dropbox);
  }
  Logger.log(folder);
  return folder.getId();
}
function afterSubfolderCreated(subfolderId) {
  console.log(subfolderId);
  console.log(allFiles);
  numUploads.total = allFiles.length;
  $('#progressbar').progressbar({ value: false });
  $(".progress-label").html('Preparing files for upload');
  for (var i = 0; i < allFiles.length; i++) {
    console.log(i);
    sendFileToDrive(allFiles[i], subfolderId);
  }
}

function sendFileToDrive(file, subfolderId) {
  var reader = new FileReader();
  reader.onload = function (e) {
    var content = reader.result;
    console.log('Sending ' + file.name);
    google.script.run.withSuccessHandler(updateProgressbar).uploadFileToDrive(content, file.name, subfolderId);
  }
  reader.readAsDataURL(file);
}

function updateProgressbar(idUpdate) {
  console.log('Received: ' + idUpdate);
  numUploads.done++;
  var porc = Math.ceil((numUploads.done / numUploads.total) * 100);
  $("#progressbar").progressbar({value: porc});
  $(".progress-label").text(numUploads.done + '/' + numUploads.total);
  if (numUploads.done == numUploads.total) {
    numUploads.done = 0;
    $(".progress-label").text($(".progress-label").text() + ': FINISHED!');
    $("#progressbar").after('(Optional) Refresh this page if you want to fill out another request.');
    // does not work
  }
}

function fileUploaded(status) {
  document.getElementById('myForm').style.display = 'none';
  document.getElementById('output').innerHTML = status;
}

Comment: I disagree with the need for the HTMLService here: it can all be accomplished with Google Forms & Google Sheets. Incidentally, Forms already does all of this for you (handle upload of multiple files, write submitted data to a spreadsheet, write file URLs to the same spreadsheet): what do you need to implement that's not provided there?
Comment: _"For now I won't bother you with the code"_ Can you include the code that you have tried at the Question. See https://stackoverflow.com/help/how-to-ask, https://stackoverflow.com/help/mcve
Comment: Include the code so we can better help you. the whole proccess just involves using HTMLService to get the form to the "server side" and then using DriveApp to upload the files (the form gives them to you as blobs), get the links from them and finally use SpreadsheetApp to put it all in your google sheet.
Comment: Fair enough, the above can roughly be accomplished with Google forms, but for me the issue is that it requires a google account. I have also included parts of the code above, but since I am very new to this all, please correct me if anything is missing.
Comment: A common way to organize code in your question for webapps is to explicitly indicate which scripts are in .gs code files (which are run server-side only), and which are within `
Answer: I don't know about the code, not competent enough. However, when you enter your data in a spreadsheet through a Google Form, you can use the Autocrat add-on to generate a google doc of pdf file which will be sent by e-mail and saved to a single folder. You can also use the dynamic reference folder ID to save the file to several folders at once. All you have to do is enter the Google Drive files reference in you spreadsheet. If you have hundreds of folders to link, it can be strenuous, but I do it with a hundred students or so for assessments and it works perfectly. Hope that helps...


incompatible pointer type assigning in function pointer usage

Question: I'm trying to use function pointer in my code, the code is as below.
#include <stdio.h>
#include <pthread.h>

typedef void (*PFUNC)(int);

typedef struct tag_FUNC_INFO_S
{
    PFUNC callback;
    int   index;
} FUNC_INFO_S;

PFUNC callback_print(int index)
{
    printf("[callback] index = %d\n", index);
    return NULL;
}

void thread_test(FUNC_INFO_S *info)
{
    info->callback(info->index);

    pthread_exit(NULL);
}

int main()
{
    pthread_t tid;

    FUNC_INFO_S info;
    info.callback = callback_print;
    info.index    = 777;

    pthread_create(&tid, NULL, (void *)thread_test, &info);

    printf("main printing\n");

    return 0;
}

After compiled the code with "gcc -Wall xxx.c -o xxx -lpthread", the compiler complains with the following message:
func_ptr_test.c:30:16: warning: incompatible pointer types assigning to 'PFUNC' (aka 'void ()(int)') from 'PFUNC (int)' (aka 'void ((int))(int)' [-Wincompatible-pointer-types] info.callback = callback_print;
But, if I change the code from
info.callback = callback_print;

to
info.callback = (PFUNC)callback_print;

No warning message comes out any more. But, even without type casting, I think the "info.callback" has totally the same type with "callback_print", so I'm wondering why the warning message comes out. Does anyone have idea about this?
Comment: I do believe: `PFUNC callback_print(int index)` --> `void callback_print(int index)`
Comment: the functions being used as threads MUST have the syntax: `void * functionName( void *)`  Your thread functions do not have that syntax
Comment: near the end of the `main()` function the statement(s): `int *status = NULL;  pthread_join( tid, &status );` is missing
Comment: the first few lines of `thread_test()` should be: `void *thread_test( void *param)  {  FUNC_INFO_S info = *( FUNC_INFO*)param;`
Comment: strongly suggest replacing: `gcc -Wall xxx.c -o xxx -lpthread` with `gcc -Wall -Wextra -Wconversion -pedantic -std=gnu11 xxx.c -o xxx -lpthread`
Answer: You can't define a function with a function pointer typedef.  You just need to define the function to match the typedef:
void callback_print(int index)
{
    printf("[callback] index = %d\n", index);
}

Answer: Sometimes, exploring what is beneath the surface helps to understand the picture better.
In C, you can pretty much treat the function name as a pointer to that function. Take a look at the example below
#include <stdio.h>

int main() {
    (*printf)("test\n");
    return 0;
}

In the code snippet above, we could simply use printf() instead of (*printf)(), and it actually is the usual way you would call a function.
Another example is the signal() library function (yes, I am a FreeBSD user), whose definition is given as
 void
 (*signal(int sig, void (*func)(int)))(int);

When you call signal(), the convention is
void
handle(int sig)
{
    ...
}

int main(int argc, char **argv)
{
    (void) signal(SIGUSR1, handle);
    ...
}

Now, can you see the trick here? Although, signal() is declared to take void (*func)(int) (i.e. a pointer to a function returning void and taking a single int argument), we pass the name of a function of that type as the second argument to signal().
Going back to your question, PFUNC is an alias for a pointer to a function returning void and taking a single int argument. By declaring callback as PFUNC callback you are saying your compiler that, the callback variable will point a function which returns void and takes a single int argument.
So, you should have
void callback_print(int index) /* now you have a void ()(int) */
{
    printf("[callback] index = %d\n", index);
}

to match what is expected as the lvalue of your assignment performed by info.callback = callback_print;.
Answer: You have have a wrong understanding of the funcion pointer.
You can change your
PFUNC callback_print(int index)

prototype as
void callback_print(int index)

And all things should be fine. Why the compiler is not happy is because
PFUNC callback_print(int index)

prototype is void (* (*)(int))(int) but PFUNC type is void(*)(int)
So your return type is void(*)(int) not void


Line Icons / Filled Icons

Question: When to use line icons and when filled icons ? Is it something related to personal choice or it depends on the visual balance of the screen.
Comment: I would say it is a design choice, depending on the page content, etc. line could suit better than filled (I personally prefer filled). Take a look at the [Spotify icon redesign](https://medium.com/@andrealimjoco/redesigning-the-spotify-icon-suite-63f16853ba00).
Comment: This sounds like an issue for your Visual Design team.
Answer: I think it's important to consider the visual balance while choosing they type of icons - plus the cognitive load as well. My personal opinion is to use solid icons as they reduce cognitive load and increase interaction speed.
Here's a great study done on this topic:

Averaged across all 20 icons, hollow icons were selected about 0.1
  second slower than solid icons, which would seem to support Johnson's
  assertion that hollow icons require more cognitive effort to recognize
  than solid icons (if only a very small amount more). However, the
  picture isn't yet complete.
https://www.viget.com/articles/are-hollow-icons-really-harder-to-recognize-a-research-study

Line Icons / Filled Icons


Can this upper vent be covered?

Question:
can this upper vent be covered/removed? This is a wood fireplace, that we plan on using. There is also a hole in the right side of the fireplace.
We plan on putting a large post/shelf where this vent is, but are unsure if covering or removing this is unsafe.
Comment: refer to the fireplace instalation instructions ...
Comment: At minimum it will reduce the effectiveness of the fireplace at producing heat, as it's all but certain to be the exhaust vent of a "heatilator" to recover some heat before it goes up the flue. Unless you are "using it" merely for amusement value rather than to get some heat, this plan sounds unwise for that reason alone. The location is probably also too close to the top of the fireplace for any shelf made of wood or other combustible materials.
Answer: The comments have already addressed that you should look at the installation instructions of the fireplace. And it is probably an exhaust.  Ours needed in air inlet, but that was a grill much lower down.
Whether you remove the vent or not.  If you are wanting to put a timber shelf, you can do what we did.  We got a metal heat deflector made - it was actually designed by our fireplace installer.  It was very thin, barely visible, and hung down about an inch from the shelf.  It was very effective.

Can this upper vent be covered?


Give permission to hdf to remove directory

Question: When I run hdf namenode -format then it wants to remove a directory /home/hadoop/hadooptmpdata/dfs/name/current but it has no permission to do it.
How to give it a permission?
Answer: Use sudo command sudo hdf namenode -format


Flutter error : The argument type 'Map' can't be assigned to the parameter type 'Map'

Question: I am trying to store the image in SQFLite database as string. While setting up the DBHelper class, I am getting the said error.

Here is the code of model.dart and dbhelper.dart

class Photo {
  int? id;
  String? photoName;

  Photo({this.id, this.photoName});

  Map<String, dynamic> toMap() {
    var map = <String, dynamic>{
      'id': id,
      'photoName': photoName,
    };
    return map;
  }

  Photo.fromMap(Map<String, dynamic> map) {
    id = map['id'];
    photoName = map['photoName'];
  }
}

import 'package:path_provider/path_provider.dart';
import 'package:sqflite/sqflite.dart';
import 'package:path/path.dart';
import 'model.dart';
import 'dart:io' as io;
import 'dart:async';

class DBHelper {
  static Database? _db;
  static const String ID = 'id';
  static const String NAME = 'photoName';
  static const String TABLE = 'PhotosTable';
  static const String DB_NAME = 'photos.db';

  Future<Database?> get db async {
    if (null != _db) {
      return _db;
    }
    _db = await initDb();
    return _db;
  }

  initDb() async {
    io.Directory documentsDirectory = await getApplicationDocumentsDirectory();
    String path = join(documentsDirectory.path, DB_NAME);
    var db = await openDatabase(path, version: 1, onCreate: _onCreate);
    return db;
  }

  _onCreate(Database db, int version) async {
    await db.execute("CREATE TABLE $TABLE ($ID INTEGER, $NAME TEXT)");
  }

  Future<Photo> save(Photo photo) async {
    var dbClient = await db;
    photo.id = await dbClient!.insert(TABLE, photo.toMap());
    return photo;
  }

  Future<List<Photo>> getPhotos() async {
    var dbClient = await db;
    List<Map> maps = await dbClient!.query(TABLE, columns: [ID, NAME]);
    List<Photo> photos = [];
    if (maps.length > 0) {
      for (int i = 0; i < maps.length; i++) {
        photos.add(Photo.fromMap(maps[i]));     // ==> Here, at maps[i], it shows the error
      }
    }
    return photos;
  }

  Future close() async {
    var dbClient = await db;
    dbClient!.close();
  }
}

How can I solve this ?
Answer: Change your Photo model to Map<dynamic, dynamic>. The reason for this is that the db is returning a Map<dynamic, dynamic>.
class Photo {
  int? id;
  String? photoName;

  Photo({this.id, this.photoName});

  Map<dynamic, dynamic> toMap() {
    var map = <String, dynamic>{
      'id': id,
      'photoName': photoName,
    };
    return map;
  }

  Photo.fromMap(Map<dynamic, dynamic> map) {
    id = map['id'];
    photoName = map['photoName'];
  }
}


return data from sendAsynchronousReques

Question: Objective c: I have a serviceClass connecting to a db with NSURLConnection and sendAsynchronousRequest.
I want to be able to use this class method and return the db-data to any other classmethod requesting it.
But since the sendAsynchronousRequest is returning void - how can i do this?
I cant get my head around it at all atm. Blocks? But how...
Please help
atm I am creating a user object directly in this codechunk bellow:
[NSURLConnection
 sendAsynchronousRequest:urlRequest
 queue:[[NSOperationQueue alloc] init]
 completionHandler:^(NSURLResponse *urlResponse,
                     NSData *data,
                     NSError *error) {

     if ([data length] > 0 && error == NULL){ // do success or error call with true or    false
         NSMutableData *incomingData;
         if(!incomingData) {
             incomingData = [[NSMutableData alloc]init];
         }
         [incomingData appendData:data];
         NSString *string = [[NSString alloc]initWithData:incomingData
                                                 encoding:NSUTF8StringEncoding];
         //incomingData = nil;

         // create dictionary from json
         NSData *jsondata = [NSData dataWithData:incomingData];
         NSMutableDictionary *userDictionary = [NSJSONSerialization JSONObjectWithData:jsondata
                                                                                options:NSJSONReadingMutableContainers
                                                                                error:NULL];
         // create user object
         User *user = [User userFromDictionary:userDictionary];
         NSLog(@"user back to object successfull!! %@", user);

     }

     }

Comment: are you getting data in incomingData?
Comment: yes. I get the data from the db. so far so good..
Comment: you want to access incomingData in this class itself? If that the case, then you can just create property for this and access it through out the class.
Comment: I want to be able to pass the data along so that other classes can access the data. not use it in the class itself.
Comment: you can do that as well using property of this, if this is initialised without returning from class you can send anywhere.
Answer: You can use property for incomingData and then use that property to pass data to other methods/class.
@property (nonatomic, retain) NSMutableData * incomingData;

Now you can use self.incomingData to set value, and you need to return. You can use it in other methods, and when you need to pass this to other class, you can pass it.
Comment: but how can I return the incoming data from within the asyncronous completion handler? When I call it from another method/class it gets null since the asyncrounus still is working in the background.
Hope you understand my question.
Comment: i am not saying to return anything, you just set the data as a property, now you can pass it anywhere without returning, have you tried implementing this?

return data from sendAsynchronousReques


How can I draw a line in a printer that looks thinner than a pixel?

Question: I know the GDI limitation. GDI can only draw line which width is at least 1 pixel. But I still want to draw a line which looks thinner than 1 pixel in a printer.
Do you mean I can do it like this:
<code>with cLogBrush do
begin
    lbStyle := BS_Solid;
    lbColor := ACanvas.Pen.Color;
    lbHatch := 0;
end;
dwStyle := PS_COSMETIC or PS_ALTERNATE;
ACanvas.Pen.Handle := ExtCreatePen(dwStyle, 1, cLogBrush, 0, nil);
ACanvas.MoveTo(X1, Y1);
ACanvas.LineTo(X2, Y2);
</code>
Comment: I'm going to take your word that GDI and printing deals with pixels and not other units. You could try using dithering to fake the line weight.
Answer: You could (for example) draw a line of alternating black and white pixels. At least with a typical laser printer at 600 to 1200 DPI, this will normally blend pretty well into a line that looks less dark. I should add, however, that a line only one pixel wide from a good laser printer really is pretty thin.
A lot here does depend on the printer though. Just for example, with most ink jet printers, the thinnest line you can draw is thicker, even when/if they quote the same (or even higher) resolution. The lines usually aren't quite as clean either -- in both cases, they're darkest at the center, and fade to the paper color, but with an ink jet that "fade" is usually quite a bit slower so the edges of the line aren't as clean.
Comment: Do you mean I can do it like this:


GeoNode installation issue with Openjdk

Question: I'm following the official guide to install GeoNode on Ubuntu 18.04.
After typing of sudo update-java-alternatives --jre-headless --jre --set java-1.8.0-openjdk-amd64 I see this error:

update-alternatives: error: no alternatives for policytool

How I can solve?
Comment: Try this : `sudo update-alternatives --config java` .... Then you can select the preferred version. ... If it's installed !
Comment: It run! If you add this comment as answer I upvote you
Answer: Selecting between installed java versions :
sudo update-alternatives --config java

... Then select the preferred version.

GeoNode installation issue with Openjdk


Is it mandatory to only use alkaline batteries ("LR6" designation) with the Xbox One controller?

Question: According to Xbox support:

When replacing the batteries in your Xbox One Wireless Controller, use only AA batteries that have an "LR6" designation (alkaline batteries).

I have two types of rechargeable batteries from two manufacturers (Sony and Varta) and both are nickel metal hydride (NiMH, see battery types compared). I don't want to purchase new batteries solely for the controller, especially not disposable models due to environmental waste and cost.
Answer: From my experience, I use Energizer NiMH rechargeable batteries in my Xbox One Elite controller (and a regular Xbox One Controller as well), and have experienced no issues what so ever.  I don't think the material of the battery has any significant impact, if any at all on the controller.  Mine still work, and I've had them for years now.
Answer: I can't say anything about that particular controller (I don't own one), but I can shed some light on why they might be recommending against rechargeable batteries.
While the controller doesn't really care about the particular chemistry of the battery you put in it, it might care about the battery voltage.
Regular alkaline non-rechargeable batteries come in at ~1.6V fresh from the box and have a fairly linear discharge curve. NiMH rechargeable cells have a voltage of ~1.4V when fully charged and sit between 1.1V and 1.2V when discharging most of the time.
Some appliances work great with both types while others refuse to work at the 1.2V level, which means that NiMH batteries don't really suit them - you can't access most of the energy stored. That might be the case here.
There is a third option though - you can look for lithium based rechargeable AA batteries. They have a built-in buck converter and USB charging circuitry. You can get them from e-bay or amazon, though they are more expensive than NiMH batteries, so stick to those if they work for you.
Answer: It's not mandatory. That's only a power source. Using alkaline batteries prevents eventual risk of leak if controller lay unused decent amount of time. If you won't let your NiMH's lay discharged a long time that shouldn't be a problem. But even when leak occurs nothing happens... except risk of environment contamination ;)
Edit: NiMH's doesn't like slow discharging, it leads to raise of its internal resistance and consequently faster use (becoming less efficent faster). But if you play intensively from time to time, that's not a problem.

Is it mandatory to only use alkaline batteries (“LR6” designation) with the Xbox One controller?


Use Apache Camel for doing a fire and forget HTTP request

Question: I would like to know if it is possible to do a HTTP POST Request fire and forget and don't wait until you get a response. I am not sure if I should using HTTP component or AHC, I guess AHC is more convenient for my scenario.
I am using Apache Camel 2.12.1 and Spring XML. If is possible, how can I achieve it?
Thanks!
Answer: Choosing between the http4 and ahc Camel components is not a matter of asynchronism but of performance under heavy load. Said differently, if your request rate is small or medium, http4 component is enough.
There are several ways of achieving "request fire and forget" whatever the target component is:

Use ProducerTemplate#asyncSend to create a request-only exchange http://camel.apache.org/async.html
Use a SEDA component with waitForTaskToComplete set to Never http://camel.apache.org/seda.html

In both cases, the request will be executed in separate thread, so the caller won't wait.
Comment: I ended up using Async and AHC because I need to handle heavy load. Thanks for the options.


Alternatives to 3mm welded mesh for mice protection?

Question: One room of my house is below a slanted roof. The tiles on the roof are quite old, so mice can probably enter through the tiles. I want to use a classic design for insulation. (From top to bottom). Underlay, Insulation, Moisture barrier. I have read that mice can bite through the underlay to get into the insulation layer, thus I want to protect the underlay with welded mesh wire, so the mesh wire will be installed as the outermost layer under the tiles. I can't use copper wool, since I have to cover an extensive area of about 10-15m2.
In a comment to this question the User "Ecnerwal" suggested to use 3mm mesh wire.
I have done an extensive search for welded 3mm mesh. However welded mesh of this mesh size is very hard to get. The smallest I could find so far is 3.5mm but the price is very high, about 50 Euro per m2.
I'm also starting to question the 3mm number. I found this research paper stating

While extremely good guides, they do contain an important
error – they confuse the statement that mice can squeeze under a ¼ inch (approximately 6 mm) gap with
a later figure that shows a round hole of ¼ inch diameter, clearly too small for even a newly-weaned
mouse to get through. Howeve,r facts such as this can become accepted wisdom in the pest control
industry, especially in the absence of recent basic behavioural research on proofing techniques.

This guide by the University of Nebraska lists 6mm as being effective against mice.

Rats only need slightly more than a ½-inch gap to enter; mice only need slightly more than a ¼-inch gap

Texas A&M University also has a guide stating the 1/4" as being effective against mice.

Open access points as small as 1/4 inch in diameter for mice 1/2 inch for rats act like beacons, attracting rodents with warm air and food smells.
Seal any openings greater than 1/4 inch in diameter in foundations, walls, fascia, and roofs. Screen vents and install door sweeps to prevent access. If rats are entering through floor drains, seal these with hardware cloth with mesh smaller than 1/2 inch.

The University of Massachusetts gives a similar number.

Some rodents such as mice can get in through openings as small as ¼ inch.

The University of Utah gives a similar number

The mesh should be 1/4 inch or less in size
Comment: Do you need the ventilation/passage of stuff that a mesh provides?  If not then a solid piece of metal will provide mice/rat blockage and you do not need to worry about size or welded or not.  Most of those links are for covering holes in walls/floors, not for floors/walls without holes, which your underlay/tiles should not have or you have made a goof.
Comment: No, since for large areas copper mesh is not suitable. I need to protect my underlay since mice can also enter through the tiles. Also the comments do not specify which mesh size to use
Comment: You need to add that info to the question, @CuriousIndeed. Because buried down here in the comments it's not likely to get read by everyone. While you're editing that in, you may want to indicate (in the question) why the copper mesh won't work for you.
Comment: I think 6mm is too wide.
Comment: @FreeMan Tried to clarify the question.
Comment: @RohitGupta Not according to all the sources I found from universities
Comment: @CuriousIndeed - my experience differs.  Maybe their mice are fatter.  It would be silly to put in 6mm mesh and then find out that it doesn't work.  `Open access points as small as 1/4 inch in diameter for mice 1/2 inch for rats act like beacons, attracting rodents with warm air and food smells.` doesn't say what you are interpreting it to be.  They act like beacons, because the holes are large.  It doesn't say then cant enter through narrower holes.
Comment: @RohitGupta Added another passage from the same document to clarify. Did you ever use 1/4 inch rustfree, WELDED mesh and it did not work? Did you check why it did not work?
Answer: I don't know your desired application but if you really want a 3mm mesh you could get perforated sheet metal.
To prevent rodents entering the roof: There are matching products widely available. Ask for "metal eave combs" at your local building supply.
Comment: Surely mice cannot get through 1/4 inch mesh "hardware cloth". This would be square openings 6.35 mm on each side, 9 mm diagonal.
Comment: @JimStewart yes, without doubt. I didn't read his citations, so I just went the "he wants it - he gets it" route.