text:
Q: Automize portfolios volatilities computation in R Thanks for reading my post. I have a series of portfolios created from the combination of several stocks. I should compute the volatility of those portfolios using the historical daily performances of each stock. Since I have all the combinations in one data frame (called final_output), and all stocks return in another data frame (called perf, where the columns are stocks and rows days) I don't know which will be the most efficient way to automize the process. Below you can find an extract:
> Final_output

        ISIN_1       ISIN_2       ISIN_3       ISIN_4
2 CH0595726594 CH1111679010 XS1994697115 CH0587331973
3 CH0595726594 CH1111679010 XS1994697115 XS2027888150
4 CH0595726594 CH1111679010 XS1994697115 XS2043119358
5 CH0595726594 CH1111679010 XS1994697115 XS2011503617
6 CH0595726594 CH1111679010 XS1994697115 CH1107638921
7 CH0595726594 CH1111679010 XS1994697115 XS2058783270
8 CH0595726594 CH1111679010 XS1994697115 JE00BGBBPB95

> perf

     CH0595726594  CH1111679010  XS1994697115  CH0587331973
626  0.0055616769 -0.0023656130  1.363791e-03  1.215922e-03
627  0.0086094443  0.0060037334  0.000000e+00  2.519220e-03
628  0.0053802380  0.0009027081  0.000000e+00  7.508635e-04
629 -0.0025213543 -0.0022046297  4.864050e-05  1.800720e-04
630  0.0192416817  0.0093401627 -6.079767e-03  3.800836e-03
631 -0.0101224820  0.0051741294  6.116956e-03 -1.345184e-03
632 -0.0013293793 -0.0100475153 -4.494163e-03 -1.746106e-03
633  0.0036350604  0.0012999350  3.801130e-03 -5.997121e-05
634  0.0030097434 -0.0011484496 -1.187614e-03 -2.069131e-03
635  0.0002034381  0.0030493901 -1.851762e-03 -3.806280e-04
636 -0.0035594427  0.0167455769 -2.148123e-04 -4.709560e-04
637  0.0007654623 -0.0051958237 -3.711191e-04  1.604010e-04
638  0.0107592678 -0.0016260163  4.298764e-04  3.397951e-03
639  0.0050953486 -0.0007403020  2.011738e-03  8.790770e-04
640  0.0008532851 -0.0071121648 -9.746114e-04  5.389598e-04
641 -0.0068204614  0.0133810874 -9.755622e-05 -1.346674e-03
642  0.0091395678  0.0102591793  1.717157e-03 -1.977785e-03
643  0.0027520640 -0.0157912638  1.256440e-03 -1.301119e-04
644 -0.0048902196  0.0039494471 -1.624514e-03 -3.373340e-03
645 -0.0116838833  0.0062450826  6.625549e-04  1.205255e-03
646  0.0004566442 -0.0018570102 -3.456636e-03  4.474138e-03
647  0.0041586368  0.0085679315  4.435933e-03  1.957455e-03
648  0.0007575758  0.0002912621  0.000000e+00  2.053306e-03
649  0.0046429473 -0.0138309230 -4.435798e-03  1.541798e-03
650  0.0049731250 -0.0488164953  4.181975e-03 -9.733133e-04
651  0.0008497451 -0.0033110870  2.724477e-04 -7.555498e-04
652  0.0004494831  0.0049831300 -8.657588e-04 -1.790813e-04
653 -0.0058905751  0.0020143588  8.178287e-04 -1.213991e-03
654  0.0000000000  0.0167525773  4.864050e-05  9.365068e-04
655  0.0010043186  0.0048162231  0.000000e+00 -2.110146e-03
656 -0.0024079462 -0.0100403633 -2.431907e-03 -9.176600e-04
657 -0.0095544604 -0.0193670047  0.000000e+00 -8.935435e-03
658  0.0008123477  0.0114339172  2.437835e-03  5.530483e-03
659  0.0022828734 -0.0015415446 -3.239300e-03  2.765060e-03
660  0.0049096523 -0.0001029283  3.199079e-02  2.327835e-03
661 -0.0027702226 -0.0357198003  9.456712e-04  3.189602e-04
662 -0.0008081216 -0.0139311449 -2.891020e-02 -1.295363e-03
663 -0.0033867462  0.0068745264 -2.529552e-03 -1.496588e-04
664 -0.0015216068 -0.0558572120 -3.023653e-03 -7.992975e-03
665  0.0052829422  0.0181072771  4.304652e-03 -3.319519e-03
666  0.0084386054  0.0448545861 -8.182748e-04  4.279284e-03
667 -0.0076664829 -0.0059415480 -2.047362e-04  6.059936e-03
668 -0.0062108665 -0.0039847073  7.313506e-04  5.993467e-04
669 -0.0053350948  0.0068119154 -1.042631e-02 -2.056524e-03
670 -0.0263588067  0.0245395479 -2.188962e-02 -6.732491e-03
671 -0.0021511018  0.0220649895  1.412435e-02  1.702085e-03
672  0.0205058100 -0.0007179119  3.057527e-03 -1.002423e-02
673  0.0096862280 -0.0194488633  1.207407e-03 -1.553899e-03
674  0.0007143951 -0.0068557672  6.227450e-03  1.790274e-03
675 -0.0021926470 -0.0051114507 -6.267498e-03 -1.035691e-03
676  0.0076655765 -0.0139300847  6.583825e-03  3.059472e-03
677 -0.0032457653  0.0180480206 -4.635495e-03  1.064002e-03
678  0.0036633764  0.0060676410 -2.762676e-04  5.364970e-04
679 -0.0008111122 -0.0013635410 -1.065898e-03  1.214059e-03
680  0.0050228311  0.0055141267  3.003507e-03  1.121643e-03
681 -0.0007067495  0.0147281558 -2.699002e-03 -1.514035e-04
682 -0.0024248548  0.0002573473 -2.113685e-03 -1.423409e-03
683 -0.0002025624  0.0138417207 -4.374895e-03  1.415328e-04
684 -0.0141822418 -0.0169517332 -3.578920e-03 -1.799234e-03
685 -0.0005651749 -0.0259693324 -5.926428e-03 -3.635333e-03
686  0.0004112688  0.0133043570 -1.545642e-03  1.981828e-03
687 -0.0150565262 -0.0107757493 -1.717916e-02 -1.328749e-02
688  0.0039129754 -0.0441013167 -8.376631e-03 -5.653841e-04
689  0.0019748467  0.0115063340 -2.835394e-02  7.868428e-03
690  0.0072614108  0.0358764014  3.586897e-02  7.960077e-03
691 -0.0003604531  0.0106119001  1.024769e-04 -2.733651e-04

What I should do is look for each portfolio (each row of final_output is a portfolio, i.e. 4 stocks portfolio) in perf and compute the volatility (standard deviation) of that portfolio using the stocks historical daily performances of the last three months. (Of course, here I have pasted only 4 stocks performances for simplicity.) Once done for the first, I should do the same for all the other rows (portfolios).
Below is the formula I used for computing the volatility:
#formula for computing the volatility
sqrt(t(weights) %*% covariance_matrix %*% weights)

#where covariance_matrix is
cov(portfolio_component_monthly_returns)

#All the portfolios are equiponderated
weights = [ 0.25 0.25 0.25 0.25 ]

What I'm trying to do since yesterday is to automize the process for all the rows, indeed I have more than 10'000 rows. I'm an RStudio naif, so even trying and surfing on the new I have no results and no ideas of how to automize it. Would someone have a clue how to do it?
Hope to have been clearer as possible, in case do not hesitate to ask me.
Many thanks


text:
Q: template for an automatic header on emacs so I'm jumping back into trying to learn programming.
I'm using my MBP using SSH to access the university's linux machines and programming in python and using emacs.
Each file is required to have a header:
# File: file.py
# Author: My Name
# Date: 30 September 2014
# Section: 1
# Email: me@school.edu
# Description: sample header

My question is:
Is there a way to make that a permanent template, so that whenever I create a new file, those comments are already there? everything except file date and description would be static. If there is a way, is there also a way to automatically fill in the stuff that changes file.py = whateverINamedTheProgram.py and date = todaysDate or something?

A: header2.el is the way to go, however, here is an occasion to learn some emacs lisp and see how we can script our use of emacs. Maybe it's a bad idea now since you are learning programming, but maybe you'll find it clearer (than the non friendly header2 and yasnippet docs).
The advantage of this code is that you call it on demand and we can do what we want.
(defun my-insert-header ()
  "Asks for file name, date, description, ... and insert at point."
  (interactive)
  (setq cur-file (read-from-minibuffer "file name ? "
                   (file-name-nondirectory (buffer-file-name))))
  (setq cur-date (org-read-date))
  (setq cur-author "Me")
  (setq cur-description (read-from-minibuffer "description ? "))
  (insert (format "# File: %s \n" cur-file))
  (insert (format "# date : %s \n" cur-date))
  (insert (format "# Description : %s \n" cur-description))
)

Put it in your dot file (.emacs.d/init.el or ~/.emacs).
You can just try it by putting it in the scratch buffer, going just after the last parentheses and hitting C-x C-e (eval-last-sexp). (see this tutorial: http://wikemacs.org/wiki/Emacs_Lisp_in_15_minutes)
Now explanations:

*

*defun: define a function, like def in python.

*(interactive): let the function be called with Alt-x. see http://ergoemacs.org/emacs/elisp_basics.html

*setq: way to define a variable

*read-from-minibuffer: does what it says :) the second argument is an optional default text to edit

*org-read-date: a nice utility function from org-mode. You can change dates with Shift-left/right. It returns a string.

*buffer-file-name: returns "/home/you/dir/try.py"

*file-name-nondirectory: returns "try.py"

*insert: insert text in current buffer

*format "foo %s \n": string formatting, like in python

and that's it. I let you finish the function as you want !

A: Yes, you can use library header2.el to do what you ask. You can use it with different programming languages. Particular fields in the file header can be automatically updated when you save the file, if you want.
Your question is almost identical to this question, posed at almost the same time. (Coincidence?) See that question for more info about header2.el. Or see Emacs Wiki page  Automatic File Headers, for more description and examples.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Encapsulate Type Guards into Functions Is there anyway to encapsulate a type guard within a function as defined below?
function assertArray(value: any): void {
  if (!Array.isArray(value)) {
    throw "Not an array"
  }
}

// Doesn't work
function example1(value: string | []) {
  assertArray(value)
  return value.join('')
}

// But this works
function example2(value: string | []) {
  if (!Array.isArray(value)) {
    throw "Not an array"
  }
  return value.join('')
}

Playground
The use cases is rather simple. I want to have runtime assertions, and I'd like to encapsulate the logic without having to return new variables. I know I could const x = assertArray(y), but why can't I just assertArray(y)?

A: If you are using at least Typescript 3.7, you can create assertion functions:
function assertArray(value: any): asserts value is any[] {
  if (!Array.isArray(value)) {
    throw "Not an array"
  }
}

function example1(value: string | []) {
  assertArray(value)
  return value.join('')
}


text:
Q: Is PostgreSQL 9.2 autovacuum sufficient for a busy table? I have one table on a PostgreSQL 9.2/PostGIS 2.0.1 database:
CREATE TABLE ch02.markers
(
  ff_id SERIAL PRIMARY KEY,
  col1 boolean,
  col2 smallint,
  created_at timestamp,
  lat double precision,
  lon double precision,
  geog geography(POINT,4326)
);

CREATE INDEX idx_markers_geog ON ch02.markers USING gist(geog);

This table is having records, probably thousands but potentially tens of thousands per hour, inserted and deleted 24/7.
I am wondering if the default autovacuum settings will sufficiently manage the table?
Otherwise I presume I write a SP function that is called by cron. However, what should I use? VACUUM ANALYZE? I am wary of using any anything that locks the table (CLUSTER, REINDEX). Do these even work for an index on a geography point column?
I am not used to such active tables and I am completely new to Postgres, so I have absolutely no feel for this. Any help appreciated.

A: Before you fiddle with cron jobs and other curiosities you can adjust the autovacuum default settings just inside PostgreSQL. This can be done globally or individually for each table.


text:
Q: Как заблокировать RadioButton после выбора? Есть несколько RadioButton и при выборе одного из них нужно блокировать другие. Как можно  это реализовать?

A: Следует написать универсальный метод, который при выборе radioButton будет вызываться у каждого radioButton, а внутри метода будем менять их состояния:
void radioButtons_CheckedChanged(object sender, EventArgs e)
{
    RadioButton currentRadioButton = sender as RadioButton; // на кого кликнули
    if (radioButton != null)
    {
        // пройдем по всем RadioButton нашей формы и поменяем состояние
        foreach(var radioButton in this.Controls.OfType<RadioButton>())
        {
            radioButton.Enabled = false; // заблокируем каждый
        }
        currentRadioButton.Enabled = true; // разблокируем выбранный
    }
}

Таким образом после выбора одного radioButton остальные будут заблокированы. Для того, чтобы данный метод вызывался у всех radioButton, размещенных на форме, необходимо в свойствах этих компонент, у каждого, задать метод, который будет вызываться для события CheckedChanged - вызвать метод radioButtons_CheckedChanged.

A:
Доброго времени суток. Для деактивации (блокировки) radio button, после выбора необходимо написать след. код:
функция создается автоматически, после нажатия несколько раз мышкой по radio button
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{

Enabled = false; //деактивируем radio button

}

Для деактивации других radio button необходимо деактивировать их след. образом:
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
   Enabled = false;
   radioButton2.Enabled = false; // название radio button . деактивация = деактивировать
   radioButton3.Enabled = false;
}

для того, чтобы вырубить всю форму, нужно просто написать в функцию след. строчку:
Form1.ActiveForm.Dispose();


text:
Q: How can I align text on top of a column in Bootstrap? This is my code and a screenshot of the website.
How can I align my text "button will show a page as below" on the left but on the same height like the start of my picture?

Item Price

            button will show a page as below

I am talking about the first column!

A: Okay i got it:

Item Price

               A very long text(about 300 words)

My css clas:
.logo{
    position: relative;
    top: -70px; /* This will move it 20px up */
    left: 20px; /* This will move it 20px to the right */
  }

Thanks to Drown who answered this question

A: instead of making the logo position relative you can use
margin-top:-70px
margin-left:20px

absolute position for this task is not recommended.


text:
Q: JavaFX Span Tableview Merge Cells by MapEntries Hello i have the following Map:
Map<String,ArrayList>

I would like to have a TableView like this
|--------------|-----------|
|ArrayList e1  | String e  |
|--------------|           |
|ArrayList e2  |           |
|--------------|           |
|ArrayList e3  |           |
|--------------|-----------|
|ArrayList x1  | String x  |
|--------------|           |
|ArrayList x2  |           |
|--------------|-----------|

I already tried it with several CellValueFactory Callbacks, but i don't have any clue how to read out my values and, span or merge these cells.
Best regards

A: I solved it by creating a CellValueFactory for the first column where I grabbed the ArrayList as String so:
    arrayListCol.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<Map.Entry<PropertyDifference, DifferenceFileList>, String>, ObservableValue<String>>() {
        @Override
        public ObservableValue<String> call(TableColumn.CellDataFeatures<Map.Entry<PropertyDifference, DifferenceFileList>, String> p) {
            return new SimpleStringProperty(Arrays.toString(p.getValue().getValue().getFileList().toArray()));
        }
    });

results in:
|--------------|-----------|
|[e1,e2,e3]    | String e  |
|--------------|-----------|
|[x1,x2]       | String x  |
|--------------|-----------|

This handles the values for the column entries. Now i thought about a further representation form and used a CellFactory for this, which afterward formats the cell.
    Callback<TableColumn<Map.Entry<PropertyDifference, DifferenceFileList>, String>, TableCell<Map.Entry<PropertyDifference, DifferenceFileList>, String>> tableCellList = new Callback<TableColumn<Map.Entry<PropertyDifference, DifferenceFileList>, String>, TableCell<Map.Entry<PropertyDifference, DifferenceFileList>, String>>() {
        @Override
        public TableCell<Map.Entry<PropertyDifference, DifferenceFileList>, String> call(TableColumn<Map.Entry<PropertyDifference, DifferenceFileList>, String> param) {
            return new TableCell<Map.Entry<PropertyDifference, DifferenceFileList>, String>() {
                @Override
                protected void updateItem(String item, boolean empty) {
                  if (item != null) {
                      item = item.replace("[", "") .replace("]", "");
                      ObservableList<String> items = FXCollections.observableArrayList(item.split(","));
                      final ListView<String> listView = new ListView<String>();

                      listView.setItems(items);

                      setGraphic(listView);
                  }
                }
            };
        }
    };

    arrayListCol.setCellFactory(tableCellList);

This replaces the "[" and "]" chars and splits the "stringed" ArrayList into an ObservableList by using "," as a split delimeter.
The ObservableList is used for a ListView which is then added to the cell via the line:
setGraphic(listView);

.
|------|-----------|
|  e1  | String e  |
|  e2  |           |
|  e3  |           |
|------|-----------|
|  x1  | String x  |
|  x2  |           |
|------|-----------|

Anything unclear? -> just comment.


text:
Q: Installing easy_install... to get to installing lxml I've come to grips with the fact that ElementTree isn't going to do what I want it to do. I've checked out the documentation for lxml, and it appears that it will serve my purposes. To get lxml, I need to get easy_install. So I downloaded it from here, and put it in /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/. Then I went to that folder, and ran sh setuptools-0.6c11-py2.6.egg.
That installed successfully. Then I got excited because I thought the whole point of easy_install was that I could then just install via easy_install lxml, and lxml would magically get downloaded, built, and installed properly, ready for my importing enjoyment. So I ran easy_install lxml. I pasted the results below. What should I do?
easy_install lxml
Searching for lxml
Reading http://pypi.python.org/simple/lxml/
Reading http://codespeak.net/lxml
Best match: lxml 2.2.6
Downloading http://codespeak.net/lxml/lxml-2.2.6.tgz
Processing lxml-2.2.6.tgz
Running lxml-2.2.6/setup.py -q bdist_egg --dist-dir /var/folders/49/49N0+g5QFKCm51AbzMtghE+++TI/-Tmp-/easy_install-rxbP6K/lxml-2.2.6/egg-dist-tmp-fjakR0
Building lxml version 2.2.6.
NOTE: Trying to build without Cython, pre-generated 'src/lxml/lxml.etree.c' needs to be available.
Using build configuration of libxslt 1.1.12
Building against libxml2/libxslt in the following directory: /usr/lib
unable to execute gcc-4.0: No such file or directory
error: Setup script exited with error: command 'gcc-4.0' failed with exit status 1

A: First off we don't use easy_install anymore. We use pip. Please use pip instead.
To get to your particular troubles, as the comments point out, you're missing GCC. On OS X, Xcode Command Line Tools provides GCC, as well as many other programs necessary for building software on OS X. For OS X 10.9 (Mavericks) and newer, either install Xcode through the App Store, or alternatively, install only the Xcode Command Line Tools with
xcode-select --install

For more details, please see the Apple Developer FAQ or search the web for "install Xcode Command Line Tools".
For older versions of OS X, you can get Xcode Command Line Tools from the downloads page of the Apple Developer website (free registration required).
Once you have GCC installed, you may still encounter errors during compilation if the C/C++ library dependencies are not installed on your system. On OS X, the Homebrew project is the easiest way to install and manage such dependencies. Follow the instructions on the Homebrew website to install Homebrew on your system, then issue
brew update
brew install libxml2 libxslt

Possibly causing further trouble in your case, you placed the downloaded setuptools in /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/. Please do not download any files to this location. Instead, I suggest you download the file to your home directory, or your usual Downloads directory. After downloading it, you're supposed to run sh setuptools-X.Y.Z.egg, which will then install it properly into the appropriate site-packages and put the executable easy_install on your path.

A: It looks like lxml wants to build an extension that requires access to a C compiler. You will need gcc for that. Try running sudo apt-get install build-essential and that should fix this particular issue.

A: Make sure that all the following packages are installed on your system first:
gcc gcc-c++ python-devel libxml2 libxml2-dev libxslt libxslt-dev

You should be able to install them using some variant of:
sudo apt-get install
sudo yum install
Only after all of the above have been successfully installed should you attempt to run:
sudo pip install lxml

A: Ensure you have libxml2-dev and libxslt1-dev installed
apt-get install libxml2-dev
apt-get install libxslt1-dev

Then your installation should build properly.

A: try:
sudo apt-get install python-lxml


text:
Q: accessing php soapservice from C# well i wanted to make a simple webservice that searches the db and return the data i know i can do it with mysql connector but this is just to learn how to use soaps here is the code for php soap server

require_once ('lib/nusoap.php');

$namespace = "http://localhost/webservice/index.php?wsdl";
$server = new soap_server();
$server->configureWSDL("DBQuery");
$server->wsdl->schemaTargetNamespace = $namespace;
$server->register(
    'QueryMsg',
    array('name'=>'xsd:string'),
    array('return'=>'xsd:string'),
    $namespace,
    false,
    'rpc',
    'encoded',
    'returns data from database');

function QueryMsg($query)
{
    $con=mysqli_connect('localhost','root','','webserivce');

    if (mysqli_connect_errno()) {
        return "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    if(!isset($query) or strpos(strtolower($query),'select')<=-1)
    {
        return "invalid order";
    }
    else
    {

        mysqli_real_escape_string($con,$query);
        $result = mysqli_query($con,$query);
                while($row = mysqli_fetch_array($result)) {
                    $data[] = $row;}

                return json_encode($data);

    }
}
// create HTTP listener
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
exit();
?>

it works when i try calling it from a php soap client but when i try adding this http:// localhost /webservice/index.php in visual studio as service refernce to consume it from C# application i get an error here it is
The HTML document does not contain Web service discovery information.
Metadata contains a reference that cannot be resolved: 'http://localhost/webservice/index.php'.
The content type text/xml; charset=ISO-8859-1 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 700 bytes of the response were: '<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><SOAP-ENV:Fault><faultcode xsi:type="xsd:string">SOAP-ENV:Client</faultcode><faultactor xsi:type="xsd:string"></faultactor><faultstring xsi:type="xsd:string">Operation '' is not defined in the WSDL for this service</faultstring><detail xsi:type="xsd:string"></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>'.
The remote server returned an error: (500) Internal Server Error.
If the service is defined in the current solution, try building the solution and adding the service reference again.

solved : well it was easy actually there is two ways either use WCF and change encoding to ISO-8859-1
or change encoding of the web service itself by adding this line $server->soap_defencoding = 'UTF-8'; after creating the soap server

A: I would try adding the service WSDL with a tool like SOAP U.I. and see what kind of errors you get back from that.  It's a little more agnostic than adding a web reference with C#, and might disclose more details about why at the client level you can't consume this.
I'm happy to help you troubleshoot this with a little more information.  Are you running this service on the same machine where you're running the client from?  If it's complaining about being unable to correlate the file http://localhost/webservice/index.php to something I wonder if the discovery process is trying to evaluate a file that can't be found.  I.E. an import operation in your source WSDL that points to a URL the client can't resolve.


text:
Q: Cannot access SQL Server through C# application
I am developing an application in C# in Visual Studio 2010 for connecting this application with SQL Server 2008R2 on local computer.
I have written a connection string file in my application. But when I try to access the database through config file by accessing the connection string it gives me an error

Object reference not set to an instance of an object

I am sharing the snapshot of my SQL Server instance and also the config file so please let me know what is the problem.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
 <add name="MyDbConn1"
     connectionString="Data Source=jahanzaib-pc\SQLEXPRESS;Database=Tawacal;User Id=sa;
 Password=123;"/>
 </connectionStrings>
</configuration>

And code for accessing connection string.
constr = System.Configuration.ConfigurationSettings.AppSettings["MyDbConn1"].ToString();
SqlConnection newcon = new SqlConnection(constr);
newcon.Open();


text:
Q: C# LINQ Arrange Multiple Columns Value and Resign to Specific Columns I have tried this with Foreach loop, a new array and is working but I want to learn and see if there is a better way to do this with LINQ lambda.
I have a fruits table like this
public class fruits
{
   string id {get;set;}
   string fruit1 {get;set;}
   string fruit2 {get;set;}
   string fruit3 {get;set;}
}

Somehow not all fruit field in the table got filled for example:
id    fruit1    fruit2    fruit3
1     Apple               Kiwi
2               Lime
3                         Watermelon
4               Oranges   Grapes

Need output like:
id    fruit1    fruit2    fruit3
1     Apple     Kiwi
2     Lime
3     Watermelon
4     Oranges   Grapes

tried the following step to make this working

*

*foreach loop through the list of fruits object

*add fruit1 ,fruit2 ,fruit3 to a new array

*create a for loop base on the array.length assign value like so object fruit  [i]

I would like to know if there a better way to do this with LINQ lambda.
thanks

A: So using ternary conditional operators this would look like this, although using a loop would be more readable.
list = list.Select(x => new fruits
        {
            id = x.id,
            fruit1 = x.fruit1 ?? x.fruit2 ?? x.fruit3,
            fruit2 = !string.IsNullOrEmpty(x.fruit1) ? (x.fruit2 ?? x.fruit3) : string.IsNullOrEmpty(x.fruit2) ? null : x.fruit3,
            fruit3 = string.IsNullOrEmpty(x.fruit1) || string.IsNullOrEmpty(x.fruit2) ? null : x.fruit3
        }).ToList();

A: Another approach with Linq
fruits[] output = input.Select(x => {
var items = new[] { x.fruit1, x.fruit2, x.fruit3 }.Where(y => !string.IsNullOrEmpty(y));
                return  new fruits() {
                    id = x.id,
                    fruit1 = items.ElementAtOrDefault(0),
                    fruit2 = items.ElementAtOrDefault(1),
                    fruit3 = items.ElementAtOrDefault(2)
                };}).ToArray();

https://dotnetfiddle.net/OXYWpW

the imo better approach with loop
foreach (fruits item in fruitarray)
{
    var columns = new[] { item.fruit1, item.fruit2, item.fruit3 }.Where(y => !string.IsNullOrEmpty(y));
    item.fruit1 = columns.ElementAtOrDefault(0);
    item.fruit2 = columns.ElementAtOrDefault(1);
    item.fruit3 = columns.ElementAtOrDefault(2);
}

https://dotnetfiddle.net/RVhl9n

A: Linq-operations Select, Skip and FirstOrDefault:
var projection = fruitses.Select(r=>
    new fruits {
        id = r.id,
        fruit1 = new List<string>(){r.fruit1, r.fruit2, r.fruit3}
            .FirstOrDefault(s=>!string.IsNullOrEmpty(s)),
        fruit2 = new List<string>(){r.fruit2, r.fruit3}
            .Skip(r.fruit1==null?1:0)
            .Skip(r.fruit2==null?1:0)
            .FirstOrDefault(s=> !string.IsNullOrEmpty(s)),
        fruit3 = new List<string>(){r.fruit3}
            .Skip(r.fruit1==null?1:0)
            .Skip(r.fruit2==null?1:0)
            .FirstOrDefault(s=> !string.IsNullOrEmpty(s))
    });

.NET Fiddle here

A: first i would go about making a list of those fruit so u can actually do something with them. preferably u would store them in a list to begin with;
add a property fruits that returns the fruits as a list.
public List<string> fruit
    {
        get { return new List<string> { this.fruit1, this.fruit2, this.fruit3 };}
        set {
            this.fruit1 = value.ElementAtOrDefault(0);
            this.fruit2 = value.ElementAtOrDefault(1);
            this.fruit3 = value.ElementAtOrDefault(2);
        }
    }

so taking a list of the Fruits object:
List<Fruits> fruitList = {...};

u can then remove all fruits where there is nothing, thus creating a list with no empty spots.
fruitList.ForEach(s => s.fruits =  s.fruits.Where(x => !string.IsNullOrEmpty(x)).ToList());

However, this list can be shorter than the previous list as all empty strings get removed. So we must check if the value at the appropriate index still exists. We do this with ElementAtOrDefault, this return null if there is no value present at the index.
You must note however that this is not a sustainable way of keeping these objects as u will need to create more fruit properties for every increase in the number of fruit u want to store in a row. so it would be best to just store those fruit in a list to begin with and circumvent all these problems.


text:
Q: Implementing an SNMP Reporter (agent) in C# (must run on Mono)? I am attempting to implement some additional statistics gathering in a C# server application - I have about 20 or so variables I'd like to be able to report to network monitoring tools; so I am assuming (hopefully correctly) that SNMP is the correct way to go.
There are however two problems:

*

*The application is an open source server that cant include proprietary components, and

*It needs to run on Mono under *nix environs as well as Windows via .NET.

The "#SNMP" library at http://sharpsnmplib.codeplex.com/ appears to be a promising solution - but there are no samples I can find; and my knowledge of SNMP is lacking.
Does anyone here have any (quick) examples of reporting data via SNMP? (ideally using a library under the LGPL, X/MIT, BSD or Zlib licenses)
Help much appreciated
Edit:
The problem appears to be a lack of libraries capable of acting as SNMP servers, if anyone is aware of any - this would probably solve the problem nicely.
Edit #2:
Basically I'm looking for a SNMP server library or sample reference implementation.

A: As the author :) I suggest you check out TestAgent sample. It can send out TRAP or INFORM messages to the IP address you specify.
Note that this is a tiny sample, which does not reveal all powers of SNMP.

A: #SNMP source comes with some samples (they're actually tests, but one can have an idea about how it works).
Another thing you could try is send your snmp queries calling directly the snmpget executable with the Process class. It's not the best way, but it could work (I've used this kind of approach with another language).


text:
Q: Windows Server 2012 RDS - How to add new Domainuser So far I never had much to do with server administration, so this question might be very basic to some people.
I have to manage a Windows Server 2012 R2. There are around 8 users who use it. They all have a local computer and connect to it via RDP and work on the server. If i type in cmd
net users

there are only the standard users (Administrator, Guest and 1 more costum), but none of the 8 "real" users. If i create a new user with
net user newuser newpw /add

this user appears in the "net users"-command, but has a different domainname than the 8 real users. For example newusers fullname is "ITS/newuser", while all the "real" users are "COMPANY/username". The Server is not member of an Active Directory Network.
Furthermore when I log in as Admin and use the Computermanagement-Tool, i canot find the 8 real users listed anywhere. The 8 real users all have a folder in C:\Users\username with the typical subfolders like Desktop, Downloads, Documents, etc.
I want to add a new user, and put them into the same domain as the 8 existing users. So far, I have no idea how to do this.
Of course i googled a lot, but every solution I found was about managing users in an Active Directory Network and in my case there is no Active Directory.
Can someone explain in general what exactly is going on and how this server works? To be honest I do not even understand the structure about how users are managed on this server and I am desperate for any information.
If you want more information or even screenshots, just ask for them. I am very glad if someone can help me

A: net user user /ADD is the correct way to add an account, the format should be; MACHINE\username. If you see COMPANY\username then the net user was run against your Active Directory.
Please use computer management to manage the local user database, it's way more simple than using net user. Run->compmgmt.msc
If you can't see the user in compmgmt.msc, it mean you runned net users without the /ADD, which doest add the user, or net user was run against the DOMAIN.
For that I suggest to use computer management it's less confusing.


text:
Q: Split a JSON object by parameters I have a JSON Object defined in Typescript, I want to split it into parts but I can only get the keys:
This is my JSON object:
let data = {
  "dataTest": "data1,data2,data3",
  "insTest": "ins1,ins2,ins3",
  "serTest": "ser1,ser2,ser3"
}

This is what I do to loop through it:
for (let key of Object.keys(data)) {
  console.log(key)
}

This is what I get:
1º //dataTest
2º //insTest
3º //serTest

This is what I want to get:
1º //dataTest: "data1,data2,data3"
2º //insTest: "ins1,ins2,ins3"
3º //serTest: "ser1,ser2,ser3"

Upgrade
Is it also possible to get the concatenation of all the values in a single array?
Example:
data1,data2,data3,ins1,ins2,ins3,ser1,ser2,ser3

A: Use Object.entries().
The Object.entries() method returns an array of a given object's own enumerable string-keyed property [key, value] pairs.
See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries

const data = {
  dataTest: "data1,data2,data3",
  insTest: "ins1,ins2,ins3",
  serTest: "ser1,ser2,ser3"
};

const entries = Object.entries(data);

entries.forEach(([key, value]) => {
  console.log(`${key}: ${value}`);
});

A: You can get the required value using Object.entries().

let data = {
  "dataTest": "data1,data2,data3",
  "insTest": "ins1,ins2,ins3",
  "serTest": "ser1,ser2,ser3"
}

Object.entries(data).forEach(([key, value]) => {
  console.log(`${key}: ${value}`);
});

A: Here is another way
for(let key in data) {
    console.log(key + ': ' + '"' + data[key] + '"');
}

using Template literals
for(let key in data) {
    console.log(`${key}: "${data[key]}"`);
}


text:
Q: dash code error: TypeError: Unexpected keyword argument `selected_columns`
Using Dash Data Table, getting the above exception when running the app.

A: I solved the problem by upgrading to the latest version of Dash (pip install dash --upgrade)


text:
Q: Trying to create spring project with maven Hello everyone I was just going trough http://static.springsource.org/docs/Spring-MVC-step-by-step/part1.html spring tutorial, and I thought its old I'll think something better on my own. For starters how do I start spring project with maven, which archtype should I choose? I wanna create simple spring app, write class which I will deploy to jboss, spring will instansiate it at startup .. that is what have in mind for now .. for now I need to start it first

A: The Spring 3 samples are maven based and are a good starting point. Just get them from their source control: https://src.springframework.org/svn/spring-samples/
Another option would be to use an AppFuse archetype like the appfuse-modular-spring to create a modular application with Hibernate, Spring and Spring MVC.

A: An archetype only sets up your POM and directory structure based on a template. I wouldn't get hung up on which one to choose.
The MVC tutorial uses the following structure:

*

*src - Java source code

*war - Web resources, web.xml, and Spring context files

If you want to use the Maven standards, this should convert to

*

*src/main/java - Java source code

*src/main/resources - Spring context files and configuration (non-web related) files, which you'd like to be on the classpath (i.e. WEB-INF/classes) in a webapp

*src/main/webapp - Web-related resources which you'd like to appear at the root of your webapp/.war file

And the <packaging> for a webapp should be war.
Update: I'd recommend taking a look at the free Maven by Example book, it walks you through building a sample application using Maven, including a chapter on "A Simple Web Application". There is also Maven: The Complete Reference for more reference.

A: appfuse has a maven archetype for creating webapp with spring, hibernate and spring MVC
artifactId: appfuse-basic-spring
groupId: org.appfuse.archetypes

A: You can create a project using the web archetype:
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-webapp -DarchetypeArtifactId=maven-archetype-webapp

Then add spring as a dependency in the generated pom.xml to get the spring jars:
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring</artifactId>
    <version>2.5.6</version>
</dependency>

You can follow the spring tutorials from there.
You will need to update the java source version to 1.5 in the pom for annotations etc, it describes how to do this on the maven site.


text:
Q: Javascript delete statement Q: I am trying to work out why there is a delete statement in this code?
My assumption is foo will be dereferenced once statement has finished executing therefore would be no need to explicitly do it.
(function () {
    var foo = globalObject;

    foo.bar = function () {
        //code here
    }
    delete foo;
}());

What is going on here?

A: See this article on when To and Not To use the delete operator.
This does not appear to be a proper use.
Local variables cannot be deleted as they are marked internally with the DontDelete attribute. There are occasions when you might want to clear a local variable (if you want to release any memory used by it and the scope may survive indefinitely in a closure), but you don't use the delete operator for this purpose - you can just set it to null.
In normal functions that don't create closures, any local variables will simply be garbage collected when the function completes and if there are no other references to their data in other code, that data will be freed by the garbage collector.
The only time you need to worry about clearing references to data is when you have a scope that will exist for a long duration of time (closure or global) and you no longer need that data and it's useful to free up its memory usage.
FYI, the most common use of the delete operator is to remove a property from an object as in:
var foo = {x: 1, y: 2};
delete foo.x;


text:
Q: How to place others name object to last position of the array? I have a object of array  which is give below -
arrayData = [
{label:"data",value:"data"},
{label:"data",value:"data"},
{label:"Others",value:"Others"},
{label:"data",value:"data"},
]

and want to shift the others object at the last position of the array and i also don't know the index value of that object.
Thankyou

A: You can filter it out first and push then into the end:

var arrayData = [
  {label:"data",value:"data"},
  {label:"data",value:"data"},
  {label:"Others",value:"Others"},
  {label:"data",value:"data"},
]

var res = arrayData.filter(x => x.label !== 'Others');
res.push(arrayData.find(x => x.label === 'Others'));

console.log(res);

A: You could get the index first, splice this item and push the spreaded array.

var array = [{ label: "data", value: "data" }, { label: "data", value: "data" }, { label: "Others", value: "Others" }, { label: "data", value: "data" }],
    index = array.findIndex(({ value }) => value === 'Others');

array.push(...array.splice(index, 1));

console.log(array);
.as-console-wrapper { max-height: 100% !important; top: 0; }

A:
i also don't know the index value of that object

for that you can use findIndex. First get the index of the required object , and in another variable get the last object in the array. Then swap their place

var arrayData = [{
    label: "data",
    value: "data"
  },
  {
    label: "data",
    value: "data"
  },
  {
    label: "Others",
    value: "Others"
  },
  {
    label: "data",
    value: "data"
  },
]

let findIndex = arrayData.findIndex(function(item) {
  return item.label === 'Others' && item.value === 'Others'
})
let storeLastVal = arrayData[arrayData.length - 1];
let otherVal = arrayData[findIndex]
arrayData[findIndex] = storeLastVal;
arrayData[arrayData.length - 1] = otherVal;
console.log(arrayData)

A: Well you can first parse the array and create two arrays, one with the elements that will stay in place, the other with the elements that will be placed at the end. Then you can join those 2 arrays.
arrayData = [
{label:"data",value:"data"},
{label:"data",value:"data"},
{label:"Others",value:"Others"},
{label:"data",value:"data"},
]

var startValues = [];
var endValues = [];

arrayData.forEach((value) => {
  if (value.label === "Others") {
    endValues.push(value);
  } else {
    startValues.push(value);
  }
});

arrayData = startValues.concat(endValues);

A: Or you can use recursion. This program has a distinct advantage in that it doesn't have to find the element (or index) before beginning the computation -

const data =
  [ { label: "data", value: "data" }
  , { label: "data", value: "data" }
  , { label: "Others", value: "Others" }
  , { label: "data", value: "data" }
  ]

const transform = ([ a, ...rest ]) =>
  a === undefined
    ? []
    : a.label === "Others"
        ? [ ...transform (rest), a ]
        : [ a, ...transform (rest) ]

console .log (transform(data))
// [ { label: "data", value: "data" }
// , { label: "data", value: "data" }
// , { label: "data", value: "data" }
// , { label: "Others", value: "Others" }
// ]

Obviously you should probably make "Others" a parameter of the function -

const data =
  [ { label: "data", value: "data" }
  , { label: "data", value: "data" }
  , { label: "Others", value: "Others" }
  , { label: "data", value: "data" }
  ]

const transform = (query, [ a, ...rest ]) =>
  a === undefined
    ? []
    : a.label === query
        ? [ ...transform (query, rest), a ]
        : [ a, ...transform (query, rest) ]

console .log (transform ("Others", data))
// [ { label: "data", value: "data" }
// , { label: "data", value: "data" }
// , { label: "data", value: "data" }
// , { label: "Others", value: "Others" }
// ]

console .log (transform ("data", data))
// [ { label: "Others", value: "Others" }
// , { label: "data", value: "data" }
// , { label: "data", value: "data" }
// , { label: "data", value: "data" }
// ]

Note, the original input is not mutated. If multiple labels are found matching the query, all of them will be moved to the end of the array.


text:
Q: Using vertex shader to move texture to pixel center I am trying to move my texture to the center of the pixel as stated here OpenGL Texture Coordinates in Pixel Space but am struggling to do so. Are the pixels we are trying to center on in the texture or on the screen? How do we access them? Here is my vertex shader:
"uniform mat4 " + ShaderProgramConstants.UNIFORM_MODELVIEWPROJECTIONMATRIX + ";\n" +
"attribute vec4 " + ShaderProgramConstants.ATTRIBUTE_POSITION + ";\n" +
"attribute vec4 " + ShaderProgramConstants.ATTRIBUTE_COLOR + ";\n" +
"attribute vec2 " + ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES + ";\n" +
"varying vec4 " + ShaderProgramConstants.VARYING_COLOR + ";\n" +
"varying vec2 " + ShaderProgramConstants.VARYING_TEXTURECOORDINATES + ";\n" +

"void main() {\n" +
"   " + ShaderProgramConstants.VARYING_COLOR + " = " + ShaderProgramConstants.ATTRIBUTE_COLOR + ";\n" +
"   " + ShaderProgramConstants.VARYING_TEXTURECOORDINATES + " = " + ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES + ";\n" +
    "   gl_Position = " + ShaderProgramConstants.UNIFORM_MODELVIEWPROJECTIONMATRIX + " * " + ShaderProgramConstants.ATTRIBUTE_POSITION + ";\n" +
"}"

I am new to open GL and have just started doing research on vertex shaders, so any suggestion or tip would be much appreciated.
EDIT: The problem I experience, is that the pixels from my texture get deformed when scaled. Normal textures look fine, but when they are scaled using the scaleM command on the 4x4 Matrix (Model view matrix), then it looks like there are two columns or two rows of the same pixels in random rows and columns.

A: Turns out the scale factor was causing the distortion. All I had to do was make sure that each pixel in the texture had the same amount of pixels on the display, and the distortions disappeared.


text:
Q: Utilizing Sphinx with reStructuredText formatted docstrings According to the writing docstrings tutorial of Sphinx, it is possible to utilize Sphinx's autodoc extension to automatically generate documentation. We can either write docstring with the Sphinx format, Google or Numpy (the latter two with the napoleon extension).
Is it possible to write docstrings in reStructuredText format?
e.g.:
"""[Summary]

Extended description of function.

:param int arg1: Description of arg1.
:param str arg2: Description of arg2.
:raise: ValueError if arg1 is equal to arg2
:return: Description of return value
:rtype: bool
"""

For comparison, this is Sphinx native format:
"""[Summary]

:param [ParamName]: [ParamDescription], defaults to [DefaultParamVal]
:type [ParamName]: [ParamType](, optional)
...
:raises [ErrorType]: [ErrorDescription]
...
:return: [ReturnDescription]
:rtype: [ReturnType]
"""

Comparison of docstrings

A: The two formats are actually the same. This can be confusing but what's called the Info field lists can be considered the reST docstring syntax. If you look carefully at the version number it's been around since Sphinx version 0.4, next if we look at the current Sphinx change list it remits to a change list that predates version 1.0... The earliest mention there is:

Release 0.4 (Jun 23, 2008)
==========================

*

*Sphinx now interprets field lists with fields like :param foo:   in description units.

If we want to dig further back to the definition of the reST docstring syntax the archives of the Doc-SIG - Python Documentation Special Interest Group would be the way to go, but a good enough overview is given by PEP 256 - Rationale dated 01-Jun-2001. The document that emerged from then and is most frequently cited only makes a loose recommendation:

PEP 257 -- Docstring Conventions
Python is case sensitive and the argument names can be used for keyword arguments, so the docstring should document the correct argument names. It is best to list each argument on a separate line.

To summarize things, the reST docstring syntax consists simply of using reST Field Lists! (the NumPy and Google styles are just different styles of also writing reST Field Lists)!

Field List - reStructuredText Markup Specification
Field lists are mappings from field names to field bodies,
(...)
The interpretation of individual words in a multi-word field name is up to the application. The application may specify a syntax for the field name.
Syntax diagram (simplified):
+--------------------+----------------------+
| ":" field name ":" | field body           |
+-------+------------+                      |
        | (body elements)+                  |
        +-----------------------------------+

It's up to the application to specify the syntax of the field names; so what Sphinx documentation generator specifies for the 2 example syntaxes in the question is that they are equivalent (this does not necessarily hold if you change to a different documentation generator).

A: Thanks to @mzjin's answer in the comments: this link describes that it is possible since v0.4.
The below example is given in the link, which is exactly what I was looking for.
py:function:: send_message(sender, recipient, message_body, [priority=1])
   """
   Send a message to a recipient

   :param str sender: The person sending the message
   :param str recipient: The recipient of the message
   :param str message_body: The body of the message
   :param priority: The priority of the message, can be a number 1-5
   :type priority: integer or None
   :return: the message id
   :rtype: int
   :raises ValueError: if the message_body exceeds 160 characters
   :raises TypeError: if the message_body is not a basestring
   """


text:
Q: How to have different divs on different positions? I am going to the following positions for my divs:

*

*If I have two divs, they should be located in the middle of the page

*If I have three divs, they should be located in one row

*If I have four divs,  three of them should be in one row and the last one should be in the next row in the left

*If I have five divs, three of them should be in one row and  the two last ones should be in the next row in the middle

My problem is the when I have four divs, the last one is in the middle of the next row.
This is my code:
HTML

CSS
.mt60 {
margin-top: 60px;
text-align: center;
}

.card-container-outer {
width: 480px;
}

.card-container {
margin-left: auto;
margin-right: auto;
width: 310px;
height: 510px;
position: relative;
}

A: (Tip : margin: 0 auto; is better than margin-left and margin-right auto)
You can center the first line and align left the last by putting this on the container :
text-align: center;
text-align-last: left;

A: You could possibly make these containers a little more malleable with display:inline-block with the full container being text-align:center - they will build on one another this way. Then if you write a small amount of jQuery to check for how many "containers" there are to assign the last element its alignment property.
var number = $('#containers').length();
if(number===4){
  $('#containers').last().css(//change the css properties to make the last div float left)
}

You could put a number of different if/else parameters in there to determine what the alignment should be.


text:
Q: Javascript Issue with the document.form I am trying to run the code but i do not know what is causing the issue. It was working before, now when i try like this:
function makeUnderline(formName,editor) {
    var txt = window.prompt("Enter the text you wish to be underlined.", "Enter Text Here");
    if (txt != null) {
        document.formName.editor.value += "" + txt + "";
    }
    document.formName.editor.focus();
}

<input type="button" name="bUnderline" value=" underline " onClick="makeUnderline('formFaqs','answer');" alt="Use this button to create text that is underlined." title="Use
this button to create text that is underlined.">

I am getting Error:
TypeError: document.formName is undefined

document.formName.editor.value += "" + txt + "";

A: You are passing in the form name as a variable, you need to use bracket notation.
document.forms[formName].elements[editor].value += "" + txt + "";


text:
Q: TableModel Change the value of a jcheckbox cell after a second click in other checkbox I have a table with a checkbox column, I am able to show the table like i want and I make editable just the column where the checkbox is placed. The problem is when I select the checkbox the render paint in the right way the checkbox but the value in the tablemodel isn't changed, this value just change until i give click in another checkbox, always the last checkbox that I choose doesn't reflects his value in the TableModel. The classes that I am using are:
Checkcell
class CheckCell extends DefaultCellEditor implements TableCellRenderer{

    private JComponent component = new JCheckBox();
    private boolean value = false;

    public CheckCell() {
        super(new JCheckBox());
    }

    @Override
    public Object getCellEditorValue() {
        return ((JCheckBox)component).isSelected();
    }

    @Override
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {

        ( (JCheckBox) component).setBackground( new Color(200,200,0) );

        boolean b = ((Boolean) value).booleanValue();
        ( (JCheckBox) component).setSelected( b );
        ( (JCheckBox) component).setHorizontalAlignment(SwingConstants.CENTER);
        return ( (JCheckBox) component);
    }

    @Override
    public boolean stopCellEditing() {
        value = ((Boolean)getCellEditorValue()).booleanValue() ;
        ((JCheckBox)component).setSelected( value );
        return super.stopCellEditing();
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        if (value == null)
            return null;
         return ( (JCheckBox) component );
    }

}

CheckRender
class CheckRender extends JCheckBox implements TableCellRenderer {

    private JComponent component = new JCheckBox();

    public CheckRender() {
        setOpaque(true);
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

       ((JCheckBox) component).setBackground( new Color(0,200,0));

       boolean b = ((Boolean) value).booleanValue();
       ((JCheckBox) component).setSelected(b);
       ((JCheckBox) component).setHorizontalAlignment(SwingConstants.CENTER);
       return ((JCheckBox) component);
    }

}

My Model
class DynaTableModel extends DefaultTableModel {

    public DynaTableModel() {
        super();
    }

    public DynaTableModel(final DynaTableBean dynaBean) {
        super(dynaBean.getContent(), dynaBean.getHeaders());
    }

    @Override
    public boolean isCellEditable(int row, int col) {
        if (col == 0)
        {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public void setValueAt(Object value, int row, int column) {
        super.setValueAt(value, row, column);
    }

Could you help me with this? what is missing me to change the value in the jtable when this change in the checkbox.
I am new in java and I think that there are something that is missing me.
Thanks in advanced.

Being a little more explicity, when I ticked the checkbox and I tried to recover the value from the TableModel the value is wrong by example if I ticked the first checkbox and I tried to recover the value using:
valor = (Boolean) tablemodel.getValueAt(i, 0);
I am getting false when this should be true, but if I check the first checkbox and later the second one the value of the first checkbox now is fine(true) but the second is still false is a kind of bug but I don't find the way to avoid this.
Someone knows how to avoid this.

A:
I have a table with a checkbox column, I am able to show the table
  like i want and I make editable just the column where the checkbox is
  placed. The problem is when I select the checkbox the render paint in
  the right way the checkbox but the value in the tablemodel isn't
  changed, this value just change until i give click in another
  checkbox, always the last checkbox that I choose doesn't reflects his
  value in the TableModel

*

*JTable has built in support for JCheckBox as TableCellRenderer and Editor

*Boolean value represens JCheckBox in XxxTableModel, you would need to put there true or false (1st column)

*override public Class getColumnClass(int c) {,


text:
Q: Why can't I talk to Baldor Iron-Shaper? I have defeated the Thalmor on the ship and gotten the map for the quest "A New Source of Stahlrim," but when I try to take the map back to Baldor, it won't let me talk to him.  Instead, he just does the normal NPC dialogue thing, where he says random things and doesn't let you actually tell him anything.  Why does it do this, and how can I fix it?  I am tired of going into my inventory to drop or store things I don't need and trying to drop the map and not being able to!

A: If you have not completed the main questline and defeated Miraak, you cannot accept any new missions from the Skaal or complete any missions that you may have already received.


text:
Q: Given $n\in\mathbb N$ what are the maximum number of divisors of a natural number not more than $n$? So the question is in the title itself. The minimum number of divisors are $2$ (for primes), but the maximum number of divisors are what we are interested in. It cannot be more than the number itself for sure, so it's bounded above by $n$.
We know that the number of divisors of $\prod_{i=1}^jp_i^{k_i}$, where $p_i$'s are distinct primes is given by $\prod_{i=1}^j(k_i+1)$. We have to maximize this given the constraint that $\prod_{i=1}^jp_i^{k_i}\le n$.


text:
Q: How should I use Google APIs in this scenario? In our company we run a number of different websites which are being tracked with Google Analytics (GA). Up to this point we have been using the Login protocol and GData to access GA data to display the data nicely on our custom web application dash boarded which we use for tracking traffic on our sites.
Nowadays Google has Google API Console which lets you track your API usage. We want to take advantage of this service to view howmuch APIs we consume. However from what we can understand it requires us to use OAuth for authentication instead of the username and password we currently use to access the data. We don't like OAuth because it redirects the user to Google for authentication when currently the user has no need to know about where the data is coming from and what credentials are needed.
Is there anyway that we could make Google API Console monitor our usage without having to switch from GData and the Login protocol?

A: You can switch to the OAuth 2 protocol and use a refresh token for offline access. Once you get the refresh token, you can save it to a file or database and use that to access the data without an authorization redirect.
See the docs here: https://developers.google.com/accounts/docs/OAuth2InstalledApp#refresh
Also see where there is discussion of using the refresh token: How can we access specific Google Analytics account data using API?


text:
Q: Loading src package in composer So i have a composer package i am developing and i want to unit test the package without creating a new composer package for actually unit testing it. Is there any way to load the files in the autoload_classmap.php so they are accessible without creating a new package and including it there and then testing it?
For when i just have one package the files in the src folder is not load in the autoload_classmap.php at the path vendor/composer
What is strange here is that when i include the package in another repo it loads all the files correctly into the autoload_classmap.php file.
The autoload_psr4 package looks like this :
'Nyranith\' => array($baseDir . '/src')
But there is still no files from the $basedir in the autoload_classmap.php.
On of the classes is like this:
namespace Nyranith\Models;

trait CompositPrimaryKey
{

the path to this file is: src/Models/CompositPrimaryKey.php
The autoload in the composer.json looks like this:
"autoload": {
        "psr-4": { "Nyranith\\": "src/"
        }
    },

A: In case of psr4, composer just uses path's listened in autoload_psr4.php to load all files from specified folder. So there is no need to have those classes in autoload_classmap.php
If you have already configured your composer.json for psr4 files, then just include vendor/autoload.php in the front controller of your application (usually index.php)


text:
Q: How can I move files from one folder to another created at specific date giving the creation date in redhat I am trying to use terminal to move files from one folder to another using creation date.
I am using the script
find /root/call_log/files23 -type f -newermt 2022-06-01 -not -newermt 2022-06-02 -exec mv {} /archive

/root/call_log/files23 is location ...
/archive is destination
but getting an error missing argument -exec. How can i fix it or is there a better way of doing it

A: man find gives me following information:

-cnewer reference

Time  of the last status change of the current file is more recent than that of the last data modification of the reference file.  If reference is a symbolic link and the -H option or the -L option  is  in effect, then the time of the last data modification of the file it points to is always used.

I propose you use this instead of -newermt.

A: If you want to move all files in a given folder according to when they were created and not according to the last change, this command will do the work:
find /path/to/source/directory -type f -newermt YYYY-MM-DD -exec mv {} /path/to/target/directory \;

Just replace /path/to/source/directory and /path/to/target/directory with proper absolute locations.
YYYY-MM-DD replace with the desired creation date.


text:
Q: Can we have a div having aria-role = navigation inside a div having aria-role = navigation Is this a valid scenario:
Code:

Having a role navigation inside a div having role navigation. Is it a valid scenario and is it valid under design pattern followed? Is it a good practice or should i replace inner role as region

A: Can you do that?  Yes, it's not invalid html.  The navigation role and the  element have a content model that allows nested roles as long as the nested role is not main.
Keep in mind that the navigation role and  element are landmark roles so they will allow a screen reader user to jump to that section.  Having too many landmarks on your page starts to diminish the usefulness of landmarks.
Given the limited info on your scenario, it's difficult to say whether you should be doing this.


text:
Q: Missing packages while creating a diagnostic analyzer using Roslyn To clarify: I'm using Visual Studio 2013 Ultimate, Update 2
I'm trying to create a diagnostic analyzer using Roslyn.
The sample code for a diagnostic analyzer (located here declares such an analyzer in this way:
[DiagnosticAnalyzer(LanguageNames.CSharp)]
internal class DiagnosticAnalyzer : Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer

However when I try to recreate this I cannot find the class DiagnosticAnalyzer in Microsoft.CodeAnalysis.Diagnostics (however IDiagnosticAnalyzer does exist in the same namespace).
Some samples here on StackOverflow instead use (such as this one)
[DiagnosticAnalyzer]
[ExportDiagnosticAnalyzer(DiagnosticId, LanguageNames.CSharp)]
internal class DiagnosticAnalyzer : ISyntaxTreeAnalyzer

However in this case I cannot find the ExportDiagnosticAnalyzer attribute. It seems I'm missing an assembly. Using NuGet I have installed the following packages:
<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.Bcl.Immutable" version="1.1.20-beta" targetFramework="net45" />
  <package id="Microsoft.Bcl.Metadata" version="1.0.12-alpha" targetFramework="net45" />
  <package id="Microsoft.CodeAnalysis" version="0.7.4091001-beta" targetFramework="net45" />
  <package id="Microsoft.CodeAnalysis.Common" version="0.7.4091001-beta" targetFramework="net45" />
  <package id="Microsoft.CodeAnalysis.CSharp" version="0.7.4091001-beta" targetFramework="net45" />
  <package id="Microsoft.CodeAnalysis.CSharp.Workspaces" version="0.7.4091001-beta" targetFramework="net45" />
  <package id="Microsoft.CodeAnalysis.VisualBasic" version="0.7.4091001-beta" targetFramework="net45" />
  <package id="Microsoft.CodeAnalysis.VisualBasic.Workspaces" version="0.7.4091001-beta" targetFramework="net45" />
  <package id="Microsoft.CodeAnalysis.Workspaces.Common" version="0.7.4091001-beta" targetFramework="net45" />
</packages>

Which as far as I could find, also by inspecting packages.config from the samples, should be everything I need.
When I inspect my C# project's references I have referenced the following non-standard assemblies:

*

*Microsoft.CodeAnalysis

*Microsoft.CodeAnalysis.CSharp

*Microsoft.CodeAnalysis.CSharp.Desktop

*Microsoft.CodeAnalysis.CSharp.Workspaces

*Microsoft.CodeAnalysis.Desktop

*Microsoft.CodeAnalysisWorkspaces

*Microsoft.CSharp

My question is, what am I missing that I can't find all the classes I need to create a diagnostic analyzer?

A: So a month or two ago we completely changed our API for doing analyzers. (Don't worry, it was worth the trouble: the new API is a lot nicer.) When you're looking at the current source code in CodePlex, you're seeing stuff so new that we haven't even shipped it yet on NuGet. I strongly recommend you use a Visual Studio "14" CTP and download the templates to match it, which will set you up in a place that should work. Trying to use current NuGet packages against old previews is going to result in sadness.
ExportDiagnosticAnalyzer is obsolete, the [DiagnosticAnalyzer] attribute is sufficient now.

A: VS 2013 no longer receives updates for interfacing between Visual Studio and Roslyn. It's still possible to use VS 2013, but you'll have to use older versions of the NuGet package.
Install-Package Microsoft.CodeAnalysis -Version 0.6.4033103-beta -Pre

If you use the above, you're at a number of disadvantages. The appropriate documentation/samples may no longer exist, and the Roslyn Reference source likely differs in subtle ways.
As Jason suggested, it might be easier to simply move to VS 14. Of course this likely prevents you from using your diagnostics within your organization until VS 14 releases (date still publicly unknown).


text:
Q: Can't get suds to read my load balancer's SOAP API I'm very new to SOAP and am just trying to get the basics working with "suds". I'm running the following code:
import sys
from suds.client import Client
url='http://loadbalancer/wsdl/sys_service.wsdl'
client = Client(url)

If I run 'print client' in my interpreter, I get the following:
Suds ( https://fedorahosted.org/suds/ )  version: 0.4.1 (beta)  build: R705-20101207
Service ( AdcSysInfo ) tns="urn:webservicesapi"
Prefixes (1)
  ns0 = "urn:webservicesapi"
Ports (1):
  (AdcSysInfoSOAP)
     Methods (61):
    ....
    (many methods come back, truncated the output)
    getCPU()
    ....

I just want to focus on the getCPU method for now, so I run this statement in my interpreter:
example = client.service.getCPU()

But I get the following output back:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/suds/client.py", line 542, in __call__
return client.invoke(args, kwargs)
File "/usr/lib/python2.6/site-packages/suds/client.py", line 602, in invoke
result = self.send(soapenv)
File "/usr/lib/python2.6/site-packages/suds/client.py", line 643, in send
reply = transport.send(request)
File "/usr/lib/python2.6/site-packages/suds/transport/https.py", line 64, in send
return  HttpTransport.send(self, request)
File "/usr/lib/python2.6/site-packages/suds/transport/http.py", line 77, in send
fp = self.u2open(u2request)
File "/usr/lib/python2.6/site-packages/suds/transport/http.py", line 118, in u2open
return url.open(u2request, timeout=tm)
File "/usr/lib64/python2.6/urllib2.py", line 391, in open
response = self._open(req, data)
File "/usr/lib64/python2.6/urllib2.py", line 414, in _open
'unknown_open', req)
File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/lib64/python2.6/urllib2.py", line 1223, in unknown_open
raise URLError('unknown url type: %s' % type)
urllib2.URLError: <urlopen error unknown url type: urlprefix>

Any idea what I am doing wrong? Thanks.

A: Have you tried using https://pypi.python.org/pypi/suds-jurko ?
It may be more up-to-date than plain suds.


text:
Q: C# .Net WinForms app: anonymous collection- how to caste return type Seems like this is a recorring problem for me.  I am again having a problem with casting type when I use an anonymous collection. My query from the XML file returns a collection of string values.  I am trying to return these values from my data access layer to my business logic layer.  Thanks in advance.
    public string[] getCustDetails(string customerId)
    {
        //Pulls customer information for selected customer
        var doc = XDocument.Load("Portfolio.xml");
        var custRecord = from account in doc.Descendants("acct")
                         let acct = account.Element("acct")
                         where (string)account.Attribute("custid").Value == customerId
                         select new
                         {
                             Fname = (string)account.Attribute("fname").Value,
                             Lname = (string)account.Attribute("lname").Value,
                             Ssn = (string)account.Attribute("ssn").Value,
                             Dob = (string)account.Attribute("dob").Value,
                             Custid = (string)account.Attribute("custid").Value
                         };
return ?????

    }

A: You can't use anonymous types are either parameters to a method or a return type.
I suggest creating a simple class with the properties you need and use that instead of an anonymous type.
public class AccountDetails
{
  public string FName { get; set; }
  public string LName { get; set; }
  public string Ssn { get; set; }
  public string Dob { get; set; }
  public string Custid { get; set; }
}

public IEnumerable<AccountDetails> getCustDetails(string customerId)
{
    //Pulls customer information for selected customer
    var doc = XDocument.Load("Portfolio.xml");
    var custRecords = from account in doc.Descendants("acct")
                     let acct = account.Element("acct")
                     where (string)account.Attribute("custid").Value == customerId
                     select new AccountDetails
                     {
                         Fname = (string)account.Attribute("fname").Value,
                         Lname = (string)account.Attribute("lname").Value,
                         Ssn = (string)account.Attribute("ssn").Value,
                         Dob = (string)account.Attribute("dob").Value,
                         Custid = (string)account.Attribute("custid").Value
                     };

    return custRecords;
}

A: create new class for the requirement and return it as a list...
    public MyClass[] getCustDetails(string customerId)
    {
        //Pulls customer information for selected customer
        var doc = XDocument.Load("Portfolio.xml");
        var custRecord = (from account in doc.Descendants("acct")
                         let acct = account.Element("acct")
                         where (string)account.Attribute("custid").Value == customerId
                         select new MyClass
                         {
                             Fname = (string)account.Attribute("fname").Value,
                             Lname = (string)account.Attribute("lname").Value,
                             Ssn = (string)account.Attribute("ssn").Value,
                             Dob = (string)account.Attribute("dob").Value,
                             Custid = (string)account.Attribute("custid").Value
                         }).ToArray();
   return custRecord;

    }

define your class as
public class MyClass
{
    public string Fname  { get; set; }
    public string Lname { get; set; }
    public string Ssn { get; set; }
    public string Dob { get; set; }
    public string Custid { get; set; }
}

A: I would create a new class containing the following properties.
 string Fname
 string Lname
 string Ssn
 string Dob
 string Custid

Then return this type from your getCustDetails() method


text:
Q: How to write my own custom compression logic in apache server Im doing some project for compressing the web traffic, that is the data send from server to browser.
So like other http compression techniques like gzip or sdcp, i want to compress the data before sending it from server. But i have no idea about writing such a module in apache.
Can any one guide me?
I have written a proxy server at the browser side which decompress the data compressed by my logic.

A: Compress it in a servlet filter and stream it back, but... really? Your compression is better/faster/etc. than standard gzip? Is it enough faster to want to bother?


text:
Q: Validating python regex flags specified in json I am writing a tool which accepts user configuration via a json file. One piece of this config is a python regular expression and some optional regex flags. Currently the configuration for the regex flags is an array of integers which will all be run through a bitwise or (|) and sent to the re compile method.
My question is how can I validate these integers to ensure that they are valid re flags?
EDIT: Or potentially another solution to my problem... Is it possible for the user to specify the actual re flags in the JSON? I.e., [re.DEBUG, re.IGNORECASE] etc etc and then somehow translate those from the JSON file in my python script?

A: You can define a dictionary of all possible flags (they are really few, see re 6.2.2. Module Contents), and just get the value by the corresponding key.
A Python demo:
import re
re_flags = { 're.A' : re.A,
    're.ASCII' : re.ASCII,
    're.DEBUG' : re.DEBUG,
    're.I' : re.I,
    're.IGNORECASE' : re.IGNORECASE,
    're.L' : re.L,
    're.LOCALE' : re.LOCALE,
    're.M' : re.M,
    're.MULTILINE' : re.MULTILINE,
    're.S' : re.S,
    're.DOTALL' : re.DOTALL,
    're.X' : re.X,
    're.VERBOSE' : re.VERBOSE }
flg = 're.I'                      # User input
if flg in re_flags:               # If the dict contains the key
    print(re_flags[flg])          # Print the value (re.I = 2)

If you still want to go with numbers instead:
import re
print(re.A)           # 256
print(re.ASCII)       # 256
print(re.DEBUG)       # 128
print(re.I)           # 2
print(re.IGNORECASE)  # 2
print(re.L)           # 4
print(re.LOCALE)      # 4
print(re.M)           # 8
print(re.MULTILINE)   # 8
print(re.S)           # 16
print(re.DOTALL)      # 16
print(re.X)           # 64
print(re.VERBOSE)     # 64


text:
Q: Start WildFly with nohup standalone full I want to start the WildFly 11 using the standalone-full.xml instead standalone.xml.
So I have to execute the command:
sh standalone.sh -c standalone-full.xml

inside folder wildfly-11.0.0.Final/bin/.
But if I want to start the WildFly in silence mode with nohup, it doesn't start with parameter -c standalone-full.xml.
I tried with:
nohup ./standalone.sh  -b 0.0.0.0 -c standalone-full.xml >/dev/null 2>&1 &

But it does not work.
What is the correct command to start WildFly with standalone-full.xml in silence mode in Linux?
Server information: cat /etc/*-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.4 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.4"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.4 (Maipo)"
CPE_NAME="cpe:/o:redhat:enterprise_linux:7.4:GA:server"

Thanks.

A: Use the below cammand.
nohup sh standalone.sh -c standalone-full.xml > /dev/null &


text:
Q: How can I show $G_0$ and $G_1$ are conjugate subgroups? Let $E$ be path-connected. Let $p : E → B$ be a covering map and $p_∗$ be the induced
homomorphism from the fundamental group of $E$ to the fundamental group of $B$. Let $e_o$ and $e_1$ be points in E such that $p(e_0) = p(e_1) = b$. Consider the subgroups $G_0 = p_∗π_1(E, e_0)$ and $G_1 = p_∗π_1(E, e_1)$.
How can I prove that there exists $γ ∈ π_1(B, b)$ such that every $σ ∈ G_0$ can be written uniquely in the form $γτ γ^{-1}$ for some $τ ∈ G_1$?

A: I like to do such situations in the algebraic setting of covering morphisms of groupoids, see Chapter $10$ of the book Topology and Groupoids. So if $p:E \to B$ is a covering map of spaces then $\pi_1 p: \pi_1 E \to \pi_1 B$ is a covering morphism of groupoids. So  $q: H \to G$ is a covering morphism of groupoids if for each $e \in Ob(H)$ and each $g: p(e) \to b$ in $G$ there is a unique $h: e \to e'$ in $H$ such that $q(h)=g$. This easily implies that a composable sequence $g_1, \ldots,g_n$ starting at $b$ has a unique lift to a composable sequence $(h_1,\ldots,h_n) $ starting at $e$ of elements of $H$ such that $q(h_i)=g_i, i=1, \ldots, n$.
Now suppose $H$ is connected and $q(e_0)=q(e_1)=b$. Since $H$ is connected there is an element $h: e_0 \to e_1$ of $H$. Let $\gamma=q(h): b \to b$. Let $G_i= q(H(e_i)), i=0$, where $H(e)$ is the group of elements of $H$ which are $e \to e$. We know by unique lifting that $q$ is injective on $H(e)$.
Let $\sigma \in G_0$. You should now be able to use unique lifting to prove the result you want. Draw a picture of the situation in $H$.


text:
Q: Webpages not served during large file transfers (IIS7.5 + PHP) For some reason, our webserver is not responding while it's serving large files.
We use the windows platform, because we need to remotely call Win32 applications in order to generate the file that is to be served. This file is served through PHP's function: fpassthru, using this code:
if (file_exists($file)) {

$handle = @fopen($file, "rb");
header('Content-Description: File Transfer');
header('Content-Type: video/mp4');
if($stream==0){
    header('Content-Disposition: attachment; filename='.basename($filename.".mp4"));
}

header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($file));

ob_end_clean();

fpassthru($handle);

exit;

}

These files are often over 1GB in size and takes a while to transfer, but during this time, the webserver will not serve any pages. My firefox indicates it's 'connecting' but nothing else. Note that somebody else is transferring this file, not me, so different IP, different session.
Any clue where to look? Obviously, it's intolerable to have to wait 5 minutes for a website.
Thanks in advance!

A: This is commonly caused when you do not close the session before you begin sending the file data. This is because the session cache file can only be opened by one PHP process at a time, therefore the download is effectively blocking all other PHP processes at session_start().
The solution is to call session_write_close() to commit the session data to disk and close the file handle before you start outputting the file data.


text:
Q: linking with c binding of library I'm trying to link with the next library:(see docs)
It's a C binding for a lib written in C++. But if make static lib and then try to link to it.
I get these messages:
uchardet//libuchardet.a(uchardet.cpp.o): In function `uchardet_new':
uchardet.cpp:(.text+0x19): undefined reference to `operator new(unsigned long)'
uchardet.cpp:(.text+0x3c): undefined reference to `std::string::_Rep::_S_empty_rep_storage'
uchardet.cpp:(.text+0x4b): undefined reference to `std::string::assign(char const*, unsigned long)'
uchardet.cpp:(.text+0x6c): undefined reference to `operator delete(void*)'
uchardet.cpp:(.text+0x7f): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
uchardet//libuchardet.a(uchardet.cpp.o): In function `HandleUniversalDetector::Reset()':
uchardet.cpp:(.text._ZN23HandleUniversalDetector5ResetEv[_ZN23HandleUniversalDetector5ResetEv]+0x16): undefined reference to `std::string::assign(char const*, unsigned long)'
uchardet//libuchardet.a(uchardet.cpp.o): In function `HandleUniversalDetector::Report(char const*)':
uchardet.cpp:(.text._ZN23HandleUniversalDetector6ReportEPKc[_ZN23HandleUniversalDetector6ReportEPKc]+0x35): undefined reference to `std::string::assign(char const*, unsigned long)'
uchardet//libuchardet.a(uchardet.cpp.o): In function `HandleUniversalDetector::~HandleUniversalDetector()':
uchardet.cpp:(.text._ZN23HandleUniversalDetectorD2Ev[_ZN23HandleUniversalDetectorD5Ev]+0x1a): undefined reference to `std::string::_Rep::_S_empty_rep_storage'
uchardet.cpp:(.text._ZN23HandleUniversalDetectorD2Ev[_ZN23HandleUniversalDetectorD5Ev]+0x4d): undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
uchardet//libuchardet.a(uchardet.cpp.o): In function `HandleUniversalDetector::~HandleUniversalDetector()':
uchardet.cpp:(.text._ZN23HandleUniversalDetectorD0Ev[_ZN23HandleUniversalDetectorD0Ev]+0x1a): undefined reference to `std::string::_Rep::_S_empty_rep_storage'
uchardet.cpp:(.text._ZN23HandleUniversalDetectorD0Ev[_ZN23HandleUniversalDetectorD0Ev]+0x2c): undefined reference to `operator delete(void*)'
uchardet.cpp:(.text._ZN23HandleUniversalDetectorD0Ev[_ZN23HandleUniversalDetectorD0Ev]+0x55): undefined reference to `std::string::_Rep::_M_destroy(std::allocator<char> const&)'
uchardet//libuchardet.a(uchardet.cpp.o):(.rodata._ZTI23HandleUniversalDetector[_ZTI23HandleUniversalDetector]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(uchardet.cpp.o):(.eh_frame+0xab): undefined reference to `__gxx_personality_v0'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o): In function `nsUniversalDetector::HandleData(char const*, unsigned int)':
nsUniversalDetector.cpp:(.text+0x368): undefined reference to `operator new(unsigned long)'
nsUniversalDetector.cpp:(.text+0x396): undefined reference to `operator new(unsigned long)'
nsUniversalDetector.cpp:(.text+0x3c6): undefined reference to `operator new(unsigned long)'
nsUniversalDetector.cpp:(.text+0x4eb): undefined reference to `operator new(unsigned long)'
nsUniversalDetector.cpp:(.text+0x527): undefined reference to `operator delete(void*)'
nsUniversalDetector.cpp:(.text+0x53a): undefined reference to `operator delete(void*)'
nsUniversalDetector.cpp:(.text+0x554): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o): In function `nsUniversalDetector::~nsUniversalDetector()':
nsUniversalDetector.cpp:(.text+0x5bc): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o): In function `nsCharSetProber::~nsCharSetProber()':
nsUniversalDetector.cpp:(.text._ZN15nsCharSetProberD0Ev[_ZN15nsCharSetProberD0Ev]+0x8): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTI19nsUniversalDetector[_ZTI19nsUniversalDetector]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTV19nsUniversalDetector[_ZTV19nsUniversalDetector]+0x30): undefined reference to `__cxa_pure_virtual'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTV15nsCharSetProber[_ZTV15nsCharSetProber]+0x20): undefined reference to `__cxa_pure_virtual'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTV15nsCharSetProber[_ZTV15nsCharSetProber]+0x28): undefined reference to `__cxa_pure_virtual'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTV15nsCharSetProber[_ZTV15nsCharSetProber]+0x30): undefined reference to `__cxa_pure_virtual'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTV15nsCharSetProber[_ZTV15nsCharSetProber]+0x38): undefined reference to `__cxa_pure_virtual'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTV15nsCharSetProber[_ZTV15nsCharSetProber]+0x40): more undefined references to `__cxa_pure_virtual' follow
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.rodata._ZTI15nsCharSetProber[_ZTI15nsCharSetProber]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
uchardet//libuchardet.a(nsUniversalDetector.cpp.o):(.eh_frame+0xbb): undefined reference to `__gxx_personality_v0'
uchardet//libuchardet.a(nsEscCharsetProber.cpp.o): In function `nsEscCharSetProber::~nsEscCharSetProber()':
nsEscCharsetProber.cpp:(.text+0x1a0): undefined reference to `operator delete(void*)'
nsEscCharsetProber.cpp:(.text+0x1a9): undefined reference to `operator delete(void*)'
nsEscCharsetProber.cpp:(.text+0x1b2): undefined reference to `operator delete(void*)'
nsEscCharsetProber.cpp:(.text+0x1bb): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEscCharsetProber.cpp.o): In function `nsEscCharSetProber::~nsEscCharSetProber()':
nsEscCharsetProber.cpp:(.text+0x1e0): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEscCharsetProber.cpp.o):nsEscCharsetProber.cpp:(.text+0x1e9): more undefined references to `operator delete(void*)' follow
uchardet//libuchardet.a(nsEscCharsetProber.cpp.o): In function `nsEscCharSetProber::nsEscCharSetProber(unsigned int)':
nsEscCharsetProber.cpp:(.text+0x276): undefined reference to `operator new(unsigned long)'
nsEscCharsetProber.cpp:(.text+0x296): undefined reference to `operator new(unsigned long)'
nsEscCharsetProber.cpp:(.text+0x2b6): undefined reference to `operator new(unsigned long)'
nsEscCharsetProber.cpp:(.text+0x2d2): undefined reference to `operator new(unsigned long)'
uchardet//libuchardet.a(nsEscCharsetProber.cpp.o): In function `nsEscCharSetProber::~nsEscCharSetProber()':
nsEscCharsetProber.cpp:(.text+0x20b): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEscCharsetProber.cpp.o):(.rodata._ZTI18nsEscCharSetProber[_ZTI18nsEscCharSetProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsEscCharsetProber.cpp.o):(.eh_frame+0x137): undefined reference to `__gxx_personality_v0'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o): In function `nsMBCSGroupProber::nsMBCSGroupProber(unsigned int)':
nsMBCSGroupProber.cpp:(.text+0x964): undefined reference to `operator new(unsigned long)'
nsMBCSGroupProber.cpp:(.text+0x97f): undefined reference to `operator new(unsigned long)'
nsMBCSGroupProber.cpp:(.text+0x9d0): undefined reference to `operator new(unsigned long)'
nsMBCSGroupProber.cpp:(.text+0x9f9): undefined reference to `operator new(unsigned long)'
nsMBCSGroupProber.cpp:(.text+0xa22): undefined reference to `operator new(unsigned long)'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o):nsMBCSGroupProber.cpp:(.text+0xa43): more undefined references to `operator new(unsigned long)' follow
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o): In function `nsMBCSGroupProber::nsMBCSGroupProber(unsigned int)':
nsMBCSGroupProber.cpp:(.text+0xd6b): undefined reference to `operator delete(void*)'
nsMBCSGroupProber.cpp:(.text+0xda5): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o): In function `nsMBCSGroupProber::~nsMBCSGroupProber()':
nsMBCSGroupProber.cpp:(.text+0x8f0): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o):(.rodata._ZTI17nsMBCSGroupProber[_ZTI17nsMBCSGroupProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o):(.rodata._ZTV23JapaneseContextAnalysis[_ZTV23JapaneseContextAnalysis]+0x10): undefined reference to `__cxa_pure_virtual'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o):(.rodata._ZTV23JapaneseContextAnalysis[_ZTV23JapaneseContextAnalysis]+0x18): undefined reference to `__cxa_pure_virtual'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o):(.rodata._ZTI23JapaneseContextAnalysis[_ZTI23JapaneseContextAnalysis]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
uchardet//libuchardet.a(nsMBCSGroupProber.cpp.o):(.eh_frame+0x67): undefined reference to `__gxx_personality_v0'
uchardet//libuchardet.a(nsSBCSGroupProber.cpp.o): In function `nsSBCSGroupProber::nsSBCSGroupProber()':
nsSBCSGroupProber.cpp:(.text+0xdf4): undefined reference to `operator new(unsigned long)'
nsSBCSGroupProber.cpp:(.text+0xe28): undefined reference to `operator new(unsigned long)'
nsSBCSGroupProber.cpp:(.text+0xe5c): undefined reference to `operator new(unsigned long)'
nsSBCSGroupProber.cpp:(.text+0xe90): undefined reference to `operator new(unsigned long)'
nsSBCSGroupProber.cpp:(.text+0xec4): undefined reference to `operator new(unsigned long)'
uchardet//libuchardet.a(nsSBCSGroupProber.cpp.o):nsSBCSGroupProber.cpp:(.text+0xef8): more undefined references to `operator new(unsigned long)' follow
uchardet//libuchardet.a(nsSBCSGroupProber.cpp.o): In function `nsSBCSGroupProber::nsSBCSGroupProber()':
nsSBCSGroupProber.cpp:(.text+0x13fb): undefined reference to `operator delete(void*)'
nsSBCSGroupProber.cpp:(.text+0x1422): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsSBCSGroupProber.cpp.o): In function `nsSBCSGroupProber::~nsSBCSGroupProber()':
nsSBCSGroupProber.cpp:(.text+0xdc9): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsSBCSGroupProber.cpp.o):(.rodata._ZTI17nsSBCSGroupProber[_ZTI17nsSBCSGroupProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsSBCSGroupProber.cpp.o):(.eh_frame+0x67): undefined reference to `__gxx_personality_v0'
uchardet//libuchardet.a(nsSBCharSetProber.cpp.o): In function `nsSingleByteCharSetProber::~nsSingleByteCharSetProber()':
nsSBCharSetProber.cpp:(.text._ZN25nsSingleByteCharSetProberD0Ev[_ZN25nsSingleByteCharSetProberD0Ev]+0x8): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsSBCharSetProber.cpp.o):(.rodata._ZTI25nsSingleByteCharSetProber[_ZTI25nsSingleByteCharSetProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsSJISProber.cpp.o): In function `nsSJISProber::~nsSJISProber()':
nsSJISProber.cpp:(.text._ZN12nsSJISProberD2Ev[_ZN12nsSJISProberD5Ev]+0x10): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsSJISProber.cpp.o): In function `nsSJISProber::~nsSJISProber()':
nsSJISProber.cpp:(.text._ZN12nsSJISProberD0Ev[_ZN12nsSJISProberD0Ev]+0x10): undefined reference to `operator delete(void*)'
nsSJISProber.cpp:(.text._ZN12nsSJISProberD0Ev[_ZN12nsSJISProberD0Ev]+0x20): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsSJISProber.cpp.o):(.rodata._ZTI12nsSJISProber[_ZTI12nsSJISProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsUTF8Prober.cpp.o): In function `nsUTF8Prober::~nsUTF8Prober()':
nsUTF8Prober.cpp:(.text._ZN12nsUTF8ProberD2Ev[_ZN12nsUTF8ProberD5Ev]+0x10): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsUTF8Prober.cpp.o): In function `nsUTF8Prober::~nsUTF8Prober()':
nsUTF8Prober.cpp:(.text._ZN12nsUTF8ProberD0Ev[_ZN12nsUTF8ProberD0Ev]+0x10): undefined reference to `operator delete(void*)'
nsUTF8Prober.cpp:(.text._ZN12nsUTF8ProberD0Ev[_ZN12nsUTF8ProberD0Ev]+0x20): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsUTF8Prober.cpp.o):(.rodata._ZTI12nsUTF8Prober[_ZTI12nsUTF8Prober]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsLatin1Prober.cpp.o): In function `nsLatin1Prober::~nsLatin1Prober()':
nsLatin1Prober.cpp:(.text._ZN14nsLatin1ProberD0Ev[_ZN14nsLatin1ProberD0Ev]+0x8): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsLatin1Prober.cpp.o):(.rodata._ZTI14nsLatin1Prober[_ZTI14nsLatin1Prober]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(CharDistribution.cpp.o):(.rodata._ZTI24CharDistributionAnalysis[_ZTI24CharDistributionAnalysis]+0x0): undefined reference to `vtable for __cxxabiv1::__class_type_info'
uchardet//libuchardet.a(CharDistribution.cpp.o):(.rodata._ZTI25EUCTWDistributionAnalysis[_ZTI25EUCTWDistributionAnalysis]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(CharDistribution.cpp.o):(.rodata._ZTI25EUCKRDistributionAnalysis[_ZTI25EUCKRDistributionAnalysis]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(CharDistribution.cpp.o):(.rodata._ZTI26GB2312DistributionAnalysis[_ZTI26GB2312DistributionAnalysis]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(CharDistribution.cpp.o):(.rodata._ZTI24Big5DistributionAnalysis[_ZTI24Big5DistributionAnalysis]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(CharDistribution.cpp.o):(.rodata._ZTI24SJISDistributionAnalysis[_ZTI24SJISDistributionAnalysis]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(CharDistribution.cpp.o):(.rodata._ZTI25EUCJPDistributionAnalysis[_ZTI25EUCJPDistributionAnalysis]+0x0): more undefined references to `vtable for __cxxabiv1::__si_class_type_info' follow
uchardet//libuchardet.a(nsHebrewProber.cpp.o): In function `nsHebrewProber::~nsHebrewProber()':
nsHebrewProber.cpp:(.text._ZN14nsHebrewProberD0Ev[_ZN14nsHebrewProberD0Ev]+0x8): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsHebrewProber.cpp.o):(.rodata._ZTI14nsHebrewProber[_ZTI14nsHebrewProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsBig5Prober.cpp.o): In function `nsBig5Prober::~nsBig5Prober()':
nsBig5Prober.cpp:(.text._ZN12nsBig5ProberD2Ev[_ZN12nsBig5ProberD5Ev]+0x10): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsBig5Prober.cpp.o): In function `nsBig5Prober::~nsBig5Prober()':
nsBig5Prober.cpp:(.text._ZN12nsBig5ProberD0Ev[_ZN12nsBig5ProberD0Ev]+0x10): undefined reference to `operator delete(void*)'
nsBig5Prober.cpp:(.text._ZN12nsBig5ProberD0Ev[_ZN12nsBig5ProberD0Ev]+0x20): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsBig5Prober.cpp.o):(.rodata._ZTI12nsBig5Prober[_ZTI12nsBig5Prober]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsEUCJPProber.cpp.o): In function `nsEUCJPProber::~nsEUCJPProber()':
nsEUCJPProber.cpp:(.text._ZN13nsEUCJPProberD2Ev[_ZN13nsEUCJPProberD5Ev]+0x10): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEUCJPProber.cpp.o): In function `nsEUCJPProber::~nsEUCJPProber()':
nsEUCJPProber.cpp:(.text._ZN13nsEUCJPProberD0Ev[_ZN13nsEUCJPProberD0Ev]+0x10): undefined reference to `operator delete(void*)'
nsEUCJPProber.cpp:(.text._ZN13nsEUCJPProberD0Ev[_ZN13nsEUCJPProberD0Ev]+0x20): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEUCJPProber.cpp.o):(.rodata._ZTI13nsEUCJPProber[_ZTI13nsEUCJPProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsEUCKRProber.cpp.o): In function `nsEUCKRProber::~nsEUCKRProber()':
nsEUCKRProber.cpp:(.text._ZN13nsEUCKRProberD2Ev[_ZN13nsEUCKRProberD5Ev]+0x10): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEUCKRProber.cpp.o): In function `nsEUCKRProber::~nsEUCKRProber()':
nsEUCKRProber.cpp:(.text._ZN13nsEUCKRProberD0Ev[_ZN13nsEUCKRProberD0Ev]+0x10): undefined reference to `operator delete(void*)'
nsEUCKRProber.cpp:(.text._ZN13nsEUCKRProberD0Ev[_ZN13nsEUCKRProberD0Ev]+0x20): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEUCKRProber.cpp.o):(.rodata._ZTI13nsEUCKRProber[_ZTI13nsEUCKRProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsEUCTWProber.cpp.o): In function `nsEUCTWProber::~nsEUCTWProber()':
nsEUCTWProber.cpp:(.text._ZN13nsEUCTWProberD2Ev[_ZN13nsEUCTWProberD5Ev]+0x10): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEUCTWProber.cpp.o): In function `nsEUCTWProber::~nsEUCTWProber()':
nsEUCTWProber.cpp:(.text._ZN13nsEUCTWProberD0Ev[_ZN13nsEUCTWProberD0Ev]+0x10): undefined reference to `operator delete(void*)'
nsEUCTWProber.cpp:(.text._ZN13nsEUCTWProberD0Ev[_ZN13nsEUCTWProberD0Ev]+0x20): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsEUCTWProber.cpp.o):(.rodata._ZTI13nsEUCTWProber[_ZTI13nsEUCTWProber]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
uchardet//libuchardet.a(nsGB2312Prober.cpp.o): In function `nsGB18030Prober::~nsGB18030Prober()':
nsGB2312Prober.cpp:(.text._ZN15nsGB18030ProberD2Ev[_ZN15nsGB18030ProberD5Ev]+0x10): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsGB2312Prober.cpp.o): In function `nsGB18030Prober::~nsGB18030Prober()':
nsGB2312Prober.cpp:(.text._ZN15nsGB18030ProberD0Ev[_ZN15nsGB18030ProberD0Ev]+0x10): undefined reference to `operator delete(void*)'
nsGB2312Prober.cpp:(.text._ZN15nsGB18030ProberD0Ev[_ZN15nsGB18030ProberD0Ev]+0x20): undefined reference to `operator delete(void*)'
uchardet//libuchardet.a(nsGB2312Prober.cpp.o):(.rodata._ZTI15nsGB18030Prober[_ZTI15nsGB18030Prober]+0x0): undefined reference to `vtable for __cxxabiv1::__si_class_type_info'
collect2: error: ld returned 1 exit status

If make shared one and try to use it in my program, it compiles, but when I run it, I have:
error while loading shared libraries: libuchardet.so.0: cannot open shared object file: No such file or directory

I compile in this way:
gcc test.c  -Ithird -Lthird/parserutils/lib_amd64/ -lparserutils -I uchardet/ -L uchardet/ -luchardet

OK! This works!
LD_LIBRARY_PATH=uchardet/ ./a.out

But can I use static linking here?

A: For shared library case: by default, RTLD applies only public library search paths. To add another one, add an option when linking the binary: -Wl,-rpath=$libdir, e.g.

gcc test.c  -Ithird -Lthird/parserutils/lib_amd64/ -lparserutils -I uchardet/ -L uchardet/ -luchardet -Wl,-rpath=`pwd`/uchardet

This option will ask RTLD to search libraries also in the specified directory. It can be specified multiple times for each additional directory invoked here.
What is having happened for the static library case, you can determine using ldd for the shared library. Most likely it requires libg++, libstdc++ or analog, depending on your system. If so, you should add its static analog also for your linking. g++ does this automatically even if pure C code is compiled, but gcc doesn't.