Getting 'live' controller variable values within Javascript I'm calling an actionFunction from Javascript to set a controller variable.  Even though the variable is being updated within the controller, when I subsequently access it from the same piece of script it still holds the old value. Now I understand that the updated value will become available after rerendering, but I'd like to access the new value later in the same script. Is there any way I can refresh the controller variable during the lifetime of the script, or is it easier just to create a JS variable that holds the new value, and use that instead?  UPDATE  I'm not sure why this has been marked as a duplicate. This post describes a different issue, and the fix offered for my other post does not help with what I describe here.  PAGE  &lt;apex:page controller="MyController"&gt;     &lt;apex:form &gt;         &lt;apex:outputPanel id="panel"&gt;             &lt;apex:outputText value="MyString = {!MyString}"/&gt;             &lt;apex:actionFunction name="SetString" rerender="panel"&gt;                 &lt;apex:param name="param1" value="" assignTo="{!MyString}"/&gt;             &lt;/apex:actionFunction&gt;             &lt;script&gt;                 function JSetString()                 {                     console.log('before: ' + '{!MyString}'); // shows last value assigned                     SetString('{!MyString}' + '.');                     console.log('after: ' + '{!MyString}'); // doesn't show updated value                 }              &lt;/script&gt;             &lt;apex:outputPanel onclick="JSetString()" styleClass="btn"&gt;                 Grow {!MyString} (works)             &lt;/apex:outputPanel&gt;         &lt;/apex:outputPanel&gt;     &lt;/apex:form&gt; &lt;/apex:page&gt;   CONTROLLER  global class MyController {      public MyController() { MyString = 'hello'; }      public String MyString {get;set;} }
Setting controller variables not reliable from apex:commandButton I'm trying to set a variable inside my controller via an actionFunction, which is called by some Javascript, which is initially called by either by an actionPanel (with styleClass='btn') or a commandButton.  If the caller is the actionPanel then the variable updates reliably. However with the commandButton I can see the updated value flash briefly before reverting to its previous value. Maybe one out of every six clicks of the button actually causes the new value to stick. Sometimes it can take a dozen or more tries, regardless of click frequency.  Can someone please explain what's going on here?  PAGE  &lt;apex:page controller="MyController"&gt;     &lt;apex:form &gt;         &lt;apex:outputPanel id="panel"&gt;             &lt;apex:outputText value="MyString = {!MyString}"/&gt;             &lt;apex:actionFunction name="SetString" rerender="panel"&gt;                 &lt;apex:param name="param1" value="" assignTo="{!MyString}"/&gt;             &lt;/apex:actionFunction&gt;             &lt;script&gt;                 function JSetString() {                     SetString('{!MyString}' + '.');                 }             &lt;/script&gt;             &lt;apex:outputPanel onclick="JSetString()" styleClass="btn"&gt;                 Grow {!MyString} (works)             &lt;/apex:outputPanel&gt;             &lt;apex:commandButton onclick="JSetString()" value="Grow {!MyString} (unreliable)" rerender="panel"/&gt;         &lt;/apex:outputPanel&gt;     &lt;/apex:form&gt; &lt;/apex:page&gt;   CONTROLLER  global class MyController {      public MyController() { MyString = 'hello'; }      public String MyString {get;set;} }
How do I transfer data and settings from one Apple Watch to another? I have an Apple Watch. I have had it for a while. I just bought a new Apple Watch. (Both are Series 1, just different sizes.)  I would like to transfer all my data and settings from my old Apple Watch to my new Apple Watch and then sell my old Apple Watch.  Is it possible to migrate my profile from one Apple Watch to another?  If so, what is the procedure?  All the search results I have found have to do with moving an Apple Watch to a new iPhone or restoring a backup to the same Apple Watch. Perhaps it is possible to restore a backup from an old Apple Watch onto a new one? I'm a Sri Lankan passport holder. I'm planning to travel to China in January and have to transit in Malaysia. I wonder whether I can obtain a Malaysian transit visa in KLIA 2 when I'm flying back to Sri Lanka. I have meticulously read through similar questions, answers and their comments but I still do not understand how the deletion is done. From what I understand I email the customer service and then they do what exactly?     1) They disable my account so that I can no longer use it?      2) They reassign all of my questions and answers to some other   account? To which one?      3) They delete all my questions and answers so that they go away from   public view?   What is the flexibility (if it exists) of the deletion procedure? Is it possible to erase the traces of my former association with the site. Can I request any of the following be done?     4) All of my questions and answers be deleted from public view?      5) Some of my questions and answers be deleted? If yes what criteria?      6) Can I have all of my contributions be assigned to some other   account which runs as sort of a "collective account" and already has   tons of content so that it doesn't happen like my contributions just   move to some other url but still stay grouped under that location and   therefore that location can be discovered as representing my account?      7) Can I have my contributions dispersed through several "collective   accounts?      8) Can my current public name be removed from any comments to my posts   so that my posts cannot be identified later as once belonging to me?   Please be polite with me. I wouldn't have asked if I have found the answer in the other questions. The other questions are also old and it is not clear what the situation is as per 05/2012.  UPDATE (for those interested):  I asked the Stackoverflow team about the procedure. Apparently none of the points 2-8 I asked above are possible, only 1 will take place. The link to my user page from my contributions is going to be removed and replaced with non-clickable text of an anonymized user name like "user1234". Whether this number is the same as my current user_id is not clear. That's all the information I got.  I'm going now to rename myself to "Anonymous" then request the account deletion. Those interested in the procedure will witness the exact result on this page.  Farewell. Recovering data from a faulty disk When I plug in a removable 1TB USB disk in my laptop, the operations led keeps blinking for a while and then you can hear the servo mechanism resetting with a short "tack".  I'd like to recover the data.    I believe there might be some way to get the data through low level IOs.    What I believe is that the mounting process assumes the disk is OK and I should prevent this before using ddrescue or something similar.  Does anybody have a solution to this problem? Workaround for Android 4.4 not being able to write to SD cards? Yesterday I upgraded my Samsung Galaxy S4 to Android 4.4 KitKat and had the bad surprise that it cannot write to my SD card anymore... I know this problem is widely documented everywhere, but has any workaround been found for it yet? (Other than removing the card physically from the phone and opening it on my PC) Also, because of the KNOX flag I can't downgrade to 4.3...  (PS: Rooted or not, it makes no difference) Prove the set of all infinite binary sequences is uncountable by using Cantor's theorem. This is different then the other versions of the questions here. I'm not supposed to use the diagonal argument. I'm looking to write a proof based on Cantor's theorem, and power sets. Typesetting Chemical Formulas How do I alter a language item link? I am looking to modify the default output of Drupal 8 of links in a certain situation, the language switcher. Ideally I want to be able to do that in a twig template and not have to produce a  that overwwrites that whole link generation system and add a BIG if for the cases I need to overwrite.  I think the output layout should be controllable in the twig template similar to  (this answer outputs the same url for every languages)  I am using bootstrap as a base theme so i'd like to use the bootstrap markup for my links (btn btn-primary, dropdown)  Here is my code I am trying to make links--language-block.html.twig  {%- if links|length == 2 -%}     {# show only alternate language button #}     {%- for key, item in links -%}         {%- if not item.attributes['#options']['set_active_class'] -%} {# &lt;--- this is always true!? #}             &lt;a href="{{ item.link['#url'] }}" class="btn btn-primary"&gt;{{ item.link['#title'] }}&lt;/a&gt; {# #url is always the same what ever the language it is pointing to! #}         {%- endif -%}     {%- endfor -%} {%- elseif links|length &gt; 2  -%}     {# show selected language in button and other languages in drop down #}     &lt;button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown"&gt;{{ selectedLanguage }}&lt;span class="caret"&gt;&lt;/span&gt;&lt;/button&gt;     &lt;ul class="dropdown-menu"&gt;         {% for key, item in links %}             {%- if not item.attributes['#options']['set_active_class'] -%} {# &lt;--- this is always true!? #}             &lt;li&gt;&lt;a href="{{ item.link['#url'] }}"&gt;{{ item.link['#title'] }}&lt;/a&gt;&lt;/li&gt;             {% endif %}         {% endfor %}     &lt;/ul&gt; {%- endif -%}   Anyone has an idea on how to do this? I'm not a resident of USA. But I work on a cruise ship which required me to have C-1/D visa. I am leaving USA and traveling to Mexico but I will have a connecting flight somewhere in another US airport with 1-2 hours waiting for connecting flight to Mexico.   Do I need B1/B2 visa for that? Or my transit visa C-1/D will be enough as long as I am leaving USA? The help pages in R assume I know what those numbers mean, but I don't. I'm trying to really intuitively understand every number here. I will just post the output and comment on what I found out. There might (will) be mistakes, as I'll just write what I assume. Mainly I'd like to know what the t-value in the coefficients mean, and why they print the residual standard error.   Call: lm(formula = iris$Sepal.Width ~ iris$Petal.Width)  Residuals:      Min       1Q   Median       3Q      Max  -1.09907 -0.23626 -0.01064  0.23345  1.17532    This is a 5-point-summary of the residuals (their mean is always 0, right?). The numbers can be used (I'm guessing here) to quickly see if there are any big outliers. Also you can already see it here if the residuals are far from normally distributed (they should be normally distributed).  Coefficients:                  Estimate Std. Error t value Pr(&gt;|t|)     (Intercept)       3.30843    0.06210  53.278  &lt; 2e-16 *** iris$Petal.Width -0.20936    0.04374  -4.786 4.07e-06 *** --- Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1    Estimates $\hat{\beta_i}$, computed by least squares regression. Also, the standard error is $\sigma_{\beta_i}$. I'd like to know how this is calculated.  I have no idea where the t-value and the corresponding p-value come from. I know $\hat{\beta}$ should be normal distributed, but how is the t-value calculated?  Residual standard error: 0.407 on 148 degrees of freedom   $\sqrt{ \frac{1}{n-p} \epsilon^T\epsilon }$, I guess. But why do we calculate that, and what does it tell us?  Multiple R-squared: 0.134,  Adjusted R-squared: 0.1282    $ R^2 = \frac{s_\hat{y}^2}{s_y^2} $, which is $ \frac{\sum_{i=1}^n (\hat{y_i}-\bar{y})^2}{\sum_{i=1}^n (y_i-\bar{y})^2} $. The ratio is close to 1 if the points lie on a straight line, and 0 if they are random.  What is the adjusted R-squared?  F-statistic: 22.91 on 1 and 148 DF,  p-value: 4.073e-06    F and p for the whole model, not only for single $\beta_i$s as previous. The F value is $ \frac{s^2_{\hat{y}}}{\sum\epsilon_i} $. The bigger it grows, the more unlikely it is that the $\beta$'s do not have any effect at all. If $U_1$, $U_2,\ldots,U_n$ are proper subspaces of a vector space $V$ over a field $F$, and $|F|\gt n-1$, why is $V$ not equal to the union of the subspaces $U_1$, $U_2,\ldots,U_n$? Group Membership Test for Permutations As the topic is there exist a homeomorphism between either pair of $(0, 1),(0,1],[0,1]$ Is there a way to block a list of specific apps on macOS?  I have looked up solutions such as Cisdem, but there are some holes in the way it works that I don't like.   Unless you also block Activity Monitor, Terminal, and System Preferences, you can simply quit the Cisdem process or create a new user to get around it. You have to block Activity Monitor, Terminal, and System Preferences to make it work well.   I want to block an app from running or even being installed on my Mac. The app can be installed via the App Store and the web. Not sure how to go about this. Enabling Parental Controls won't work as Administrator privileges are needed.   The specific app I want to block is Apple Configurator.  Any ideas? I am using an APEX batch to process and insert large amounts of data. Essentially I would like it to process every row to catch any errors with the data and then rollback the entire batch if a single error is found. Is there any simple way to do this?  I have tried using a Save Point, but because they are not serialisable, it doesn't work across the entire batch.   Just to clarify, by error I mean an error that I have defined, error with validation, etc. Not an Exception thrown by the system. Adding 3 electron spins I've learned how to add two 1/2-spins, which you can do with C-G-coefficients. There are 4 states (one singlet, three triplet states). States are symmetric or antisymmetric and the quantum numbers needed are total spin and total z-component.  But how do you add three 1/2-spins? It should yield 8 different eigenstates. Which quantum numbers do you need to characterise the 8 states?  It is not as easy as using C-G-coefficients and the usual quantum numbers as for the total momentum the doubly degenerate 1/2 state and quadruple degenerate 3/2 state can describe only 6 or the 8 states. You will need an additional quantum number for the degeneracy.  So how do you get the result?  (I actually tried out myself with a large 8x8 matrix. The total spin 1/2 is each doubly degenerate. For the additional quantum number I chose the cyclic permutation. Spin 1/2 states are neither symmetric nor antisymmetric. But what is the usual way to derive this?)  EDIT: For reference I'm adding my results for up to 4 spins from some time ago:   If you recall the basics of quantum mechanics with matrices it is actually a straightforward matrix diagonalization and requires no specialized knowledge. However, you still need to find an additional operator which breaks degeneracy. I chose the cyclic permutation, which seems to do the job. Please refer to the below answer, since I haven't checked all details. Can we access class properties dynamically with Object class? Is it possible to access Apex class properties dynamically? While we can create Object's, and assign any other class to an Object, I'm not sure how I can access the properties of these Object's. Can anyone provide some documentation or references to code which would allow me to do this?   Example:  public class XYZ {    public string s1 { get; set; }    public string s2 { get; set; } }  XYZ testXyzObj = new XYZ(); Object obj = testXyzObj;  // Method does not exist or incorrect signature: [Object].get(String) String s1 = obj.get('s1'); Returning multiple values from a C++ function How do I quickly rename a MySQL database (change schema name)? The MySQL manual at  covers this.  Usually I just dump the database and reimport it with a new name. This is not an option for very big databases. Apparently RENAME {DATABASE | SCHEMA} db_name TO new_db_name; .  This needs to work with , which stores things very differently than . Are bicategories and lax 2-categories the same?