Case Statement - using BETWEEN. Ms Access to SQL Server

Question: Hi have made a query in ms access, as my DB is access, however i am creating reports in C# RDLC.
Im just going through making my dataadapters for the reports and i just can't get this CASE statement and BETWEEN to work!!
Now funnily it does actually produce the correct data.. but i get an error:

Error in list of function arguments: 'BETWEEN' not recognized.
  Unable to parse query text.

SELECT        [CountAge].AgeGroup, COUNT(*) AS CountOfAgeGroup
FROM
(SELECT Switch([Age] BETWEEN 0 AND 17, '0-17',
 [Age] BETWEEN 18 AND 30, '18-30',
[Age] BETWEEN 30 AND 45, '30-45',
[Age] BETWEEN 45 AND 60, '45-60',
[Age] > 60, 'Over 60') AS AgeGroup

FROM
(SELECT tblcustomers.firstname, tblcustomers.lastname, Year(Now()) -
Year([DOB])  AS Age FROM TblCustomers )) as CountAge

GROUP BY [CountAge].AgeGroup

I've tried a number of things but i cant seem to get it right! Any advice would be great.
It also has an error with Year(date) and changes to year but it works when i change it back.
Update - Clarification (because I'm stupidly vague - sorry)

So just clarifying my problem.
My DB is in access - not sql server - that was a bad tag of mine.
I have created the query inside Access and it works, exactly as it is above.
HOWEVER I'm trying to create it as a datatable for a report in Visual Studio as an RDLC report.
In Dataset Designer I am adding a datatable usign the above query however it doesnt work due to the aforementioned error (BETWEEN).
I have since tried Gustav's suggestion in replacing BETWEEN with > and >= etc however i now get this error;

Error in list of function arguments: '<' not recognized.
  Unable to parse query text.

Update 2: THIS QUERY WORKS.. as in it DOES create results that are correct, however because of this Unable to Parse Query Error.. i cant actually SAVE it.
Ideas?
Comment: Did you know that CASE is an expression, and not a statement? I did, because people love to tell people that call it a case statement...and now I am one of them.
Comment: So what have you tried? What is the connection string?
Comment: So are you using sql server or not? You have it tagged and mentioned in your question title but the explanation of the question makes it sound like everything is in Access and nothing at all to do with sql server.
Comment: I removed the `sql-server` tag, this is a tag you should use if you are using Microsoft Sql Server. Everything in your question is specific to MS Access. If there is something relating to Sql Server you can re-tag it but update your question with the specifics for Sql Server.
Comment: Yeh sorry about the sqlserver tag, i must have typed sql and selected by server by access.  I was referring to the SQL text for msaccess! Sorry!
Comment: @Leonidas199x, respectfully, it sounds like you know the answer and obviously I'm doing this wrong, but I still can't figure it out. Would you mind expanding on this?  Or are you literally just having a go at the title?
Comment: Well I've spent 2 hours trying to work this out... and just can't get it so if anyone does have ideas I'm happy to try.
Comment: @GlennAngel afraid not, I came when you had tagged it as SQL server, no idea about access, sorry.
Answer: The Switch function doesn't take SQL syntax. So:
Switch([Age] <= 17, '0-17',
    [Age] <= 30, '18-30',
    [Age] <= 45, '30-45',
    [Age] <= 60, '45-60',
    [Age] > 60, 'Over 60')

Answer:     Select case when [Age] between 0 and 17 then '0-17'
           when [Age] between 18 and 30 then '18-30'
           when [Age] between 31 and 45 then '31-30'
           when [Age] between 46 and 60 then '46-60'
           when [Age] >60 then '>60'
            else 'Invalid Age' end
    from (SELECT tblcustomers.firstname, tblcustomers.lastname, Year(Now())
    Year([DOB])  AS Age FROM TblCustomers) as CountAge

Else Case is for when wrong data entered in Database like future date.
User defined function is most suitable solution in current scenario as per usability and maintainability.


Ubuntu 23.04 logs me out arbitrarily while going to sleep mode

Question: I upgraded my desktop to Ubuntu 23.04 a few days ago. Since then I've noticed that sometimes i get logged out when the system goes into sleep mode after 15 minutes of inactivity.
I searched askubuntu and elsewhere for solutions but didn't find any.
Any suggestions?
Thank you in advance.
Answer: Open Settings -> Privacy -> Screen and disable Automatic Screen Lock.

Read more at https://help.ubuntu.com/stable/ubuntu-help/privacy-screen-lock.html
Comment: this actually worked for me after 23.10 upgrade, why would "Automatic Screen Lock" mean log the user out? (closing all applications), that doc explicitly says otherwise:

"_When your screen is locked, your applications and system processes will continue to run, but you will need to enter your password to begin using them again._"
Comment: Thanks. But, this doesn't answer my question. I know how to put it n sleep mode; that is not the problem. When my desktop goes into sleep mode, sometimes i get logged out in 23.04; this wasn't the case until now.


The following page url can't be found

Question: I'm working on MVC5 project. I've an index page which is auto generated.
when the user goes the index page and decide to delete a record that its id is 5 for example, it goes to the following url: /XYZ/Delete/5
When the user confirm the deletion, he is redirected to index page: /Roles_ModelFields
If the user clicked the back button he will be redirected to:/XYZ/Delete/5, which gives an error: The following page url can't be found: /XYZ/Delete/5
How can I redirect him to the index page instead of the delete page with the deleted record id.
Regards.
Comment: `"When the user complete deleting a record, it go back to the index page. [...] How can I redirect him to the index page?"` - It sounds like you're already doing that?  Can you clarify what the problem is?  Are you already successfully redirecting the user to the index or not?
Comment: I mean that when the user go the index page, which is auto generated, and decided to delete a record that its id is 5 for example, it goes to the following url: /XYZ/Delete/1
When the user confirm the deletion, he is redirected to index page: /Roles_ModelFields
If the user clicked the back button he will be redirected to:/Roles_ModelFields, which gives an error: The following page url can't be found: /XYZ/Delete/5
Comment: So you mean the link from the index page to the `Delete` action is using the wrong ID value?  (1 instead of 5 in the example you just described.)  That's not clear at all from the question.  Please clarify exactly what problem you're facing and what you're asking.  **Edit:** The more you edit that previous comment, the less clear the problem becomes.  So... The user is pressing the back button and re-sending a request?  If the record doesn't exist, I'd expect a 404 error.  Is your controller code returning a 404?  Maybe if you show your code that might clarify the problem?
Answer: Okay, well following your example.. if the user has already deleted the record, then redirected back to the Index page, and then the user decided to hit the back button then they should be presented with the error "The following page url can't be found".  That page cannot be found because that page is specifically for the record that you've deleted.
This is most likely not the best way to handle this situation, but in your Delete ActionResult.. I'm assuming you left the generic code in the action, so it looks like this:
<code>// GET: ControllerName/Delete/5
[ValidateInput(false)]
public ActionResult Delete(int? id)
{
    if (id == null)
    {
        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
    }

    ...

    if(!db.TableName.Any(x => x.Id == id.Value)) // if there are zero record's Ids that match the id passed then do this
    {
        return RedirectToAction("Index");
    }
</code>
Let me know if this helps.

The following page url can't be found


Thymeleaf - include template from the same directory (relative path)

Question: I am currently including fragments in Thymeleaf templates by specifying full path to the fragment directory like this:

The problem is paths are sometimes long due to the fact the application has many views separated in folders.
We are using following statement to use the current directory:

But this become deprecated in 3.0 version. Is there any way to use the current path of the currently processed template in included fragments.
I know I can use the template prefix, but this is not the solution as we're only prefixing by the root template directory. Also I do not want to put fragments to the same file as the template.
Answer: I attempted something similar using Thymleaf 3.0.11, and this looks like it works -


Switch between array entries

Question: I am writing an application which interfaces with an external API. We have five API clients (in order to process more requests - which is allowed under the API T&C) which are stored in an array. We have another array of objects which we perform an action on using foreach.
For example:
$clients = array(
    array(
        "key" => "somekey",
        "secret" => "somesecret"
    ),
    array(
        "key" => "somekey",
        "secret" => "somesecret"
    ),
    array(
        "key" => "somekey",
        "secret" => "somesecret"
    )
);

Next we have an array of objects to be processed:
$objects = array(
    array(
        "info" => "someinfo",
        "url" => "someurl",
        "id" => 1234,
        "more" => "more"
    ),
    array(
        "info" => "someinfo",
        "url" => "someurl",
        "id" => 1234,
        "more" => "more"
    ),
    array(
        "info" => "someinfo",
        "url" => "someurl",
        "id" => 1234,
        "more" => "more"
    )
);

So to process them with one API key we would do something like:
foreach($objects as $object){
     $class->setAPIKey($clients[0]);
     $result = $class->process($object);
}

In order to process them with multiple keys we have tried this:
$key = 0;
foreach($objects as $object){
    $class->setAPIKey($clients[$key]);
    $result = $class->process($object);
    if($key + 1 == sizeof($clients)){
        $key = 0;
    } else {
        $key++;
    }
}

This works, but seems a little inefficient. Is there a quicker/smaller way to do the same thing?
Answer: You can try it like this:
foreach($objects as $key => $object){
     $class->setAPIKey($clients[$key]);
     $result = $class->process($object);
}

Switch between array entries


Two commuting isometries $A_1$ and $A_2$ such that $A_1A_1^*+A_2A_2^*=I$.

Question: Let $E$ be a complex Hilbert space and $\mathcal{L}(E)$ be the algebra of all operators on $E$.
Recall that an operator $T\in \mathcal{L}(E)$ is said to be isometry if $T^*T=I$.

I want to find two commuting isometries $A_1$ and $A_2$ such that
  $A_1A_1^*+A_2A_2^*=I$.

I ask this question because I want to show that the equality
$$\left\|\displaystyle\sum_{k=1}^dA_k^*A_k \right\|=\left\|\displaystyle\sum_{k=1}^dA_kA_k^* \right\|,$$
need not hold in general even if the operators $A_k$ are commuting.
Answer: Hopefully I didn't do any mistake.
This is not possible.
Indeed, if $A_1A_1^*+A_2A_2^*=I$, multiplying on the LHS by $A_1^*$ you get
$$A_1^*A_1A_1^*+A_1^*A_2A_2^*=A_1^* \\
A_1^*+A_1^*A_2A_2^*=A_1^* \\
A_1^*A_2A_2^*=0 \\
$$
Multiply on the RHA by $A_2$ to get
$$A_1^*A_2=0 \\
A_1^*A_2A_1 =0$$
Now, since $A_1,A_2$ commute you get
$$A_1^*A_1A_2=0 \\
A_2=0$$
Comment: So, it is possible that the equality
$$\left\|\displaystyle\sum_{k=1}^dA_k^*A_k \right\|=\left\|\displaystyle\sum_{k=1}^dA_kA_k^* \right\|,$$ holds for commuting operators?
Comment: @Student No, the above only shows that it is not possible to get $$A_1A_1^*+A_2A_2^*=I$$ But maybe you can get a different operator of norm one...And I am not sure if the same idea would show that it is not possible for 3 operators to get $A_1A_1^*+A_2A_2^*+A_3A_3^*=I$.
Comment: Thank you. I hope to give me an example if you know.


Error with predict and glm.predict in R

Question: The Problem
I trained a linear regression in R to predict this.target from city, variables in data frame data. This trainig is done on a subset of the data, which is specified by train.index.
model = glm('data[, this.target] ~ data$city', data = data, subset = train.index)

I am trying to test this model on the held out data, which is specified by test.index.
predictions = predict(model, data[test.index, ])

For whatever reason, this second step creates an error and a warning.
Error in model.frame.default(Terms, newdata, na.action = na.action, xlev =
object$xlevels) : invalid type (NULL) for variable 'data$city' In addition:
Warning message: 'newdata' had 22313 rows but variables found have 0 rows

My Analysis
data$city is a factor of 4 levels, but it seems like R reads it as an "invalid type (NULL)" even though none of the observations in this variable are NULL.
Moreover, it seems like R reads the rows but not the columns of the training set correctly. dim(data[test.index, ]) yields a vector with 22313 and 12.
Comment: Your formula in `glm` is totally wrong. Your formulas should never include subsetting operations like `[` or `$`. Just the variables.
Answer: Thanks to joran's comment, I was able to find the solution to my problem. joran pointed out that formulas should not include subsetting operations.
As it turns out, this subsetting was allowing model fitting to proceed as normal, but it caused model predicting to balk with the error and warning described above. By removing subsetting from my formula definition, both model fitting and predicting ran without problem.
Comment: i have the same problem, can you tell me how to solve subsetting operations problem?
Comment: In the above example, instead of `model = glm('data[, this.target] ~ data$city', data = data, subset = train.index)` I did `model = glm('target ~ city', data = data, subset = train.index)`.
Answer: This solution is for this error but not for the main question cause it is difficult to follow .
The solution is making a variable let's say x; x=as.data.frame(testset) and pass it to predict as
classifier = glm(formula = Survived ~ .,
                 family = binomial,
                 data = training_set)
x = as.data.frame(test_set)
prob_pred = predict(classifier, type = 'response', newdata =x)
y_pred = ifelse(prob_pred > 0.5, 1, 0)

Predicting the Test set results
In glm or rpart (library for classification based on decision tree), the test set should be data frame and sometimes the pre-processing steps change your data type (the data you want to predict) should be data frame, if it is not, the
error

Error in model.frame.default(Terms, newdata, na.action = na.action,
  xlev = object$xlevels): 'data' must be a data.frame, not a matrix
  or an array

will appear.

Error with predict and glm.predict in R


How do I get the water pressure back?

Question: I have what seems to be a strange, but hopefully easily solved problem. I have a Rheem Warrior series electric hot water heater in my mobile home.
My husband is installing a new shower and we could not find the shut off on the heater, so we had to shut the main valve off under our home.
Days later, we have plenty of hot water, but the cold is, lets say at half pressure.
We have shut the main off and on a couple times, hoping that would do the trick, but no luck! I'm going to try cutting the power to the heater next to see what that does.
I feel like this should have an easy solution and really don't want to call a plumber for something so silly! Any ideas would be appreciated!
Comment: Is the low pressure everywhere, or just at one sink?
Comment: The low pressure is just with the cold water in the washing machine and one bathroom.
Answer: Closing the main valve could have dislodged some rust / scale that is now stuck in the cold water valve. Since your hot is running ok turn the water off again and pull the valve apart.
You may have to slightly turn the water back on to fully flush the line out. Reassemble and see if you have full flow again.
Did you purge the air using the cold valves? this is when the gunk gets pushed into the valves.

How do I get the water pressure back?


Display full string in F# interactive window

Question: If I type the following into an fsx in Visual Studio Code
let longString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

and run F# interactive on it by highlighting and pressing Alt+Enter, the output in the interactive window is
- let longString = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepte- ur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";;
val longString : string =
  "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed "+[384 chars]

or as screenshot:

How can I tell the F# interactive window to display the full string? Is there a shortcut or else?
I am aware of this post, but as fas as I know this is different here because a string is not lazily-evaluated.
Answer: printfn  will print it completely:
printfn "%s" longString

Alternatively, you can change the fsi object properties, for instance:
fsi.PrintWidth <- 1000;;

Also, you can use AddPrinter:
fsi.AddPrinter (fun (s:string) -> s)

Here is the documentation: https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/fsharp-interactive-options#f-interactive-structured-printing
Comment: Yes I know, but I would love to be able to achieve it without changing my code. For example, a change in the config is what I am looking for.
Comment: Ok, I expanded my answer.
Comment: Works as expected. Thank you!
Comment: the last docs link is broken
Comment: @user1623521 thanks for pointing it out. Link fixed.
Answer: If it is just for testing/debugging:
If you are in VSC you can run your script interactively as you mentioned. You can take advantage of that by using the interactive terminal and typing (in said interactive terminal)
longString;;

//output
val it : string =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

This will then show the whole string and is in most cases sufficient (since you do not want to clutter your script with unnecessary outputs anyway).


Fastening stone stair treads to a CMU base in a removable manner

Question: I'm designing a very, very low set of landscape stairs (really more like a wide stoop) to transition two areas of my yard. My plan is to pour a concrete base slab, build a core with CMUs on top of that, and then clad everything in natural limestone. I'd like to integrate low-voltage lighting under the tread noses.
My plan so far is to cut a network of grooves into the CMU core to run the low-voltage wires from the fixtures back to the transformer. The treads would then go on top, concealing the fixtures and wires. However if I mortar the treads in place, it will be very difficult to replace the fixtures when they inevitably fail. Could I get away with some kind of less permanent fastening, like a masonry caulk that could be cut away when the treads need to be removed? The stone treads are quite heavy, and are mostly held in place by their weight. I think I would only need something to keep them from rocking/budging.
Comment: I would either run the wiring in the ground (which I believe you can safely get away with for LV wiring), or hold it up under the nose of the steps with some silicone sealant as an adhesive. Just a spot of silicone every 12" or so with the wire held tight. Give each spot a minute or two to set, or, even better, run everything held up up by some tape, then go back and silicone in place. Give it 48 hours and peel the tape off.
Answer: Stairs need to be EXTRA safe, because a loose stair is potentially deadly. It's not something you want to mess around with, heavy or not. Could you drill and bolt them toward the back of each tread, running the bolts down into the concrete below the CMU blocks? You could countersink the bolt heads  on the tread stone and fill them with sand or something to hide them, then vacuum out the sand if you ever need to remove the bolts to lift the tread. If you do that, use stainless steel hardware all around.


How do I test "Parameters Passed In Final Call" using RhinoMocks?

Question: What's the best way in Rhino Mocks to test that a particular parameter is passed on the FINAL call to a method? Eg mockview.SetSomething(myObj) might be called any number of times by mockview.Init, but I want to test that the last time it's called  as mockview.SetSomething(inParticular).
Now I know I can use GetArgumentsForCallsMadeOn with this, but my problem is that it doesn't work if I've subsequently changed the parameter holding variable. e.g
public interface IView
{
    void SetSomething(ViewData data);
}

public class ViewData
{
    public int Age { get; set; }
    public string Name { get; set; }

    public ViewData Person(int age, string name)
    {
        Age = age;
        Name = name;
        return (this);
    }
}

public class WorkingPresenter
{
    public void Init(IView view)
    {
        var data = new ViewData {Age = 1, Name = "One"};
        view.SetSomething(data);
        data = new ViewData {Age = 2, Name = "Two"};
        view.SetSomething(data);
        data = new ViewData {Age = 3, Name = "Three"};
    }
}

public class NotWorkingPresenter
{
    private ViewData _data;

    public void Init(IView view)
    {
        _data = new ViewData();
        view.SetSomething(_data.Person(1, "One"));
        view.SetSomething(_data.Person(2, "Two"));
        _data.Person(3, "Three");

    }
}

then my tests are ...
    [Test]
    public void GetDataOfLastCall()
    {
        ViewData dummydata=null;
        var view = MockRepository.GenerateStub<IView>();

        //Approach 1 : This works
        var workingPresenter = new WorkingPresenter();
        workingPresenter.Init(view);
        var lastCall = view.GetArgumentsForCallsMadeOn(v => v.SetSomething(dummydata)).Count - 1;
        var lastParams = view.GetArgumentsForCallsMadeOn(v => v.SetSomething(dummydata))[lastCall];
        var lastData = (ViewData)lastParams[0];

        //Approach 2: This doesn't
        var notWorkingPresenter = new NotWorkingPresenter();
        notWorkingPresenter.Init(view);
        lastCall = view.GetArgumentsForCallsMadeOn(v => v.SetSomething(dummydata)).Count - 1;
        lastParams = view.GetArgumentsForCallsMadeOn(v => v.SetSomething(dummydata))[lastCall];
        lastData = (ViewData)lastParams[0];

What I want is to verify that the last call to SetSomething was with {name="Two", age=2}. Now workingPresenter does this but wouldn't you expect notWorkingPresenter to do so too?
Answer: There must be something else going on in your code (outside of the mocking).  I just threw together a few items:
public interface IView
{
    void SetSomething(ViewData data);
}

public class ViewData
{
    public int Age { get; set; }
    public string Name { get; set; }
}

And I tested it with:
[TestMethod]
public void GetDataOfLastCall()
{
    var view = MockRepository.GenerateStub<IView>();

    var data = new ViewData {Age = 1, Name = "One"};
    view.SetSomething(data);
    data = new ViewData { Age = 2, Name = "Two" };
    view.SetSomething(data);
    data = new ViewData { Age = 3, Name = "Three" };

    var lastCall = view.GetArgumentsForCallsMadeOn(v => v.SetSomething(data)).Count - 1;
    var lastParams = view.GetArgumentsForCallsMadeOn(v => v.SetSomething(data))[lastCall];
    var lastData = (ViewData) lastParams[0];
}

And I got the values of 2 and "Two" inside the ViewData.  It appears Rhino.Mocks supports what you want to do.  Could you create a failing test case that shows the issue identified in your original question (where you got a reference to the most recent information)?
Comment: Hi Patrick.Yes sorry: in trying to simplify the code I simplified out the problem! The below demonstrates what I think the issue is. To be fair I can see better ways of writing the code now but I'd still intuitively expect NotWorkingPresenter to work?


Broadcast the change to system after set system environment variable

Question: I am working on adding system environment variables to Windows via Python.
I tried via Python library. It was able to add system environment variables; however, program doesn't recognize newly added system environment variables.
I ran as admin Python code and restart PC after added system environment variables.
I thought I didn't broadcast newly added system  environment variables. Therefore, I used "SendMessage" to broadcast newly added variables to system.
However, it didn't really work.
I used "Edit the environment variables" on windows to add system variables manually. It was working and program recognized new system  environment variable. However, code below does add variables on system environment variables part. But program doesn't recognize for some reasons.
I am not sure what I miss. Anybody knows what I missed?
Thanks!
<code>def set_system_env(name, value):
    path = r'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
    hklm = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
    try:
        key = OpenKey(hklm, path, 0, KEY_READ | KEY_WRITE)
    except:
        self.log("Error")
    SetValueEx(key, name, 0, REG_EXPAND_SZ, value)
    CloseKey(key)
    broadcast_env_change()

def broadcast_env_change():
    SendMessage(win32con.HWND_BROADCAST, win32con.WM_SETTINGCHANGE, 0, 'Environment')
def add_sys_val()
    set_system_env("Test_PATH" , "C:\System_Folder")
</code>
Answer: The broadcast message only notifies Windows applications that are listening for the message, such as the Desktop process.  The environment is normally inherited from the parent process and doesn't change unless the current process changes it, such as listening for the broadcast message and updating its own environment.
Comment: Is there any ways to  system environment variables via python? I checked similar questions in stack overflow (with other language) What they doing is very similar to code that i write..
Comment: @NBB You don't have a [mcve] for me to verify.  Make sure all the code is present, such as imports.  Did you check that registry location to make sure it was updated before rebooting?  Your question was about broadcasting, which is all I addressed.  Normally you will need to reboot or at least restart your program from the desktop (which does receive broadcast messages) before seeing the change.
Comment: Thanks for your answer. I am not sure how to check make sure that registry location. How I can check it and what do i need to do with registry location?  I search API to added system variable. When my code doesn't work, i searched that i need to broadcast to system that i added new variable on system......
Comment: Use the `regedit` tool and view the `SYSTEM\CurrentControlSet\Control\Session Manager\Environment` location.


List of Contacts from Contacts App in SwiftUI

Question: Hi I am trying to build an interface that lists all the contacts just like the Contacts and Phone app with the same UI. What I have tried so far is below. Basically I tried to implement CNContactPickerViewController from ContactsUI using the UIViewControllerRepresentable. However what I am getting is a blank white page.
struct ContactsViewController: UIViewControllerRepresentable {

    func makeUIViewController(context: UIViewControllerRepresentableContext<ContactsViewController>) -> CNContactPickerViewController {
        let controller = CNContactPickerViewController()
        controller.delegate = context.coordinator
        controller.displayedPropertyKeys = [CNContactGivenNameKey]
        return controller
    }

    func updateUIViewController(_ uiViewController: CNContactPickerViewController, context: UIViewControllerRepresentableContext<ContactsViewController>) {
        print("updating")
    }

    func makeCoordinator() -> Coordinator {
        return Coordinator(self)
    }

    class Coordinator: NSObject, CNContactPickerDelegate {
        var parent: ContactsViewController

        init(_ contactsViewController: ContactsViewController) {
            self.parent = contactsViewController
        }

    }
}

And the SwiftUI file;
struct ContactsView: View {
    var body: some View {
        ContactsViewController()
    }
}

A reminder is I am calling the ContactsView inside of TabView in some other SwiftUI file.  So I want show contacts in a SwiftUI View that is part of TabView. Any help would be really appreciated.
Answer: There are two solutions here: https://stackoverflow.com/a/57621666/8818408
(1) works but flashes a view before showing the list of contacts.  Not a good experience for the user.
(2) sort of works.  It also flashes a view before showing the list of contacts.  It shows with unexpected transparency and unexpected colors along leading, trailing, and bottom edges.  These may be possible to sort out.
I'm just getting started trying to resolve issues with #2 above.  If anyone can offer a solution that works completely, that would be great.


How to get 468 face landmarks points using ARCore - IOS

Question: I am using ARCore-IOS to create AR IOS application.
https://github.com/google-ar/arcore-ios-sdk/tree/v1.25.0
I am able to get nose, left-forehead and right-forehead region point as well face rotation from this module.
But I need all 468 face landmark points, which are mentioned in the documentation. But there is no specific method or class which returns 468 points.
So, how can we get 468 face landmarks points in IOS native or flutter, using or without using ARCore.
Answer: The GARAugmentedFace class contains a mesh, which contains the 3D vertex locations. For example, in the SCNSceneRendererDelegate method:
if let face = frame.face {
print(face.mesh.vertices[467])
}

https://developers.google.com/ar/reference/ios/interface_g_a_r_augmented_face_mesh
All of the vertex positions are in their default positions, i.e. in the canonical_face_mesh. If you want the vertex positions from the individual face in the camera, you need to get that info from the scenekit geometry, which is conveniently stored in the faceTextureNode. It is somewhat less convenient to extract the data.
faceTextureNode.geometry = faceMeshConverter.geometryFromFace(face)
faceVertices = vertexPositionFromSCNGeometry(geometry: faceTextureNode.geometry!)

private func vertexPositionFromSCNGeometry(geometry: SCNGeometry) -> [SCNVector3] {
  let geometrySources = geometry.sources(for: SCNGeometrySource.Semantic.vertex)
  var geometryVertices = [SCNVector3()]
  if let geometrySource = geometrySource.first{
    let stride = geometrySource.dataStride
    ...
      let vector = SCNVector3Make(buffer[0], buffer[1], buffer[2])
      return vector
      })
  geometryVertices = vertices
  }
return geometryVertices
}

The rest of the function can be filled in from the detailed answer here:
https://stackoverflow.com/a/66748865/14437826
The vertex positions are relative to the face center transform. If you want the raw locations, you would have to calculate using the center transform.


Revising questions

Question: I just wanted to follow the discussion in the comments on this question:
How can I find open access journals for cognitive science research?
I initially submitted a very vague question which was helpfully edited by others to make it clearer (thanks!).
However in the comments that took place someone actually suggested an even more specific and helpful question which is much more along the lines of what I'd really like to know ("are there any open access cognitive science journals with an impact factor >1 or any websites showing impact factors for open access journals in this area").
Id would like to ask that exact question. It was pointed out that its not a good idea to edit the existing question as this would invalidate the existing answers.
Should I start an entirely new question - if I do should I make reference to the original question?
Thanks for any advice - this has been a valuable lesson in specificity and clearly thinking about what I want to ask.
Comment: I don't feel that would be a better question. As Ben stated in a comment: _"@Jeff perhaps you're right there are few "reputable" journals out there, but turning this into a list of subjectively good journals fitting a criteria makes it even more subjective and less concrete question than even the initial question."_.
Comment: @StevenJeuris The normal way to find impact factors is through Thompson Reuters citation reports (http://bit.ly/eR25Im).
Most instituations provide access to this database. This allows you to search for particular journals and provides a range of scores for each entry. As far as know however, it does not show whether or not a journal is open access. The interesting thing to find out, as far as im concerned, is whether any cog.sci journals have a impact score >1. A list of impact factors for this field would just be a way of determing that.
Im not sure why you'd like this asked as 2 questions?
Comment: @StevenJeuris the point of using impact factor is that it's *not* subjective.
Comment: @Jeff: So how do you calculate this impact factor?
Comment: Oh, I see now that's part of the question: _"or any websites showing impact factors for open access journals in this area"_. Perhaps that's a good first question to ask. Please don't ask them together.
Comment: Thanks for that info. I'd ask as two questions because the list question is bound to get closed because there is a risk it doesn't follow the [FAQ](http://cogsci.stackexchange.com/faq#dontask), unless many effort goes into it. If you can at least base the list question on a properly defined premise (in which the second question could help) I believe you'll get nearer to the goal you're trying to achieve. Try to plug all the holes which could lead the question to being interpreted as not following the faq.
Comment: _"The interesting thing to find out, as far as im concerned, is whether any cog.sci journals have a impact score >1.  A list of impact factors for this field would just be a way of determing that."_ .. No, finding any Cog.Sci journal with an impact factor >1 would determine that, and any journal with an impact factor >1 would be a valid answer, regardless of how high the impact factor is.
Comment: @StevenJeuris which part of the FAQ or guidelines do you think this question is at risk of violating?
Comment: @mob 1. _"every answer is equally valid: "What's your favorite ______?"_, 2. _"your answer is provided along with the question, and you expect more answers: "I use ______ for ______, what do you use?"_ Just keep those in mind. There _are_ ways of making them work. ;p I'm just warning you it's not easy.
Comment: .. oh and: _"Your questions should be reasonably scoped. If you can imagine an entire book that answers your question, you're asking too much."_ But I can't predict the scope of your question. Stating in your question why you find it to be reasonably scoped can do wonders as well. Better not make that an hypothesis either.
Answer: To answer your general question, yes, ask a different question. The spirit of the question should always remain true to the original post (I hope our edits did that), if you need to ask something more specific or something that no longer matches answers given to that post, break your new query into a new question.
Comment: Thanks for the general clarification Ben.

For the new specific question, I'm not sure why are you are saying what I am proposing is subjective. Impact factor is a completely objective metric.
http://en.wikipedia.org/wiki/Impact_factor
Comment: @mob my bad then; I wasn't aware of that. I withdrew that point

Revising questions


Logistic differential equation

Question: The logistic differential equation $$y'=y(b-ay) \, \textrm{with}\,  a\neq 0, b\neq 0$$ has the non-trivial solution $$y(t) = \frac{\frac{b}{a}}{1+e^{-bt}}, \quad (1)$$ where $c$ is a constant.
My questions are:
1) Why are we assuming that both $a$ and $b$ are nonzero.
2) Is $y(t)=0$ also a solution to the differential equation.
3) I want to show that $(1)$ is a solution to the differential equation.
My idea is that I want to find $y'$ and then calculate $y(b-ay)$ where I insert (1). Then show that they are equal. When calculation $y'$ I dont want to use differentiation rule of  quotient, I want to use rule of composition function. How can I do that?
Comment: There is no reason to assume that both $a$ and $b$ are non-zero.
Answer: For question (1): If $a=0$ the equation is $y'=by$, a simple exponential function, and if $b=0$ the equation is $y'=-ay^2$, which I don't know offhand how to solve, but probably doesn't give a logistic function.
For question (2): Yes, $y=0$ is a solution; so is $y=b/a$. These are on a graph the lower and upper bounds of the logistic curves in between, and are asymptotes, for the typical initial values used.
For question (3) $y(t)$ doesn't look like a composition of functions to me, except in some trivial ways which likely won't help in taking the derivative, and maybe the quotient rule has to be dragged in at some point.
Comment: Solving $y'=-ay^2$ is not hard, as the equation is separable. The solution satisfies $-\int y^{-2}\,dy=a\int dt=a(t-t_0)$ for some $t_0$, so that $y=1/(a(t_0-t))$. (Note that the solution blows up at $t=t_0$.)
Comment: Is it that if either  a=0 or b=0 then the equation is not logistic?
Comment: Harald: yes, I should have noticed it's separable for $y'=-ay^2$. That's not logistic, since a look at the line field shows all solutions go off to infinity or minus infinity. As you note from the explicit solution, this happens in finite time.

Logistic differential equation


Business mathematics

Question: The demand function for a good is given as $$P = 50 - 2Q$$

Write down expressions for the TR and MR functions.
Find and classify the type of the point price elasticity at price $P = 10$
Calculate the output at which TR is a maximum, and use
$\hspace{0.4cm}$ second order
conditions to confirm that it is maximum.
Confirm that marginal revenue is zero at maximum point.
Comment: Maybe TR, MR are common abbreviations in business mathematics (I've no idea), but you should show some self work in this, anyway.
Comment: @callculus Oh, I'm not interested at all...
Comment: @DonAntonio A quick [search](https://www.google.com/search?q=TR%2C+MR+demand&ie=utf-8&oe=utf-8&client=firefox-b-ab) helps.
Comment: I think it has a print error  for derivative dTR/dQ
Answer: $ TR = P×Q \Rightarrow TR=(50−2Q)Q=50Q-2Q^2$

The marginal revenue function is the first derivative of the total revenue function

$MR=50-4Q$

When the derivative of TR=0 in that point it reachs its maximum value($Q=\frac{50}{4}$)

The Price elasticity($e_p=\frac{P_o}{Q_o}*Q(P_o)'$) $e_p=\frac{10}{20}*0.5=1/4=0.25$ which means  Relatively Inelastic

Business mathematics


Git: Testing commits without pushing

Question: We have two separate teams that are working on the same product: design and verification.
Designer adds features, run a simple test to check that design compiles and a very basic test is running and need to pass it to the verification team.
My question and concern is: how designer can easily and safely pass commits without pushing them to the server? Otherwise it could be a very long commits history which I want to avoid.
If designer can work with verification team without pushing changes to the server all those commits can be squashed to a single one and then pushed.
Comment: Look at branches. Work on the same branch between both teams, then squash when merging to master.
Comment: There's a trivially simple rule: to *test* a commit you must *have* that commit. Who is doing the testing? He (or she or it) must have the commit. Hence there must be some communications channel between developer and tester. That does not have to be "the" server, anyone can be a server, there is only a "the" server if you say "that server there, that is *the* server". (And: branch names do not matter, only *commits* matter. For push/pull you do need to attach *some* name, at least temporarily, of course.)
Comment: I want to eliminate history pollution by an iteration between design and QA.
Answer:
without pushing them to the server

With Git, you don't have to limit yourself to "the" (one) server.
You can add as a remote another server, dedicated for QA testing, where designer can push.
A post-receive hook can then:

pass some test
reject (reset) the commit which has just been pushed if those tests fail
or push that same commit to the actual server if those tests pass.

In other words, the QA server acts as a gateway between the designer commits and the actual server.
Another approach is to push those commits to the (one) server, but in a dedicated branch, merge by the verification team to master of the tests pass.
Comment: But all these commits still be visible in the history. And I won't be able to squash them.
Comment: @Michael the post-receive hook can squash them for you (if you want: that hook is a script: you can make it do whatever you need) on a dedicated branch (if the tests pass) and push that for you.
Answer: You absolutely don't have to restrict commits using git. That is not the purpose of it. One of the best practices says Commit Early And Often. If you want to have some order in your repository, you must use branches.
In your case, you can have a branch for the design of a feature, and when that feature is finished, the design team can run tests an close the branch. Doing that, the verification team will see that a feature as being merged, and then will verify it.
There is a really good extension of git that makes this work easier called git-flow. Maybe that is what you are really looking for.
Comment: I agree. But I don't want the history have a lot of iterations between design and QA.
Answer: If there is a legitimate reason to want to pass commits around without pushing to a central server, you can look into git-bundle, which allows you to package up one or more commits and ship them directly as a single file.
Edit: If the OP really wants to avoid both rewriting history (even on a separate branch) and having extra commits, one possible solution (not generally recommended) is to not create commits at all, and simply pass patch files around.

The developer makes whatever change they want and then runs git diff > MyChange.patch. He emails this to QA.
QA checks out the same commit as the developer, and runs patch -p1 < MyChange.patch. The QA now has the same state as the developer, without any git commits being created.
Comment: Isn't it the same as push/pull but without server? If I squash commits later the QA will not be able to use their workspace anymore.
Comment: @Michael, Just to be clear, are you aware that if you have a shared branch with only the QA such as `test`, they can always do a `git reset --hard origin/test` to make their history match yours after you squash? They will be able to use their workspace again after such a command.

Git: Testing commits without pushing


$\text{Show that }\log(1+x) \le x , \quad \forall x \in [0,\infty)$

Question: Show that
$$\log(1+x) \le x , \quad \forall x \in [0,\infty)$$

So I have come up with two ways to solve this question and I was wondering which way is more accurate?
Proof
$\boldsymbol{\text{Way 1}} \\ \text{Let } f(x) = \log(1+x) -x \le 0 \\ \text{Notice f(0) = 0 } \\ f'(x) \le 0 \quad x \in [0,\infty) \\ f(x) \text{ is decreasing } \\ \text{ Now } f'(x) = \frac{-x}{1+x}\le 0 \text{ True.} $
$\boldsymbol{\text{Way 2}}\\ \text{Let} f(x) = x- \log(1+x) \ge 0 \\ f(0) =0 \\ \text{We only NTS } \\ f'(x) \ge 0 \\ \text{f(x) is increasing}  \\ f'(x) =1-\frac{1}{1+x} = \frac{x}{1+x} \ge 0 \text{ True } $
Comment: The look pretty equivalent to me. However, instead of writing what looks like bad poetry, you should include either words like "from which it follows" or "because" etc., or implication arrows ($\Rightarrow$). Otherwise, there is no fully valid argument. In particular, you'll notice that the last three to four lines each are sort of the wrong way around.
Comment: But other than those improvements the logic holds well for either way.
Answer: Let $g(x)=\log(1+x)$. Since $$g''(x)=-\frac{1}{(1+x)^2}<0$$
$g$ is a concave function and $y=x$ is their tangent  line at the point $(0,0)$.
Answer: If you define
$\log(x)
=\int_1^x \dfrac{dt}{t}
$,
then
$\begin{array}\\
\log(1+x)
&=\int_1^{1+x} \dfrac{dt}{t}\\
&=\int_0^{x} \dfrac{dt}{1+t}\\
&\lt\int_0^{x} dt\\
&=x\\
\end{array}
$
Answer: The proofs have all the right ingredients (though it's not really two different ways, it's the same method just with a slightly different definition of $f$). What you can improve is the presentation of the proof. Try to write it up in a more structured and logical way and add some words. Right now you are mixing up the definition of the function with the inequality you want to show and then mixing up referencing the theorem you use with showing that your function satisfy it which is a bit confusing.
Here is a simple example of how one could rewrite your proof:

Define the function $f(x) = x - \log(1+x)$. We see that $f'(x) = 1 - \frac{1}{1+x} = \frac{x}{1+x}$ so $f'(x) \geq 0$ for $x\geq 0$. Since the derivative is positive $f$ is increasing on $[0,\infty)$ and we therefore have
  $$f(x) \geq f(0) = 0  \implies x\geq \log(1+x)~~~\text{for}~~~x\geq 0$$

If you want to be more detailed you could for example also prove the theorem you use:

If $f'(x) \geq 0$ then from the mean value theorem we have $\frac{f(b)-f(a)}{b-a} = f'(c) \geq 0$ and it follows that if $b>a$ then $f(b) \geq f(a)$ so $f$ is increasing.

Or just reference it:

By the mean value theorem $f'(x) \geq 0$ implies that $f$ is increasing and we therefore have...

However this is such a well known statement that it's not needed to prove it unless you want to be very thorough.
Answer: You can add an exponent on both sides. The result is
$$1+x \leq \mathrm{e}^x$$
Remembering that $\mathrm{e}^x = \sum_{i=0}^\infty \frac{x^i}{i!}$, the inequality holds since the l.h.s. is exactly the first two elements of the exponent Taylor series, and all elements in this series are positive.
Answer: If $x=0$ then the relation is valid. Let $x>0$. By the mean value theorem we have that
$$
\frac{\log(1+x)-\log 1}{1+x-1}=\frac 1t,\qquad t\in(1,1+x).
$$
Since the right-hand side is less than 1 we get the given relation
$$
\frac{\log(1+x)}{x}<1\quad\Rightarrow\quad \log(1+x)<x,\quad x>0.
$$


emacs evil-mode key map

Question: yep I am the one who started to use EMACS but not willing to abandon the VIM skills I learned.
evil is definitely a good thing.
the issue I am encountering is that there too few documentation for this. Obviously I am using a tiny fraction of the key-mappings defined in evil.
So I take a look at the evil-maps.el, and get quite a few question regarding this file:

a lot of the key are not mapped to the function defined there
what is the evil-window-map ? (just find out my self, it is key-bindings for jumping between windows, and to activate it: need to (setq evil-want-C-w-in-emacs-state 1 ) )
what is the operator pending state ?

did evil load all the maps it listed in the evil-maps file into Emacs ?
any better documentation for evil ?
Answer: it takes sometime to understand the STATE of EVIL plugin and then those shortkeys just become handy. so the solution is to read the documentation again and again.

emacs evil-mode key map


Parse character

Question: I have a character. For example: "RSSI:-41,-40,-41". There is a fast and easy way of parsing this character? I mean getting the values -41 -40 and -41.
Comment: Try `library(stringr);as.numeric(str_extract_all(str1, '[0-9.-]+')[[1]])`
Answer: Based on the example provided, this also works
 scan(text=sub('.*:', '', str1), sep=",", quiet=TRUE)
 #[1] -41 -40 -41

stri_extract_all_regex from stringi would be faster
 as.numeric(stri_extract_all_regex(str1, '[-0-9.]+')[[1]])
 #[1] -41 -40 -41

data
 str1 <- "RSSI:-41,-40,-41"

Answer: library(stringr)
> str_extract_all("RSSI:-41,-40,-41", "[-0-9]+")
[[1]]
[1] "-41" "-40" "-41"

Parse character


Move /opt to a different, already existing drive

Question: I dual boot Ubuntu 16.04 and Windows 8.1.  All of Ubuntu lives on an SSD, and the core Windows stuff lives there too, in a separate partition.  The main User folders for Windows (Documents, Downloads, etc.) live on a separate hard drive.
I'm running out of space in Ubuntu. I'd like to move /opt and /usr/local to the hard drive.  All the Q&A I've found about this, however, starts with the assumption that these folders are already mounted on a different partition, or that I can format the destination drive. Neither of these is true for me.
I don't remember exactly what I did when I set this computer up, but I do know the hard drive is accessible from Ubuntu (and is at /dev/sdb1, mounted at /media/steve/storage).  Is it possible to do what I'm asking?
Comment: 15.04 reached end-of-life in February. You should switch to a supported release.
Comment: Since /opt and /usr/local contain program files, you may prefer to move your /home partition first, for the sake of speed. If so, refer to [How can I move my /home directory to another partition if it's already part of the / partition?](http://askubuntu.com/q/5484/301745).
Comment: Sorry I meant 16.04. And I don't want to move /home, that's the whole point of putting it on the SSD.
Comment: You can edit your question to fix the version number. As for /home, I don't follow.
Comment: General warning: you should NOT move directories that contain production critical files that are needed to be started during boot. If there is any trouble with that other disk it wont mount possibly breaking your boot, leaving you with an unbootable machine where you need a live session or a grub resque. That spells serious trouble if that machine is a cloud instance or even a server that is outside your reach. The 1st act of cleaning up an SSD should be to move USER CONTENT to that other disk.
Answer: You can simply link to it:

Move the /opt directory:
sudo mv /opt /mnt/otherDisk/

Create a symlink to the new location:
sudo ln -s /mnt/OtherDisk/opt /

You will now have:
$ ls -ld /opt
lrwxrwxrwx 1 root root 5 Apr  6 14:23 /opt -> /mnt/OtherDisk/opt

As Rinzwind correctly pointed out in the comments, this can break your system if you move a directory containing files needed during boot. For example, you certainly don't want to do this for /bin. /opt should be fine though.
Comment: This is not a complete answer.  You can't just sym link opt and expect everything to be happy.  If the drive or partition that you sym link it to does not automatically mount then it causes huge frustrations.  The actual answer is to change the destination of OPT in FSTAB.
Comment: @JoshuaRobison there shouldn't be anything in`/opt` that's required during boot. If there is, then yes indeed not having it mounted might be an issue. On the other hand, it might also be a problem to mount the drive automatically since that would stop the boot when the drive isn't attached. Moving and linking something like `/usr` would be a horrible idea, but `/opt` should be fine in the vast majority of cases. In any case, there is another answer that suggests the (perfectly valid, as you say) fstab approach.
Comment: This answer is not good. Lots of issues:, Where did foo come from, sym linking to root???. As @jushuaRobison suggested - Move the data from opt to new drive, and mount this new drive on boot (fstab). once I do this I will post the process below.

Often I put the current hdd into another machine to get unchanged data off, and this way pretty much anything can be moved (using dd). That siad be very careful!
Comment: @NZDev whoops, thanks. I must have been using `foo` to test when I wrote it. That `foo` should have been `opt`. Apart from that, please see my answer to Joshua above. Mounting on boot can have a different set of problems. You just need to use the right approach for you. However, I struggle to think of a case where moving `/opt` would be a problem. There may well be such cases, I just can't think of one. I am not saying you can do this for any directory in general, but `/opt` _should_ be fine.
Comment: Somewhat agree, unfortunately the question did not have enough info to determine the exact setup.
He said existing HDD this could mean it already has data on it, which in that case your solution is fine for opt. My preference would be to move out home, opt, srv, var to disk space that works for the solution.
My preference is if creating brand new space for something that is getting larger is to stand up a new drive/partition and then mount it with fstab, mounting can have problems, but it is a good skill and usually the right practice
Comment: I don't know enough about sym linking, but I would have assumed the parameters are the source file/directory and then the destination file/directory, You have provided just root as the second parameter, I would have though the command should be:
sudo ln -s /mnt/OtherDisk/opt /opt
Comment: @NZDev no, that would be very different. That would create a symlink at `/opt/opt`, not at `/opt`. Frankly, I'm surprised you don't know this after your pretty assertive "This answer is not good. Lots of issues:".
Comment: OK so you are part right I have never used ln that way, and yes it does work as you have described, I have always been explicit with my naming of my symlinks, and hence /opt. But you are wrong, my way would not create /opt/opt, my way is how the docs and majority of guides explain how ln should be used. If I had put a / at the end then maybe it would have tried to add opt into an opt folder, but it would have failed "No such file or directory" due to /opt/ not existing.
Comment: @NZDev no, of course it won't create a directory, how could it? If `/opt` exists and is a directory, then `ln -s foo /opt` will create `/opt/foo`. If `/opt` doesn't exist, then it will create `/opt` as a symlink to `foo`. And if it exists but isn't a directory it will fail unless you use `ln -f` in which case it would replace the existing file with a link.
Answer: I second moving /home, but it's possible to do what you want.
If I understand correctly, you have two drives, one with ubuntu (and possibly some windows stuff) and one with the windows user files.  What you would need to do is shrink the windows partition (while I have done this successfully many times, resizing partitions may lead to data loss, so back up your data), and that will free up room on that drive.  You can use a program like GParted to resize partitions.  Once done, you can take the leftover space and make a new partition (also done with GParted).  Then you'll need to copy the contents of /usr/local and /opt over to the new partition (I usually do this part by inserting a live cd and mounting everything and copying).  Finally, you'll need to edit /etc/fstab and tell it where to mount /usr/local and /opt.
The link given above on the steps to move /home are the same, so you can follow that guide for moving /usr/local and /opt.  What you will need to do is resize the windows partition first.
Comment: Not /home/ but the user content (the directories) should be moved. So altering `./config/user_dirs.dirs`
Answer: RISKY PROCESS, DATA CAN BE LOST! Make backups

I used this approach on my raspberrypi (just now) with different
linux os (raspbian).
setup the existing partition in my case with the same permissions on
the folder. It was the only partition that was already mounted to
/mnt/existingpartitionfolder/.
Copied with rsync all contents of opt to existingpartitionifolder
$sudo rsync -avX /opt/ /mnt/existingpartitionfolder/. Existing data
in the existingpartitionfolder would soon becaome part of opt.
I prayed that my symlinks moved relative to the copy process and did
not link to the old opt location. I believe -l does this which is
included in the -a switch, and they looked ok???
Adjust /etc/fstab entry from /mnt/existingpartitionfolder to /opt
I had an nfs running on that /mnt/ folder so I also adjusted
/etc/exports entry to point at /opt which would be the same logical
location after reboot.
rename /opt $ sudo mv /opt /optold (my backup)
$sudo reboot now
Everything came back perfect and intact, now just need to delete
/optold (deleting the backup, or move it to new /opt) if the space is required, and test.

To do this on other top level folders, may not work if data is moving.
The same approach can be taken by putting the HDDs into another machine or running a LIVE disk.
Just be carefull with your UUIDs in fstab, and permissions of folders and files.
If boot sequence fails it is likely your UUIDs in fstab(big assumption).
If you need to copy whole disks use the dd command.


`fstrim` service reports strange values

Question: I have two SSD disks on my system and three filesystems:
$ lsblk | grep -v '^loop'
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 465.8G  0 disk /home
sdb      8:16   0 238.5G  0 disk
├─sdb1   8:17   0   512M  0 part /boot/efi
└─sdb2   8:18   0   238G  0 part /var/snap/firefox/common/host-hunspell
                                 /

and their utilization is like this:
$ df -BM / /home /boot/efi
Filesystem     1M-blocks    Used Available Use% Mounted on
/dev/sdb2        238777M  34465M   192112M  16% /
/dev/sda         468357M 203036M   241459M  46% /home
/dev/sdb1           511M      7M      505M   2% /boot/efi

The fstrim service runs once a week, but reports some "unnatural" values:
$ journalctl | grep   "fstrim.*/home"
Oct 23 12:42:02 x fstrim[23187]: /home: 249.6 GiB (267956338688 bytes) trimmed on /dev/sda
Oct 30 19:19:38 x fstrim[22436]: /home: 248.9 GiB (267243692032 bytes) trimmed on /dev/sda
Nov 06 13:35:55 x fstrim[31818]: /home: 243.7 GiB (261722529792 bytes) trimmed on /dev/sda
Nov 13 11:53:32 x fstrim[11380]: /home: 242.9 GiB (260790439936 bytes) trimmed on /dev/sda
Nov 20 11:36:39 x fstrim[8200]: /home: 257.8 GiB (276775620608 bytes) trimmed on /dev/sda

$ journalctl | grep   "fstrim.*/:"
Oct 23 12:42:02 x fstrim[23187]: /: 197.1 GiB (211671953408 bytes) trimmed on /dev/sdb2
Oct 30 19:19:38 x fstrim[22436]: /: 197.5 GiB (212089090048 bytes) trimmed on /dev/sdb2
Nov 06 13:35:55 x fstrim[31818]: /: 197.5 GiB (212091011072 bytes) trimmed on /dev/sdb2
Nov 13 11:53:32 x fstrim[11380]: /: 198.9 GiB (213588897792 bytes) trimmed on /dev/sdb2
Nov 20 11:36:39 x fstrim[8200]: /: 199.1 GiB (213827371008 bytes) trimmed on /dev/sdb2

$ journalctl | grep   "fstrim.*/efi:"
Oct 23 12:42:02 x fstrim[23187]: /boot/efi: 504.9 MiB (529436672 bytes) trimmed on /dev/sdb1
Oct 30 19:19:38 x fstrim[22436]: /boot/efi: 504.9 MiB (529436672 bytes) trimmed on /dev/sdb1
Nov 06 13:35:55 x fstrim[31818]: /boot/efi: 504.9 MiB (529436672 bytes) trimmed on /dev/sdb1
Nov 13 11:53:32 x fstrim[11380]: /boot/efi: 504.9 MiB (529424384 bytes) trimmed on /dev/sdb1
Nov 20 11:36:39 x fstrim[8200]: /boot/efi: 504.9 MiB (529424384 bytes) trimmed on /dev/sdb1

My weekly usage is not uniform. For example, I have done a 23.04 → 23.10 upgrade on November 8th. Taking into consideration my usage and disk utilization, the numbers reported by fstrim do not make sense.
Can somebody help me interpret these numbers? Can somebody make similar checks on their system and see if it is also the case on that systems too? I thought that the numbers reported are supposed to be the number of block or bytes recovered after the trim operation, but it looks like they are the number of free block or bytes as known by the OS. How can I see the actual number of blocks recovered?

Note that this question may be related to How to know if my NVMe SSD needs TRIM
Comment: From this we can conclude that: (1) fstrim sends **all** the empty (as known to the OS) blocks to SSD for recovery. This is true after the first invocation after OS boot. Subsequent runs of fstrim will only send the **newly** deleted blocks. However this information is lost during shutdown, so after reboot fstrim will send all deleted blocks again to SSD. (2) There's no way to know the actual number of blocks recovered by the SSD, since this information is not communicated back (?) to the OS by the SSD.
Comment: I got to the same conclusion as you. But my TRIM knowledge is very limited... I learned most of it in the last 5 days :)
Comment: How often do you reboot your machine?
Comment: It is a notebook computer. I never go to standby, sleep or whatever.  I always shut it down (power off) at least once per day, sometimes I reboot it several times a day (due to software update, etc.).
Comment: This may be helpful to you: https://askubuntu.com/q/729279/1157209
Comment: Thanks @sotirov . Although an old question, the answer seems valid. What about my very last question above?
Comment: I think that's how TRIM works. These are my logs https://i.stack.imgur.com/5fDUI.png I am not really into restarting, and it can be seen from the image :) It's normal for me to have several weeks uptime on my laptop.
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/149823/discussion-between-fedkad-and-sotirov).
Answer: From the discussion with @sotirov on the comments above, I can conclude the following:

fstrim sends all the empty (as known to the OS) blocks to SSD for recovery. This is so during its first invocation after OS boot. Subsequent runs of fstrim will only send the newly deleted blocks. However, this information is lost during OS shutdown, so after reboot fstrim will send all deleted blocks again to SSD.

There's no way to know the actual number of blocks recovered by the SSD, since this information is not communicated back to the OS by the SSD.

Please comment or correct my answer.

`fstrim` service reports strange values


Publish npm Package for React

Question: I have been attempting to publish an npm package for react but keep running into issues. More specifically, after I publish my package and go to test it, the installed package has errors related to the jsx.
I built the published package with create-react-app and then added an additional package.json in the specific directory I wanted to publish.
I assume my issues are because create-react-app expects you to use the root package.json and not a separate one within the project. So this leads me to believe there are Webpack or Babel configurations I need to handle. I am having trouble finding this information.
The directory I am trying to publish only has 3 files other than my package.json which looks like this
{
  "name": "...",
  "version": "1.0.0",
  "description": "...",
  "main": "index.js",
  "peerDependencies": {
    "react": "^17.0.1",
    "react-dom": "^17.0.1"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "license": "ISC",
  "keywords": []
}

this has so far been unsuccessful. I have also attempted the following
{
  "name": "...",
  "version": "1.0.0",
  "description": "...",
  "main": "index.js",
  "peerDependencies": {
    "react": "^17.0.1",
    "react-dom": "^17.0.1"
  },
  "babel": {
    "presets": [
      "@babel/preset-react"
    ]
  }
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "license": "ISC",
  "keywords": []
}

Im not sure what I am missing
Answer: You can use the create-react-library for creating packages for React and publishing those to NPM.

Publish npm Package for React


What is the difference between Shallow Information Architecture and deep Information Architecture?

Question: I am new to User Centric Design process, wish to learn Information architecture in detail. Please help me understand difference between Shallow Information Architecture and deep Information Architecture? Example should help me to understand better.
Thanks-
Answer: If you want to learn about Information Architecture there is a great book on the subject - Information Architecture for the Web and Beyond (4th Edition) by Peter Morville & Jorge Arango.
However, this question has been asked before: Should we use 'narrow and deep' or 'broad and shallow' navigation pattern on mobile devices? and there is a good diagram showing the difference between shallow and deep structures in this question.
Answer: Basic definitions:
Shallow = more top level categories, not many sub catgeories.
Deep = less top level, more sub.
Donna Spencer is a great expert and the practical guide of IA is an easy ready with lots of info based on experience.
http://maadmob.com.au/design/ia


SURD/Differential Question - Did they rationalise the fraction?

Question: I am doing this question but don't understand this solution. Did they rationalise the SURD on this step?

If you would like context in terms of the whole question here it is:
Answer: $$ \frac{dh}{dt}= -k\sqrt h= -k'\frac{\sqrt{Ah}}{A} $$
so
$$ k=k' \frac{\sqrt{Ah}}{A\sqrt h}=k' \sqrt\frac{Ah}{A^2h} =\frac{k'}{\sqrt A}$$
Comment: Hi, I am a bit confused as to what you have done on the second line. Why have you multiplied the denominator by root H?
Comment: I have divided both sides of $-k\sqrt h= -k'\frac{\sqrt{Ah}}{A}$ by $-\sqrt h$


An error-message pops up very short at startup and disappear. Where can I read it?

Question: Very easy for non computer/Ubuntu 14.04 LTS peasants, but I think the message provide some help,
Answer: hardware-related messages are in dmesg, while others are in /var/log/syslog
dmesg | tail -n 50
cat /var/log/syslog | less


How to percolate simple_query_string/query_string query

Question: Index:
{
    "settings": {
        "index.percolator.map_unmapped_fields_as_text": true,
    },
    "mappings": {
        "properties": {
            "query": {
                "type": "percolator"
            }
        }
    }
}

This test percolator query works
{
    "query": {
        "match": {
            "message": "blah"
        }
    }
}

This query doesn't work
{
    "query": {
        "simple_query_string": {
            "query": "bl*"
        }
    }
}

Results:
{"took":15,"timed_out":false,"_shards":{"total":5,"successful":5,"skipped":0,"failed":0},"hits":{"total":{"value":1,"relation":"eq"},"max_score":0.13076457,"hits":[{"_index":"my-index","_type":"_doc","_id":"1","_score":0.13076457,"_source":{"query":{"match":{"message":"blah"}}},"fields":{"_percolator_document_slot":[0]}}]}}

Why this simple_query_string query doesn't match the document ?
Comment: Your last query `{ "query": { "simple_query_string": {"query": "blah"}, "analyzer" : "my_analyzer" } }` errors out because it is not valid, it should be `{ "query": { "simple_query_string": {"query": "blah", "analyzer" : "my_analyzer" } } }`
Comment: What exactly is your question? do you have an example of what's not working?
Comment: The question is how to unit percolator index to work with simple_query_string queries. Or how to insert simple_query_string into a percolator index. Basically I'm looking for a working example.
Answer: I don't understand what you are asking either. It may be that you do not understand percolator very well?
This is an example I just tried now.
Let's assume you have an index - let's call it test - in which you want to index some documents. This index has the following mapping (just a random test index I have in my test setup):
{
    "settings": {
        "analysis": {
          "filter": {
            "email": {
              "type": "pattern_capture",
              "preserve_original": true,
              "patterns": [
                "([^@]+)",
                "(\\p{L}+)",
                "(\\d+)",
                "@(.+)",
                "([^-@]+)"
              ]
            }
          },
          "analyzer": {
            "email": {
              "tokenizer": "uax_url_email",
              "filter": [
                "email",
                "lowercase",
                "unique"
              ]
            }
          }
        }
      },
    "mappings": {
        "properties": {
            "code": {
                "type": "long"
            },
            "date": {
                "type": "date"
            },
            "part": {
                "type": "text",
                "fields": {
                    "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                    }
                }
            },
            "val": {
                "type": "long"
            },
            "email": {
              "type": "text",
              "analyzer": "email"
            }
        }
    }
}

You notice it has a custom email analyzer that splits something like email@example.com into these tokens: email@example.com, foo, bar.com, bar, com.
As the documentation says, you could create a separate percolator index that will hold only your percolator queries, not also the documents themselves. And, even if the percolator index doesn't contain the documents themselves, it should hold the mapping of the index that should hold the documents (test in our case).
This is the mapping of the percolator index (which I called it percolator_index) that also has the special analyzer used for splitting the email field:
{
    "settings": {
        "analysis": {
          "filter": {
            "email": {
              "type": "pattern_capture",
              "preserve_original": true,
              "patterns": [
                "([^@]+)",
                "(\\p{L}+)",
                "(\\d+)",
                "@(.+)",
                "([^-@]+)"
              ]
            }
          },
          "analyzer": {
            "email": {
              "tokenizer": "uax_url_email",
              "filter": [
                "email",
                "lowercase",
                "unique"
              ]
            }
          }
        }
      },
    "mappings": {
        "properties": {
            "query": {
                "type": "percolator"
            },
            "code": {
                "type": "long"
            },
            "date": {
                "type": "date"
            },
            "part": {
                "type": "text",
                "fields": {
                    "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                    }
                }
            },
            "val": {
                "type": "long"
            },
            "email": {
              "type": "text",
              "analyzer": "email"
            }
        }
    }
}

Its mapping and settings are almost the same with my original index, the only difference being the additional query field which is of type percolator added to the mapping.
The query you are interested it - simple_query_string - should go into a document inside percolator_index. Like so:
PUT /percolator_index/_doc/1?refresh
{
    "query": {
        "simple_query_string" : {
            "query" : "month firstname.lastname@example.com",
            "fields": ["part", "email"]
        }
    }
}

To make it more interesting, I added the email field in there to be specifically searched for in the query (by default, all of them are searched).
Now, the aim is to test a document that should eventually go into test index against this simple_query_string query from your percolator index. For example:
GET /percolator_index/_search
{
  "query": {
    "percolate": {
      "field": "query",
      "document": {
        "date":"2004-07-31T11:57:52.000Z","part":"month","code":109,"val":0,"email":"email@example.com"
      }
    }
  }
}

What's under document is, obviously, your future (non-existent yet) document. This will be matched against the above defined simple_query_string and will result in a match:
{
    "hits": {
        "total": {
            "value": 1,
            "relation": "eq"
        },
        "max_score": 0.39324823,
        "hits": [
            {
                "_index": "percolator_index",
                "_type": "_doc",
                "_id": "1",
                "_score": 0.39324823,
                "_source": {
                    "query": {
                        "simple_query_string": {
                            "query": "month email@example.com",
                            "fields": [
                                "part",
                                "email"
                            ]
                        }
                    }
                },
                "fields": {
                    "_percolator_document_slot": [
                        0
                    ]
                }
            }
        ]
    }
}

What if I would have percolated this document instead:
{
  "query": {
    "percolate": {
      "field": "query",
      "document": {
        "date":"2004-07-31T11:57:52.000Z","part":"month","code":109,"val":0,"email":"foo"
      }
    }
  }
}

(notice that the email is only foo)
This is the result:
{
    "hits": {
        "total": {
            "value": 1,
            "relation": "eq"
        },
        "max_score": 0.26152915,
        "hits": [
            {
                "_index": "percolator_index",
                "_type": "_doc",
                "_id": "1",
                "_score": 0.26152915,
                "_source": {
                    "query": {
                        "simple_query_string": {
                            "query": "month email@example.com",
                            "fields": [
                                "part",
                                "email"
                            ]
                        }
                    }
                },
                "fields": {
                    "_percolator_document_slot": [
                        0
                    ]
                }
            }
        ]
    }
}

Notice that the score is a bit lower than the first percolated document. This is probably like this because foo (my email) matched only one of the terms inside my analyzed firstname.lastname@example.com, while email@example.com would have matched all of them (thus giving a better score)
Not sure what analyzer are you talking about though. I think the example above covers the only "analyzer" issue/unknown that I think may be a bit confusing.
Comment: FYI, I created https://github.com/elastic/elasticsearch/issues/48874 because there is either an undocumented issue or a bug in itself.
Comment: Now I understand the actual issue you have. Let me look into it.
Comment: Thank you for such a detailed answer Andrei, but my problem is a little bit different. The simple_query_string from my example doesn't look for a specific field, instead it looks across the all fields in the document. So, I'm looking how to make this cross field query to work under percolator.
Comment: That doesn't make a difference. You can remove the `fields` part from the query def. The point is that it's about how you structure your index and what analyzers you define for your fields (I just provided a bit more complex example with an `email` custom analyzer), and not about the percolator. The percolator is just a way to run a document through a set of defined queries (your `simple_query_string`). Defining the mappings for the fields used in the document should be done like the percolator wouldn't even be used. Can you explain a bit more, please? I still don't see an issue here, sorry.
Comment: May I suggest one more thing: play with `simple_query_string` just like you would do if percolator would not be in the picture. Like, using an `analyzer` to analyze the text provided to `simple_query_string`. And when you are done coming up with the final query and the final mapping for your index, move that to a percolator.
Comment: I've updated the question with an actual simple_query_string example which doesn't work.
Comment: Thank you Andrei, this was really helpful, I hope you guys will sort this out.


F5 Load balancer over web server

Question: I have to derive the infrastructure set up for my company. I was confused if a web server(Apache) can be replaced by F5 load balancer.
Are all the capabilities a web server possess/handles can be handled/possessed by F5 load balancer.
What i know is web server will safe gaurd the app server other than serving the static data.
Even the re-write rules of Apache can written in F5 load balancer as iRules.
With the above I am seeing the necessity of having a web server in the application architecture.
However would like to hear from to understand if I my perception is right/wrong.
Suggestions please..
Comment: it really depends on your requirements for a web server. For some deployments, absolutely, you can eliminate the tier altogether. For others, it still makes sense to have that tier.
Answer: Following up on Jason's comment, if you're serving up publicly consumable content, you should use Apache.  Your developers would normally not have access to the BIG-IP so any content management requirements would be hindered by placing publicly served pages on the BIG-IP.
If you're only using BIG-IP for rewrites, redirects, traffic manipulation, and any SSL/TLS management, BIG-IP would be an appropriate place for this as long as your dev teams don't require frequent management of these functions.
This is really an opinion question but standard practices do host web servers behind the BIG-IP for content layer presentation.

F5 Load balancer over web server


Trim spaces between value

Question: LinkButton section = (LinkButton)gridcheck.Rows[i].FindControl("lbSection");

if (section == sender)
  Response.Redirect(section.Text + ".aspx");

Lets say I have an "AirPlane.aspx" page and the database table I am calling is named "Air Plane".  I tried to use this to trim the space between the "r" and "P" but it does not work
Convert.ToString(section).Replace(" ", "");

Answer: It appears you're trying to convert the entire object to a string. Instead, you should be able to use the text field and perform a replace directly against it.
Response.Redirect(section.Text.Replace(" ", string.Empty) + ".aspx");

Trim spaces between value


proof: inverse of lower triangular identity matrix

Question: As you know that is enough negating below of diagonal to inverse of lower triangular identity matrix.
example
$$A = \left(\begin{matrix}
        1 & 0 & 0 & 0 \\
        3 & 1 & 0 & 0 \\
       -1 & 0 & 1 & 0 \\
2 & 0 & 0 & 1 \\
        \end{matrix}\right)
$$
basically inverse of A
$$A' = \left(
        \begin{matrix}
        1 & 0 & 0 & 0 \\
        -3 & 1 & 0 & 0 \\
       1 & 0 & 1 & 0 \\
-2 & 0 & 0 & 1 \\
        \end{matrix}\right)
$$
I just need to prove it.
my question is not related any software. it is general linear algebra question. It's not enough to say that "if $A'=$ (inversion of $A$), multiplication $A'$ and $A$ should be $I$ (identity matrix)". we cannot say for all case. I need a general proof.
it's related topic with Gauss Elimination - LU decomposition
thank you for any help.
Comment: I don't understand what you mean by "*cannot say for all case*".
Comment: my friend tried to prove it like "if A′= (inversion of A), multiplication A′ and A should be I (identity matrix)". i just want to say that it is not a actual proof. because we should check for all lower triangular identity matrices
Comment: Your observation only works for so-called "Gauss transforms", which are rank-1 corrections to the identity matrix that turn up in LU decomposition. Golub and Van Loan should have a proof of this.
Comment: yest J. M., you are right. it's related topic with Gauss Elimination - LU decomposition.
Answer: I don't think your statement is correct.  For example,
$$
\pmatrix{
1\\
1&1\\
0&1&1\\
0&0&1&1
}^{-1} =
\left( \begin{array}{rrrr}
1\\
-1&1\\
1&-1&1\\
-1&1&-1&1
\end{array} \right)
$$
However, if only the first column is non-zero, then we can write our matrix in the form
$$
A =
\pmatrix{
1&0\\
x&I_3
}
$$
where $x \in \Bbb R^3$ and $I_3$ is the size $3$ identity matrix.  We then note using block-matrix multiplication that
$$
\pmatrix{
1&0\\
x&I_3
}
\pmatrix{
1&0\\
-x & I_3} =
\pmatrix{1&0\\0&I_3} = I_4
$$
so that indeed, we can find the inverse by negating whatever is below the diagonal.
Comment: I would be very surprised if you actually "already presented the same thing", and the prof didn't accept it as a proof.  What is *"prove $M1 + M2$"* supposed to mean?  Also, I am saying the reverse: if $AA' = I$, **then** $A' = A^{-1}$.  This is always true for matrices.
Comment: thank you Omnomnomnom.  Actullay I showed my prof exactly same thing like your last equality. However, He didn't accept. Because this answer is not a proof actually.
Comment: with following equality, you just showed us A'.A=I

$$
\pmatrix{
1&0\\
x&I_3
}
\pmatrix{
1&0\\
-x & I_3} =
\pmatrix{1&0\\0&I_3} = I_4
$$

thak you anyway
Comment: In what way is this not a proof? If $AA'=I$, then $A'$ is the inverse of $A$.
Comment: I have a strong feeling that you don't know what I mean by "block-matrix multiplication"


CoreAnimation and Device Rotation

Question: I have a CAKeyframeAnimation that looks great in landscape but when the device rotates the animate is of course out of place compared to the rest of the content.  Is there a way to adjust (scale) the path of an animation in progress?
Edit: Adding Code
<code>        let circle = CAShapeLayer()
        circle.path = UIBezierPath(roundedRect: CGRect(x: -60.0, y: -60.0, width: 100.0, height: 100.0), cornerRadius: 50.0).cgPath
        circle.fillColor = UIColor.clear.cgColor
        circle.strokeColor = UIColor.blue.cgColor

        let animation = CAKeyframeAnimation(keyPath: "position")
        animation.duration = (path["endTime"] as! Double) - (path["startTime"] as! Double)
        animation.repeatCount = 0
        animation.path = (path as! UIBezierPath).cgPath
        animation.calculationMode = kCAAnimationPaced
        animation.fillMode = kCAFillModeForwards
        animation.isRemovedOnCompletion = false

        circle.add(animation, forKey: "position")
        self.view.layer.insertSublayer(circle, at: 5)
</code>
The problem is that the UIBezierPath is defined in either Portrait or Landscape (the app supports both) so playback at the same orientation that it was created is no problem, but if you rotate the device the Animation defined by the UIBezierPath should be updated for the new orientation. I'm just looking for a method of updating the CAKeyframeAnimation path to the new coordinate system while it is animating.
Comment: Would you have any code to show us?
Comment: So you're saying you want to change the animation _while it is in the middle of animating_ because the user rotated the device?
Comment: exactly! Because the coordinate system changes the path needs to update.  I'm just not sure how to do that.
Answer: I found that you can't adjust the path on the fly, but you can create a new path based on the points in the original and your calculated scale/translations.
To get the array of CGPoints from the UIBezierPath you can use this method: https://stackoverflow.com/a/36374209/1491675
For device rotation once the animation begins, keep a reference to the current point in the animation and on device rotation recalculate the path and replace the existing animation with a new one leaving out the part of the animation that has already occurred.
Comment: Maybe it would help me (and others) if you showed the actual code.
Comment: I don't understand why you don't just stop the animation dead when the rotation starts, leaving the view at the point where it is (the presentation layer will give you this information), and then start a new animation with a new path after the rotation finishes.
Comment: you mean like I described above? "... on device rotation recalculate the path and replace the existing animation with a new one..."

CoreAnimation and Device Rotation


Jettisoned Tasks Still In Multitasking Bar

Question: I was inspecting my crash log and noticed several apps appear to have been jettisoned. But looking at the multitasking bar, they are still there. Is there another way I can confirm that inactive apps are actually being jettisoned before my app crashes?  Can this be seen in any of the tools?
Up until now, I assumed my app was being closed without the inactive apps being jettisoned. Now I'm unsure.
Update
I have, on several occasions, had my crashing app stop crashing after I removed everything from the multitasking bar. I didn't check the crash log in those cases, and I'll have to do that in the future. But it's hard to imagine that that was just a coincidence.
Answer: The bar is simply a launch history.  It doesnt represent the current state of your device memory except by coincidence.....
Comment: Thanks. I updated my question with additional info. My question is still open though. How can I use the available tools to see if the apps have been jettisoned?
Comment: When you say "removed everything" do you mean all items or just your item?
Comment: I removed all items from the bar and then reloaded my application.
Comment: Then you have altered the memory condition of your device by terminating all of the other background apps, so it may not crash because there is more free memory available to work with.
Comment: Then that makes the bar more than a launch history. So my question is  why does the crash log show them jettisoned (jetsam does this to free memory), but they are still in the bar and taking up memory.
Comment: That's exactly what I said...the bar is a launch history...i.e. These are the last programs that you LAUNCHED, but they may or may not be actually running in the background
Answer: I used instruments to see what the memory usage was while my app was running. I can see that real memory in the Memory Monitor reports the amount of real memory being used by each app.
Seeing that several inactive apps were showing memory use, I confirmed that they were in the multitasking bar. I was able to manually delete each one from the bar and saw an immediate response in memory usage. Each deleted app disappeared from the memory usage list.
This answers my question -- Instruments can show how much memory is used by apps that show up in the multitasking bar.
Apparently, the multitasking bar is showing applications that are currently taking real memory. It is not just a launch history.
That being said, I don't understand why Jetsam does not release these apps before killing my running app. I'll post that question later as a new one.


Is it possible to generate alpha worlds with specific seeds?

Question: I have some seeds from some old worlds I want to see again, is there a mod that allows the ability to create alpha worlds with seeds or would it be possible to make a world blank but with the seed so that when the world is loaded it generates the world with seed using the generation type of that version?
Answer: I'm nearly 6 years late, but someone made a fabric mod which adds a seed selector into alpha 1.2.2a. Here is a zip you can import into MultiMC to use fabric mods in 1.2.2a.
Answer: Here is how you can make a world with a custom seed in Minecraft Alpha, before you could change the seed in-game

Start Minecraft Alpha by changing the version in the Minecraft Launcher
Create any world, and save and exit Minecraft
Use NBTedit to open level.dat found in the saves/ folder of .minecraft
Open Data/RandomSeed and change this to your seed you want
Delete all the chunk files
Open the world in Minecraft again
Answer: I found a mod that let's you use old alpha seeds if you're still looking for this. There's no need to do this whole world update stuff just download this mod for 1.12.2. I know it says it's a server plugin, but I can 100% guarantee that it will work like any other mod, just download forge for minecraft 1.12.2 and drag this mod into the mod folder, when you're creating a world, select "world type: alpha 1.1.2_01" and then you're done. This mod doesn't generate villages or anything like that, but if you're using mods such as recurrent complex, rouge-like dungeons etc. it will generate those structures. Anyway Here's the link.
https://forums.spongepowered.org/t/nostalgiagen-0-6-generate-minecraft-alpha-beta-worlds-on-your-sponge-forge-server/10126


How to reduce a garden rocker's squeaking?

Question: Last night I finished mounting a garden rocker (it's something like this).
It looks and feels nice but unfortunately it's very, very squeaky when used, especially when I'm barely moving it.
Is there anything I can do to attenuate the squeaking?
I was thinking about changing the springs or adding some sort of rubber to the current springs.
The current rocker's spring looks like this:
Answer: If all the fasteners in the frame are thoroughly tight, put a drop of 3-in-1 oil on the end of each spring where it goes through the eye and contacts metal (two on the upper end for each side) and see if that gets rid of most of it.
Squeaking is caused by metal-on-metal contact where there's minute movement and no lubricant. Changing out the springs won't take care of where the squeaks usually come from.
After lubricating the spring ends, if it's still squeaking, have someone sit in the swing and observe the bolted joints for slight movement. If they're reasonably tight, you might hit them with something like Tri-flow lubricant spray between the joined pieces and wipe the residue off. The spring coils wouldn't be hurt by a little of that either as an anti-corrosive.
Comment: Thank you for your detailed explanations! I'll try what you suggested and see if it will fix it
Comment: Glad to be of help! Squeaks like that can be like fingernails on a chalkboard and remove all the joy out of why you bought the swing.


Are mice dying in my loft?

Question: I have a downstairs toilet that protrudes from the side of the house. As a result, it has a loft area that is not accessible without cutting into the plasterboard ceiling.
Mice are fairly common in the area due the woodlands opposite the house, so it wasn't a surprise when I started hearing noises in the space above the toilet. What I have noticed recently are some dark orange spots appearing on the ceiling. Some now have droplets hanging from them.
Could this be decomposing mice in the loft space?
It's worth noting that last year some water damage had occurred which has (hopefully) been fixed.
Comment: Is there a bathroom above it? What does it smell like in there? wet mine shaft or ammonia?
Comment: There's a tiled roof above it where it sticks out of the house. No weird smells or anything like that but could be masked due to ventilation from outside.
Comment: Dead mice don't usually exude enough liquid to penetrate the ceiling; they dry out and mummify in a non-leaky attic. It's just barely conceivable that enough live mice with one designated piddle spot could, but not likely as they like to piddle everywhere.
Answer: The presence of the droplets seems to indicate that there is still a water leak in the roof of the bumpout. The discoloration is likely coming from the accumulated dirt and dust in the "attic" part of the bumpout. It is also possible that the discoloration is coming from the leak water pooling in an area where the mice deposited their droppings and then finding its way through the drywall on the bathroom ceiling.
Comment: Thanks! The puddles on my floor this morning confirms the worst. Looks like I need to address that first.

Are mice dying in my loft?


How to align 2 separated lines numbers?

Question: I'm new to CSS. What I need to do is to align two separated lines, which can have different numbers. What I have now is:
First line: 1,1,1,1
 Second: 2,2,2,2
What I need to achieve is:
First line: 1,1,1,1
 Second:    2,2,2,2

.wrap {
    display: flex;
}

First line: 1,1,1,1

Second: 2,2,2,2

As you can see the numbers are not aligned with each other at the moment. If I would add something like text-align and the numbers would change, it wouldn't be aligned either.. How to do so in CSS?
Comment: Well, in your post, the numbers look aligned in both your obtainedoutput and your required output. On a mobile device.
Answer: Wrap the text and numbers with spans, and use CSS to display as table:

.foo {
  display: table
}

.foo p {
  display: table-row;
}

.foo span {
  display: table-cell;
  padding: 0 0.5em;
}

    First line:
    1,1,1,1

    Second:
    2,2,2,2

Answer:
 First line: 1,1,1,1

Second:2,2,2,2

Use display block and width to have them each in a separate line
And if you want to use flex:

 First line: 1,1,1,1

Second:2,2,2,2

How to align 2 separated lines numbers?


Maximum values of Chebyshev Polynomials

Question: Let $T_n(x)$ be the $nth$ Chebyshev Polynomial. Prove that $|T_n(x)| \leq 1$ for $x \in [0,1]$ and determine when there is equality.
So far I was thinking that $t$ would have to be of the form $\frac{p}{q}\pi$ where $p,q\in \mathbb{Q}$ and $p<q$. Then the number of solutions would be $\lfloor{n/q}\rfloor$.
Answer: For $-1 \le x \le 1$ the trigonometric definition
of the Chebyshev polynomials is
$$
 T_n(x) = \cos(n  \arccos(x)) \, ,
$$
which immediately implies $|T_n(x)| \le 1$ in that range.
If we exclude the (trivial) case $n=0$ then
equality holds exactly if $n  \arccos(x)$ is an integer multiple of $\pi$, i.e. if
$$
 x = \cos(\frac {k \pi}n)
$$
for some $k \in \Bbb Z$. It remains to determine which values of $k$ lead
to solutions $x \in [0, 1]$.

Maximum values of Chebyshev Polynomials


How much should over-the-range microwave stick out?

Question: I moved into an apartment and want to install an over-the-range microwave. The space above the stove measures 30 in. wide, 11 in. deep, 15 in height. But how far outside of that should a microwave typically stick?
I gather I don't need to vent the microwave to the outside (which is good), but wonder if there's anything else I should think about. I've not done a lot of DIY work in the past.
Comment: By apartment, if you mean the "usual in my area" it's a rental rather than you own it, an OTR microwave is a farly dubious thing, as they approximate "built in" and may upset the owner of the apartment. If you mean a space which you own, go for it.
Comment: Is there a power receptacle readily available? If not, you're messing with wiring, which is sketchy, or getting a pro, which is pricey.
Comment: Do you mean toward the user? What's the concern?
Comment: @Ecnerwal I mean an "usual in my area" rental, but I can replace the hood without any issues from them. When they redo my apartment, they plan to replace all the appliances, including put their own microwave in. But it'll cost me $200/mo. to get a refurbished apt..
Comment: @isherwood Oh, OK. The back of the open space is flat wall, then the cabinets are 11". All the microwaves I see are 15", which means it would extend 4 inches in front of the cabinets. Then, the space is 15" high, but most microwaves seem to be 16 inches tall.
Comment: The biggest issue is power requirements. A vent hood only requires less than 1 amp. Depending upon the age of the apartment and wiring method, it may be connected to a lighting circuit (common).  Microwaves generally are supplied by a dedicated circuit.   I installed one in one of my rentals and ran a new circuit to the panel to provide adequate power.
Comment: "*I gather I don't need to vent the microwave to the outside*"  Why do you think that. Is your current hood vented to the exterior? What kind of stove do you have?
Comment: Most microwave range hoods are shipped with a recirculating fan arrangement. They usually have the option to convert to external venting, but recirculation is the default. So no, it's not required to vent outside in most cases.
Comment: @isherwood I asked for clarification because If the existing hood is vented out then it would be best to vent it out since the duct is already there,  especially if the range is gas. Required and  Best  may not be the same.
Answer: As much as the microwave needs it to. They almost always stick out some, both forward and below the side cabinets.
Most upper cabinets are ~12" deep. My microwave comes out another 2-1/2" or so beyond the face of the cabinets (without the handle) and hangs below about 2". The top mounting screws are maybe 10" from the wall, so as long as your cabinet has that depth and is robust enough to support the weight, all good.
Comment: Same way you'd tell if a chair was going to collapse if you sat on it. Use some common sense! This isn't rocket surgery. :)
Comment: On a slightly more serious note, @Jeff, use a stud finder to see if they built in any horizontal bracing that you could mount it to. If there is, you should be golden. If not, use the stud finder to find where the studs are and see how they line up with the mounting screws for the microwave. If you've got studs right behind the mounting holes, you're golden! If not, peruse this forum for questions about mounting things to drywall, but consider the weight of the oven _plus_ the (HOT) food you're cooking before you decide to continue with this endeavor.
Comment: There is some concern that the cabinets in an apartment aren't up to the task. It's for that and other reasons I didn't get into that issue. It's out of scope here as the question stands and is a broad topic. Photos or a a clear description would be required for specific advice.
Comment: How can I tell if they're strong enough to support the weight?