text:
Q: I want to prevent people from accessing my php pages directly using .htaccess I have a site that is made up of php pages, but they are served to the user through includes based on what I think they need. if they can guess the name of a php file, they can access those pages. while this is not a security risk at all, i would rather have a way to catch this and redirect them to somewhere else.
i really want everything to go through the index page unless it is a file that exists (exeption being for any file ending with .php).
I tried this, didnt work:
RewriteEngine on
RewriteCond %{REQUEST_URI} !(.*\.php$) [NC]
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule .* /n/index.php [NC]

A: Maybe you can put the php files in a directory outside the web path?

A: One way to handle this would be to define a constant in the page doing the including:
define("access", "legitimate");

Then at the start of each included file:
if(!defined('access')){
    header("Location:index.php");
    die(); // make sure to call die() or the rest of the page will be parsed
}

This is the way many frameworks and CMS handle this issue (off the top of my head, Joomla! and CodeIgniter) - you don't need to mess about with .htaccess, and it will also work across various hosting platforms.

A: I think something like this will work for you:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
RewriteRule \.php$ index.php [L]

A: RewriteEngine on
RewriteCond %{REQUEST_URI} .*\.php$ [NC]
RewriteRule !^index\.php$ error.php

This works for me, and looks like it should do what you want. Putting the scripts you don't want direct access to outside of the web path is the better answer though - it doesn't require special rules (that may later break and require changing) nor extensions.


text:
Q: Secure ASP.NET Web API for iOS Consumtion So I am trying to secure an ASP.NET Web API Service so that an iOS (iPhone 4/5) application can access it RESTfully using their Windows user name and password (don't ask :) ), and I have followed this article here, and for the most part it works, I just modified it a little to use Active Directory Services to validate the user name and password, but I am wondering if there are better ways to secure a ASP.NET Web API that will be used from non-browser clients as well as browsers possibly?
This is hosted with IIS7, so should I just let IIS control the authentication?
Need a little guidance... Thanks

A: It's a bit unclear specifically what you are looking for, in my experience assuming I'm authenticating against a server the keys were

*

*Put access to the APIs behind https

*Send the request via POST.

If you're also coding the iOS side, make sure you are implementing authentication challenging properly.  Here's an article on the iOS side: http://mobiledevelopertips.com/networking/handling-url-authentication-challenges-accessing-password-protected-servers.html

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to declare a variable depends on another in Angular 8 Updated stackblitz link : https://stackblitz.com/github/Cheong-LiJie/student-program
I am new in Angular 8 and I am coding a college project which user can register student and professor.
I have 2 interface which are Student and Professor and each professor is handling different subject and if the student is taking IT subject then his professor will be A, if he is taking Account then his professor will be B.
The only way that I can think is create an if..else statement like
if (student.subject == IT){
   student.professor == Dr. Kenny
}else {
   student.professor == Dr. John
}

But this is just hard-code and every time I add a new professor and subject I need to modify the code again.  How can I declare the student.professor depends on professor.subject and student.subject?
College.ts:
export interface IStudent{
  id:number;
  name:string;
  age:number;
  subject:string;
  education:string;
  professor:string;
}

export interface IProfessor{
  id:number;
  name:string;
  faculty:string;
  subject:string;
}

in-memory-data.service.ts
export class InMemoryDataService implements InMemoryDbService{

  createDb() {
    var students = [
  {"id":1,"name":"John","age":22,"subject":"IT","education":"Diploma"},
  {"id":2,"name":"Austine","age":26,"subject":"Business","education":"Degree"},
  {"id":3,"name":"Samantha","age":24,"subject":"Account","education":"Diploma"},
  {"id":4,"name":"Lily","age":25,"subject":"IT","education":"Degree"},
  {"id":5,"name":"Ken","age":19,"subject":"Account","education":"Diploma"},
    ];

    var professors = [
      {  "id":1, "name":"Dr. Lim","faculty":"FOCS","subject":"IT"},
      {  "id":2, "name":"Professor Anthony","faculty":"FASC","subject":"Account"},
      {  "id":3, "name":"Ms. Pua","faculty":"FAFB","subject":"Business"}
    ];
    return {students,professors};
  }

studentList.html

      ID
      Name
      Age
      Programme
      Education
      Professor
      Action

        {{ student.id }}

      {{ student.name }}
      {{ student.age }}
      {{ student.subject }}
      {{ student.education }}
      {{ student.professor }}

student.component.ts
export class StudentListComponent implements OnInit {
  students: IStudent[];
  public successMsg: string;
  public popoverTitle : string = 'Confirmation Dialog';
  public popoverMessage : string = 'Are you sure you want to delete this student?';
  public confirmClicked : boolean = false;
  public cancelClicked : boolean = false;

  @ViewChild(StudentDetailComponent) child;

  constructor(
    private _studentService: StudentService,
    private route: ActivatedRoute,
    private router: Router,
  ) {}

  ngOnInit() {
    this._studentService
      .getStudents()
      .subscribe(data => (this.students = data));

    this.successMsg = this.child.successMsg;
  }

  delete(student: IStudent): void {
    this.students = this.students.filter(s => s !== student);
    this._studentService
      .delete(student)
      .subscribe(
        data =>
          (this.successMsg = "You have deleted student with ID " + student.id)
      );
  }

  private loadAllUsers() {
    this._studentService.getStudents().subscribe(students => {
      this.students = students;
    });
  }
}

student.service.ts:
export class StudentService {
  private _url = "api/students";

  constructor(
    private _http: HttpClient,
    private messageService: MessageService
  ) {}

  delete(student: IStudent | number): Observable<IStudent> {
    const id = typeof student === "number" ? student : student.id;
    const url = `${this._url}/${id}`;

    return this._http.delete<IStudent>(url);
  }

  private log(message: string) {
    this.messageService.add(`StudentService: ${message}`);
  }

  getStudents(): Observable<IStudent[]> {
    return this._http.get<IStudent[]>(this._url);
  }

  getStudent(id: number): Observable<IStudent> {
    const url = `${this._url}/${id}`;
    return this._http.get<IStudent>(url);
  }

  addStudent(student: IStudent): Observable<any> {
    return this._http.post<any>(this._url, student);
  }
  updateStudent(student: IStudent): Observable<any> {
    return this._http.put<any>(this._url, student);
  }
}

A:
How can I declare the student.professor depends on professor.subject and student.subject?

You have set your interfaces up in what is known as a denormalised way. By that, I mean you are storing information about a unique entity across multiple entities.
In your domain you have at least the following entity concepts:

*

*student

*professor

*subject

Subject and student (as things stand) have a one-to-many relationship. One subject can have many students. One student can have one subject.
Subject and professor have a one-to-one relationship. One subject can have one professor. One professor can have one subject (I assume).
The design
Subject has one property - its name. Professors have many properties. You could store the subject on the professor and the professor object on the student.
export interface IStudent{
  id:number;
  name:string;
  age:number;
  education:string;
  professor: IProfessor;
}

export interface IProfessor{
  id:number;
  name:string;
  faculty:string;
  subject:string;
}

Then you get the student's subject via the professor:
const subject = student.professor.subject;

Treating the subject as an object
Alternatively, you could treat the subject as an object. It is also common to store the id of a complex object and then look it up when you need it.
export interface IStudent{
  id:number;
  name:string;
  age:number;
  education:string;
  subjectId: number;
}

export interface IProfessor{
  id:number;
  name:string;
  faculty:string;
}

export interface ISubject{
  id: number;
  name: string;
  professorId: number;
}

You would add unique entities for each entity (within each entity array), and then lookup an entity when you need it.
For example:
const student = this.service.getStudent(1);
const subject = this.service.getSubject(student.subjectId);
const professor = this.service.getProfessor(subject.professorId);

Where the service methods are some optimised way of finding an entity by its id.
How to choose a design?
There is never just one choice to make when choosing a design. Which one you choose depends on how it best suits your needs. This is not only true in the entity design, but also how you store it. If you have 1000 students and a lot of queries, you don't want to be searching the whole array every time just to find a student by their id.

A: I think that the idea is "cache" the profesors (profesors will be a few profesors)
profesor.service
professors:IProfessor[]=null;
 getProfessors(): Observable<IProfessor[]> {
    return this.professors? of(this.professors):
      this._http.get<IProfessor[]>(this._url).pipe(
         tap(res=>{
            this.professors=res;
         })
      );
  }

Then, in student.service, you can change the getStudents and getStudent to get the profesor
getStudents(): Observable<IStudent[]> {
    return forkJoin(this._professorService.getProfessors(),this._http.get<IStudent[]>(this._url)).pipe(
    map(([professors,students]:[IProfessor[],IStudent[]])=>{
       students.forEach(x=>{
          const professor=professors.find(p=>p.subject==x.subject)
          x.professor=professor
          //you can also only get the name, e.g.
          //x.profesorName=profesor?profesor.name:''
       })
       return students
    })
  )
  }

getStudent(id: number): Observable<IStudent> {
    const url = `${this._url}/${id}`;
    return forkJoin(this._professorService.getProfessors(),
                    this._http.get<IStudent>(url)).pipe(
    map(([professors,student]:[IProfessor[],IStudent])=>{
          const professor=professors.find(p=>p.subject==student.subject)
          student.professor=professor
          //you can also only get the name, e.g.
          //student.profesorName=profesor?profesor.name:''
         return student
    })
    )
  }

A: Instead of using an if statement, you could do a search by the subject on the professors array. Something like this will assign the first professor of the subject,
const professor = professors.find(p => p.subject === student.subject);
student.professor = professor ? professor.name : null;


text:
Q: Calculate field using data from excel table I need to interpolate data that I have in a excel file using data from an attribute table of a point feature.
I want to create a new field on the attribute table with the result of that interpolation. The problem is that my data is on excel and I don't want to join the excel table with the attribute table. I just want to use the data from excel table to obtain a result for my attribute table.
Is there any way to do that?

A: Use map joins with field calculator. Map join won't add the fields physically to your table, rather, it is an in-memory join.
Right-click your layer in TOC > Click Joins and Relates> Join...
Then use Field Calculator to interpolate.


text:
Q: Mathematical uses of string theory It is widely believed that correctness of string theory as a physical theory will not be decided in the near future. Regardless whether this will turn out to be correct or not, mathematical concepts derived from string theory may have proved theorems whose correctness (and relevance for mathematics) is undisputed.
What are (important in mathematics) mathematical theorems which wouldn't have been proved without the development of string theory?

A: If the question is set on the level of mentioning important "theorems" or "computations" or "results" which

wouldn't have been proved without the development of string theory

i think one could easily build a very-very long list.
Maybe it would be more appropriate to speak about which "theories" wouldn't have been out there (at least in their present form) had string theory been missing.
I believe that the case of mirror symmetry is a good candidate. See also Kontsevich's 1994 paper
Edit: Regarding the comment:

would it be right to say that actual proofs (as far as they exist) are not using input from physics and that the role of string theory was to formulate the relationship?

In some sense yes (at least regarding the part "...the role of string theory was to formulate the relationship"); and this may be seen in some precise sense as the the role of dualities in string theory: In general, duality -in string theory- means that two different string theory models may come down to the same "quantitative predictions" (for exampe the same set of topological invariants) for suitable choices of their parameters. The values of the parameters are often indicated by physical arguments (which may include experimental data or phenomenological arguments) and then the duality imposes conjectures of mathematical nature.
(However, this does not exclude the possibility that the actual proofs are indeed  using input from physics -i think that Witten's work has pointed to that direction but i do not have some exact reference available right now).
  The following diagram outlines some general scheme of the physics-mathematics interaction through dualities of string theory:

For more details, you can see the very interesting article: Mathematics and string theory, by Marcos Marino (see especially the discussion in p. 4-5).
P.S.: Maybe it would be interesting to have a look at the list included in the first answer at the following quora's question:
Are there any applicable uses of the string theory in maths? Or does it just apply for physics?

A: I recall that Richard Wentworth's first paper on precise constants in bosonization formula (which is part of his PhD thesis?) extensively used computational methods from bosonic string theory. I am not sure if the methods have been justified, since his second paper used completely different methods to derive the same result. Later I was informed that Jorgenson proved the same result using much more classical methods like asymptotic expansion of heat kernel, construction and estimate of the paramatrix, etc.
To me I feel the fact that path integral and $\zeta$-function regularization methods "coincide" in actual computation for topics related to Polyakov measure is not a mere coincidence. I do not really know string theory, but this observation striked me as something deep and subtle connecting physics to mathematics.

A: Monstrous moonshine, the famous relationship between the
dimensions of the irreducible representations of the Monster group and the coefficients in the Fourier expansion of
the $j$-invariant. Borcherds' proof of monstrous moonshine uses the Goddard-Thorn
theorem, which comes out of string theory,
specifically the quantization of the bosonic string.

A: 1) Verlinde's formula: Let $\mathrm{C}$ be a curve of genus $g\geqslant 2$. The Picard group of the Moduli space of rank $2$ bundles on $\mathrm{C}$ with trivial determinant is an infinite cyclic group, with ample generator denoted by $\mathscr{L}$. Verlinde's formula says that $$h^0(\mathscr{L}^{\otimes k})=\sum_{p=0}^{k} \mathrm{S}_{p0}^{-\chi(\mathrm{C})},$$
where the matrix $\mathrm{S}=(\mathrm{S}_{pq})_{p,q=0}^{k}$ is given by
$$\mathrm{S}_{pq}=\sqrt{\frac{2}{k+2}}\sin\frac{(p+1)(q+1)}{k+2}\pi.$$
This was proven in the early 90s by several people (Bertram-Szenes, Faltings, Thaddeus,...).
The corresponding result for rank $1$ bundles (in which case the right hand side of the formula is $k^g$) is classical and easy to prove. For rank $2$ bundles the Moduli space is not smooth, let alone a torus, and so the intersection theory is very hard to determine.
2) Witten's conjecture: Consider the DM compactified moduli space $\overline{\mathscr{M}}_{g,n}$ of genus $g$ curves with $n$ markings. For each $1\leqslant i\leqslant n$ there is a line bundle $\mathscr{L}_i$ on $\overline{\mathscr{M}}_{g,n}$ whose fiber over $(\mathrm{C};p_1,\ldots,p_n)$ is the cotangent space $\mathrm{T}^\vee_{\mathrm{C},p_i}$. Let $\psi_i=c_1(\mathscr{L}_i)$. For $k_1,\ldots,k_n\geqslant 0$ define $\left\langle\tau_{k_1}\cdots\tau_{k_n}\right\rangle_g$ to be
$$\int_{\overline{\mathscr{M}}_{g,n}}\psi_1^{k_1}\cdots\psi_n^{k_n}$$
if $\sum_{i=1}^n k_i=\dim\overline{\mathscr{M}}_{g,n}=3g-3+n$ and $0$ otherwise. Then define
$$F_g((t_i)_{i=0}^\infty)=\sum_d \left(\prod_{i=1}^\infty \frac{t_i^{d_i}}{d_i!}\right)\left\langle\tau_0^{d_0}\tau_1^{d_1}\tau_2^{d_2}\cdots\right\rangle_g,$$
the summation being over all sequences $d=(d_i)_{i=1}^\infty$ of natural numbers with finite support. Consider the generating series
$$F=\sum_{g=0}^\infty F_g \lambda^{2g-2}$$
with derivatives
$$\left\langle\left\langle\tau_{k_1}\cdots\tau_{k_n}\right\rangle\right\rangle=\frac{\partial}{\partial t_{k_1}}\cdots\frac{\partial}{\partial t_{k_n}}F.$$
Witten's conjecture says that for all $n\geqslant 1$
$$(2n+1)\lambda^{-2}\left\langle\left\langle\tau_n \tau_0^2\right\rangle\right\rangle=\left\langle\left\langle\tau_{n-1}\tau_0\right\rangle\right\rangle\left\langle\left\langle\tau_0^3\right\rangle\right\rangle+2\left\langle\left\langle\tau_{n-1} \tau_0^2\right\rangle\right\rangle\left\langle\left\langle\tau_0^2\right\rangle\right\rangle+\frac{1}{4}\left\langle\left\langle\tau_{n-1} \tau_0^4\right\rangle\right\rangle.$$
(For more on this see for example Harris & Morrison, Moduli of Curves, page 71.)
For $n=1$ Witten's conjecture means that $U=\partial^2 F/\partial t_0^2$ satisfies the KdV equation
$$3\lambda^{-2}\frac{\partial U}{\partial t_1}=3U\frac{\partial U}{\partial t_0}+\frac{1}{4}\frac{\partial^3 U}{\partial t_0^3}.$$
Witten's conjecture was first proven by Kontsevich, and again several other people have given alternative proofs (Okounkov-Pandharipande, Kazarian-Lando, Mirzakhani,...). But I find it difficult to imagine that this result would have seen the light of day without string theory.
3) Counting rational curves on quintic threefolds, see for example Pandharipande's Séminaire Bourbaki talk. Some of the history is described  here.


text:
Q: Non-fatal IronPython NumPy Exceptions I installed Enthought's NumPy implementation for IronPython as per their instructions.
Everything seems to work, including import numpy and import scipy, but having these statements in an IronPython program causes the following exceptions:
A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in IronPython.dll

A first chance exception of type 'System.MissingMemberException' occurred in Microsoft.Dynamic.dll

A first chance exception of type 'System.MissingMemberException' occurred in IronPython.dll

A first chance exception of type 'IronPython.Runtime.Exceptions.TypeErrorException' occurred in Snippets.debug.scripting

How do I fix these exceptions?

A: I wouldn't worry about them, and I doubt they could be removed anyway. Those all map to Python exceptions, which means that they're probably necessary to keep compatibility with CPython. In CPython, exceptions are fast (a couple orders of magnitude faster than .NET) so they're much more commonly used in Python code than in C#.
IronPython normally uses the .NET exception mechanism to surface Python exceptions, which can lead to huge slowdowns in some code. 2.7 add a "lightweight exception" mechanism, but it's not consistently used (compatibility is more important than performance right now, but I would strongly consider a pull request). It's possible that some of the code that throws these exceptions could be modified to use lightweight exceptions instead.


text:
Q: How to connect MySQL to c++ on m1 Mac? I am using Apple M1 MacBook Air.
I want to connect MySQL to c++. I've tried 2 variants: 'c++ connector' installed from official MySQL website(with jdbc.h) and 'mysql-8.0.26-macos11-arm64' installed with 'brew install mysql'.
I can include both of them with:
#include </usr/local/mysql-connector-c++-8.0.27/include/mysql/jdbc.h>

OR
#include </usr/local/mysql-8.0.26-macos11-arm64/include/mysql.h>

And it successfully compiles.
But when I try to write any code that uses any of those libraries, it gives errors:
Code for JDBC:
#include </usr/local/mysql-connector-c++-8.0.27/include/mysql/jdbc.h>

using namespace std;

int main() {
        try {
                sql::mysql::MySQL_Driver *driver;
                sql::Connection *con;

                driver = sql::mysql::get_mysql_driver_instance();
                con = driver->connect("tcp://127.0.0.1:3306", "root", "rootpass");

                delete con;
        } catch (sql::SQLException &e) {
          cout << "# ERR: SQLException in " << __FILE__;
          cout << "(" << __FUNCTION__ << ") on line "
             << __LINE__ << endl;
          cout << "# ERR: " << e.what();
          cout << " (MySQL error code: " << e.getErrorCode();
          cout << ", SQLState: " << e.getSQLState() << " )" << endl;
        }
        return 0;
}

Error:
Undefined symbols for architecture arm64:
  "check(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      check_lib() in sql-c9ebd3.o
  "check(std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > > const&)", referenced from:
      check_lib() in sql-c9ebd3.o
  "sql::mysql::_get_driver_instance_by_name(char const*)", referenced from:
      sql::mysql::get_driver_instance_by_name(char const*) in sql-c9ebd3.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Code for mysql-arm64 from 'brew':
#include </usr/local/mysql-8.0.26-macos11-arm64/include/mysql.h>
#include <iostream>
#include <stdlib.h>

using namespace std;
int main(void)
{
  MYSQL_RES *result;
  MYSQL_ROW row;
  MYSQL *connection, mysql;

  int state;

  mysql_init(&mysql);

  connection = mysql_real_connect(&mysql,"127.0.0.1","root","rootpass","mysql",0,0,0);

  if (connection == NULL)
  {
    std::cout << mysql_error(&mysql) << std::endl;
  }
state = mysql_query(connection, "SHOW TABLES");
  if (state !=0)
  {
    std::cout << mysql_error(connection) << std::endl;
  }

  result = mysql_store_result(connection);

  std::cout << "tables: " << mysql_num_rows(result) << std::endl;
  while ( ( row=mysql_fetch_row(result)) != NULL )
  {
    cout << row[0] << std::endl;
  }

  mysql_free_result(result);
  mysql_close(connection);
  return 0;
}

Error:
Undefined symbols for architecture arm64:
    "_mysql_close", referenced from:
      _main in sql_another-80b5eb.o
  "_mysql_error", referenced from:
      _main in sql_another-80b5eb.o
  "_mysql_fetch_row", referenced from:
      _main in sql_another-80b5eb.o
  "_mysql_free_result", referenced from:
      _main in sql_another-80b5eb.o
  "_mysql_init", referenced from:
      _main in sql_another-80b5eb.o
  "_mysql_num_rows", referenced from:
      _main in sql_another-80b5eb.o
  "_mysql_query", referenced from:
      _main in sql_another-80b5eb.o
  "_mysql_real_connect", referenced from:
      _main in sql_another-80b5eb.o
  "_mysql_store_result", referenced from:
      _main in sql_another-80b5eb.o
   ld: symbol(s) not found for architecture arm64
   clang: error: linker command failed with exit code 1 (use -v to see invocation)

Or maybe MySQL connector for c++ is not available on M1 MacBooks?
Help me, please)))

A: Yes, you are right. No  MySQL connector for c++ for M1 yet.

A: I hope you've found a solution in the meantime, otherwise here's one that could work.
I'm using a Macbook Air M1, MacOs 12.2 Monterey, MySQL installed via Homebrew (brew install mysql).
Openssl installed via homebrew too.
To compile I use:
gcc -o filename.out filename.c `mysql_config --libs`
Please take note of the backtick used in the last command
The first time I used this command, ld came out with other libaries not found (zstd, ssl, and so on): just add the correct path to LIBRARY_PATH via this command scheme:
export LIBRARY_PATH=$LIBRARY_PATH:$(brew --prefix NAME_OF_LIBRARY)/lib/
For example, if the missing library is lssl, the NAME_OF_LIBRARY will be ssl, or if the error is for lzstd, the NAME_OF_LIBRARY will be zstd


text:
Q: What is the namespace i need to use to declare a particular class?  The class is the following:
public __gc class test :public MarshalByValueComponent,IListSource,ISupportInitialize,ISerializable

A: The namespace is System.ComponentModel


text:
Q: DynamoDB PHP Return Value I am studying how to write php code of DynamoDB now.
I have encounter some problems.
1) How can I know when connect to db fail
$aws = Aws::factory('config.php');
$client = $aws->get('DynamoDb');

Return client is a object, but i don't know how to check connect success or fail in my php code.
2) Same question when i try to putItem, updateItem and deleteItem
$result = $client->putItem(array(
        ...
    ));

I read the AWS SDK of PHP document, but I can't find solution.
These function return value is a array(?) and no attribute is mean success or fail.
Only queryItem() can check by 'Count' attribute.
How should I do in my php code to check these ?
Thanks in advance.

A: Regarding #1, the "connection" should not be treated the same way as a connection to a MySQL database. Requests to DynamoDB are made over HTTP(S), and this does not require that you establish an upfront connection. When you create the client object, you are not making a connection to DynamoDB, you are just configuring an HTTP client that will make requests to DynamoDB.
Regarding #2, I think you should read the SDK's Getting Started Guide, especially the sections on Working with modeled responses and Detecting and handling errors. Basically, if a request succeeds you get a Guzzle\Service\Resource\Model object, which behaves like an array (i.e., implements PHP's ArrayAccess and Traversable interfaces). If the request fails, an exception is thrown. For DynamoDB, that exception will be Aws\DynamoDb\Exception\DynamoDbException.
try {
    $result = $client->putItem(array(
        'Table' => 'my-table',
        // ...
    ));
} catch (DynamoDbException $e) {
    // The PutItem operation failed.
    echo $e->getMessage();
}


text:
Q: Dropwizard/Jetty REST calls returning http status 202 under moderate-to-light load I'm running into an issue with a rest service built on dropwizard 0.7.1.3, which I believe has Jetty 0.9.7.1.v20131107 embedded.
The service has various REST endpoints setup, where some are used to submit a background task, some are used for checking status of said job, and lastly, some are used to retrieve the results of the job when it is completed. To be clear... none of these endpoints are explicitly returning 202.
I'm currently doing some load testing of the application where it is simulating multiple users hitting the service simultaneously in order to submit jobs, check their status and retrieve results. For a simulation of about 30 users ramped up over 30 seconds, there are about 3500 request submitted to the service over the course of a couple minutes. The average rate is about 16/second. During this time, I see the occasional return of 202 http status code from some of the endpoints. If I increase the number of users, the frequency of 202s increases as well.
During profiling of the application while load testing, the CPU and heap space available both seem to stay within reasonable bounds. The same goes for garbage collection. Also, the number of threads in use is much lower than the maximum set for the service which is about 1024... I see maybe 175 allocated.
I'm at a point now where I can't seem to figure out what is causing these 202s. I've tried increasing acceptor threads, selector threads, etc settings in drop wizard config but they don't help to alleviate the problem.
I've tried googling for information on what circumstances cause Jetty to return a 202 but I can't find any useful information on this either.
Has anyone experienced an issue such as this before? Can anyone tell me under what circumstances Jetty will decide to return a 202 versus actually process the request? and what I might be able to change in order to alleviate the problem?
It just doesn't make sense to me that an average rate of 16 requests/second would be enough to warrant returning 202. If there is any additional information that might help to diagnose this, please let me know.

A: Note: this question is too unclear and I will flag it. But my comment doesn't fit the requirement for size.
If you are absolutely sure that Jetty is to blame you could check for some weird configuration of Jetty QoS or DoS filters. Their default return codes are HTTP 503 Service unavailable but the return code is configurable.
IMO the return of HTTP 202 status codes seems to be an intended behaviour from the application.
The official registry of HTTP status codes at IANA states:

202  Accepted RFC7231, Section
6.3.3
The 202 response is intentionally noncommittal.  Its purpose is to
allow a server to accept a request for some other process (perhaps a
batch-oriented process that is only run once per day) without
requiring that the user agent's connection to the server persist until
the process is completed.  The representation sent with this response
ought to describe the request's current status and point to (or embed)
a status monitor that can provide the user with an estimate of when
the request will be fulfilled.

As a batch-oriented process you can imagine for example the export of several GB of files to some web-server or S3-like object storage. The server accepted the request, instructed successfully the other systems that are involved in the process and tell you that the task is started. It can't provide the result immediately. When and where you can find the result is application dependent and have to be checked with it documentation.

A: In the end, we discovered that there actually was some code in an internal company library that was returning a 202 in a very specific case.


text:
Q: Link without edit balloon in ckeditor5 I used CKEditor5 with Reactjs,
I want to add the link without editing, I actually want to see the creation balloon once and it is at the time of creation
Then on clicking the link, without the 'editi balloon', to be directed to a specific target.
is that possible or I have to handle it with css and js code?

A: After a few days I was able to find a solution, I hope it is useful for someone else
I added contenteditable:'false' in attributes of the Link and my problem has solved
When the link is not editable, it is displayed without balloons
 <CKEditor
            disabled={!this.state.isOrganizer}
              editor={ClassicEditor}
              data={this.state.Message}
              config={{
                toolbar: ['heading', '|', 'bold', 'italic', 'blockQuote', 'link', 'numberedList', 'bulletedList', 'imageUpload', 'insertTable',
                  'tableColumn', 'tableRow', 'mergeTableCells', 'mediaEmbed', '|', 'undo', 'redo'],
                language: 'de',
                link: {
                  decorators: {
                      addTargetToExternalLinks: {
                          mode: 'automatic',
                          callback: url => /^(https?:)?\/\//.test( url ),
                          attributes: {
                              target: '_blank',
                              rel: 'noopener noreferrer',
                              contenteditable:'false' //<=========== solution***
                          }
                      }
                  }
                }
              }}
              onChange={(event, editor) => {
                const data = editor.getData();
                this.setState({
                  Message: data
                }, () => {

                })
              }}
            />


text:
Q: Eclipse Error: Cannot determine URI for /project-path/ I'm running Eclipse Luna on Ubuntu 12.0.4 in VirtualBox with a Windows 8 host and every once in a while, I will boot up Ubuntu and open up Eclipse to find this:

My projects should be listed in the package explorer but it's all empty and whenever I try to import the project again, it says no projects are found.
At this point, I usually go to my workspace folder and delete the .lock file and rebuild the workspace but is there an alternative to this? This error happens every ~5 times I reopen Eclipse and it has become very annoying. Any help will be appreciated!
EDIT: Okay I just tried deleting the .lock file in the .metadata folder in my workspace and I'm still getting the same error. Any suggestions?
EDIT 2: While closing my currently open tabs, I got this error. The projects that were open were Maven projects if that makes a difference.

A: so I am a little late for the party, but I fixed that on reimporting my projects.
Under File->Import.. you choose General->Import existing Projects into workspace. On the next page you set your workspace directory as the root directory for importing, which will give you a warning like "Some projects already exist in workspace". Ignore this and click finish.
After that all my projects where back in my workspace.
Good luck

A: To solve this problem, I re-created my workspace and imported my projects again.
Creating a new workspace is done via:
File > Switch Workspace

This is not an optimal solution, but until Eclipse fixes these bugs, this can save you some time trying to debug your current workspace.
I previously had a very small number of Eclipse plugins installed. So, I quickly headed to the Marketplace and installed my plugins.
And yes, Eclipse's downfall is expected. I personally find IntelliJ IDEs much better.


text:
Q: Which of the following sums is a closer approximate to $e^{-5}$? Here are two sums given:

*

*$$e^{-5}\approx \sum_{i=0}^9 \frac{(-1)^i 5^i}{i!}$$

*$$e^{-5}=1/e^5\approx \frac{1}{\sum_{i=0}^9 \frac{5^i}{i!}}$$

Using Matlab ;) I've got (2) to be closer. But computer-aside, is there anyway to say which one is closer than the other, say by thinking about the errors?

A: The approximation
$$
e^x\approx\sum_{i=0}^{n-1}\frac{x^i}{i!}
$$
will have error term $\approx x^n/n!$ when $n\gg x$ since at this stage the terms are getting closer to zero. Thus, for $e^x$ and $e^{-x}$, the error term is the same order of magnitude. However, for $x>0$, the error term relative to the value is larger for $e^{-x}$, which is what matters when we estimate $e^{-x}$ using $1/e^x$.
Thus, for $x>0$, it is better to approximate $e^{-x}$ as $1/e^x$.

A: The proportionate error is related to the value of the sum so far. The absolute value of the terms here is the same, but in the first case the sign alternates and the terms cancel (at least a bit) so each new term is greater in proportion to the sum than in the second case where there is no cancellation.


text: Q: "-- more --" is disabled when I use :g/pattern I used to analyze logs with vim and I always use the command :g/pattern to filter what I want. But in some OS versions this command doesn't work like the "more" or "less" commands. All output is shown in a straight way. I'd like to set vim editor to stop the output and show one page at a time. Is there a setting option for that?


text:
Q: How to write machine language commands directly to ELF executable I'm currently using NASM to take some assembly code commands, make a .o file, and then using ld to link it to an ELF executable. My assembly file ok.asm:
section .text
   global _start     ;must be declared for linker (ld)

_start:             ;tells linker entry point
   mov  edx,len     ;message length
   mov  ecx,msg     ;message to write
   mov  ebx,1       ;file descriptor (stdout)
   mov  eax,4       ;system call number (sys_write)
   int  0x80        ;call kernel

   mov  eax,1       ;system call number (sys_exit)
   int  0x80        ;call kernel

section .data
msg db 'Hello, world!', 0xa  ;string to be printed
len equ $ - msg     ;length of the string

Then nasm -f elf ok.asm which generates ok.o
Then ld -m elf_1386 -s -o yo ok.o to generate the finished product.
The problem is that I want to be able to test out pure machine language (not necessarily assembly) without any dependencies to build and link it, like NASM and LD. All I have available is the ability to write (/generate) pure bytes into a file, so I would like to take the machine language pure commands (I can take care of that part) and write it to an executable .ELF format (the part I need help with).
If I object dump it I can get some idea of the architecture.
First objdump -x ./yo (to get the header info):
x ./yo

./yo:     file format elf32-i386
./yo
architecture: i386, flags 0x00000102:
EXEC_P, D_PAGED
start address 0x08048080

Program Header:
    LOAD off    0x00000000 vaddr 0x08048000 paddr 0x08048000 align 2**12
         filesz 0x0000009d memsz 0x0000009d flags r-x
    LOAD off    0x000000a0 vaddr 0x080490a0 paddr 0x080490a0 align 2**12
         filesz 0x0000000e memsz 0x0000000e flags rw-

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         0000001d  08048080  08048080  00000080  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         0000000e  080490a0  080490a0  000000a0  2**2
                  CONTENTS, ALLOC, LOAD, DATA
SYMBOL TABLE:
no symbols

Now objdump -s ./yo to get the contents:
s yo

yo:     file format elf32-i386

Contents of section .text:
 8048080 ba0e0000 00b9a090 0408bb01 000000b8  ................
 8048090 04000000 cd80b801 000000cd 80        .............
Contents of section .data:
 80490a0 48656c6c 6f2c2077 6f726c64 210a      Hello, world!.

Pretty sure that ".text" section contains the pure machine code bytes generated from the above commands (e.g., mov edx, len ;etc)
And when I read it byte-for-byte in JavaScript along with the string, I get this (360 lines, one line for each byte, first line number, then byte in base 2, then charCode, then actual char):
000: 01111111, 127: \u007f
001: 01000101, 069: E
002: 01001100, 076: L
003: 01000110, 070: F
004: 00000001, 001: \u0001
005: 00000001, 001: \u0001
006: 00000001, 001: \u0001
007: 00000000, 000: \u0000
008: 00000000, 000: \u0000
009: 00000000, 000: \u0000
010: 00000000, 000: \u0000
011: 00000000, 000: \u0000
012: 00000000, 000: \u0000
013: 00000000, 000: \u0000
014: 00000000, 000: \u0000
015: 00000000, 000: \u0000
016: 00000010, 002: \u0002
017: 00000000, 000: \u0000
018: 00000011, 003: \u0003
019: 00000000, 000: \u0000
020: 00000001, 001: \u0001
021: 00000000, 000: \u0000
022: 00000000, 000: \u0000
023: 00000000, 000: \u0000
024: 10000000, 128: \u0080
025: 10000000, 128: \u0080
026: 00000100, 004: \u0004
027: 00001000, 008: \u0008
028: 00110100, 052: 4
029: 00000000, 000: \u0000
030: 00000000, 000: \u0000
031: 00000000, 000: \u0000
032: 11001000, 200: È
033: 00000000, 000: \u0000
034: 00000000, 000: \u0000
035: 00000000, 000: \u0000
036: 00000000, 000: \u0000
037: 00000000, 000: \u0000
038: 00000000, 000: \u0000
039: 00000000, 000: \u0000
040: 00110100, 052: 4
041: 00000000, 000: \u0000
042: 00100000, 032:
043: 00000000, 000: \u0000
044: 00000010, 002: \u0002
045: 00000000, 000: \u0000
046: 00101000, 040: (
047: 00000000, 000: \u0000
048: 00000100, 004: \u0004
049: 00000000, 000: \u0000
050: 00000011, 003: \u0003
051: 00000000, 000: \u0000
052: 00000001, 001: \u0001
053: 00000000, 000: \u0000
054: 00000000, 000: \u0000
055: 00000000, 000: \u0000
056: 00000000, 000: \u0000
057: 00000000, 000: \u0000
058: 00000000, 000: \u0000
059: 00000000, 000: \u0000
060: 00000000, 000: \u0000
061: 10000000, 128: \u0080
062: 00000100, 004: \u0004
063: 00001000, 008: \u0008
064: 00000000, 000: \u0000
065: 10000000, 128: \u0080
066: 00000100, 004: \u0004
067: 00001000, 008: \u0008
068: 10011101, 157: \u009d
069: 00000000, 000: \u0000
070: 00000000, 000: \u0000
071: 00000000, 000: \u0000
072: 10011101, 157: \u009d
073: 00000000, 000: \u0000
074: 00000000, 000: \u0000
075: 00000000, 000: \u0000
076: 00000101, 005: \u0005
077: 00000000, 000: \u0000
078: 00000000, 000: \u0000
079: 00000000, 000: \u0000
080: 00000000, 000: \u0000
081: 00010000, 016: \u0010
082: 00000000, 000: \u0000
083: 00000000, 000: \u0000
084: 00000001, 001: \u0001
085: 00000000, 000: \u0000
086: 00000000, 000: \u0000
087: 00000000, 000: \u0000
088: 10100000, 160:
089: 00000000, 000: \u0000
090: 00000000, 000: \u0000
091: 00000000, 000: \u0000
092: 10100000, 160:
093: 10010000, 144: \u0090
094: 00000100, 004: \u0004
095: 00001000, 008: \u0008
096: 10100000, 160:
097: 10010000, 144: \u0090
098: 00000100, 004: \u0004
099: 00001000, 008: \u0008
100: 00001110, 014: \u000e
101: 00000000, 000: \u0000
102: 00000000, 000: \u0000
103: 00000000, 000: \u0000
104: 00001110, 014: \u000e
105: 00000000, 000: \u0000
106: 00000000, 000: \u0000
107: 00000000, 000: \u0000
108: 00000110, 006: \u0006
109: 00000000, 000: \u0000
110: 00000000, 000: \u0000
111: 00000000, 000: \u0000
112: 00000000, 000: \u0000
113: 00010000, 016: \u0010
114: 00000000, 000: \u0000
115: 00000000, 000: \u0000
116: 00000000, 000: \u0000
117: 00000000, 000: \u0000
118: 00000000, 000: \u0000
119: 00000000, 000: \u0000
120: 00000000, 000: \u0000
121: 00000000, 000: \u0000
122: 00000000, 000: \u0000
123: 00000000, 000: \u0000
124: 00000000, 000: \u0000
125: 00000000, 000: \u0000
126: 00000000, 000: \u0000
127: 00000000, 000: \u0000
128: 10111010, 186: º
129: 00001110, 014: \u000e
130: 00000000, 000: \u0000
131: 00000000, 000: \u0000
132: 00000000, 000: \u0000
133: 10111001, 185: ¹
134: 10100000, 160:
135: 10010000, 144: \u0090
136: 00000100, 004: \u0004
137: 00001000, 008: \u0008
138: 10111011, 187: »
139: 00000001, 001: \u0001
140: 00000000, 000: \u0000
141: 00000000, 000: \u0000
142: 00000000, 000: \u0000
143: 10111000, 184: ¸
144: 00000100, 004: \u0004
145: 00000000, 000: \u0000
146: 00000000, 000: \u0000
147: 00000000, 000: \u0000
148: 11001101, 205: Í
149: 10000000, 128: \u0080
150: 10111000, 184: ¸
151: 00000001, 001: \u0001
152: 00000000, 000: \u0000
153: 00000000, 000: \u0000
154: 00000000, 000: \u0000
155: 11001101, 205: Í
156: 10000000, 128: \u0080
157: 00000000, 000: \u0000
158: 00000000, 000: \u0000
159: 00000000, 000: \u0000
160: 01001000, 072: H
161: 01100101, 101: e
162: 01101100, 108: l
163: 01101100, 108: l
164: 01101111, 111: o
165: 00101100, 044: ,
166: 00100000, 032:
167: 01110111, 119: w
168: 01101111, 111: o
169: 01110010, 114: r
170: 01101100, 108: l
171: 01100100, 100: d
172: 00100001, 033: !
173: 00001010, 010:
174: 00000000, 000: \u0000
175: 00101110, 046: .
176: 01110011, 115: s
177: 01101000, 104: h
178: 01110011, 115: s
179: 01110100, 116: t
180: 01110010, 114: r
181: 01110100, 116: t
182: 01100001, 097: a
183: 01100010, 098: b
184: 00000000, 000: \u0000
185: 00101110, 046: .
186: 01110100, 116: t
187: 01100101, 101: e
188: 01111000, 120: x
189: 01110100, 116: t
190: 00000000, 000: \u0000
191: 00101110, 046: .
192: 01100100, 100: d
193: 01100001, 097: a
194: 01110100, 116: t
195: 01100001, 097: a
196: 00000000, 000: \u0000
197: 00000000, 000: \u0000
198: 00000000, 000: \u0000
199: 00000000, 000: \u0000
200: 00000000, 000: \u0000
201: 00000000, 000: \u0000
202: 00000000, 000: \u0000
203: 00000000, 000: \u0000
204: 00000000, 000: \u0000
205: 00000000, 000: \u0000
206: 00000000, 000: \u0000
207: 00000000, 000: \u0000
208: 00000000, 000: \u0000
209: 00000000, 000: \u0000
210: 00000000, 000: \u0000
211: 00000000, 000: \u0000
212: 00000000, 000: \u0000
213: 00000000, 000: \u0000
214: 00000000, 000: \u0000
215: 00000000, 000: \u0000
216: 00000000, 000: \u0000
217: 00000000, 000: \u0000
218: 00000000, 000: \u0000
219: 00000000, 000: \u0000
220: 00000000, 000: \u0000
221: 00000000, 000: \u0000
222: 00000000, 000: \u0000
223: 00000000, 000: \u0000
224: 00000000, 000: \u0000
225: 00000000, 000: \u0000
226: 00000000, 000: \u0000
227: 00000000, 000: \u0000
228: 00000000, 000: \u0000
229: 00000000, 000: \u0000
230: 00000000, 000: \u0000
231: 00000000, 000: \u0000
232: 00000000, 000: \u0000
233: 00000000, 000: \u0000
234: 00000000, 000: \u0000
235: 00000000, 000: \u0000
236: 00000000, 000: \u0000
237: 00000000, 000: \u0000
238: 00000000, 000: \u0000
239: 00000000, 000: \u0000
240: 00001011, 011: \u000b
241: 00000000, 000: \u0000
242: 00000000, 000: \u0000
243: 00000000, 000: \u0000
244: 00000001, 001: \u0001
245: 00000000, 000: \u0000
246: 00000000, 000: \u0000
247: 00000000, 000: \u0000
248: 00000110, 006: \u0006
249: 00000000, 000: \u0000
250: 00000000, 000: \u0000
251: 00000000, 000: \u0000
252: 10000000, 128: \u0080
253: 10000000, 128: \u0080
254: 00000100, 004: \u0004
255: 00001000, 008: \u0008
256: 10000000, 128: \u0080
257: 00000000, 000: \u0000
258: 00000000, 000: \u0000
259: 00000000, 000: \u0000
260: 00011101, 029: \u001d
261: 00000000, 000: \u0000
262: 00000000, 000: \u0000
263: 00000000, 000: \u0000
264: 00000000, 000: \u0000
265: 00000000, 000: \u0000
266: 00000000, 000: \u0000
267: 00000000, 000: \u0000
268: 00000000, 000: \u0000
269: 00000000, 000: \u0000
270: 00000000, 000: \u0000
271: 00000000, 000: \u0000
272: 00010000, 016: \u0010
273: 00000000, 000: \u0000
274: 00000000, 000: \u0000
275: 00000000, 000: \u0000
276: 00000000, 000: \u0000
277: 00000000, 000: \u0000
278: 00000000, 000: \u0000
279: 00000000, 000: \u0000
280: 00010001, 017: \u0011
281: 00000000, 000: \u0000
282: 00000000, 000: \u0000
283: 00000000, 000: \u0000
284: 00000001, 001: \u0001
285: 00000000, 000: \u0000
286: 00000000, 000: \u0000
287: 00000000, 000: \u0000
288: 00000011, 003: \u0003
289: 00000000, 000: \u0000
290: 00000000, 000: \u0000
291: 00000000, 000: \u0000
292: 10100000, 160:
293: 10010000, 144: \u0090
294: 00000100, 004: \u0004
295: 00001000, 008: \u0008
296: 10100000, 160:
297: 00000000, 000: \u0000
298: 00000000, 000: \u0000
299: 00000000, 000: \u0000
300: 00001110, 014: \u000e
301: 00000000, 000: \u0000
302: 00000000, 000: \u0000
303: 00000000, 000: \u0000
304: 00000000, 000: \u0000
305: 00000000, 000: \u0000
306: 00000000, 000: \u0000
307: 00000000, 000: \u0000
308: 00000000, 000: \u0000
309: 00000000, 000: \u0000
310: 00000000, 000: \u0000
311: 00000000, 000: \u0000
312: 00000100, 004: \u0004
313: 00000000, 000: \u0000
314: 00000000, 000: \u0000
315: 00000000, 000: \u0000
316: 00000000, 000: \u0000
317: 00000000, 000: \u0000
318: 00000000, 000: \u0000
319: 00000000, 000: \u0000
320: 00000001, 001: \u0001
321: 00000000, 000: \u0000
322: 00000000, 000: \u0000
323: 00000000, 000: \u0000
324: 00000011, 003: \u0003
325: 00000000, 000: \u0000
326: 00000000, 000: \u0000
327: 00000000, 000: \u0000
328: 00000000, 000: \u0000
329: 00000000, 000: \u0000
330: 00000000, 000: \u0000
331: 00000000, 000: \u0000
332: 00000000, 000: \u0000
333: 00000000, 000: \u0000
334: 00000000, 000: \u0000
335: 00000000, 000: \u0000
336: 10101110, 174: ®
337: 00000000, 000: \u0000
338: 00000000, 000: \u0000
339: 00000000, 000: \u0000
340: 00010111, 023: \u0017
341: 00000000, 000: \u0000
342: 00000000, 000: \u0000
343: 00000000, 000: \u0000
344: 00000000, 000: \u0000
345: 00000000, 000: \u0000
346: 00000000, 000: \u0000
347: 00000000, 000: \u0000
348: 00000000, 000: \u0000
349: 00000000, 000: \u0000
350: 00000000, 000: \u0000
351: 00000000, 000: \u0000
352: 00000001, 001: \u0001
353: 00000000, 000: \u0000
354: 00000000, 000: \u0000
355: 00000000, 000: \u0000
356: 00000000, 000: \u0000
357: 00000000, 000: \u0000
358: 00000000, 000: \u0000
359: 00000000, 000: \u0000

Also a simple hexdump command yields the following:
    hexdump -C -n 360 ./yo
00000000  7f 45 4c 46 01 01 01 00  00 00 00 00 00 00 00 00  |.ELF............|
00000010  02 00 03 00 01 00 00 00  80 80 04 08 34 00 00 00  |............4...|
00000020  c8 00 00 00 00 00 00 00  34 00 20 00 02 00 28 00  |........4. ...(.|
00000030  04 00 03 00 01 00 00 00  00 00 00 00 00 80 04 08  |................|
00000040  00 80 04 08 9d 00 00 00  9d 00 00 00 05 00 00 00  |................|
00000050  00 10 00 00 01 00 00 00  a0 00 00 00 a0 90 04 08  |................|
00000060  a0 90 04 08 0e 00 00 00  0e 00 00 00 06 00 00 00  |................|
00000070  00 10 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000080  ba 0e 00 00 00 b9 a0 90  04 08 bb 01 00 00 00 b8  |................|
00000090  04 00 00 00 cd 80 b8 01  00 00 00 cd 80 00 00 00  |................|
000000a0  48 65 6c 6c 6f 2c 20 77  6f 72 6c 64 21 0a 00 2e  |Hello, world!...|
000000b0  73 68 73 74 72 74 61 62  00 2e 74 65 78 74 00 2e  |shstrtab..text..|
000000c0  64 61 74 61 00 00 00 00  00 00 00 00 00 00 00 00  |data............|
000000d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
000000f0  0b 00 00 00 01 00 00 00  06 00 00 00 80 80 04 08  |................|
00000100  80 00 00 00 1d 00 00 00  00 00 00 00 00 00 00 00  |................|
00000110  10 00 00 00 00 00 00 00  11 00 00 00 01 00 00 00  |................|
00000120  03 00 00 00 a0 90 04 08  a0 00 00 00 0e 00 00 00  |................|
00000130  00 00 00 00 00 00 00 00  04 00 00 00 00 00 00 00  |................|
00000140  01 00 00 00 03 00 00 00  00 00 00 00 00 00 00 00  |................|
00000150  ae 00 00 00 17 00 00 00  00 00 00 00 00 00 00 00  |................|
00000160  01 00 00 00 00 00 00 00                           |........|
00000168

I've also seen https://docs.oracle.com/cd/E19455-01/806-3773/6jct9o0bs/index.html
as well as this https://linux-audit.com/elf-binaries-on-linux-understanding-and-analysis/
which gives this useful picture diagram:

as well as a link to the elf header file.
The question:
How, exactly, can I simply "insert" the pure machine language list of commands directly into an ELF file format (perhaps using a template based on the above?) without using any external dependencies (like NASM, LD etc.), only a pure binary writer?
I tried simply changing the string "Hello, World!" to something longer, but (obviously) it got cut off, because the length was only set to a specific amount, but I don't know where to find the length attribute in the binary code, if someone could at least point to that, then that would be helpful


text:
Q: How are system calls called? So I understand what system calls are for and what they do. Pretty much anything that requires a computer's resources invokes a system call at some point. My question is, how does a user-created program in Python for example compile and know where to make system calls? If I write a "Hello World" program, does the compiler (interpreter in this case) know to associate the print() function in Python with a particular system call in its host operating system? Where in the process of writing a user program in a programming language and turning it into 1s and 0s do system calls come into play? Thanks.

A:
how does a user-created program in Python for example compile and know where to make system calls?

You can explore some of this yourself.
Given this Python program: print("Hello"), on a UNIX system one can guess that a write(2) system call will eventually be invoked. Let's see if that's true:
gdb -q --args python -c 'print("Hello")'

(gdb) catch syscall write
Catchpoint 1 (syscall 'write' [1])

(gdb) run
Starting program: /usr/bin/python -c print\(\"Hello\"\)
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Catchpoint 1 (call to syscall write), 0x00007ffff6f3cdd4 in __GI___libc_write (fd=1, buf=0x555555b2f9f0, nbytes=6) at ../sysdeps/unix/sysv/linux/write.c:26
26      ../sysdeps/unix/sysv/linux/write.c: No such file or directory.

(gdb) x/s $rsi
0x555555b2f9f0: "Hello\n"

(gdb) bt
#0  0x00007ffff6f3cdd4 in __GI___libc_write (fd=1, buf=0x555555b2f9f0, nbytes=6) at ../sysdeps/unix/sysv/linux/write.c:26
#1  0x00007ffff6ecdb9d in _IO_new_file_write (f=0x7ffff720d760 <_IO_2_1_stdout_>, data=0x555555b2f9f0, n=6) at fileops.c:1183
#2  0x00007ffff6eccf3f in new_do_write (fp=0x7ffff720d760 <_IO_2_1_stdout_>, data=0x555555b2f9f0 "Hello\n", to_do=to_do@entry=6) at libioP.h:839
#3  0x00007ffff6ecece9 in _IO_new_do_write (fp=<optimized out>, data=<optimized out>, to_do=6) at fileops.c:432
#4  0x00007ffff6ece26f in _IO_new_file_xsputn (f=0x7ffff720d760 <_IO_2_1_stdout_>, data=<optimized out>, n=1) at libioP.h:839
#5  0x00007ffff6ec2c3f in __GI__IO_fputs (str=0x55555580d74d "\n", fp=0x7ffff720d760 <_IO_2_1_stdout_>) at libioP.h:839
#6  0x00005555556966ac in PyFile_WriteString ()
#7  0x000055555564c42d in PyEval_EvalFrameEx ()
#8  0x000055555564610a in PyEval_EvalCodeEx ()
#9  0x0000555555645a29 in PyEval_EvalCode ()
#10 0x0000555555676c5f in ?? ()
#11 0x00005555556a4846 in PyRun_StringFlags ()
#12 0x00005555556a567c in PyRun_SimpleStringFlags ()
#13 0x000055555562005a in Py_Main ()
#14 0x00007ffff6e7652b in __libc_start_main (main=0x55555561fb30 <main>, argc=3, argv=0x7fffffffdc78, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>,
    stack_end=0x7fffffffdc68) at ../csu/libc-start.c:308
#15 0x000055555561fa4a in _start ()

What can you deduce from this?

*

*The write system call is indeed invoked, with expected characters in the $RSI register (which happens to be where the second argument to system calls must be for this particular platform).

*The system call is invoked from __GI___libc_write routine, which is a system call wrapper provided by libc.

*Python did not call __libc_write directly. It called __GI__IO_fputs (which is actually an alias for fputs.

*The Python interpreter translated the print into a call to PyFile_WriteString, and that function delegated the actual work to libc.

This is not at all unusual -- in fact most user-level programs do not execute system calls directly. Instead, they call libc routines, such as write or fputs, and let the libc worry how to implement these routines in terms of system calls.
By doing so, they can abstract the details of the particular machine and OS; they expect to find some libc on any machine, and only libc developers have to worry about actual system call details.


text:
Q: conan C++ ERROR: Unable to find Package in remotes I'm new to Conan. I tried to create a package and upload into remote (myconan-test). The package is in local cache and in remote.
Package in local
[user@dev build]$ conan search MyLib*
Existing package recipes:

MyLib/0.1@myself/Testing

Upload package to remote
[user@dev build]$ conan upload MyLib/0.1@myself/testing -r=myconan-test
Uploading to remote 'myconan-test':
Uploading MyLib/0.1@myself/testing to remote 'myconan-test'
Compressing conan_sources.tgz completed [3 files]
Uploading conanmanifest.txt completed [0.24k]
Uploaded conan recipe 'MyLib/0.1@myself/testing' to 'myconan-test': http://xxx.xx.xx.xx:8081/artifactory/api/conan/conan-local

Now package is in remote
[user@dev build]$ conan search MyLib* -r=myconan-test
Existing package recipes:

MyLib/0.1@myself/testing

I created a consumer project that uses MyLib/0.1. But when I did: conan install .. I had an error like:
MyLib/0.1: Not found in local cache, looking in remotes...
MyLib/0.1: Trying with 'conan-center'...
MyLib/0.1: Trying with 'myconan-test'...
ERROR: Unable to find 'MyLib/0.1' in remotes

My conanfile.txt is
[requires]
MyLib/0.1

[generators]
gcc
cmake
txt

[imports]
bin, *.a -> ./bin # Copies all dll files from the package "bin" folder to my project "bin" folder

If I change the require to: MyLib/0.1@myself/testing. It works because it uses the package in cache. My question is how I can use the remote package.
What is my error?
Thank you in advance.
EDIT---
After understanding how to call my package by adding MyLib/0.1@myself/testing. I can download the package from remote. But in the building step, I have an error:
[user@dev build]$ conan build ..
Using lockfile: '/home/user/Projects/consumer_MyLib/build/conan.lock'
Using cached profile from lockfile
conanfile.py: Running build()
-- Conan: called by CMake conan helper
-- Conan: Adjusting output directories
-- Conan: Using cmake global configuration
-- Conan: Adjusting default RPATHs Conan policies
-- Conan: Adjusting language standard
-- Conan: Checking correct version: 4.8
-- Conan: C++ stdlib: libstdc++
**CMake Error at CMakeLists.txt:23 (target_link_libraries):
  Cannot specify link libraries for target "MyLib" which is not built by this
  project.**

CMakeLists.txt
cmake_minimum_required(VERSION 2.8.12)
project(consumer_MyLib CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

add_executable(${project_name} example.cpp)
target_link_libraries(${project_name}  ${CONAN_LIBS})

A: The package reference in conanfile.txt is declared using its name, version, user and channel. Both user and channel are used as a namespace and they are important to the package reference. Besides that, Conan also supports package names without a namespace, thus we can have:
zlib/1.2.11
zlib/1.2.11@acme/stable
zlib/1.2.11@acme/testing

Here we have 3 packages, both are related to zlib/1.2.11, but they are different packages. The first doesn't have a namespace, however it's a valid package name and it's owned by Conan Center Index. The other 2 packages are provided by acme, but have different channels. Conan see each package reference as unique, so if you refer zlib/1.2.11 in your conanfile.txt it will look for the first package only.
Now backing to your situation, you created the package MyLib/0.1@myself/Testing, and Conan search command returned it when using the regex, which is plausible because is a search command. However, when referring the package in your conanfile.txt, you have to use the complete reference which follows your package:
# conanfile.txt

[requires]
MyLib/0.1@myself/Testing

...

If you look for MyLib/0.1 only, Conan will take it as a valid reference, and won't complete with your reference. There is no implicit deduction.

A: You are missing the @user/channel part in your requires:
[requires]
MyLib/0.1@myself/testing

When you are uploading the packages, you probably want to add --all to make sure you upload the binary too:
conan upload MyLib/0.1@myself/testing -r=myconan-test --all

Check the upload command in the docs.
If you want to make sure that your cache doesn't have the package, do a conan remove "*" -f


text:
Q: Should one use the Application or HomeController in Scala Play? When activator new is run a controllers folder is created containing:

*

*AsyncController

*CountController

*HomeController

Various Scala Play examples contain an Application.scala.
Is the HomeController.scala the successor of the Application.scala?

A: Short answer: Yes, it was changed in the few last releases.
Long Answer: https://github.com/playframework/playframework/pull/5721

Purpose
Changes instances of Application to HomeController and uses class
  HomeController instead of object HomeController to make the code more
  DI aware.
Background Context
The new Play templates use HomeController as a name instead of
  controllers.Application to avoid confusion with play.api.Application.
  Since 2.5.x uses InjectedRoutesGenerator by default, use of object
  Application should be a deprecated usage and there are multiple bugs
  based on outdated docs.


text:
Q: What determines the direction of cross product resultant vector? Why do we use the right hand rule to determine the direction of the vector resulting from using the cross product? A resultant vector that was directed in the opposite direction would also be perpendicular to both vectors...
EDIT: If we cross a x b, using the right hand rule we use point our index finger in direction of a, the middle finger in direction of b, and we use the thumb to get the direction of c. From a mathematical point of view, why can't c point in the opposite direction to the thumb?

A: We have to pick one way to do it - either the right hand rule or the left hand rule. It's not important which one we use, as long as everyone uses the same one - just like which side of the road we drive on. We'd get the same eventual results if we all used the left hand rule. Someone chose the right hand rule over the left hand rule, and it became convention, so that's what we use.

A: It is the way the cross product and the convention of the coordinate system is defined.
https://en.wikipedia.org/wiki/Right-hand_rule#Coordinates


text:
Q: Delete redundant timestamp ranges in Postgres SQL I have a table which is having filenames and a number of timestamp ranges for each file for eg as below:
       filename           mindatetime                 maxdatetime
    monitor_4.dat   2019-04-28 09:00:00 AM      2019-04-29 11:00:00 AM
    monitor_4.dat   2019-04-28 11:00:00 AM      2019-04-29 18:00:00 PM
    monitor_4.dat   2019-04-28 09:30:00 AM      2019-04-29 23:00:00 PM
    monitor_5.dat   2019-04-28 07:00:00 AM      2019-04-28 10:00:00 AM
    monitor_5.dat   2019-04-28 02:00:00 PM      2019-04-28 06:00:00 PM
    monitor_5.dat   2019-04-28 09:00:00 AM      2019-04-28 03:00:00 PM
    monitor_7.dat   2019-04-21 03:06:26.0 AM    2019-05-21 03:06:10.0 AM
    monitor_7.dat   2019-05-21 03:06:10.001 AM  2019-05-24 03:06:11.0 AM
    monitor_7.dat   2019-06-05 03:06:18.001 AM  2019-06-06 03:06:11.0 AM
    monitor_7.dat   2019-05-24 03:06:11.001 AM  2019-06-05 03:06:18.0 AM
    monitor_7.dat   2019-05-12 07:00:10.001 AM  2019-05-13 10:00:10.000 AM
    monitor_7.dat   2019-05-15 09:30:10.001 AM  2019-05-18 11:30:10.000 AM

I have a requirement to remove the redundant timestamp ranges ie> the ones which fall under a given timestamp range.
In this case for the file "monitor_5.dat" we need the mindatetime as 7AM and maxdatetime as 6PM as they form the logical min and max timestamp ranges which would cover the other entries.
So my resultant output should look like:
   filename           mindatetime                 maxdatetime
monitor_4.dat   2019-04-28 09:00:00 AM      2019-04-29 23:00:00 PM
monitor_5.dat   2019-04-28 07:00:00 AM      2019-04-28 06:00:00 PM
monitor_7.dat   2019-04-21 03:06:26.0 AM    2019-06-05 03:06:18.0 AM
monitor_7.dat   2019-05-12 07:00:10.001 AM  2019-05-13 10:00:10.000 AM
monitor_7.dat   2019-05-15 09:30:10.001 AM  2019-05-18 11:30:10.000 AM

This needs to be achieved through SQL only. Any suggestions would be helpful. I have already explored the "tsrange" function provided in Postgres but that is not helping me completely.

A: This answer is for PostgreSQL only; did you tag MySQL deliberately?
You'd have to join the table with itself and delete the entries contained in other entries:
DELETE FROM mytable AS a
USING mytable AS b
WHERE a.filename = b.filename
  AND tsrange(a.mindatetime, a.maxdatetime) <@ tsrange(b.mindatetime, b.maxdatetime)
  AND (a.ctid, a.xmin::text) <> (b.ctid, b.xmin::text);

The last condition prevents that a row is compared to itself.

A: This is a form of gaps-and-islands problem.  I would recommend finding where the "overlaps" occur and then using a cumulative sum to identify the groups.  A cumulative max() works for this:
select filename, min(mindatetime) as mindatetime,
       max(maxdatetime) as maxdatetime
from (select t.*,
             sum(case when prev_maxdatetime >= mindatetime then 0 else 1 end) over
                 (partition by filename order by mindatetime) as grp
      from (select t.*,
                   max(maxdatetime) over
                       (partition by filename
                        order by mindatetime
                        rows between unbounded preceding and 1 preceding
                       ) as prev_maxdatetime
            from t
           ) t
     ) t
group by filename, grp;

The innermost subquery determines where a non-overlapping time range starts.  The middle query then does a cumulative sum of these "starts" to assign a grouping identifier to each group.  The outer query then aggregates by this group (and the filename).
You can run the inner queries and see what values they produce.
Here is a db<>fiddle.  As far as I'm concerned, this is working correctly according to the question that you have asked here.  If you have a time lag where you want to consider the values the same/overlapping, then ask a new question with a clear explanation of your logic.
EDIT:
If you want a single record per filename, then just use aggregation:
select filename, min(mindatetime) as mindatetime,
       max(maxdatetime) as maxdatetime
from t
group by filename;

The first version combines rows that have no gaps between them.  This just takes the earliest and latest date/times.


text:
Q: Is there a way to pass a sequential value for a varargs function? If you call a vararg function with a list you get a list of the list, which makes perfect sense.
(defn foo
  [& bar])

(foo 1 2 3) ;; bar = (1 2 3)
(foo '(1 2 3)) ;; bar = ((1 2 3))

Other than a macro to splice the list into the foo form, is there a way to call foo with '(1 2 3) such that bar is (1 2 3)?
For example, you can call varargs with an array or varargs:
class Foo
{
    public static void main (String[] args)
    {
        varargs(1, 2, 3);
        int[] varargs = new int[]{3, 4, 5};
        varargs(varargs);
    }

    public static void varargs(int... varargs) {
        System.out.println(java.util.Arrays.toString(varargs));
    }
}

A: this is what apply does:
user> (defn foo [ & stuff]
        (println (reverse stuff)))
#'user/foo
user> (apply foo [1 2 3])
(3 2 1)


text:
Q: Book of calculus Sometimes I want to test the concepts of calculus in practice, but the most popular books like Thomas/Maurice is   a  little approach to me.Does someone know a book that works with calculus in practice (more than Pearson's books, contextualized problems...)

A: I second the physics text idea. Although any calculus based text should work, I especially like "Fundamentals of Physics" by Halliday, Resnick, and Walker. While I'm sure there are other even better texts out there, this one is a great introductory text with plenty of interesting exercises. Gauss's Law and electric fields come to mind.


text:
Q: poblem with use the npm start in nodejs . 'nodemon' is not recognized as an internal or external command, operable program or batch file i create a project in ubuntu and i run and deploy that   , its worked fine .
now i change the operation system and a use the windows 10 and when i run this code npm start in vscode it show me this error :
> Store@1.0.0 start F:\Projects\Nodejs\Store
> nodemon server.js

'nodemon' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Store@1.0.0 start: `nodemon server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Store@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\programmer\AppData\Roaming\npm-cache\_logs\2020-06-27T11_34_26_614Z-debug.log

i install the nodemon :
    {
  "name": "Store",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "start": "nodemon server.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "nodemon": "^2.0.4"
  }
}

and download and install the nodejs in windows .
whats the problem ? how can i solve this problem ??

A: i solve the problem . i delete all node_module and install that again with npm install command .


text:
Q: error while downloading file in PHP while downloading file im getting this error. specially pdf files.
and also program like download manger doesn't work on the downloading.
v?—x¢b(°®ه– çzٍڈà÷µï½zTَکêùQïىxùSَ–jîآ·×Yï¹oف5KK÷¾oصتمح+¾¦œ:و†ƒloوnأ"گ ±Oّ•زـ¦§w8^uLٹé†-ئûpfچâ+أجشƒœر د؛-ںe•ؤ…¬RH¦ hْDyے#½=@'X'§¾ذXœtz"†رص0âLوٍ›"ء²{÷ڈے ½}f؛ِâB¦کژ¯"كگyeطPeüpy,¥¼تِŒً•MR±wگCي¢âٹ'¬}Fzى3¢e¾NAو^4è¬{j=¤ر³جسâل<¶–5Mz&@+MYN1ُ¨Cںq)زêذش£M nj]T‡à*×h0ï3D¤6غإQ.µg¬€ء¥w«ي|م+s"çكûmٍاe¯Œغ½وؤ~لà…½ں$/‡ھ(!·@‡]µظtحîز4»CQeں[°ظ5گ+è'ہù4›MQd™@ں|‡فژd؟×ë×F*xز' ¹'پ÷i·?ù×ـسخ½Mأ}ق¸َOe$ِ à'ظgءl"ƒ=fRن(rإهـPy¨2ش2ج:طQî49œt رA3kfفذ'){¯'7ذE=»نx¾ةLb|'شاـ×s ل‡ةأجô‰—ثSùy¦y†uھc>ا/'›Zç9Vٍ·بش&¸ةq"s؟Yعlzگïگ_v¼ئ؟!؟د h=لّ'ےJتْ…£ںبb÷U;Lآڑ›eڑƒ¨}كFپ ں›Uنvi>"]¤vçW†•Bڑˆˆ´!ج=¥4†é1حز ہحٹ'é?"ل¢qع¬ ض4‹فلtڑgؤbوT§ةŒEچ8"س©#ôںآ‹EW9—ھr '8ژ§¦z$»±¸SW •¨xضث؛i›©سؤ™:pا¾YهسaکؤvC«صژkœچ "ژr\îW"Tùؤ'œ¥<غàû<§«،«ئ¶ —ًيFل¥رکً³ظ(WVتG{i®> stream xœه]ëڈeإqXXVثs1ث'¹ ;†¹ôûAâDٹEت7[Hùùd'N"ضر'ے_JUWَُô¹sg¦w±#ygخمVWuWWW?~Oâ(صAàüةف¯çüك»éد‡ےxWë®4ٌ£;Hkز؟ے_ؤƒSر~ü÷»ےQpئ¨C0؛{,=ƒ=َù‰ég"qً?™ïH،l{[:گJ›Uي¢؛ٍص,أوm)¤>ٌ6ف‍ے°R:^ùêî[ثٹ3¢¾m…ƒضŒ‡ إVeززF{{0BMˆڑں°îùخVيئ[ّ هYPüG6Eàغn{[£´Rآدù•د¥·ءىفس¾¸÷‹~÷=ِ/
here is my php code for downloading
<?php

$company =$_GET['company'];

// Make sure an ID was passed
if(isset($_GET['id'])) {
// Get the ID
$id = intval($_GET['id']);

// Make sure the ID is in fact a valid ID
if($id <= 0) {
    die('The ID is invalid!');
}
else {
    // Connect to the database
    $dbLink = new mysqli('localhost', 'sqldata', 'sqldata', 'balhaf');
    if(mysqli_connect_errno()) {
        die("MySQL connection failed: ". mysqli_connect_error());
    }

    // Fetch the file information
    $query = "
        SELECT mime, name, size, data
        FROM $company
        WHERE id = $id";
    $result = $dbLink->query($query);

    if($result) {
        // Make sure the result is valid
        if($result->num_rows == 1) {
        // Get the row
            $row = mysqli_fetch_assoc($result);

            // Print headers
            header("Content-Type: ". $row['mime']);
            header("Content-Length: ". $row['size']);
            header("Content-Disposition: attachment; filename=". $row['name']);

            // Print data
            echo $row['data'];
        }
        else {
            echo 'Error! No image exists with that ID.';
        }

        // Free the mysqli resources
        @mysqli_free_result($result);
        }
        else {
        echo "Error! Query failed: <pre>{$dbLink->error}</pre>";
        }
        @mysqli_close($dbLink);
        }
        }
        else {
        echo 'Error! No ID was passed.';
        }
        ?>

A: use BLOB in MySQL to prevent that the data is changed due to the encoding (there might be encoding issues which produce your errors, saving as BLOB is binary safe)
related to Binary Data in MySQL
it may be better to store a link as file reference in the database instead of saving the actual content of the file and retrieve the files using file_get_contents and other related functions to get the mimetype (or finfo) ...
take a look at Trying to download Blob via PHP / MySQL and http://www.sitepoint.com/forums/showthread.php?693871-Problem-using-PHP-to-pull-binary-files-from-a-BLOB-field-in-MYSQL

A: Try flushing the output buffer immediately before you start setting headers with ob_end_clean, and then exiting immediately after the echo. Take a look at the section of the PHP book on Output Control.
The other possibility is that you are running out of memory when attempting to echo the data, and the error is getting obfuscated by all the preceding binary. Try splitting the binary in to smaller chunks (substr is binary safe), iterating over them and returning them to the output buffer.


text:
Q: pthread_create segmentation fault I'm using the method 'pthread_create' in my program, and get a segmentation fault INSIDE THIS METHOD.
 What can possibly cause this? I'm calling this function with the correct arguments' types!
this is the code:
pthread_t* _daemon;

void* writer(void* arg){
    // stuff that dont involve "arg"...
}

int initdevice(){
    if(pthread_create(_daemon, NULL, &writer, NULL) != 0) //seg in this line
    {

      cerr << "system error\n";
      return ERR_CODE;
    }
    return SUCCESS;
}

int main () {
    initdevice();
    return 0;
}

Note: I've tried to run it also without the '&' before the calling to writer in pthread_create, and also - we've tried sending to this method some void* argument instead of the last NULL argument.

A: Your probelem is here:
pthread_t* _daemon;

This should be:
pthread_t  daemon;

Then change the call to pthread_create:
if(pthread_create(&daemon, NULL, &writer, NULL) != 0)

The idea is that pthread_create takes a pointer to an existing pthread_t object so that it can fill in the details. You can think of it as the C version of a constructor. Initially the pthread_t object is uninitialized this initializes it.
In addition your code is still probably not going to always work as you do not wait for the thread to finish. Make sure your main thread does not finish before all the children:
int main ()
{
    initdevice();
    pthread_join(daemon, NULL); // wait for the thread to exit first.
    return 0;
}

A: you must allocate _daemon variable with new or malloc function, because you have use of a pointer. like bellow :
pthread_t* _daemon;
_daemon = new pthread_t;


text:
Q: Access value of array object NodeJS I think I'm going crazy... I'm just trying to do some basic API learning for NodeJS and I've got this, which works fine and prints "United States Dollar" to console...
app.get("/", function(req, res){

  const url = "https://api.coindesk.com/v1/bpi/currentprice.json"
  https.get(url, function(response){
    console.log(response.statusCode);

    response.on("data", function(data){
      const priceData = JSON.parse(data);
      console.log(priceData.bpi.USD.description);
    })
  })

but when I'm trying to access it by using the array position of USD (which is [0])like this...
app.get("/", function(req, res){

  const url = "https://api.coindesk.com/v1/bpi/currentprice.json"
  https.get(url, function(response){
    console.log(response.statusCode);

    response.on("data", function(data){
      const priceData = JSON.parse(data);
      console.log(priceData.bpi[0].description);
    })
  })

I get a crash of ...
TypeError: Cannot read property 'description' of undefined

The JSON is
{
  "time": {
    "updated": "Oct 21, 2021 16:10:00 UTC",
    "updatedISO": "2021-10-21T16:10:00+00:00",
    "updateduk": "Oct 21, 2021 at 17:10 BST"
  },
  "disclaimer": "This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org",
  "chartName": "Bitcoin",
  "bpi": {
    "USD": {
      "code": "USD",
      "symbol": "$",
      "rate": "63,222.0050",
      "description": "United States Dollar",
      "rate_float": 63222.005
    },
    "GBP": {
      "code": "GBP",
      "symbol": "£",
      "rate": "45,779.4964",
      "description": "British Pound Sterling",
      "rate_float": 45779.4964
    },
    "EUR": {
      "code": "EUR",
      "symbol": "€",
      "rate": "54,306.7540",
      "description": "Euro",
      "rate_float": 54306.754
    }
  }
}

The USD object is position[0] of the bpi array (right?) so why can't I just tap into it like above? This example seems pretty similar to mine so can't see where I'm going wrong?

A: The problem is the content of priceData.bpi is not an array [], it's an object {}, so you can't access USD by position, the only way to access it is priceData.bpi.USD.
More about JS arrays, objects.

However, if you really need to access it by position, you can convert the contents of priceData.bpi into an array using the Object.entries() method.
Example

let priceData = {"time":{"updated":"Oct 21, 2021 16:39:00 UTC","updatedISO":"2021-10-21T16:39:00+00:00","updateduk":"Oct 21, 2021 at 17:39 BST"},"disclaimer":"This data was produced from the CoinDesk Bitcoin Price Index (USD). Non-USD currency data converted using hourly conversion rate from openexchangerates.org","chartName":"Bitcoin","bpi":{"USD":{"code":"USD","symbol":"$","rate":"63,340.4233","description":"United States Dollar","rate_float":63340.4233},"GBP":{"code":"GBP","symbol":"£","rate":"45,865.2439","description":"British Pound Sterling","rate_float":45865.2439},"EUR":{"code":"EUR","symbol":"€","rate":"54,408.4735","description":"Euro","rate_float":54408.4735}}}

let bpiArr = Object.entries(priceData.bpi)
console.log(bpiArr[0][1].description)

Note: the first [0] element of bpiArr[0] contains the string "USD" and the second [1] contains an object which got the description key and its value.
More information

A: bpi is not an Array but an object. If it uses curly brackets it is an object. If using square brackets it is an array. To access the USD property of bpi object you use dot notation (like you have done: bpi.USD) or you use bpi["USD"]

A: Based on your JSON bpi is an object but you are accessing it via array index which is wrong. If you want the value of USD, the way you were accessing in the first snippet is correct. However, if you want to use it as an array, you can do like below:
const {bpi= {}} = json;
const bpiArr = Object.entries(bpi);

// to access all the values
for (const [key,val] of bpiArr) {
   console.log(key,val.description)
}


text:
Q: Material-ui Select component not update state correctly I made multiple select input with Material-UI. By default state have an array of two objects. I set this state as select value, so it should show default objects as selected.
But problem is, that this not working, even when I try to select others items select updates this state but I can't to deselect default values.
I placed my code on CodeSandbox

A: The default values you created are separate than the values in vesselsList. If you change your default state to this it works.

const [desiredVesselType, setDesiredVesselType] = useState([
    vesselsList[3],
    vesselsList[4]
  ]);


text:
Q: Check port status on CentOS I have a CentOS machine, and I opened a port on witch I should get a stream (actually it is the 5004 port - rtp). However, seems like the stream is not received.
Is there anyway to check on status of a port? (I mean not on/of... but if anything is received).

A: You can use lsof -i :5004 to see if any process has that port open. Alternately, if you're not sure about the port in use but do know the process that is listening, you can use lsof -p process_id to find the port.

A: First, you can use netstat to see state of port.
Second, you can use tcpdump to see traffic going in and out on that port.
tcpdump -i eth0 "port 5004"

reports traffic on eth0 to port 5004.

A: Check 'iptables -L' for any rule blocking port 5004 and turn off firewall and selinux in 'system-config-securitylevel'


text:
Q: Is there a way to automatically save the system state when kernel panic occurs? Is there a way to save the overall state of the system when kernel panic occurs?
Kernel panic occurs during operation.
However, when kernel panic occurs, I can not debug through tty!
If kernel panic happens, I connect the tty debug cable to the board and check it with teraterm.
In this situation, the terminal does not work.
Do you dump system status (dmesg, process status, memory, etc ,,,) to file when kernel panic occurs or does this exist?
I would like to debug the situation in which kernel panic occurs.


text:
Q: qmake not working with Qt 5.6 I have installed Qt 5.6 with Creator. I have a simple Qt project which I am trying to 'make'. If I run qmake && make while in the project directory I get the following result:
qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory

I found several posts online that suggested installing qmake for QT4 to resolve this, using:
sudo apt-get install qt4-qmake

I actually did this and it seemed to get Qmake working, but the make process failed with
make: /usr/lib/x86_64-linux-gnu/qt4/bin/moc: Command not found
Makefile:190: recipe for target 'main.moc'
failed make: *** [main.moc] Error 127

So it seems to not find moc in the environment. I "think" this is because I am running qmake for version 4 but I actually have version 5.6 of Qt installed. I have since removed qt4-qmake and i have the original error again.
So my question is this: if i have Qt 5.6 installed (which is required for the Qt libraries I am using), why is it looking for version 4 qmake and how can I get qmake to recognize my version 5.6 install?
Update 1
So I can run qmake from within Qt Creator, but it doesnt create a makefile file in the project directory. If I run the debugger in Qt Creator, I can see where Creator runs qmake and make from and I can see it is successful. But I see no files that it creates as a result. Does running the project in Qt Creator result in any files being created, and if so where?
Update 2
I updated the project details on the project tab in Qt Creator. Strangely it doesnt save to there by default. Mow running QMake in Creator creates the file in the right folder.

A: In the projects tab, is shadow build ticked ? If yes, that's why the makefile doesn't appear in the project folder.
Usually you run qmake from the Qt creator because it's way more convenient.


text:
Q: AWS Printing DynamoDB Table Via CLI I'm trying to find the right command to use in the CLI to print the contents of a table within DynamoDB.
I've tried using the following command but it gives me a "parameter validation failed" error.
`
aws dynamodb get-item \
    --table-name Traffic \
    --key file://traffic.json \
    --return-consumed-capacity TOTAL

`
The AWS website is giving me a 403 error, at the moment, so I can't search for the solution through the official site.

A: To get all items in a table, use a scan operation, not a get item operation. This basic scan operation works fine with the CLI:
aws dynamodb scan --table-name Work

You can find all valid options here:
https://docs.aws.amazon.com/cli/latest/reference/dynamodb/scan.html

A: You can run the Scan API  to output how the table looks in DynamoDB JSON format.
aws dynamodb scan \
--table-name test \
--output text

If you have a list of keys to fetch in your traffic.json file then you should use batch-get-item.
If it's a single item you need then please share the contents of traffic.json file.


text:
Q: "lo: Disabled Privacy Extensions" and ipv6 disabling? There are lots of "lo: Disabled Privacy Extensions" in var/log/messages .
I googled and find it is ipv6 releated, so I tried to disable ipv6.
I added the following lines to /etc/sysctl.conf
net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.lo.disable_ipv6=1

and blacklist ipv6 to /etc/modprobe.d/blacklist.conf
after that, I restarted the network by /etc/init.d/networking restart .
My question is:
The ip addr still shows inet6 address attached to eth0 in forms like
 inet6 fe80::212:79ff:fecf:edaf/64 scope link
Does it means my ipv6 not disabled?

A: Disbale IPv6 in Ubuntu
Method 1
gksudo gedit  /etc/modprobe.d/aliases

Find the line: alias net-pf-10 ipv6
change to alias net-pf-10 off
If the above change is not working you need to change the following one
    alias net-pf-10 off ipv6
Method 2
Edit /etc/default/grub file
gksudo gedit  /etc/default/grub

Change
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

to
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1 quiet splash"

Save and exit the file
Update the grub from the command line
sudo update-grub

Keep me informed.
Regards,
Ilias el Matani

A: ipv6 support appears to be built-in in the latest ubuntu kernels, so you can't blacklist the module.
To disable ipv6 you need to do sysctl -p /etc/sysctl.conf before the changes in that file are used. (assuming you didn't reboot your computer, in which case the changes should be active already).
But why do you want to disable ipv6? The log messages wont harm your computer.
Oh, and if you want to disable only the privacy extensions part of ipv6 (which you probably wont need on a server anyway), put the key net.ipv6.conf.all.use_tempaddr = 0 in /etc/sysctl.conf

A: On an openSUSE 11.2 box that has a much newer kernel than original, I was getting this message too.
The use_tempaddr setting above is already -1 so that is no fix.
However elsewhere several people have said that shutting off vsftpd stops their messages.
And, as an LXC user I happen to be aware of an unusual thing vsftpd does with the namespaces support in newer kernels which causes a problem when vsftpd is used within an LXC container.
It turns out merely disabling that namespace-based isolation feature in vsftpd is enough to halt the messages at least for me.
Add the following to /etc/vsftpd.conf:

isolate=NO
isolate_network=NO

Then restart vsftpd.
ipv6 and vsftpd are both still enabled yet no more privacy extension messages.

A: As answered by Brian K. White,
I just reconfigured /etc/vsftpd.conf with the undocumented isolate_network=NO and it did the trick.
One minor difference about his answer is, that I didn't had to set isolate=NO.
This configuration variable reverts vsftpd to use fork(). Otherwise it would use clone() with CLONE_NEWNET parameter. This would put the process accessing the files into a separate networking environment that cannot access any network. (I have found this information on another answer on ServerFault)
I followed this path, because I saw those log messages appear after I've setup vsftpd.

A: To check if IPv6 is enabled or disabled
$ cat /proc/sys/net/ipv6/conf/all/disable_ipv6

0 means it's enabled and 1 is disabled.
To disable IPv6
$ su -
# nano /etc/sysctl.conf

and add these lines to sysctl.conf file
#disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Save sysctl.conf file with new config, then reboot your system
# reboot

Check your system again
$ cat /proc/sys/net/ipv6/conf/all/disable_ipv6

Now you should see "1″ means IPv6 has been disabled on your system.
How to disable IPv6 on Ubuntu and Linux Mint


text:
Q: exception occurred when using GAE/J and Google Cloud SQL with multiple project following exception occured.
    The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:33)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1117)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:350)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2416)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2450)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2235)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:818)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
Caused by: java.net.SocketException: Unable to open connection to the instance: project-A:dba
    at com.mysql.jdbc.GoogleCloudSqlSocket.<init>(GoogleCloudSqlSocket.java:48)
    at com.mysql.jdbc.GoogleCloudSqlSocketFactory.connect(GoogleCloudSqlSocketFactory.java:81)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:300)
    ... 44 more
Caused by: java.io.FileNotFoundException: /cloudsql/project-A:dba(No such file or directory)
    at java.io.RandomAccessFile.open(Native Method)
    at java.io.RandomAccessFile.<init>(RandomAccessFile.java:247)
    at java.io.RandomAccessFile.<init>(RandomAccessFile...(length 8379)

I have two GAE/J project and both refer same google cloud sql instance.
ex)

*

*project-A(gae/j) use project-A:dba(cloudsql)

*project-B(gae/j) use project-A:dba(cloudsql)

such exception occured in project-B.
db connection setting is following.
////(in project-B's java file)//////
String url = "jdbc:google:mysql://"+ "project-B" + ":db/db1";
Connection con = DriverManager.getConnection(url, properties);
////

this is bug? or any mistake?

A: If the Cloud SQL instance is the same for both projects, then the "project X" used as a qualifier of the instance, must be the same for both applications. This is the project name under which the Cloud SQL instance was created.
The DB host is built in Java as "jdbc:google:mysql://your-project-id:your-instance-name/"
According to your example, it would be "project-A:db/".
Don't forget to authorize your project-B app to access the Cloud SQL instance.


text:
Q: handling lookup tables with deleted records and databound controls I have a table Resource with a field Type. Type is a lookup into the table ResourceType.
So for instance ResourceType might have:
1: Books
2: Candy
3: Both
And Resource might have
1: Tom's Grocery, 2
2: Freds News, 3
It would display as: Tom's Grocery    Candy
Now lets say I am using a databound combobox for the resource type and the third record is deleted from ResourceType, we of course get an error when Fred's News is displayed.  I could simply put a marker in (perhaps an asterisk), indicating that it has been deleted, rather than actually delete it.  It shows up as **Both* in the textbox portion of the combo and I am content.
However, I would not want it to show up as an option in the dropdown.  Is this too much to ask from databound fields?  Must I write my own code to load the drop down?

A: Add a bit Deleted column to the lookup table.  When you delete a type, set Deleted = 1.  When you pull back ResourceTypes, only pull out ResourceTypes where Deleted = 0 and then bind to the dropdown.
Edit:
How are you getting the dataset that you're binding to the dropdownlist?  Are you using drag and drop datasets?  I really haven't worked with datasets like that in years, but I'm pretty sure you can change the Get sql to what you need it to be.

A: OK, I already have most of that built into the solution - but I must be binding wrong.  If I only pull back records where deleted = 0, I get exceptions - I'm guessing because the textbox can't be filled from the record set.
I guess I'm not sure how to bind the textbox display to one dataset - the one with all the records - and the dropdown to a filtered dataset.

A: Simply adding a deleted column was not enough - there had to be a way to see a deleted record in the text portion of a combo box while at the same time filtering out deleted records in the drop down.
In the end, I wrote a custom user control to handle this.


text:
Q: Where is the function when click on "Manage Categories" in admin panel I am checking in admin panel, when admin click on "Manage Categories" page is redirect to other location.I want to to know where is the function when click on "Manage Categories".

A: This function is written in
app\code\core\Mage\Adminhtml\controllers\Catalog\CategoryController.php
 public function indexAction()
    {
        $this->_forward('edit');
    }

the it goes to
public function editAction()
    {
        $params['_current'] = true;
        $redirect = false;

        $storeId = (int) $this->getRequest()->getParam('store');
        $parentId = (int) $this->getRequest()->getParam('parent');
        $_prevStoreId = Mage::getSingleton('admin/session')
            ->getLastViewedStore(true);

        if (!empty($_prevStoreId) && !$this->getRequest()->getQuery('isAjax')) {
            $params['store'] = $_prevStoreId;
            $redirect = true;
        }

        $categoryId = (int) $this->getRequest()->getParam('id');
        $_prevCategoryId = Mage::getSingleton('admin/session')
            ->getLastEditedCategory(true);

        if ($_prevCategoryId
            && !$this->getRequest()->getQuery('isAjax')
            && !$this->getRequest()->getParam('clear')) {
           // $params['id'] = $_prevCategoryId;
             $this->getRequest()->setParam('id',$_prevCategoryId);
            //$redirect = true;
        }

         if ($redirect) {
            $this->_redirect('*/*/edit', $params);
            return;
        }

        if ($storeId && !$categoryId && !$parentId) {
            $store = Mage::app()->getStore($storeId);
            $_prevCategoryId = (int) $store->getRootCategoryId();
            $this->getRequest()->setParam('id', $_prevCategoryId);
        }

        if (!($category = $this->_initCategory(true))) {
            return;
        }

        $this->_title($categoryId ? $category->getName() : $this->__('New Category'));

        /**
         * Check if we have data in session (if duering category save was exceprion)
         */
        $data = Mage::getSingleton('adminhtml/session')->getCategoryData(true);
        if (isset($data['general'])) {
            $category->addData($data['general']);
        }

        /**
         * Build response for ajax request
         */
        if ($this->getRequest()->getQuery('isAjax')) {
            // prepare breadcrumbs of selected category, if any
            $breadcrumbsPath = $category->getPath();
            if (empty($breadcrumbsPath)) {
                // but if no category, and it is deleted - prepare breadcrumbs from path, saved in session
                $breadcrumbsPath = Mage::getSingleton('admin/session')->getDeletedPath(true);
                if (!empty($breadcrumbsPath)) {
                    $breadcrumbsPath = explode('/', $breadcrumbsPath);
                    // no need to get parent breadcrumbs if deleting category level 1
                    if (count($breadcrumbsPath) <= 1) {
                        $breadcrumbsPath = '';
                    }
                    else {
                        array_pop($breadcrumbsPath);
                        $breadcrumbsPath = implode('/', $breadcrumbsPath);
                    }
                }
            }

            Mage::getSingleton('admin/session')
                ->setLastViewedStore($this->getRequest()->getParam('store'));
            Mage::getSingleton('admin/session')
                ->setLastEditedCategory($category->getId());
//            $this->_initLayoutMessages('adminhtml/session');
            $this->loadLayout();

            $eventResponse = new Varien_Object(array(
                'content' => $this->getLayout()->getBlock('category.edit')->getFormHtml()
                    . $this->getLayout()->getBlock('category.tree')
                    ->getBreadcrumbsJavascript($breadcrumbsPath, 'editingCategoryBreadcrumbs'),
                'messages' => $this->getLayout()->getMessagesBlock()->getGroupedHtml(),
            ));

            Mage::dispatchEvent('category_prepare_ajax_response', array(
                'response' => $eventResponse,
                'controller' => $this
            ));

            $this->getResponse()->setBody(
                Mage::helper('core')->jsonEncode($eventResponse->getData())
            );

            return;
        }

        $this->loadLayout();
        $this->_setActiveMenu('catalog/categories');
        $this->getLayout()->getBlock('head')->setCanLoadExtJs(true)
            ->setContainerCssClass('catalog-categories');

        $this->_addBreadcrumb(Mage::helper('catalog')->__('Manage Catalog Categories'),
             Mage::helper('catalog')->__('Manage Categories')
        );

        $block = $this->getLayout()->getBlock('catalog.wysiwyg.js');
        if ($block) {
            $block->setStoreId($storeId);
        }

        $this->renderLayout();
    }


text:
Q: Maclaurin series for $f(x) = \frac{x-cosa}{1 - 2xcosa + x^{2}}$ I'm trying to compute the Taylor series at 0 for the function $\frac{x-cosa}{1 - 2xcosa + x^{2}}$. The answer in my textbook is: $-\sum_{n=0}^{\infty}cos((n+1)a)x^{n}$.
Although I can calculate it up to the 2nd or 3rd term, I'm having troubles proving the general formula.
I've tried to make a substitution $t = x-cosa$ and find Taylor series at $t=-cosa$ for $\frac{t}{sin^{2}a + t^2}$, but it didn't make it any easier.

A: Hint: Show that
$$\frac{x-\cos a}{x^2-2x\cos a+1}=\frac{1}{2}\Big(\frac{1}{x-e^{ia}}+\frac{1}{x-e^{-ia}}\Big)$$
Expand around $x=0$:
$$\frac{1}{x-z}=\frac{1}{z}\sum_{n=0}^{\infty}\Big(\frac{x}{z}\Big)^n$$
and simplify for the result.


text:
Q: How to to get all methods in a class and store in a file Using DXCore? I am trying to write a simple console application as a learner with Dxcore open Api's. I have parsed a C# file using the following line of code.
   LanguageElement   parsedFile = parser.ParseFile(fileLocation)

and i want to try few basic things on this file. So i was trying to get all methods in this file and its parameters and place them in a list.
I saw a property which would do this but could not use it.
  DevExpress.CodeRush.StructuralParser.TypeDeclaration.AllMethods

Also few links on Dxcore plugin development documentations would be helpful.
Thanks in Advance.

A: You can cast your "parserFile" reference to the SourceFile type instance and then use the code like this:
  SourceFile parsedFile = parser.ParseFile(fileLocation) as SourceFile;
  if (parsedFile != null)
    foreach (TypeDeclaration type in parsedFile.AllTypes)
      foreach (Method method in type.AllMethods)
        foreach (Param param in method.Parameters)
        {
          // Do something...
        }

This link may probably be a bit of help: How to enumerate solution and source code items using DXCore

A: I believe you're looking for the following code.
SourceFile parsedFile = CodeRush.Language.Parse(fileName);
foreach (TypeDeclaration type in parsedFile.AllTypes)
{
    foreach (Method method in type.AllMethods)
    {
        // do stuff
    }
}

Note the change from LanguageElement to SourceFile.