text:
Q: What problems would arise in physics by treating infinitesimals as ~1 (in units much smaller than the measurement precision) rather than ~0? I have a hopefully simple/ignorant question.
The difference quotient, where $h$ is an "infinitesimally" small value:
$$f'(x) = \frac{f(x + h) - f(x)}{h}$$
What problems (if any) would arise by thinking of this as $h \approx 1$, in units where $x >> 1$ and $f(x) >> 1$?
I am asking here rather than the mathematics stack exchange because I am concerned only with cases when there is finite precision in the measurements.

A: It would require you to tediously carry around an unknown parameter h in your expressions. This would complicate symbolic math without any advantage.
But note that this is essentially what we do in numerical methods.

A: If I understand correctly, you want to know what it means $h\to0$ and find the relevant scale to which you want to compare it to. The natural approach you had is $x$, except it isn't quite correct. The simplest way to see this is by expanding it to next order to estimate the error:
$$
\frac{f(x+h)-f(x)}{h} = f'(x)+\frac{f''(x)h}{2} +o(h)
$$
so the relevant scale is rather:
$$h \ll \frac{2f'(x)}{f''(x)}$$
Intuitively, this translates the idea that the local behaviour of $f$ is crucial to estimate the speed of convergence. As you can see, if you're interested in relative error, the scale of $f$ is irrelevant, so your condition $f(x)\gg1$ is not necessary. Also, you can see that it isn't $x$ which will directly determine the relevant scale. Naturally, for a sufficiently large difference $h\ll x$ you'll necessarily arrive at the point where the above criterion is also verified.
To come back to your approach, you'd rather need to choose a system of units where $h\sim 1$ and $\frac{2f'(x)}{f''(x)}\gg1$.
Hope this helps.


text:
Q: Can Nginx act as reverse proxy with a forward proxy as the backend, and how? I have set up a dns server to resolve *.google.com to 192.168.1.2 where, hopefully, a nginx server accepts the requests and sends the requests to the real destination via a forward proxy at 192.168.1.3.
So the network is like this.
Can nginx reverse-proxy HTTP(s) traffic to a HTTP(s) forward proxy so that users don't need to configure their browser proxy settings to access the sites like google.com blocked by firewall?

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to make multiple save calls atomic in reactive spring data cassandra? The scenario is that, I have a cassandra API which needs to save data in 3 tables/repositories. So, once the API is hit, either data should be persisted in all the tables or in none of them. How do I acheive this?
The microservice is based on spring boot and web flux and ofcourse reactive spring data cassandra.
I know that batching is still not available for reactive cassandra.
Can the zip operator be of any help here if I zip the 3 save calls using the operator? (I suspect, it won't be helpful)
Insights on this will be very helpful. Thanks.

A: You are right ..there was no support for BatchOperations in reactive cassandra but they have introduced it in version
2.1 RC2 check this
As an alternative you can club you individual statements in Batch and use.


text:
Q: Integration of $f(x)=(-1)^n(n+1)1_{(\frac{1}{n+1},\frac1n]}(x)$ over $[c,1]$

Could anyone explain why is the last equality true?

A: First, take the integral from $c$ to $\frac{1}{N}$. $f(x)=(-1)^N(N+1)$ on this interval, which is a constant, so we get $(-1)^N(N+1)\left(\frac 1 N-c\right)$. That takes care of the first term.
Now, we have to go from $\frac{1}{N}$ to $\frac{1}{N-1}$, from the latter to $\frac{1}{N-2}$, from that to $\frac{1}{N-3}$, ..., from $\frac{1}{2}$ to $\frac{1}{1}$. That's a lot to deal with, so let's just say we're going from $\frac{1}{k+1}$ to $\frac{1}{k}$. On this interval, we get that $f(x)=(-1)^k(k+1)$, which is a constant, so the integral over this interval is just $(-1)^k(k+1)\left(\frac{1}{k}-\frac{1}{k+1}\right)$, which can be simplified to:
$$(-1)^k(k+1)\left(\frac{(k+1)-k}{k(k+1)}\right)=(-1)^k\left(\frac{1}{k}\right)=\frac{(-1)^k}{k}$$
Now, remember, we want to go to do this starting from the interval $\frac{1}{N}$ to $\frac{1}{N-1}$ and ending at the interval $\frac{1}{2}$ to $\frac{1}{1}$. The above interval represents $\frac{1}{k+1}$ to $\frac 1 k$, so if we sum the above from $k=N-1$ to $k=1$ (or the other way around), we'll get the rest of the integral, which takes care of the second term.


text:
Q: Duplicate words in a list How can I return a duplicated word in a list?
I was asked to create a function, word_count(text, n). The text is converted into a list and then return the word that is repeated n times. I've tried to write it but it seems to return every single word.
>>> repeat_word_count("one one was a racehorse two two was one too", 3)
['one']

I've used the for loop and conditioned it. I'm wanted to post my code but I'm scared that my school will find the code online :(

A: I think I know what it is that you are wanting to do and without seeing your code I can't point out exactly where you're going wrong so I'll take you through creating this function step by step and you should be able to figure out where you went wrong.
I think you are trying to create this:
def function(a,b):
    """where a is a sentence and b is the target number.
        The function will return to you each word in the
        given sentence that occurs exactly b times."""

To do this we have to do the following:

*

*converts the sentence into a list of words and removes punctuation,capitalization,and spaces.

*iterates through each unique word in the sentence and print it if it occurs exactly b times in the sentence

*put these together to make a function

so in your example your sentence was "one one was a racehorse two two was one too", and you're looking for all words that occur exactly 3 times, so the function should return the word "one"

We'll look at each step one at a time.
FIRST STEP -
we have to take the sentence or sentences and convert them into a list of words.  Since I don't know if you will be using sentences with punctuation and/or capitalization I'll have to assume that its possible and plan to deal with them.  We'll have to omit any punctuation/spaces from the list and also change all the letters in each word to lowercase if they happened to have a capital letter because even though "Cat" and "cat" are the same word, according to a computer brain, "Cat" does NOT equal any of these:

*

*"cat" - lowercase c doesn't match uppercase C in "Cat"

*" Cat" - there is an extra space at the start of the word

*"Cat." - There is a period after the word

*"Cat " - There is a space after the word
So if we use "One one was a racehorse two two was one, too." as our input we'll need to handle spaces, punctuation, and capitalization.  Luckily all of this work can be done with 2 lines of code by using a regular expression and list comprehension to get rid of all the junk and create a list of words.
import re

wordlist=[i.lower() for i in re.findall(r"[\w']+",sentence)]

This gives us our list of words:
['one', 'one', 'was', 'a', 'racehorse', 'two', 'two', 'was', 'one', 'too']

SECOND STEP -
Now we need to iterate through each Unique word in the wordlist and see if it occurs exactly b times. Since we only need unique words we can create a list that only contains each word exactly once by converting the wordlist from a list to a set and looping through each word in the set and counting the number of times they appear in the wordlist.  Any that occur exactly b number of times are our solutions.  I'm not exactly sure how you were wanting the results returned but i'm going to assume you want to have each word that fits the criteria to be printed one at a time.
for word in set(wordlist):
    if wordlist.count(word)==b:
        print word

THIRD STEP -
Now I'll put all this together to create my function:
 import re

 def repeat_word_count(a,b):
     wordlist=[i.lower() for i in re.findall(r"[\w']+",a)]
     for word in set(wordlist):
         if wordlist.count(word)==b:
             print word

I hope this helps you understand a bit better


text:
Q: Application causing phone to heat up I have been getting complaints from a few users that once they installed my application there phone has been heating up (sometimes even when the application is not running).

*

*What are the reasons this could be happening?

*What can I do to overcome this issue?

*Is there any way my application could heat up the phone even when it is not running?

Edit : How does a white application background compare to a black or darker application background in terms of battery usage? (assuming that excessive battery usage could heat up the phone)
Edit : Say I have a service that runs indefinitely, but does cpu specific work very rarely, how costly, in terms of cpu / battery / memory, is maintaining the service? (I know a better way would be to implement it using alarm manager, but before I change the implementation I need to know how big a difference it would make.)

A: First thing first there is no way your application can heat up the phone when your app is not running (at least in background). Now when your app is running, there are many reasons for your app to heat up the phone,

*

*Calculations- especially floating point calculations.This cause lot
of heat

*heavy or unending loops

*downloading large files (in background or foreground). When you
download there are lot of network activities happening.

*Animation and graphics, simply because it uses a lot of calculations
in background

As a programmer, I don't thing you can do anything if someone say your app is causing phone heat up even when it is not running. So forget about it. Heat is not a thing which vanish quickly, and will remain for sometime even if the app that emitted it gets killed. I think your users misunderstood that your app emitting heat even if it is not running. You only need to make sure your app is light weight and less taxing on the processor when it is running.

A: The only thing that can cause a device to warm up is when you have a Service running in background and have it working on some real heavy loops or calculations...
And as I saw in your post, is not your case..


text:
Q: How to play song which is fetched from internal storage I have fetched music from phone's internal storage and it is displaying perfectly but i don't know how to play these songs. Here is my code, please tell me how can i play it. I am not getting which URI i have to pass to play the song.
Help me to resolve this.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    view=  inflater.inflate(R.layout.fragment_music, container, false);
    if(ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){
        if(ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE)){
            ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSTION_REQUEST);

        } else {
            ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, MY_PERMISSTION_REQUEST);
        }
    } else {
        doStuff();
    }

    return view;
}
public void doStuff(){
    ListView listView = view.findViewById(R.id.musicrecyclerview);
    musicModes = new ArrayList<>();
    getMusic();
    ArrayAdapter adapter = new ArrayAdapter(getContext(), android.R.layout.simple_list_item_1, musicModes);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent intent =new Intent();
            intent.setAction(Intent.ACTION_VIEW);

        }
    });
}
public void getMusic(){
    ContentResolver contentResolver = getActivity().getApplicationContext().getContentResolver();
    Uri uri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
    Cursor mycursor = contentResolver.query(uri, null, null, null, null);
    if(mycursor != null && mycursor.moveToFirst()){
        songtitle = mycursor.getColumnIndex(MediaStore.Audio.Media.TITLE);
        songsize = mycursor.getColumnIndex(MediaStore.Audio.Media.DATA);
        column_index = mycursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
        do{
            currenttitle = mycursor.getString(songtitle);
            currentsize = mycursor.getString(songsize);
            musicModes.add(currenttitle+ "\n"+ currentsize);
        } while(mycursor.moveToNext());
    }
}

A: Please try this:
int dataIndex= mycursor.getColumnIndex(MediaStore.Audio.Media.DATA);
String data =  mycursor.getString(dataIndex)
Uri uri= Uri.parse("file:///" + data);

MediaPlayer player= new MediaPlayer();
player.setAudioStreamType(AudioManager.STREAM_MUSIC);
player.setDataSource(getApplicationContext(), uri);
player.prepare();
player.start();


text:
Q: PHP Array in wrong format I have a query which I want the results inserted in an array so after all I'll encode it into a JSON, but my problem is that I want the data to be set like this:

array[0] = project1, project2, project3;
  array[1] = item1, item2, item3;

and I'm having this:

array[0] = project1;
  array[1] = project2;
  array[2] = project3;

and so on..
this is what I've done so far:
$info = array();

    $items = mysql_query("SELECT * FROM `vision`.`projects` WHERE  proj_area = 'area_1'");

        if (mysql_num_rows($items) != 0) {
            while($proj = mysql_fetch_array($items)) {

            $proj_name = $proj['proj_name'];
            $proj_beg = $proj['proj_beg'];
            $proj_end = $proj['proj_end'];

            array_push($info, $proj_name, $proj_beg, $proj_end );
        }
    }

    echo json_encode($info);

my query result gave me these result:

["nome", "0000-00-00", "0000-00-00", "Projeto 2", "2016-12-12", "2020-07-30", "Projeto", "2017-02-03", "2018-03-10"]

and this is my $.getJSON code:
$.getJSON("includes/get_area.php",function(data){

                    console.log(data);
                    })

What am I doing wrong?

A: Try this one; this will add a list in each one of the three array indexes.
$info = array();

$items = mysql_query("SELECT * FROM `vision`.`projects` WHERE  proj_area = 'area_1'");
if (mysql_num_rows($items) != 0) {
    while($proj = mysql_fetch_array($items)) {
        $info[0][] = $proj['proj_name'];
        $info[1][] = $proj['proj_beg'];
        $info[2][] = $proj['proj_end'];
    }
}

echo json_encode($info);


text:
Q: Meniscus shape on complete wetting What happens when a liquid wets a solid completely , then what will be meniscus shape in long tube , and I recieved answers telling it will be concave.
But in concave , contact angle is non zero and I thought that complete wet must mean contact angle zero , so the meniscus should be cylindrical.
Any explanation ?


text:
Q: userEvent.type inputs only last character when wrapped in act I found an issues in the user-event github and it says its resolved in version 12.0.1 but I'm on version 12.1.5 and I keep getting the error.
import React, { Fragment } from "react";
import { render, act } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import App from "./App";

test("Gets a code and renders it in a new route", () => {
  const { getByLabelText } = render(<App />);
  act(() => {
    userEvent.type(getByLabelText("Code:"), "12345");
  });
  expect(getByLabelText("Code:")).toHaveValue("12345");
});

  ● Gets a code and renders it in a new route

    expect(element).toHaveValue(12345)

    Expected the element to have value:
      12345
    Received:
      5

A: Your problem might be in the implementation of the change handler. I recently had a similar issue, and here's what I thought would work, versus what really worked. More info at this github comment.
function handleChange(ev: FormEvent, key = "") {
  ev.preventDefault();

  // ✅ Passes
  const value = (ev.target as HTMLInputElement).value;

  setState(s => {
    // ❌ Fails (individual characters instead of progressively built up strings)
    // const value = (ev.target as HTMLInputElement).value;

    return { ...s, [key]: value };
  });
}


text:
Q: In Policy Iteration, why the successive value vector monotonically increases? Let $\mathcal{X}=:\{x_1, x_2, x_3,...,x_n\}$ be the state space. Let $\mathcal{U}:=\{u_1, u_2, u_3,...,u_m\}$ be the set of actions. Let $A^{u_1}, A^{u_2}, A^{u_3},...,A^{u_m}$ be the state transition matrices corresponding to the actions $u_1, u_2, u_3,...,u_m$ respectively. Let $a^{u_k}_{i,j}$ denotes the $(i,j)^{th}$ entry of matrix $A^{u_k}$, i.e., $a^{u_k}_{i,j}=(A^{u_k})_{i,j}$, where $k\in\{1,2,3,...,m\}$. Let $\mathcal{R}(x_i,u_k)\in\mathbb{R}$ denotes the reward associated with the state $x_i$ and action $u_k$. Define the Bellman iteration
map $\mathcal{B}:\mathbb{R}^n\rightarrow \mathbb{R}^n$ as:
$$(Bv)_i=\max_{u_k\in\mathcal{U}} \{ \mathcal{R}(x_i,u_k)+\sum_{j=1}^{n}a^{u_k}_{i,j}(v)_i\}, $$
for an arbitrary vector $v\in\mathbb{R}^n$, where $(v)_i$ denotes the $i^{th}$ entry of $v$.
Let $\pi_{0}:\mathcal{X}\rightarrow \mathcal{U}$ be a deterministic policy. Let $v_{\pi_{0}}$ is the value vector corresponding to the policy $\pi_{0}$.
Now update the policy as follows:
$$\pi_{1}(x_i)=\arg \max_{u_k\in\mathcal{U}} \{\mathcal{R}(x_i,u_k)+\sum_{j=1}^{n} a^{u_k}_{i,j}(v_{\pi_0})_j\}.$$
Now calculate the value vector $v_{\pi_1}$ corresponding to the policy $\pi_1$. Again update the policy as follows:
$$\pi_{2}(x_i)=\arg \max_{u_k\in\mathcal{U}} \{\mathcal{R}(x_i,u_k)+\sum_{j=1}^{n} a^{u_k}_{i,j}(v_{\pi_1})_j\}.$$
Now calculate the value vector $v_{\pi_2}$ corresponding the policy $\pi_2$ and again update the policy as follows:
$$\pi_{3}(x_i)=\arg \max_{u_k\in\mathcal{U}} \{\mathcal{R}(x_i,u_k)+\sum_{j=1}^{n} a^{u_k}_{i,j}(v_{\pi_2})_j\}.$$
We keep iterating the policy in this manner, i.e.,
$$\pi_{k+1}(x_i)=\arg \max_{u_k\in\mathcal{U}} \{\mathcal{R}(x_i,u_k)+\sum_{j=1}^{n} a^{u_k}_{i,j}(v_{\pi_k})_j\}.$$
Now, how I can prove the following:
(1) $v_{\pi_{k+1}}\geq v_{\pi_{k}}$
(2) $v_{\pi_{k}}$ converges to optimal value vector $v^{*}$ as $k$ tends to $\infty$
(3) $v_{\pi_{k+1}}= Bv_{\pi_{k}}$


text:
Q: Appium find_elements_by_accessibility_id or find_elements_by_id occasionally do not return all the elements I am running tests with Robot Framework + Appium in Android emulator, using python to write the test code.
Lately, when running the tests in an emulator, I have seen odd behavior when find_elements_by_accessibility_id or find_elements_by_id do not return all the elements that are visible on the screen. Usually there are 9 - 14 elements, depending on the situation, but find_elements_* only returns seven, or zero, elements. On the other hand, sometimes it works without problems.
The elements that are returned seem to the the last ones on the view. First ones are left out.
I have tried adding sleeps before the call's, sometimes it seems to help, most of the time it does not, but it is difficult to say for sure, since the behavior varies anyway.
I've also tried with different id's. Format "com.mycompany.myapp:id/item_in_the_view" seems to be more reliable than "item_in_the_view".
I am not sure if it is related problem, but sometimes when AppiumLibrary Wait Until Page Contains Element fails and prints out xml it tries to look for the element, it seems that the xml handled is very short, missing a lot of content, while a screenshot from the same situation shows that everything is correct on the screen.
Any ideas on how to fix it?


text:
Q: Show No data message if no records found in reactjs functional component I am new to reactjs. I need to check whether if records are present, then I need to show grid using map function. Else I need to show message "No data". This is my code. I used ternary operator to do so
<Grid container spacing={2}>
{data.length > 0 ?
  {data.map((activity) => (
      <Grid
        item
        xs={6}
        sm={4}
        md={3}
        lg={3}
        onClick={() => {
          setSpec(activity.spec)
          setActivity(activity)
          handleClickOpen(activity.spec)
        }}
        className={classes.thumbMain}
      >
        <ButtonBase focusRipple className={classes.fullwidthBtn}>
          <Card className={classes.manage}>
            <Box mt={2} mb={1}>
              <Box
                className={classes.mainIcons}
              ></Box>
            </Box>
            <Typography className={classes.cardlabel}>{(activity.name)}</Typography>
          </Card>
        </ButtonBase>
      </Grid>
    ))}
   :
No data

   }
  </Grid>

The above code returns following error

Parsing error: ',' expected : in data.map((activity)

A: You shouldn't wrap data.map(...) in braces:
<Grid container spacing={2}>
  {data.length ? (
    data.map((activity) => (
      <Grid
        item
        xs={6}
        sm={4}
        md={3}
        lg={3}
        onClick={() => {
          setSpec(activity.spec);
          setActivity(activity);
          handleClickOpen(activity.spec);
        }}
        className={classes.thumbMain}
      >
        <ButtonBase focusRipple className={classes.fullwidthBtn}>
          <Card className={classes.manage}>
            <Box mt={2} mb={1}>
              <Box className={classes.mainIcons}></Box>
            </Box>
            <Typography className={classes.cardlabel}>
              {activity.name}
            </Typography>
          </Card>
        </ButtonBase>
      </Grid>
    ))
  ) : (

No data

  )}
</Grid>;

You should wrap JS code in braces only one time to use it in JSX. If you add braces in other braces then you will be getting that error again.


text:
Q: Cannot reference delegate protocols in implimentation I have a UIViewController with a UIPickerView that creates a string that I want to pass along to my RootViewController (BL_MainViewController).
My tactic was to use the delegate pattern but I can't figure out where I'm going wrong here. If my RootViewController is created using a Storyboard, how do I tell it BL_MainViewController.BL_SetTimerViewController = self and where do I set that in the implementation (guess:ViewDidLoad)?
BL_SetTimerViewController.h (the child VC presented by modal segue in IB)
@protocol BL_SetTimerViewControllerDelegate

-(void) updateLabelWithString:(NSString *)string;

@end

@interface BL_SetTimerViewController : UIViewController{
  ... // some ivars
}

@property (assign, nonatomic) id <BL_SetTimerViewControllerDelegate> delegate;

@end

BL_SetTimerViewController.m
@implementation BL_SetTimerViewController
...
@synthesize delegate;
...
- (IBAction)setTimerAndDismissViewController:(id)sender {

    // does some stuff, then:

    [self.delegate updateLabelWithString:@"TEST"];
    [self dismissViewControllerAnimated:YES completion:nil];

}

BL_MainViewController.h (The Root VC)
#import "BL_SetTimerViewController.h"

@interface BL_MainViewController : UIViewController <BL_SetTimerViewControllerDelegate>{
...
}

@end

BL_MainViewController.m
- (void)viewDidLoad {
    [super viewDidLoad];
    // do some stuff here
    // presumably also assign the delegate protocol?
}

-(void)updateLabelWithString:(NSString *)string {
    self.pLabel.text = string;
}

A: In your  BL_MainViewController.m
- (void)viewDidLoad {
    [super viewDidLoad];

}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.pLabel.text=GlobleSting;
}

-(void)updateLabelWithString:(NSString *)string {
    GlobleSting = string; //declare in .h file
}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"YoursegueIdentifir"]) {
        BL_SetTimerViewController *settimerVC =
        segue.destinationViewController;
        settimerVC.delegate = self;
    }
}

A: Super simple test app for delegate(note that many thing are left out as it's quickly thrown together), this works for me.(note that delegate is weak, not assign. If you are targeting iOS 5+, use weak for delegates)
SimpleProtocol.h
@protocol SimpleProtocol <NSObject>

- (void)updateText:(NSString *)text;

@end

ViewController.m
#import "ViewController.h"

#import "SecondViewController.h"
#import "SimpleProtocol.h"

@interface ViewController ()<SimpleProtocol>

@property (nonatomic, weak) IBOutlet UILabel *label;

@end

@implementation ViewController

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    SecondViewController *vc = (SecondViewController *)segue.destinationViewController;
    vc.delegate = self;
}

- (void)updateText:(NSString *)text
{
    self.label.text = text;
}

@end

SecondViewController.m
#import "SimpleProtocol.h"

@interface SecondViewController ()

@end

@implementation SecondViewController

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(timerFire:) userInfo:nil repeats:NO];
}

- (void)timerFire:(NSTimer *)timer
{
    NSString *text = [NSString stringWithFormat:@"Test %@", @(arc4random())];
    [self.delegate updateText:text];
    [self.navigationController popViewControllerAnimated:YES];
}

@end


text:
Q: Centering Problems Okay, so I just started a basic template for a website and I'm already running into an issue with centering.
I have a big box that I want to cover MOST of the website with a little room on every side, and I just want it to hang centered in the website.
Problem is, I set the position to relative and the thing disappears, I set it to absolute and the thing shows up but isn't centered of course. I'm just wondering why the box disappears when I'm setting it to relative, when it should be relative to the body.
Here's all the code, it's not much as I'm just starting this template
HTML:

CSS:
* {
    margin: 0px;
    padding: 0px;
}

body{
    background-color:#212121;
}

.bigbox{
    background-color:red;
    height:90%;
    width:90%;
    margin: 0 auto;
    position:relative;
    z-index:1;
    float:left;
}

Thanks for taking a look, I'm sure it's a retarded easy fix

A: You can achieve what you want in various ways:
vertical height (vh unit): https://jsfiddle.net/arthurcamara/bjhrz9n9/

*
{
    margin: 0px;
    padding: 0px;
}

body{
    background-color:#212121;

}

.bigbox{
    background-color:red;
    height:90vh;
    width:90%;
    margin: 5vh auto;
}

absolute positioniong: https://jsfiddle.net/arthurcamara/bjhrz9n9/1/

body{
    background-color:#212121;

}

.bigbox{
    background-color:red;
    position: absolute;
    top: 5%;
    right: 5%;
    left: 5%;
    bottom: 5%;
}

and my favorite flexbox: https://jsfiddle.net/arthurcamara/bjhrz9n9/2/

body{
  margin: 0px;
  padding: 0px;
  height: 100vh;
  background-color:#212121;

  display: flex;
  justify-content: center;
  align-items: center;
}

.bigbox{
    background-color:red;
    width: 90%;
    height: 90%;
}

A: I guess your problem is the percentage height in combination of an unknown height of the body. You should add a height to the body like in the following example:
html, body {
    height: 100%;
}

Working JFiddle

A: The problem occurs, because the box has no fixed height. So you need to set the height for body and html to 100%

* {
  margin: 0px;
  padding: 0px;
}
html {
  height: 100%;
}
body {
  background-color: #212121;
  height: 100%;
}
.bigbox {
  background-color: red;
  height: 90%;
  width: 90%;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  float: left;
}

A: First up add a width to the div. You could do it in any format px, %, vw etc.
div{
  width: 80%;
  margin: 0 auto;
}

A: The following should give you what you are looking for. You can adjust the border by changing the html, body height percent and the .bigbox margins.

html, body {
  height: 98%;
}

body{
  background-color:#212121;

}

.bigbox{
  background-color:red;
  height: 100%;
  margin: 15px 5px;
  position: relative;
}


text:
Q: Run BHO inside embedded IE control within third-party desktop application I have a third-party windows desktop .Net application with embedded Internet Explorer control. I want to run my BHO from that IE control. BHO dosn't have any GUI, it just captures users' actions.
Is it possible? Probably I can use Windows Hooks API to embed by BHO's dll, find IE contol with reflection and register my BHO. But it sounds a little bit scary.
Any help would be greatly appreciated. Thanks.

A: There's no supported way to load/run a BHO inside a Web Browser control. You're correct to note that you could, conceivably, write code that loads the BHO and calls SetSite on the control using the Web Browser Control's handle. However, the BHO may not work in such an environment if it has dependencies on other objects present in IE but not in the Web Browser control.
Backing up a bit-- what does your BHO do and why do you need to load it into someone else's program?


text:
Q: pthread_cleanup_push with pthread_mutex_unlock I have following code in C:
pthread_cleanup_push(pthread_mutex_unlock, &mutex);

however when I compile it, I get the following warning:
warning: initialization from incompatible pointer type

What's wrong? It looks like the cleanup handler should return void*, not int. Is there any way to bypass this warning without writing additional wrapper?

A: The expression pthread_mutex_unlock does not have type void (*)(void *). You need to wrap it:
static void cleanup_unlock_mutex(void *p)
{
    pthread_mutex_unlock(p);
}

and pass this function's address to pthread_cleanup_push.
Others may advise you to just cast pthread_mutex_unlock, but this is incorrect and unsafe. It will cause the function to be called via a pointer to the wrong function type, resulting in undefined behavior.


text:
Q: Thin server on Elastic Beanstalk Runy 2.6 on AMI Linux V2 I'm trying to migrate my Sinatra App from the legacy Amazon Linux to V2 on Elastic Beanstalk using the Thin Server. The Thin Server refuses to start on deploy. However, it starts fine and works correctly if I manually start it as the webapp user with the command:
bundle exec thin start -R config.ru -e production -C config/thin.yml -V

Here are my configuration files:
.plaform/hooks/prebuild/02_set_permissioms.sh
#!/usr/bin/env bash

echo "Set permissions"
su -s /bin/bash -c "mkdir -p /var/run/thin"
su -s /bin/bash -c "mkdir -p /var/log/thin"
su -s /bin/bash -c "mkdir -p /var/log/thin/rotated"
chown -R webapp:webapp /var/run/thin
chown -R webapp:webapp /var/log/thin
chown -R webapp:webapp /var/log/thin/rotated

.plaform/hooks/03_symlink_pid.sh
#!/bin/bash

echo "Symlink thin PID to web PID"
set -xe
sudo ln -nsf /var/run/thin/thin.0.0.pid /var/pids/web.pid

.platform/nginx/conf.d/elasticbeanstalk-nginx-ruby-upstream.conf
upstream my_app {
  server unix:///var/run/thin/thin.0.sock;
}

Procfile
web: bundle exec thin start -R config.ru -e production -C config/thin.yml -V

config/thin/yml
---
chdir: /var/app/current
environment: production
address: 0.0.0.0
port: 9292
timeout: 30
log: /var/log/thin/thin.log
pid: /var/run/thin/thin.pid
max_conns: 1024
max_persistent_conns: 512
require: []
wait: 30
threadpool_size: 20
daemonize: true
socket: /var/run/thin/thin.sock
servers: 1

/var/log/messages
Jan 12 12:45:58 ip-adress systemd: Starting This is web daemon...
Jan 12 12:45:58 ip-adress systemd: Started This is web daemon.
Jan 12 12:45:58 ip-adress systemd: Reloading.
Jan 12 12:45:58 ip-adress systemd: Starting The nginx HTTP and reverse proxy server...
Jan 12 12:45:58 ip-adress nginx: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Jan 12 12:45:58 ip-adress nginx: nginx: configuration file /etc/nginx/nginx.conf test is successful
Jan 12 12:45:58 ip-adress systemd: Started The nginx HTTP and reverse proxy server.
Jan 12 12:45:58 ip-adress web: NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:45:58 ip-adress web: Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:45:58 ip-adress web: 2022-01-12 12:45:58 +0000 Starting server on /var/run/thin/thin.0.sock ...
Jan 12 12:45:58 ip-adress web: 2022-01-12 12:45:58 +0000 /opt/elasticbeanstalk/.rbenv/versions/2.6.9/bin/thin start --chdir="/var/app/current" --environment="production" --timeout=30 --log="/var/log/thin/thin.0.log" --pid="/var/run/thin/thin.0.pid" --max-conns=1024 --max-persistent-conns=512 --threadpool-size=20 --rackup="config.ru" --trace --daemonize --socket="/var/run/thin/thin.0.sock"
Jan 12 12:45:59 ip-adress healthd: Version 2 of the Ruby SDK will enter maintenance mode as of November 20, 2020. To continue receiving service updates and new features, please upgrade to Version 3. More information can be found here: https://aws.amazon.com/blogs/developer/deprecation-schedule-for-aws-sdk-for-ruby-v2/
Jan 12 12:45:59 ip-adress web: 2022-01-12 12:45:59 +0000 NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:45:59 ip-adress web: 2022-01-12 12:45:59 +0000 Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:45:59 ip-adress systemd: web.service holdoff time over, scheduling restart.
Jan 12 12:45:59 ip-adress systemd: Stopped This is web daemon.
Jan 12 12:45:59 ip-adress systemd: Starting This is web daemon...
Jan 12 12:45:59 ip-adress systemd: Started This is web daemon.
Jan 12 12:46:00 ip-adress web: NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:00 ip-adress web: Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:00 ip-adress web: 2022-01-12 12:46:00 +0000 Starting server on /var/run/thin/thin.0.sock ...
Jan 12 12:46:00 ip-adress web: 2022-01-12 12:46:00 +0000 /opt/elasticbeanstalk/.rbenv/versions/2.6.9/bin/thin start --chdir="/var/app/current" --environment="production" --timeout=30 --log="/var/log/thin/thin.0.log" --pid="/var/run/thin/thin.0.pid" --max-conns=1024 --max-persistent-conns=512 --threadpool-size=20 --rackup="config.ru" --trace --daemonize --socket="/var/run/thin/thin.0.sock"
Jan 12 12:46:00 ip-adress web: 2022-01-12 12:46:00 +0000 NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:00 ip-adress web: 2022-01-12 12:46:00 +0000 Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:01 ip-adress systemd: web.service holdoff time over, scheduling restart.
Jan 12 12:46:01 ip-adress systemd: Stopped This is web daemon.
Jan 12 12:46:01 ip-adress systemd: Starting This is web daemon...
Jan 12 12:46:01 ip-adress systemd: Started This is web daemon.
Jan 12 12:46:01 ip-adress web: NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:01 ip-adress web: Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:01 ip-adress systemd: Created slice User Slice of root.
Jan 12 12:46:01 ip-adress systemd: Started Session 1 of user root.
Jan 12 12:46:01 ip-adress web: 2022-01-12 12:46:01 +0000 Starting server on /var/run/thin/thin.0.sock ...
Jan 12 12:46:01 ip-adress web: 2022-01-12 12:46:01 +0000 /opt/elasticbeanstalk/.rbenv/versions/2.6.9/bin/thin start --chdir="/var/app/current" --environment="production" --timeout=30 --log="/var/log/thin/thin.0.log" --pid="/var/run/thin/thin.0.pid" --max-conns=1024 --max-persistent-conns=512 --threadpool-size=20 --rackup="config.ru" --trace --daemonize --socket="/var/run/thin/thin.0.sock"
Jan 12 12:46:01 ip-adress CloudWatch-PutInstanceData: Cannot obtain instance id from EC2 meta-data.
Jan 12 12:46:01 ip-adress systemd: Removed slice User Slice of root.
Jan 12 12:46:02 ip-adress web: 2022-01-12 12:46:02 +0000 NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:02 ip-adress web: 2022-01-12 12:46:02 +0000 Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:02 ip-adress systemd: web.service holdoff time over, scheduling restart.
Jan 12 12:46:02 ip-adress systemd: Stopped This is web daemon.
Jan 12 12:46:02 ip-adress systemd: Starting This is web daemon...
Jan 12 12:46:02 ip-adress systemd: Started This is web daemon.
Jan 12 12:46:02 ip-adress web: NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:02 ip-adress web: Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:02 ip-adress web: 2022-01-12 12:46:02 +0000 Starting server on /var/run/thin/thin.0.sock ...
Jan 12 12:46:02 ip-adress web: 2022-01-12 12:46:02 +0000 /opt/elasticbeanstalk/.rbenv/versions/2.6.9/bin/thin start --chdir="/var/app/current" --environment="production" --timeout=30 --log="/var/log/thin/thin.0.log" --pid="/var/run/thin/thin.0.pid" --max-conns=1024 --max-persistent-conns=512 --threadpool-size=20 --rackup="config.ru" --trace --daemonize --socket="/var/run/thin/thin.0.sock"
Jan 12 12:46:03 ip-adress web: 2022-01-12 12:46:03 +0000 NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:03 ip-adress web: 2022-01-12 12:46:03 +0000 Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:03 ip-adress systemd: web.service holdoff time over, scheduling restart.
Jan 12 12:46:03 ip-adress systemd: Stopped This is web daemon.
Jan 12 12:46:03 ip-adress systemd: Starting This is web daemon...
Jan 12 12:46:03 ip-adress systemd: Started This is web daemon.
Jan 12 12:46:03 ip-adress web: NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:03 ip-adress web: Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:03 ip-adress web: 2022-01-12 12:46:03 +0000 Starting server on /var/run/thin/thin.0.sock ...
Jan 12 12:46:03 ip-adress web: 2022-01-12 12:46:03 +0000 /opt/elasticbeanstalk/.rbenv/versions/2.6.9/bin/thin start --chdir="/var/app/current" --environment="production" --timeout=30 --log="/var/log/thin/thin.0.log" --pid="/var/run/thin/thin.0.pid" --max-conns=1024 --max-persistent-conns=512 --threadpool-size=20 --rackup="config.ru" --trace --daemonize --socket="/var/run/thin/thin.0.sock"
Jan 12 12:46:04 ip-adress web: 2022-01-12 12:46:04 +0000 NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:04 ip-adress web: 2022-01-12 12:46:04 +0000 Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:04 ip-adress systemd: web.service holdoff time over, scheduling restart.
Jan 12 12:46:04 ip-adress systemd: Stopped This is web daemon.
Jan 12 12:46:04 ip-adress systemd: Starting This is web daemon...
Jan 12 12:46:04 ip-adress systemd: Started This is web daemon.
Jan 12 12:46:04 ip-adress web: NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:04 ip-adress web: Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:04 ip-adress web: 2022-01-12 12:46:04 +0000 Starting server on /var/run/thin/thin.0.sock ...
Jan 12 12:46:04 ip-adress web: 2022-01-12 12:46:04 +0000 /opt/elasticbeanstalk/.rbenv/versions/2.6.9/bin/thin start --chdir="/var/app/current" --environment="production" --timeout=30 --log="/var/log/thin/thin.0.log" --pid="/var/run/thin/thin.0.pid" --max-conns=1024 --max-persistent-conns=512 --threadpool-size=20 --rackup="config.ru" --trace --daemonize --socket="/var/run/thin/thin.0.sock"
Jan 12 12:46:05 ip-adress web: 2022-01-12 12:46:05 +0000 NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:05 ip-adress web: 2022-01-12 12:46:05 +0000 Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:05 ip-adress systemd: web.service holdoff time over, scheduling restart.
Jan 12 12:46:05 ip-adress systemd: Stopped This is web daemon.
Jan 12 12:46:05 ip-adress systemd: start request repeated too quickly for web.service
Jan 12 12:46:05 ip-adress systemd: Failed to start This is web daemon.
Jan 12 12:46:05 ip-adress systemd: Unit web.service entered failed state.
Jan 12 12:46:05 ip-adress systemd: web.service failed.

/var/log/web.stdout.log
Jan 12 12:45:58 ip-ddress web: NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:45:58 ip-ddress web: Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:45:58 ip-ddress web: 2022-01-12 12:45:58 +0000 Starting server on /var/run/thin/thin.0.sock ...
Jan 12 12:45:58 ip-ddress web: 2022-01-12 12:45:58 +0000 /opt/elasticbeanstalk/.rbenv/versions/2.6.9/bin/thin start --chdir="/var/app/current" --environment="production" --timeout=30 --log="/var/log/thin/thin.0.log" --pid="/var/run/thin/thin.0.pid" --max-conns=1024 --max-persistent-conns=512 --threadpool-size=20 --rackup="config.ru" --trace --daemonize --socket="/var/run/thin/thin.0.sock"
Jan 12 12:45:59 ip-ddress web: 2022-01-12 12:45:59 +0000 NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:45:59 ip-ddress web: 2022-01-12 12:45:59 +0000 Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:00 ip-ddress web: NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:00 ip-ddress web: Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:00 ip-ddress web: 2022-01-12 12:46:00 +0000 Starting server on /var/run/thin/thin.0.sock ...
Jan 12 12:46:00 ip-ddress web: 2022-01-12 12:46:00 +0000 /opt/elasticbeanstalk/.rbenv/versions/2.6.9/bin/thin start --chdir="/var/app/current" --environment="production" --timeout=30 --log="/var/log/thin/thin.0.log" --pid="/var/run/thin/thin.0.pid" --max-conns=1024 --max-persistent-conns=512 --threadpool-size=20 --rackup="config.ru" --trace --daemonize --socket="/var/run/thin/thin.0.sock"
Jan 12 12:46:00 ip-ddress web: 2022-01-12 12:46:00 +0000 NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:00 ip-ddress web: 2022-01-12 12:46:00 +0000 Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:01 ip-ddress web: NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:01 ip-ddress web: Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:01 ip-ddress web: 2022-01-12 12:46:01 +0000 Starting server on /var/run/thin/thin.0.sock ...
Jan 12 12:46:01 ip-ddress web: 2022-01-12 12:46:01 +0000 /opt/elasticbeanstalk/.rbenv/versions/2.6.9/bin/thin start --chdir="/var/app/current" --environment="production" --timeout=30 --log="/var/log/thin/thin.0.log" --pid="/var/run/thin/thin.0.pid" --max-conns=1024 --max-persistent-conns=512 --threadpool-size=20 --rackup="config.ru" --trace --daemonize --socket="/var/run/thin/thin.0.sock"
Jan 12 12:46:02 ip-ddress web: 2022-01-12 12:46:02 +0000 NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:02 ip-ddress web: 2022-01-12 12:46:02 +0000 Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:02 ip-ddress web: NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:02 ip-ddress web: Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:02 ip-ddress web: 2022-01-12 12:46:02 +0000 Starting server on /var/run/thin/thin.0.sock ...
Jan 12 12:46:02 ip-ddress web: 2022-01-12 12:46:02 +0000 /opt/elasticbeanstalk/.rbenv/versions/2.6.9/bin/thin start --chdir="/var/app/current" --environment="production" --timeout=30 --log="/var/log/thin/thin.0.log" --pid="/var/run/thin/thin.0.pid" --max-conns=1024 --max-persistent-conns=512 --threadpool-size=20 --rackup="config.ru" --trace --daemonize --socket="/var/run/thin/thin.0.sock"
Jan 12 12:46:03 ip-ddress web: 2022-01-12 12:46:03 +0000 NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:03 ip-ddress web: 2022-01-12 12:46:03 +0000 Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:03 ip-ddress web: NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:03 ip-ddress web: Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:03 ip-ddress web: 2022-01-12 12:46:03 +0000 Starting server on /var/run/thin/thin.0.sock ...
Jan 12 12:46:03 ip-ddress web: 2022-01-12 12:46:03 +0000 /opt/elasticbeanstalk/.rbenv/versions/2.6.9/bin/thin start --chdir="/var/app/current" --environment="production" --timeout=30 --log="/var/log/thin/thin.0.log" --pid="/var/run/thin/thin.0.pid" --max-conns=1024 --max-persistent-conns=512 --threadpool-size=20 --rackup="config.ru" --trace --daemonize --socket="/var/run/thin/thin.0.sock"
Jan 12 12:46:04 ip-ddress web: 2022-01-12 12:46:04 +0000 NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:04 ip-ddress web: 2022-01-12 12:46:04 +0000 Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:04 ip-ddress web: NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:04 ip-ddress web: Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.
Jan 12 12:46:04 ip-ddress web: 2022-01-12 12:46:04 +0000 Starting server on /var/run/thin/thin.0.sock ...
Jan 12 12:46:04 ip-ddress web: 2022-01-12 12:46:04 +0000 /opt/elasticbeanstalk/.rbenv/versions/2.6.9/bin/thin start --chdir="/var/app/current" --environment="production" --timeout=30 --log="/var/log/thin/thin.0.log" --pid="/var/run/thin/thin.0.pid" --max-conns=1024 --max-persistent-conns=512 --threadpool-size=20 --rackup="config.ru" --trace --daemonize --socket="/var/run/thin/thin.0.sock"
Jan 12 12:46:05 ip-ddress web: 2022-01-12 12:46:05 +0000 NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed in Rubygems 4
Jan 12 12:46:05 ip-ddress web: 2022-01-12 12:46:05 +0000 Gem::Specification#has_rdoc= called from /var/app/current/vendor/gems/async-rack/async-rack.gemspec:16.

The Thin log is empty and does not through out any errors.

A: The solution is to not daemonize the Thin server in config.yml
daemonize: false


text:
Q: Search text for multiple lines matching string 1 which are not separated by string 2 I've got a file looking like this:
abc|100|test|line|with|multiple|information|||in|different||fields
abc|100|another|test|line|with|multiple|information|in||different|fields|
abc|110|different|looking|line|with|some|supplementary|information
abc|100|test|line|with|multiple|information|||in|different||fields
abc|110|different|looking|line|with|some|other|supplementary|information
abc|110|different|looking|line|with|additional||information
abc|100|another|test|line|with|multiple|information|in||different|fields|
abc|110|different|looking|line|with|supplementary|information

I'm looking for a regexp to use with sed / awk / (e)grep (it actually doesn't matter to me which of these as all would be fine) to find the following in the above mentioned text:
abc|100|test|line|with|multiple|information|||in|different||fields
abc|110|different|looking|line|with|some|other|supplementary|information
abc|110|different|looking|line|with|additional||information

I want to get back a |100| line if it is followed by at least two |110| lines before another |100| line appears. The result should contain the initial |100| line together with all |110| lines that follow but not the following |100| line.
sed -ne '/|100|/,/|110|/p'

provides me a list of all |100| lines which are followed by at least one |110| line. But it doesn't check, if the |110| line has been repeated more than once. I get back results I don't look for.
sed -ne '/|100|/,/|100|/p'

returns a list of all |100| lines and the content between the next |100| line including the next |100| line.
Trying to find lines between search patterns always was a nightmare to me. I spent hours of try and error on similar problems which finally worked. But I never really understood why. I hope, s.o. might be so kind to save me of the headache this time and maybe explain how the pattern does the work. I'm quite sure, I'll face this kind of problem again and then I finally could help myself.
Thank you for any help on this one!
Regards
Manuel

A: In AWK, the field separator is set to a pipe character and the second field is compared to 100 and 110 per line.  $0 represents a line from the input file.
BEGIN { FS = "|" }
{
    if($2 == 100) {
        one_hundred = 1;
        one_hundred_one = 0;
        var0 = $0
    }

    if($2 == 110) {
        one_hundred_one += 1;
        if(one_hundred_one == 1 && one_hundred = 1) var1 = $0;
        if(one_hundred_one == 2 && one_hundred = 1) var2 = $0;
    }

    if(one_hundred == 1 && one_hundred_one == 2) {
        print var0
        print var1
        print var2
    }
}

awk -f foo.awk input.txt
abc|100|test|line|with|multiple|information|||in|different||fields
abc|110|different|looking|line|with|some|other|supplementary|information
abc|110|different|looking|line|with|additional||information

A: Here's a GNU awk specific answer: use |100| as the record separator, |110| as the field separator, and look for records with at least 3 fields.
gawk '
    BEGIN {
        # a newline, the first pipe-delimited column, then the "100" value
        RS="(\n[^|]+[|]100[|])"
        FS="[|]110[|]"
    }
    NF >= 3 {print RT $0}        # RT is the actual text matching the RS pattern
' file

A: I'd do this in awk.
awk -F'|' '$2==100&&c>2{print b} $2==100{c=1;b=$0;next} $2==110&&c{c++;b=b RS $0;next} {c=0}' file

Broken out for easier reading:
awk -F'|' '

  # If we're starting a new section and conditions have been met, print buffer
  $2==100 && c>2 {print b}

  # Start a section with a new count and a new buffer...
  $2==100 {c=1;b=$0;next}

  # Add to buffer
  $2==110 && c {c++;b=b RS $0}

  # Finally, zero everything if we encounter lines that don't fit the pattern
  {c=0;b=""}

' file

Rather than using a regex, this steps through the file using the field delimiters you've specified. Upon seeing the "start" condition, it begins keeping a buffer. As subsequent lines match your "continue" condition, the buffer grows. Once we see the start of a new section, we print the buffer if the the counter is big enough.
Works for me on your sample data.


text:
Q: IIS 7.5 with PHP 5.3, displaying errors on page I'm running Windows Server 2008 R2, with IIS 7.5 and PHP 5.3 (configured by FastCGI). In my php.ini I have:
log_errors = On
display_errors = Off
error_log = syslog      (also tried an actual file with appropriate permissions)

Each time a page contains an error, it is never logged anywhere, but it is displayed on the page (unless I turn log_errors off). I'm guessing that the stderr from php-cgi.exe is being put on the page, instead of being logged where it is supposed to be. Is there a setting somewhere that allows me to log these errors properly?

A: I removed the PHP 5.3 installation and instead chose to install PHP 5.4 manually using the zip file rather than using the MSI installer. From there, the same configuration as mentioned in the question allowed PHP to log correctly. Perhaps it was a version mismatch or something.


text:
Q: Labview while loop not operating correctly? Im trying to make a labview program that is supposed to flip a dice and activate a specific led in order of which number it lands on, but if it lands on a 6 its supposed to make all leds blink twice. Right now if it lands on a 6 it only blinks once.
Heres the while loop i made

if false its like this:

Here's how the full program looks like if anyone would like to know:

A: You are not updating any LEDs inside your loop.

Your code does this if you roll a 6:

*

*The while loop runs 3 times, as fast possible

*The while loop passes the last value (TRUE) out.

*This "TRUE" value enters the "OR" nodes.

*The output of the "OR" nodes get written to the LEDs.

This means: Your LEDs only get updated after your while loop has stopped running.

If you want your LEDs to blink multiple times, you need to update them inside the while loop.
Make sure you understand the concept of Dataflow and make sure your code doesn't have any Race Conditions. (If you don't understand these terms, I recommend you take a course or read a book for LabVIEW beginners)

A: In addition to JKSH's answer above, note that you'll need to have some timing involved.
As JKSH pointed out, you didn't update the LED inside the loop, but even if you had, without some delay between the updates, you probably wouldn't be able to see the blink because it would happen too quickly.
I mention this because it's possible that you'll get the updating inside the loop correct, but you won't know because it will flash too quickly for you to see.


text:
Q: OpenVPN not showing when trying to configure a new VPN I am on Ubuntu 16.04 LTS and I tried to configure a new OpenVPN connection, but when I try to add one only PPTP is shown like in this question. The answer for that question is not working.
How can I solve this problem?

A: To get the VPN connection to show up in Network Manager, ensure that all these packages are installed:
network-manager-openvpn
network-manager-openvpn-gnome
network-manager-pptp
network-manager-vpnc

(From Ubuntu 16.04 OpenVPN) - this should be closed as a duplicate but can't be yet because of the bounty.

A: You need to install the OpenVPN package for NetworkManager to be aware of OpenVPN and connections using this.
Fortunately, this is just a one-liner:
sudo apt install network-manager-openvpn

This will install NetworkManager awareness, and all required dependencies (if any) to set up and maintain connections. After install, however, you may need to reboot (or at least log out/back in) for the Network Manager to figure out it has new capabilities.
Depending on your system, you may also need to install the network-manager-vpnc package.


text:
Q: Updating value based on two other values with the use of mapping table I have two tables; one lookup table which will rarely be updated, and one data table which will be updated frequently.
Lookup table looks like this, where the combination of Code1 and Code2 is unique for each row.
Code1 | Code2 | Classification
------------------------------
AB    | CD    | Class1
XX    | YY    | Class2

Data table looks like this;
SomeData | Code1 | Code2 | Classification
------------------------------
foo      |AB     | CD    |
bar      |XX     | YY    |

I need to dynamically update the data table with the Classification corresponding to the unique combination of Code1 and Code2 in the lookup table.
What would be the simplest / most elegant way of achieving this?

A: You simply need to join the 2 tables like this :
Select b.SomeData, b.Code1, b.Code2, a.Classification
FROM
Lookup_table a
left join
Data_table b
on (a.Code1 = b.Code1 and a.Code2 = b.Code2)

So your update becomes :
Update b
Set b.Classification = a.Classification
FROM
Data_table b
Right join
Lookup_table a
on (a.Code1 = b.Code1 and a.Code2 = b.Code2)

A: You can just create view with this code and get whenver you want
select t2.somedata,t1.Code1,t1.Code2,t1.Classification from lookup_table as t1
left join data_table as t2 on t1.code1=t2.code1 and t1.code2=t2.code2

If you still need to update, use this
update t2
set
t2.Classification=t2.Classification
 from lookup_table as t1
inner join data_table as t2 on t1.code1=t2.code1 and t1.code2=t2.code2

A: You can update 2 table like this
UPDATE table1, table2
SET table2.Classification = table1.Classification
WHERE table1.Code2 = table2.Code2 AND table1.Code1 = table2.Code1;


text:
Q: R: Average sequential values when their difference is below some threshold I'd like to take an increasing sequence of numbers (e.g. a series of times)
set.seed(41);  d <- seq(1:100) + runif(100, 0, 1)

and if the difference between two sequential numbers is below a threshold, merge them into a single point by taking the mean value of the two and, then continue going through until the next time combining is necessary.  I resorted to functions I usually avoid: while and ifelse to write a quick-and-dirty function, and it works but isn't fast.  Can you solve this task 1) more efficiently and 2) without invoking a for or while loop.  Is there some built-in function, perhaps with even more functionality, that is well-suited for such a task?
combine_points <- function(x, th=0.5)
{
    i = 1                           # start i at 1
    while(min(diff(x)) < th)        # initiate while loop
    {
    ifelse(x[i+1] - x[i] < th,      # logical condition
           x[i] <- x[i+1] <-
           mean(c(x[i+1], x[i])),      # assignment if TRUE
           (x[i] <- x[i]))          # assignment if FALSE
    x <- sort(unique(x))            # get rid of the duplicated entry created when
                                    # the ifelse statement was TRUE
    # increment i or reset i to 1 if it gets too large
    ifelse(i == length(x), i <- 1, i <- i+1 )
    }
    return(x)
}

newd <- combine_points(d)
th <- 0.5
which(diff(newd) < th)

integer(0)

Update to benchmarks of solutions so far.
I benchmarked with a larger sample vector, and the Rcpp solution suggested by @Roland is slower than my first while loop when the vector gets long.  I made an improvement to the initial while loop, and made an Rcpp version of it, too.  The benchmark results are below.   Note that @flodel answer is not directly comparable because it is a fundamentally different approach to combining, but it is definitely very fast.
set.seed(41);  d <- seq(1:4000) + runif(4000, 0, 1)
library(microbenchmark)
microbenchmark(
     combine_points.Frank(d,th=0.5),
     combine_points.Frank2(d,th=0.5),
     combine_points_Roland(d,th=0.5),
     combine_points_Roland2(d,th=0.5))
Unit: milliseconds
                                expr       min        lq    median        uq        max neval
   combine_points.Frank(d, th = 0.5) 2115.6391 2154.5038 2174.5889 2193.8444  7884.1638   100
  combine_points.Frank2(d, th = 0.5) 1298.2923 1323.2214 1341.5357 1357.4260 15538.0872   100
  combine_points_Roland(d, th = 0.5) 2497.9106 2506.5960 2512.3591 2519.0036  2573.2854   100
 combine_points_Roland2(d, th = 0.5)  494.8406  497.3613  498.2347  499.8777   544.9743   100

This is a considerable improvement over my first attempt, and the following is an Rcpp version, which is the fastest, so far:
combine_points.Frank2 <- function(x, th=0.5)
{
    i = 1
    while(min(diff(x)) < th)
    {
    if(x[i+1] - x[i] >= th){
           i <- i + 1}
    else {
           x[i] <- x[i+1] <-
           mean(c(x[i+1], x[i]));x <- unique(x); i <- i }
    }
    return(x)
}

Rcpp version
cppFunction('
 NumericVector combine_points_Roland2(NumericVector x, double th) {
  int i=0;
  while(min(diff(x)) < th)
  {
    if ((x[i+1] - x[i]) >= th)
    {
      i = i + 1;
    }
    else{
      x[i] = (x[i+1] + x[i])/2;
      x[i+1] = x[i];
      x = sort_unique(x);
      i = i;
    }
   }
   return x;
}
')

A: See if this does what you want:
combine_points <- function(x, th=0.5) {
  group <- cumsum(c(FALSE, diff(x) > th))
  unname(sapply(split(x, group), mean))
}

combine_points(c(-1, 0.1, 0.2, 0.3, 1, 1.5, 2.0, 2.5, 3.0, 10), 0.5)
# [1] -1.0  0.2  2.0 10.0

A: Here is a translation of your function into Rcpp. It uses sugar functions, which are very convenient, but often there are faster alternatives (RcppEigen or RcppArmadillo are good for that). And of course the algorithm could be improved.
#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
NumericVector combine_points1(NumericVector x, double th) {
  int i=0;
  while(min(diff(x)) < th)
  {
    if ((x[i+1] - x[i]) < th)
    {
      x[i] = (x[i+1] + x[i])/2;
      x[i+1] = x[i];
    }
    x = sort_unique(x);
    if(i <= x.size())
    {
      i = i+1;
    }
    else {
      i=1;
    }
  }
   return x;
}

I recommend using RStudio for writing Rcpp functions and sourcing them.
all.equal(combine_points1(d, 0.5),
          combine_points(d, 0.5))
#[1] TRUE

library(compiler)
combine_points_comp <- cmpfun(combine_points)

library(microbenchmark)
microbenchmark(combine_points1(d, 0.5),
               combine_points_comp(d, 0.5),
               combine_points(d, 0.5))

# Unit: microseconds
#                        expr      min        lq    median        uq       max neval
#     combine_points1(d, 0.5)  652.772  664.6815  683.1315   714.653  1030.171   100
# combine_points_comp(d, 0.5) 8344.839 8692.0880 9010.1470 10627.049 14117.553   100
#      combine_points(d, 0.5) 8996.768 9371.0805 9687.0235 10560.226 12800.831   100

A speed-up by a factor of 14 without real effort.

A: Here is something faster. It avoids resizing/copying x in the loop.
#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
 NumericVector combine_points_Roland3(NumericVector x, double th) {
  int i=0, j;
  int n(x.size());
  while(i < n-1)
  {
    if ((x[i+1] - x[i]) >= th)
    {
      i = i + 1;
    }
    else{
      x[i] = (x[i+1] + x[i])/2;
      n = n-1;
      for (j=i+1; j<n; j++)
      {
        x[j]=x[j+1];
      }
    }
  }
  NumericVector y(n);
  for (i = 0; i < n; i++) {
    y[i] = x[i];
  }
   return y;
}

An R implementation of the same algorithm:
combine_points_Roland3R <- function(x, th) {
  i <- 1
  n <- length(x)

  while(i < n) {
    if ((x[i+1] - x[i]) >= th) {
      i <- i + 1;
    } else {
      x[i] <- (x[i+1] + x[i])/2
      n <- n-1
      x[(i+1):n] <- x[(i+2):(n+1)]
    }
  }
  x[1:n]
}

set.seed(41);  d <- seq(1:4000) + runif(4000, 0, 1)
x2 <- combine_points_Roland2(d, 0.5)
x3 <- combine_points_Roland3(d, 0.5)
all.equal(x2, x3)
#TRUE
x4 <- combine_points_Roland3R(d, 0.5)
all.equal(x2, x4)
#TRUE

Benchmarks:
library(microbenchmark)
microbenchmark(combine_points_Roland2(d, 0.5),
               combine_points_Roland3(d, 0.5),
               combine_points_Roland3R(d, 0.5))

# Unit: microseconds
#                            expr       min         lq      median          uq        max neval
#  combine_points_Roland2(d, 0.5) 126458.64 131414.592 132355.4285 133422.2235 147306.728   100
#  combine_points_Roland3(d, 0.5)    121.34    128.269    140.8955    143.3595    393.582   100
# combine_points_Roland3R(d, 0.5)  17564.24  18626.878  19155.6565  20910.2935  68707.888   100


text: Q: UIBarButton doesn't restore itself when I set customView to nil I've got a UIBarButtonItem that refreshes my data, and while the update is in process, I set refreshButton.customView to an instance of UIActivityIndicator, which is displayed fine. However, when data has been updated and I call refreshButton.customView = nil, the initial UIBarButtonItem is not displayed any more (just a blank space). Anyone knows how can I fix this?


text:
Q: php file not shows error I have PHP file inside the wamp server. when i run that file in localhost it gives some error like below.
This is My PHP file:
<?php
$response = array({
    "success": [
        {
            "message": "Required field id missing"
        },
        {
            "message": "successfully created."
        },
        {
            "message": "Oops! An error occured"
        }
    ]}
);

if (isset($_POST['name']) && isset($_POST['price']) && isset($_POST['description'])) {

    $name = $_POST['name'];
    $price = $_POST['price'];
    $description = $_POST['description'];

    require_once __DIR__ . '/db_connect.php';

    $db = new DB_CONNECT();

    $result = mysql_query("INSERT INTO products(name, price, description) VALUES('$name', '$price', '$description')");

    if ($result) {

        $response["success"] = 1;
        $response["message"] = "Product successfully created.";

        echo json_encode($response);
    } else {

        $response["success"] = 2;
        $response["message"] = "Oops! An error occurred.";

        echo json_encode($response);
    }
} else {

    $response["success"] = 0;
    $response["message"] = "Required field(s) is missing";

    echo json_encode($response);
}
?>

when i run it in localhost following error shows,

( ! ) Parse error: syntax error, unexpected '{', expecting ')' in
  D:\wamp\www\android\create_product.php on line 2

also suggest me that how to set the localpath to run php file in the browser.

A: your array format is wrong, btw, you dont need it, because you are adding message to array in conditions, so just remove this part:
$response = array({
    "success": [
        {
            "message": "Required field id missing"
        },
        {
            "message": "successfully created."
        },
        {
            "message": "Oops! An error occured"
        }
    ]}
);

A: Your code better look this:

*

*You should not echo response after every conditional statement ends, you can do it once.

*Also when using isset function, you can as many params as you want.

 isset($_POST['name']) && isset($_POST['price']) && isset($_POST['description'])

is equal to:
 isset($_POST['name'],$_POST['price'],$_POST['description'])

Final:
if (isset($_POST['name'],$_POST['price'],$_POST['description'])) {

    $name = $_POST['name'];
    $price = $_POST['price'];
    $description = $_POST['description'];

    require_once __DIR__ . '/db_connect.php';

    $db = new DB_CONNECT();

    $result = mysql_query("INSERT INTO products(name, price, description) VALUES('$name', '$price', '$description')");

    if ($result) {
        $response["success"] = 1;
        $response["message"] = "Product successfully created.";
    } else {
        $response["success"] = 2;
        $response["message"] = "Oops! An error occurred.";
    }
} else {
    $response["success"] = 0;
    $response["message"] = "Required field(s) is missing";
}

echo json_encode($response);


text:
Q: I am getting an error using LOAD in neo4j. What's my error? I am trying to load data into neo4j using a local csv on my system:
    USING PERIODIC COMMIT
    LOAD CSV WITH HEADERS FROM "file:/Users/jlujan/Desktop/northwind/customers.csv" AS row
    CREATE (:Customer {CustomerID: row.CustomerID, CompanyName: row.CompanyName,
    ContactName: row.ContactName, ContactTitle: row.ContactTitle,
    Address: row.Address, City: row.City, Region: row.Region, PostalCode: row.PostalCode, Country: row.Country, Phone: row.Phone, Fax: row.Fax});

Every time I get this error: Couldn't load the external resource at: file:/var/lib/neo4j/import/Users/jlujan/Desktop/northwind/customers.csv
I think it's a URL issue, but I'm not exactly sure what. Please help!

A: Looks like you're using Neo4j 3?
You'll find a setting in neo4j.conf like this
# This setting constrains all `LOAD CSV` import files to be under the `import` directory. Remove or uncomment it to
# allow files to be loaded from anywhere in filesystem; this introduces possible security problems. See the `LOAD CSV`
# section of the manual for details.
dbms.directories.import=import

If you remove this/comment it, Neo4j should allow loading files from anywhere in the system


text:
Q: Infer specific type from an object associated to a specfic object's key I have a registry object in a shape of {[key]: <T>()=>T}, the Ts can be absolutely anything as I want to easily add more entries into it in the future. I then have a function accepting registry key as string and this function should then return a value of the associated generic type. But I can't get it to work, because it returns union of generic types returned by all the functions in the registry.
The description is kind of unwieldy, so I hope the simple working example describes what I intend to do in enough detail.
type valFn<T> = () => T

declare const stringFn: valFn<string>;
declare const numberFn: valFn<number>;

const registry = {
  alpha: stringFn,
  beta: numberFn,
  // ... i want to easily add some records in the future without modifying +registryEater+ every time i do so, all the records will be of type +key: ValFn<Something>+
};

// CHANGES CAN BE MADE ONLY DOWN FROM HERE
type ReturnType<T> = T extends valFn<infer R> ? R : never
const registryEater = <T extends keyof typeof registry>(registryKey: T): ReturnType<typeof registry[T]> => {
  const desiredFn = registry[registryKey];
  const desiredValue = desiredFn();
  // TS2322 because +desiredValue+ is string | number, but i need it do be a specific type depending on real value of +registryKey+
  return desiredValue;
};
// CHANGES CAN BE MADE ONLY UP FROM HERE

const thisIsString = registryEater('alpha');
const thisIsNumber = registryEater('beta');

I can get it work by changing return desiredValue; to return desiredValue as ReturnType<typeof registry[T]>;, but isn't there a cleaner way?

A: The compiler can't really do much type analysis on conditional types that depend on generic type parameters, like ReturnType<typeof registry[T]>.  If you want to write your function in a way that the compiler "understand"s, you should refactor to use distributive object types as described in microsoft/TypeScript#47109.  The idea is to start with a very basic mapping type like
interface RegistryReturn {
    alpha: string;
    beta: number;
}

and then represent your other operations as mapped types on that:
type Registry = { [K in keyof RegistryReturn]: () => RegistryReturn[K] }
const registry: Registry = {
    alpha: stringFn,
    beta: numberFn
}

Your generic function could then just index into that mapped type, and things work:
const registryEater = <K extends keyof RegistryReturn>(
    registryKey: K
): RegistryReturn[K] => {
    const desiredFn = registry[registryKey];
    const desiredValue = desiredFn();
    return desiredValue; // okay
};

The desiredFn variable is seen to be of type Registry[K], and then desiredValue() is seen to be of type RegistryReturn[K], specifically because Registry is defined as a mapped type as described in microsoft/TypeScript#47109.

So that compiles as desired, but unfortunately it re-defines registry in terms of Registry, which you're not allowed to do.  Instead, your requirement is that registry is given to you and cannot be modifierd.  Luckily we can just define the RegistryReturn mapping type in terms of it:
type RegistryReturn = { [K in keyof typeof registry]:
  ReturnType<typeof registry[K]>
}

And then just assign registry to a new variable of type Registry so that the mapped type lookup still happens:
const registryEater = <K extends keyof RegistryReturn>(
    registryKey: K
): RegistryReturn[K] => {
    const _registry: Registry = registry; // new variable
    const desiredFn = _registry[registryKey];
    const desiredValue = desiredFn();
    return desiredValue; // still okay
};

That still compiles.  The only thing left to do is make sure callers get the behavior they want:
const thisIsString: string = registryEater('alpha'); // okay
const thisIsNumber: number = registryEater('beta'); // okay

Looks good!
Playground link to code


text:
Q: Django ORM filter function Is there a way to use an expression in django filter function like a key.
I am trying to do this:
models.Product.objects.filter("name_cn" = "smth")

and get an error:
SyntaxError: keyword can't be an expression

A: If name_cn is a variable, then put it in a dictionary, and deliver the keyword arguments in your dictionary using the ** operator:
models.Product.objects.filter(**{name_cn: "smth"})

If "name_cn" is the name of the field you want to filter on, then try:
models.Product.objects.filter(name_cn="smth")


text:
Q: How to name an abstract class that all components extend from? I have a simple abstract class that have some common properties and methods, that all my components want to share. This abstract class in not a component by itself but all my components extend it. My naming convention for components is to name for example SidePanelComponent class at a file sidePanel.component.ts. The question is, what is the recommended convention to name my Base Abstract class?
abstract class Base {}

or
abstract class BaseComponent {}

@Component({
   ....
})
class SidePanelComponent extends Base {}

Should I name my Base class using the component keyword in the name even though it is not a component by itself?

A: BaseComponent. Base is way too board and does not tell what it does.
Think about if you have another set of abstraction, will you name it Base again?
For Component, maybe it's ok to use abstract class.
But always consider composition and other means before relying on inheritance. Inheritance is a strong coupling mechanism.
It would well worth your time to doublethink would those properties and methods come from a different set of concerns.


text:
Q: How to save a file in /usr/local/lib/cnet? How can I save a file in /usr/local/lib/cnet? I'm trying to save a GIF image in the CNET resource folder to use for a simulation.
It says permission denied, and when I try to chmod the folder it gives me the error "not permitted".
Any ideas?

A: Seems like you need more rights to achieve this.
To be able to chmod, try becoming root before doing the call:
sudo chmod <YOUR_CHMOD> /usr/local/lib/cnet


text:
Q: Legal syntax for parameterized interface I have a interface definition for a parameterized interface as follows :
interface A#(parameter adr=64,parameter data=128,parameter enable=1)(input clk, input rst);
endinterface

Now, can i declare something like ? Is this legal ?
A#(,,0) A0(clk,rst);

I did not find any such examples in the 1800-2012 SV LRM, so I was wondering about the legality of this syntax before I contact the EDA vendor. One such major tool vendor works perfectly fine but another major vendor complains about this - The error specifically being
near ",": syntax error, unexpected ','.

A: I don't know whether it's legal. Two simulators rejected it and one didn't (probably the same one as you). But you could
i) rearrange the order of the parameters:
interface A#(parameter enable=1, parameter adr=64,parameter data=128)(input clk, input rst);
endinterface

A #(0) a (.clk, .rst);

ii) use named mapping:
A #(.enable(0)) a (.clk, .rst);

A: You cannot skip over parameter overrides in an ordered list. It's illegal syntax according to the BNF:
list_of_parameter_assignments ::=
    ordered_parameter_assignment { , ordered_parameter_assignment }
  | named_parameter_assignment { , named_parameter_assignment }
ordered_parameter_assignment ::= param_expression

Contrast this with an ordered list of port connections:
list_of_port_connections29 ::=
    ordered_port_connection { , ordered_port_connection }
  | named_port_connection { , named_port_connection }
ordered_port_connection ::= { attribute_instance } [ expression ]

The param_expression in not optional in a parameter list, but an expression is optional in a port connection list.


text:
Q: Set schemaLocation on XML JAXB I need to add schemaLocation Property that is nested on another object,
I have a class...
...
@XmlRootElement(name = "Comp")
public class Comp {
...

I marshall objects of this class setting Marshaller.JAXB_SCHEMA_LOCATION and it works great, but now there is another class that has a property like this...
@XmlRootElement(name = "TSAT")
public class TSAT {
...
@XmlAnyElement(lax = true)
     protected Object any;
...

and then I set that property with an instance of Comp, setting the property Marshaller.JAXB_SCHEMA_LOCATION do adds the schemaLocation attribute but for the TSAT element and I want it for the Comp element.
I tried marshalling the Comp element and then setting it on the any property, then marshalling TSAT, but I got Comp wrapped inside an  tag.
what I want:
<TSAT>
   <Comp schemaLocation="uri">
   ...
   </Comp>
</TSAT>

what I get:
<TSAT schemaLocation="uri">
   <Comp>
   ...
   </Comp>
</TSAT>

or
<TSAT>
   <any>
   &lt;Comp schemaLocation="uri"&gt;
   ...
   &lt;/Comp&gt;
   </any>
</TSAT>

A: Did you try using different marshallers? i.e. one marshaller that marshals Comp object. This marshaller has xmlschema property. Marshal JAXBElement in a DOMResult. And set the element from DOMResult in Tsat.any object and then marshal Tsat using another marshaller. I don't guarantee that it will work, but worth trying.


text:
Q: Can you only have one hibernate session per thread in java? So I'm working on an application without multi threading. We have a main business logic method that opens a Hibernate session like this:
session = HibernateSessionFactory.getSession();
tx = session.beginTransaction();

and then performs some light DB operations (a few selects). A method that I've overridden in a subclass is then called that needs to perform another select. I can't pass the session as a parameter without having to update 20ish subclasses.
I tried opening a new session and transaction and closing them when I was done, but when my method kicked back to the business method, I got an error that the session was closed. I tried not closing the session and committing the transaction, but that wasn't working either.
Right now I'm just using this and everything seems to be working properly locally:
session = HibernateSessionFactory.getSession();
tx = session.getTransaction();

and I'm only closing the session and rolling back incase of errors. I'm just uncertain if getSession will always return the session thats already open. Am I right to assume that only one session can be open at a time per thread?
Here's the implementation of getSession:
Session session = (Session) threadLocal.get();

    if (session == null || !session.isOpen())
    {
        if (sessionFactory == null)
        {
            rebuildSessionFactory();
        }
        session = (sessionFactory != null) ? sessionFactory.openSession() : null;
        threadLocal.set(session);
    }

    return session;

Thanks!

A: From my understanding, getSession will return a new hibernate session.   There are two methods of using sessions in Hibernate that is described transactional patterns in the document: https://docs.jboss.org/hibernate/orm/4.2/devguide/en-US/html/ch02.html
The actual "session" to the database depends on your connection to the database.   Most people utilize a connection pool, like C3P0 that can be used to ensure session reuse and speed up your code.
The  best structure I use is to create a SessionFactory once in application launch, as this sets up the connection pool to the database.   Then, utilizing maybe a singleton pattern to keep a single SessionFactory, request new sessions for each transaction you perform from the single SessionFactory.   Hibernate will utilize the underlying connection pool to handle session reuse for speed and optimization.


text:
Q: Would it be possible to make different frontName in one module? I would like to call three urls that show me three views from one module with three methods and three templates.
Exemple
Saying that I have a module called promo and controller is IndexController.php and in the controller three methods: method1, method2, method3.
Url 1 : www.exemple.com/promo/index/method1
Url 2 : www.exemple.com/promo/index/method2
Url 3 : www.exemple.com/promo/index/method3
It is possible to replace the urls to :
Url 1 : www.exemple.com/promo
Url 2 : www.exemple.com/promo2
Url 3 : www.exemple.com/promo3
Which my question and my idea is to call directly the frontname in the URL and this allows me to not create three modules for only three views.

A: It is possible, to have different front names mapping to the same module.
Create multiple nodes below <routers> in your modules config.xml. They will have the same value in <module> but different values in <frontName>:
<routers>
    <your_module_1>
        <use>standard</use>
        <args>
            <module>Your_Module</module>
            <frontName>promo</frontName>
        </args>
    </your_module_1>
    <your_module_2>
        <use>standard</use>
        <args>
            <module>Your_Module</module>
            <frontName>promo2</frontName>
        </args>
    </your_module_2>
</routers>

(your_module_1 and your_module_2 is arbitrary, each element name just has to be unique).
But this results in:
/promo   => your_module/index/index
/promo2  => your_module/index/index

Each front name maps to the same module, so these URLs both result in the same controller action to be called.
So to achieve what you want, you don't need different front names, but instead a custom router.
Here's a tutorial for writing a custom router: http://inchoo.net/magento/custom-router-in-magento/
The router will check if the URL starts with "promo", and if it is the case, set the appropiate controller and action in the request object.


text:
Q: Compute the areas of portions of a circle defined by a point Given a circle with center (cx,cy) and radius r, and a point inside the circle (px,py), draw the lines x=px and y=py to divide the circle into four sections.  How can I compute the areas of these four sections?

A:
Wlog, we can assume the circle is $C(O, r)$; where $O=(0, 0)$ and $r$ is the radius. We can further assume that $P(x_p, y_p)$ is a point in the 1st quadrant and $d(O, P) \le r$.
Thus, the lines $x = x_p$ and $y = y_p$ divide that quarter of circle into $4$ regions as shown.
It is not difficult to see that [(yellow)region] can be found.
By using "area of sector – the area of the corresponding central triangle", the areas of the following can be found:-
$[A] = [(green + brown)]$; and $[B] = [(blue + brown)]$.

Then,
$[A \cup B] = [(green + brown + blue)] = 0.25[whole circle] – [(yellow)]$
$[(Brown)] = [A \cap B] = [A] + [B] – [A \cup B]$
Once $[(Brown)]$ is known, the other $3$ regions can be found.


text:
Q: Receiving email in Parse via Mailgun So I'm new to Mailgun. I'm trying to use it to receive emails and forward them onto Parse so that I can save the information in them to a Parse database. I have a route set up correctly between Mailgun and Parse. Using the 'Send a sample POST' feature from Mailgun, data is added to my database in Parse. So my route is configured correctly from Mailgun to Parse.
Problem
Sending an email to sample-address@mydomain.com gives me a bounced email back, with an 550-Please turn on SMTP Authentication in your mail client error. It also says that it's not permitted to relay 550 through this server without authentication. Seems like it's a problem with Mailgun not correctly configuring the mailserver. Maybe?
Things I've Tried

*

*Checking all MX records, CNAME, TXT records - all are set up according to Mailgun's specs

*Not using a mydomain.com MX record - no change

*Using a different address@mydomain.com, or a catchall forwarder from Mailgun - no change in status

Anyone know what's up? It's a weird error that I can't figure out how to debug. Any tips on debugging this would be highly appreciated.

A: I think your mail client is not allowing mailgun to post data, You can lower down the security parameters in your mail client settings, allowing less trusted systems to post.


text:
Q: Using table of Laplace transforms for t>0 to calculate functions defined on t<0 I've noticed that it's often true that if:
$$\mathcal{L}(f(t)\theta(t)) = F(s), \qquad Re(s)>0$$
then:
$$\mathcal{L}(f(t)(\theta(t) - 1)) = F(s), \qquad Re(s)<0$$
For example it is true for $f(t)=sin(at)$
But is this a general rule?
If it where it would mean that if we have a table of Laplace transforms for functions defined on $(0,\infty)$ we could use the same table of one-sided transforms for functions defined on $(-\infty,0)$, as long as we multiply the function we want to transform by $-1$ first.


text:
Q: C# WPF run PowerShell async with Reactive and AsyncRelayCommand I want to use a button click to execute a PowerShell script asynchronously and display the output directly in my UI.
It is based on this StackOverflow question.
Since I couldn't quite figure out the implementation, I tried to solve it myself. It works, but I think there is a lot of room for improvement.
Is my implementation a good approach? In particular, the three observables that I combine in the GetPowerShellOutputObservable method don't feel right to me.
onCompleted is never called, although the observer.OnCompleted(); is passed through in powershellEnded-Observable.
MyViewModel.cs
public MyViewModel()
{
    ExecuteCommand = new AsyncRelayCommand<string>(Execute, CanExecute);
    // ...
}

public IAsyncRelayCommand ExecuteCommand { get; }

private Task Execute(string scriptFile)
{
    _service.GetPowerShellOutputObservable(scriptFile).Subscribe(
        onNext:         output => print(output),
        onError:        exception => print($"Exception: {exception.Message}"),
        onCompleted:    () => print("Completed!")
    );
    return Task.CompletedTask;
}

private bool CanExecute(string param)
{
    return !string.IsNullOrEmpty(param) && File.Exists(param);
}

public void print(string message)
{
    Console.WriteLine(message);

    //App.Current.Dispatcher.Invoke((Action)delegate
    //{
        CompleteCommandOutput += DateTime.Now.ToString("HH:mm:ss:fff ") + message + "\r\n";
    //});

}

MyPowerShellWorker.cs
// ...
public IObservable<string> GetPowerShellOutputObservable(string scriptFile)
{
    var scriptContents = File.ReadAllText(scriptFile);
    var powerShell = PowerShell.Create();
    powerShell.AddScript(scriptContents);
    var powerShellOutputBuffer = new PSDataCollection<string>();

    // Observable<string>: Streams.Information
    var powershellStreamInformationDataAdded = Observable.FromEventPattern<DataAddedEventArgs>(
        handler => powerShell.Streams.Information.DataAdded += handler,
        handler => powerShell.Streams.Information.DataAdded -= handler)
        .Select(eventPattern =>
        {
            PSDataCollection<InformationRecord> collection = eventPattern.Sender as PSDataCollection<InformationRecord>;
            return collection[eventPattern.EventArgs.Index].MessageData.ToString();
        });

    // Observable<string>: OutputBuffer
    var powershellOutputBufferDataAdded = Observable.FromEventPattern<DataAddedEventArgs>(
            handler => powerShellOutputBuffer.DataAdded += handler,
            handler => powerShellOutputBuffer.DataAdded -= handler)
        .Select(eventPattern =>
        {
            PSDataCollection<string> collection = eventPattern.Sender as PSDataCollection<string>;
            return collection[eventPattern.EventArgs.Index];
        });

    // Observable<string>: PowerShell ended
    var powershellEnded = Observable.Create<string>(
        observer =>
        {
            var invokeAndEndInvokePowerShellTask = Task.Factory.FromAsync(
                                                        powerShell.BeginInvoke(
                                                            (PSDataCollection<PSObject>)null,
                                                            powerShellOutputBuffer),
                                                        powerShell.EndInvoke);

            invokeAndEndInvokePowerShellTask.ContinueWith(a => {
                powerShell.Dispose();
            });

            invokeAndEndInvokePowerShellTask.ContinueWith(a => {
                if (a.Exception == null)
                {
                    observer.OnCompleted();
                }
                else
                {
                    observer.OnError(a.Exception);
                }
            });

            return Disposable.Empty;
        });

    return Observable.Merge(new List<IObservable<string>>() {
        powershellStreamInformationDataAdded,
        powershellOutputBufferDataAdded,
        powershellEnded
    });
}


text:
Q: Can't do all possible moves of a Horse in a Chess table UPDATE: Thanks a lot M Oehm for your awesome answer, really helped me a lot. That struct pos moves is really helpful, haven't studied it yet on class. Im working on a fully solution of my code adding yours as a bone on the programs skeleton. Already fixed the problem of updating fila and columna, the random choice and the switch from 0 to 7 without the ' ' because they're not characters as you and davidc pointed. My program still have some problems which im working on before posting the fully operational program here. I'll update the code tomorrow if not today. Thank you all for your comments and solutions, and M oehm for the time you spent making that wonderful answer.
------------------------------------------------------------------------------------------------------------------------------------

UPDATE 2: Finnished it, made some  little changes on M Oehm code and instead of putting manually the first location of the horse i used my previous PosicionCaballo(). Had to delete the code of the MoverCaballo() which had a Switch with 8 possible moves which was set by a random number because i couldn't make it work (i guess the main problem was that part because already was a mess). Now the program with the code below should ask the user for the initial position of the horse, after that the screen will print a 10x10 table filled with 0's (free spaces), fill it with 1's (taken spaces which did the horse moving randomly) and when it finnishes display a message on how many positions did it take.
COORD cxy;
#define posicion(x,y) {(cxy.X)= (x);(cxy.Y)= (y); SetConsoleCursorPosition((GetStdHandle(STD_OUTPUT_HANDLE)), (cxy) );}

int ajedrez[10][10];
int fila, columna;

void GenerarTablero(int m[10][10]){
    int i, j;
    for (i = 0; i < 10; i++){
        for (j = 0; j < 10; j++){
            m[i][j] = 0;
        }
    }
}

GenerarTablero makes the chess board and fills it with 0's.

Global are fila (row) and columna (column) the parts of the ajedrez[10][10]
ajedrez[10][10] is the chess table in a 10x10 size.
void PosicionCaballo(int m[10][10]){
    printf("Fila: ");
    scanf_s("%d", &fila);
    printf("Columna: ");
    scanf_s("%d", &columna);
    printf("\n");

    m[fila][columna] = 2;
    system("cls");

}

PosicionCaballo does ask the user for the initial position of the horse and puts the horse on the table.
Example: Row: 5 Column: 5
int horse(int y, int x)
{
    int visited[SIZE][SIZE] = { { 0 } };
    int count = 0;

    if (on_board(y, x) == 0) return -1;

    /* Set starting position */
    visited[y][x] = 1;

    while (1) {             /* Infinite loop - must use break */
        int poss[8];        /* Possible moves */
        int nposs = 0;      /* Actual length of poss */
        int i, k = 1;

        for (i = 0; i < 8; i++) {
            int xx = x + moves[i].x;
            int yy = y + moves[i].y;

            if (on_board(yy, xx) && visited[yy][xx] == 0) {
                poss[nposs++] = i;
            }
        }

        /* No more valid moves: return */
        if (nposs == 0){
            posicion(0, 11);
            printf("El tablero se ha bloqueado con ");
            return count;
        }

        /* pick one of the valid moves */
        i = poss[rand() % nposs];
        x = x + moves[i].x;
        y = y + moves[i].y;

        /* update horse's position */
        visited[y][x] = 1;
        count++;

        /* print position */

        posicion(y, x);
        printf("1");

    }

    return -1;      /* Should never be reached */
}

void MostrarMapa(int m[10][10]){
    int i, j;
    for (i = 0; i < 10; i++){
        for (j = 0; j < 10; j++){
            printf("%d", ajedrez[i][j]);
        }
        printf("\n");
    }
}

MostrarMapa only prints the chess table on the screen.

int main(void){

    int n;

    srand(time(NULL));
    GenerarTablero(ajedrez);
    PosicionCaballo(ajedrez);
    MostrarMapa(ajedrez);
    n = horse(fila, columna);
    posicion(31, 11);
    printf("%d movimientos\n", n);

    getch();
    return 0;
}

and then my main which im using all the functions stated upside.
Thank you very much in advance for your help guys :).

A: I guess that your assignment is about finding a valid path that visits all squares. Your code tries to find one random path.
Your code has several errors:

*

*When you test ajedrez[fila - 2][columna - 1], you don't check whether fila - 2 or columna - 1 are really valid indices of your chess board. If you access invalid indices, way -1 or 11, you invoke undefined behaviour.

*You don't update fila and columna, that is: You don't move your horse.

*You overwrite the board twice. That's not an error, but your code shouldn't do double duty.

*Your random choice is broken. You have eight possible moves, so you want rand() % 8, which yields numbers from 0 to 7. (David has already pointed this out in a comment.)

*Your case labels are charater constants, not numbers. Use case 0:, not case '0':.

*You just skip invalid moves. When there are no more valid moves, this will result in an infinite loop. You should check this condition and terminate the loop if it occurs.

*As I understand it, the ´posicion` macro is just to show ehere the horse is. Maybe you should skip that at the moment and just print the new coordinates, which isn't as pretty, but straightforward.

Your eight switch cases manifest another flaw: You have the same repeated code eight times over. The only difference is the jump pattern. Such a set-up lends itself to either writing a function where you pass the row and columns distance to jump or to using an array of possible jump patterns.
Your code should instead do something like this for each move:

*

*Loop over all eight jump patterns. If the horse would jump off the board or if the horse would visit a tile that has already been visited, skip that possibility. Otherwise, add the move to an auxiliary array.

*If the number of possibilities is zero, terminate the loop - the horse has nowhere to go.

*Pick one of the valid moves.

*Move the horse, mark the current tile visited.

*Report the jump, if desired: Print the new position or place the cursor, whatever.

Below is an example implementation that uses an array of jump patterns. It will give one random path. You can adapt this code to your problem.
#include <stdlib.h>
#include <stdio.h>
#include <time.h>       /* for time() */

#define SIZE 10         /* Fixed board size */

struct pos {
    int x, y;
};

struct pos moves[8] = {     /* Jump patterns */
    {1, 2},
    {2, 1},
    {2, -1},
    {1, -2},
    {-1, -2},
    {-2, -1},
    {-2, 1},
    {-1, 2}
};

/*
 *      Is position (y, x) a valid board coordinate?
 */
int on_board(int y, int x)
{
    if (x < 0 || x >= SIZE) return 0;
    if (y < 0 || y >= SIZE) return 0;
    return 1;
}

/*
 *      Move the horse randomly, starting from (y, x). Print the
 *      visited fields and return the number of moves made or
 *      -1 if an error occurs.
 */
int horse(int y, int x)
{
    int visited[SIZE][SIZE] = {{0}};
    int count = 0;

    if (on_board(y, x) == 0) return -1;

    /* Set starting position */
    visited[y][x] = 1;
    printf("%c%d, ", 'A' + y, x + 1);

    while (1) {             /* Infinite loop - must use break */
        int poss[8];        /* Possible moves */
        int nposs = 0;      /* Actual length of poss */
        int i;

        for (i = 0; i < 8; i++) {
            int xx = x + moves[i].x;
            int yy = y + moves[i].y;

            if (on_board(yy, xx) && visited[yy][xx] == 0) {
                poss[nposs++] = i;
            }
        }

        /* No more valid moves: return */
        if (nposs == 0){
            printf("whoa!\n");
            return count;
        }

        /* pick one of the valid moves */
        i = poss[rand() % nposs];
        x = x + moves[i].x;
        y = y + moves[i].y;

        /* update horse's position */
        visited[y][x] = 1;
        count++;

        /* print position */
        printf("%c%d, ", 'A' + y, x + 1);
    }

    return -1;      /* Should never be reached */
}

int main()
{
    int n;

    srand(time(NULL));

    n = horse(3, 6);
    printf("%d moves\n", n);

    return 0;
}

A: You seem to update the position using posicion(), but not update fila and columna


text: Q: Passive dative voice if it is correct Can I say "I was bought a car" meaning that a car was bought for me or it is incorrect. And the following sentence "The universe expands" it means that The Universe expands something or The universe itself is being expanded ? I was bought or I was given sometimes is used but it seems a bit ambiguous to me it seems like I was bought or given from someone to someone like slavery .


text:
Q: Creating an autofilter search box I'm trying to create a search box that filters the data based on a string inputted in a inputbox. Rather than filtering based on a single column I'd like to search the entire table (Currently A8:AK700 but may change in the future).
I have got a search function that works on a single column and filters the data accordingly, I then tried to create a loop to search one column after another, but this removes all data as I believe its looking for a match in all columns.
Sub Filter()
    If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData

    Dim strName As String, LastColumn As Long, StartCell As Range, Si As Integer 'String Name
    Si = 1
    Set sht = Sheets("Contract History")
    Sheets("Contract History").Select
    Set StartCell = Range("A8")

    'Find Last Row and Column
    LastRow = StartCell.SpecialCells(xlCellTypeLastCell).Row
    LastColumn = StartCell.SpecialCells(xlCellTypeLastCell).Column
    sht.Range(StartCell, sht.Cells(LastRow, LastColumn)).Select
    'Search Function
    strName = InputBox("What would you like to search for?")

    Do
        Selection.AutoFilter Field:=Si, Criteria1:="=*" & strName & "*", Operator:=xlAnd
        Si = Si + 1
    Loop Until Si = 37
End Sub

As an example I'd like to search for Korea, and it show all rows of data containing Korea in either of the Customer, Location, or Source columns. Currently I get 0 results