text:
Q: How to create a report that groups a selection of fields by the day of the week I am new to Crystal Reports and have been asked to produce a report that is sectioned off by Day of the Week (Monday, Tuesday, ...), has a required data range, then lists all activities for the day of the week within that date range.
I tried to insert an image but I am told I can't so ....
The first line of each section should be gray in color and have the column headers for the start date, start time, end time, event, day of the week (ie: MONDAY), location of event.  Under that 'header' line there should be a list of all events with in the date range that fall on a MONDAY.  The next section would be TUESDAY, the next WEDNESDAY....and so on.
I have tried putting the 'header' in the detail section but it repeated (Mon, Tue, Wed, Thu, Fri, Sat, Sun, Mon, Tue,...).  So I tried inserting a group header above the detail section.  Group Header # 1 worked ok...it had detail a below it but I can't figure out how to get the second group header to be directly before detail b section for Tuesday.
Thank you in advance.

A: Note: Check the name of the weekday name and use accordingly

Assuming your database field is date
Create a Formula @Group and use that formula in grouping
if WeekdayName (DayOfWeek ({databasefield.Date})) ="Monday"
Then "Monday"
Else if WeekdayName (DayOfWeek ({databasefield.Date})) ="Tuesday"
Then "Tuesday"
Else if WeekdayName (DayOfWeek ({databasefield.Date})) ="Wednesday"
Then "Wednesday"
Else if WeekdayName (DayOfWeek ({databasefield.Date})) ="Thursday"
Then "Thursday"
Else if WeekdayName (DayOfWeek ({databasefield.Date})) ="Friday"
Then "Friday"
Else if WeekdayName (DayOfWeek ({databasefield.Date})) ="Saturday"
Then "Saturday"
Else if WeekdayName (DayOfWeek ({databasefield.Date})) ="Sunday"
Then "Sunday"

Use the created formula @Group in grouping so that you will get all the groups one by one
Now in details keep the Events database field


text:
Q: Is there a way to change the positions (axis) for a p5 group? As I've been coding, I came across an issue for one of my looped variables. I added the looped variable as shown below, the snake tail, to a group. But, when I tried to set the x and y values to the group so it moves with the snake, it just set to the default of (0,0) and didn't move at all. I do not know if there's a specific function in p5 which changes the group position value, and I've already tried defining the x-pos and y-pos normally. I've already searched the p5 documents and couldn't seem to find anything. Is there any group function to define the positions or any way else
to help define the tail position out of the loop?

    if(snake.isTouching(apple)){
      for (var i = 0; i < 1; i++){
          var tail = createSprite(0,0, snake.width, snake.height);

          tail.shapeColor = rgb(Math.round(random(1,255)),Math.round(random(1,255)),
          Math.round(random(1,255)));
          score = score + 1;

          apple.x = Math.round(random(245,1700));
          apple.y = Math.round(random(150,700));
      }

      tailGroup.add(tail);

      }

      if(keyDown(LEFT_ARROW)){
        tailGroup.x = snake.x - 50;
        tailGroup.y = snake.y;
        }

        if(keyDown(RIGHT_ARROW)){
          tailGroup.x = snake.x + 50;
          tailGroup.y = snake.y;
        }

        if(keyDown(UP_ARROW)){
        tailGroup.y = snake.y - 50;
        tailGroup.x = snake.x;
        }

        if(keyDown(DOWN_ARROW)){
        tailGroup.y = snake + 50;
        tailGroup.x = snake.x;
        }

redpajama_set_name: RedPajamaStackExchange


text:
Q: Can you create a new instance with the copy assignment operator? I'm trying to wrap my head around the copy assignment operator in C++, and I'm wondering if there's a way to create a new instance if the object is null.
class Person {
public:
    Person(string name) { pName_ = new string(name); }
    ~Person() { delete pName_; }
    Person(const Person& rhs) {
        if (pName_ != NULL) delete pName_;
        pName_ = new string(*(rhs.pName()));
    }
    Person& operator=(const Person& rhs) {
        cout << "begin copy..." << endl;
        if (this == NULL) {
            Person* p = new Person(rhs);
            cout << "end copy null..." << endl;
            return *p; // Not working?
        }
        delete pName_;
        pName_ = new string(*(rhs.pName()));
        cout << "end copy..." << endl;
        return *this;
    };
    string* pName() const { return pName_; }
    void printName() { cout << *pName_ << endl; }
private:
    string* pName_;
};
int main() {
    Person *a = new Person("Alex");
    Person *b = new Person("Becky");
    Person *c = NULL;
    *b = *a; // copy works
    *c = *a; // copy doesn't
    if (a != NULL) a->printName(); // Alex
    if (a != NULL) delete a;
    if (b != NULL) b->printName(); // Alex
    if (b != NULL) delete b;
    if (c != NULL) c->printName(); // NULL
    if (c != NULL) delete c;
    return 0;
}

This is the output:
begin copy...
end copy...
begin copy...
end copy null...
Alex
Alex

Is there something I can change in my code to make this work, or is this something I shouldn't even attempt to try?

A: The code you have shown is all kinds of wrong, and needs to be rewritten.
You are calling an improperly implemented copy assignment operator via a dereferenced NULL pointer, which is undefined behavior.  A copy assignment operator is defined to be called only with valid objects, and must copy values from one object to another, and return a reference to the object that was copied to.  You are not doing that.
To answer your question, NO, the copy assignment operator cannot create a new object when this is NULL. For starters, if this is NULL then you have a bug in your code that needs to be fixed. But even if this were NULL, there is no way for the operator to update the caller's pointer (assuming a pointer were used in the first place) to point at a new object instance. this is just a compiler-generated parameter containing the memory address of the object being called into, it is not the caller's original pointer used to invoke the operator. So, if the operator did allocate a new object on the heap, that object will be leaked when the operator exits, as the caller won't have a pointer to the object to free it later.
A proper version of your code should look more like this instead:
class Person {
public:
    Person(const string &name) : pName_(name) {}

    Person& operator=(const Person& rhs) {
        // if you remove these output statements then
        // this entire operator can be removed...
        cout << "begin copy..." << endl;
        if (this != &rhs) {
            pName_ = rhs.pName();
            cout << "non self copied..." << endl;
        }
        cout << "end copy..." << endl;
        return *this;
    }

    string pName() const {
        return pName_;
    }

    void printName() const {
        cout << pName_ << endl;
    }

private:
    string pName_;
};

int main() {
    Person *a = new Person("Alex");
    Person *b = new Person("Becky");
    Person *c = NULL;

    *b = *a;
    //*c = *a; UNDEFINED BEHAVIOR!

    if (a) {
        a->printName();
        delete a;
    }

    if (b) {
        b->printName();
        delete b;
    }

    if (c) {
        c->printName();
        delete c;
    }

    return 0;
}


text:
Q: Hide checkbox until mouse over WPF I am new to XAML, but I would like the CheckBox option to be hidden on my application until the user mouses over the row and can check the box from there. Here is what I currently have and I'm not sure why it doesn't work.
<DataGridTemplateColumn.CellTemplate>
   <DataTemplate>
      <CheckBox Name="cbkSelect"
                IsChecked="{Binding Path=IsSelectedForOrder, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
         <CheckBox.Style>
            <Style TargetType="CheckBox">
               <Setter Property="Visibility" Value="Hidden"/>
               <Style.Triggers>
                  <DataTrigger Binding="{Binding ElementName=cbkSelect, Path=IsMouseOver}" Value="True">
                     <Setter Property="Visibility" Value="Visible"/>
                  </DataTrigger>
               </Style.Triggers>
            </Style>
         </CheckBox.Style>
      </CheckBox>
   </DataTemplate>
</DataGridTemplateColumn.CellTemplate>

A: If you want to display the CheckBox only if a user hovers the row, meaning any cell of a row, you can use a RelativeSource binding to the IsMouseOver property the parent row.
<Style TargetType="{x:Type CheckBox}">
   <Setter Property="Visibility" Value="Hidden"/>
   <Style.Triggers>
      <DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource AncestorType={x:Type DataGridRow}}}" Value="True">
         <Setter Property="Visibility" Value="Visible"/>
      </DataTrigger>
   </Style.Triggers>
</Style>

If you want it to be dislayed only if a user hovers over the CheckBox column, your style will not work as you do not receive the mouse events on a hidden control. You can work around this with a Border that is visible.
<DataGridTemplateColumn>
   <DataGridTemplateColumn.CellTemplate>
      <DataTemplate>
         <Border x:Name="cbkBorder" Background="Transparent">
            <CheckBox Name="cbkSelect"
                      IsChecked="{Binding Path=IsSelectedForOrder, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
               <CheckBox.Style>
                  <Style TargetType="CheckBox">
                     <Setter Property="Visibility" Value="Hidden"/>
                     <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=cbkBorder, Path=IsMouseOver}" Value="True">
                           <Setter Property="Visibility" Value="Visible"/>
                        </DataTrigger>
                     </Style.Triggers>
                  </Style>
               </CheckBox.Style>
            </CheckBox>
         </Border>
      </DataTemplate>
   </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>


text:
Q: Get object properties from symfony form without using foreach loop ranges is selected from a form. Lets say the user selects 4 & 9. How can I retrieve tests and quizzes in those ranges - and only those ranges, without looping through $ranges? Since $ranges is an object I thought I could use type casting to convert it into a simple array, i.e. (array) $ranges...however that results in an empty array. Ultimately I'm trying to get the id of one range without using a foreach loop
$ranges = $form->get('ranges')->getData();

$tests = $em->getRepository('AppBundle:Test')->findBy($ranges);
$quizes = $em->getRepository('AppBundle:Quiz')->findBy($ranges);

$testsAndQuizzes = array_merge($tests, $quizzes);

The purpose of doing this is so once I get to this point, I can loop through my merged array of tests and quizzes and have all the possible outcomes and have one less loop to use.
foreach ($testsAndQuizes as $tq) {
    var_dump($tq);//all of $tq's in $ranges 4 & 9.
}

A: Make use of queries?
$repository = $this->getDoctrine()->getRepository('AppBundle:Test');

$query = $repository->createQueryBuilder('test')
    ->where('test.id >= :range_min')
    ->andWhere('test.id <= :range_max')
    ->setParameter(['range_min' => $range_min, 'range_max' => $range_max])
    ->getQuery();

$test = $query->getResult();

Do the same for Quiz.


text:
Q: SPWeb.GetListItem returns null in custom workflow activity I created an custom workflow activity with the following code:
namespace Custom.SharePoint
{
    public class CustomActivity : Activity
    {
        #region Fields
        public static readonly DependencyProperty __ContextProperty =
            DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(WebServiceActivity));

        public static readonly DependencyProperty AddressProperty =
            DependencyProperty.Register("Address", typeof(string), typeof(WebServiceActivity));

        public static readonly DependencyProperty StatusIdProperty =
            DependencyProperty.Register("StatusId", typeof(string), typeof(WebServiceActivity));
        #endregion

        #region Properties
        public WorkflowContext __Context
        {
            get { return (WorkflowContext)GetValue(__ContextProperty); }
            set { SetValue(__ContextProperty, value); }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Browsable(true)]
        public string Address
        {
            get { return (string)GetValue(AddressProperty); }
            set { SetValue(AddressProperty, value); }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        [Browsable(true)]
        public string StatusId
        {
            get { return (string)GetValue(StatusIdProperty); }
            set { SetValue(StatusIdProperty, value); }
        }

        #endregion

        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                var listItem = this.__Context.Web.GetListItem(this.__Context.CurrentItemUrl);
                var requestId = listItem["RequestId"];

                // rest of code removed for brevity
            });
            return ActivityExecutionStatus.Closed;
        }
    }
}

Unfortunately, this.__Context.Web.GetListItem(this.__Context.CurrentItemUrl) always returns null, even though this.__Context.CurrentItemUrl has a valid value (e.g. "http://{Server Name}/Lists/{List Name}/DispForm.aspx?ID=9")
Am I doing something wrong?

A: I have never had luck using SPWeb.GetListItem...I've used the following in the past when dealing with WorkflowContext objects:
SPListItem item = __Context.Web.Lists[new Guid(__Context.ListId)].GetItemById(__Context.ItemId);

Should do the trick.


text:
Q: How to put alert value to element in this code i am trying to get the alert value to the element.
brief:
my ajax code checks the database values and gets the new values from database and
displays the fetched values in alert. but i am not able to put that alert values into
element...
How can i do this?
Code:

HTML code:

<s:property value="%{#m.status}" />

In alert(data) i am getting the value.
but when i put same value like this
document.getElementById("#div1").innerHTML=data;

it is not applying the value to element

A: you don't need # using javascript's getElementById
try this
 document.getElementById("div1").innerHTML=data; //notice no `#` in front of div1

or
using jquery that should be
 $('#div1').html(data);

A: try
document.getElementById("div1").innerHTML=data[0];
document.getElementById("div2").innerHTML=data[1];
or
$('#div1').html(data[0]);
$('#div2').html(data[1]);
Pass the actual data inside the object to the HTML element, not the object itself.


text:
Q: DC/OS has three roles, they are master, slave, slave_public, why can't put them on one host? I just investigate DC/OS, I find that DC/OS has three roles:master, slave, slave_public, I want to deploy a cluster which can host  master, slave or slave_public roles on one host, but currently I can't do that.
I want to know that why can't put them on one host when designed. If I do that, could I get some suggestions?
I just have the idea. If I can't do, I'll quit using DCOS, I'll use mesos and marathon.
Is there someone has the idea with me? I look forward to the reply.

A: This is by design, and things are actually being worked on to re-enforce that an machine is installed with only one role because things break with more than one.
If you're trying to demo / experiment with DC/OS and you only have one machine, you can use Virtual Machines or Docker to partition that one machine into multiple machines / parts which you can install DC/OS on. dcos-vagrant and dcos-docker can help you there.
As far as installing though, the configuration for each of the three roles is incompatible with one another. The "master" role causes a whole bunch of pieces of software to be started / installed on a host (Mesos-DNS, Mesos master, marathon, exhibitor, zookeeper, 3dt, adminrouter, rexray, spartan, navstar among others) which listen on various ports. The "slave" role causes a machine to have a mesos-agent (mesos renamed mesos-slave to mesos-agent, hence the disconnect) configured and started on the agent. The mesos-agent is configured to control / most ports greater than 1024 to tasks which are launched by mesos frameworks on the agent. Several of those ports are used by services which are run on masters, resulting in odd conflicts and hard to fix bad behavior.
In the case of running the "slave" and "slave_public" on the same host, those two conflict more directly, because both of them cause mesos-agent to be run on the host, with slightly different configuration. Both the mesos-agent (the one configured with the "slave" role and the one with the "slave_public" role are configured to listen on port 5051. Only one of them can use it though, so you end up with one of the agents being non-functional.

A: DC/OS only supports running a node as either a master or an agent(slave). You are correct that Mesos does not have this limitation. But DC/OS is more than just a Mesos/Marathon. To enable all the additional features of DC/OS there are various components built around Mesos and Marathon. At times these components behave differently whether they are running on a master or an agent and at other times the components that exist on a master may or may not exist on an agent or vice versa. So running a master and an agent on the same node would lead to conflicts/issues.
If you are looking to run a small development setup before scaling the solution out to a bigger distributed system DC/OS Vagrant might be a good starting point.


text:
Q: Acceptance Test (Capybara) can't find my Submit Button Question:
How can I get my feature test to recognize my button?
Explanation:
I'm writing an acceptance test with Capybara for "User can add a product to a shopping list".
In my setup I log in as a user, I am able to click on a current shopping list and be directed to the page with the search input for a new product.
I then ask to click the button with
click_button "Search"
Search is the name for my button and is what appears on the page. When I run the actual program everything works, but when I am running the test it keeps telling me that it can't find the Search button.
What I've Tried:
I've tried putting a value instead of a name on my submit button.
I've also tried passing in the id of the button
Instead of clicking on the button I tried adding \n to the input field to hit enter

*

*All of these work when I actually run the program, but they won't work in my testing.
Here is my code! Would love any insight you might have :) Many thanks in advance.

My Code:
The form:
<form method="GET" action="products/show" />
    <label for="search_input">Search Products:</label>
    <input type="text" name="search_input" id="search_input_field" />
    <input type="submit" value="Search" id="submit_search"/>
</form>

The Testing Code:
require 'spec_helper'

describe "a user can add a product to their shopping list" do
    let!(:user_one) { FactoryGirl.create(:user) }
    let!(:households) do
        user_one.shopping_lists.create!({
            title: "households",
            date: Date.today
        })
    end

    it "will add product to the list" do
        login(user_one)
        click_link "View Shopping Lists"
        click_link "households"
        fill_in "search_input_field", with: "toothpaste"
        # save_and_open_page
        click_button "Search"
        # expect(page).to
        # first(:button, "Add Item").click

        # expect(page).to have_button "Delete"
    end

    def login(user)
        visit root_path
        fill_in :email, with: user.email
        fill_in :password, with: user.password
        click_button "Login!"
    end

end

A: I believe the main issue is that Capybara is looking for an html  tag rather than the input as a button.
In your test for the button portion try using
click_on 'Login'


text:
Q: How to extract all key frames from a video clip? I'm trying to extract key frames from a video clip. I tried the following command, but it extracts all frames.
ffmpeg -vf select="eq(pict_type\,PICT_TYPE_I)" -i 2.flv -vsync 2 -s 73x41 -r 30 -f image2 thumbnails-%%02d.jpeg

A: You can make this simpler using -skip_frame without the need for select video filter:
ffmpeg -skip_frame nokey -i 2.flv -vsync 0 -r 30 -f image2 thumbnails-%02d.jpeg

A: Example using the select and scale filters:
ffmpeg -i 2.flv -vf "select=eq(pict_type\,I),scale=73x41" \
-vsync vfr -qscale:v 2 thumbnails-%02d.jpeg

A few tips:

*

*Filters should not come before the -i option, as they're an output option. I don't know where exactly you got the command from, but PICT_TYPE_I does not exist –  it should be I.

*In the scale filter you can replace 73 or 41 to have the filter automatically calculate the width or height to preserve aspect ratio: such as scale=73:-1 or scale=-1:41. This prevents stretching or squishing that can result from "forced" scaling.

*Output quality can be controlled with -qscale:v (or the alias -q:v). Effective range is a linear scale of 2 to 31 and a lower value is a higher quality.

*That your ffmpeg allows a filter before the input tells me it could be outdated. Download a recent static build for your operating system, or build it yourself according to the compilation guides if the above does not work.

A: if this errors:
Option vf (set video filters) cannot be applied to input url 1508.mp4 -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.
Error parsing options for input file 1508.mp4.
Error opening input files: Invalid argument
you can do this:
ffmpeg -i 263.mp4 -vf select=eq(pict_type\,PICT_TYPE_I)  -vsync 2 -s 480x320 -r 24 -f image2 thumbnails-%05d.jpeg

==--------------------------------------------
"-i" Parameters in advance


text:
Q: Qt dynamic layout I'm trying to implement a layout like the file explorer in thumbnails mode. The items are in a grid with fixed distance between them and when you resize the main window, the items are re-positioned to fit.
For example, on a small window you have:

i1 i2 i3
j1 j2 j3
k1 k2 k3

But when the window is wider, the items become:

i1 i2 i3 j1
j2 j3 k1 k2
k3

And if you make the window even wider, the items become:

i1 i2 i3 j1 j2
j3 k1 k2 k3

I'm trying to implement it as simply as possible, maybe using only the default classes?...
The HBoxLayout doesn't overflow if you put an infinite number of items; they just line up infinitely.
The GridLayout cannot help, because after you put the items first, after a window resize, you have to clean the layout, re-calculate the number of items, re-populate the layout with the new order. It doesn't reposition the items automatically.
Another way could be to put items in a TableWidget, Qt3 style. But that's just the same; after window resize, you have calculate how many items fit in the new window, clean the table and re-populate.
There is also the fix position method. You put the items in fixed position and move them after each window resize... it's a headache.
Did anyone try something like that - an explorer or image viewer?  How did you resolve this issue?

A: I think you need to look into doing something like the FlowLayout from the example set.  Note that there is a python port of it.


text:
Q: Proxy with Authentication in Selenium, JAVA We try to use authenticated proxy in Selenium driving headless Chrome, JAVA.
ChromeOptions inherit from ChromeCapabilities (deprecated). We pass instance of Proxy class into a ChromeOptions instance.
The Selenium Proxy class has no methods of HTTP proxy to set up username & password:
        Proxy proxy = new Proxy();
        proxy.setAutodetect(false);
        proxy.setHttpProxy(proxyStr);
        proxy.setFtpProxy(proxyStr);
        proxy.setSslProxy(proxyStr);
        chromeOptions.setCapability("proxy", proxy);

Any way out?

A: I think that good way is to use AutoIT tool.
It is described here: https://www.guru99.com/selenium-proxy-authentication.html#4


text:
Q: Navigate in compose based on result I've this screen:
@Composable
fun SetNewPasswordScreen(
    viewModel: SetNewPasswordViewModel,
    navigateToSetDetails: () -> Unit,
) {
    val state by viewModel.state.collectAsState()
    if (state.passwordConfirmed) {
        LaunchedEffect(Unit) {
            navigateToSetDetails()
        }
    } else {
        SetNewPasswordScreen(
            confirmNewPassword = viewModel::confirmNewPassword
        )
    }
}

and this is the view model:
@HiltViewModel
class SetNewPasswordViewModel @Inject constructor(
    private val setNewPassword: SetNewPassword,
) : ViewModel() {
    val state: StateFlow<SetNewPasswordViewState> = setNewPassword.flow
        .map { hasSetNewPassword ->
            SetNewPasswordViewState(passwordConfirmed = hasSetNewPassword)
        }
        .stateIn(
            scope = viewModelScope,
            started = SharingStarted.WhileSubscribed(),
            initialValue = SetNewPasswordViewState.Empty
        )

    fun confirmNewPassword(newPassword: String, repeatedNewPassword: String) {
        viewModelScope.launch {
            setNewPassword(SetNewPassword.Params(newPassword, repeatedNewPassword))
        }
    }
}

My problem is when I try to navigate back from
SetDetailsScreen
to
SetNewPasswordScreen
I'm getting true for state.passwordConfirmed again, and I'm stuck in a loop.
I've thought about resetting passwordConfirmed right after the if statement, or using previousBackStackEntry in SetDetailsScreen to store that password should be confirmed again, but it doesn't seem right to do so every time I want to navigate back to a screen that got a result. What's the best practice for this kind of situation?


text:
Q: How to get a wstring in Chinese from rapidjson::Document? I'm a student, and developing a PC-Client with cpp. I do not know how to deal with which rapidjson with encoding Unicode. I always get a messy code. I am a jackeroo about cpp, how can i get the correct result? I will appreciate it much!
Just show a example:
class Test {
    // I have got the string of json
    // eg: { "name" : "小明" }
    public : void test(const std::string& data) {
        rapidjson::Document json;
        json.Parse<0>(data.c_str());

        // there are a method GetString() , return a string
        // The name value are another Chinese characters(I guess which because of its encoding).
        // I want to get a wstring which value is "小明"(Not a messy code). How can i do ?
        std::string name = json["name"].GetString();
    }
};

// I had used this method
// But still got a messy code
str::UnicodeToAnsi();

A: #include <codecvt>
#include <string>

// convert UTF-8 string to wstring
std::wstring utf8_to_wstring (const std::string& str)
{
    std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
    return myconv.from_bytes(str);
}

// convert wstring to UTF-8 string
std::string wstring_to_utf8 (const std::wstring& str)
{
    std::wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
    return myconv.to_bytes(str);
}

Convert wstring to string encoded in UTF-8 Thanks!


text:
Q: Issue with taking out a segment of an character array in C I have a source.txt file here:
https://palomar.blackboard.com/bbcswebdav/pid-1168887-dt-content-rid-3710280_1/courses/2177-70219/payfile%281%29.txt
void readData() { // Scans each line from the .txt and puts each line into an element in the array
    FILE *fp;
    fp = fopen("info.txt", "r");

    char Line[100];
    int i = 0;

    while (!feof(fp)) {

        char agetemp[3];
        char tenuretemp[2];
        char salarytemp[7];

        fgets(Line, 100, fp);
        strsub(Line, employee[i].first, 0, 6);
        strsub(Line, employee[i].initial, 8, 9);
        strsub(Line, employee[i].last, 10, 18);
        strsub(Line, employee[i].street, 20, 35);
        strsub(Line, employee[i].city, 37, 46);
        strsub(Line, employee[i].state, 49, 50);
        strsub(Line, employee[i].zip, 52, 56);
        strsub(Line, employee[i].sex, 61, 61);

        strsub(Line, agetemp, 58, 59);
        employee[i].age = atoi(agetemp); // converted the age column to an int

        strsub(Line, tenuretemp, 63, 63);
        employee[i].tenure = atoi(tenuretemp); // converted tenure column to an int

        strsub(Line, salarytemp, 65, 70);
        employee[i].salary = atof(salarytemp); // converted the salary column to float

        i++;
    }
}

And my assignment is giving me a user-made function, called strsub, which is defined here:
void strsub(char buf[], char sub[], int start, int end) { // function template for strsub
    int i, j;

    for (j = 0, i = start; i <= end; i++, j++) {
        sub[j] = buf[i];
    }
    sub[j] = '\0';
}

So basically when I scan the source .txt file the strsub function is singling out particular segments and putting them into it's respective array of structure. It works fine for the most part, for example when I print out employee[2].city:
https://prnt.sc/hl25n7
Nothing is wrong there. However, when I try to print out the employee[i].first variable, it clumps together a bunch of letters, more than what I told it to do, and I don't know why. Here's a picture of when I try to print out employee[2].first:
https://prnt.sc/hl26gt
In the readData(), I only told it to go from 0 to 6, why is it taking in more input than what I told it do rather than just the first 7 characters?
Oh, and also this is my structure right here; I put it in a separate header file:
struct info {
    char first[7];
    char initial[1];
    char last[9];
    char street[16];
    char city[11];
    char state[2];
    char zip[5];
    int age;
    char sex[1];
    int tenure;
    double salary;
};

A: We need to see the record structure of employee.  If first is defined as char[7] then it does not have enough memory to hold 0-6 (which is 7 char) + null termination.  Also, if initial is 1 char, your function is coping 2 char if input is 8, 9.


text:
Q: What is the difference between "peasant" and "villager"? Can anyone explain to me the difference between peasant and villager? I can see that peasant refers to a social class, and villager refers to a physical location, but are these words interchangeable?

A: Peasant and villager are not completely synonymous. While a villager is just someone who lives in or comes from a village, peasant is more likely to be used in a pejorative way:

*

*(especially in the past, or in poorer countries) a farmer who owns or rents a small piece of land

*(informal, disapproving) a person who is rude, behaves badly, or has little education

A peasant might be described as of low social status, or uncouth, similar to a peon, serf, churl, boor, lout. Closer to villager are synonyms like yokel, bumpkin; but these still imply judgment or disapproval.
Villager alone lacks such a strong negative connotation. It could be used to describe someone from a village without obvious reference to their profession and without implying that they're ignorant or from the "back woods", though there are often assumptions that life in villages matches stereotypes such as being simpler, more authentic, or less modern: The villagers adjusted well after moving to the big city.
Interestingly, the etymology of both words reflects that they describe people from a physical location. Peasant is from Latin pagus "country or rural district"; villager is from Latin villa "country house, farm".

A: A villager is someone who lives in a village.
A peasant, instead, is "a poor farmer of low social status who owns or rents a small piece of land for cultivation (chiefly in historical use or with reference to subsistence farming in poorer countries)." [NOAD]
They're not really interchangeable, and not even synonyms, according to the Oxford American Writer's Thesaurus. Furthermore, you can't exactly use "villager" to refer to someone who lives in a city, simply because "village" and "city" are two different types of "people agglomeration". A village is generally even smaller than a town, which itself is smaller than a city.

A: I think OP may be conflating villager one who lives in a village, with villein (or villain) a feudal serf in medieval times.
In the UK (and US, I would hope), the word peasant can't really be applied to living people except as a "metaphoric" insult, though I believe there still are people living as peasants in many other countries. @Alenanno's definition of the word is as good as any.
In the UK today, villagers are likely to be significantly wealthier than the average of the population at large, if we accept the strict definition of the word. Poor people have long since migrated to urban areas in search of work (agriculture is largely mechanised these days). Rich people can afford the higher costs of maintaining an acceptable standard of living in a remote location.
However, those wealthy village-dwellers do employ domestic cleaners, gardeners, etc., and there are always other reasons why some people in a village are relatively poor. It's my impression that some of the wealthier people do sometimes refer to their poorer neighbours collectively as "the villagers", whilst thinking of themselves as somehow above such crude social stratification.

A: They are interchangeable in the context of a peasant who lives in a village, but not so for peasants residing outside a village, such as in a large city or on a farm, or for non-peasants residing in villages.
(Thanks @Martin Beckett for noticing I missed the last point)


text:
Q: Insert image in jsp I'am using Struts2 project with tomcat server and I want to load pictures from my project I put the picture into webapp/WEB-INF/images/image.png and this in jsp  but I've go this as en error in the browser

GET http://localhost:8080/crudreverse/WEB-INF/images/image.png 404

A: Try this:

A: Files under WEB-INF are, by design, not directly accessible to clients, unless you disable normal security precautions (please don't).
Images (in general) should not be stored in the app itself, but if they are, they need to not be under WEB-INF.
If they are under WEB-INF "on purpose" then you need an endpoint to stream those images, but there's little reason to do that.


text:
Q: Deploying binaries to Maven Central On the internets there is quite a lot of conflicting information on how/if binaries can be deployed to Maven Central.
As I would like to avoid hiding them inside the JAR, I have found the guide which suggests using the POM target and then the codehaus plugin in order to deploy the required binary:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <packaging>pom</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>mybinary.so</file>
                                    <type>so</type>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

I use the following ANT task to upload the binary:
<target name="stage" depends="" description="deploy release version to Maven staging repository">
    <artifact:mvn>
        <arg value="org.apache.maven.plugins:maven-gpg-plugin:1.3:sign-and-deploy-file" />
        <arg value="-Durl=${ossrh-staging-repository-url}" />
        <arg value="-DrepositoryId=${ossrh-server-id}" />
        <arg value="-DpomFile=pom.xml" />
        <arg value="-Dfile=mybinary.so" />
        <arg value="-Pgpg" />
    </artifact:mvn>
</target>

When I run the task, I can see my binary uploading and the SUCCESS return message, but when I log in and check the OSS control panel, my upload only contains the POM file.
Any clues? Any success stories? And finally why is this so difficult, to me Ivy was already too complicated after pypi, but Maven seems oh-so-much-worse.


text:
Q: WildFly plugin for Gradle Is there a plugin available for Gradle that can be used for deploying to a remote WildFly server? I did a search and couldn't find anything yet.

A: WildFly team is aware of this and working on it. I'll keep you update on when the plugin would be available. In the meanwhile, you can look at the Maven plugin at:
https://docs.jboss.org/wildfly/plugins/maven/latest/

A: You can already utilize the Cargo plugin for this. It supports deploying to a remote WildFly server.

A: Gradle plugin is already available at:
https://github.com/nikit-cpp/wildflyDeployPlugin


text:
Q: Calculating the expectation of a sum of dependent random variables Let $(X_i)_{i=1}^m$ be a sequence of i.i.d. Bernoulli random variables such that $\Pr(X_i=1)=p<0.5$ and $\Pr(X_i=0)=1-p$. Let $(Y_i)_{i=1}^m$ be defined as follows: $Y_1=X_1$, and for $2\leq i\leq m$
$$
Y_i = \begin{cases}
1,\ &\mathrm{if\ \ \ }p\left(1-\frac{1}{i-1}\sum_{j=1}^{i-1}Y_j\right)+(1-p)\frac{1}{i-1}\sum_{j=1}^{i-1}Y_j<\frac{1}{i}\sum_{j=1}^iX_j\\
0,\ & \mathrm{otherwise}
\end{cases}
$$
Finally, define
$$
Z_i=\begin{cases}
Y_i,\ &\mathrm{w.p. }\ \ 1-p\\
1-Y_i,\ & \mathrm{w.p. }\ \ p
\end{cases}
$$
for $i=1,2,\ldots,m$. I want to calculate or get an upper bound on the expectation $\mathbb{E}\left(\sum_{i=1}^mZ_i\right)$ and the variance $\mathrm{Var}\left(\sum_{i=1}^mZ_i\right)$.
For any $i$, we have $\mathbb{E}Z_i = p+(1-2p)\mathbb{E}Y_i$. So a trivial upper bound is
$$
\mathbb{E}\left(\sum_{i=1}^mZ_i\right) =mp+(1-2p)\sum_{i=1}^m\mathbb{E}Y_i\leq mp+m(1-2p) = m(1-p)
$$
becasue $\mathbb{E}Y_i\leq1$. Unfortunately, when trying to calculate explicitly $\mathbb{E}Y_i$ things quickly become quite involved. Is there any way to get better bounds? Numerical calculation (as well as analytical calculation of the first few) of the means of the random variables $Y_i$ suggest that $\mathbb{E}Y_i\leq \mathbb{E}Y_1 = p$ for any $i$, which would give
$$
\mathbb{E}\left(\sum_{i=1}^mZ_i\right)\leq 2mp(1-p)
$$
However, it is not clear if $\mathbb{E}Y_i\leq \mathbb{E}Y_1$ is indeed true.


text:
Q: Arc length of a sequence of semicircles. Let $\gamma_1$ be the semicircle above the x axis joining $-1$ and $1$.
Now divide this interval into $[-1,0]$ and $[0,1]$, and trace a semicircle joining $-1,0$ above the $x$-axis and another one joining $0,1$ below the $x$-axis, call this curve $\gamma_2$
Keep subdividing the interval into $2^n$ subintervals, proceding as above, and call the resulting curve $\gamma_n$.
Now, from looking at their graphs, I can say that the arc length of all these curves is $\pi$, but the arc length of the limit, $\gamma$ (which I think should be a straight line connecting $-1$ and $1$) is $2$.
Why does this happen? Shouldn't the arc length of the limit be $\pi$ as well? Does $\gamma_n\to \gamma$ uniformly?
One of my professors said that this is because
$$
\operatorname{Arc}(\gamma_i)=\int_D\sqrt{1+\gamma_i'^2}dx
$$
And that $\gamma_i'$ becomes pretty crazy when $i$ is large (as it's $\pm \infty$ on the edges of the circles).

A: The problem with this argument, and many other alike, is that the arc length of a curve is not a continuous function of a curve, which means that if sequence of curves $\gamma_i$ converges to a curve $\gamma$ (notion of convergence of functions like that can be made formal, but let me not do that here), then there is no guarantee the sequence of arclengths $l(\gamma_i)$ to converge to the arclength $l(\gamma)$. Indeed, if you look at the integrals $\int_0^1\sqrt{1-\gamma_i'(t)^2}dt$, then you might expect that the expression under the integral converges to $\sqrt{1-\gamma'(t)^2}$, which however isn't the case, because convergent sequence of differentiable functions (I am ignoring the "cusps" where the semicircles meet here; they are important as well, but that's beyond my point right now), then the sequence of derivatives need not be convergent.

A: $\lim \limits_{n\to\infty}{2^n*Pi/2^n}$
This obviously is $Pi$. The circles may seem very small, but can't get $0$ (otherwise, the two points at $-1$ and $1$ wouldn't be connected). Consider their radius' as infinitesimal, so the curve length always will stay $Pi$ and will never get $2$.
Also, the the length of $2$ would mean that the curve is a straight line and accordingly that it contains all points with $y=0$ and $-1\le x\le1$.
There are simply $2^n+1$ points that touch the x-axis (so the x-coordinates are rational), infinitely many, but not all. This might sound contradictory, however, Cantor has proven that there are more real than rational numbers (Cantor's Diagonal Argument).

A: The arc length should also be $\pi$. The curve "converges" to a straight line, but is actually an infinite union of semicircles of 0 length. You cannot approximate the arc length like that, it is similar to the fallacious proofs that $\pi=4$. In fact, there are $2^n$ semicircles each with diamater $\frac{1}{2^n}$, then the arc length is $2^n\pi\frac{1}{2^n}=\pi$.


text:
Q: Multiple layouts vs css trickery vs partials in a rails app for dynamic page layout I was wondering if anyone could comment on which way is better and WHY?
Here is a simplified version of what I have ( in HAML):
#header
#root
  #content
    = yield
  #sidebar
    = context_navigation
#footer

The problem:
I want #sidebar to display on some pages to show context menu, such as on the account page to show links to profile, password, order history. On the product page show links to product specifications,  description, "send link", etc. But not on other pages - such as on the home page I need to use the whole width of #root for #content to show news or featured items.
Solution & Question:
I have several ideas on how to implement it, but I was looking for some input at to which one you think is better and please explain WHY? The main objective is maintainability of code.
Here are some ideas:

*

*CSS \ SCSS trickery - make the sidebar a collapsible div if there context navigation is empty

*Use an else/if to load different partials depending on which part of the site I'm in.

*Create a separate layout (seems like an overkill - as I understand layouts are to be used mostly for different media such as screen vs. print vs. pdf vs. mobile - etc)

*Any other ideas?

Thank you,
Nick

A: You could use nested layouts to get this working:
http://guides.rubyonrails.org/layouts_and_rendering.html#using-nested-layouts

A: Different views might serve you well... you may need to rethink your controller also to make them more use case specific. Going along this route will make you app more dynamic, increase cohesion amongst all of the components and allow for greater extensibility.


text:
Q: Handle ambiguous struct declarations while debugging C code I'm currently debugging through code for a certain coordinate projection algorithm in osgeo/proj.4, to compare it with another implementation where I suspect the presence of a bug.
proj.4 contains multiple different declarations for a certain struct with the same name, each one of those in a separate .c-file:
struct pj_opaque {
    double phic0;
    double cosc0, sinc0;
    double R2;
    void *en;
};

struct pj_opaque {
    double K, c, hlf_e, kR, cosp0, sinp0;
};

(and many more).
The correct struct declaration I'm interested in:
struct pj_opaque {
    double  A, B, E, AB, ArB, BrA, rB, singam, cosgam, sinrot, cosrot;
    double  v_pole_n, v_pole_s, u_0;
    int no_rot;
};

This seems to cause problems in the debugger. At runtime, I'm not able to view all values of a struct I'm interested in, because the debugger uses an incompatible declaration for the type, which doesn't have the members I want to look at.
Here is an example:
Q is of type pj_opaque*, I want to look at the member u_0. In the watch, struct Q does not even have a member u_0. Accessing it directly via Q->u_0 gives an error. (class"XYZ" has no member "UVW")

Is there a general way to deal with this kind of ambiguity while debugging, like a compiler switch, which makes those ambiguous names unique?
For the record: proj.4 is built with vcpkg on Windows, debugger is Visual Studio 2017.

A: I'm guessing the problem is that from the caller, the struct declaration is opaque so you won't be able to see it, regardless of if there's one or several struct definitions elsewhere. Meaning that the caller just has an incomplete declaration such as typedef struct pj_opaque pj_opaque somewhere. This means that the caller can't know the contents of that struct, it is a way to do OO and private encapsulation in C.
The sensible thing to do would be something like:
// top of caller .c file
#ifdef DEBUG_RELEASE
struct pj_opaque { /* definition here */ };
#endif

This allows the compiler of the caller .c file to know what the structure contains, pass this on to the object file, which in turn can get passed on to the debugger file format. This is a bit dirty though, since it exposes the code to the caller, if only in debug mode. A prettier alternative would be to create a header file like "pj_opaque_debug.h" where you put the above compiler switch code.


text:
Q: 'Nested Intervals Theorem' in $\mathbb{R}^2$ Cantor's Nested Intervals Theorem can be stated as "If $\{[a_n,b_n]\}_{n=1}^\infty$ is a nested sequence of closed and bounded intervals, then $\cap_{n=1}^\infty [a_n,b_n]$ is not empty.  If, in addition, the diameters of the intervals converge to $0$, then $\cap_{n=1}^\infty [a_n,b_n]$ has precisely one member."
How exactly does this generalize to $\mathbb{R}^2$?  The first part I think is pretty straightforward: 'If $\{[a_n,b_n] \times [c_n,d_n]\}_{n=1}^\infty$ is a nested sequence of closed and bounded rectangles in $\mathbb{R}^2$, then $\cap_{n=1}^\infty[a_n,b_n] \times [c_n,d_n]$ is nonempty.'
It's the second part that I'm curious about.  The natural two-dimensional analogue of the diameter of the intervals converging to $0$ would be the area of the rectangles going to zero.  However, this could result in a point or a line segment.  If $a$,$c$ and $b$,$d$ are the supremums and infimums respectively of the sequences of endpoints of the intervals $[a_n,b_n]$ and $[c_n,d_n]$, is the correct generalization that the intersection will be $[a,b] \times \{c=d\}$, $\{a=b\} \times [c,d]$, or a single point, $\{(a,c)\}$?  Or is it more correct to say that if $\mbox{diam}[a_n,b_n] \to 0$ and $\mbox{diam}[c_n,d_n] \to 0$ then the intersection is a single point, $\{(a,c)\}$.  The latter doesn't require us to make 'area' meaningful so I have the feeling this is the case but I'd like to hear some thoughts on it.
Afterthought: Does a similar idea work for nested sequences of closed balls $B[x,r]$ as $r \to 0$?

A: The correct generalization would be by speaking of their diameters going to zero. It is not enough that their Lebesgue measure (or, volume, area) goes to zero, as pointed out this can yield other results than singletons. Basicly any "lower dimensional" object has Lebesgue measure of zero, such as a line in the plane.
In fact, the second part of the theorem generalizes to any complete metric space $(X,d)$ by considering a sequence $(F_{i})_{i=1}^{\infty}$ of nested non-empty closed sets such that diam$(F_{i})\to 0$. Here's a sketch how to prove it. By choosing a sequence with $x_{i}\in F_{i}$ for all $i$ we obtain a Cauchy sequence (since the diameters go to zero) which has a limit $x\in F_{1}$ since $X$ is complete and $F_{1}$ is closed. Now it is not hard to show that $x\in \cap_{i=1}^{\infty}F_{i}$ since if there was an index $i_{0}$ with $x\notin F_{i_{0}}$, then $x\notin F_{n}$ for all $n\geq i_{0}$ (since the sequence of sets is nonincreasing). Since $F_{i_{0}}$ is closed its complement is open, so there exists $r>0$ so that $B(x,r)\subset F_{i_{0}}^{c}$. On the other hand, we find $k_{0}$ (by definition of convergence) so that $d(x,x_{i})<r$ for all $i\geq k_{0}$. Choose $n_{0}=\max\{k_{0},i_{0}\}$, whence $d(x,x_{i})$ is less than $r$ (by convergence) and more or equal than $r$ (since the sequence continues in the complement of $B(x,r)$) for all $i\geq n_{0}$, which is a contradiction. Hence $x\in \cap_{i=1}^{\infty}F_{i}$. If there would be more elements in the intersection, say another point $y$, we find $F_{i}$ with diameter less than their distance (since the diameters go to zero) and yet containing both points, which is again a contradiction. Hence the intersection contains only $x$, i.e. it is a singleton.
So to your last question: Yes it works for a nested sequence of closed balls with diameters going to zero by the result above if the underlying metric space is complete (and $\mathbb{R}^{n}$ is complete for all $n\in\mathbb{N}$).


text:
Q: An identity on Kähler manifold I am reading  The Seiberg–Witten equations and applications to the topology of smooth four manifolds by John Morgan. In the calculation for a Kähler surface in page 116, he uses an identity: for a smooth real valued function $\lambda$ on a Kähler surface $\bar\partial\partial\lambda\wedge\omega=\frac{2}{i}\Delta(\lambda)dvol$. However my own calculation doesn't match up with the coefficint, can someone please point out where is the mistake I am making. Here's my calculation. I wonder if there's an easier way to see this.
On an appropriate local chart $\omega=dx_1\wedge dy_1+dx_2\wedge dy_2$.
\begin{align}
&\partial\bar\partial\lambda\wedge\omega\\
&=\bigg(\sum\limits_{k=1}^2\frac{\partial^2\lambda}{\partial z_k\partial\bar{z}_k}  dz_k\wedge d\bar{z}_k\bigg)\wedge\omega\\
&=\bigg(\sum\limits_{k=1}^2\frac{1}{2}\big(\frac{\partial}{\partial x_k}-i\frac{\partial}{\partial y_k}\big)\frac{1}{2} \big(\frac{\partial}{\partial x_k}+i\frac{\partial}{\partial y_k}\big)(\lambda) dz_k\wedge d\bar{z}_k\bigg)\wedge\omega\\
&=\frac{1}{4}\times -2i \sum\limits_{k=1}^2\big(\frac{\partial^2}{\partial x_k^2}+\frac{\partial^2}{\partial y_k^2}\big)(\lambda) dx_k\wedge dy_k\wedge\omega\\
&=\frac{i}{2}\Delta(\lambda)dvol
\end{align}

A: On any Kahler manifold, the Kahler identities say that $[\Lambda, \bar\partial] = -i \partial^\dagger$, where $\Lambda$ is the adjoint of the Lefchetz operator and $\partial^\dagger$ is the adjoint of $\partial$. For a smooth function $f$, we know that $\partial^\dagger f = 0$ for degree reasons. Thus
$$
\Delta_\partial f
= (\partial \partial^\dagger + \partial^\dagger \partial)f
= \partial^\dagger \partial f
= i(\Lambda \bar\partial - \bar\partial \Lambda) \partial f
= i \Lambda \bar\partial\partial f
$$
as $\Lambda \partial f = 0$ for degree reasons. As $\Lambda$ is complex linear and $\Delta_d = 2\Delta_\partial$, we conclude that
$$
\Delta_d f
= 2i \Lambda \bar\partial\partial f
= \frac 2i \Lambda \partial \bar\partial f
$$
Taking the product with the volume form $\omega^n/n!$ we get
$$
\Delta_d f \, \omega^n/n!
= \Lambda \frac 2i \partial\bar\partial f \, \omega^n/n!
= \frac 2i \, \partial\bar\partial f \wedge \omega^{n-1}/(n-1)!.
$$
On a surface, where $n = 2$, this agrees with what your calculations gave.


text:
Q: Generate unique id using strings I am parsing data from multiple sources and I want to assign a unique (string) id to each entry. Each entry contains a title (string), url(string) and body(string). We can get same title from multiple sources but those will have different urls and I would like to store both the items in that case. I am thinking of creating a hash of title and url and assign that as an id, that ways if I get same title and url from different sources, the id will be same and I will be able to identify that it's a duplicate.
import hashlib
hashlib.sha256(str("title url").encode('utf-8')).hexdigest()

But I think there can be a case where 2 different title url combinations might generate same hash, not sure how to overcome the clash. Can someone suggest a way of generating unique identifier using strings
I don't want to use timestamp because I might get same row from different sources at different times

A: You're safe, you won't have 2 different title url combinations generating same hash with SHA-256

SHA256 is a cryptographic hash function, from the SHA-2 hash family, and is a standard from 2020.
The collision probability (2 inputs gives same output) is 1/(2^128) which is about 2e-39.

See:  SHA-256 collisions on crypto.stackexchange


text:
Q: Solving Two sum: NoneType' is not iterable The problem statement : Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
My solution(trying to do better than bruteforce approach):
def twoSum(nums, target):
    """
    :type nums: List[int]
    :type target: int
    :rtype: List[int]
    """
    for i in range(0,len(nums)):
        if (target - nums[i]) in nums.remove(nums[i]):  #error
            if i != nums.index(target - nums[i]):
                return i, nums.index(target - nums[i])

I keep getting Line 9: TypeError: argument of type 'NoneType' is not iterable .
I believe.remove() returns a list and I am trying to check if target - nums[i] is in the list.

A: remove() returns None. Try this instead:
def twoSum(nums, target):
    """
    :type nums: List[int]
    :type target: int
    :rtype: List[int]
    """
    for i in range(0,len(nums)):
        nums.remove(nums[i])
        if (target - nums[i]) in nums:
            if i != nums.index(target - nums[i]):
                return i, nums.index(target - nums[i])

Alternately, if you need to maintain nums, make a copy and remove:
def twoSum(nums, target):
    """
    :type nums: List[int]
    :type target: int
    :rtype: List[int]
    """
    for i in range(0,len(nums)):
        nums_copy = list(nums)
        nums_copy.remove(nums[i])
        if (target - nums[i]) in nums_copy:
            if i != nums.index(target - nums[i]):
                return i, nums.index(target - nums[i])

A: a.remove() doesn't return a list. It returns None
>>> a_list = [1, 2]
>>> print(a_list.remove(1))
None
>>> print(a_list)
>>> [2]

As the error message suggest to iterate an object you need an object which is iterable.


text:
Q: Can you choose #define based on parameter? To simplify a commonly occurring bitmap lookup, I decided to write a macro for it.  This macro would take in parameters array, position, and number of bits per entry.  The latter is always 1, 2, or 3, to be determined at compile time.
The macros for one and two bits per entry are quite simple:
#define 1BITLOOKUP(array, index) (array[index / CHAR_BIT] >> (index % CHAR_BIT)) & 1
#define 2BITLOOKUP(array, index) (array[2 * index / CHAR_BIT] >> (2 * index % CHAR_BIT)) & (0x11)

However, three-bit bitmap will be more complex, since it will cross byte boundaries.  For the sake of efficiency, I do not wish to include that code when I am only using one- and two- bit lookups.  So I would like to use a macro of the sort
#define BITMAPLOOKUP(array, index, k) kBITLOOKUP(array, index)

However, this does not work.  Is there a workaround?
NOTE: This has been updated to a non-minimal working example, as per request of multiple commenters.

A: You can paste the macro argument into other words without separator, using the ## construct. So here this will work:
#define FUNCTION(k) FUNCTION##k

Try it online!

A: @MadPhysicist suggests something like:
#include <stdio.h>

static void func0(void) { printf("0\n"); }
static void func1(void) { printf("1\n"); }
static void func2(void) { printf("2\n"); }
static void func3(void) { printf("3\n"); }

static void (*func[])(void) = {func0, func1, func2, func3};

int main(void)
{
    func[1]();
    return 0;
}

This has an advantage: you are not limited to compile time literals:
for (int i = 0; i < 3; i++) {
     FUNCTION(i); /* invalid */
     func[i](); /* valid */
}


text:
Q: Is there promise resolve return more than one value function get(url) {
  console.log('Making fetch() request to: ' + url);

  let promise = new Promise((resolve, reject) => {
    fetch(url).then(response => {`enter code here`
      if (response.ok) {
        const contentType = response.headers.get('Content-Type') || '';

        if (contentType.includes('application/json')) {
          response.json().then(obj => {
            resolve(obj);
          }, error => {
            reject(new ResponseError('Invalid JSON: ' + error.message));
          });
        } else if (contentType.includes('text/html')) {
          response.text().then(html => {
            resolve({
              page_type: 'generic',
              html: html
            });
          }, error => {
            reject(new ResponseError('HTML error: ' + error.message));
          });
        } else {
          reject(new ResponseError('Invalid content type: ' + contentType));
        }
      } else {
        if (response.status == 404) {
          reject(new NotFoundError('Page not found: ' + url));
        } else {
          reject(new HttpError('HTTP error: ' + response.status));
        }
      }
    }, error => {
      reject(new NetworkError(error.message));
    });
  });

  return promise;
}

A:

    const pobj = new Promise((resolve,reject)=> {
        setTimeout(()=>{
            $.get("https://jsonplaceholder.typicode.com/posts1",function(data){
                resolve(data)
            }).fail((err)=>reject("Fail to load"))
        },1000)
    })

    async function abc(){
        const ob1= await pobj;
        ob1.forEach(element => {
            document.write(element.userId +"


text:
Q: 'ActualWidth' and 'ActualHeight' give the initial values, but not the actual values I have two grids in my app, a container grid and a child grid. It is possible for the container grid's width and height to change at runtime. Child grids have a default width and height of 700x700. If the parent grid is 300x300, then the child grid will be 300x300 as well, but when I get the actual width and height of the child grid at runtime, I still get 700x700, despite the fact that the actual width and height are 300x300.
XAML
<Grid Width="300" Height="300">
    <Grid Width="700" Height="700" Loaded="Grid_Loaded" >
    </Grid>
</Grid>

Code Behind
private void Grid_Loaded(object sender, RoutedEventArgs e)
{
    Grid grid = sender as Grid;
    int width = (int)grid.ActualWidth;  //<-- 700, but 300 expected
    int height = (int)grid.ActualHeight;//<-- 700, but 300 expected
}


text:
Q: How to use lombok's @Delegate annotations in Java I would like to use lombok's @Delegate annotations in the my code.
Please check code snippet below and it throws an error saying :getAge() is already defined :
public interface I {
    String getName();
    int getAge();
}

@Data
public class Vo {
    private String name;
    private long age;
}

@AllArgsConstructor
public class Adapter implements I {

    @Delegate(types = I.class)
    private Vo vo;

    //I want to use my own code here,Because vo.getAge() returns a long,But I.getAge() expects a int
    public int getAge(){
        return (int) vo.getAge();
    }
}

A: From the lombok documentation:

To have very precise control over what is delegated and what isn't, write private inner interfaces with method signatures, then specify these private inner interfaces as types in
@Delegate(types=PrivateInnerInterfaceWithIncludesList.class, excludes=SameForExcludes.class).

Which means that to include everything in I, but exclude only getAge, you can  declare an extra inner interface like this:
private interface Exclude {
    int getAge();
}

and pass it to exclude:
@Delegate(types = I.class, excludes = Exclude.class)


text:
Q: POSIX shared memory and semaphore does't work on Mac OS 10.14.6 and Ubuntu 18.04 I wrote a simple c program. Used share memory and semaphore. The clang lsp warned that the the shamt is invalid in c99 when I complied the program server.c
Undefined symbols for architecture x86_64:
  "_shamt", referenced from:
      _main in server-214a3e.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

But I have main function in server.c
Here is the code:
#include <assert.h>
#include <errno.h>
#include <pthread.h>
#include <semaphore.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <time.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/stat.h>
#include <fcntl.h>
#define MSG_MAX_SIZE 4096

char *server_memory, *client_memory;
sem_t *sig_server, *sig_client;
char message_client[MSG_MAX_SIZE];
char message_server[MSG_MAX_SIZE];

key_t generate_key(int ID) {
  key_t res;
  if ((res = ftok("/tmp", 'C')) == -1) {
    perror("ftok faild ");
    exit(1);
  }
  return res;
}

int get_shm_id(key_t key) {
  int res = shmget(key, sizeof(char) * MSG_MAX_SIZE, IPC_CREAT | 0666);
  if (res == -1) {
    perror("server: Failed to open/creat share memory");
    exit(2);
  }
  return res;
}

int main() {

  key_t key_client = generate_key('C');
  key_t key_server = generate_key('S');

  int shm_server_id = get_shm_id(key_server);
  int shm_client_id = get_shm_id(key_client);

  server_memory = shamt(shm_server_id, (void *)0, 0);
  client_memory = shamt(shm_client_id, (void *)0, 0);

  sig_server =
      sem_open("/tmp/signal_server", O_CREAT | 0666, S_IRUSR | S_IWUSR, 1);
  sig_client =
      sem_open("/tmp/signal_client", O_CREAT | 0666, S_IRUSR | S_IWUSR, 1);

  while (1) {
    printf("enter message,enter q to quit,enter p to pass input\n");
    fgets(message_server, MSG_MAX_SIZE, stdin);
    if (message_server[0] == 'q') {
      // :TODO
      exit(0);
    } else if (message_server[0] != 'p') {
      sem_wait(sig_client);
      strcpy(client_memory, message_server);
      sem_post(sig_client);
    }
    if (sem_trywait(sig_server) == -1) {
      printf("The client is typing\n");
      printf("enter r to reply and or w to wait The other party:");
      char c = getchar();
      if (c == 'w') {
        sem_wait(sig_server);
      } else if (c == 'r') {
        continue;
      } else {
        // :TODO
      }
    }
    strcpy(message_client, server_memory);
    sem_post(sig_server);
    printf("message recived:%s\n", message_client);
  }

  return 0;
}

And I also tried to compile the code on Ubuntu 18.04 but there are more errors when compiling.
/tmp/ccrxmeXg.o: In function `main':
server.c:(.text+0xd5): undefined reference to `shamt'
server.c:(.text+0xf7): undefined reference to `shamt'
server.c:(.text+0x11e): undefined reference to `sem_open'
server.c:(.text+0x143): undefined reference to `sem_open'
server.c:(.text+0x19c): undefined reference to `sem_wait'
server.c:(.text+0x1bf): undefined reference to `sem_post'
server.c:(.text+0x1ce): undefined reference to `sem_trywait'
server.c:(.text+0x209): undefined reference to `sem_wait'
server.c:(.text+0x234): undefined reference to `sem_post'
collect2: error: ld returned 1 exit status

So how to solve this problem. I want to run this program on my Mac OS but also Ubuntu.
Please help me!


text:
Q: How can I run jQuery function only if user hasn't scrolled? I've been trying to incorporate an auto scroll function on my website (live here). I want it to scroll to the content 6 seconds after load, but only if the user is on the very top of the page and hasn't scrolled enough to uncover the #introduction element.
I have this code, which works, but I don't want it to execute if the user has already scrolled by themself:
$('html,body').delay(6000).animate({
    scrollTop: $('#introduction').offset().top
}, 1000);

I would also like it to happen with a type of ease-in-out, if possible.

A: You can do something like this:
$('html')
  .delay(6000)
  // If the user has scrolled down, do nothing. Otherwise scroll to element
  .queue(function(next) {
    if ($(window).scrollTop() > 0) {
      return;
    } else {
      next();
    }
  })
  .animate(
    {
      scrollTop: $('#introduction').offset().top,
    },
    1000,
    'swing',
  );

As for the ease-in-out animation you need JqueryUI for that. swing and linear are the Jquery library supported easing functions.


text:
Q: Simplify $\sum_{l=0}^\infty \sum_{r=0}^\infty\frac{\Gamma(L+r-2q)}{\Gamma(L+r-1+2q)} \frac{\Gamma(L+r+l-1+2q)}{\Gamma(L+r+l+2)}\frac{r+1}{r+l+2}$ This question is a continuation of this post.

Let $r,l,L\geq 1$ be integers.
Assume that $q\in [0,1]$ is a real number.
The authors obtained the following equation $36$ in their paper (I express in summation forms).
$$\sum_{r=1}^\infty \sum_{l=1}^\infty \frac{r}{r+l} 4(1-q)q \frac{Γ(L)}{Γ(L − 2p)} \frac{Γ(L + l − 1 − 2p)}{Γ(L + l − 2q)} \frac{Γ(L + l + r − 1 − 2q)}{ Γ(L + l + r) } = $$
$$ 1 - \frac{2q^2}{(1-2q)^2} - \frac{2\pi q(1-q)}{(1-2q)(3-4q)} \cot(2\pi q).$$
Note that the above formula are equal in the sense of asymptotically.
In the midst of obtaining the above formula, I stuck at the following.

Question: Is it possible to express
  $$\sum_{l=0}^\infty \sum_{r=0}^\infty\frac{\Gamma(L+r-2q)}{\Gamma(L+r-1+2q)} \frac{\Gamma(L+r+l-1+2q)}{\Gamma(L+r+l+2)}\frac{r+1}{r+l+2}$$
  in closed form independent of summations (possibly in terms of Gamma function)?

I tried to express above double summations using Appell's series.
However, I stuck at
$$\frac{\Gamma(L-2q)}{\Gamma(L+2)} \sum_{l=0}^\infty \sum_{r=0}^\infty \frac{(L-1+2q)_{l+r}}{(L+2)_{l+r}} \frac{(L-2q)_r}{(L-1+2q)_r} \frac{(1)_l}{l!r!} \frac{(2)_r}{(r+l+2)}.$$
In particular, can we express
$$\frac{(L-2q)_r}{(L-1+2q)_r (r+l+2)}$$
to be something which allows us to use Appell series?

I also tried to evaluate the summation over $l$, that is,
$$\sum_{l=0}^\infty \frac{\Gamma(L+r-1+2q+l)}{\Gamma(L+r+2+l)(r+l+2)},$$
and I arrive at
$$_3F_2(L+r-1+2q,1,r+2; L+r+2,r+3;1)\frac{\Gamma(L+r-1+2q)}{\Gamma(L+r+2)(r+2)}.$$
However, I could not find any formula to evaluate $_3F_2(L+r-1+2q,1,r+2; L+r+2,r+3;1)$ in Wolfram Alpha.

Updated (2 Nov 2018): @Nikos Bagis uses the Mathematica 10 to obtain a closed form for my question.
However, I would like to have a detailed calculations on how to obtain the answer.

A: ...
$$
\sum^{\infty}_{l=0}\sum^{\infty}_{r=0}\frac{\Gamma(L+r-2q)\Gamma(L+r+l-1+2q)}{\Gamma(L+r-1+2q)\Gamma(L+r+l+2)}\frac{r+1}{r+l+2}\tag 0
$$
I have an answer but I use Mathematica 10 for it.
Set
$$
A_0(L,q,x):=\sum^{\infty}_{l=0}\sum^{\infty}_{r=0}\frac{\Gamma(L+r-2q)\Gamma(L+r+l-1+2q)}{\Gamma(L+r-1+2q)\Gamma(L+r+l+2)}(r+1)x^{l+r+1}.
$$
Then using Mathematica evaluate $A_0(L,q,x)$ and FullSimplify it. You will get result. Then integrate the result
$$
\int^{1}_{0}A_0(L,q,t)dt
$$
and FullSimplify it. You get a function of $\cot$, $\Gamma$, ${}_2F_1$ and ${}_3F_2$ functions. But you have to wait a while.
The function ${}_2F_1$ is computable with elementary functions. It is actualy
$$
{}_2F_1(1,-1+L-2q;L;1)=\frac{L-1}{2q}
$$
For the ${}_3F_2$, you have to evaluate
$$
{}_3F_2(1,1+L-2q,-1+L+2q;2+L,L+2q;1),\tag 1
$$
$$
{}_3F_2(2,2+L-2q,L+2q;3+L,1+L+2q;1)\tag 2
$$
and
$$
{}_3F_2(3,3+L-2q,1+L+2q;4+L,2+L+2q;1).\tag 3
$$
Note that these are the zero, first and second derivatives of
$$
{}_3F_2(1,1+L-2q,-1+L+2q;2+L,L+2q;x)\tag 4
$$
at $x=1$. So actualy, you have to compute $(4)$,
or if you prefere the values $(1),(2),(3)$. The function $(4)$ also referes to the problem of finding
$$
\sum^{\infty}_{n=0}\frac{\Gamma(n+a)\Gamma(n+b)}{\Gamma(n+c)\Gamma(n+d)}x^n
$$
So the final answer is

$\ldots$
CONTINUED
Assume that
$$
F_1(L,q,x):=\sum^{\infty}_{l=0}\sum^{\infty}_{r=0}\frac{\Gamma(L+r-2q)\Gamma(L+r+l-1+2q)}{\Gamma(L+r-1+2q)\Gamma(L+r+l+2)}x^lx^r.
$$
Then
$$
F_1(L,q,x)=-\frac{\Gamma(L-2q)(L-2q-1)}{4q-2}{}_2\widetilde{F}_1\left(1,L-2q;L+2;x\right)+
$$
$$
\frac{(L+2q-2)\Gamma(L-2q)}{4q-2}{}_2\widetilde{F}_1\left(1,L+2q-1;L+2;x\right)-
$$
$$
-\frac{\Gamma(L-2q)}{4q-2}{}_2\widetilde{F}_1\left(2,L-2q;L+2;x\right),
$$
where
$$
{}_p\widetilde{F}_q\left(a_1,a_2,\ldots,a_p;b_1,b_2,\ldots,b_q;z\right):=
$$
$$
{}_pF_q\left(a_1,a_2,\ldots,a_p;b_1,b_2,\ldots,b_q;z\right)/(\Gamma(b_1)\Gamma(b_2)\ldots\Gamma(b_q))
$$
is the regularized hypergeometric function.
Set now
$$
F_2(L,q,x):=\sum^{\infty}_{l=0}\sum^{\infty}_{r=0}\frac{\Gamma(L+r-2q) \Gamma(L+r+l-1+2q)}{\Gamma(L+r-1+2q) \Gamma(L+r+l+2)}rx^lx^r.
$$
Then
$$
F_2(L,q,x)=
$$
$$
=\frac{x\Gamma(L-2q+1)(2+L-6q-4Lq+8q^2)}{2(2q-1)(4q-3)\Gamma(L+3)}{}_2F_1\left(2,L-2q+1;L+3;x\right)-
$$
$$
-\frac{\Gamma(L-2q+1)(L+2q-2)}{2(2q-1)(4q-3)\Gamma(L+2)}{}_2F_1(1,L-2q;L+2;x)+
$$
$$
+\frac{\Gamma(L-2q+1)(L+2q-2)}{2(2q-1)(4q-3)\Gamma(L+2)}{}_2F_1(1,L+2q-1;L+2;x)-
$$
$$
-x\frac{\Gamma(L-2q+1)}{(4q-3)\Gamma(L+3)} {}_3F_2\left(2,2,L-2q+1;1,L+3;x\right).
$$
But
$$
F_3(L,q,x)
=\sum^{\infty}_{l=0}\sum^{\infty}_{r=0}\frac{\Gamma(L+r-2q) \Gamma(L+r+l-1+2q)}{\Gamma(L+r-1+2q) \Gamma(L+r+l+2)}(r+1)x^lx^r=
$$
$$
=F_1(L,q,x)+F_2(L,q,x)
$$
and
$$
S=S(L,q)=\int^{1}_{0}x\cdot F_3(L,q,x)dx
$$
But also
$$
k_{11}(b,c):=\int^{1}_{0}x\cdot { }_2F_1(1,b;c;x)dx=
$$
$$
=\frac{(c-1)}{(b-1)(b-2)}\left[2-b+(c-2)\psi(c-2)-(c-2)\psi(c-b)\right],
$$
where $Re(b)<Re(c)$.
$$
k_{12}(b,c):=\int^{1}_{0}x\cdot {}_2F_1(2,b;c;x)dx=
$$
$$
=\frac{(c-1)(c-2)}{(b-1)(b-2)}\left[-1+{}_2F_1(1,b-2;c-2;1)-\psi(c-2)+\psi(c-b)\right]
$$
$$
k_{21}(b,c):=\int^{1}_{0}x^2\cdot { }_2F_1(1,b;c;x)dx
=\frac{(c-1)}{2(b-1)(b-2)(b-3)}\times
$$
$$
\times\left[-(b-3)(2c+b-6)+2(c-3)(c-2)\psi(c-3)-2(c-3)(c-2)\psi(c-b)\right],
$$
$$
k_{22}(b,c):=\int^{1}_{0}x^2\cdot { }_2F_1(2,b;c;x)dx
=\frac{(c-1)(c-2)}{(b-1)(b-2)(b-3)}\times
$$
$$
\times\left[b-c+(c-3){}_2F_1(1,b-3;c-3;1)-2(c-3)\psi(c-3)+2(c-3)\psi(c-b)\right],
$$
and
$$
M(b,c):=\int^{1}_{0}x^2\cdot { }_3F_2(2,2,b;1,c;x)dx=
$$
$$
=-\frac{18}{(b-3)(b-2)(b-1)}-\frac{2b}{(b-3)(b-2)(b-1)}+
$$
$$
\frac{(c-4)(c-3)(c-2)(c-1)}{(b-1)(b-2)(b-c+1)(b-c+2)}
+\frac{35c}{(b-1)(b-2)(b-3)}+
$$
$$
+\frac{3bc}{(b-1)(b-2)(b-3)}-\frac{21c^2}{(b-1)(b-2)(b-3)}
-\frac{bc^2}{(b-1)(b-2)(b-3)}+
$$
$$
+\frac{4c^3}{(b-1)(b-2)(b-3)}-\frac{4(c-1)(c-2)(c-3)(c-4)}{(b-1)(b-2)(b-3)(c-b-1)}+
$$
$$
+\frac{4(-6+11c-6c^2+c^3)\psi(c-3)}{(b-1)(b-2)(b-3)}-\frac{4(-6+11c-6c^2+c^3)\psi(b-c)}{(b-1)(b-2)(b-3)},
$$
where $2+Re(b)<Re(c)$.
Hence the value of the double sum (tag $(0)$) is
$$
S=S(L,q)=-\frac{\Gamma(L-2q)(L-2q-1)}{(4q-2)\Gamma(L+2)} k_{11}(L-2q,L+2)+
$$
$$
+\frac{(L+2q-2)\Gamma(L-2q)}{(4q-2)\Gamma(L+2)}k_{11}(L+2q-1,L+2)-
$$
$$
-\frac{\Gamma(L-2q)}{(4q-2)\Gamma(L+2)}k_{12}(L-2q,L+2)+
$$
$$
+\frac{\Gamma(L-2q+1)(2+L-6q-4Lq+8q^2)}{2(2q-1)(4q-3)\Gamma(L+3)}k_{22}(L-2q+1,L+3)-
$$
$$
-\frac{\Gamma(L-2q+1)(L+2q-2)}{2(2q-1)(4q-3)\Gamma(L+2)}k_{11}(L-2q,L+2)+
$$
$$
+\frac{\Gamma(L-2q+1)(L+2q-2)}{2(2q-1)(4q-3)\Gamma(L+2)}k_{11}(L+2q-1,L+2)-
$$
$$
-\frac{\Gamma(L-2q+1)}{(4q-3)\Gamma(L+3)}M(L-2q+1,L+3).
$$
Where
$$
\psi(x):=\frac{\Gamma'(x)}{\Gamma(x)},
$$
where $\Gamma(x)$ is the classical Euler's Gamma function.
After simplification we get
$$
S=S(L,q)=\frac{(-2 q (q (4 q-11)+8)-2 \pi  (q-1) q (2 q-1) \cot (2 \pi  q)+3) \Gamma (L-2 q)}{4 (1-2 q)^2 (q-1) q (4 q-3) \Gamma (L)},\tag 5
$$
with the condition $L\in \textbf{R}$ and $0<q<\frac{3}{2}$.
When $q=3/2-1/t$, $t>>1$ and
i) $L=t^a$, $a=1/3$, then $\lim_{t\rightarrow\infty}S(L,q)=1/24$.
ii) $L=t^a$, $a>1/3$, $\lim_{t\rightarrow\infty}S(L,q)=0$
iii) $L=t^a$, $a<1/3$, $\lim_{t\rightarrow\infty}S(L,q)=\infty$
Also for $q\rightarrow 0+$, then if $L\in\{0,-1,-2,\ldots\}$, we get $\lim_{t\rightarrow\infty}S(L,q)=0$.
If $q\rightarrow 0+$ and $L>0$, then $\lim_{q\rightarrow 0+}S(L,q)=\infty$.

A: The sum to find can be written in the two equivalent forms, as demonstrated
in the precedent post.
$$
\eqalign{
  & S(L,q) = \sum\limits_{r = 0}^\infty  {\sum\limits_{l = 0}^\infty  {{{\Gamma (L + r - 2q)}
 \over {\Gamma (L + r - 1 + 2q)}}{{\Gamma (L + r + l - 1 + 2q)} \over {\Gamma (L + r + l + 2)}}{{r + 1} \over {r + l + 2}}} }  =   \cr
  &  = \sum\limits_{r = 0}^\infty  {\sum\limits_{l = 0}^\infty  {\left( {r + 1} \right)\left( {L + r - 1 + 2q} \right)^{\,\overline {\, - \left( { 4q-1} \right)\,} }
 \left( {L + r + l + 2} \right)^{\,\overline {\, - 3 + 2q\,} } {1 \over {r + l + 2}}} }   \cr
  &  = \sum\limits_{s = 0}^\infty  {{1 \over {s + 2}}\left( {L + s + 2} \right)^{\,\overline {\, - 3 + 2q\,} }
 \sum\limits_{r = 0}^s {\left( {r + 1} \right)\left( {L + r - 1 + 2q} \right)^{\,\overline {\, - \left( { 4q-1} \right)\,} } } }  \cr}
$$
Now, using the composition formula for the Rising Factorial
$$
x^{\,\overline {\,a + b\,} }  = x^{\,\overline {\,a\,} } \left( {x + a} \right)^{\,\overline {\,b\,} }
$$
we obtain  two fundamental blocks that we need for proceeding
$$
\eqalign{
  & \left( {r + 1} \right)\left( {r + 1 + a} \right)^{\,\overline {\,1 - b\,} }
  = {{\left( {r + 1} \right)^{\,\overline {\,1\,} } \left( {r + 2} \right)^{\,\overline {\,a - 1\,} } \left( {r + 1 + a} \right)^{\,\overline {\,1 - b\,} } }
 \over {\left( {r + 2} \right)^{\,\overline {\,a - 1\,} } }} =   \cr
  &  = {{\left( {r + 1} \right)^{\,\overline {\,a + 1 - b\,} } } \over {\left( {r + 2} \right)^{\,\overline {\,a - 1\,} } }}
 = {{1^{\,\overline {\,r + 1\,} } } \over {1^{\,\overline {\,r\,} } }}{{1^{\,\overline {\,r\,} } \left( {r + 1} \right)^{\,\overline {\,a + 1 - b\,} } }
 \over {1^{\,\overline {\,r + 1\,} } \left( {r + 2} \right)^{\,\overline {\,a - 1\,} } }}
 = {{2^{\,\overline {\,r\,} } } \over {1^{\,\overline {\,r\,} } }}{{1^{\,\overline {\,r + a + 1 - b\,} } } \over {1^{\,\overline {\,r + a\,} } }} =   \cr
  &  = {{2^{\,\overline {\,r\,} } } \over {1^{\,\overline {\,r\,} } }}{{1^{\,\overline {\,a + 1 - b\,} } \left( {a + 2 - b} \right)^{\,\overline {\,r\,} } }
 \over {1^{\,\overline {\,a\,} } \left( {a + 1} \right)^{\,\overline {\,r\,} } }}
 = \left( {a + 1} \right)^{\,\overline {\,1 - b\,} } {{2^{\,\overline {\,r\,} } \left( {a + 2 - b} \right)^{\,\overline {\,r\,} } }
 \over {1^{\,\overline {\,r\,} } \left( {a + 1} \right)^{\,\overline {\,r\,} } }} \cr}
$$
and
$$
\eqalign{
  & {1 \over {y + 2}}\left( {y + 2 + c} \right)^{\,\overline {\,d\,} }
  = {{\left( {y + 3} \right)^{\,\overline {\,c - 1\,} } \left( {y + 2 + c} \right)^{\,\overline {\, - d\,} } }
 \over {\left( {y + 2} \right)^{\,\overline {\,1\,} } \left( {y + 3} \right)^{\,\overline {\,c - 1\,} } }} =   \cr
  &  = {{\left( {y + 3} \right)^{\,\overline {\,c - d - 1\,} } } \over {\left( {y + 2} \right)^{\,\overline {\,c\,} } }}
 = {{1^{\,\overline {\,y + 1\,} } } \over {1^{\,\overline {\,y + 2\,} } }}{{1^{\,\overline {\,y + 2\,} } \left( {y + 3} \right)^{\,\overline {\,c - d - 1\,} } }
 \over {1^{\,\overline {\,y + 1\,} } \left( {y + 2} \right)^{\,\overline {\,c\,} } }} =   \cr
  &  = {{1^{\,\overline {\,y + 1\,} } } \over {1^{\,\overline {\,y + 2\,} } }}{{1^{\,\overline {\,y + 1 + c - d\,} } } \over {1^{\,\overline {\,y + 1 + c\,} } }}
 = {{1^{\,\overline {\,1\,} } 2^{\,\overline {\,y\,} } } \over {1^{\,\overline {\,2\,} } 3^{\,\overline {\,y\,} } }}
{{1^{\,\overline {\,1 + c - d\,} } \left( {2 + c - d} \right)^{\,\overline {\,y\,} } }
 \over {1^{\,\overline {\,1 + c\,} } \left( {2 + c} \right)^{\,\overline {\,y\,} } }} =   \cr
  &  = {{1^{\,\overline {\,1\,} } 1^{\,\overline {\,1 + c - d\,} } } \over {1^{\,\overline {\,2\,} } 1^{\,\overline {\,1 + c\,} } }}
{{2^{\,\overline {\,y\,} } \left( {2 + c - d} \right)^{\,\overline {\,y\,} } } \over {3^{\,\overline {\,y\,} } \left( {2 + c} \right)^{\,\overline {\,y\,} } }} =   \cr
  &  = {{\left( {c + 2} \right)^{\,\overline {\, - d\,} } } \over 2}{{2^{\,\overline {\,y\,} } \left( {2 + c - d} \right)^{\,\overline {\,y\,} } }
 \over {3^{\,\overline {\,y\,} } \left( {2 + c} \right)^{\,\overline {\,y\,} } }} \cr}
$$
1) the $(r,l)$ version
Applying the above to the sum in $(r,l)$
$$ \bbox[lightyellow] {
\eqalign{
  & \left\{ \matrix{
  \matrix{   {a = L - 2 + 2q} \hfill & {b = \,4q} \hfill  \cr    {c = L} \hfill & {d = 3 - 2q\,} \hfill  \cr }  \hfill \cr
  A = {1 \over 2}\left( {c + 2} \right)^{\,\overline {\, - d\,} } \left( {a + 1} \right)^{\,\overline {\,1 - b\,} }
  = {1 \over 2}\left( {L + 2} \right)^{\,\overline {\, - 2 - 2q\,} }  \hfill \cr}  \right.  \cr
  & S(L,q) = \sum\limits_{r = 0}^\infty  {\sum\limits_{l = 0}^\infty
{\left( {r + 1} \right)\left( {r + 1 + L - 2 + 2q} \right)^{\,\overline {\,1 - 4q\,} } \left( {L + r + l + 2} \right)^{\,\overline {\, - \left( {3 - 2q} \right)\,} }
 {1 \over {r + l + 2}}} }  =   \cr
  &  = A\;\sum\limits_{r = 0}^\infty  {\sum\limits_{l = 0}^\infty  {{{2^{\,\overline {\,r + l\,} } \left( {2 + c - d} \right)^{\,\overline {\,r + l\,} } }
 \over {3^{\,\overline {\,r + l\,} } \left( {2 + c} \right)^{\,\overline {\,r + l\,} } }}{{2^{\,\overline {\,r\,} } \left( {a + 2 - b} \right)^{\,\overline {\,r\,} } }
 \over {1^{\,\overline {\,r\,} } \left( {a + 1} \right)^{\,\overline {\,r\,} } }}} }  \cr}
} \tag{1.1}$$
Now, the above, once rewritten as
$$ \bbox[lightyellow] {
\eqalign{
  & S(L,q) = A\;\sum\limits_{r = 0}^\infty  {\sum\limits_{l = 0}^\infty  {{{2^{\,\overline {\,r + l\,} } \left( {2 + c - d} \right)^{\,\overline {\,r + l\,} } }
 \over {3^{\,\overline {\,r + l\,} } \left( {2 + c} \right)^{\,\overline {\,r + l\,} } }}
{{2^{\,\overline {\,r\,} } 1^{\,\overline {\,l\,} } \left( {a + 2 - b} \right)^{\,\overline {\,r\,} } 1^{\,\overline {\,l\,} } }
 \over {\left( {a + 1} \right)^{\,\overline {\,r\,} } 1^{\,\overline {\,l\,} } }}} } {{x^{\,r} } \over {r!}}{{y^{\,l} } \over {l!}} =   \cr
  &  = A\,F\left( {\matrix{   2  \cr    3  \cr    2  \cr    2  \cr
 } \,\left| {\,\matrix{
   {2;\left( {2 + c - d} \right)}  \cr
   {2,\,1\;;\;\left( {a + 2 - b} \right),1\;}  \cr
   {3;\left( {2 + c} \right)}  \cr
   {\;\left( {a + 1} \right),1}  \cr
 } \,} \right|x,y} \right)\quad \quad \left| {\;x = y = 1} \right. \cr}
} \tag{1.2}$$
tells us that the sum is a

Kampé de Fériet function computed at $x=y=1$.

Looking on the web one can find various specialized papers dealing with the
expansion of Kampé de Fériet function function in terms of Hypergeometric functions.
So the expansion found by @Nikos Bagis well enters into the scene.
(re. to e.g. this paper and to this and this).
Also interesting is the connection with the "Extended Beta" integral representation
(re. for instance to this and this paper, and specially this), which relates with the integral representation
hinted in my answer to the previous post
2) the $(r,s)$ truncated sum version
Restarting from (1.1) above, and writing $S(L,q)$ in the truncated way we get
$$ \bbox[lightyellow] {
\eqalign{
  & S(L,q) = \sum\limits_{r = 0}^\infty  {\sum\limits_{l = 0}^\infty
  {\left( {r + 1} \right)\left( {r + 1 + L - 2 + 2q} \right)^{\,\overline {\,1 - 4q\,} } \left( {L + r + l + 2} \right)^{\,\overline {\, - \left( {3 - 2q} \right)\,} }
 {1 \over {r + l + 2}}} }  =   \cr
  &  = A\;\sum\limits_{r = 0}^\infty  {\sum\limits_{l = 0}^\infty  {{{2^{\,\overline {\,r + l\,} } \left( {2 + c - d} \right)^{\,\overline {\,r + l\,} } }
 \over {3^{\,\overline {\,r + l\,} } \left( {2 + c} \right)^{\,\overline {\,r + l\,} } }}{{2^{\,\overline {\,r\,} } \left( {a + 2 - b} \right)^{\,\overline {\,r\,} } }
 \over {1^{\,\overline {\,r\,} } \left( {a + 1} \right)^{\,\overline {\,r\,} } }}} }  =   \cr
  &  = A\;\sum\limits_{s = r + l = 0}^\infty  {{{2^{\,\overline {\,s\,} } \left( {2 + c - d} \right)^{\,\overline {\,s\,} } }
 \over {3^{\,\overline {\,s\,} } \left( {2 + c} \right)^{\,\overline {\,s\,} } }}\sum\limits_{r = 0}^s {{{2^{\,\overline {\,r\,} }
 \left( {a + 2 - b} \right)^{\,\overline {\,r\,} } } \over {1^{\,\overline {\,r\,} } \left( {a + 1} \right)^{\,\overline {\,r\,} } }}} }  \cr}
} \tag{2.1}$$
In order to reduce it, exactly or asymptotically, into more manageable terms,
 I am currently exploring the possibilities offered by some possible approaches that I could individuate up to now.
2.a) Product of two Hypergeometric
A truncated Hypergeometric series can be transformed into the limit of a standard one, by adding
two additional parameters
$$
\eqalign{
  & \sum\limits_{r = 0}^s {{{2^{\,\overline {\,r\,} } \left( {a + 2 - b} \right)^{\,\overline {\,r\,} } }
 \over {1^{\,\overline {\,r\,} } \left( {a + 1} \right)^{\,\overline {\,r\,} } }}}  = \mathop {\lim }\limits_{\varepsilon \, \to \,0} \sum\limits_{r = 0}^\infty
{{{\left( { - s} \right)^{\,\overline {\,r\,} } 2^{\,\overline {\,r\,} } \left( {a + 2 - b} \right)^{\,\overline {\,r\,} } }
 \over {\left( { - s + \varepsilon } \right)^{\,\overline {\,r\,} } 1^{\,\overline {\,r\,} } \left( {a + 1} \right)^{\,\overline {\,r\,} } }}}  =   \cr
  &  = \mathop {\lim }\limits_{\varepsilon \, \to \,0} \sum\limits_{r = 0}^\infty  {{{\left( { - s} \right)^{\,\overline {\,\varepsilon \,} }
 2^{\,\overline {\,r\,} } \left( {a + 2 - b} \right)^{\,\overline {\,r\,} } } \over {\left( { - s + r} \right)^{\,\overline {\,\varepsilon \,} }
 1^{\,\overline {\,r\,} } \left( {a + 1} \right)^{\,\overline {\,r\,} } }}}  \cr}
$$
(re. to the renowned "Concrete Mathematics" - Ch. 5 - ex. 34)
which takes advantage of that $\left( { - s} \right)^{\,\overline {\,r\,} }$ becomes null for non negative integers $s < r$.
This gives us a summand product of two hypergeometric terms, but with one fraction containing both parameters.
Since
$$
{{\left( { - s} \right)^{\,\overline {\,\varepsilon \,} } } \over {\left( { - s + r} \right)^{\,\overline {\,\varepsilon \,} } }}
 = {{\Gamma \left( { - s + \varepsilon } \right)\Gamma \left( { - s + r} \right)} \over {\Gamma \left( { - s} \right)\Gamma
 \left( { - s + r + \varepsilon } \right)}}
 = {{{\rm B}\left( { - s + r,\varepsilon } \right)} \over {{\rm B}\left( { - s,\varepsilon } \right)}}
$$
there might be a possibility to expand it in some interesting way.
2.b) series expression of the truncated Hypergeometric
Trying to apply the formulas provided in this work


text:
Q: RadioGroup with radio buttons in different layouts Is it possible to have a radio group with radio buttons in their own layouts? Every radio button has to be on a row that contains text and an image. I wouldn't use a list view because I only have 2 rows.

A: Here is the way to do it:
Create a separate RadioGroup on each RadioButton in the XML layout file. For example:
<RadioGroup
    android:id="@+id/rdoFooWrapper"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <RadioButton
        android:id="@+id/rdoFoo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</RadioGroup>

<RadioGroup
    android:id="@+id/rdoBooWrapper"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <RadioButton
        android:id="@+id/rdoBoo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
</RadioGroup>

Now, inside the java source code, do something like this:
rdoFooWrapper = (RadioGroup) findViewById(R.id.rdoFooWrapper);
rdoFoo = (RadioButton) findViewById(R.id.rdoFoo);
rdoBooWrapper = (RadioGroup) findViewById(R.id.rdoBooWrapper);
rdoBoo = (RadioButton) findViewById(R.id.rdoBoo);

rdoFoo.setOnCheckedChangeListener(this); // implement OnCheckedChangeListener to the current class
rdoBoo.setOnCheckedChangeListener(this);

// ...

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked)
{
    rdoFooWrapper.clearCheck();
    rdoBooWrapper.clearCheck();
}


text:
Q: tensorflow_model_server error while loading shared libraries I've trained a Keras model on a GPU, converted it to a TF estimator, then exported the estimator for TF serving with export_savedmodel.
I can successfully serve this model on a GPU machine, but what I'd like to do is serve it on a CPU. When I try to serve on a CPU-only instance, I get the error:
tensorflow_model_server: error while loading shared libraries: libcuda.so.1: cannot open shared object file: No such file or directory
I'm not sure why Tensorflow serving is looking for CUDA on a CPU instance. Is it TF serving that is looking for CUDA or is it my exported model that is looking for a GPU device because that's what it was trained with?


text:
Q: Android SQL Update statement Can anyone tell me where I am going wrong with this SQL Update statement please?
SQLiteDatabase hashDB = openOrCreateDatabase(HASH_DB, MODE_PRIVATE, null);

hashDB.execSQL("CREATE TABLE IF NOT EXISTS " + HASH_TABLE1 + " (FileName VARCHAR, Hash VARCHAR);");

ContentValues updateFilesTable = new ContentValues();
updateFilesTable.put("Hash", hash);
hashDB.update(HASH_TABLE1, updateFilesTable, "FileName" + "=" + file, null);

file and hash are both Strings and I know they have the correct data in them, the records I am trying to update definitely exist in the database. HASH_TABLE1 also points to the correct table.
Many Thanks
Matt

A: You aren't quoting the file string.  You want this line to read:
hashDB.update(HASH_TABLE1, updateFilesTable, "FileName = ?", new String[] { file });


text:
Q: Filtering a Pivot Table in Google Scripts This is my first post here and I am new to coding. I have been tasked with creating an automated report which will send a google form submitter a graph to help them monitor their production versus their daily goal. To do this I am using the new developer Google sheets script to refresh a pivot table. I found this code online, and it works great, however, I want to add a line which will filter based to the unique submitter's data. Here is the code I have so far:
function updatePivotTable() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var pivotTableSheetName = "Lunch Chart";
  var pivotTableSheetId = ss.getSheetByName(pivotTableSheetName).getSheetId();
  var fields = "sheets(properties.sheetId,data.rowData.values.pivotTable)";
  var sheets = Sheets.Spreadsheets.get(ss.getId(), {fields: fields}).sheets;
  for (var i in sheets) {
  if (sheets[i].properties.sheetId == pivotTableSheetId) {
  var pivotTableParams = sheets[i].data[0].rowData[0].values[0].pivotTable;
  break;
}
}

// Update source range:
pivotTableParams.source.endRowIndex = 40;

// Send back the updated params
var request = {
"updateCells": {
  "rows": {
    "values": [{
      "pivotTable": pivotTableParams
    }]
  },
  "start": {
    "sheetId": pivotTableSheetId
  },
  "fields": "pivotTable"
}
};

Sheets.Spreadsheets.batchUpdate({'requests': [request]}, ss.getId());
}

Is this possible? Where would I add in the filter piece? I found this on the google developer site, but I am very new to coding so I don't really know where to put it or how to make it conditional. https://developers.google.com/sheets/api/reference/rest/v4/FilterCriteria
Thank you!

A: I am not sure if this is still relevant to you but you can add a filter using following piece of code-
"criteria": {
            <col_index>: {"visibleValues": <filter criteria>},
            <col_index>: {"visibleValues": <filter criteria>},

A: I've had the same problem and didn't find an easy explanation or code. Here is what I've done and it works:
function updatePivotTable() {
  var ss = SpreadsheetApp.openById(SHEET_ID);
  var pivotTableSheetName = "Pivot";
  var pivotTableSheetId = ss.getSheetByName(pivotTableSheetName).getSheetId();

  var fields = "sheets(properties.sheetId,data.rowData.values.pivotTable)";
  var sheets = Sheets.Spreadsheets.get(ss.getId(), {fields: fields}).sheets;
  for (var i in sheets) {
    if (sheets[i].properties.sheetId == pivotTableSheetId) {
      var pivotTableParams = sheets[i].data[0].rowData[0].values[0].pivotTable;
      break;
    }
  }

  // Update source range:
  pivotTableParams.source.endRowIndex = 111;
  pivotTableParams.criteria = { 3: {"visibleValues": ["foo"]}};

  // Send back the updated params
  var request = {
    "updateCells": {
      "rows": {
        "values": [{
          "pivotTable": pivotTableParams
        }]
      },
      "start": {
        "sheetId": pivotTableSheetId
      },
      "fields": "pivotTable",
    }
  };

  Sheets.Spreadsheets.batchUpdate({'requests': [request]}, ss.getId());
}

So basically you need to pass the criteria as a pivotTableParams where the key of the object is the index of the column that you want to query and the value should be passed as another object with the format  {"visibleValues": ["foo"]}.


text:
Q: Can you apply CSS only on text that is wrapped, i.e. the second and subsequent lines? I want to put a margin-left on only the text that is wrapped, i.e. text after the first line:
This is text with no margin left
     this text has margin left

Example
click to see
The input and the label are in 1 div and text is wrapped on the second line, which is what I want
but is it possible to have like a margin left on only the text that is wrapped on the second line
jsfiddle example of my problem

A: Yeah, sort of — I'd suggest combining padding-left and text-indent:
HTML

        <input type="checkbox" id="2question1" name="2question" title="Merknaam 1" /> Very long text which is wrapped on the next line

        <input type="checkbox" id="2question2" name="2question" title="Merknaam 2" /> Merknaam 2

        <input type="checkbox" id="2question3" name="2question" title="Merknaam 3" /> Merknaam 3

        <input type="checkbox" id="2question4" name="2question" title="Merknaam 4" /> Merknaam 4

 CSS
.test {
    width:200px;
}

.test label {
    display: block;
    padding-left: 1em;
    text-indent: -1em;
}

text-indent applies only to the first line of text in a block-level element, so it should achieve what you want.
See http://jsfiddle.net/pauldwaite/qUvvv/

A: No, but you can apply CSS to the first line, so you could reverse your thinking to achieve the same effect.
Something like this:
.mytext {margin-left:-5em;}
.mytext:first-line {margin-left:0;}

Here's a JSFiddle example of it working: http://jsfiddle.net/4ckxJ/3/
See http://www.quirksmode.org/css/firstline.html for more info on the :first-line pseudo-class.

A: You could wrap the line you want to wrap in a span and apply:
display: block;
margin-left: 12px;

Giving it display: block will make it wrap to a new line and the margin pushes it off to the right.

A: as per your updated example, here's a fork JSFiddle
float the input and then make the label display block so it floats right in beside it - spacing created with padding and margin, overflow:hidden makes the text "not wrap"  - then you also might want to remove the br's from your HTML


text:
Q: How to pass custom props in react-select? How can i pass custom props in react-select without ts ignore? 1
Cause i always need to put ingore where i use custom prop 2

A: You cannot (or at least should not), as this requires changing react-select typescript definition files.
You might be able to override the typing definition locally, but keep in mind there is already an open issue about this matter.


text:
Q: Import data from mbpoll application to excel I want to get data from power analyzer with mbpoll application. But my code gives an error 'can't create an object'. I have tried to create other objects and it worked. It doesn't work on mbpoll. Here it is the link to my Mbpoll document. Appreciate all helps that i can get.
Mbpoll program-->https://drive.google.com/drive/folders/1cOr95sNdKO_o7_ox-T3JLY3XBz5kXYwT?usp=sharing
Public doc1 As Object
Public doc2 As Object
Public app As Object
Dim res As Integer
Dim n As Integer

Public Sub StartModbusPoll_Click()
   Set app = CreateObject("Mbpoll.Application")
   Set doc1 = CreateObject("Mbpoll.Document")
   Set doc2 = CreateObject("Mbpoll.Document")

   ' Read 10 Holding Registers every 1000ms
   res = doc1.ReadHoldingRegisters(1, 0, 10, 1000)
   ' Read 10 Coil Status every 1000ms
   res = doc2.ReadCoils(1, 0, 10, 1000)
   ' doc1.ShowWindow()

   app.Connection = 1 ' Modbus TCP/IP
   app.IPAddress = "192.168.37.100"
   app.ServerPort = 502
   app.ConnectTimeout = 1000
   res = app.OpenConnection()
End Sub

Public Sub Read_Click()
   Cells(5, 7) = doc1.ReadResult() 'Show results for the requests
   Cells(6, 7) = doc2.ReadResult()

   For n = 0 To 9
      Cells(5 + n, 2) = doc1.Registers(n)
   Next n

   For n = 0 To 9
      Cells(18 + n, 2) = doc2.Coils(n)
   Next n
End Sub


text:
Q: Replace an object in object tree I need to replace an object from in object tree, I tried several methods but I couldn't
let data = [
    {
      "accountId": 2
    },
    {
      "accountId": 6,
      "children": [{
        "accountId": 8
      }]
    },
    {
      "accountId": 45
    }
];

In above object array I need to replace ( when I know the accoundId )
{
  "accountId": 2
}

to
{
  "accountId": 2,
  "children": [
    {
      "accountId": 85
    }
  ]
}

Is there any way(s)/library(s) to do that.

A: Plain javascript, using Array.prototype.map function:

var data = [{ "accountId": 2 }, { "accountId": 6, "children": [{ "accountId": 8 }] }, { "accountId": 45 }];

var newData = { "accountId": 2, "children": [{ "accountId": 85 }] };

data = (function upd(data, n) {
    return data.map(e => {
        if (e.children) {
            var o = {};
            o.accountId = e.accountId;
            o.children = upd(e.children, n);
            return o;
        }
        else if (e.accountId == 8) {
            return n;
        } else return e;
    });
})(data, newData);

document.write('
' + JSON.stringify(data, 0, 2) + '
');

A: You can use an iterative function for the search for the id and update of the array item.

function makeUpdate(a, u) {
    return Array.isArray(a) && a.some(function (b,i,bb) {
        if (b.accountId === u.accountId) {
            bb[i] = u;
            return true;
        }
        return makeUpdate(b.children, u);
    });
}

var data = [{ "accountId": 2 }, { "accountId": 6, "children": [{ "accountId": 8 }] }, { "accountId": 45 }],
    update = { "accountId": 8, "children": [{ "accountId": 85 }] };

makeUpdate(data, update);
document.write('
' + JSON.stringify(data, 0, 4) + '
');


text:
Q: Reference request: Source for "Cauchy's Theorem" (?) on integration in elementary functions Buried deep in my notes from a course I took many years ago, I find a reference to the following, which (in my notes) is called "Cauchy's Theorem":

Theorem.  The integral $\int x^p (1-x)^q dx $ can be expressed in terms of elementary functions if and only if one of the following
  holds:

*

*$p\in\mathbb Z$

*$q\in\mathbb Z$

*$p+q \in\mathbb Z$

Thus, for example, this would imply that $\int x^{1/3}(1-x)^{1/2} dx$ cannot be expressed in elementary functions.
I've been trying to find a source for this theorem but have been coming up empty -- searches for "Cauchy's Integral Theorem" lead to his theorem on line integrals of holomorphic functions in $\mathbb C$, which seems unrelated.  (If it is related, the connection is certainly beyond my comprehension.)
Can anybody provide me with a source for this theorem, or at least a confirmation that it is true and is in fact due to Cauchy?

A: This is called the differential binomial, and the theorem is due to Chebyshev. You can find this site
http://www2.onu.edu/~m-caragiu.1/bonus_files/CHEBYSHE.pdf
useful, or just google chebyshev differential binomial.
Hope this helps.


text:
Q: Multiplying long double gives weird output long double i, j, ans;
scanf("%Lf %Lf", &i, &j);
ans=i*j;
printf("%Lf %Lf", ans, i*j);

i/p -> 1 1
o/p -> -2.000000 -2.000000
expected o/p -> 1.000000 1.000000

Please explain this behaviour, and where is it going wrong and how can we come over it?
If the o/p appx to close to 1 also acceptable.
FYI: long double format specifier I tried Lf, lf, LF and llf according to other StackOverflow post.


text:
Q: created custom year drop down field I've created year dropdown field. Here is a code. It is showing in admin section. But when i tried to save the field.
I get validation error "Value u'2013' is not a valid choice" Can someone help me? thanks
# fields.py

import datetime

from django.db import models

YEAR_CHOICES = []
for r in range(1980, (datetime.datetime.now().year+1)):
    YEAR_CHOICES.append((r, r))

class YearDropdownField(models.CharField):
    def __init__(self, *args, **kwargs):
        kwargs.setdefault('editable', True)
        kwargs.setdefault('max_length', 4)
        kwargs.setdefault('choices', YEAR_CHOICES)
        kwargs.setdefault('default', datetime.datetime.now().year)
        super(YearDropdownField, self).__init__(*args, **kwargs)

# models.py

year = YearDropdownField(_('Year'))

A: try
    for r in range(1980, (datetime.datetime.now().year+1)):
        YEAR_CHOICES.append((r, unicode(r)))


text:
Q: Access computer on internal network from Internet My setup: Ubuntu 13.10 server with ufw, facing outside world on eth0, IP forwarding and masquerading working OK. Internal network 192.168.0/24 on eht1, no problem accessing the internet. I need to access ports 81, 8000 and 554 on 192.168.0.101 coming to/from the internet (it's a DVR for a CCTV system, which I need to monitor remotely). How can I achieve this? Thanks in advance for the help.

A: Let's solve:

*

*the ports under 1024 (like 554) are reserved to the Administrator (root), so any software which uses them must be executed as root (or safer with the sudo software). It's a safety measure.

*the ports you want to use should be opened, execute those commands:
sudo ufw default deny
sudo ufw enable

...to enable the ufw iptables wrapper. Then execute:
sudo ufw allow <port number>

...for any port number you want to open (81,8000 and 554) to any type of connection from any host (the sintax may vary from version to version, always read man ufw).
The sintax to control the ufw interface is reported here, I suggest to read it.
After that you need to open the ports on your default gateway (a router or a switch) if it features an hardware firewall (like the Netgear and Belkin routers).
Now you have the desired remote access. :-)
Let us know by commenting down here if it's all ok & have a nice experience.

A: Update:
This is how solved it:
1) Insert rules for three ports:
ufw allow 81
ufw allow 8000
ufw allow 554

2) in /etc/ufw/before.rules I added the following lines in the NAT section (just before POSTROUTING):
:PREROUTING - [0:0]
-A PREROUTING -p tcp --dport 81 -j DNAT --to-destination 192.168.0.101:81
-A PREROUTING -p tcp --dport 8000 -j DNAT --to-destination 192.168.0.101:8000
-A PREROUTING -p tcp --dport 554 -j DNAT --to-destination 192.168.0.101:554

3) Reload the firewall:
ufw reload

In Firefox I type http//myserver.com:81 (http://myserver.com is our regular webpage) and I'm redirected to the DVR on the internal network which runs the CCTV programs I need to access from the internet (ports 8000 and 554 are used to access the system using a smartphone)
Again, thanks for the help.