text:
Q: dyanamic php and bootstrap carousel is not working I have this code that does not make the carousel but instead puts all the images on top of each other and the image sliding does not work.
Here is the code:

  <?php
    $results = mysqli_query($mysqli, "SELECT * FROM `posts`");

    $extensions_arr = array("svg", "jpeg", "jpg", "png");

    while($row = mysqli_fetch_array($results)) {
      if(in_array($row['postFileType'], $extensions_arr)) {
   ?>

       <img src="<?php echo $row['post']; ?>" style="height: 25vh;" />

  <?php
      }
    }
  ?>

Update code:

                              <?php
                                $results = mysqli_query($mysqli, "SELECT * FROM `posts`");

                                $extensions_arr = array("svg", "jpeg", "jpg", "png");

                                  while($row = mysqli_fetch_array($results)) {
                                    if(in_array($row['postFileType'], $extensions_arr)) {
                                      ?>

                                        <img src="<?php echo $row['post']; ?>" style="height: 25vh;" />

                                      <?php
                                    }
                                  }
                              ?>

    Previous

    Next

also the classes that were changed are these:
I changed dataride to data-ride changed item to carousel-item changed dataslide into data-slide but it still does not work

A: It looks like you're using the classes for a Bootstrap 3.* carousel As you said in the comments you have Bootstrap 4. The carousel structure is changed since Bootstrap 4. Try to convert your code to the new Bootstrap carousel structure.
https://getbootstrap.com/docs/4.5/components/carousel/
Edit:
You forgot to make an item active I've changed your code. (not tested)

        <?php
        $results = mysqli_query($mysqli, "SELECT * FROM `posts`");

        $extensions_arr = array("svg", "jpeg", "jpg", "png");

        $index = 0;
        while ($row = mysqli_fetch_array($results)) {
            if (in_array($row['postFileType'], $extensions_arr)) {
        ?>
                <div class="carousel-item <?= ($index === 0 ? 'active' : '') ?>">
                    <img src="<?= $row['post']; ?>" style="height: 25vh;" />

        <?php
            }
            $index++;
        }
        ?>

        Previous

        Next


text:
Q: Exchange data from Microsoft Business Central to JavaScript Curerntly I'am working on a scanner that inputs data into BC fields. The communication between the device and the software is in javascript.  I can send data from JS to BC with
 Microsoft.Dynamics.NAV.InvokeExtensibilityMethod('BarcodeRead',[BCode] );

but I couldn't figure out how to send data back to JS.  (The reader has a screen, and I need to display warehouse inventory on it based on BC data).
My current best guess would be to send data with STREAMS to a .txt file, and the JS code read from that. But that would be slow and not so reliable in my opinion.

A: As you know allready that InvokeExtensibilityMethod can trigger events on the BC side, you know that you need a  Control Add-In.
On the Microsoft Docs page about Control Add-Ins, there is an example which shows you how to call JS functions from BC:
    // The procedure declarations specify what JavaScript methods could be called from AL.
    // In main.js code, there should be a global function CallJavaScript(i,s,d,c) {Microsoft.Dynamics.NAV.InvokeExtensibilityMethod('CallBack', [i, s, d, c]);}
    procedure CallJavaScript(i: integer; s: text; d: decimal; c: char);

In BC lingo, procedures are kind of the opposite of events.

redpajama_set_name: RedPajamaStackExchange


text:
Q: VB script or Batch script to detect changes after autorefresh Can anyone help me with this?
I have VB script to auto refresh webpage every 20 seconds.
But i need one more feature.
i need alert message (messagebox or popup or just cmd prompt ) when there is a dfference between old webpage and autorefreshed webpage.
is it possible in VB or batch?
For autorefreshing i am using
Set IE = CreateObject("InternetExplorer.Application")
With IE
    .Navigate "http://www.yahoo.com"    ' change to actual site needed
    .Visible = True
End With

Do While True
    WScript.Sleep 10000    ' 10 seconds
    IE.Refresh()
Loop

From http://www.computerhope.com/forum/index.php?topic=23314.0

A: You can get the html response text, make a hash, and store it somewhere at first. On each subsequent refresh, repeat the procedure and compare the hash for any changes.
Edited: As an alternative, you can try the following
Dim init
Dim temp
init = GetString()

Do While True
    WScript.Sleep 10000    ' 10 seconds
    temp = GetString()
    If temp <> init Then
    MsgBox "Not Equal"
    Else
    MsgBox "Equal"
    End If
    init = temp
Loop

Function GetString()
    Dim o
    Set o = CreateObject("MSXML2.XMLHTTP")
    o.open "GET", "http://www.example.com", False
    o.send
    GetString=o.responseText
End Function


text:
Q: Calling Methods C++ with compile errors with the following program I am getting a ton of compile errors when i try and compile it. I think they have something to to with method calling. I am not familiar with c++ and don't know what is causing them. Can anyone help? Here is the source code:
#include <iostream>
using namespace std;
//getting the greatest common divisor to help reduce fractions
int GDC(int x, int y)
{
    int t;
     while (y!=0)
    {
        t=y;
        y=x%y;
        x=t;
    }
    return x;
}

//constructing a RationalNumber wit a numerator and a denominator as seperate elements.
//it also reduces the fraction as well as show them.
//prevents 0 in the denominator as well as avoid negative denominators
class RationalNumber
{
    public:
        RationalNumber(int num=0, int denom=0)
        {
            numerator=num;
            denominator=denom;
        }
        void show()
        {
            {
                cout << "(" << numerator <<"/";
                cout << denominator << ")";
            }
        }
        void reduce()
        {
            int reduction;
            reduction= GCD(numerator, denominator);
            numerator=numerator/reduction;
            denominator=denominator/reduction;

            if(denominator == 0)
            {
                cout << "Cannot compute with 0 denominator ";
            }
            if(denominator < 0)
            {
                cout << "Cannot compute negative demoninators ";
            }
            else
            {
                //simplifies fraction to a whole number when denominator is 1
                if(denominator == 1)
                {
                    cout << "(" << numerator <<")";
                }
                else
                {
                    cout << "(" << numerator <<"/";
                    cout << denominator << ")";
                }
            }
        }
        RationalNumber operator+(RationalNumber op2);
        RationalNumber operator-(RationalNumber op2);
        RationalNumber operator*(RationalNumber op2);
        RationalNumber operator/(RationalNumber op2);
        RationalNumber operator++();

    private:
        double numerator, denominator;
};

void Accept(int n)
{
    if(n<0)
    {
       cout << "Cannot have negatice denominators: ";
    }
    else if (n == 0)
        cout << "Cannot have zero in the denominator: ";
}

//Division
RationalNumber RationalNumer::operator/(RationalNumber op2)
{
    RationalNumber temp;
    int reduction;
    temp.numerator=(numerator*op2.denominator);
    temp.denominator=denominator*op2.numerator;
    cout << "Division:       ";
    return temp;
}

//Subtraction
RationalNumber RationalNumer::operator-(RationalNumber op2)
{
    RationalNumber temp;
    int reduction;
    temp.numerator=(numerator*op2.denominator)-(op2.numerator*denominator);
    temp.denominator=op2.denominator* denominator;
    cout << "Subtraction:       ";
    return temp;
}

//Multiplication
RationalNumber RationalNumer::operator*(RationalNumber op2)
{
    RationalNumber temp;
    temp.numerator=(op2.numerator*numerator);
    temp.denominator=op2.denominator* denominator;
    cout << "Multiplication:       ";
    return temp;
}

//Addition
RationalNumber RationalNumer::operator+(RationalNumber op2)
{
    RationalNumber temp;
    temp.numerator=(op2.numerator*denominator) + ((numerator)*(op2.denominator));
    temp.denominator=op2.denominator* denominator;
    cout << "Addition:       ";
    return temp;
}

RationalNumber RationalNumer::operator++()
{
    numerator++;
    denominator++;
    return *this;
}

void getFraction(int &x, int &y, int &z, int &t)
{
    cout << "First Fraction: ";
    cout << "\n";
    cout << "numerator: ";
    cin >> x;

    do
    {
        cout << "denominator: ";
        cin >> y;
        Accept(y);
        cout << "\n";
        cout << endl;
    }
    while(y <=0);

    cout << "Second Fraction: ";
    cout << "\n";
    cout << "numerator: ";
    cin >> z;
    do
    {
        cout << "denominator: ";
        cin >> t;
        Accept(t);
        cout << "\n";
        cout << endl;
    }
    while(t <=0);
}

void aftermath(int &x, int &y, int &z, int &t)
{
    RationalNumber obA, obS, obM, obD, ob2(x,y), ob3(z,t);
    char Math;
    cout << "Enter sign (+,-,*,/):  ";
    cin >> Math;
    if(Math == '+')
    {
        obA=ob2+ob3;
        obA.reduce();
        cout << "\n";
    }
    else if(Math == '-')
    {
        obS=ob2-ob3;
        obS.reduce();
        cout << "\n\n";
    }
    else if(Math == '*')
    {
        obM=ob2*ob3;
        obM.reduce();
        cout << "\n\n";
    }
    else if(Math == '/')
    {
        obD=ob2/ob3;
        obD.reduce();
        cout << "\n\n";
    }
    else
        cout << "Invalid sign";
}

int main()
{
    char answer;
    do
    {
        int x,y,z,t = 0;
        getFraction(x,y,z,t);
        RationalNumber obA, obS, obM, obD, ob2(x,y), ob3(z,t);

        ob2.show();
        cout <<" ";
        ob3.show();
        cout << "\n\n";
        aftermath(x,y,z,t);
        cout << "\n\n";
        cout << "Create another fraction? - y or n? ";
        cin >> answer;
        cout << "\n";
    }
    while((answer == 'y'));

    if((answer != 'y'))
    {
        cout << "GOOD-BYE ";
    }
    return 0;
}

and here are the compile errors:
g++ -o Math math.cpp
math.cpp: In member function 'void RationalNumber::reduce()':
math.cpp:37: error: 'GCD' was not declared in this scope
math.cpp: In function 'void getFraction(int&, int&, int&, int&)':
math.cpp:136: error: invalid operands of types '<unresolved overloaded function type>' and 'const char [2]' to binary 'operator<<'
math.cpp:151: error: invalid operands of types '<unresolved overloaded function type>' and 'const char [2]' to binary 'operator<<'

A: (Note: Kyle has updated the output since I posted the answer, so some of this lacks the proper context.)
First error: You're calling "GCD" but your function is called "GDC".
Second error: "RationalNumer" not "RationalNumber".
Most or all of the other errors will go away when you fix the second one in all the places it occurs (and there are five of them - search for "RationalNumer").
New error in updated output - another typo: count << "\n"; should be cout << "\n";.
Two pieces of general advice:

*

*Read the error messages.  8-)  Often they'll appear to be impenetrable jargon, or be simply lying, but often the answer really is in there.

*Only ever worry about the first error.  More often than not, fixing that will make some or all of the others go away.


text:
Q: Edit and reload MVC 4 model with jquery I am wondering if there is a way to edit a MVC 4 model then reload the view with the new model from jQuery. The basics of what I am trying to do is I have a page that has weeks of dates and text boxes after each date. This page is for a time card site. The model contains the days of the week and the name of the days for that date. What I am want to modify is the dates in the model so if a user is on this week and realizes they forgot to enter there time for last week they can click a button that takes the to enter time for the last week. I have function to get the dates and the days of the week just not sure how to edit the model and reload it.
The site controllers in C# code samples or any idea would be helpful.

A: You should look into communicating with your server using jQuery/AJAX. Serialize you model into JSON, modify it in your controller and send it back. You can then update your view with the new data.


text:
Q: How to move functions from Shiny App to Global.R file? I'm working on a Shiny App that uses lengthy text explanations in the modalDialog functions. User clicks on an Action Button and the explanation pops up in a dialogue box. I'd like to move these long text functions out of the App file (containing UI and Server) into a separate Global.R file to clean up the code, make it more readable. Why does my below attempt not work? I'm sure the solution is simple. It's addressed in several other Stack Exchange posts but the solutions presented don't seem to work in this case.
Below is a MWE of where I am currently in creating a separate Global.R (both files are saved in the same directory):
App.R file (the function it's reaching out to in Global.R file is called "AbeLincoln"):
library(shiny)
source("./Global.R")

ui <- fluidPage(style = "margin-top:20px",
  fluidRow
    (column(12,
          actionButton("explain1",
          strong("Gettyburg Address"),
          icon = icon("info-circle"),
          style="font-size:19px;
                 position:fixed")
     ) # closes column
  ), # closes fluid row
)  # fluid page

server <- function(input, output) {
  AbeLincoln(input$explain1)
} # closes server

shinyApp(ui = ui, server = server)

Global.R file containing the Observe Event that responds to the Action Button and all the text:
AbeLincoln <- function(x){

observeEvent(x, {
    showModal(modalDialog(

      title = "Background and text of the Gettysburg Address",

      tags$ul(

        tags$li("Gettysburg Address is a speech that Abraham Lincoln delivered at
                 the dedication of the Soldiers' National Cemetery in Gettysburg, PA."),
        tags$li("On the afternoon of November 19, 1863."),
        tags$li("Four and a half months after the Union armies defeated those of the
                 Confederacy at the Battle of Gettysburg."),
        tags$li("It is one of the best-known speeches in American history.")),

      tags$p(strong("Text of speech:")),

        "Four score and seven years ago our fathers brought forth upon this continent,
        a new nation, conceived in Liberty, and dedicated to the proposition that all men
        are created equal.",tags$p(""),
        "Now we are engaged in a great civil war, testing whether that nation, or any
        nation so conceived and so dedicated, can long endure. We are met on a great
        battle-field of that war. We have come to dedicate a portion of that field, as
        a final resting place for those who here gave their lives that that nation might
        live. It is altogether fitting and proper that we should do this.",tags$p(""),

        "",tags$p(""),

        "But, in a larger sense, we can not dedicate—we can not consecrate—we can not
        hallow—this ground. The brave men, living and dead, who struggled here, have
        consecrated it, far above our poor power to add or detract. The world will little
        note, nor long remember what we say here, but it can never forget what they did here.
        It is for us the living, rather, to be dedicated here to the unfinished work which
        they who fought here have thus far so nobly advanced. It is rather for us to be here
        dedicated to the great task remaining before us—that from these honored dead we take
        increased devotion to that cause for which they gave the last full measure of devotion
        — that we here highly resolve that these dead shall not have died in vain—that this
        nation, under God, shall have a new birth of freedom—and that government of the
        people, by the people, for the people, shall not perish from the earth."

      ) # close modal dialog
    ) # close show modal
  }) # close observe event
} # close function

Here is how the App is supposed to work. I present images below instead of posting the combined code above without Global.R.
First prompted with action button:

After clicking the action button this is what you get:

A: The observeEvent function assumes you are passing in an unquoted value. It's trying to observe x and not input$explain1. To make it more general, you should pass in the input to your function.
Change your wrapper to something like
AbeLincoln <- function(input, value){
  observeEvent(input[[value]], {
    showModal(modalDialog(  ...) )
  }
}

and then your server would be
server <- function(input, output) {
  AbeLincoln(input, "explain1")
}

Alternatively you could mess with the observeEvent parameters and use non-standard evaluation on the AbeLincoln function. So you could do
AbeLincoln <- function(x){
  x <- substitute(x)
  observeEvent(x,
    event.quoted=TRUE, event.env=parent.frame(), {
    showModal(modalDialog(  ...) )
  }
}

or, alternatively,
AbeLincoln <- function(...) {
  observeEvent(..., event.env=parent.frame(), {
    showModal(modalDialog(  ...) )
  }
}

And your server functions could still be
server <- function(input, output) {
  AbeLincoln(input$explain1)
}

It really just depends on what you find more intuitive I guess.


text:
Q: Loop on each level of a factor What finally worked was:
        a <- cast(we, year ~ region, mean, value='response')

Although, I only have 1 observation per region and site, so mean is just a workaround. I couldn't get c to work as a function.

*

*Output for suggested answer (by Justin)
    > DT
    > response year
    > 1:      15 2000
    > 2:       6 2000
    > 3:      23 2000
    > 4:      23 2000
     ---
    > 794:       3 2010
    > 795:       5 2010
    > 796:       1 2010

*Update: desired output should look like:
   > Year   x1  x2  x3   x4
   > 2000   4   5   16   22
   > 2001   6   11   2   18
   > 2002   1   0   21   10
   > ...

I am struggling to find a way to transpose my data based on factor levels. I have data with 2 columns, a factor and a response. I have many rows for each factor, so I want to transpose the table such that each factor is on one row, with the different responses as a column in that row. I cannot seem to subset within a loop based on levels of that factor. I would appreciate any insight.
example of data:
          > response    year
          > 5           2001
          > 10          2001
          > 8           2001
          > 1           2002
          > 7           2010

  > levels(data$year)
  [1] "2000" "2001" "2002" "2003" "2004" "2005" ...
  w <- matrix(0,54,15)

  for(i in 1:levels(data$year)){
    w[i] <- levels(data$year)==i
  }

This syntax is obviously not correct, but it is the idea of what I'm trying to accomplish.
Thank you.

A: Using the data.table package this is trivial:
library(data.table)
DT <- data.table(data)
DT[, as.list(value), by=year]

However, this will fall apart if you have different numbers of observations per year.  Instead:
DT[, list(values = list(value)), by=year]

Or using base R:
tapply(data$value, data$year, c)

A: Here's another way, using aggregate:
> set.seed(1)
> data <- data.frame(year = rep(2000:2010, each=10), value = sample(3:30, 110, TRUE))
> aggregate(value~year, data=data, FUN=c)
   year value.1 value.2 value.3 value.4 value.5 value.6 value.7 value.8 value.9 value.10
1  2000      10      13      19      28       8      28      29      21      20        4
2  2001       8       7      22      13      24      16      23      30      13       24
3  2002      29       8      21       6      10      13       3      13      27       12
4  2003      16      19      16       8      26      21      25       6      23       14
5  2004      25      21      24      18      17      25       3      16      23       22
6  2005      16      27      15       9       4       5      11      17      21       14
7  2006      28      11      15      12      21      10      16      24       5       27
8  2007      12      26      12      12      16      27      27      13      24       29
9  2008      15      22      14      12      24       8      22       6       9        7
10 2009       9       4      20      27      24      25      15      14      25       19
11 2010      21      12      10      30      20       8       6      16      28       19

A: If I had a different number of responses per year, I would probably come at this problem by first making a new variable to represent the response in each year and then casting that dataset out using dcast.  By default dcast fills in missing values with NA, although you can change that if needed.
set.seed(1)
data = data.frame(year = c(rep(2000:2010, each=10), 2011), value = sample(3:30, 111, TRUE))

require(reshape2)
require(plyr)
# Create a new variable representing the number of responses per year and add to dataset
dat2 = ddply(data, .(year), transform,
              response = interaction("x", 1:length(value), sep = ""))

dcast(dat2, year ~ response, value.var = "value")


text:
Q: I want to remove the top ImageView in RelativeLayout when a ImageView is added at bottom of stack but it is removing whole layout //here is my recyclerview onScrollEvent
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
    @Override
    public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
        super.onScrollStateChanged(recyclerView, newState);
    }

    @Override
    public void onScrolled(final RecyclerView recyclerView, int dx, int dy) {
        super.onScrolled(recyclerView, dx, dy);
        final int positionView = ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastVisibleItemPosition();
        if (dy > 0) {
            if (positionView >= 3) {
                final View view = recyclerView.getChildAt(3);
                if (view != null && recyclerView.getChildAdapterPosition(view) == positionView) {
                    TranslateAnimation translateAnimation = new TranslateAnimation(0, 0, 200, 0);
                    translateAnimation.setAnimationListener(new Animation.AnimationListener() {
                        @Override
                        public void onAnimationStart(Animation animation) {
                            recyclerView.smoothScrollToPosition(positionView);
                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                            view.clearAnimation();
                        }

                        @Override
                        public void onAnimationRepeat(Animation animation) {

                        }
                    });
                    translateAnimation.setDuration(350);
                    view.setAnimation(translateAnimation);

                }
                createStackImageView();
                for (int i = stackView.getChildCount()-1; i >=1; i--) {
                    ResizeAnimation resizeAnimation = new ResizeAnimation(stackView.getChildAt(i));
                    resizeAnimation.setHeights(stackView.getChildAt(i).getHeight(), stackView.getChildAt(i - 1).getHeight());
                    resizeAnimation.setWidths(stackView.getChildAt(i).getWidth(), stackView.getChildAt(i - 1).getWidth());
                    resizeAnimation.setDuration(250);
                    stackView.getChildAt(i).startAnimation(resizeAnimation);
                    if(i==1){
                            stackView.removeView(stackView.getChildAt(i));
                            stackView.invalidate();
                            stackView.requestLayout();
                        }
                }
                stackView.invalidate();
            }
        } else {

        }
    }
});

//And this is the method where i create a imageview in relativelayout
private void createStackImageView() {
    fourthStack = new ImageView(getActivity());
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams
        (1, 1);
    layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    fourthStack.setLayoutParams(layoutParams);
    fourthStack.setScaleType(ImageView.ScaleType.CENTER_CROP);
    Random rnd = new Random();
    int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256));
    fourthStack.setBackgroundColor(color);
    fourthStack.requestLayout();
    stackView.addView(fourthStack, layoutParams);
}

Now my main problem is when the RecyclerView is scrolled i create image at bottom so that there is number of stack dynamically.When this ImageView is created at bottom the top most image in RelativeLayout should be removed so that there will be no memory issue.But what happens for me is it is removing the whole stack i have created. I cannot figure out why this is happening.

A: When u remove the ImageView from top It might have a relative connection to the bottom elements. So when you remove the image from top the views with relative connection to the removed view would go invisible. If you are using GONE method to remove the top view Try using Invisible and check whether the same is happening


text:
Q: scheduled tasks don't show up in Get-ScheduledTask result I have defined some scheduled task using Windows Task Scheduler GUI under "" [default] path but when i run Get-ScheduledTask in powershell, it does not return them. why?
I have tried with Get-ScheduledTask -TaskName "MyTaskName" with one of my task name but it comes up with "No MSFT_ScheduledTask objects found with property 'TaskName' equal to 'MyTaskName'"
Actually I have tried https://library.octopusdeploy.com/step-template/actiontemplate-windows-scheduled-task-disable but it doesn't work so I have tried running script directly.
UPDATE
I have found the following script to get task list on http://www.fixitscripts.com/problems/getting-a-list-of-scheduled-tasks:
# PowerShell script to get scheduled tasks from local computer
$schedule = new-object -com("Schedule.Service")
$schedule.connect()
$tasks = $schedule.getfolder("\").gettasks(0)
$tasks  | Format-Table   Name , LastRunTime    # -AutoSize
IF($tasks.count -eq 0) {Write-Host "Schedule is Empty"}
Read-Host

A: Have you tried using a com object? This code works for me:
# FOR A REMOTE MACHINE
$s = 'SERVER_NAME' # update this with server name
($TaskScheduler = New-Object -ComObject Schedule.Service).Connect($s)

# FOR LOCAL MACHINE
($TaskScheduler = New-Object -ComObject Schedule.Service).Connect()

#now we can query the schedules...
cls;$TaskScheduler.GetFolder('\').GetTasks(0) | Select Name, State, Enabled, LastRunTime, LastTaskResult | Out-GridView

This code will retrieve a particular task and enable it:
$task = $TaskScheduler.GetFolder('\').GetTask("TASKNAME")
$task.Enabled = $true

A: When running Get-ScheduledTask from a user-level prompt, even if the user is an administrator, they will see only the tasks that they can read with user-level permissions. Seeing them in the TaskSchd.Msc window indicates that program is running with different permissions.
Therefore, running a PowerShell prompt as administrator solves the problem.
The same issue occurs when using SchTasks.exe from a command prompt.

A: UAC
The result is likely affected by UAC. To see everything try right clicking the PowerShell icon, select Run as Administrator and then run your Get-ScheduledTask command again and see if that changes anything.
Further reading: http://david-homer.blogspot.co.uk/2017/10/not-all-scheduled-tasks-show-up-when.html


text:
Q: Why do I have to restart the Django server every time I make some changes in views? I am new to Django and every time I make a change in veiws.py or urls.py I have to run python manange.py run server. This is hectic as for every small change I have to restart the server. Is there any fix? Or is this normal?

A:
check your TEMPLATES of 'settings.py`.

If you have defined your DIRS something like this:
'DIRS': [BASE_DIR , 'templates'],

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR , 'templates'],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

So change it to 'DIRS': [BASE_DIR / 'templates'], if you don't do this it will cause the server to restart again and again.
like this:

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates'],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

It may solve your problem.


text:
Q: Count the number of worksheets in excel using VB.Net I am trying to build a code that counts all the worksheets in VB.Net If the worksheet does not exist, then I want the code create the sheet. Here's what I came up with so far. I have this written in VBA, but I need to translate this into VB.Net
  'Define the variables for creating you new sheet
    Dim WorksheetCounter    As Integer
    Dim Exists              As Boolean

   For WorksheetCounter = 1 To Worksheets.Count
    If Worksheets(WorksheetCounter).Name = "Apples" Then
        Exists = True
    End If

   Next WorksheetCounter

   If Not Exists Then
    Sheets.Add.Name = "Apples"
   End If


text:
Q: Targeting UI elements dynamically with Appcelerator Alloy? Is there a way to target a specific alloy UI element by passing a variable? I would like to pass a variable like so:
controller.js
var flag = "se";
changeBackground(flag); //should change the background color of ImagView of the se flag

function changeBackground(elementToChange){
    elementToChange.backgroundColor = "red"; //does not work
   $. + elementToChange +  backgroundColor = "red"; //does not work
}

view.xml
<View id="flagRow" layout="horizontal" backgroundColor="blue" height="Ti.UI.SIZE">
    <ImageView id="se" height="20dp" left="5dp" image="/images/flags/se.png" onClick="downloadPastLanguageLevels"/>
    <ImageView id="de" height="20dp" left="10dp" image="/images/flags/de.png" onClick="downloadPastLanguageLevels"/>
    <ImageView id="en" height="20dp" left="10dp" image="/images/flags/en.png" onClick="downloadPastLanguageLevels"/>
            </View>

Right now I am looping through the $.flagRow. container but I would rather know how to set the flag directly.
var i, view;
    for (i in $.flagRow.children) {
            view = $.flagRow.children[i];
            if (view.id.indexOf(flag) > -1) {
                view.backgroundColor = "red";
            } else {
                view.backgroundColor = "transparent";
            }
        }

A: You reference elements in a view from the controller by using $.id so if you had an element called "myButton" you would reference it as $.myButton. If you were passing the name as a variable to a function expecting a parameter called "element" then you'd address it as $[element] where element is a string representing the id so "myButton" in this case.
In your case changing the code to reference $[elementToChange] should do it.


text:
Q: Using PTY as a proxy for remote serial port I'm working on an IO expansion device.
Among other things, it exposes a bunch of serial ports, which I want to expose on my Linux host as /dev/ttySomethingN
I could write a TTY kernel module for that, but I'd like to keep it on userspace for now.
The solution I've found is to use a PTY as a proxy: The master side talks to my device and the slave talks to my applications, and I use TIOCPKT_IOCTL to know when the device needs to reconfigure its speed/bits/parity/stop bits.
It works pretty well! See my source
But there is one little issue: I cannot set the number of bits (CS5/CS6/CS7) or parity (PARENB) in a PTY:
Any ideas why this restriction is in place? And how to work around it?


text:
Q: How to find IP addresses in OpsWorks I am not good with Ohai. I would like to know if there is any way to find out all ip address (including own) of nodes from respective subnet through Chef recipe.
I have created one layer in AWS Opswork and want to add each node's ip addr and hostname in the configuration file. Any help will highly appreciated.

A: So this depends a little bit on if you want to get all the instances in a layer, or all the total instances in your stack.
For the first, something like this - untested! - code for your recipe should work:
my_layer_name = "my_database_layer_or_whatever"

node[:opsworks][:layers][my_layer_name][:instances].each do |current_instance, current_instance_data|

    puts node[:opsworks][:layers][my_layer_name][:instances][current_instance][:private_dns_name]
end

Note that this will get you the private dns name - so internal to the OpsWorks network. You may or may not want that - there are a dozen or so other attributes on the object, including the public IP address.
If you wanted to get instances for the entire stack, I'm betting you could loop through node[:opsworks][:layers], as I've looped through the instances here. Just another loop.
Also note this code is for Chef 11. In Chef 12 things have changed a bit.
If you're using Chef 12, I found the documentation on how to use/search the Chef Data Bags for OpsWorks.


text:
Q: Keycloak - using admin API to add client role to user I'm triyng to use keycloak AdminAPI (https://www.keycloak.org/docs-api/3.0/rest-api/index.html#_users_resource) to create user and assign client roles. I'm receiving correct token, and user is created but assigning roles return 404
I'm using Postman to connect with API:
/auth/realms/{realmName}/protocol/openid-connect/token
Content-Type application/x-www-form-urlencoded <-with parameters ofc
/auth/admin/realms/{realmName}/users

Content-Type application/json
Authorization Bearer {TOKEN}
Body:

{
   "username": "name",
   "enabled": true,
   "emailVerified": false,
   "firstName": "first",
   "lastName": "last",
   "credentials": [
       {
           "type": "password",
           "value": "newPas1*",
           "temporary": false
       }
   ]
}

Above works for me, but the next one don't
/auth/admin/realms/{realmName}/users/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/role-mappings/clients/realm-management

Content-Type application/json
Authorization Bearer {TOKEN}
Body:

{
   "roles": [
       {
           "id": "0830ff39-43ea-48bb-af8f-696bc420c1ce",
           "name": "create-client",
           "description": "${role_create-client}",
           "composite": false,
           "clientRole": true,
           "containerId": "344e7c81-e7a2-4a43-b013-57d7ed198eee"
       }
   ]
}

where 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx' is userID returned during creation and create-client role exists
I need a way to add client role via Http request. I saw there are some keycloack implementation for java but I'm using .NET CORE so there will be the target implementation but I need to have working request first as you may gues

A: You have to pass client UUID to the role-mappings REST method, not the ID that you specify when creating a client in admin UI. Use GET /admin/realms/{realm}/clients?clientId=realm-management REST method to find out the client UUID.
UPDATE
In Keycloak 6.0.1 to add a role it is required to pass role name and id.
Example:
POST /auth/admin/realms/{realm}/users/{user}/role-mappings/clients/{client}

[
  {
    "id": "0830ff39-43ea-48bb-af8f-696bc420c1ce",
    "name": "create-client"
  }
]


text:
Q: Is $\overline{\{x: f(x) < a\}} = \{x: f(x) \leq a\}$? Let $f: \mathbb{R}^{2} \rightarrow \mathbb{R}$ be a continuous function. Is $\overline{A} =\overline{\{x: f(x) < a\}} = \{x: f(x) \leq a\} = B$?
Since $B$ is closed and contains $A$, $\overline{A} \subset B$ as $\overline{A}$ is the smallest closed subset containing $A$. It remains to show $B \subset \overline{A}$. Let $x \in B$. If $f(x) < a$, then we are done. Now suppose $f(x) = a$. There exists $x_{n} \in \mathbb{R}^{2}$ such that $x_{n} \rightarrow x$. However, I cannot guarantee that $f(x_{n}) < a$.

A: Yes you are right, to see a counterexample take $ f(x,y)=a$.

A: Consider $f(x,y)=x^2+y^2$ and $a=0$. Then one set is empty and the other is a singleton.


text:
Q: Google indexes my sitemap as webpage I have the following problem. My sitemap's content is shown in GOOGLE search results. There is a link to the sitemap on the main page. That can cause it. I have added this URL to GOOGLE as sitemap and I would like it to be treated as sitemap only, not as sitemap and webpage. How do I tell GOOGLE not to index it as webpage? Using robots.txt?
Thank you

A: The problem is that google is indexing everything where they find links to.
You can prevent them with robots.txt as you stated.
robots.txt
Personally I have nerver seen something like that...
If you link to your website somewhere and tell us which URL you added to GOOGLE as sitemap I could take a look at it and see if it has something to do withthe way your site is built.
Hope this helps :-) tell me if you need any more info


text:
Q: Evaluation of $\sum\limits_{k=1}^n\left(x^{k}+\frac{1}{x^k}\right)^k$ Can anyone find a simplified expression for the sum $\displaystyle \sum_{k=1}^n\left(x^{k}+\frac{1}{x^k}\right)^k$? I have tried expanding the first few terms but it gets a little messy with no clear leads. I suspect formulae for geometric series may come into it somehow, but at the moment it isn't clear how to start.

A: Let $S(n)$ be your sum.
For $1 \le m \le n^2$, the coefficient of $x^m$ (and of $x^{-m}$, by symmetry) in $S(n)$ is
$$ [x^m]\; S(n) = \sum_k {k \choose \frac{m}{2k}+\frac{k}{2}}$$
where the sum is over all divisors $k$ of $m$ such that $m \le k^2 \le n^2$
and $\frac{m}{k} \equiv k \mod 2$.  In particular this is $0$ if $m \equiv 2 \mod 4$.
The coefficient of $x^0$ in $S(n)$ is $$ [x^0] \; S(n) = \sum_{j=1}^{\lfloor n/2 \rfloor} {2j \choose j}$$

A: Not an answer, just a long comment;
Not sure how to proceed, but one way to rewrite it is $x=e^{i\phi}$, getting
$$\sum_{k=1}^n (2\cos k\phi)^k=\sum_{k=1}^n 2^k T_k^k(\cos(\phi))$$
where $T$ is a Chebyshev polynomial of the first kind.
It seems to me that the expression is too convoluted to expect a nice solution. Another similar approach that might be considered is to express everything with $x+x^{-1}$. We have expressions of the type
$$(x+x^{-1})^2=2+(x^2+x^{-2})$$
$$(x+x^{-1})^3=3(x+x^{-1})+(x^3+x^{-3})$$
which could be solved for $x^k+x^{-k}$ but I can't see how to get a closed form for a general term. This solution does give you the constant term (reproduces result by @RobertIsrael) but the rest gets complicated due to $()^k$ - we get summations over very strange sets.
A reference that might be useful - it includes some very similar expressions.


text:
Q: How to pipe binary data into numpy arrays without tmp storage? There are several similar questions but none of them answers this simple question directly:
How can i catch a commands output and stream that content into numpy arrays without creating a temporary string object to read from?
So, what I would like to do is this:
import subprocess
import numpy
import StringIO

def parse_header(fileobject):
    # this function moves the filepointer and returns a dictionary
    d = do_some_parsing(fileobject)
    return d

sio = StringIO.StringIO(subprocess.check_output(cmd))
d = parse_header(sio)
# now the file pointer is at the start of data, parse_header takes care of that.
# ALL of the data is now available in the next line of sio
dt = numpy.dtype([(key, 'f8') for key in d.keys()])

# i don't know how do make this work:
data = numpy.fromxxxx(sio , dt)

# if i would do this, I create another copy besides the StringIO object, don't I?
# so this works, but isn't this 'bad' ?
datastring = sio.read()
data = numpy.fromstring(datastring, dtype=dt)

I tried it with StringIO and cStringIO but both are not accepted by numpy.frombuffer and numpy.fromfile.
Using StringIO object I first have to read the stream into a string and then use numpy.fromstring, but I would like to avoid creating the intermediate object (several Gigabytes).
An alternative for me would be if I can stream sys.stdin into numpy arrays, but that does not work with numpy.fromfile either (seek needs to be implemented).
Are there any work-arounds for this? I can't be the first one trying this (unless this is a PEBKAC case?)
Solution:
This is the current solution, it's a mix of unutbu's instruction how to use the Popen with PIPE and the hint of eryksun to use bytearray, so I don't know who to accept!? :S
proc = sp.Popen(cmd, stdout = sp.PIPE, shell=True)
d = parse_des_header(proc.stdout)
rec_dtype = np.dtype([(key,'f8') for key in d.keys()])
data = bytearray(proc.stdout.read())
ndata = np.frombuffer(data, dtype = rec_dtype)

I didn't check if the data is really not creating another copy, don't know how. But what I noticed that this works much faster than everything I tried before, so many thanks to both the answers' authors!
Update 2022:
I just tried above solution steps without the bytearray() step and it just works fine. Thanks to Python 3 I guess?

A: You can use Popen with stdout=subprocess.PIPE. Read in the header, then load the rest into a bytearray to use with np.frombuffer.
Additional comments based on your edit:
If you're going to call proc.stdout.read(), it's equivalent to using check_output(). Both create a temporary string. If you preallocate data, you could use proc.stdout.readinto(data). Then if the number of bytes read into data is less than len(data), free the excess memory, else extend data by whatever is left to be read.
data = bytearray(2**32) # 4 GiB
n = proc.stdout.readinto(data)
if n < len(data):
    data[n:] = ''
else:
    data += proc.stdout.read()

You could also come at this starting with a pre-allocated ndarray ndata and use buf = np.getbuffer(ndata). Then readinto(buf) as above.
Here's an example to show that the memory is shared between the bytearray and the  np.ndarray:
>>> data = bytearray('\x01')
>>> ndata = np.frombuffer(data, np.int8)
>>> ndata
array([1], dtype=int8)
>>> ndata[0] = 2
>>> data
bytearray(b'\x02')

A: Since your data can easily fit in RAM, I think the easiest way to load the data into a numpy array is to use a ramfs.
On Linux,
sudo mkdir /mnt/ramfs
sudo mount -t ramfs -o size=5G ramfs /mnt/ramfs
sudo chmod 777 /mnt/ramfs

Then, for example, if this is the producer of the binary data:
writer.py:
from __future__ import print_function
import random
import struct
N = random.randrange(100)
print('a b')
for i in range(2*N):
    print(struct.pack('<d',random.random()), end = '')

Then you could load it into a numpy array like this:
reader.py:
import subprocess
import numpy

def parse_header(f):
    # this function moves the filepointer and returns a dictionary
    header = f.readline()
    d = dict.fromkeys(header.split())
    return d

filename = '/mnt/ramfs/data.out'
with open(filename, 'w') as f:
    cmd = 'writer.py'
    proc = subprocess.Popen([cmd], stdout = f)
    proc.communicate()
with open(filename, 'r') as f:
    header = parse_header(f)
    dt = numpy.dtype([(key, 'f8') for key in header.keys()])
    data = numpy.fromfile(f, dt)


text:
Q: Update calling activity after PreferenceScreen close? I have an activity A from where I invoke a PreferenceAvtivity P via a normal startActivity.
The user can update some settings there, and after the P is closed, activity A should update itself to get the new settings.
Now I've read here How to return from preference screen to main activity? that you should not/must not open the preferences via startActivityForResult, but rather implement an OnSharedPreferenceChangeListener in activity A.
My problem here is, the updating task in activity A might be a heavy one, and when activity A listens to PreferenceChanges, it updates whenever something was changed in P.
--> I need A to update only once, this is after P is closed.
How can I do that?

A: Simple: Read relevant preferences in onResume() of activity A.
Edit: Great nick btw


text:
Q: Why raster layer name change to default when using raster::calc function? Why raster layer name change to default when using raster::calc function, but not when using Arith-methods:
Toy example copied from Reference manual (calc function).
library(raster)
r <- raster(ncols=36, nrows=18)
r[] <- 1:ncell(r)
names(r) <- "Band1"
r

rc1 <- calc(r, function(x) { x * 10 })
names(rc1) # Default name "layer"

#But when:
rc2 <- r*10
names(rc2) #It conserves the name "Band1"

I did not find an easy way to check the calc function code?

A: There's no mention of what happens with layer names in the documentation for calc so I suspect the answer is "just because". If you rely on layer  names in your code then you should probably explicitly set them any time you think they might change.
Note that arithmetic can change layer names - even though both operands here have the same name, the output is different:
> names(r)
[1] "Foo"
> names(r*r)
[1] "layer"

Even simple functions of one raster can change layer names:
> names(r)
[1] "Foo"
> names(sqrt(r))
[1] "layer"

I think the best advice is to treat layer names as fragile and reset them when you need them, copying them from source rasters at the start of a processing step.
I'm not sure there's always a sensible default when doing arithmetic - suppose you are doing operations on more than one raster, which one do you use? Simpler to let the user decide. The setNames function comes in very handy here:
Two rasters with differing names:
> names(r)
[1] "Foo"
> names(q)
[1] "Bar"

When multiplied, returns neither:
> names(r*q)
[1] "layer"

Wrap in setNames and get a raster:
> rq = setNames(r*q, names(q))
> rq2 = setNames(r*q, names(r))

With whichever names you ask for:
> names(rq)
[1] "Bar"
> names(rq2)
[1] "Foo"
>

a = setNames(b, n) is essentially the same as a = b; names(a)=n; return(a)


text:
Q: Assigned icon to Windows 10 folder doesn't show I created desktop.ini files for a number of folders programmatically, like folders having "picture" in it should show a camera icon. The desktop.ini files look like this:
[.ShellClassInfo]
IconResource=D:\Images\Icons\camera.ico,0

and I made the files system and hidden. And checked that the .ico file exists.
Yet none of the icons show. I tried rebuilding the icon cache, but got "access denied" responses when I tried to delete the cache DB (and yes, I cancelled the Explorer task first).
Anyhoo, rebuilding the cache shouldn't be necessary, since assigning an icon manually through properties and customize does work.
Do I have to send a notification message to the OS when I create the desktop.ini files? Or what else is different between assigning the icon manually or programmatically?

edit
To clarify, by "programmatically" I mean an executable (.exe), not a PowerShell or other script. The distinction may be relevant.

A: For Explorer to process the desktop.ini file, the folder must have its Read-only or System attribute set.
You can use the attrib command from a Command Prompt or PowerShell:
attrib +r "c:\myfolder"

In PowerShell:
(get-item "c:\myfolder").Attributes += 'Readonly'

Check the folder's attributes by adding the Attributes column to a Details view:


text:
Q: How to configure annotations processing in IntelliJ IDEA 14 for current project work? The structure of the project is:

*

*Parent project

*

*A project (Spring) have dependency of project B in pom.xml

*B project (Spring MVC) have dependency of project A in pom.xml

After launching project B in Tomcat 7, I have an error:

Error:java: Annotation processing is not supported for module cycles.
  Please ensure that all modules from cycle [A,B] are excluded from
  annotation processing

How do I avoid this problem?
I use Java 8, Tomcat 7 and Intellij Idea 14.

A: To solve these kind of problems need to use Analyze Module dependencies in InteliJ-idea.
File Menu > Analyze > Module Dependencies
This shows the list of all projects which have cyclic dependencies and should be resolved first.
This feature helps you to find the problem.
EDIT – For the latest version, it is Analyze -> Analyze Module Dependencies..

A: If the circular dependency is wrong then open Module Settings and remove it from the module(s) that should not have it.
If the dependency is correct then uncheck the Enable annotation processing box in File | Settings | Build, Execution, Deployment | Compiler | Annotation Processors

A: In addition to Mikhails answer, here is how to fix it:
When you saw which modules have cyclic dependencies, right-click your project and
Open Module Settings -> Expand the according module-group and select the module -> Dependencies -> select and remove it

A: Going into Settings->Build->Compiler->Annotation Processors and disabling it solved it.
Allowing Test-A to depend on B, even though B depends on A
I'm using IntelliJ2019.1
But it's sad it doesn't seem to consider the maven test scope

A: An alternative in order to solve this problem that worked for me (the above answers didn't).
Go to the pom.xml from the package / project that you have.
Delete the tag that is causing the issue.
You can find the dependecy with the issue in the console.
Hope it helps. :)


text:
Q: D'Alembertian and index notation Is $$\partial_{\alpha}\partial^{\alpha}\phi $$ the same as $$\partial^{\alpha}\partial_{\alpha}\phi $$ ?
Could you explain why, please?

A: No they are not the same.
$$ \partial^\alpha\partial_\alpha \phi = g^{\alpha\beta}\partial_\beta\partial_\alpha \phi $$
while
$$ \partial_\alpha\partial^\alpha \phi = \partial_\alpha g^{\alpha\beta}\partial_\beta \phi =  g^{\alpha\beta} \partial_\alpha\partial_\beta \phi +(\partial_\alpha g^{\alpha\beta})(\partial_\beta \phi) $$.
Hence if $\phi$ is sufficiently smooth to exchange the order of partial derivatives
$$ \partial_\alpha\partial^\alpha \phi - \partial^\alpha\partial_\alpha \phi = (\partial_\alpha g^{\alpha\beta})(\partial_\beta \phi)$$.
So unless $\partial_\alpha g^{\alpha\beta} = 0$ (which is true for example in Minkowski space). The two are not equal.


text:
Q: Core Data crash when not connect to Xcode both device and simulator My app runs on both the device and in simulator when connected to Xcode. Other wise it crashes at this point (On both device / simulator when run without Xcode). Must be the debugger keeping it alive or something. I think the crash is coming from:
CDObject * cdObject = [NSEntityDescription insertNewObjectForEntityForName:@"CDObject" inManagedObjectContext:self.moc];

I use Core Data else where in the program and it is working fine.
I've verified that the self.moc is not nil through NSLog statements. Here is part of the crash report..
    Date/Time:       2011-12-06 10:19:39.146 -0500
OS Version:      iPhone OS 5.0 (9A334)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x3d6936a8
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x362b6fca objc_msgSend + 30
1   CoreFoundation                  0x374276ea CFDictionarySetValue + 102
2   CoreData                        0x317082ec _PFCMT_SetValue + 852
3   CoreData                        0x31769b90 -[NSManagedObjectContext(_NSInternalAdditions) _insertObjectWithGlobalID:globalID:] + 60
4   CoreData                        0x31760aba -[NSManagedObjectContext insertObject:] + 134
5   CoreData                        0x31707d56 -[NSManagedObject initWithEntity:insertIntoManagedObjectContext:] + 538
6   CoreData                        0x3173f5ce +[NSEntityDescription insertNewObjectForEntityForName:inManagedObjectContext:] + 174


text:
Q: What is the significance of the name "telophase topology"? Steen and Seebach, in their Counterexamples in Topology (2ed, 1978) define the "telophase topology" as:
"Let $(X, \tau)$ be the topological space formed by adding to the ordinary closed unit interval $[0,1]$ another right-hand end point, say $1^*$, with the sets $(a,1) \cup \{1^*\}$ as a local neighborhood basis."
What is the significance of the term "telophase", and who coined it?
My research:
According to Wikipedia, I learn that "telophase" is a term in biology for a late stage in the process of cell division, at which point all the interior components of the cell have separated into two aggregations just before the cell actually divides into two parts.
I gather that the main significance of this topology (and its raison d'être) is the fact that it has compact subsets $[0,1]$ and $[0,1) \cup \{1^*\}$ whose intersection is not compact, and perhaps the term "telophase" is a picturesque way of providing an analogy between two daughter cells (in the biological context) and those two "daughter" closed unit intervals which are separately compact sets which are still, so to speak, "inside" the parent cell $(X, \tau)$.
I can't find any discussion about this topology in the online literature. While S&S has a comprehensive bibliography, it does not match the citations with their appearance in the text.)

A: I don't know who came up with this name, it's just the same idea as the "line with double origin", which is a standard example to show that Hausdorff is "needed" in the definition of manifold, e.g. Maybe instead of using split point, or double point etc. they liked a "fancy" name and opted for the biological metaphor.


text:
Q: Apache2 Configuration for Single Page Application I am trying to get my single page application running with Apache2. This is my file structure:

static

*

*js

*

*

*main.js

*css
dashboard.html
index.html

Now I am trying to write a .htaccess file with rewrite rules.
example.com/ -> /index.html
example.com/dashboard -> /dashboard.html
example.com/dashboard/info -> /dashboard.html
example.com/dashboard/... -> /dashboard.html
example.com/static/js/main.js -> /static/js/main.js

I don't want to use redirects, just rewriting the URL.
What do I have to put in the file .htaccess.
It would appreciate an answer very much.
Solution
I figured out the solution myself:
RewriteEngine On
RewriteRule ^dashboard$ /dashboard.html [PT]
RewriteRule ^dashboard/$ /dashboard.html [PT]
RewriteRule ^dashboard/(.*)$ /dashboard.html [PT]


text:
Q: fetch class schedule from mind body api i have two scripts through which i am trying to fetch class schedule from mindbody api. For this i am refereing the documents from github
devincrossman mindbody api
Code on first page index.php starts from the following code
require 'MB_API.php';
$mb = new \DevinCrossman\Mindbody\MB_API(array(
    "SourceName"=>'ABC',
    "Password"=>'ABC',
    "SiteIDs"=>array('123')
));

and code on second page MB_API.php starts from
namespace DevinCrossman\Mindbody;
class MB_API {
    protected $client;
    protected $sourceCredentials = array(
        "SourceName"=>'ABC',
        "Password"=>'ABC',
        "SiteIDs"=>array('123')
    );

It was working fine, but recently i switched my server and now it is not working, it is supposed to show the schedule of all classes.
now i am getting error
Unexpected character in input:  '\' (ASCII=92) state=1 on line 3
syntax error, unexpected T_STRING on line 3 in index.php (i.e $mb = new \DevinCrossman\Mindbody\MB_API(array()
syntax error, unexpected T_STRING on line 2 in MB_API.php (i.e namespace DevinCrossman\Mindbody;)

Can anyone please tell why this error is present although it used to work fine earlier


text:
Q: How do I insert a record in Rails when there's no model and without using SQL I have created a table that implements an n-to-n relation using the following statement:
create_table :capabilities_roles, :id => false do |t|
  t.integer :capability_id, :null => false
  t.integer :role_id, :null => false
end

There is no model for this table. How do I insert records without resorting to SQL?
I found this in the ActiveRecord::ConnectionAdapters::DatabaseStatements module:
insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)

and also:
insert(arel, name = nil, pk = nil, id_value = nil, sequence_name = nil, binds = [])

I have no idea what arel means. Can someone give me an example of a valid insert? I would like to use stuff like :role_id => Role.find_by_name('Business user') in it.

A: If you're going to be manipulating the database records via Rails, then there should be a model for it. Just create a role.rb in your models directory with the lines
class Role < ActiveRecord::Base
end

And you're as good as gold.

A: It looks like a join table for has and belongs to many relationship between Capability and Role models. You should let the Rails handle it for you. First define required associations:
class Capability < ActiveRecord::Base
  has_and_belongs_to_many :roles
end

class Role < ActiveRecord::Base
  has_and_belongs_to_many :capabilities
end

Then just add instance of Role model to roles array of an instance of Capability model (or vice versa):
capability.roles << role
role.capabilities << capability

Removing records from join table is done via removing object from an array:
capability.roles -= [role]

A: In our project we have many meta tables which don't have models. To generate active record models on the fly we use follow module:
module EntityModel
  module_function
  ACCESS_MODELS = {}

  def for(table_name)
    return ACCESS_MODELS[table_name] if ACCESS_MODELS.has_key?(table_name.id)
    ACCESS_MODELS[table_name] = create_access_model(table_name)
  end

  def create_access_model(table_name)
    Class.new(ActiveRecord::Base) do
      self.table_name = table_name
    end
  end
end

This create anonymous models and store it in the global hash for performance purposes.
Uses as:
EntityModel.for(:users)


text:
Q: PostgreSQL 11 and Oracle foreign data wrapper I have a problem with installing the Oracle foreign data wrapper for PostgreSQL_11 on CENTOS 8.
I have no connection to internet, so I copied all necessary files by SSH, I have installed PostgreSQL 11 and Oracle client, and finally need to install Oracle FWD (oracle_fwd-master.zip). Initially I unzipped and then by instruction below:
ORACLE FDW INSTALLATION:
root@user-laptop:~# cd /opt/oracle_fdw/
root@user-laptop:/opt/oracle_fdw# make
root@user-laptop:/opt/oracle_fdw# make install

but I got below issue
[root@oracle_fdw-master]# make
make: pg_config: Command not found
make: *** No targets.  Stop.**

Please help how it can be resolved?

A: First, never run make as user root. It will work, but is an unnecessary danger. That is why mak mand make install are two different steps: the latter typically has to be run by root.
Anyway, your problem is that you either didn't install the postgresql11-devel package, or /usr/pgsql-11/bin is not on your PATH.
Verify that the headers and pg_config are installed, and try
PATH=/usr/pgsql-11/bin:$PATH make


text:
Q: Specific formulation of a Laurent Series? I'm rather new to this branch of calculus, but I've been trying to learn about it on my own time. I currently rather fluently understand more basic topics such as Taylor Series, which come with an easy little formula for determining them$\left(T_a(f(x))=\sum_{k\geq0}\frac{f^k(a)}{k!}(x-a)^k\right)$.
This is how I currently go about finding a Laurent Series, and I'm pretty sure it's wrong. Let's look at the example $$f(z)=\frac{1}{z+2}=-\frac1{x_1}=\frac1{x_2}:x_1=-(z+2)\wedge x_2=(z+2)$$ Basically, using these x-substituted forms, I take two Taylor Series combined to get one who has indices on $(-\infty,\infty)$. So:
$$-\frac1{x_1}=-x_1^{-1}=-T_1(x_1^{-1})=-\sum_{k=0}^{\infty}(-1)^k(x_1-1)^{k-1}=\sum_{k=0}^{-\infty}(-1)^k(x_1-1)^{k+1}\\
\frac1{x_2}=x_2^{-1}=T_1(x_2^{-1})=\sum_{k=0}^{\infty}(-1)^k(x_2-1)^{k-1}\\
\therefore \sum_{k=0}^{-\infty}(-1)^k(x_1-1)^{k+1}+\sum_{k=0}^{\infty}(-1)^k(x_2-1)^{k-1}\\
\downarrow\text{substituting }x_1, x_2 \downarrow\\\sum_{k=0}^{-\infty}(-1)^k(-z-3)^{k+1}+\sum_{k=0}^{\infty}(-1)^k(z+1)^{k-1}\\
\sum_{k=-\infty}^{\infty}2(-1)^k(-z-3)^{k+1}+(z+1)^{k-1}
$$
So yeah, even assuming this is the right sum equation, I'm still hella confused. Firstly, my end goal with understanding Laurent series is being able to calculate contour integrals, which you must use the coefficient of the $-1^{\text{st}}$ index of the series to calculate the residue$\left(\oint_{\gamma} f(z) dz=2\pi i\sum_{k\leq n}\text{Res}\left(f\left(z\right),z_k\right)\right)$. If someone could help explain to me what the correct way to calculate this is in the context of Taylor Series or introductory complex analysis terminology, that would be awesome. Thanks in advance!


text:
Q: Eloquent Get higher value of a specific table's column Using Eloquent in Laravel,
To get the minimum value of a column this code works:
public function getLowestYearBook()
{
    return CV_Outputs::min('book_publication_year');
}

But to get the higher value it doesn't work, i'm using 'max' instead of 'min'.
How to get the higher? Thanks!
--------------- Edit:
the problem is I have some rows with "Not defined" text in it, so sorting by desc it returns that row, because letters are "higher" than number.
I fixed it by doing this:
public function getHighestYearBook()
{
    return CV_Outputs::all()
    ->where('book_publication_year', '<>', "Not defined")
    ->sortByDesc('book_publication_year')
    ->first()->book_publication_year;
}

A: You should check if the type/value is the same in all rows, because max should do the job. But try sorting them in descending order which means highest first and then get the first element like this:
CV_Outputs::all()
    ->where('book_publication_year', '!=', 'Not defined')
    ->sortByDesc('book_publication_year')
    ->first();


text:
Q: Creating scrollview for custom dialog box in Swift I have custom dialog box which has following contents
  here
I wanted to know what constraints i have to give for view which is under scrollView, I also
  want View dynamically grow so that whenever needed scrollView can appear.
  If you could help me I'll appreciate.


text:
Q: Procfile for worker process running Heroku Sceduler I have a heavy process which downloads data off APIs which I want to schedule with 'Heroku Scheduler'. (https://addons.heroku.com/scheduler)
I want a dedicated worker process for the job. How should I define my Procfile?
How should I define the worker task in scheduler plugin settings page?

A: I'm assuming that you're using rails. If you're not, then you'll have to change the instructions slightly, but the general instructions work.
You'll need a command to run your data downloader. In Rails, the best way to do this would be to create a rake command in /lib/tasks/scheduler.rake called api_data_downloader for example.
If you're not using rails then create a script (You can place it in bin).
Then to add the job, go to your app on the Heroku dashboard. Click on 'general info', then on the scheduler add-on. Click 'add a job' and select a frequency and time. For the job, input the command that would run your script. For Rails, you would run 'rake api_data_downloader'. Otherwise you may need to do something such as 'ruby api_data_downloader.rb' or 'php api_data_downloader' depending on your needs'.
You can read the blog post on the scheduler app or read the documentation on it.
The scheduler app is a one-off dyno not a worker dyno. The scheduler add-on is meant for short tasks and worker dynos for processes that take longer than a couple minutes. If you need a worker dyno, then in your procfile you need to specify
worker: rake api_data_downloader

and scale it up with
heroku ps:scale worker=1

The scheduler add-on and a worker dyno are different from each other.


text:
Q: How do I prevent a pagebreak in `align` before an `intertext`? Usually, one can prevent a page break at a line break in an align-environment using \\*. When the line break in question comes before an \intertext, however, there seems to be no effect, as illustrated by the following example:
\documentclass{scrartcl}
\usepackage{amsmath,lipsum}
\usepackage[paperheight=10cm]{geometry}

\begin{document}
\lipsum[1]
\begin{align*}
    a &= b\\*
\intertext{Some text}
    a &= b\\*
\intertext{Some text}
    a &= b
\end{align*}
Some text
\end{document}

I also tried playing around with \predisplaypenalty and and \postdisplaypenalty, which seem to affect also the penalties for breaking before/after an \intertext (for instance, \postdisplaypenalty=10000 seems to do what I intended here), but I am not sure if that's the way to go and where precisely to alter the penalties.
So, how should I prevent page breaks around \intertexts?

A: The spacing isn't right (more like \shortintertext), but it achieves the effect.  Note that without \allowdisplaybreaks, \\* has the same effect as \\.
\documentclass{scrartcl}
\usepackage{amsmath,lipsum}
\usepackage[paperheight=10cm]{geometry}

\begin{document}
\lipsum[1]
\allowdisplaybreaks
\begin{flalign*}
&&    a &= b &&\\*
\text{\rlap{\parbox[t]{\textwidth}{Some text}}}\\
&&    a &= b \\*
\text{\rlap{\parbox[t]{\textwidth}{Some text}}}\\
&&    a &= b
\end{flalign*}
Some text
\end{document}


text:
Q: Need to split the file path/directory and use it as an argument using shell script I need to split the file path/directory and use it as an argument using shell script.
I have a file path: /home/ubuntu/testscriptsfolder/jmx/*.jmx
and need to get only *.jmx in my variable so that I can pass it as an argument in one of my run commands.
Please suggest how it is achievable in shell script.

A: These commands are useful for that:
$ basename /path/to/name
name
$ dirname /path/to/name
/path/to


text:
Q: Can I use final nodes in activity diagrams to end a use case? I'm working on several activity diagrams wich describes different use cases about a client-server application. Can final nodes be used to specify the end of a use case and not of a process? For example at the end of the login use case both server and client don't end but they continue their execution for other interactions. Have I to use final nodes in this cases?
Thanks.

A: This should help you:
http://www.sparxsystems.com.au/resources/uml2_tutorial/uml2_activitydiagram.html

Final Node
There are two types of final node: activity and flow final nodes.
The activity final node is depicted as a circle with a dot inside.
The flow final node is depicted as a circle with a cross inside.
The difference between the two node types is that the flow final node denotes the end of a single control flow; the activity final node denotes the end of all control flows within the activity.

(Emphasis mine)


text:
Q: Xamarin Android RecyclerView 2 строки в одной ячейке, программное создание RecyclerView Суть моего вопроса заключается в том, чтобы можно было, например как в почтовом клиенте, в одну ячейку поместить 2 строчки одна под другую и при этом они могут иметь разные параметры (шрифт, цвет, отступ и тд).
При этом чтобы RecyclerView создавался программно, так как нужно, чтобы всё происходило на одном слое.
    Например нажал на кнопку, слой затирается и на него кладутся вновь созданные элементы.
Вот основа моих опытов:  Есть код простенького RecyclerView
 using Android.App;
using Android.OS;
using Android.Support.V7.App;
using Android.Runtime;
using Android.Widget;
using Android.Support.V7.Widget;
using Android.Views;

namespace recyclerview
{
    [Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]
    public class MainActivity : AppCompatActivity
    {
        public class MyAdapter : RecyclerView.Adapter
        {
            string[] items;

            public MyAdapter(string[] data)
            {
                items = data;

            }

            // Create new views (invoked by the layout manager)
            public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
            {
                //    set the view's size, margins, paddings and layout parameters
                var tv = new TextView(parent.Context);
                tv.SetHeight(200);
                tv.Text = "";

                var vh = new MyViewHolder(tv);
                return vh;
            }

            // Replace the contents of a view (invoked by the layout manager)
            public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
            {
                var item = items[position];

                // Replace the contents of the view with that element
                var holder = viewHolder as MyViewHolder;
                holder.TextView.Text = items[position];

            }

            public override int ItemCount
            {
                get
                {
                    return items.Length;
                }
            }
        }
        public class MyViewHolder : RecyclerView.ViewHolder
        {
            public TextView TextView { get; set; }

            public MyViewHolder(TextView v) : base(v)
            {
                TextView = v;

            }
        }

        //MyAdapter mAdapter;
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);
            RecyclerView TaskList;
           // TaskList = new RecyclerView(this);
          //  LinearLayout lin = FindViewById<LinearLayout>(Resource.Id.linearall);
           // TaskList.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
            TaskList =  FindViewById<RecyclerView>(Resource.Id.recyclerView);
           // lin.AddView(TaskList);

            // Plug in the linear layout manager:
            var layoutManager = new LinearLayoutManager(this) { Orientation = LinearLayoutManager.Vertical };
            TaskList.SetLayoutManager(layoutManager);
            TaskList.HasFixedSize = true;

            //    var recyclerViewData = GetData(Lister);
            string[] recyclerViewData = new string[] { "odin", "dva", "tri" };

            // Plug in my adapter:
            MyAdapter mAdapter = new MyAdapter(recyclerViewData);
            TaskList.SetAdapter(mAdapter);

        }
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
        {
            Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

            base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }
}

и есть такой вот axml
  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id ="@+id/linearall">
    <android.support.v7.widget.RecyclerView
        android:layout_width ="match_parent"
        android:layout_height ="match_parent"
        android:scrollbars="vertical"
        android:id = "@+id/recyclerView"

 />

</LinearLayout>

Подскажите куда копать, что нажимать

A: В общем сам разобрался в основном благодаря вот этой статье на java https://metanit.com/java/android/5.11.php Вот рабочий код
using Android.App;
using Android.OS;
using Android.Support.V7.App;
using Android.Runtime;
using Android.Widget;
using Android.Support.V7.Widget;
using Android.Views;
using System.Collections.Generic;
using Android.Content;

namespace recyclerview
{
    [Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]
    public class MainActivity : AppCompatActivity
    {
        public class data
        {
            public string text1 { get; set; }
            public string text2 { get; set; }
            public data(string text1,string text2)
            {
                this.text1 = text1;
                this.text2 = text2;
            }
        }
        public class MyAdapter : RecyclerView.Adapter
        {
           public List<data> dataall;
            public LayoutInflater inflater;

            public MyAdapter(Context context,List<data> datacome )
            {
                dataall = datacome;
                this.inflater = LayoutInflater.From(context);

            }

            // Create new views (invoked by the layout manager)
            public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
            {

                View tv = inflater.Inflate(Resource.Layout.list_item,parent,false);

                var vh = new MyViewHolder(tv);
                return vh;
            }

            // Replace the contents of a view (invoked by the layout manager)
            public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
            {
                 data dataone = dataall[position];

                // Replace the contents of the view with that element
                var holder = viewHolder as MyViewHolder;
                holder.data1.Text = dataone.text1;
                holder.data2.Text = dataone.text2;

            }

            public override int ItemCount
            {
                get
                {
                    return dataall.Count;
                }
            }
        }
        public class MyViewHolder : RecyclerView.ViewHolder
        {
            public TextView data1 { get; set; }
            public TextView data2 { get; set; }

            public MyViewHolder(View v) : base(v)
            {

                data1 = (TextView)v.FindViewById(Resource.Id.data1);
                data2 = (TextView)v.FindViewById(Resource.Id.data2);

            }
        }

        //MyAdapter mAdapter;
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);
            RecyclerView TaskList;
           // TaskList = new RecyclerView(this);
          //  LinearLayout lin = FindViewById<LinearLayout>(Resource.Id.linearall);
           // TaskList.LayoutParameters = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MatchParent, LinearLayout.LayoutParams.WrapContent);
            TaskList =  FindViewById<RecyclerView>(Resource.Id.recyclerView);
           // lin.AddView(TaskList);

            // Plug in the linear layout manager:
            var layoutManager = new LinearLayoutManager(this) { Orientation = LinearLayoutManager.Vertical };
            TaskList.SetLayoutManager(layoutManager);
            TaskList.HasFixedSize = true;

            //    var recyclerViewData = GetData(Lister);

            List<data> phones = new List<data>();
            setInitialData();
            // Plug in my adapter:
            MyAdapter mAdapter = new MyAdapter(this, phones);
            TaskList.SetAdapter(mAdapter);

             void setInitialData()
            {

                phones.Add(new data("Huawei P10", "Huawei"));
                phones.Add(new data("Elite z3", "HP"));
                phones.Add(new data("Galaxy S8", "Samsung"));
                phones.Add(new data("LG G 5", "LG"));
            }

        }
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
        {
            Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);

            base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
    }
}

так же к нему нужно создать еще 1 слой list_item.axml с таким вот кодом
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/main_parent"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:padding="5dp">
    <TextView
        android:id="@+id/data1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="18sp"
        android:padding="5dp"/>
    <TextView
        android:id="@+id/data2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="15sp"
        android:padding="5dp"/>
</LinearLayout>


text:
Q: Prove that $F(x,y) =(2x+y, x+4y)$ is bijective I need to prove that
$$F(x,y) =(2x+y, x+4y)$$
is injective and surjective. I started by assuming $$F(x_1,y_1) = F(x_2,y_2)$$
or
$$(2x_1+y_1, x_1+4y_1) = (2x_2+y_2, x_2+4y_2)\implies\\2x_1+y_1 = 2x_2+y_2\\x_1+4y_1 = x_2+4y_2$$
But I don't know how to show that $x_1 = x_2$ and $y_1 = y_2$.
Also, for surjectivity, I don't know how to prove that $(2x+y, x+4y)$ will always have a vector to get mapped to. I know it has, it's obvious, but I don't know how to show it.

A: Your $F$ is a linear mapping. Take $(x,y) \in \ker F$. So : $$\begin{cases}2x+y=0 \\x+4y = 0\end{cases}$$
We have that $(0,0)$ is a solution, and it is the only one, because $$\begin{vmatrix}2 & 1 \\ 1 & 4\end{vmatrix} = 7 \neq 0.$$
Conclusion: $\ker F = \{(0,0)\}$ and $F$ is injective. On the other hand, by the rank-nullity theorem, we have that $$2 = \dim \Bbb R^2 = \dim \ker F + \dim {\rm Im}\  F = \dim {\rm Im}\  F,$$ and hence ${\rm Im} \ F = \Bbb R^2.$ So $F$ is surjective.

A more elementary approach:

*

*For injectivity, suppose that $F(x_1,y_1) = F(x_2,y_2)$. Then we have: $$\begin{cases}2x_1+y_1 = 2x_2+y_2 \\ x_1+4y_1 = x_2+4y_2\end{cases} \iff \begin{cases} 2(x_1-x_2)+(y_1-y_2) =0 \\ (x_1-x_2)+4(y_1-y_2) = 0\end{cases} \iff \begin{cases}2\Delta x+\Delta y=0 \\ \Delta x+4\Delta y = 0\end{cases},$$ where $\Delta x = x_1-x_2$ and $\Delta y = y_1 - y_2$. But I've already told you what is the only solution of this system, which is linear in $\Delta x$ and $\Delta y$. This process of thought is the same used in proving that $F$ injective $\iff \ker F = \{{\bf 0}\}$.

*For surjective, let $(r,s)$ in the image of $F$. Then, we have for some pair $(x,y)$, the relation $(r,s) = F(x,y)$, that is: $$\begin{cases}2x+y=r \\x+4y = s\end{cases}.$$ Can you find $r$ and $s$ in terms of $x$ and $y$? This proves surjective.

A: If $(r, s)=(2x+y,x+4y)$ solve $(x, y)$ in terms of $(r, s)$.

A: $$
(2x_1+y_1, x_1+4y_1) = (2x_2+y_2, x_2+4y_2)\implies\\2x_1+y_1 = 2x_2+y_2\\x_1+4y_1 = x_2+4y_2
$$
from the second equation you get $x_1 = x_2+4y_2 - 4y_1$ substitute this in the first equation to get:
$$
2x_2 + 8y_2-8y_1 + y1 = 2x_2 + y_2 \implies y_1=y_2
$$

A: There are a few methods here:

First, is the continuation of yours: As you've observed, $F(x_1, y_1) = F(x_2, y_2)$ implies
\begin{align}
2 x_1 +   y_1 &= 2 x_2 +   y_2 \\
  x_1 + 4 y_1 &=   x_2 + 4 y_2 .
\end{align}
Respective subtracting twice each side of the second equation from each side of the first give
$$- 3 y_1 = - 3 y_2,$$
and multiplying both sides by $-\frac{1}{3}$ gives
$$y_1 = y_2$$
as desired. An analogous pair of operations gives $y_1 = y_2$.

Alternatively, we can simply look for an inverse: That is solve $(u, v) = F(x, y) = (2 x + y, x + 4y)$ for $x, y$ in terms of $(u, v)$. If we can do so, $F$ is invertible, with inverse $F^{-1}$ given by this expression.

Finally, since $F$ is linear, we may write it in matrix form:
$$F\left(\begin{pmatrix}x\\y\end{pmatrix}\right) = \begin{pmatrix}2 & 1\\1 & 4\end{pmatrix}\begin{pmatrix}x\\y\end{pmatrix}.$$
If the $2 \times 2$ matrix is invertible, then we can solve for $F(x, y)$ in terms of $(x, y)$, which shows that $F$ is invertible:
$$\begin{pmatrix}x\\y\end{pmatrix} = \begin{pmatrix}2 & 1\\1 & 4\end{pmatrix}^{-1}F\left(\begin{pmatrix}x\\y\end{pmatrix}\right).$$
To show that this matrix is invertible we need not compute its inverse directly---a matrix is invertible iff its determinant is nonzero, which is the case for this matrix:
$$\det \begin{pmatrix}2 & 1\\1 & 4\end{pmatrix} = (2)(4) - (1)(1) = 7 \neq 0.$$


text:
Q: Continuous function that can be written as two distinct infinite polynomials I want to find a function $f:[0,1]\rightarrow \mathbb{R}$, where I can write
$$f(x)=\sum_{n=0}^\infty c_nx^n$$
and such $(c_n)_n$ is not unique.
I can exclude $f$ that is infinitely differentiable at $0$ since $f$ would have unique Maclaurin series,
but then I don't know which function would be equal to two distinct infinite polynomials.

A: Let's assume you have sucha function, and you can write
$$
\sum_{n=0}^\infty a_n x^n = f(x) = \sum_{n=0}^\infty b_n x^n
$$
Then, subtract the RHS from the LHS to get
$$
0 = \sum_{n=0}^\infty (a_n - b_n) x^n, \quad \forall x \in (0,1).
$$
Can you prove this is only possible if $a_n=b_n$ for all $n \in \mathbb{N}$?

A: You don't actually say that your series converge on $[0,1]$, so we are free to use series that converge on smaller domains centered at $0$.  (We don't explicitly use this freedom below, but it is an area of freedom that one can exploit in this setting.)  You don't say that your series are produced by the recipe for Taylor series, so in fact we could just write down any two series and claim these are the two "Jason Dil" series for this function.  But let's assume you intend to use Taylor's recipe for projecting a function onto the space of analytic functions (centered at $0$).
Let $f$ be some function with domain $[0,1]$,  \begin{align*}
f_1 &= \sum_{n=0}^\infty c_n x^n \text{, and}  \\
f_2 &= \sum_{n=0}^\infty d_n x^n \text{,}
\end{align*}
with $(c_n)_n \neq (d_n)_n$, where $f_1$ and $f_2$ each converge on at least one point.  Let $S_1$ be the radius of agreement of $f_1$ with $f$,
$$  S_1 = \sup \{u : \left. f \right|_{[0,u)} = \left. f_1 \right|_{[0,u)} \}  \text{,}  $$
and $S_2$ be the radius of agreement of $f_2$ with $f$.  Let $S = \min \{S_1, S_2\}$.
(Note that $S_i$ is less than or equal to the radius of convergence of $f_i$ for $i \in \{1,2\}$.  That equality is not assured can be seen most easily by expanding our context to $\Bbb{C}$.  Start with an entire $f$.  Outside of the strip $-1 < \Im(x) < 1$, replace $f$ with $f+1$.  The radius of agreement with this modified function cannot exceed $1$, but the radius of convergence of the power series is $\infty$.)
If $S > 0$, since $f_1 = f_2$, on $0 \leq x < S$, we have
$$  f_1 - f_2 = 0,  \quad 0 \leq x < S  \text{,}  $$
or, what is the same thing,
$$  \sum_{n=0}^\infty (c_n - d_n) x^n = 0,  \quad 0 \leq x < S  \text{.}  $$
By the identity theorem for power series (see this for a statement and some discussion),
$c_n = d_n$ for all $n$.
If $S = 0$, then at least one of $f_1$ and $f_2$ has radius of agreement $0$.  WLOG, assume $f_1$ has radius of agreement $0$ (otherwise, swap the labels "$f_1$" and "$f_2$").  This means $f_1$ only agrees with $f$ when $x = 0$ and therefore has $c_0 = f_1(0) = f(0)$.  Since $f_2$ at least agrees with $f$ on $\{0\}$, we also have $d_0 = f_2(0) = f(0)$.  So $d_0 = c_0$ is forced.  But then every other coefficient is completely unconstrained.
So, for your desired scenario to happen, let $f_2$ be a Taylor series of $f$ at $0$ (using one-sided derivatives at $0$) agreeing with your function on some interval (possibly of zero width) and let $f_1$ be any Maclaurin series (different from $f_2$) with zero radius of convergence and same constant coefficient as $f_2$ (for example, $c_0 = f(0)$ and $c_n = n!$ for $n > 0$).  This is perhaps unsatisfying as these two series only agree at one point -- but we have seen above that if the series agree on an interval, they are identical, so one point is the largest interval of agreement for two series having different coefficients.
Perhaps such an $f_1$ seems strange.  Here is an example.  Observe $\lim_{x \rightarrow 0} \mathrm{e}^{-1/x^2} = 0$ and define the continuous function
$$  f(x) =  \begin{cases} \mathrm{e}^{-1/x^2} ,& x \neq 0  \\
0 ,& x = 0 \end{cases}  \text{.}  $$
Since $f(0) = f'(0) = f''(0) = \cdots = 0$, the Maclaurin series of $f$ is $0$.  It agrees with $f$ only at $x = 0$, even though the series has infinite radius of convergence.

A: This is not possible. $f$ can be extended to a map defined on $(-1/2, 1/2)$ expandable into a power series on that interval. Therefore $f$ is indefinitely differentiable and $c_n = \frac{f^{(n)}(0)}{n!}$.


text:
Q: accept-charset attribute in html form The accept-charset attribute specifies the character encodings that are to be used for the form submission . This attribute overrides the default encoding of html page specified in the header field of page while encoding the form submission data. How does the server know which encoding is used to encode the form submitted data? Does any request header are sent by browser to specify type of encoding?

A: HTML5 suggests this as a form input value:

_charset_
This value, if used as the name of a Hidden control with no value attribute, is automatically given a value during submission consisting
  of the submission character encoding.

A quick test seems to indicate that it's pretty well supported in browsers at least back to IE7.


text:
Q: The Equivalence of Non-Singularity and Invertibility for Finite-Dimensional Vector Spaces In Lipschutz's Linear Algebra, he provides the attached discussion (see below) on invertible operators in $A(V$). Now, I understand the sketch of the proof that non-singularity and invertibility are equivalent, but I suppose I'm confused about the counterexample that he provides to show that non-singularity does not imply invertibility in the general case of potentially infinite-dimensional vector spaces.
My thinking was: $F$ is clearly non-singular because the zero vector maps to the zero vector. However, it is not onto because the constant $a_0$ is not present in the image of $F$. Is that it? It seems to me then that I am missing something, because then I think about the case of a finite polynomial vector space, $P_n(t)$. This would also not have $a_0$ in its image. But maybe this isn't a valid counter example because $F$ maps $P_n(t)$ out of $P_n(t)$ and into $P_{n+1}(t)$ and therefore this is not a valid counterexample to the assertion made about finite-dimensional vector spaces.
Lipschutz

A: You are right. Since $a_0$ is not in the image of $F$, the map $F$ is not onto.
The situation with $P_n(t)$ is no counterexample since $F$ maps $P_n(t)$ into $P_{n + 1}(t)$ and these two spaces have not the same dimension. The equivalence of surjectivity and injectivity of a linear map $F : V \longrightarrow W$ is only given, if $\dim(V) = \dim(W) < \infty$.


text:
Q: How to transform a string into an ASCII string like in C? I have to do a cryptography project for my school and I choose Go for this project !
I read the doc but I only C, so it's kinda hard for me right now.
First , I needed to collect the program arguments, I did it. I stockd all arguments in a string variable like :
var text, base string = os.Args[1], os. Args[6]

Now , i need to store the ASCII number in a array of int , for exemple , in C I would done  something like that :
int     arr[18];
char    str[18] = "Hi Stack OverFlow";

arr[i] = str[i] - 96;

So how could I do that in Go?
Thanks !

A: My guess is that you want something like this:
package main

import (
    "fmt"
    "strings"
)

// transform transforms ASCII letters to numbers.
// Letters in the English (basic Latin) alphabet, both upper and lower case,
// are represented by a number between one and twenty-six. All other characters,
// including space, are represented by the number zero.
func transform(s string) []int {
    n := make([]int, 0, len(s))
    other := 'a' - 1
    for _, r := range strings.ToLower(s) {
        if 'a' > r || r > 'z' {
            r = other
        }
        n = append(n, int(r-other))
    }
    return n
}

func main() {
    s := "Hi Stack OverFlow"
    fmt.Println(s)
    n := transform(s)
    fmt.Println(n)
}

Output:

Hi Stack OverFlow
[8 9 0 19 20 1 3 11 0 15 22 5 18 6 12 15 23]

Take A Tour of Go and see if you can understand what the program does.

A: Here's an example that is similar to the other answer but avoids importing additional packages.
Create a slice of int with the length equal to the string's length. Then iterate over the string to extract each character as int and assign it to the corresponding index in the int slice. Here's code (also on the Go Playground):
package main

import "fmt"

func main() {
    s := "Hi Stack OverFlow"
    fmt.Println(StringToInts(s))
}

// makes a slice of int and stores each char from string
// as int in the slice
func StringToInts(s string) (intSlice []int) {
    intSlice = make([]int, len(s))
    for i, _ := range s {
        intSlice[i] = int(s[i])
    }
    return
}

Output of the above program is:
[72 105 32 83 116 97 99 107 32 79 118 101 114 70 108 111 119]

The StringToInts function in the above should do what you want. Though it returns a slice (not an array) of int, it should satisfy your usecase.


text:
Q: How would one do a for loop in a cucumber feature? I have a set of preferences I want to test the exact same tests for, and make sure they all behave appropriately. So, the for loop would iterate over each preference configuration, and run the same set of tests is the previous and next iteration.  *With IF statements of course, so tests that don't apply to the current configuration don't need to be tested.
Is there a way to do this / something similar?
I'm using rails 2.3.8

A: Cucumber has a concept called Scenario Outlines that is used to describe a scenario that needs to be run repeatedly with differing data.

A: It sounds like you want cucumber example tables, where you can enumerate all your Preference values you want to test the same behavior of:
Given I have a preference defined
When I do some thing
Then I should see this behavior

Examples:
  | preference | label_name |
  | foo        | It's Foo!  |
  | bar        | So bar...  |

Here's a link to a tutorial using table based examples for testing like this:
http://asciicasts.com/episodes/159-more-on-cucumber

A: This sounds like something you use a scenario outline for:
https://github.com/cucumber/cucumber/wiki/Scenario-outlines


text:
Q: What's the cleanest way to allow access to a webpage only through a redirect I'm developing a website for an university homework, and I'd like to forbid access to some pages who should be accessed only by some users when specific links are clicked.
Suppose users should not access to secretAccountsList.jsp page, but only administrators can, and they can only access it by clicking the specific URL which calls sendRedirect to secretAccountsList.jsp.
I know that this could be achieved somehow with sessions and forms, but it seems quite mechanical to me, is there any cleaner and direct way?


text:
Q: Formatting data to API I'm trying to send data trough a webcall API and have to send a specific value as number.
                $groupmembers = Get-ADGroupMember -Identity $group.SamAccountName -Recursive
                $members = ""
                foreach ($member in $groupmembers) {
                    $currentFlexAssets = (Get-ITGlueFlexibleAssets -filter_flexible_asset_type_id $Users_flex_asset_id -filter_organization_id $api__org_id -filter_name $member.name)
                    $value = $currentFlexAssets.data.attributes.'resource-url'
                    $Split = $value.split("{/}")
                    $members += $Split[7] + ", "
                }

                $members = $members.TrimEnd(", ")
                $members
                $members2 = 1715837278175409, 1715837265510575, 1715837270687920

members is the tag field build up from the string split and comma separted.
members2 is the tag field which I've typed myself for testing
memberstext are the same values but then send to a text field:
Group name
GG_Inkoop
Members
Piet van der Ven (tag)
members2
Henk de Vries (tag)
Kees Jansma (tag)
Piet van der Ven (tag)
memberstext
1715837278175409, 1715837270687920
memberstext2
1715837278175409
1715837265510575
1715837270687920
$api__body = @{
        type = "flexible_assets"
        attributes = @{
            organization_id = $api__org_id
            flexible_asset_type_id = $api_config.flexible_asset_type_id
            traits = @{
                $api__key_name_group_name = $groupname
                $api__key_name_members = $members

                $api__key_name_members2 = $members2
                $api__key_name_memberstext = $memberstext
                $api__key_name_memberstext2 = $memberstext2
            }
        }
    }

I've tried string to integer but the value is to long
Cannot convert value "1715837270687920" to type "System.Int32". Error: "Value was either too large or too small for an Int32
looking at values I've seen the brackets around members2
traits                         {members2, memberstext, members, memberstext2...}
members2                       {1715837278175409, 1715837265510575, 1715837270687920}
memberstext                    1715837278175409, 1715837265510575, 1715837270687920
members                        1715837278175409, 1715837265510575, 1715837270687920
memberstext2                   {1715837278175409, 1715837265510575, 1715837270687920}

But doing $members = "{" + $members.TrimEnd(", ") + "}" results in an error from the webserver saying the value is wrong
I'm a bit stuck on this one has someone got a solution?

A:                         $groupmembers = Get-ADGroupMember -Identity $group.SamAccountName -Recursive
                    $members = @()
                    foreach ($member in $groupmembers) {
                        $currentFlexAssets = (Get-ITGlueFlexibleAssets -filter_flexible_asset_type_id $Users_flex_asset_id -filter_organization_id $api__org_id -filter_name $member.name)
                        $value = $currentFlexAssets.data.attributes.'resource-url'
                        $Split = $value.split("{/}")
                        $members += $Split[7]
                    }

                    $members
                    $members2 = 1715837278175409, 1715837265510575, 1715837270687920

Solved by making an array of the value members $members = @()


text:
Q: Calling static method from external application I have the following static function that exports to be called from external application
[DllExport("Initialize", CallingConvention = CallingConvention.StdCall)]
public static void OnStartUp1( )
{
    try
    {
        a = new Indicator();
        a.Init();

    }
    catch (Exception e)
    {
        MessageBox.Show(e.ToString());

    }
}

when I used and call this method from .NET another application it is working well but when I call it from the external application that I build this function for it is return the following exception :

System.InvalidOperationException: DragDrop registration did not succeed. ---> System.Threading.ThreadStateException: Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.

A: You need to match the same apartment. The error indicates that it must be called from an application with the same apartment (Single Threaded Apartment or STA). Therefore, your calling application must be STA.
To make it STA, you need the [STAThread] attribute on your main method.
This has to do with COM. Some COM components can only be accessed by a single thread so they are hosted in an STA. Some are made thread-safe and be accessed by multiple threads so they are hosted in Multi Threaded Apartment (MTA). When you are calling these COM components you must match that apartment.
You will notice windows forms applications will have main method like this:
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
}

Most like the .NET application, with which it is working and you do not get that error, has this [STAThread] attribute on its main method.


text:
Q: .off not unbinding animationend event Alright, so I am making an animated menu that slides/expands tabs back and forth and will look fluid.  I have it all working except for unbinding the animationend event which I am attaching to the clicked tab.  So pretty much you click a tab, a listener is attached to it for the end of the animations and on the click of the next tab I want to unbind the listener to the tab that was previously clicked.  However, I cannot get the .off function to fire for some reason.  Here is my code below
var $featuredTab = this.$('.featured'),
    $tabContainer = $(e.target).parent(),
    $menu = this.$el,
    index = $tabContainer.index(),
    count = $tabContainer.parent().children().length;

    if($featuredTab.length > 0) {
        $menu.off('animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd', $featuredTab, function() {
            console.log('off');
            //do stuff
        });
    }

    $tabContainer.addClass('featured');

    $menu.on('animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd', $tabContainer, function(e) {
            console.log(e.originalEvent);
            //do stuff
    });

any ideas as to why the off event isn't firing?

A: Assuming that you are treating second parameter as a selector then you are using on incorrectly. The second parameter is a selector(string) where you are passing an object. The second(selector) and  third(data) parameters are optional.
Take a look here - http://api.jquery.com/on/
However you can try this.
$menu.off('animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd');

A: Because off() doesn't trigger an event.

The off() method removes event handlers that were attached with .on().

It looks like you want to unbind any events that were previously attached to the menu:
// this removes ALL events
$menu.off('animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd');

If you want to only remove your event, see this example from the documentation.