text:
Q: How do I connect pgadmin with postgres after installed by docker? This is my docker-compose.yml
services:

    db:
        container_name: postgres
        image: postgres:latest
        restart: always
        environment:
            POSTGRES_USER: root
            POSTGRES_PASSWORD: root
            POSTGRES_DB: test_db
    pgadmin:
        container_name: pgadmin
        image: dpage/pgadmin4
        restart: always
        environment:
            PGADMIN_DEFAULT_EMAIL: admin@test.com
            PGADMIN_DEFAULT_PASSWORD: admin123
        ports:
            - 8002:80

Pg-admin is running in port 8002
To connect pgsql with pgadmin I have used below credential to add new server in pgadmin, I am getting below error,

How do I will map this connection ?
In docker panel it's showing postgres is running

My operating system : Mac m1.

A: When you using more than one container and there are related, localhost not works.
Instead of localhost set the ip of the host in which your postgress is running.
Read these topics to understand ip vs localhost in docker

*

*https://stackoverflow.com/a/52213178/3957754

*https://stackoverflow.com/a/63207679/3957754


text:
Q: MySQL Brute Force Defense I was wondering what defense MySQL server uses to protect against brute force attacks on the user credentials? I hope this isn't too simple of a question! I have tried to Google it, but can't seem to find really any clear cut answer.

A: MySQL security hasn't been every a particular strong point of the server software. That is why most people recommend not expose the MySQL port outside the internal network/firewall. Like any other software, there has been records of vulnerabilities found.
Having said that, MySQL has a basic protection against port-scan attacks, as it maintains internally a list of blocked hosts and it adds a host to this list when more than 10/100 TCP/IP connections are interrupted (max_connect_errors). Please note that this is not a real brute-force attack protection, as both a successful and an unsuccessful complete connection will reset the counter and localhost is whitelisted.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Cannot select tester on iTunes Connect "Add Existing Testers to Build" My user role is admin and legal. As you can see (because it's highlighted) from the screenshot I have clicked on one of the testers.  In the right hand corner the "next" button is still not able to be clicked.
Any help would be great thanks!
Screen Shot

A: I had the same issue. After struggling for a bit, I found the solution was to remove all the users from the "iTunes Connect Users" group and then re-add them from existing users. Then I was able to send an invite to start testing.
Hope this helps.


text:
Q: Is the bounty system effective? For years, people have been able to spend their hard-earned imaginary Internet points to add "bounties" to questions in order to attract more attention to them. (Because, really, "attention" is the only thing that you can be reasonably sure a bounty will give you.)
But does this extra attention translate into better results?
Granted, any individual question may not be really answerable or is still boring even with the extra carrot. And a question might be so interesting that it would have gotten a ton of (good) answers even without the bounty.
Do questions that have bounties get more/better answers—in aggregate—than questions that never had a bounty? Does this vary by site? If so, do bounties seem more effective at a certain site "size"?
Or is it really just a wash, and that all anyone ever gets for their bounty is extra attention?

A: Bounties gain attention in their own way on each SE site. Each SE site is a culture of it's own, sometimes with overlap into other SE sites, and sometimes with hardly any overlap at all.
I have offered bounties on a few sites with mixed results:

*

*On Christianity.SE I have offered a bounty to reward an already existing answer that was quite superb. I earned this one. I have seen, many times, a bounty bring in equally superb answers as many as 100 days after the question was asked.

*On MSE, when it was MSO, actually, I offered a bounty on a feature request that was not my question to get the SE staff to notice it. It received no further attention from anyone except a few more upvotes and a worthless answer that basically said "yep, me too," which three people upvoted for some reason.

*I just offered a bounty on SU for a question that went three weeks with no activity at all. We will see.

On the bigger sites, the quality of interaction seems to decline the bigger it gets. They are a victim of their own success. Hence, I don't think the bounties are too effective for those sites.
On the mid-sized sites, the bounties seem to work very well. There is a high possibility that a regular user can answer very well, but for the few upvotes they might get, they are not really willing to put in the time. The promise of a bounty gives them that extra push.
I have no experience with the small sites, but I suspect the bounties are hit and miss, mostly because there is actually a good chance that none of the regular users can provide a good answer.
See that your only experience is on SO and MSE, I can understand you frustrations.
Here's some examples:

*

*On C.SE, the bounty made most of those answers; the OP didn't award any of them for some reason: Why does God command us to have children? I personally think most of those answers are pretty good. This question's current bounty brought in three answers so far, of which, one is pretty good. This question's bounty has brought in one answer so far, that at least looks extensive, but I can't comment on quality/factuality; it has no up or down votes.

*On MSE I found my reposting of this, after the bounty on the other did exactly nothing. Still nothing on the reposting: Revisit favorite answers feature request

*This is my question on SU with the current bounty: Is is possible to get a virtual disc drive to mount over usb to another machine's motherboard?

A: The bounty system does bring more views to bountied questions. On average, Stack Overflow questions get 1455 views. Bountied questions average 2631. It stands to reason that the more people who see a question, the better the odds it will get a quality answer.
To test that, I divided all answers into three groups:

*

*All answers whether their question has been bountied or not (the control),

*Answers that arrived before the bounty (before), and

*Answers that arrived after the bounty (after).

Since questions can have multiple bounties, an answer might belong to all three groups. A slightly cleaner test would only look at questions with just one bounty.
Score is our usual method of determining quality. The query is based on public data and I've included deleted posts.
group    N       avg_score bountied_rate accepted_rate
-------- ------- --------- ------------- -------------
before    112270      18.8         0.122         0.123
after     388660       2.9         0.259         0.243
control 26548476       2.3         0.004         0.306

Despite the extra attention, answers posted after the bounty are barely better scored than answers in general. Existing answers get most of the voting benefit of being featured. It seems entirely possible that this is a result of the reward existing answer bounty reason. But new answers are more than twice as likely (26%) to receive a bounty as existing answers (12%).
The odds an answer will be accepted has more to do with the total number of other answers to the question than it's actual quality. So let's look at questions instead:
group  N         avg_score avg_max_score avg_bounties accept_rate avg_views
-----  --------- --------- ------------- ------------ ----------- ---------
bounty    161510       2.8          9.45        1.022       0.658      4536
control 14181661       1.5          3.26          N/A       0.572      2242

Questions that have been bountied get higher scoring answers on average. And the highest scoring answer is also markedly higher on average. But as I mentioned above, that could be a function of the greater number of views. There is an increase in accept rate among questions that have been bountied. The surprising thing is how many questions get multiple bounties:
bounties N        answers avg_score avg_max_score accept_rate avg_views
-------- -------- ------- --------- ------------- ----------- ---------
 0       14020151     2         1.5           3.2       0.571      2214
 1         158289     3         2.7           8.3       0.659      4269
 2           2979     4.5       5.8          46.1       0.574     14550
 3            182     7        12.9         189         0.555     48050
 4             35    10.5      13.5         166.5       0.714     72940
 5             15     6.1       7.6          25.6       0.467      5346
 6              4    12        30.8         417.5       0.25     127626
 7              3    14.7      36.8         392.3       1         96343
10              1     5        63.8         170         1         46912
13              1    40        28.4         430         1         67442
14              1    97       444.2       26940         1       1135600

I venture to guess that a question really isn't getting better answers after it's first bounty. Every measure of quality except accept rate increases with multiple bounties.
Summary
Bounties certainly increase attention (as designed). There is some indication that a single bounty also increases answer quality, but multiple bounties probably don't increase anything but attention. I'm only looking at Stack Overflow, but spot checks other sites show similar results.

A: Personally as an answerer, I do get a hit off the dopamine from a bounty - hightened by that delayed gratification and risk while waiting for the bounty to finish. When I put in a good answer but it doesnt get enough votes to score the bounty I am crushed (briefly).
I have several tags where I have expertise but I'll only look at bountied questions.  It's an effective way for me to avoid getting too sucked in to SO.
BTW it's so ironic that the OP gave a bounty for the best answer ...


text:
Q: Set 00000 Input Transparent Color with GeoServer Rest API I need to change parameters (Input Transparent Color) from layers in GeoServer. I have a lot of images to do it. So, I need to do this edit using GeoServer REST API.
I did the code below but it doesn't work.
curl -u admin:geoserver -v -XPUT -H "Content-type: text/xml" -d "<coverage><parameters><entry><string>*InputTransparentColor*</string><string>000000</string></entry></parameters><enabled>true</enabled></coverage>" http://localhost:$81/geoserver/rest/workspaces/sentinel2/coveragestores/$covareganame/coverages/$covareganame.xml

Is it possible to change layer's parameters from the curl commands?
What's wrong in my script it not change input transparent color to '00000'?

A: The answer is:
curl -u admin:geoserver -XPUT -H "Content-Type: text/xml" -d "<coverage><parameters><entry><string>InputTransparentColor</string><string>#000000</string></entry></parameters></coverage>"  http://$IP:PORT/geoserver/rest/workspaces/$WORKSPACENAME/coveragestores/$RESOURCENAME/coverages/LAYERNAME.xml


text:
Q: In Java, I want to call a method on an object by the name of 'foo', but 'foo' is a string. How do I get around this? I have an object named "foo" (Object foo = new Object()). I want to call this object in another method where I pass a string with this object name in the signature. How can I call this object by using a string that represents the name of the object?
I am getting a cannot find symbol error.
Here is some code:
//from main method
Object foo = new Object();
Monitor monitor = new Monitor();
//end main method

class Monitor {
  public Monitor() {
    Manager manager = new Manager();
  }

//IMPORTANT - info.objectName is user input, and for this example it is "foo"

  public void processArgument(Instruction info) {
    if (info.command == "read") int value = manager.read(info.objectName);
  }
}

class Manager {
  public int read(String obj) {
    return obj.getRead();
  }
}

class Object {
  private int value;
  public int getRead() {return value;}
}

I hope that makes sense, I'm not very good at this but I need some help. This is for a class with a strict anti-code-sharing policy so I tried to make this as abstract as I could.

A: Short answer
There is no support for this in Java or the JVM.
Long Answer Why
Given MyCustomObject xxx = new MyCustomObject();
There is no way to actually call any methods on xxx which is a reference to an instance of a type of MyCustomObject in Java given the String s = "xxx";. Because there is no way to search the JVM for the reference named xxx. There is no method that allows you to look up the reference xxx given an arbitrary String.
Duplicate Question
Java Reflection: get instances of a given class found by entering its name? If you can't find it by reference name, you can't call any methods on it!
Hacky Workaround
You could store this reference in some kind of Map<String, T> structure yourself and then pass that structure around and search it yourself, but that isn't anything that would be built into the JVM or the language itself. It would be next to impossible to enforce this, it would introduce tight coupling to some static data, and lots of other bad design things would cause lots of headaches down the road.

A: If you want to call a method with name "foo",

*

*get the class object which foo method.

*Call the getDeclaredMethod(), which return Method object.

*Call the invoke the method on thw Method object.

Class classOfFoo = FooClass.class;

FooClass obj = new FooClass(); //Or may be you have your own object.

classOfFoo.getDeclaredMethod("foo",fooParameter.class).invoke(obj,fooParametersObj);

You may want to have a look on reflection API.
getDeclaredMethod(String name,Class... parameterTypes)
public Object invoke(Object obj, Object... args)

A: There's two ways to natively do this, and one less native way.

*

*If statements

*Functor map

*Reflection

Option 1
What you have is option 1, and it's mostly correct, you just are using the wrong way of comparison. Compare yours
public void processArgument(Instruction info) {
    // this is bad - uses reference comparison
    if (info.command == "read")
        int value = manager.read(info.objectName);
}

with the recommended
public void processArgument(Instruction info) {
    // this is good - actually compares the values
    if (info.command.equals("read"))
        int value = manager.read(info.objectName);
}

Some would consider it even better to do the following because if info.command is null this will not throw an exception. Personally I don't like that because I'd rather get the exception, but many people advocate it, and they have a perfectly valid reason for doing it.
public void processArgument(Instruction info) {
    // "read" can never be null, so no null pointer exception here
    if ("read".equals(info) )
        int value = manager.read(info.objectName);
}

Of course, as you add more behaviours, you just add more if statements.
In Java 7, you can do this:
public void processArgument(Instruction info) {
    switch(info.command) {
        case "read": manager.read(info.objectName); break;
        case "write": manager.write(info.objectName); break;
        default: throw new IllegalArgumentException("Command " + info.command + " not supported");
    }
}

Option 2
Another option is to use a Map utilizing anonymous classes, like so:
// define this somewhere
abstract class Functor {
    Manager m;
    Functor(Manager m) { this.m = m; }
    void execute(Instruction info);
}

// somewhere you have access to
Map<String,Functor> funcs = new HashMap<String,Functor>();

// add this to a static block, or constructor, depending
funcs.put("read", new Functor(manager) {
    public void execute(Instruction info) { m.read(info.objectName); }
});
funcs.put("write", new Functor(manager) {
    public void execute(Instruction info) { m.write(info.objectName); }
}

Then when you call your arguments
public void processArgument(Instruction info) {
    Functor f = funcs.get(info.command);
    if(f == null) throw new IllegalArgumentException("Operation " + info.command + " not supported");
    f.execute(info);
}

Option 3
Use reflection as SagarDabas outlines in his post. Note that this may require special access permissions, and is not going to give you as flexible of correctness options.


text:
Q: Question about fields and quotients of polynomial rings I don't see how to solve the following problem:

Let $R$ be a commutative and unitary ring. If there exists a monic polynomial $f(x) \in R[x]$ so that $R[x]/(f(x))$ is a field, show that $R$ is a field. What about if $f(x)$ isn't monic?

I don't have a clue about how proving it. I see that if $R$ is a field and $f(x)$ a monic and irreducible polynomial in $R[X]$ then $\frac{R[x]}{(f(x))}$ is a field, but that is not the question!
Thank you in advance for your help

A:
Let $R$ be a commutative unitary ring. If there exists a monic polynomial $f\in R[X]$ so that $R[X]/(f)$ is a field, then $R$ is a field.

Let's first remark that the degree of non-zero polynomials in the ideal $(f)$ is at least $\deg f$. Now let $a\in R$, $a\ne 0$. We want to prove that $a$ is invertible in $R$. The residue class of $a$ in $R[X]/(f)$, denoted in what follows by $\hat a$, is not zero: if $\hat a=\hat 0$, then $a\in(f)$ and since $0=\deg a<\deg f$ we get a contradiction. Since  $R[X]/(f)$ is a field it follows that $\hat a$ is invertible in $R[X]/(f)$, so there is $g\in R[X]$ such that $\hat a\hat g=\hat 1$, that is, $ag-1\in(f)$. Now write $g=fq+r$ with $\deg r<\deg f$. Then $ag-1=a(fq+r)-1=afq+ar-1\in (f)$, so $ar-1\in (f)$. But $\deg ar\le\deg r<\deg f$, and therefore we get $ar=1$. In particular, $ar_0=1$ for some $r_0\in R$. (Of course, $r_0$ is $r(0)$.)

What about if $f$ isn't monic?

Then the result is false: take $R=\mathbb Z/6\mathbb Z$, and $f=2X-1$. We have $R[X]/(f)\simeq S^{-1}(\mathbb Z/6\mathbb Z)$, where $S=\{1, 2, 4\}$, and $S^{-1}(\mathbb Z/6\mathbb Z)\simeq \mathbb Z/3\mathbb Z$ which is a field.

A: Hints:
In any case, we can write the elements of $\;R[x]/I\;,\;\;I:=\langle f(x)\rangle\;$ ,  as $\;g(x)+I\;,\;\;\deg g<\deg f\;$ , so assuming $\;\deg f\ge 1\;$ ,we have that the elements $\;r+I\in R[x]/I\;,\;\;0\neq r\in R\;$ are part of a field and since $\;r+I\neq \overline 0=I\;$ , then they all have multiplicative inverse  ...
Added on the OP's request: The above hints us to look for a possible embedding $\;R\to R[x]/I\;,\;\;r\mapsto r+I$ (for this I need the assumption that $\;R\;$ is an ID):
$$\forall\,r,s\in R\;,\;\;r+I=s+I\iff r-s\in I\;$$
yet every element in $\;I\;$ is either zero of degree $\;\ge\deg f\;$ (here the assumption kicks in), and thus $\;r-s=0\iff r=s\;$ and we get our embedding.
Now,
$$0\neq r+I\in R/I\implies \exists\,s\in R\;\;s.t.\;\;(rs)+I=1+I\iff rs-1\in I$$
and again, as above, $\;rs=1\;$ and every non-zero element in $\;R\;$ has a multiplicative inverse.
Now, without the assumption of ID: as hinted in one of my comments below, we have that from $\;R\;$ is not a field it follows that $\;I\;$ cannot be a maximal ideal and thus the quotient ring isn't a field.
I'm not sure how, and if possible at all, to get rid of the above assumption of ID to make that approach work. If we get lucky, it could possibly be that the user that commented below and chose not to write down an answer/hint/input but rather just to question this answer will now grant us the honour to write down an answer/comment enlightening us all.

A: Let me try and clear up the confusion in the comments under DonAntonio's answer, and perhaps why the monic assumption is crucial.
Since $f$ is monic, $(f) \cap R = 0$. Thus the composition $R \to R[x] \to R[x]/(f)$ has kernel $(f) \cap R = 0$, i.e. is injective, so $R \hookrightarrow R[x]/(f)$ is a subring of a field, hence is a domain. Next, $f$ being monic says exactly that $R \hookrightarrow R[x]/(f)$ is an integral extension. Then $R$ is a domain with $\dim R = \dim R[x]/(f) = 0$, hence is a field.
As for an example where this fails if $f$ is not monic, consider $R = \mathbb{Z}_{(2)}$, $f = 2x - 1$. Then $R$ is not a field, but $R[x]/(f) = \mathbb{Z}_{(2)}[x]/(2x-1) \cong \mathbb{Z}_{(2)}[\frac{1}{2}] \cong \mathbb{Q}$ is a field (notice that this example is in much the same spirit as the one given by user26857: both are localizations at principal open sets which are fields).


text:
Q: Smooth varieties in a Hilbert scheme For a given Hilbert polynomial $P$, consider the Hilbert scheme $\text{Hilb}_P (\mathbb P^n)$.
If it is not empty, then does it contain a smooth variety?
Here $\text{Hilb}_P (\mathbb P^n)$ is regarded as the collection of  closed subschemes of $\mathbb P^n$  whose Hilbert polynomial is $P$.


text:
Q: Facebook messenger webhook not accepting my callback url I'm creating a chatbot with the Facebook Messenger developer platform.
My problem comes as I'm trying to set up the Webhook using a ngrok tunnel as callback_url and using the figaro gem to add my access_token and verify_token to my app.
Somehow, the test never passes and I don't know why.
My ngrok site works perfectly in the browser. Yet I think the problem stems from the fact that the Webhook isn't receiving the information it wants, aka the access_token & verify_token from how I understand it.
I have tried redirecting the ngrok tunnel to a page that returns the environment variables of both (ENV["ACCESS_TOKEN"] & ENV["VERIFY_TOKEN"]) yet this doesn't work. So I'm just not sure what the API is expecting and why it's not getting it.
Thanks for the help!!!!!
screenshot of what I see on the fb developer platform


text:
Q: Regular Expression search and replace on Autoblogged Plugin I'm using Autoblogged to pull a feed in as a blog post. I need to create a reg expression to convert the title of the item to things I can use as meta data. I've attached a screen of the backend I have access to. Any help would be greatly appreciated!
Here are examples of the title from the feed.
Type One Training Event New New Mexico, WY November 2012
Type Two Training Event Seattle, WA November 2012
I need that to become this:
<what>Type One Training Event</what> <city>New New Mexico</city>, <%state>WY</state> <month>November</month> <year>2012</year>

<what>Type Two Training Event</what> <city>Seattle</city>, <state>WA</state> <month>November</month> <year>2012</year>

Essentially says take whatever is before the word event and make that "what"
Take anything after the word event and before the comma and make that "city"
Take the two letters after the comma and make that "state"
Take the last two words and make em month and year
Autblogged backend:

A: Perhaps match:
^(.* Event) (.*), ([A-Z]{2}) +(?i(Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|June?|July?|Aug(?:ust)?|Sep(?:tember)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)) +((?:19|20)\d{2})\b

EDIT: re your comment, it looks like you have to surround your regex in delimiters. Try:
/insert_above_regex_here/

If you want case-insensitive, then do:
/insert_above_regex_here_but_remove_(?i_and_matching_)/i

However if you do case-insensitive, your state ([A-Z]{2}) will also match two lower-case letters. If this is OK then go for it. You culd also try changing that part of the regex to (?-i([A-Z]{2})) which says "be case-sensitive for this part", but it depends on whether that engine supports it (don't worry, you'll get an error if it doesn't).
Then replace with:
<what>$1</what> <city>$2</city>, <state>$3</state> <month>$4</month> <year>$5</year>

I'm not sure what flavour of regex that interface has so you might not be able to do the (?i bit in the Month regex (it just makes that bit case insensitive) -- you'll just have to be careful then to write your months with one capital letter and the rest lowercase, or you can modify the regex to allow upper-case too.

A: We actually have an email in queue to respond to you directly once we get our v2.9 update out. The update fixes a bug in the regex feature but I thought I would go ahead and comment here so this question isn't just left open.
The ability to extract info from a feed is one of the coolest and most powerful features of AutoBlogged and this is a perfect example of what you can do with those features.
First of all, here are the regex patterns you would use:
What: (.*)\sTraining\sEvent
City: Training\sEvent\s([^,]*)
State: .*,\s([A-Z]{2})
To use these, you create new custom fields in the feed settings. Note that the custom fields also use the same syntax as the post templates so you can use the powerful regex function to extract info from the feed. This is how the fields should look:

Once you create these custom fields you can use them in your post templates and they will be added as custom fields to your post in WordPress.
Once you have these custom fields set up, you can use them in your post template as  %what%, %city% or %state_code%. As I mentioned before this will also create custom fields on your blog post in WordPress as well. If you don't want that, you can just use %regex("%title%", "(.*)\sTraining\sEvent", "1")% instead of %what% directly in your post template.
Quick explanation of the syntax:
If you use %regex("%title%", "(.*)\sTraining\sEvent", "1")% it means this:

*

*Get this info from the %title% field

*Use the regex pattern (.*)\sTraining\sEvent

*Use match reference 1, the (.*) part.


text:
Q: Is trigger comes as part of transaction in SQL Server I have three tables in SQL Server:

*

*Employee

*EmployeeDetails

*EmployeeHistory

I wrote a trigger on the Employee table so that if entry is inserted into Employee, then it also inserts a row into EmployeeHistory; which is working fine.
Now I have created stored procedure with transaction and inserting records into Employee, then EmployeeDetails. After inserting the record into Employee and if there is any issue and the transaction is rolled back, then will the row inserted into EmployeeHistory also be removed or not?

A: By default, the option XACT_ABORT is ON in a trigger. It can be seen here. When this feature is ON, any error that occurs break off/abort the batch, so your whole transaction will be rolled back.
Microsoft documentation says:

When SET XACT_ABORT is ON, if a Transact-SQL statement raises a
  run-time error, the entire transaction is terminated and rolled back.
When SET XACT_ABORT is OFF, in some cases only the Transact-SQL
  statement that raised the error is rolled back and the transaction
  continues processing. Depending upon the severity of the error, the
  entire transaction may be rolled back even when SET XACT_ABORT is OFF.


text:
Q: How to executeScript on all frames of a page as they load (i.e. not using document_idle) My WebExtension (for Firefox, in this case) modifies pages by executing a script on them. I need the script to work on the page and all its frames, and I need it to happen as soon as possible when the page/frame is created (i.e. while things in the page are still loading).
There are two options I see, both of which can't achieve this:

*

*Call browser.tabs.executeScript() to inject the script with runAt: "document_start" and allFrames: false. On the executed content script itself, try to modify all frames of the window. This is not possible for frames whose content comes from another domain, due to cross domain policies.

*Call browser.tabs.executeScript() with allFrames: true. The script will be injected into all frames, but if a frame takes longer to load, using runAt: "document_start" will only execute on the main document and not the frame. Using "document_idle" works well but takes a long time to work.
I've also tried calling executeScript with runAt: "document_start" and allFrames: false, followed by another call with runAt: "document_idle" and allFrames: true. This would be middle ground, letting the main document work immediately (most pages) but delaying frames a bit. However, the executed script will get injected twice in the main page and cause errors.
None of these let me execute the script on all frames as they load. How can I do this?
I suspect a more cumbersome solution is needed and I'd appreciate it if you have ideas. Thanks!

A: You can have more fine-grained control over injecting your scripts. I have an extension with a webNavigation.onCompleted listener that fires when the page is fully loaded.
browser.webNavigation.onCompleted.addListener(function(details){
  // don't inject into the main frame (id = 0)
  if(details.frameId != 0) {
    chrome.tabs.executeScript(details.tabId, {file: "js/contentScript.js", frameId: details.frameId});
  }
});

This requires the webNavigation permission in manifests.json
Maybe that would work along with your first script injected into the main frame at document_start.


text:
Q: Is it better to use a "?" or a ";" in a URL? In my application, I redirect an HTTP request and also pass a parameter. Example:
http://localhost:9000/home;signup=error

Is it better to use a ; or shall I use a ? i.e. shall I do http://localhost:9000/home;signup=error or http://localhost:9000/home?signup=error?
Are the above two different from each other semantically?

A: The ? is a reserved character; I have read that this is both valid and invalid, but I have used it for 'slugs' when templating.
Should you choose to use it, percent-encode the query string using %3F which is not human readable, but will produce the ?.  (An encoder is recommended)
Perhaps you will find a more suitable solution for your redirects by adding an .htaccess file to your project.


text:
Q: Filter spam and inappropriate content in a web application how is spam and inappropriate content filtered ... spam probably captcha and what abt inappropriate content, vulgarities etc?

A: With inappropriate content, you need to have a reference list of words you don't want to see. You can then flag / filter content based on your list. You can add to the list over time with words and phrases that have "got through".
As with all solutions, if you prevent people putting the word "hello", then they will inevitably start putting "h e l l o" or "hell0" or other variations, which are harder to detect.
The best way to catch them all is to supply a "flag inappropriate content" flag so humans can notify you of anything offensive.

A: You could also use a service such as Aksimet.


text:
Q: Boxing a rusqlite Rows iterator I am having trouble figuring out how to return an Iterator (impl or Box) when using prepare and query.
Here is what I have tried:
fn foo<'a>(
    conn: &'a mut rusqlite::Connection
) -> Box<impl 'a + fallible_streaming_iterator::FallibleStreamingIterator<Item=rusqlite::Row<'a>>> {
    Box::new(
        conn
            .prepare("SELECT a, b FROM t")
            .unwrap()
            .query(rusqlite::NO_PARAMS)
            .unwrap()
    )
}

The problem is the prepared statement is a temporary variable owned by the function scope. (error[E0515]: cannot return value referencing temporary value).


text:
Q: what does this freq mean? pandas pd.date_range('2000-1-1', periods=100, freq="1953U") I am new to Pandas. Can someone please help me understand what does this freq value mean "1953U". I know that "U" is for micro seconds. What I am not sure is the 1953 number before "U".
pd.date_range('2000-1-1', periods=100, freq="1953U")

Thanks for your help.

A: 1953 is the multiplier. You can find details in the pandas documentation:

freq : string or DateOffset, default 'D' (calendar daily) Frequency
  strings can have multiples, e.g. '5H'

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.date_range.html#pandas-date-range

Under the hood, these frequency strings are being translated into an
  instance of pandas DateOffset, which represents a regular frequency
  increment. Specific offset logic like "month", "business day", or "one
  hour" is represented in its various subclasses.

http://pandas.pydata.org/pandas-docs/stable/timeseries.html#dateoffset-objects

A: It means that the frequency is 1953 microseconds. You can have your answer by actually running the command :
>>> import pandas as pd
>>> pd.date_range('2000-1-1', periods=100, freq="1953U")
DatetimeIndex([       '2000-01-01 00:00:00', '2000-01-01 00:00:00.001953',
               '2000-01-01 00:00:00.003906', '2000-01-01 00:00:00.005859',...


text:
Q: How To Make A VS Code Extension In Python I Use Python As My Main Language, And I Want To Make A VS Code Extension, But I Cant Find Any Docs/Resources, Is Possible To Make One In Python?

A: VS Code is built on Electron framework which run with Node.js, so it's impossible to make a extension "directly" using Python. However you can use these two ways to keep your stuff mainly in Python:

*

*Node.js allows you to call outside scripts using child_process. it is often used to achieve multi-threading in Node.js.

*If you are developing a language extension, you should give Language Server with LSP a try. By doing this you can start up a server written by Python and communicate with VSC JS client using LSP.

Note that both ways requires you to write some JS/TS code.

A: VS Code has official documentation on using the Langugage Server/LSP to create a python extension: https://code.visualstudio.com/api/advanced-topics/python-extension-template
If you prefer to use the child_process approach, there is an unofficial python wrapper: https://github.com/CodeWithSwastik/vscode-ext?u=t&m=o#example-extension


text:
Q: MVVM Displayer OberservableCollection with unknown UserControl im a little bit stuck with my current project and hope someone can help me out of this.
My application works with plugins so that the user is able to add additional functionality to the application. Now i would like to have the configuration window in the same style (Maybe a plugin need some kind of configurations).
The configuration window loads all plugins and get the configuration ViewModel from the plugins. All the ViewModels are stored in an ObservableCollection. These ViewModels should be displayed in a TabControl (one tab per ViewModel)
But i dont know the type of UserControl the plugin is using, because the plugin come up with its own UserControl for configuration purposes.
Otherwise i would create a TabControl, bind its ItemsSource to the ObservableCollection and specify the UserControl in the Resources (DataTemplates).
But how to do it in case the UserControls are unknown to compile time?
I thought about using a ObservableCollection instead of ViewModels, but im not realy happy with that and even dont know if this will work.
Do you have some idea how to deal with that?
Kind regards,
SyLuS

A: You could use a ContentControl to achieve this.
It's used to show views depending on their viewmodel.
In your xaml you can specifiy which view should be shown. Based on the viewmodel which is the current DataContext.
<ContentControl>
    <ContentControl.Resources>
        <DataTemplate DataType="{x:Type vm:MyViewModel}">
            <v:MyView/>
        </DataTemplate>
    </<ContentControl.Resources>
</ContentControl>

But when you say you are using a plugin system, maybe something like PRISM, you have to setup the datatemplates automatically. Never done this before. But maybe I gave you a point where you can start.


text:
Q: Are Hera Syndulla and Kanan Jarrus in love? Watching the interactions between Hera and Kanan - especially when they are alone - I get a weird vibe that there is more to their relationship than just close friends and fellow rebels. It could be just me, maybe it's really just a boring normal friendship - I don't really have experience in this field. I just find it intriguing that Hera and Kanan open up to each other in ways they don't to others, not even Ahsoka - not just with regards to the secrets they hold inside them, but also a hidden side of their selves altogether.
Of course, Jedi cannot have that kind of relationships, but that does not mean they are not liable to experiencing the same underlying emotions - it won't be the first time, after all.
Is there any romantic attraction at play here, either reciprocal or just one-sided?

A: The implication is that their relationship status is pretty well established. They appear to be in a committed monogamous relationship, albeit one they keep almost totally hidden from the rest of the crew and us, the audience. There's also a certain element of not really wanting to admit to each other how close they've gotten. Hera also uses her close relationship with Kanan to manipulate him (emotionally) into doing things her way, especially when she calls him "love".

This dialogue from "A New Dawn" (before the start of Rebels) strongly implies that while Hera is open to flirtation, she's really not interested in maintaining a serious relationship.

He obviously liked her starship, she could see as he walked around it.
  That was good. He was also smitten with her, she could tell—and she
  was all right with that, too. She didn't want to tell him that her war
  had already begun, and that in war, there was no time for anything
  else. He would probably understand that eventually.

With that in mind, in the short "The Machine in the Ghost", they're clearly about to kiss when interrupted by Chopper. After a brief bit of banter, they give him a bunch of chores to do elsewhere on the ship, the metaphorical equivalent of giving him $10 to bugger off to the cinema.

And in the Star Wars: Rebels - Rise of the Rebels novel, we have the following internal voice from Hera's perspective:

There was nothing but static. If the TIE's blasts had somehow hit the
  turret and she'd lost Kanan, she didn't know what she'd do. Kanan
  Jarrus was more than a friend or a colleague. The human meant the
  world to her—although she'd never admit it to him.

and this quote from Hera's character actor Vanessa Marshall shows that the relationship is a lot deeper than even she's been told!

So I don't see much schmaltzy romance, on the page. When I watch the
  episodes and I've seen some gestures and body language that wasn't
  described in the script, as far as I recall, I thought, "woah, wait a
  minute!" I remember being at Star Wars Weekends and they played that
  initial short where the two of them are bickering and Chopper is going
  between them. At the end, they sort of come together, and I remember
  sitting there watching it, going "hey now! What was that?" Everyone
  was asking me, and I had no idea! I didn't get a sense of that while
  reading it or recording it! So it's interesting to me to allow what
  may happen in the animation, a caress or a look, that indicates a
  deeper connection.

 And of course, the final season makes it abundantly clear. They kiss, she tells him that she's in love with him and they ultimately have a child together

A: I'd always assumed that they were in a full de facto relationship, but because Rebels was made for a younger audience the writers wanted to keep it relatively PG. There is something about their body language when they're together. Here's one example:

(source: tumblr.com)  .
A man and a woman just don't get in each other's personal space like that unless they've been given permission. Although nothing is ever said, in dialogue, most older viewers pick up on the body language and draw the inevitable conclusion.
So, there's probably some smooching and kanoodling going on, but it's all happening behind closed doors. And the kiddies notwithstanding, if they're in an established relationship there probably isn't much to be gained (in a dramatic sense) from showing the romantic stuff anyway.

A: From part 2 of the Season Three finale:

WHOOSHING FADES) (EXPLOSIONS STOP) (CRACKLING) It held! It held!
(LAUGHING) (COMLINK BEEPING)
Hera: Kanan? Kanan, do you copy?
KANAN: (GROANS) I'm gettin' the feeling Thrawn's actually trying to kill us this time.
Hera: Oh, that is only funny because you're still alive. Now, please, come home, love.

A: Welp Hera does refer to Kanan as "my love" in one of the last two episodes of the current season (the season with the episode "twin suns") so unless this is a figure of speech that I've never heard of seems fairly indicative of a relationship.


text:
Q: Remove/hide or update a Bootstrap panel from shinyWidget In order to make an app where panels are created dynamically, I would like to remove, hide and/or update panels from the package shinyWidgets.
I didn't find any function to do so nor way to add IDs to these panel.
If you have the solution or a way around, I would be more than happy. Thank you in advance !
library(shiny)
library(shinyWidgets)

ui <- fluidPage(
    panel(
      heading = "Test panel",
      actionButton("remove_panel", "Remove this panel")
    )
)

server <- function(input, output) {

    observeEvent(input$remove_panel,{
      print("remove panel")
    })
}

shinyApp(ui = ui, server = server)

A: There is no official method you can use to change the panel states, but we can do it with custom expressions.
library(shiny)
library(shinyWidgets)
library(shinyjs)

ui <- fluidPage(
    useShinyjs(),
    panel(
        heading = "Test panel1",
        id = "test_panel1",
        actionButton("remove_panel", "Remove this panel")
    ),
    panel(
        heading = "Test panel2",
        id = "test_panel2",
       "some content"
    ),
    actionButton("hide_panel", "Hide this panel")
)

server <- function(input, output) {

    observeEvent(input$remove_panel,{
        removeUI('.panel:has([id="test_panel1"])', immediate = TRUE)
    })
    observeEvent(input$hide_panel,{
        toggle(selector = '.panel:has([id="test_panel2"])')
        if(input$hide_panel %% 2 == 1) return(updateActionButton(inputId = "hide_panel", label = "Show this panel"))
        updateActionButton(inputId = "hide_panel", label = "Hide this panel")
    })
}

shinyApp(ui = ui, server = server)

To remove:

*

*add an ID argument to your panel, and use removeUI to remove it. Remember to change the ID in you own case.

To hide/show:

*

*We can use toggle from shinyjs to show or hide some elements we choose.

*Use updateActionButton to also change it text when hidden.


text:
Q: Got an error message Using Android Location Services Mock Locations i'm developing an Android Application and i need to test my app using Mock Locations, going out at 5AM with almost 0ºC isnt reaaly a good idea!!. I'm using Google Play services Location API,
So, i read Google Documentation and made all the requirements to use Mock Locations.
1 - Add ACCESS_MOCK_LOCATION permission on Manifest -
<permission android:name="android.permission.ACCESS_MOCK_LOCATION" />

2 - Check the box in Developers Options to "Allow mock Location.
3- Turn on Mock Mode with mLocationClinet.setMockMode(true);
But, in execution time, i got the next error when setMockMode is executed.
java.lang.SecurityException: Client must have ACCESS_MOCK_LOCATION permission to perform mock operations.

Anyone with a similar problem? ideas?

A: It needs to be uses-permission, not permission:
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />


text:
Q: NFS mount. Permission issue? Attempting to mount an NFS share on my server and the following seems to be as far as I get...  I've tried various solutions apart from an OS reload, which may be coming still... :)  Not running an LDAP server, as each machine has it's own local authentication.  Any suggestions would be appreciated.
sudo mount -t nfs -v 192.168.10.4:/Storage /home/david/Storage/

Reults in:
mount.nfs: timeout set for Mon Feb  1 08:27:50 2016
mount.nfs: trying text-based options 'vers=4,addr=192.168.10.4,clientaddr=192.168.11.11'
mount.nfs: mount(2): Permission denied
mount.nfs: access denied by server while mounting 192.168.10.4:/Storage

A: If your showmount -e shows you the correct shares, you may have mapped UID/GID incorrectly.
From this how to page:

Note regarding UID/GID permissions on NFSv4 without Kerberos
    To make UID/GUD work as with NFSv3, set sec=sys both in the server's /etc/export and in the client's /etc/fstab. This will make

NFSv4 work with the old host-based security scheme.
    They do not work. Can someone please help investigating? Following this guide will result in UID/GID on the export being

generic despite having same UID on client and server. (According to my
  experience it works at least with "precise", if uid/gid are equal on
  both sides. hwehner) Mounting same share on NFSv3 works correctly with
  regards to UID/GID. Does this need Kerberos to work fully? According
  to http://arstechnica.com/civis/viewtopic.php?f=16&t=1128994 and
  http://opensolaris.org/jive/thread.jspa?threadID=68381 you need to use
  Kerberos for the mapping to have any effect.
    This is a possibly related bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=500778

Not clear what is meant by UID/GID on the export being generic. This
  guide does not explicitly state that idmapd must also run on the
  client side, i.e. /etc/default/nfs-common needs the same settings as
  described in the server section. If idmapd is running the UID/GID are
  mapped correctly. Check with ps ax|grep rpc that rpc.idmapd is
  running.

I know that it's not clear but it's the only possible answer that I can give (as I'm also seeking the answer).
EDIT: As stated here, Kerberos isn't needed.


text:
Q: Intellij wrap .java file text at certain length just for me. No '\n','\r', etc. saved to files. Word Wrap like notepad I like to format my code such that I can see everything without having to scroll to the right.  However, my monitor size is smaller than others on my team so when I format it they get early returns and don't like the extra white space. If they format it, I still can't see all the text without scrolling to the right. It would be nice if we could keep the text all on one line and intlleij would automatically wrap the text according to our editing window size. Just like when you turn on word wrap in notepad.  Is there a way to do this in intellij? I put some examples below of the problem kind of looks like and what the fix would kind of look like.
!=where the window cuts off.
problem examples:
Teams screens when I format:
    /*
       Lorem ipsum dolor sit amet,           !
       consectetur adipiscing elit.          !
       Cras vel imperdiet augue.             !
       Aenean d                              !
    */

My screen when they format:
    /*
       Lorem ipsum dolor sit amet, consectetu!r adipiscing elit.
       Cras vel imperdiet augue.Aenean d     !
    */

Fix examples
My screen
    /*
       Lorem ipsum dolor sit amet, !
       consectetur adipiscing elit.!
       Cras vel imperdiet augue.   !
       Aenean d                    !
    */

Teams screen
    /*
       Lorem ipsum dolor sit amet, consectetur adipiscing elit.!
       Cras vel imperdiet augue.Aenean d                       !
    */

A: Settings (Preferences on macOS) | Editor | General | Soft-wrap these files. Add ; *.java to the list.


text:
Q: Adding days to datapicker's formatDate I am printing date using datepicker this way:
$(".final-date").text($.datepicker.formatDate('dd.mm.yy', new Date()));

I am using it within my loan calculator. How can i add days to a current date? e.g. 17.01.2016, but in my calculator i choose loan period for 10 days, so it should be 27.01.2016

A: this should give you the offset date:
new Date(new Date().valueOf() + 1000*60*60*24*days);

so your code would probably become:
$(".final-date").text($.datepicker.formatDate('dd.mm.yy', new Date(new Date().valueOf() + 1000*60*60*24*10);));

or maybe more legibly:
var loanPeriodDays = 10;
var dayInMillis = 1000*60*60*24;
var loadEndDate = new Date(new Date().valueOf() + dayInMillis*loanPeriodDays);
$(".final-date").text($.datepicker.formatDate('dd.mm.yy', loadEndDate));


text:
Q: Ember.JS - How to use multiple models, controllers and views in same page? I mostly understand the basics of Ember.JS. Most examples out there really just deal with a single controller and a model to show something on a page. I am really after building a full web app with Ember so can anyone tell me how do I organize and connect multiple controllers, models and views into a single page?
For example, if I navigate to /app/posts, I want to show a navigation-bar with bunch of things including some logged in information, a sidebar to search with a controller attached to it, a bunch of posts listed in the middle and maybe a twitter feed populated on the sidebar with a TwitterFeedController.
How do I connect a bunch of these together. What is the basic way to achieve "Sections" with their own controllers and models and views in Ember.JS?
I understand there's named "outlets". Current documentation doesn't seem to mention it past having a main {{ outllet }} in application template. I can't find the definition on their public API docs too (might be blind...).
Thanks in advance!

A: Hope this answers Example1 and this one too Example2

var BaseApp = Em.Application.extend({
    app_title: 'Auto Web Shop',
    contact: function() {
        if(this.get('link') !== '') {
            var html = '%@'
                       .fmt(this.get('link'), this.get('author'));
            return new Handlebars.SafeString(html);
        } else {
            return this.get('author');
        }
    }.property('author', 'link')
});

// Extensions - End

window.App = BaseApp.create({
    author: 'Your Name Here',
    link: 'https://twitter.com/torontoemberjs'
});

// Controllers - Begin

App.ShopController = Em.ArrayController.extend();
App.ProductsController = Em.ArrayController.extend();
App.ProductsIndexController = Em.ArrayController.extend();
App.CategoriesController = Em.ArrayController.extend();

// Controllers - End

// Routes - Begin

App.Router.map(function() {
    this.resource('app');
    this.resource('products', function() {
        this.route('product', {path: 'product/:product_id'});
        this.route('category', {path: 'category/:category_id'})
    });
});

App.ApplicationRoute = Em.Route.extend({
  setupController: function() {
      this.controllerFor('categories').set('model', App.Category.find());
  }
});

App.ProductsIndexRoute = Em.Route.extend({
    model: function() {
        return App.Product.find();
    }
});

App.IndexRoute = Em.Route.extend({
    redirect: function() {
        this.transitionTo('app');
    }
});

// Routes - End

// Models - Begin

// Defining a Data Store for the application from DS namespace
App.Store = DS.Store.extend({
    // Until Ember reaches 1.0, Ember-Data will use a revisions to
    // alert developers about breaking changes to the API. At the time I'm
    // writing this, Ember-Data is on revision 11. To find out more, go to:
    // https://github.com/emberjs/data/blob/master/BREAKING_CHANGES.md
    revision: 11,
    // Define your adapter. The Adapter is responsible to 'translate' the data from
    // your backend API into what Ember-Data needs in order for it to work. Ember-Data
    // comes with a REST Adapter and a Fixture Adapter, the later is very useful for
    // debugging and for mocking up an application. This example uses the Fixture Adapter
    adapter: 'DS.FixtureAdapter'
});

App.Category = DS.Model.extend({
    name: DS.attr('string'),
    imageUrl: DS.attr('string'),
    products: DS.hasMany('App.Product')
});

App.Product = DS.Model.extend({
    name: DS.attr('string'),
    imageUrl: DS.attr('string'),
    price: DS.attr('number'),
    category: DS.belongsTo('App.Category')
});

// Loading sample data
// Note that all fixtures have an `id` property. That's because Ember-Data needs your
// models to have an Id, but you don't define it on your model classes.
App.Category.FIXTURES = [
    {
        id: 1,
        name: 'Air Conditioners',
        imageUrl: 'http://img9.imageshack.us/img9/1207/howtoreplaceyourcarairc.jpg',
        products: []
    },
    {
        id: 2,
        name: 'Tires',
        imageUrl: 'http://img526.imageshack.us/img526/5290/r8wheel1ljpg0f089f10250.jpg',
        products: []
    },
    {
        id: 3,
        name: 'Brakes',
        imageUrl: 'http://img651.imageshack.us/img651/5600/brakes.gif',
        products: []
    },
    {
        id: 4,
        name: 'Exhausts',
        imageUrl: 'http://img217.imageshack.us/img217/7366/carbon20fibre20exhaust2.jpg',
        products: []
    },
    {
        id: 5,
        name: 'Batteries',
        imageUrl: 'http://img842.imageshack.us/img842/268/t2ec16nhjhqe9nzej50bqu7.jpg',
        products: []
    },
    {
        id: 6,
        name: 'Wipers',
        imageUrl: 'http://img145.imageshack.us/img145/3750/1208764x64.jpg',
        products: []
    },
    {
        id: 7,
        name: 'GPS',
        imageUrl: 'http://img687.imageshack.us/img687/8899/kgrhqroifcpor3cm0bq1ufc.jpg',
        products: [701,702,703]
    },
    {
        id: 8,
        name: 'Windshields',
        imageUrl: 'http://img405.imageshack.us/img405/6826/windshield3thumb.jpg',
        products: []
    }
];

App.Product.FIXTURES = [
    {
        id: 201,
        name: 'Pirelli P4 Four Seasons',
        category: 2,
        price: 9999,
        imageUrl: 'http://img4.imageshack.us/img4/4372/pirellip4fourseasonslg.jpg'
    },
    {
        id: 701,
        name: 'Tomtom Start 4.3" GPS (45TM)',
        category: 7,
        price: 12999,
        imageUrl: 'http://img856.imageshack.us/img856/7471/seeq2501.jpg'
    },
    {
        id: 702,
        name: 'Garmin nüvi 4.3" GPS (40)',
        category: 7,
        price: 11999,
        imageUrl: 'http://img27.imageshack.us/img27/5116/88121963.jpg'
    },
    {
        id: 703,
        name: 'Magellan RoadMate 2230T 4.3" GPS ',
        category: 7,
        price: 14399,
        imageUrl: 'http://img820.imageshack.us/img820/7981/36361380.png'
    }
];

// Models - End

// Views - Begin

// Views - End


text:
Q: How to fix for loop as it is returning only last iteration I have a list of pdfs and list of keywords, each keyword should run through each pdf and return TRUE if it exists in the pdf
Tried with two for loops but its returning only last keyword and the result also incorrect, all are returning as TRUE. Only one pdf contains that word but it is showing TRUE for all the pdfs

library(pdftools)
library(stringr)
library(tm)
library(filesstrings)
library(RODBC)

setwd("C:/RProject/ReadPDF/InputFiles/")

 SelectFirstKeyword <- list("new formula" , "new research", "morning up")

 ID  <- list.files("C:/RProject/ReadPDF/InputFiles/", full.names = T)

 ID_ <- ID[ID != ""]

 files   <- ID_

 for(i in 1:length(files)){

         for(j in 1:length(SelectFirstKeyword)){

           filename <- files[i]
           read <- readPDF(control = list(text = "-layout"))

           mystring <- Corpus(URISource(filename), readerControl = list(reader = read))

           lower_string <- tolower(mystring)
           CleanData  <- gsub("\n", " ",lower_string)

           second_string <- tolower(SelectFirstKeyword[j])
           print(second_string)

           mystring <- paste(CleanData,sep=" ")
           mystring_vector <- str_split(CleanData, "!")[[1]]

           FirstMatch <- second_string

           Match1 <- grepl(FirstMatch,mystring_vector[1])

           mystring <- paste(CleanData,sep=" ")
           mystring_vector <- str_split(CleanData, "!")[[1]]

           FirstMatch <- second_string

           Match1 <- grepl(FirstMatch,mystring_vector[1])

          FinalOutput <- paste(pdf_list,Outid, Match1)

          View(FinalOutput)

            if (Match1 == TRUE)
            {
                DATA1  <- paste(ID = pdf_list, Outid = FirstMatch , Keywordinnote = Match1)

            }

     }
}

View(DATA1)

### I shall email you the pdf files

Expected output is:
ID  outid       keywordinnote
1   news        TRUE
2   new formula TRUE


text:
Q: Windows 8 hang after installing virtualbox After I install virtualbox, my pc hang at reboot.
After sometime, it prompted me more setting, I choose to restore to a certain point, but it fail to restore because of antivirus.
How to disable antivirus. I am worried my data and installed software is lost.
How can I solve the problem. It take hours to see the restore mode.

A: reinstall in incompatibility mode for earlier version of windows.
right click on setup -> open properties -> click on compatibility tab -> Tick Run this program in compatibility mode for -> select windows 7 or earlier version on which it your application worked successfully.
            -->> apply -->> Ok

run the setup to install again.


text:
Q: Passing pointers between C and Java through JNI I've been storing c pointers in Java through JNI by following the advice of @tulskiy in this post Passing pointers between C and Java through JNI
The trick is to cast the pointer as a jlong. So from c I have return (jlong) ptr;
I'm returning a jlong (always 64 bits) because I want my code to work on both 64 and 32 bit systems. The size in memory of a 64 bit pointer on a 64 bit computer is 64 and it follows that on a 32-bit computer, the size of the pointer in memory is 32 bits.
The problem is that on the 32 bit machine I get a compiler warning saying "casting to integer from pointer of different size." The warnings goes away if I have
return (jlong) (int32_t) ptr; However this code is not good for the 64 bit machine.
I would like to have my code compile without warnings so that if there is a legitimate warning I will see it. Anyone have any ideas?
Thanks,
Ben

A: There are various handy integer types in C. The one you want is probably intptr_t or uintptr_t:
return (jlong)(intptr_t) ptr;

The difference?

*

*Casting from intptr_t to jlong and back is guaranteed to work provided jlong is big enough (which you're implicitly assuming it is anyway).

*Casting from uinttptr_t to jlong and back avoids a sign-extension, but is undefined behaviour if the uintptr_t is too big to fit in a jlong (but all "sane" architectures/compilers just use two's complement arithmetic)

A: Try casting with intptr_t (store a pointer regardless of the platform capacity).


text:
Q: ubuntu 15.04 no sound there is no sound on my desktop and my Chassis Information are:
Handle 0x0003, DMI type 3, 22 bytes
Chassis Information
    Manufacturer: Gigabyte Technology Co., Ltd.
    Type: Desktop
    Lock: Not Present
    Version: To Be Filled By O.E.M.
    Serial Number: To Be Filled By O.E.M.
    Asset Tag: To Be Filled By O.E.M.
    Boot-up State: Safe
    Power Supply State: Safe
    Thermal State: Safe
    Security Status: None
    OEM Information: 0x00000000
    Height: Unspecified
    Number Of Power Cords: 1
    Contained Elements: 0
    SKU Number: To be filled by O.E.M.

And
☁ $  sudo dmidecode
# dmidecode 2.12
# SMBIOS entry point at 0x000f04c0
SMBIOS 2.7 present.
76 structures occupying 3104 bytes.
Table at 0x000EC070.

Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
    Vendor: American Megatrends Inc.
    Version: F1
    Release Date: 02/24/2015
    Address: 0xF0000
    Runtime Size: 64 kB
    ROM Size: 4096 kB
    Characteristics:
        PCI is supported
        BIOS is upgradeable
        BIOS shadowing is allowed
        Boot from CD is supported
        Selectable boot is supported
        BIOS ROM is socketed
        EDD is supported
        5.25"/1.2 MB floppy services are supported (int 13h)
        3.5"/720 kB floppy services are supported (int 13h)
        3.5"/2.88 MB floppy services are supported (int 13h)
        Print screen service is supported (int 5h)
        8042 keyboard services are supported (int 9h)
        Serial services are supported (int 14h)
        Printer services are supported (int 17h)
        ACPI is supported
        USB legacy is supported
        BIOS boot specification is supported
        Targeted content distribution is supported
        UEFI is supported
    BIOS Revision: 4.6

Handle 0x0001, DMI type 1, 27 bytes
System Information
    Manufacturer: Gigabyte Technology Co., Ltd.
    Product Name: B85M-D2V-TM
    Version: To be filled by O.E.M.
    Serial Number: To be filled by O.E.M.
    UUID: 038D0240-045C-0525-2F06-180700080009
    Wake-up Type: Power Switch
    SKU Number: To be filled by O.E.M.
    Family: To be filled by O.E.M.

Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
    Manufacturer: Gigabyte Technology Co., Ltd.
    Product Name: B85M-D2V-TM
    Version: x.x
    Serial Number: To be filled by O.E.M.
    Asset Tag: To be filled by O.E.M.
    Features:
        Board is a hosting board
        Board is replaceable
    Location In Chassis: To be filled by O.E.M.
    Chassis Handle: 0x0003
    Type: Motherboard
    Contained Object Handles: 0

Handle 0x0003, DMI type 3, 22 bytes
Chassis Information
    Manufacturer: Gigabyte Technology Co., Ltd.
    Type: Desktop
    Lock: Not Present
    Version: To Be Filled By O.E.M.
    Serial Number: To Be Filled By O.E.M.
    Asset Tag: To Be Filled By O.E.M.
    Boot-up State: Safe
    Power Supply State: Safe
    Thermal State: Safe
    Security Status: None
    OEM Information: 0x00000000
    Height: Unspecified
    Number Of Power Cords: 1
    Contained Elements: 0
    SKU Number: To be filled by O.E.M.

Handle 0x0004, DMI type 7, 19 bytes
Cache Information
    Socket Designation: CPU Internal L1
    Configuration: Enabled, Not Socketed, Level 1
    Operational Mode: Write Back
    Location: Internal
    Installed Size: 256 kB
    Maximum Size: 256 kB
    Supported SRAM Types:
        Unknown
    Installed SRAM Type: Unknown
    Speed: Unknown
    Error Correction Type: Single-bit ECC
    System Type: Other
    Associativity: 8-way Set-associative

Handle 0x0005, DMI type 7, 19 bytes
Cache Information
    Socket Designation: CPU Internal L2
    Configuration: Enabled, Not Socketed, Level 2
    Operational Mode: Write Back
    Location: Internal
    Installed Size: 1024 kB
    Maximum Size: 1024 kB
    Supported SRAM Types:
        Unknown
    Installed SRAM Type: Unknown
    Speed: Unknown
    Error Correction Type: Single-bit ECC
    System Type: Unified
    Associativity: 8-way Set-associative

Handle 0x0006, DMI type 7, 19 bytes
Cache Information
    Socket Designation: CPU Internal L3
    Configuration: Enabled, Not Socketed, Level 3
    Operational Mode: Write Back
    Location: Internal
    Installed Size: 6144 kB
    Maximum Size: 6144 kB
    Supported SRAM Types:
        Unknown
    Installed SRAM Type: Unknown
    Speed: Unknown
    Error Correction Type: Single-bit ECC
    System Type: Unified
    Associativity: 12-way Set-associative

Handle 0x0007, DMI type 16, 23 bytes
Physical Memory Array
    Location: System Board Or Motherboard
    Use: System Memory
    Error Correction Type: None
    Maximum Capacity: 32 GB
    Error Information Handle: Not Provided
    Number Of Devices: 2

Handle 0x0008, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J1A1
    Internal Connector Type: None
    External Reference Designator: PS2Mouse
    External Connector Type: PS/2
    Port Type: Mouse Port

Handle 0x0009, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J1A1
    Internal Connector Type: None
    External Reference Designator: Keyboard
    External Connector Type: PS/2
    Port Type: Keyboard Port

Handle 0x000A, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J2A1
    Internal Connector Type: None
    External Reference Designator: TV Out
    External Connector Type: Mini Centronics Type-14
    Port Type: Other

Handle 0x000B, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J2A2A
    Internal Connector Type: None
    External Reference Designator: COM A
    External Connector Type: DB-9 male
    Port Type: Serial Port 16550A Compatible

Handle 0x000C, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J2A2B
    Internal Connector Type: None
    External Reference Designator: Video
    External Connector Type: DB-15 female
    Port Type: Video Port

Handle 0x000D, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J3A1
    Internal Connector Type: None
    External Reference Designator: USB1
    External Connector Type: Access Bus (USB)
    Port Type: USB

Handle 0x000E, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J3A1
    Internal Connector Type: None
    External Reference Designator: USB2
    External Connector Type: Access Bus (USB)
    Port Type: USB

Handle 0x000F, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J3A1
    Internal Connector Type: None
    External Reference Designator: USB3
    External Connector Type: Access Bus (USB)
    Port Type: USB

Handle 0x0010, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J9A1 - TPM HDR
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x0011, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J9C1 - PCIE DOCKING CONN
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x0012, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J2B3 - CPU FAN
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x0013, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J6C2 - EXT HDMI
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x0014, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J3C1 - GMCH FAN
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x0015, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J1D1 - ITP
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x0016, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J9E2 - MDC INTPSR
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x0017, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J9E4 - MDC INTPSR
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x0018, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J9E3 - LPC HOT DOCKING
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x0019, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J9E1 - SCAN MATRIX
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x001A, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J9G1 - LPC SIDE BAND
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x001B, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J8F1 - UNIFIED
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x001C, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J6F1 - LVDS
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x001D, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J2F1 - LAI FAN
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x001E, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J2G1 - GFX VID
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x001F, DMI type 8, 9 bytes
Port Connector Information
    Internal Reference Designator: J1G6 - AC JACK
    Internal Connector Type: Other
    External Reference Designator: Not Specified
    External Connector Type: None
    Port Type: Other

Handle 0x0020, DMI type 9, 17 bytes
System Slot Information
    Designation: J6B2
    Type: x16 PCI Express
    Current Usage: In Use
    Length: Long
    ID: 0
    Characteristics:
        3.3 V is provided
        Opening is shared
        PME signal is supported
    Bus Address: 0000:00:02.0

Handle 0x0021, DMI type 9, 17 bytes
System Slot Information
    Designation: J6B1
    Type: x1 PCI Express
    Current Usage: In Use
    Length: Short
    ID: 1
    Characteristics:
        3.3 V is provided
        Opening is shared
        PME signal is supported
    Bus Address: 0000:00:1c.0

Handle 0x0022, DMI type 9, 17 bytes
System Slot Information
    Designation: J6D1
    Type: x8 PCI Express
    Current Usage: In Use
    Length: Short
    ID: 2
    Characteristics:
        3.3 V is provided
        Opening is shared
        PME signal is supported
    Bus Address: 0000:00:01.0

Handle 0x0023, DMI type 9, 17 bytes
System Slot Information
    Designation: J7B1
    Type: x16 PCI Express
    Current Usage: In Use
    Length: Short
    ID: 3
    Characteristics:
        3.3 V is provided
        Opening is shared
        PME signal is supported
    Bus Address: 0000:00:03.0

Handle 0x0024, DMI type 9, 17 bytes
System Slot Information
    Designation: J8B4
    Type: x1 PCI Express
    Current Usage: In Use
    Length: Short
    ID: 4
    Characteristics:
        3.3 V is provided
        Opening is shared
        PME signal is supported
    Bus Address: 0000:00:1c.7

Handle 0x0025, DMI type 9, 17 bytes
System Slot Information
    Designation: J8B3
    Type: 32-bit PCI
    Current Usage: In Use
    Length: Short
    ID: 6
    Characteristics:
        3.3 V is provided
        Opening is shared
        PME signal is supported
    Bus Address: 0000:14:1e.0

Handle 0x0026, DMI type 10, 6 bytes
On Board Device Information
    Type: Video
    Status: Enabled
    Description:    To Be Filled By O.E.M.

Handle 0x0027, DMI type 11, 5 bytes
OEM Strings
    String 1: To Be Filled By O.E.M.
    String 2: To Be Filled By O.E.M.
    String 3: To Be Filled By O.E.M.
    String 4: To Be Filled By O.E.M.
    String 5: To Be Filled By O.E.M.

Handle 0x0028, DMI type 12, 5 bytes
System Configuration Options
    Option 1: To Be Filled By O.E.M.

Handle 0x0029, DMI type 24, 5 bytes
Hardware Security
    Power-On Password Status: Disabled
    Keyboard Password Status: Disabled
    Administrator Password Status: Disabled
    Front Panel Reset Status: Disabled

Handle 0x002A, DMI type 32, 20 bytes
System Boot Information
    Status: No errors detected

Handle 0x002B, DMI type 34, 11 bytes
Management Device
    Description: LM78-1
    Type: LM78
    Address: 0x00000000
    Address Type: I/O Port

Handle 0x002C, DMI type 26, 22 bytes
Voltage Probe
    Description: LM78A
    Location: <OUT OF SPEC>
    Status: <OUT OF SPEC>
    Maximum Value: Unknown
    Minimum Value: Unknown
    Resolution: Unknown
    Tolerance: Unknown
    Accuracy: Unknown
    OEM-specific Information: 0x00000000
    Nominal Value: Unknown

Handle 0x002D, DMI type 36, 16 bytes
Management Device Threshold Data
    Lower Non-critical Threshold: 1
    Upper Non-critical Threshold: 2
    Lower Critical Threshold: 3
    Upper Critical Threshold: 4
    Lower Non-recoverable Threshold: 5
    Upper Non-recoverable Threshold: 6

Handle 0x002E, DMI type 35, 11 bytes
Management Device Component
    Description: To Be Filled By O.E.M.
    Management Device Handle: 0x002B
    Component Handle: 0x002B
    Threshold Handle: 0x002C

Handle 0x002F, DMI type 28, 22 bytes
Temperature Probe
    Description: LM78A
    Location: <OUT OF SPEC>
    Status: <OUT OF SPEC>
    Maximum Value: Unknown
    Minimum Value: Unknown
    Resolution: Unknown
    Tolerance: Unknown
    Accuracy: Unknown
    OEM-specific Information: 0x00000000
    Nominal Value: Unknown

Handle 0x0030, DMI type 36, 16 bytes
Management Device Threshold Data
    Lower Non-critical Threshold: 1
    Upper Non-critical Threshold: 2
    Lower Critical Threshold: 3
    Upper Critical Threshold: 4
    Lower Non-recoverable Threshold: 5
    Upper Non-recoverable Threshold: 6

Handle 0x0031, DMI type 35, 11 bytes
Management Device Component
    Description: To Be Filled By O.E.M.
    Management Device Handle: 0x002B
    Component Handle: 0x002E
    Threshold Handle: 0x002F

Handle 0x0032, DMI type 27, 15 bytes
Cooling Device
    Temperature Probe Handle: 0x002F
    Type: <OUT OF SPEC>
    Status: <OUT OF SPEC>
    Cooling Unit Group: 1
    OEM-specific Information: 0x00000000
    Nominal Speed: Unknown Or Non-rotating
    Description: Cooling Dev 1

Handle 0x0033, DMI type 36, 16 bytes
Management Device Threshold Data
    Lower Non-critical Threshold: 1
    Upper Non-critical Threshold: 2
    Lower Critical Threshold: 3
    Upper Critical Threshold: 4
    Lower Non-recoverable Threshold: 5
    Upper Non-recoverable Threshold: 6

Handle 0x0034, DMI type 35, 11 bytes
Management Device Component
    Description: To Be Filled By O.E.M.
    Management Device Handle: 0x002B
    Component Handle: 0x0031
    Threshold Handle: 0x0032

Handle 0x0035, DMI type 27, 15 bytes
Cooling Device
    Temperature Probe Handle: 0x002F
    Type: <OUT OF SPEC>
    Status: <OUT OF SPEC>
    Cooling Unit Group: 1
    OEM-specific Information: 0x00000000
    Nominal Speed: Unknown Or Non-rotating
    Description: Not Specified

Handle 0x0036, DMI type 36, 16 bytes
Management Device Threshold Data
    Lower Non-critical Threshold: 1
    Upper Non-critical Threshold: 2
    Lower Critical Threshold: 3
    Upper Critical Threshold: 4
    Lower Non-recoverable Threshold: 5
    Upper Non-recoverable Threshold: 6

Handle 0x0037, DMI type 35, 11 bytes
Management Device Component
    Description: To Be Filled By O.E.M.
    Management Device Handle: 0x002B
    Component Handle: 0x0034
    Threshold Handle: 0x0035

Handle 0x0038, DMI type 29, 22 bytes
Electrical Current Probe
    Description: ABC
    Location: <OUT OF SPEC>
    Status: <OUT OF SPEC>
    Maximum Value: Unknown
    Minimum Value: Unknown
    Resolution: Unknown
    Tolerance: Unknown
    Accuracy: Unknown
    OEM-specific Information: 0x00000000
    Nominal Value: Unknown

Handle 0x0039, DMI type 36, 16 bytes
Management Device Threshold Data

Handle 0x003A, DMI type 35, 11 bytes
Management Device Component
    Description: To Be Filled By O.E.M.
    Management Device Handle: 0x002B
    Component Handle: 0x0037
    Threshold Handle: 0x0035

Handle 0x003B, DMI type 26, 22 bytes
Voltage Probe
    Description: LM78A
    Location: Power Unit
    Status: OK
    Maximum Value: Unknown
    Minimum Value: Unknown
    Resolution: Unknown
    Tolerance: Unknown
    Accuracy: Unknown
    OEM-specific Information: 0x00000000
    Nominal Value: Unknown

Handle 0x003C, DMI type 28, 22 bytes
Temperature Probe
    Description: LM78A
    Location: Power Unit
    Status: OK
    Maximum Value: Unknown
    Minimum Value: Unknown
    Resolution: Unknown
    Tolerance: Unknown
    Accuracy: Unknown
    OEM-specific Information: 0x00000000
    Nominal Value: Unknown

Handle 0x003D, DMI type 27, 15 bytes
Cooling Device
    Temperature Probe Handle: 0x003C
    Type: Power Supply Fan
    Status: OK
    Cooling Unit Group: 1
    OEM-specific Information: 0x00000000
    Nominal Speed: Unknown Or Non-rotating
    Description: Cooling Dev 1

Handle 0x003E, DMI type 29, 22 bytes
Electrical Current Probe
    Description: ABC
    Location: Power Unit
    Status: OK
    Maximum Value: Unknown
    Minimum Value: Unknown
    Resolution: Unknown
    Tolerance: Unknown
    Accuracy: Unknown
    OEM-specific Information: 0x00000000
    Nominal Value: Unknown

Handle 0x003F, DMI type 39, 22 bytes
System Power Supply
    Power Unit Group: 1
    Location: To Be Filled By O.E.M.
    Name: To Be Filled By O.E.M.
    Manufacturer: To Be Filled By O.E.M.
    Serial Number: To Be Filled By O.E.M.
    Asset Tag: To Be Filled By O.E.M.
    Model Part Number: To Be Filled By O.E.M.
    Revision: To Be Filled By O.E.M.
    Max Power Capacity: Unknown
    Status: Present, OK
    Type: Switching
    Input Voltage Range Switching: Auto-switch
    Plugged: Yes
    Hot Replaceable: No
    Input Voltage Probe Handle: 0x003B
    Cooling Device Handle: 0x003D
    Input Current Probe Handle: 0x003E

Handle 0x0040, DMI type 41, 11 bytes
Onboard Device
    Reference Designation:  Onboard LAN
    Type: Ethernet
    Status: Enabled
    Type Instance: 1
    Bus Address: 0000:00:19.0

Handle 0x0041, DMI type 4, 42 bytes
Processor Information
    Socket Designation: SOCKET 0
    Type: Central Processor
    Family: Core i7
    Manufacturer: Intel
    ID: C3 06 03 00 FF FB EB BF
    Signature: Type 0, Family 6, Model 60, Stepping 3
    Flags:
        FPU (Floating-point unit on-chip)
        VME (Virtual mode extension)
        DE (Debugging extension)
        PSE (Page size extension)
        TSC (Time stamp counter)
        MSR (Model specific registers)
        PAE (Physical address extension)
        MCE (Machine check exception)
        CX8 (CMPXCHG8 instruction supported)
        APIC (On-chip APIC hardware supported)
        SEP (Fast system call)
        MTRR (Memory type range registers)
        PGE (Page global enable)
        MCA (Machine check architecture)
        CMOV (Conditional move instruction supported)
        PAT (Page attribute table)
        PSE-36 (36-bit page size extension)
        CLFSH (CLFLUSH instruction supported)
        DS (Debug store)
        ACPI (ACPI supported)
        MMX (MMX technology supported)
        FXSR (FXSAVE and FXSTOR instructions supported)
        SSE (Streaming SIMD extensions)
        SSE2 (Streaming SIMD extensions 2)
        SS (Self-snoop)
        HTT (Multi-threading)
        TM (Thermal monitor supported)
        PBE (Pending break enabled)
    Version: Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
    Voltage: 1.0 V
    External Clock: 100 MHz
    Max Speed: 7000 MHz
    Current Speed: 3500 MHz
    Status: Populated, Enabled
    Upgrade: Other
    L1 Cache Handle: 0x0004
    L2 Cache Handle: 0x0005
    L3 Cache Handle: 0x0006
    Serial Number: Not Specified
    Asset Tag: Fill By OEM
    Part Number: Fill By OEM
    Core Count: 4
    Core Enabled: 1
    Characteristics:
        64-bit capable

Handle 0x0042, DMI type 17, 34 bytes
Memory Device
    Array Handle: 0x0007
    Error Information Handle: Not Provided
    Total Width: Unknown
    Data Width: Unknown
    Size: No Module Installed
    Form Factor: DIMM
    Set: None
    Locator: ChannelA-DIMM0
    Bank Locator: BANK 0
    Type: Unknown
    Type Detail: None
    Speed: Unknown
    Manufacturer: [Empty]
    Serial Number: [Empty]
    Asset Tag: 9876543210
    Part Number: [Empty]
    Rank: Unknown
    Configured Clock Speed: Unknown

Handle 0x0043, DMI type 17, 34 bytes
Memory Device
    Array Handle: 0x0007
    Error Information Handle: Not Provided
    Total Width: Unknown
    Data Width: Unknown
    Size: No Module Installed
    Form Factor: DIMM
    Set: None
    Locator: ChannelA-DIMM1
    Bank Locator: BANK 1
    Type: Unknown
    Type Detail: None
    Speed: Unknown
    Manufacturer: [Empty]
    Serial Number: [Empty]
    Asset Tag: 9876543210
    Part Number: [Empty]
    Rank: Unknown
    Configured Clock Speed: Unknown

Handle 0x0044, DMI type 17, 34 bytes
Memory Device
    Array Handle: 0x0007
    Error Information Handle: Not Provided
    Total Width: 64 bits
    Data Width: 64 bits
    Size: 8192 MB
    Form Factor: DIMM
    Set: None
    Locator: ChannelB-DIMM0
    Bank Locator: BANK 2
    Type: DDR3
    Type Detail: Synchronous
    Speed: 1600 MHz
    Manufacturer: 0420
    Serial Number: 00000000
    Asset Tag: 9876543210
    Part Number: F3-1600C11-8GNT
    Rank: 2
    Configured Clock Speed: 1600 MHz

Handle 0x0045, DMI type 20, 35 bytes
Memory Device Mapped Address
    Starting Address: 0x00000000000
    Ending Address: 0x001FFFFFFFF
    Range Size: 8 GB
    Physical Device Handle: 0x0044
    Memory Array Mapped Address Handle: 0x0047
    Partition Row Position: Unknown
    Interleave Position: Unknown
    Interleaved Data Depth: Unknown

Handle 0x0046, DMI type 17, 34 bytes
Memory Device
    Array Handle: 0x0007
    Error Information Handle: Not Provided
    Total Width: Unknown
    Data Width: Unknown
    Size: No Module Installed
    Form Factor: DIMM
    Set: None
    Locator: ChannelB-DIMM1
    Bank Locator: BANK 3
    Type: Unknown
    Type Detail: None
    Speed: Unknown
    Manufacturer: [Empty]
    Serial Number: [Empty]
    Asset Tag: 9876543210
    Part Number: [Empty]
    Rank: Unknown
    Configured Clock Speed: Unknown

Handle 0x0047, DMI type 19, 31 bytes
Memory Array Mapped Address
    Starting Address: 0x00000000000
    Ending Address: 0x001FFFFFFFF
    Range Size: 8 GB
    Physical Array Handle: 0x0007
    Partition Width: 4

Handle 0x004D, DMI type 136, 6 bytes
OEM-specific Type
    Header and Data:
        88 06 4D 00 00 00

Handle 0x004E, DMI type 131, 64 bytes
OEM-specific Type
    Header and Data:
        83 40 4E 00 35 00 00 00 00 00 00 00 00 00 00 00
        F8 00 50 8C 00 00 00 00 01 20 00 00 00 00 09 00
        CA 05 1E 00 00 00 00 00 C8 00 FF FF 00 00 00 00
        00 00 00 00 66 00 00 00 76 50 72 6F 00 00 00 00

Handle 0x004F, DMI type 13, 22 bytes
BIOS Language Information
    Language Description Format: Long
    Installable Languages: 7
        en|US|iso8859-1
        de|DE|iso8859-1
        ru|RU|iso8859-5
        ko|KR|unicode
        ja|JP|unicode
        zh|CS|unicode
        zh|CT|unicode
    Currently Installed Language: en|US|iso8859-1

Handle 0x0055, DMI type 127, 4 bytes
End Of Table

Information on audio:
☁  $  lspci| grep -i audio
00:1b.0 Audio device: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller (rev 05)
01:00.1 Audio device: NVIDIA Corporation Device 0fbc (rev a1)

☁  $  cat /proc/asound/cards
0 [PCH            ]: HDA-Intel - HDA Intel PCH
                     HDA Intel PCH at 0xf7210000 irq 30
1 [NVidia         ]: HDA-Intel - HDA NVidia
                     HDA NVidia at 0xf7080000 irq 17

☁ $  aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC887-VD Analog [ALC887-VD Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

My problem is there is no sound on the front Chassis Phone Out, but has sound on the back of the Chassis. And I have no idea how to solve it.

A: This is what can be tried in a situation like this:

*

*Running alsamixer in a terminal and see if there is an output that is muted;

*Checking if the jack is wired correctly to the sound card;

*Fiddling with hda-jack-retask, which can reroute sound pins on some cards. If this ends up the solution, maybe a bug should be reported in https://bugs.launchpad.net/ubuntu
(summarized from my comments above)


text:
Q: How do I center a rotated image using GDI+? I'm trying to center a rotated image into a destination buffer using GDI+. The source buffer and the destination buffer are different sizes.
The source buffer is the size of the image data: (width, height).
The destination buffer is the size of the rectangle required to fit the entire rotated image: (rotatedWidth, rotatedHeight).
This is the code I'm trying:
// Calculate the size needed for the image to be rotated into
int width = /* some width */;
int height = /* some height */;
System::Windows::Size destSize
  = IPMathUtilities::CalculateRotatedImageSize(rotateAreaBoundingPoints,
    rotationDegree, width, height);

//
// Create source bitmap object
Bitmap^ sourceBitmap = gcnew Bitmap(width, height, width * 2,
  PixelFormat::Format16bppRgb555, ptrSourceBuffer);

//
// Create destination bitmap object
int destBufferSize = destSize.Width * destSize.Height * 2;
BYTE* pDestBuffer = new BYTE[destBufferSize];
memset(pDestBuffer, 0, destBufferSize);
Bitmap^ destBitmap = gcnew Bitmap(destSize.Width, destSize.Height,
  destSize.Width * 2, PixelFormat::Format16bppRgb555, (IntPtr)pDestBuffer);

//
// Draw rotated source image in destination image
Graphics^ g = Graphics::FromImage(destBitmap);
g->TranslateTransform(-width/2, -height/2);
g->RotateTransform(rotationDegree, MatrixOrder::Append);
g->TranslateTransform(destSize.Width / 2.0, destSize.Height / 2.0,
  MatrixOrder::Append);
g->DrawImage(sourceBitmap, 0, 0, width, height);

This almost works. It's close - I'm finding if height is greater than width, the left position of the rotated image is incorrect. Similarly, if width is greater than height, the top position of the rotated image is incorrect.
Some notes:

*

*IPMathUtilities is a utility class I wrote.

*I'm 100% positive that IPMathUtilities::CalculateRotatedImageSize() calculates the correct size of the rectangle required to fit the entire rotated image. 100% certain. I've tested it thoroughly and it works.

*I recently asked a similar question: Why is iplRotate() not giving me correct results?. I ended giving up on IPL/IPP and trying GDI+.

Any ideas?

A: After the rotate, first move the image back to the original position, then additionally by half the difference the new canvas is larger. If your calculation in CalculateRotatedImageSize is indeed correct, it should then fit exactly. Just tested this code and it seems to work:
g.TranslateTransform((float)(org.Width / -2), (float)(org.Height / -2));
g.RotateTransform(45, System.Drawing.Drawing2D.MatrixOrder.Append );
g.TranslateTransform((float)(org.Width / 2), (float)(org.Height / 2), System.Drawing.Drawing2D.MatrixOrder.Append);
g.TranslateTransform((float)((rotated.Width - org.Width) / 2), (float)((rotated.Height - org.Height) / 2), System.Drawing.Drawing2D.MatrixOrder.Append);

EDIT: sorry, of course
g.TranslateTransform((float)(org.Width / 2), (float)(org.Height / 2), System.Drawing.Drawing2D.MatrixOrder.Append);
g.TranslateTransform((float)((rotated.Width - org.Width) / 2), (float)((rotated.Height - org.Height) / 2), System.Drawing.Drawing2D.MatrixOrder.Append);

is really the same as
g.TranslateTransform((float)(rotated.Width / 2), (float)(rotated.Height / 2), System.Drawing.Drawing2D.MatrixOrder.Append);

which is just the code you posted. Seems to work fine for me though.
EDIT2: perhaps the error is just
g->DrawImage(sourceBitmap, 0, 0, width, height);

Try
g->DrawImage(sourceBitmap, 0, 0);

instead


text:
Q: Exercise about truth functions in J.R.Shoenfield's "mathematical logic" The first exercise in Joseph R. Shoenfield's "mathematical logic" is:

An n-ary truth function $H$ is definable in terms of the truth functions $H_1,\dots,H_k$ if $H$ has a definition $$H(a_1,\dots,a_n)=\dots$$ where the right-hand side is built up from $H_1,\dots,H_k$,$a_1,\dots,a_n$, and commas and parentheses.

  a) Let $H_{d,n}$ be the truth function defined by setting $$H_{d,n}(a_1,\dots,a_n)=\mathbf{T} \iff a_i=\mathbf{T}$$ for at least one $i$, and let $H_{c,n}$ be the truth function defined by setting $$H_{c,n}(a_1,\dots,a_n)=\mathbf{T}\iff a_i=\mathbf{T}$$ for all $i$.

  Show that every truth function is definable in terms of $H_\neg$ and certain of the $H_{d,n}$ and $H_{c,n}$

Where $H_\neg$ is the standard unary negation ($H_\neg(\mathbf{T})=\mathbf{F}$ and $H_\neg(\mathbf{F})=\mathbf{T}$)
My thougths on this problem:
We can see that this is true for unary truth functions by testing all the 4 cases and for all the binary truth functions by testing all the 16 cases by hand.
For example consider the truth function defined by $$H(\mathbf{T},\mathbf{T})=\mathbf{F}$$
$$H(\mathbf{T},\mathbf{F})=\mathbf{F}$$
$$H(\mathbf{F},\mathbf{T})=\mathbf{F}$$
$$H(\mathbf{F},\mathbf{F})=\mathbf{T}$$
That is, in terms of the functions allowed by the problem $H_\neg(H_{d,2}(\mathbf{A},\mathbf{B}))$, where $\mathbf{A}$ and $\mathbf{B}$ are expressions with a truth value, possibly other truth functions.
Now that we know that this fact holds for binary truth functions we can split every $n$-ary truth function in 2 parts, an unary one and an $(n-1)$-ary one that are combined in the original $n-ary$ truth function in one of the 16 ways possible (and we know that they are all definable in terms of the function allowed, because I checked them by hand).
Now we can reason in the same way on the $(n-1)$-ary function and keep splitting until we reach our base case of binary functions thus proving the fact we were required to prove.

The problem is that I don't know wether my proof is correct and even if it is I think it's rather ugly, involving a lot of cases to be checked by hand, is there an easier way to approach this problem? (It'd be great if you could just give me an hint instead of the full answer)
Thanks
Alessandro

A: I've read the whole problem in Shoenfield's book, and I think it is quite clear that the author is guiding the readers to the concept of expressively adequate set of connectives (those that can express all truth-functions of the language), splitting the process in several steps. And I am not sure what the author means by "certain of the $H_{d,n}$ and $H_{c,n}$". Perhaps as many of them as we want, or perhaps the "obvious" choice: $H_{d,2}$ and $H_{c,2}$ (which are $H_{\lor}$ and $H_\&$). In fact, it does not matter since any $H_{d,n}$ is definable in terms of $H_{d,2}$ (and the same for $H_{c,n}$):
$H_{d,n}=H_{d,2}(a_1,H_{d,2}(a_2,H_{d,2}(a_3,H_{d,2}(\dots,H_{d,n}(a_{n-1},a_n)\dots))))$
Your proof seems correct to me, but I think your answer is a much stronger result that the one asked in part (a) of the problem. In fact, if in the second step you show that any binary function is definable in terms of $H_\neg$ and $H_{d,2}$ (which I am sure you can do...), you are answering question b) of the problem:

b) Show that every truth function is definable in terms of $H_\neg$ and $H_{\lor}$. [Use (a).]

For part (a), I'd do the following, which is equivalent to writing a formula in disyunctive normal form (one or more disjuncts each of which is a basic conjuntion).
Let $H$ be any $n$-ary truth function. Then either $H$ is always $\mathbf{F}$ or it's $\mathbf{T}$ for at least one valuation of its arguments:

*

*If $H(a_1,\dots,a_n)=\mathbf{F}$ for any valuation of
$a_1,\dots,a_n$, then:
$H(a_1,\dots,a_n)=H_{d,n}(H_{c,2}(a_1,H_\neg(a_1)),H_{c,2}(a_2,H_\neg(a_2)),\dots, H_{c,2}(a_n,H_\neg(a_n)))$
(or any other expression wich fullfills the criteria of the problem and has the constant value $\mathbf{F}$).

*Let's say that $H=\mathbf{T}$ for $m$ different n-tuples (valuations). Then $H=H_{d,m}(H_{c,n}(1),\dots,H_{c,n}(m))$ where each $H_{c,n}(i)$ is built in the following way: it is the same as the function $H_{c,n}$ but with the unary negation applied to any argument whose value in the i-tuple (valuation) is $\mathbf{F}$.
For example, if $H=\mathbf{T}$ for just the two cases: $a_1=\mathbf{F}$, $a_2=\dots=a_n=\mathbf{T}$; and $a_1=\dots=a_{n-1}=\mathbf{T}, a_n=\mathbf{F}$ then:
$H(a_1,\dots,a_n)=H_{d,2}(H_{c,n}(H_\neg(a_1),a_2,\dots,a_n),H_{c,n}(a_1,a_2,\dots,H_\neg(a_n)))$
It is easy to check that this evaluates to $\mathbf{T}$ just in those two cases, because in fact it has been built to do so.
So, this shows that any n-ary function $H$ is definable in terms of $H_\neg$, $H_{c,n}$, $H_{c,2}$ and one function $H_{d,m}$. But (given the above remarks about the binary functions), this implies that is definable in terms $H_\neg$, $H_{\lor}$ and $H_{\&}$.

A: Sounds correct to me.  You're essentially proving this by induction on $n$.  And, yes, it's kind of ugly because you have to go through the 16 cases once, but I think there's no "elegant" way around that.


text:
Q: Android permissions, signature and the developer's key I am developing an application which has a number of components, each component will be a separate Android app.  The "Core" app will use content providers to offer access to the database, and reading the permissions documentation "Signature" protection is the way I want to go.
I've defined a group for my permission, mainly so my permissions would show up nicely against my own icon in the "Permissions" section of the App Info.  with android:protectionLevel="normal" they show up just fine.  But when I use the android:protectionLevel="signature" they disappear.
<permission-group
    android:name="com.example.permissions.GROUP"
    android:label="@string/lblGroup"
    android:description="@string/descGroup"
    android:icon="@drawable/ic_menu_permissions_group" />

<permission
    android:name="com.example.permission.CONFIG_READ"
    android:permissionGroup="com.example.permissions.GROUP"
    android:protectionLevel="signature"
    android:label="@string/lblConfigRead"
    android:description="@string/descConfigRead" />
<permission
    android:name="com.example.permission.CONFIG_WRITE"
    android:permissionGroup="com.example.permissions.GROUP"
    android:protectionLevel="signature"
    android:label="@string/lblConfigWrite"
    android:description="@string/descConfigWrite" />

Given that I am currently developing and, therefore using the developers key, are there some other hoops I need to jump through in order to get the "signature" protection level to work for developers?
As always many thanks for your help
Steve

A:
But when I use the android:protectionLevel="signature" they disappear.

That is because the user does not need to approve them. Signature-level permissions are automatically granted and denied based upon the signatures of the apps.

are there some other hoops I need to jump through in order to get the "signature" protection level to work for developers?

It already works, for your own apps. If "developers" are third parties, you cannot use signature-level permissions, as they will be signing with their own signing keys.


text:
Q: C++17: Difference in pointer storage between unique_ptr and shared_ptr I am getting confused with:
unique_ptr<char[]> u_ptr = make_unique<char[]>(10);
sprint(u_ptr.get(), 10, "milos"); // get returns char*
cout << u_ptr.get(); // get returns char*

And:
shared_ptr<char[]> s_ptr = make_shared<char[]>(10);
sprint(*s_ptr.get(), 10, "milos"); // get here returns char** ?
cout << *s_ptr.get(); // get here returns char** ?

So, while unique_ptr<char[]> returns char* for the underlying array, shared_ptr<char[]> seems to return char(*)[] pointer to array pointer?
I made few tests and I could use shared_ptr<char> with default delete:
shared_ptr<char> s_ptr(new char[10], default_delete<char[]>());
sprint(s_ptr.get(), 10, "milos"); // get here returns char*, fine
cout << s_ptr.get(); // same here

But I'm guessing the idea behind C++17 is not the approach with shared_ptr<char> and custom specified deleter: default_delete<char[]> cause this was possible prior to C++17.
Can someone clarify correct usage, and why does following occurs:
unique_ptr<int> u = make_unique<int>(5);
auto iu = u.get(); // iu is typeof int*

at the same time
unique_ptr<int[]> ua = make_unique<int[]>(5);
auto iua = ua.get(); // iua is still typeof int* ?

While for shared_ptr:
shared_ptr<int> s = make_shared<int>(5);
auto is = s.get(); // is is typeof int*

but
shared_ptr<int[]> sa = make_shared<int[]>(5);
auto isa = sa.get(); // isa is typeof int** ???

.

A: std::unique_ptr has a specific specialisation for when T is an array type. This causes the correct default deleter to be selected.
For better or worse, std::shared_ptr does not (while std::make_shared does as of c++20).
The behaviour you see in shared_ptr, returning a T** as a result of calling get() is an anomaly which has been fixed in c++17 (it will now return T*).
This is because until c++17, std::shared_ptr::element_type was T and std::shared_ptr::get returned a T*.
As of c++17 element_type is defined to be std::remove_extent_t<T> and get() returns element_type*;
so given using SAI = std::shared_ptr<int[]>
in c++14:
SAI::element_type = int[]
SAI::get() -> (int[])* which decays to int**
in c++17:
SAI::element_type = int
SAI::get() -> int*
Documentation links for reference:
https://en.cppreference.com/w/cpp/memory/unique_ptr
https://en.cppreference.com/w/cpp/memory/shared_ptr
As far as I am aware, the way to create a shared array prior to c++17 would be something like this:
#include <memory>

int main()
{
    auto uai = std::make_unique<int[]>(10);
    std::shared_ptr<int> sai { uai.release(), uai.get_deleter() };
}

and after c++17:
#include <memory>

int main()
{
    std::shared_ptr<int[]> sai = std::make_unique<int[]>(10);
}


text:
Q: OpenGL applying filters to textures with slick.util textures I am learing openGL using lwjgl. I am trying to see the effects of different filters on textures. to load the textures i am using SlickUtil.TextureLoader to load the textures and only the first 2 texture filter options work and the others result in a blank texture. if anyone knows what i am doing wrong or how to manually apply filters after a texture has been loaded please say so;
Texture[] textures = new Texture[6];
textures[0] = TextureLoader.getTexture("BMP", new FileInputStream("src/Textures/Glass.bmp"), GL_NEAREST);
textures[1] = TextureLoader.getTexture("BMP", new FileInputStream("src/Textures/Glass.bmp"), GL_LINEAR);
textures[2] = TextureLoader.getTexture("BMP", new FileInputStream("src/Textures/Glass.bmp"), GL_NEAREST_MIPMAP_NEAREST);
textures[3] = TextureLoader.getTexture("BMP", new FileInputStream("src/Textures/Glass.bmp"), GL_LINEAR_MIPMAP_NEAREST);
textures[4] = TextureLoader.getTexture("BMP", new FileInputStream("src/Textures/Glass.bmp"), GL_NEAREST_MIPMAP_LINEAR);
textures[5] = TextureLoader.getTexture("BMP", new FileInputStream("src/Textures/Glass.bmp"), GL_LINEAR_MIPMAP_LINEAR);

A: The *MIPMAP* filters require a complete mipmap chain, and it's pretty obvious that the texture loader isn't creating the mipmap chain. Mipmaps can be loaded from a file, or generated by OpenGL using glGenerateMipmap().
The usual symptom of a incomplete mipmap chain and a mipmap filter, is that the texture looks completely white (or black).
For LWJGL, you can use glGenerateMipmap (GL30, OpenGL 3.0) or glGenerateMipmapEXT (GL_EXT_framebuffer_object extension).
To use it, just bind the texture with glBindTexture, and call glGenerateMipmap with the correct texture target (the same as glBindTexture).