INSTRUCTION
stringlengths 25
999
| RESPONSE
stringlengths 0
999
| SOURCE
stringlengths 16
38
| METADATA
dict |
---|---|---|---|
UrlFetchApp timeout
I'm trying to download some reports using Google Sheets.
So basically I'm using `UrlFetchApp`to do the job and it does when the response is received within 1 minute. If the response is taking more than a minute then the request times out and the reports are not downloaded.
This is the options that I'm sending with `UrlFetchApp`:
var options = {
"method" : "post",
"header" : "someHeaders",
"muteHttpExceptions" : true,
"followRedirects" : false,
"Content-Encoding" : "gzip",
"payload" : "somePayload"
}
and then a simple call of `.fetch()`.
Is there a way to increase the timeout or any workaround for it? | Although it's not publicly documented, I realized by testing that fetch functions for `UrlFetchApp` [1] have a 1 minute timeout. There's a Feature Request open to extend or allow to configure the `UrlFetchApp` timeout [2].
[1] <
[2] < | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 5,
"tags": "google apps script, google sheets, google sheets api"
} |
Checkout old commit and make it a new commit
On Git, say I mess up my commits, and I want to make the version 3 commits ago as the new version. If I do `git checkout xxxx`, it creates a new branch and it seems like I can only merge it? Could I make this the new "master version"?
I want:
A-B-C-D-E
to become
A-B-C-D-E-F
where F has exactly the same content as C
If I use `git revert xxxx` instead, it seems like it definitely will have conflicts and I need to manually resolve it.
What I really want is just make the old commit at some point the new commit, regardless of what's in my working directory or the latest commit.
How would I go about doing this? | git rm -r .
git checkout HEAD~3 .
git commit
After the commit, files in the new `HEAD` will be the same as they were in the revision `HEAD~3`. | stackexchange-stackoverflow | {
"answer_score": 242,
"question_score": 235,
"tags": "git"
} |
contentOffset skips values in Log
So i have the following code:
int actualPosition = self.collectionView.contentOffset.y;
NSLog(@"%i", actualPosition);
The output is:
2013-03-28 15:36:42.737 test[10544:907] 484
2013-03-28 15:36:42.754 test[10544:907] 490
2013-03-28 15:36:42.770 test[10544:907] 512
2013-03-28 15:36:42.787 test[10544:907] 550
My question now is: why does it "skip" (as in why does "actualPosition" never have those values) 485-489, 491-511, and 513-549? Shouldn't it log/give actualPosition this value for all the "positions", even when I scroll faster? It works the same way for float, so this does not matter. How do I solve this so that actualPosition receives the value of every position that has been scrolled through? | Since there are a lot of pixels in screen and only some time to move what you scrolled, those values get "jumped" over by FPS. In other words if you move 100 pixels in 1 second with 30fps, one fps will jump value by 33 pixels. So you will get +3 every step instead of +1.
Getting exact position all the time is impossible, since there may be some scroll gesture so fast, that whole screen flies by in one frame. So the "jump" would be as big as screen. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "ios, xcode, skip, collectionview, contentoffset"
} |
Query to get first time customers per week
how can I get the number of new/first time customers per week from my magento store with an SQL query?
Does somebody knows that?
Thanks. | You want to retrieve customers which accounts are no older than 7 days, right?
If this is it, it's a pretty easy SQL Query. Something like this can do the job:
SELECT *
FROM customer_entity
WHERE (
`created_at` > DATE_SUB( NOW( ) , INTERVAL 7
DAY )
)
LIMIT 0 , 30
Ofcourse then you receive whole records, not just the count of new customers.
If you'd like to retrieve just the count of them use:
SELECT COUNT(*) FROM customer_entity WHERE (`created_at` > DATE_SUB(now(), INTERVAL 365 DAY));
Here's a great answer from another question how timestamp queries should be done: < | stackexchange-magento | {
"answer_score": 1,
"question_score": 1,
"tags": "database"
} |
SELECT values from two tables using third table as common column as link
I'm sorry for the post title. I wasn't sure how to word that... I have a query that is working fine:
SELECT
j.SubscriberKey,
j.JobID,
j.EventDate
from _Sent j
where
DATEPART(m, j.EventDate) = DATEPART(m, DATEADD(m, -1, GETDATE()))
AND DATEPART(yyyy, j.EventDate) = DATEPART(yyyy, DATEADD(m, -1, GETDATE()))
But I need to get another value c.Name in table Campaign_Salesforce, but in order to match I need to match values in yet another table Lead_Salesforce.
So Lead_Salesforce has a column Id which is the same as the SubscriberKey in my query above. Campaign_Salesforce has an Id column which matches the column Consumer_newsletter__c in Lead_Salesforce. Hopefully the picture below can help.
 x
ON j.SubscriberKey = x.id
where
DATEPART(m, j.EventDate) = DATEPART(m, DATEADD(m, -1, GETDATE()))
AND DATEPART(yyyy, j.EventDate) = DATEPART(yyyy, DATEADD(m, -1, GETDATE()))
For optimisation you might want to might want to perform the subquery in a staging table. | stackexchange-salesforce | {
"answer_score": 0,
"question_score": 0,
"tags": "marketing cloud, query"
} |
matrix normalisation between -1 and 1
I am using python and I have a matrix and would like to normalize individual columns in it between [-1,1]
a = matrix
([[3, 2, 4, 6]
[4, 5, 6, 5]
[6, 4, 5, 3]
[3, 5, 6, 7]])
I applied
`a = a / np.linalg.norm(a, axis=0, keepdims=True)`
and the a was normalized between [0,1]
however, I would like to do something like `.apply(lambda x: np.where(x>0,x/x.max(),np.where(x<0,-x/x.min(),x)))` so that it can get normalised between [-1,1] and the zero position is the same.
but it is not possible to use `.apply` in a matrix, how can I overcome it? | import numpy as np
matrix = np.array([[1, 2, 3],[-1, -2, -3]])
maxElement = np.amax(matrix)
new_matrix = matrix/maxElement
print(new_matrix)
Find the largest element in the matrix and divide it with all elements | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 2,
"tags": "python, matrix"
} |
Need suggestion to use SDL Translation product for automated translation work
I am not sure if this is a right place to discuss this type of issue, but sharing for experts suggestion. My client needs an automated system for translation which translate the data with minimal manual intervention. Flow of data is high and they need translated data at run time(as fast as possible). This is a non-tridion based website and translation of data required is back and forth(example, Finnish to Swedish and Swedish to Finnish). I am exploring all SDL language product but not able to find any product which can fulfill the requirement. I am already in touch with SDL marketing team to suggest some solution. Can anyone provide some suggestion if already worked on this kind of solution.. | Indeed, your question might get flagged as off topic here.
If fast, "run time" translation is required then you will clearly not be able to rely on human translation due to the time that takes but instead will require some form of machine translation.
SDL Language Cloud has a machine translation API available that you could use (this is the technology that powers SDL's own FreeTranslation.com, which does have support for Finnish and Swedish). There's also the Google Translate API. | stackexchange-tridion | {
"answer_score": 3,
"question_score": 2,
"tags": "translation manager, worldserver"
} |
Adjacent JSX elements must be wrapped in an enclosing tag with bootstrap columns
I am using React Bootstrap and trying to loop through content which is in two separate columns like this:
<Container>
<Row>
{this.state.products.map(product => (
<Col md={8}>
<div className="title">{product.name}</div>
<div className="desc">{product.description}</div>
</Col>
<Col md={4}>
<div className="price">{product.price}</div>
</Col>
))}
</Row>
</Container>
I have my closing tags so not sure why I a getting the error? | The return of your map also needs to be wrapped in a containing tag, you can use React fragment tags <> <
<Container>
<Row>
{this.state.products.map(product => (
<>
<Col md={8}>
<div className="title">{product.name}</div>
<div className="desc">{product.description}</div>
</Col>
<Col md={4}>
<div className="price">{product.price}</div>
</Col>
</>
))}
</Row>
</Container> | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "reactjs, react bootstrap"
} |
How to move (unpushed) commits from one branch to the other
I was on `branch-x` and made few changes and committed them (but did not push). Although the commits were correct, they should not have been made in `branch-x` but instead in `branch-y`. How can I take the commits from `branch-x` and apply them to `branch-y`. I want to avoid pushing the committed changes from `branch-x`.
Below is what I did in commands.
(branch-x)$: git status
(branch-x)$: git add .
(branch-x)$: git commit -m "some commit"
<oops, I should have made these changes in branch-y>
(branch-x)$: git checkout -b branch-y
(branch-y)$: <how can I take the commit from branch-x and apply it here?> | Since you already created the branch you want via `git checkout -b branch-y`, and this new branch has the commit you want, then the only remaining problem is an extra rogue commit on the tip of `branch-x`. Since you did not publish `branch-x` yet, you should be safe in rewriting that history. Do this:
git checkout branch-x # switch back to branch-x
git reset --hard HEAD~1 # nuke the rogue commit on the tip of this branch | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 2,
"tags": "git"
} |
decoding key-value fails the parsing in swift
I have these Models :
struct City: Decodable {
let famous: Flags
let name: Name
}
struct Name: Decodable {
var common , official : String
var nativeName: [String:NativeName]
enum CodingKeys: String, CodingKey {
case common, official
case nativeName = "nativeName"
}
struct NativeName: Codable {
let official, common: String
enum CodingKeys: String, CodingKey {
case official, common
}
Decoding command:
let content = try? decoder.decode([Cities].self, from: data)
as soon as comment the var nativeName: [String:NativeName] line everyThing is okay
how can I sterilize? | Your `nativeName` key is optional
let nativeName: [String:NativeName]?
Also delete all `enum CodingKeys: String, CodingKey {` content in your case there is no need for it at all | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "json, swift, codable"
} |
Is there a way to disable fakeredis once it's loaded?
I'm working with some code that uses the fakeredis gem for specs, but whenever I run those specs from a REPL, fakeredis stays around and commands like `Redis.new` will just give me fakeredis. I need to be able to disable it to be able to access the real redis store again.
Is there a way to disable/enable it in the REPL? | Two solutions, either remove the fakeredis memory class:
Redis::Connection.drivers.delete_if {|d| d == Redis::Connection::Memory }
or append the Ruby adapter again:
Redis::Connection.drivers << Redis::Connection::Ruby
Source: < | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "ruby, rubygems"
} |
Centering text in C# console app only working with some input
I am having a problem with centering text in a C#.NET4 console app.
This is my method for centering the text:
private static void centerText(String text)
{
int winWidth = (Console.WindowWidth / 2);
Console.WriteLine(String.Format("{0,"+winWidth+"}", text));
}
However, I just get the output as it would have been outputted normally. If I however use this line:
Console.WriteLine(String.Format("{0,"+winWidth+"}", "text"));
The "text" gets centered as it should.
I am calling `centerText` with these two methods:
private static void drawStars()
{
centerText("*********************************************");
}
private static void title(string location)
{
drawStars();
centerText("+++ Du er nu her: " + location + "! +++");
drawStars();
} | Try this instead:
private static void centerText(String text)
{
Console.Write(new string(' ', (Console.WindowWidth - text.Length) / 2));
Console.WriteLine(text);
}
The problem with your initial code was that your text _starts_ in the screen center. You want the center of the text to be there.
You're going to do a bit more work if you want to print entire paragraphs centered like this. | stackexchange-stackoverflow | {
"answer_score": 17,
"question_score": 7,
"tags": "c#, c# 4.0, console application, centering"
} |
label in python docstring
I'm using sphinx autodoc to translate my docstring to a nice documentation page. In the docstring I'm following numpy's docstring guideline by using the sphinx napoleon extension. I'm wondering about the following: If I have an equation like
"""
This is a very important equation which is used in the code
.. math::
a+b=c
:label: important_eq
"""
the autodoc doesn't recognize the `:label:`. Do I have a wrong formatting or can't autodoc / mathjax / napoleon deal with labels in equations? | Be careful with whitespace and indentation. This works:
.. math::
:label: important_eq
a+b=c
This works too (when the math content is only one line of text, it can be given as a directive argument):
.. math:: a+b=c
:label: important_eq | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "python sphinx, mathjax, autodoc, numpydoc"
} |
xcode passing pointers to a method
My knowledge of code just doesn't go this deep, and I have no idea where to look.
- (void) testResult: (Float32 *) levels lightLevel: (Float32 *) lightLevel;
It is required that the levels and lightLevel data pointers passed to this method point to pre-allocated storage holding any array of 2 Float32 values.
How would I retrieve these values?
Thank you. | Float32 levels[2];
Float32 lightLevel[2];
[mysteryObject testResult:levels lightLevel:lightlevel]; | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "objective c, pointers"
} |
Windows command SET seems possibly redundant?
I've inherited a batch file which reads major, minor and build numbers from a text file as part of a long-established build process - the actual reading part code is a simple `FOR /F`:
FOR /F "tokens=1,2,3* delims=." %%A IN (C:\MyBuildArea\version.txt) DO (
SET Major=%%A
SET Minor=%%B
SET Build=%%C
)
However this is followed by the line:
SET Build=%Build: =%
I don't understand this last line - what it is doing. Guessing it might be trying to catch and remove a trailing space (?) from the original file read as the `FOR /F` was delimited on dot (".") not space.
Hoping someone can help me understand - is this line redundant or serving some purpose? | The command `SET Build=%Build: =%` will simply substitute all spaces with nothing, i.e. it will remove all spaces in the text stored in `Build`.
See `set /?` on command prompt for details. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -1,
"tags": "batch file, cmd"
} |
How To Use JSON Returned From a URL in Javascript?
I have a URL which returns JSON data. I would then like to use some parts of this data in Javascript. At the moment I'm getting an 'Uncaught Syntax Error' in the console when I run it.
My code looks like this:
var myAPIcall = "
$.get(myAPIcall, function( data ) {
console.log("Place ID = " + data.results.place_id);
}, "json" );
It's the JSON itself which is causing the error.
How can I get the JSON (specifically the place_id, but I'd be happy with any of it) to display with the `console.log`? If I understand that much I should then be able to move on and use the place_id in my code.
Thanks | Check our query. Removing `callback=?` will result in a valid JSON :-)
var myAPIcall = "
$.getJSON(myAPIcall, function( data ) {
console.log(data.results[0].place_id);
});
<script src=" | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "javascript, json, google maps"
} |
What does A (base), B (local), C (remote) in KDiff3 tied to git conflict solver?
Lets assume i have a git branch FIX-8834 and branch VERSION-12.
I want to merge FIX-8834 to VERSION-12 in git.
Git tells there is a conflict.
I use Kdiff3 to solve it.
KDiff3 opens and there are 3 files open: A(base), B(local) and C(remote). What letter has the FIX_8834, VERSION-12 and from where is the third file coming from?
Is there any way to display human being names for the files in KDiff3? | The words are supposed to be human readable:
1. **Base** is the first commit down the tree the two branches split off from. It is the first common ancestor. Often it is useful to have this to help decide which of the newer commits you want.
2. **Local** is your local commit, the one in the current branch you are standing on.
3. **Remote** is the remote commit, of the branch you are merging into your local one.
Note that when re-basing, you are in fact changing your locality in a sense, to stand on the new base. So, when **rebasing** :
2. **local** is the your local commit, the one you are rebasing **onto**.
3. **Remote** is the remote commit, you are rebasing on top of the local commit. | stackexchange-stackoverflow | {
"answer_score": 25,
"question_score": 12,
"tags": "git, kdiff3"
} |
Is possible to persist data in the .net assembly Metadata or Header?
I want to implement a custom assembly signature mechanism just like Strong Name, then develop a program to write the signature info in the assembly Metadata,In the assembly of internal read and verification of the signature is correct. Is possible to do this? | This is certainly possible. You should add a custom attribute for the assembly. To do so, make an entry in the CustomAttribute table, which is defined in section 22.10 of ECMA 335. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": ".net, assemblies, signature, strongname"
} |
How to request a secured connection (https)?
Generally, we use http connection like this:
try{
HttpClient httpclient = new DefaultHttpClient();
// final HttpParams params = httpclient.getParams();
// HttpConnectionParams.setConnectionTimeout(params, REGISTRATION_TIMEOUT);
// HttpConnectionParams.setSoTimeout(params, WAIT_TIMEOUT);
// ConnManagerParams.setTimeout(params, WAIT_TIMEOUT);
HttpPost httppost = new HttpPost(url);
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
// Log.e("log_tag", "Error in http connection "+e.toString());
}
This code snippet is used for http.
How can I request a secured connection (https) ? | If you are after Android 2.2, you can simply use class AndroidHttpClient.
It will be work through https, if url scheme is https.
Otherwise, you can look to its source and make similar, and may be even easier. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "android"
} |
What happened to Force.com editions
I don't know if this topic has been already discussed here, or if this is the right place to be discussed. I would like to ask for an explanation what is exactly Force.com platform is and are there any Salesforce editions, that provide just the functionalities of Force.com platform? I have researched that there were licenses, which provides these functionalities like Force.com One App & Platform Licenses or Force.com Light & Enterprise Licenses. Could you please tell me if these licenses are deprecated and if that's the case are there another license types today, that could replace them. I have been told that for fully Force.com functionalities I have to use Salesforce Platform license. Is the same as the license types, that I have mentioned above. I will be grateful If you cloud provide me some useful official links on this topic. | Current Salesforce User license information can be found by the following links:
* User Licenses
* Standard User Licenses | stackexchange-salesforce | {
"answer_score": 1,
"question_score": -2,
"tags": "force.com, force"
} |
Removing everything in a column after a specific embeded character in a csv file
I need to remove all the contents that appear in a column after a specific character in CSV file. This is the format it is currently in:
2020-01-01T12:00:00,Transaction Description,Initiator,$00.00
I want to remove the contents in the first column that appear after T, so that it looks like:
2020-01-01,Transaction Description,Initiator,$00.00
I tried sed but it didn't work as expected. | Using standard `sed` in a similar way as Timur uses Perl:
$ sed 's/T[^,]*//' file
2020-01-01,Transaction Description,Initiator,$00.00
This removes all text from the first `T` on each line, up to (but not including) the first comma, by means of a substitution.
Redirect to a new file to save the result. | stackexchange-unix | {
"answer_score": 2,
"question_score": 0,
"tags": "sed, regular expression, perl, csv"
} |
Is there a tool for parsing feeds in Django
I did some googling and didn't find anything complete for my problem, but it is so generic, there has to be something.
I need feed parsing tool for my Django app (i want to fetch atom feed from somewhere and store its contents). I just found some feedparser.py references but the actual site is a long gone.
Could you provide some pointers? | feedparser is still pretty much the canonical solution for this in Python. It's very far from gone: see the documentation here and the actual project page here | stackexchange-stackoverflow | {
"answer_score": 8,
"question_score": 1,
"tags": "python, django, feed, atom feed"
} |
Exponents in Odd and Even Functions
I was hoping someone could show or explain why it is that a function of the form $f(x) = ax^d + bx^e + cx^g+\cdots $ going on for some arbitrary length will be an odd function assuming $d, e, g$ and so on are all odd numbers, and likewise why it will be even if $d, e, g$ and so on are all even numbers. Furthermore, why is it if say, $d$ and $e$ are even but $g$ is odd that $f(x)$ will then become neither even nor odd?
Thanks. | An even function is one for which $f(-x) = f(x)$ for all values of $x$ (e.g. evaluating at -6 is the same as evaluating at 6). If $n$ is an even exponent, then $(-x)^n = (-1)^nx^n = x^n$, since an even number of negative signs will cancel out. If all the exponents are even, then this happens for every term in the polynomial, so the result is the same as the original polynomial.
An odd function is one for which $f(-x) = -f(x)$ for all values of $x$ (i.e. the minus sign factors out). If $n$ is an odd exponent, then $(-x)^n = (-1)^nx^n = -x^n$, since an odd number of negative signs leaves just one negative sign remaining. If all the exponents are odd, then we get: $$ f(-x) = ax^d + bx^e + cx^g + \cdots = -ax^d - bx^e - cx^g - \cdots = -(ax^d + bx^e + cx^g + \cdots) = -f(x). $$
If there is a mixture of odd an even exponents, then neither of these nice properties will hold, so the function will be neither even nor odd. | stackexchange-math | {
"answer_score": 4,
"question_score": 3,
"tags": "functions, symmetry"
} |
Display 'new' badge on Blog menu item after new blog post
I'm trying to have a 'new' badge display on my menu beside the "Blog" menu item after a new blog post, and hide after 3 weeks if there's no new posts.. to let visitors know when there's a new post. The badge is a png.
 {
$menu_title_search = 'Blog';
$icon_html = '<img src="new_icon.png">';
$last_post = strtotime( get_lastpostdate() );
$new_icon_limit = strtotime( '+3 weeks', $last_post ) - strtotime( 'now' );
foreach ( $menu_items as $menu_item ) {
if ( $menu_item->title === $menu_title_search && ( $new_icon_limit > 0 ) ) {
$menu_item->title = "$menu_title_search $icon_html";
}
}
return $menu_items;
}
add_filter('wp_nav_menu_objects', 'add_icon_to_menu_item', 10, 2); | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "php, wordpress"
} |
Trying to understand Etherscan output for token swap via Uniswap
I am trying to understand a token swap transaction via Uniswap on Etherscan. Looking at the Uniswap V2: Router 2 contract for a transaction, I see the following;
, so the web calculated the ETH input needed (~0.092 ETH) which was a little more than actual use (~0.089 ETH). So the router returned ~0.002 ETH.
Read more: < | stackexchange-ethereum | {
"answer_score": 2,
"question_score": 1,
"tags": "etherscan, uniswap, transfer"
} |
ggplot geom_line color based on a density function
library(ggplot2)
library(dplyr)
i = rnorm(10000, 5, 1)
tb = tibble(x = i, y = i^2.5)
ggplot(tb, aes(x = x, y = y)) + geom_point(alpha = 0.09, size = 0.2)
) + geom_line()
$y`)? | One approach is to estimate the density, then define the approximation function with `approxfun` and evaluate it at `x`. Then just use `scale_color_gradient`.
tb %>% mutate(Density = approxfun(density(x),rule=2)(x)) %>%
ggplot(aes(x = x, y = y,color=Density)) + geom_line() + scale_colour_gradient(low = "white", high = "black")

I have 10 numbers and I want to have a new array to look like below. I need to loop through the array and assign it to the iterated numbers if they are equal.
1 - ""
2 - 2
3 - ""
4 - ""
5 - ""
6 - ""
7 - 7
8 - 8
9 - ""
10 - ""
How can I achieve this with php loop?
I'm thinking of but it gives me 30 records.
for ($x=0; $x < 10; $x++)
foreach($arr as $a) {
....
}
} | You can try this too :
for ($x=1; $x <= 10; $x++) {
$newArr[$x] = in_array($x, $arr) ? $x : "";
} | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "php, wordpress"
} |
returning a printf(), cannot find symbol
public String format()
{
return printf("%1$10s, %2$10s, %3$10d", getForename(), getSurname(), getAge());
}
I'm trying to return a formatted string. However, printf() is apparently a missing symbol. Any suggestions?
If you need more info I'll provide. | You probably mean `String.format`, not `printf`. | stackexchange-stackoverflow | {
"answer_score": 5,
"question_score": 0,
"tags": "java, format, return, printf, symbols"
} |
Resolution with windows 10 and a TV in mirror by HDMI
I experiment problem with windows 10, when I connect my tv with HDMI, resolution on my computer screen get very big. when I go to set resolution parameter, they are all good ( 1920x1080). When I unplug HDMI to TV, resolution get OK.
I have a Nvidia card Geforce 210 and I have nvidia drivers 341.81 installed I tried to move all driver settings, but I couldn't change it.... Before, in windows 7, I didn't have this problem. I already experimented the same issue with Ubuntu...
Any idea? | The easiest way is to set you pc/laptop screen to the desired/best resolution and say duplicate these screens. The HDTV will display in its own resolution, even if its lower than on your pc. | stackexchange-superuser | {
"answer_score": 0,
"question_score": 1,
"tags": "windows 10, multiple monitors, resolution, nvidia graphics card"
} |
How to change the standard navigation menu color when using genesis
I need to change the font color for a wordpress menu. I'm currently using genesis as my parent theme & putting all of the css changes for it in a child theme. I would like to change the font color of my primary navigation menu, where do I put these changes in wordpress? In the child theme style.css or at Appearance > Menus ? | Are you trying to change the background color?
If so, use `background-color: #0066CC` instead of `color: #0066CC` | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 0,
"tags": "css, genesis theme framework"
} |
Buttons in Cell not clickable IOS 9
UITableViewCell with a few buttons on it, On IOS 8.4 buttons clickable (Able to get tap event), In IOS 9 Unable to get tap event.
Did any one notice this? | Ok I found the solution for this, I think this bug was at the past already at IOS 6.. any way you should add this to your UITableViewCell:
self.contentView.userInteractionEnabled = NO;
But this was because I've added the views to the cell itself, instead of I'ts contentView. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": -1,
"tags": "ios, objective c, ios9"
} |
struts2 2.3.20 ognl allowStaticMethodAccess
I updated my project to Struts2 version 2.3.20 . Now all cases in my JSPs that uses static method access do not work.
ie.
<s:set var="linkEscaped"
value="@org.apache.commons.lang.StringEscapeUtils@escapeHtml(#attr.myObject.link)" />
I already have set in my struts.properties ->
struts.ognl.allowStaticMethodAccess=true
and tried in struts.xml ->
<constant name="struts.ognl.allowStaticMethodAccess" value="true"/>
with no success. Does anyone know what has changed and what do I need to do to enable them again? | Since static methods will not be able to be used in future releases, I decided to refactor the parts of the project that use them. The sooner the better.
So in y "BaseAction" I have created the methods I need and they call those methods. This way only the "safe" methods I allow can be used in the jsp. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 7,
"tags": "java, struts2, static methods, ognl"
} |
Compound subject and Singular/Plural verb
> 1. What **is** Mr. X and his father doing?
>
> 2. What **are** Mr. X and his father doing?
>
>
Which one of the above is correct?
My friend says that both are acceptable in accordance with the context in which they are use d.
In informal occasions, especially when we know both the subjects are doing the same work together, we can ask the question as in sentence 1. But in formal occasions, and when we know that they are doing two different things, we ask the question as in the sentence 2.
**Is my friend correct?** | Your friend is mistaken.
The subject here is "Mr. X and his father", which is plural, so the correct verb to use is "are".
Of course there's a compound noun that takes a singular verb such as "bread and butter". But this is not the case here. "Mr X and his father" is not normally conceptualized as a single unit. | stackexchange-ell | {
"answer_score": 3,
"question_score": 0,
"tags": "subject verb agreement"
} |
How to avoid printing commented out code in for loop
If I run this loop, `A` will print 10 times.
for i in range(10):
"""
A
"""
pass
How do I stop this?
 and change it around. | stackexchange-serverfault | {
"answer_score": 1,
"question_score": 0,
"tags": "linux, nginx, gentoo, packages"
} |
python flask - serve file on different url
I've build an rest server in flask with CRUD for `Order` objects.
So there's an endpoint for `POST /order` to create the `Order` and the user can then upload an attachment on `POST /order/{order_id}/attachment`
I also want to serve the attachment, to be downloadable on the same url. So that `GET /order/{order_id}/attachment` downloads the attachment file.
But when I return the werkzeug.datastructures.FileStorage, with the `filename` attribute set, the browser gives me an file to save with name: `attachment`
Is there a way to send the file with flask, with the correct filename on an different url? | The `send_from_directory` method might come in handy to serve the file(s). Example (a bit pseudo-coded):
@app.route('/order/{order_id}/attachment')
def download_file(order_id):
order = get_order_from_db(order_id)
filename = order.attachment
return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
More on `send_from_directory`: < | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 2,
"tags": "python, http, flask, werkzeug"
} |
Sql php 2 table's match
Hi I need the results where products.name whit a = before is in the alternates productsmap table.
products.name is a varchar 255 and a example result is
Haven
productsmap.alternates is a text and a example result is
=Havens go
=Haven 1
=Haven
this is one cel
I tried below but i don't get any results where i know i must get a result.
SELECT DISTINCT products.name
FROM products
WHERE CONCAT('=',products.name) in (select alternates from productsmap)
This query takes 1 minute and gives 0 rows. | The fuzzy link between the two tables could be improved. For example, this mapping table would perform better:
ProductName Alternative
Haven Havens go
Haven Haven 1
Haven Haven
To query your current table layout for `'Havens go'`, you could:
select distinct p.name
from products p
join productsmap pm
on pm.alternative like '=' + p.name + '%'
where pm.alternative = '=Havens go' | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "php, mysql, sql"
} |
Where put bootstrapper?
I want to create PRISM application with MVVM pattern and I don't know where I should put bootstrapper?
In Model, ViewModel or View?
Bootstrapper creates shell (so in View?) but it also registers container etc so maybe it should be like separate service? | The bootstrapper is part of the executable framework for configuring your application.
I suggest putting the bootstrapper code in the OnStartup event handler of your Application class.
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
SplashScreen splash = new SplashScreen("Resources\\mysplash.png");
splash.Show(true);
base.OnStartup(e);
MyBootstrapper b = new MyBootstrapper();
b.Run();
}
}
Technically, it is part of the View layer, imho, but is really there to configure the catalog and perform start-up operations. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "wpf, mvvm, prism"
} |
Do I need hard or soft brown sugar for brownies?
I found a recipe for brownies I want to try. It calls for
> 1 1/2 cups packed light brown sugar
How can I recognize if they mean hard or soft brown sugar? And how much of a difference does it make for the completed brownies if I use the wrong type? Should I just adjust the amount of sugar or other ingredients (and if yes, by how much)? Or do I have to try to make a substitution? I found a question which explains how to make soft sugar, but it requires a food processor, and I don't have one.
**Edit** Here is a picture of sugars, as Jay suggested per comment:
!sugar types
In Germany, the only type found under the name "brown sugar" (brauner Zucker) is the one in the upper right corner. But I have heard that American recipes might need the kind in the lower right corner, which is not normally available here. | The in the US, light brown sugar always means the one in the bottom left. The bottom right is dark brown sugar and has a higher molasses content. In the US, I typically see the 'brown sugar' in the upper right referred to as 'raw sugar' or the brand 'sugar in the raw'. If you're using a US recipe, it needs the bottom left.
If you don't have any and its an ingredient like in brownies, try adding the molasses and sugar as separate ingredients. 1 Cup of sugar + 1 tablespoon of molasses is about the right ratio for light brown sugar.
If you can't get molasses...try dark corn syrup, honey, or depending on the flavor your want, maple syrup. (A comment from @JasonTrue above mentions that beet syrup is an option as well, althought I haven't tried it.) | stackexchange-cooking | {
"answer_score": 12,
"question_score": 7,
"tags": "baking, brownies, brown sugar"
} |
Command not found error on HISAT2
I have been attempting to map reads to a reference genome using HISAT2 using the Pertea, et al 2016 Nature Protocols paper. I am able to successfully generate an index (using the hisat2-build command), but when it comes to the actual mapping, I run into problems. The code I'm using (from the paper):
$hisat2 -p 8 --dta -x daphnia_tran -1 C2*R1*.fastq -2 C2*R2*.fastq -S C2paired.sam
And I get the error message:
./HISAT2_Basic_14.sh: line 26: -p: command not found
When I remove the -p argument, the error message is similar, but says "--dta: command not found"
Any ideas on what the issue is?
Thank you! | tldr: Remove the `$` from the command.
I imagine you're literally typing `$hisat2`, where you mean to instead type `hisat2`. The `$` is just meant to show the end of the command prompt. If you actually type `$hisat2`, you're not executing the hisat2 program, but whatever the `$hisat2` variable is set to. Since it's likely not set to anything, it's just ignored. For example:
ryan@maximus:~$ $hisat2 ls
bin convertChromosomesChain.py ...
Since there's no `$hisat2` variable, I'm actually just running `ls`. Likewise, your command is just reducing to `-p 8 --dta -x daphnia_tran -1 C2*R1*.fastq -2 C2*R2*.fastq -S C2paired.sam`, which is the source of the error. | stackexchange-bioinformatics | {
"answer_score": 3,
"question_score": -1,
"tags": "sequence alignment, transcriptome, genomics"
} |
Symfony2 – Is there a standard for the name of entity var inside a controller & view?
I'm curious if there's a standard/recommended practice for the name of the variable storing the entity in a controller action or view.
public function demoAction(User $entity)
{
return $this->render('...', [
'entity' => $entity,
]);
}
I've seen some places where it's done this way (always name the main entity var `$entity`) and other's where `$entity` is `$user` (for example).
In my opinion, using `$entity` everywhere get's confusing when there are 2 entities and then you either have one called "entity" and the other something else.
Is there a standard/recommended practice? For Symfony? Or maybe something for the wider PHP world? Or for an ORM, ie, Doctrine? | Yeah, call them what they are, like `$user`, `$userProfile` ...
The `$entity` is from autogenerated stuff Symfony creates. Maybe this behavior could be optimized in Symfony3, so that the generated variable names are derived from the concrete class name. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "symfony"
} |
CSS Sticky Bar Overlapping
I am using the Sticky Footer code from HERE and for some reason the sticky footer overlaps my .content class on my site.
My site: <
As you can see the 910x50px image at the bottom overlaps the white box when you scroll to the bottom on any given page.
I need the 910x50px image to be at the bottom of the white box when you scroll to the bottom.
CSS for the white box .content class
.content {
padding-left: 5px;
padding-right: 5px;
padding-bottom: 5px;
margin: auto;
width: 50%;
background: white;
}
CSS for the Sticky Footer .player class
.player {
position: fixed;
left: 470px;
bottom: 0px;
height: 50px;
width: 50%;
background: transparent;
} | You could try increasing the padding of the page body.
Currently it is:
body {
background-image: url('
padding-top: 20px;
padding-bottom: 20px;
}
try changing the padding-bottom to
padding-bottom: 30px; | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "html, css, sticky footer"
} |
C# setters for INT
As I have already done, I have this piece of code:
private string opt;// create a property
public string optionInterval
{
get
{
return opt;
}
set
{
opt = value;
}
}
How can I change the opt to an integer? Especially in the set part? | public int optionInterval { get; set; }
Using **Auto-Implemented Properties**
* * *
Here's a working version of GianT971's answer:
private int opt;
public string optionInterval
{
get
{
return opt.ToString();
}
set
{
opt = Convert.ToInt32(value);
}
} | stackexchange-stackoverflow | {
"answer_score": 6,
"question_score": -3,
"tags": "c#, int, setter"
} |
How can I write this query in linq to sql?
I'm new in linq and want to write this query:
var query = from p in behzad.rptost
where p.date.substring(0, 4) == "1395"
-->in this calc sum=p.price_moavaq+price_year
select p;
How can I write that query? | From what I assume you are trying to sum up the `price_moavaq` field per year. Furthermore, by the use of the `substring` I guess your `date` field isn't of `DateTime` type but just a `string`.
So you need to use a `groupby`:
var query = from p in behzad.rptost
group p by p.date.substring(0, 4) into grouping
select new { Year = p.Key, Sum = p.Sum(x => x.price_moavaq);
In the case that your date field is of `DateTime` type then just use `.Year`:
var query = from p in behzad.rptost
group p by p.date.Year into grouping
select new { Year = p.Key, Sum = p.Sum(x => x.price_moavaq); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "c#, linq, linq to sql"
} |
Host a c# worker in Azure
I have a worker coded using C# and I'd like to host it in Azure.
So I create an Azure automation account and I tried to import my worker project as a new runbook but I find that the runbook must be built on PowerShell Workflow !!!
So I need to know
1. If there is a way to import my C# worker?
2. If not, I'd like to know How can I host my worker using my Azure account ?
**NB:** The worker is for sitemap generation
Thanks, | You could consider using Azure WebJobs or Azure Functions.
This article helps you in deciding which one to use.
If you need more control over the VM (like installing custom software) you could consider hosting your code as a 'Cloud service'
I would start of with Azure Functions to get something up and running quickly and then build on top of it. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 0,
"tags": "c#, .net, powershell, azure, web"
} |
Why do I get a Compile error Argument not optional when all arguments are specified and non-null?
I have a project that looks something like this:
Function boi(sheet As Worksheet) As Scripting.Dictionary
Set my = New Scripting.Dictionary
'actually some stuff with the sheet
my.Add Key:="Foo", Item:="Bar"
boi = my
End Function
Sub test()
Dim tsheet As Worksheet
Set tsheet = Sheets("INPUT_OLD_DATA")
MsgBox (boi(tsheet)("Foo"))
When I try to run test(), it gives me a Compile error Argument not optional on the line `boi = my`. What I dont understand ist how there can be an Argument not optional error on a line where _no function is called_. As it doesn't actually get to the line `boi = my` I also don't think the error can be due to an invalid return.
I come from Python/Javascript/Java, please pardon me if this is an extremely noob question. :) | boi is an object so you must
SET boi = my | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "excel, vba"
} |
Trying to make the python shell go full screen upon launch and also make a popup image go straight into full screen
I'm working on some extra curricular work for school and attempting to implement images into my game of hangman , the main issues I am having is when opening the image it is opening behind the shell and as such can't be noticed. I'm hoping to be doing it with the subprocess library - subprocess.call("taskkill /f /im Microsoft.Photos.exe" , shell=True) - in a similar way to how the window is shut afterwards.
Along with this , when using - print('\n' * 100) - to hide the word which the users will guess , my text begins to go offscreen which is easily fixed by making the window fill the screen but just wondering if there is an easier , automated way to do this through python ? | You can try using cv2 library, for example :
import cv2
image = cv2.imread("face.jpg")
cv2.imshow("Gray", image)
cv2.waitKey(0)
cv2.destroyAllWindows()
This will show the photo on the screen untill you press a key to destroy it.
You can also change the photo resolution with cv2.resize(image,x,y) and check the image current resolution with image.shape() | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "python, subprocess, fullscreen"
} |
array formula for --(B2*SUM(C2:E2)>0) for 10 rows?
I would like to see if B2*SUM(C2:E2) is greater than zero. If yes, the result should be one, otherwise, zero. Then, I'd like to do this for 10 rows, say, row 2 to 11, and sum the results. The final result should be between 0 and 10.
Possible to create an array formula to do this? | For only 3 columns in the sum the simplest way is like this:
`=SUMPRODUCT((B2:B11*(C2:C11+D2:D11+E2:E11)>0)+0)`
....or do you need it to be more generic? In which case try this version where you can easily expand the range to any number of columns
`=SUMPRODUCT((B2:B11*SUBTOTAL(9,OFFSET(C2:E11,ROW(C2:E11)-MIN(ROW(C2:E11)),0,1))>0)+0)`
In this latter version `OFFSET` function is used to generate the separate ranges for each row and then `SUBTOTAL` totals each range | stackexchange-superuser | {
"answer_score": 2,
"question_score": 0,
"tags": "microsoft excel, worksheet function"
} |
Check if file is a valid jpg
I would like to check if the file I am reading in from a directory is a jpg but I do not want to simply check the extension. I am thinking an alternative is to read the header. I have done some research and I want to use
ImageIO.read
I have seen the example
String directory="/directory";
BufferedImage img = null;
try {
img = ImageIO.read(new File(directory));
} catch (IOException e) {
//it is not a jpg file
}
I am not sure where to go from here, it takes in the entire directory... but I need each jpg file in the directory. Can someone tell me what is wrong with my code or what additions need to be made?
Thank you! | You can read the first bytes stored in the buffered image. This will give you the exact file type
Example for GIF it will be
GIF87a or GIF89a
For JPEG
image files begin with FF D8 and end with FF D9
<
Try this
Boolean status = isJPEG(new File("C:\\Users\\Public\\Pictures\\Sample Pictures\\Chrysanthemum.jpg"));
System.out.println("Status: " + status);
private static Boolean isJPEG(File filename) throws Exception {
DataInputStream ins = new DataInputStream(new BufferedInputStream(new FileInputStream(filename)));
try {
if (ins.readInt() == 0xffd8ffe0) {
return true;
} else {
return false;
}
} finally {
ins.close();
}
} | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 12,
"tags": "java"
} |
How do you obtain an @ubuntu.com email address?
> **Possible Duplicate:**
> How to get Ubuntu membership?
I recently saw the question "How to add an @ubuntu.com email address in Thunderbird" and wondered how one obtains an @ubuntu.com email. | You need to be an Ubuntu member, check < . | stackexchange-askubuntu | {
"answer_score": 2,
"question_score": 0,
"tags": "thunderbird, email, ubuntu email address"
} |
Unbind port used from past Ratchet websocket server
I had a server script running and I closed it prematurely using `Ctrl`+`Z`. When I tried to run it again it tells me that the port 1001 is already in use. In a live environment there is always the risk that the script could crash or something else may trigger it to end early. How do I automatically unbind this port before connecting to it? I am going to use a port that I know nothing else will ever use, so its safe to unbind it automatically.
Currently my server script is basic.
$server = IoServer::factory(
new HttpServer(
new WsServer(
new Chat()
)
),
1001
);
$server->run();
I followed the guide found here < . Everything has worked as expected, I'mm just stuck with this issue now.
I am running PHP 5.4 on Centos 7. | I couldnt find any way to do this through the command line. Only solution i could see, which could be trouble if someone finds out is to kill the script by sending a message to the websocket. Every message to the websocket server has an "action". A switch will then do something for each action. Create a random action thats impossible to guess. Within this switch use `die();`. This will kill the script and unbind the port so you dont need to go finding the PID and killing that manually when the server needs restarted.
This can be used to make a quick restart .sh script. Use php to make a websocket call to kill the server and call if from a bash script, then call php server.php and away you go. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "php, websocket, ratchet"
} |
find pom dependencies by classname
How can I found the dependency by classname?
In particular, I want to include this class org.mortbay.jetty.testing.ServletTester in my project, how do I do that? And how did you find the answer? | since version 6.1, Netbeans can add to pom.xml the dependency you need for a given class | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 17,
"tags": "java, maven 2, dependencies, pom.xml"
} |
Question on constant velocity (easy)
Two animals are charging at each other. They stand 20 m apart. The smaller animal charges at 6.5 m/s. The larger animal was measured to run 24 m in 3 s. At what position will the two sheep collide?
So far I have this:
$v_L = 8 m/s$, $v_s=-6.5 m/s$
$x_{0_L}= 0$, $x_{0_s}=20$
$x_L=8t$, $x_s=-6.5t+20$
I can set $x_L$ and $x_s$ equal to each other and solve. I know how to do this.
However I am confused because the solution sets these two equations equal:
$$8t=6.5t+20$$
instead of $$8t=-6.5t+20$$
Why isn't the velocity of one of the animals opposite of the other? I thought they would be opposite since they are running towards each other. | It is a typo. The one with the negative sign is correct. The solution should have $t=\frac{20}{14.5}$ instead of $\frac {20}{1.5}$. That would indicate which the solution is using, whether or not the negative sign is shown. | stackexchange-math | {
"answer_score": 1,
"question_score": 0,
"tags": "physics"
} |
svn commit problem, Cannot read 'd:\UC\db\txn-current': End of file found
I have a problem commiting to svn server, Here's what I got,
> File Can't read 'D:\SVNROOT\UC\db\txn-current'.: End of file found
(It's traslation of Korean, so there's might be differ than what English error said..)
In previously, I shut down transaction when update from svn, cause some file was so big,
so I was shut down downloading for delete big files first, but after that, I got message
about 'txn-current',
does anybody can help me to solve this?
thank you for regarding this | `db\txn-current` is a file in the repository data on the server which should contain the current revision number if you open it with a text editor.
If this is not the case (as the error message seems to indicate), then you should first try to run `svnadmin recover D:\SVNROOT\UC\` on the server.
You should also run `svnadmin verify D:\SVNROOT\UC\` to check if there are any other problems with the repository. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": "svn, tortoisesvn"
} |
Was it approved or was it rejected?
One of my suggested edits was rejected (thinking about it, probably rightfully so). However, the page where I can see who rejected it has the following message:
!Rejected or approved
Well, which one is it? Was it rejected in an approving manner? Was it approved in a disapproving tone?
This looks like something I'd see in Lotus Notes, not SO. | Stack Overflow requires multiple approvers for an edit. Thus, my conjecture is that Tom H did indeed approve your edit, but it was still in a pending state here. His approval vote appears to have been at `19:31:38Z`, which is 38 seconds after you initially proposed it.
However, the question got closed as a duplicate at `19:33:40Z`, which means that Community makes an auto-revision. Since there's now a higher revision than yours, which generally doesn't happen on account of the whole edit-lock thing, your edit suggestion got discarded as a rejection.
So, the suggestion was indeed on the road to approval, up until it was effectively hit by a crossing train before it reached its destination. As it never arrived, it could not be fully approved, and must be rejected even though the paperwork wasn't in order. | stackexchange-meta | {
"answer_score": 19,
"question_score": 13,
"tags": "support, suggested edits, rejected edits"
} |
Keyboard shorcut to select whole line, starting at end of the line?
I know how to select a line from the beginning to the end, starting from the beginning of the line - `shift+end`
How do I do the same thing, but beginning from end of line ? | To select the whole line starting from the end, press `Shift` \+ `Home`. | stackexchange-superuser | {
"answer_score": 1,
"question_score": 1,
"tags": "windows, keyboard shortcuts"
} |
ScrollTo can't read propperty top
I'm trying to have my page slide to the next bit of content on a click, but I ran into a small problem.
$("#projects").click(function (e) {
event.preventDefault();
var container = $('#container-content'),
scrollTo = $('#content-projects');
container.animate({
scrollTop: scrollTo.offset().top - container.offset().top + container.scrollTop()
}, 1500, 'easeInSine', function () {});
});
When I click on `projects` I get this back, `Cannot read property 'top' of undefined` When I link to the the div before #content-projects (#content-me) the code does work.
< | I made a small typo on my html. Found the problem and fixed it. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "jquery, scrollto"
} |
Forward slash is not working in gdb
Iam using gdb version 6.8 on red hat linux.In my gdb forward slash(/) is not working.Whenever I press / key i get error bell. However it works properly for my friend who uses the same gdb version and our .gdbinit files are same.
Thanks in Advance. | > our `.gdbinit` files are same.
GDB uses the GNU readline library, and that library uses `~/.inputrc` to control its behavior.
I am guessing that your `.inputrc`s are _not_ the same. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "gdb"
} |
Why are many of my packages marked as manually installed
I just realized that many of my packages are "manually" installed:
root@deb:~# apt-mark showhold
root@deb:~# apt-mark showmanual | wc -l
202
root@deb:~# apt-mark showauto | wc -l
371
I know eg from here that this happens if you upgrade only one specific package, but I did not do this for 202 packages.
Anybody has a guess how this might have happened?
Are there any downsides of having so many manual packages?
What are principal differences between manual and auto installed packages?
I can change them all to auto installed, but is this risky, could something go wrong when doing this?? | The basic set of packages installed by default when the system is initially set up are marked as manually installed, as are any packages explicitly named for installation or upgrade with `apt install` or similar tools. This means that many packages you don’t think of as manually installed (because you don’t explicitly want them) will nevertheless be marked as manually installed.
You can run
apt-mark minimize-manual
as root to remove unnecessary markers.
The difference between automatically and manually installed packages is that the former will be considered for auto-removal when no other package depends on them. | stackexchange-unix | {
"answer_score": 2,
"question_score": 2,
"tags": "debian, apt"
} |
Best Object layout in ASP.net
What's the best object layout in ASP.net or at least.. what are the advantages and disadvantages of either case:
Public Class Dog
Public Breed as String
Public Type as String
Etc....
OR the use of properties and keeping variables private
Somewhat of a debate among our team about it. Just wanted to hear thoughts. | Never expose fields directly.
Use properties with private backing fields. This allows you to change implementation and to encapsulate logic around getting/setting them.
See what the Visual Basic Team have to say on this.
Also, read about the differences between fields and properties. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "asp.net, vb.net"
} |
Smartcontract: Warning! contract execution experienced an error and gets [Reverted]
I have sent ropsten ETH to my newly created contract address (still on test mode on the Ropsten Test net). Unfortunately it kept "failing". The blockchain reports: Warning! Error encountered during contract execution [Reverted]
Please see my contract address and transaction failures here: <
I have employed myetherwallet interaction functions, interacted and queried my smart contract for the totalSupply, CurrentDistribPublicSupply, OwnerDistribSupply_ and others. Everything seems to be in order and tallies. So am super confused and quite worried. Please someone help and explain what I am doing wrongly? All sort of help and correction would be appreciated. Thank you.` of your fallback function. Debug it with Remix. It's recommended to use `require()` instead, as this will revert the change of the state automatically, if the condition inside it does not turn out `true`.
So to make sure a condition is met, you can do `require ( 2 == 2)` and if that fails, it's way easier to discover when going through the execution steps with Remix's debugger than watching at which if condition it jumped to a revert. | stackexchange-ethereum | {
"answer_score": 0,
"question_score": 1,
"tags": "solidity, contract development, transactions, revert opcode"
} |
Can 'attributes' change its value after setting value to a property?
Consider this code:
Public Class SomeViewModel
<Custom>
Public Property myData As String
End Class
I want the `Custom` attribute to have capability to change myData after it set to some data.
ie. trim myData or omit extra chars from it or ... it doesn't matter now.
I know I can use `set` and `get` statement, but those make my code look like not good, and also I want to repeat this `CustomAttribute` many times is same class or elsewhere.
**UPDATE**
Ok, if there is no way else, can I use some `customAttribute` and before my 'insert to SQL logic' call a function say: for all property that has this `customAttribute` do `this thing`? How can I implement that? | You should use setters and getters, that's what they are for.
Attributes mark parts of your code, such that reflection can be used on this code - it is a rather heavy weight approach just because you don't like the look of property setters and getters. | stackexchange-stackoverflow | {
"answer_score": 3,
"question_score": 1,
"tags": ".net, model view controller, attributes"
} |
is there any way to output the html from google chrome developer tools?
I have a website that uses javascript to change the HTML dynamically based on input. I use google developer tools to examine the HTML at any particular moment in the lifetime of the page. Is there any way easy way to output the HTML from the elements tab to a file or to the clipboard (so that I can run it thru a validator for debugging)? Control + A does not allow me to select all of the HTML. | You can Copy the `<html>` element as HTML:
!enter image description here
... but you can do this easier at the console:
` copy(document.documentElement.outerHTML); `
Note that neither of these will copy the doctype. Also this is the serialization of the live DOM which could be totally different than the markup you served. But you know that. | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "google chrome devtools"
} |
404 Error Problems with sCategory Permalink plugin
Seems throughout the day my blog seems to show 404 page errors with no pattern. I have to manually change the permalinks from /blog/%scategory%/%postname%/ to default, then back to /blog/%scategory%/%postname%/ in order to fix the permalink issue.
This has been a problem for us for the past six months, and our site gets 10k views a day. While that is not a lot, it does give us a huge problem when at certain periods of the day we have a huge issue where none of our Posts work, yet Pages continue to work fine.
I have extensive conversation on this issue at this post ( where I have narrowed a few things down, and at this point I believe the sCategory Permalink is the issue. I need help understanding what is causing this issue, and more importantly fixing this so it never happens again.
ANY help would be greatly appreciated. | I stopped using that plugin a long time ago. I don't think you really need it anymore honestly. I just remember it did the same thing that I was able to do when I disabled it, so I stopped using it. I don't think its still supported by the developer either, so may be out of date.
I may be wrong, but then again I use the least amount of plugins as I can and build most things into my themes. | stackexchange-wordpress | {
"answer_score": 1,
"question_score": 1,
"tags": "permalinks, 404 error"
} |
Can videos be played without controls?
I'm planning on making a game for the iPhone and want to have the background constantly animated. I figured rather than looping a series of images, I'd play a video. Is it possible for me to play a video (with no controls popping up), and have graphics overtop of it (the actual game)? Or would I just be better off with looping images?
(I figured SO would be a better place to ask this than Game Development) | Yes, using AVFoundation, or even the MPMoviePlayerController with the controls property turned off.
You can have anything you like overlaying the video. The performance for that is much better in iOS4 than earlier OS versions. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 1,
"tags": "iphone, video"
} |
Is it possible to print columnized output with os.listdir()?
I'm looking to create two columns with os.listdir. Code is standard listdir().
for f in os.listdir(os.curdir):
print f
Output looks like as follows:
file1
file2
file3
file4
But I'm trying to achieve:
file1 file3
file2 file4
Is that (easily) achievable with os.listdir()? | `os.listdir` just returns a list, doesn't print it nicely like `ls -C2` would do (note that you don't need python for that if you have `ls` in your system)
You could do it this way for 2 colums:
import os,itertools
dl=os.listdir(".")
for t in itertools.zip_longest(dl[::2],dl[1::2],fillvalue=""):
print("{:<20} {:<20}".format(*t))
that would interleave the values together (with `zip_longest` to avoid forgetting an odd one) and format using 20 spaces for each value.
The general case for any number of columns could be:
import os,itertools
dl=os.listdir(".")
ncols = 3
for t in itertools.zip_longest(*(dl[i::ncols] for i in range(ncols)),fillvalue=""):
print(("{:<20}"*ncols).format(*t))
(generating `ncols` shifted lists, interleaving them, and generating the format accordingly) | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 0,
"tags": "python, python 2.7, listdir"
} |
Backbone.model.save sending the whole backbone.model in request body
when i `backbone.Model.save()`, it sends the whole model data (each and every property even when it has not been modified) in the body of the request.
i want to send in the body only properties of the model, that has been modified.
I am doing :
here.model.save(
{field:params.value},
{ patch: true,
error: function() {
d.reject('Server Error..!');
},
success: function() {
d.resolve();
}
}
);
but patch:true doesn't work.
what is the error? and how to resolve? | `patch` works only for already created models. In case if your model is new it wouldn't work.
### How to fix it:
var model = new Backbone.Model();
var attributesToSave = {};
model.save(null, {attrs:attributesToSave}); | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "javascript, backbone.js"
} |
SQL or T-SQL with ASP.Net
1. Is there an obvious difference between SQL and T-SQL?
2. Which is used in a ASP.Net/C# application? or can either be used?
This might seem a bad question, but I have only recently heard the term T-SQL and wondering if there is an actual **identifiable** difference or is it just another fancy term to sound cool. | SQL is the broad term for the language
T-SQL is a procedural extension to the language SQL. It is available through Microsoft SQL Server
If you decide to use SQL Server as your DB, you get SQL and the additional functionality of T-SQL which adds a long list of things, loosely covered in the link above. T-SQL isn't just a fancy term, it does add plenty of functionality, but most of that functionality exists in other DBs through other procedural language extensions.
Yes you can use SQL Server with ASP.NET and therefore T-SQL | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "asp.net, sql server, tsql"
} |
Parse cloud code error 141 invalid function
I want to run a function on my cloud code "test". This is my **complete cloud code**.
Parse.serverURL = '
Parse.Cloud.define("countUsers", function(request, response) {
var query = new Parse.Query("_Users");
query.count({
success: function(count) {
response.success(count);
},
error: function(error) {
response.error("Count failed" + error.message);
}
});
});
Parse.Cloud.define('hello', function(request, response) {
response.success('Hi'); // it works
});
Parse.Cloud.job('test', function(request, response){
response.success('OK');
});
When I call it via postman I get this error
{
"code": 141,
"error": "Invalid function: \"hello\""
}
Any idea what I might have done wrong? | You probably forgot to define your Webhooks for your function. You can easily define the function in the Webhooks section in Parse Dashboard. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "parse platform, cloud"
} |
How to check duplicate column values?
I have create stored procedure to select data and result is:
ID NAME EMAIL
1 John [email protected]
2 Sam [email protected]
3 Tom [email protected]
4 Bob [email protected]
5 Tom [email protected]
and I would like to get result like:
ID NAME EMAIL
1 John [email protected]
2 Sam [email protected]
3 Tom [email protected], [email protected]
4 Bob [email protected]
so, how can I do it?
Thanks. | select
id,
name,
email
from (
select
rn = row_number() over(partition by name order by id asc),
id,
name,
email = stuff((select ', ' + convert(varchar, t2.email)
from @table_var t2
where t1.name = t2.name
for xml path(''))
,1,2,'')
from @table_var t1
group by t1.id, t1.name
)t
where rn = 1
order by id | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": -2,
"tags": "sql, sql server"
} |
git diff-tree and copy or xargs to a folder
I want to do something very simple. Get all my committed files I pushed and copy without overwriting them to a specific folder on my repo. I found the first command:
$ git diff-tree --no-commit-id --name-only -r $CI_COMMIT_SHA # list latest committed files inside my pipeline
Now I am stuck on the next step and not sure if it would work with:
git diff-tree --no-commit-id --name-only -r $CI_COMMIT_SHA | "xargs... or cp -vnpr" path/to/folder
If there is a bash I can use please let me know as well. I didn't really find anything pertinent to this. THANK YOU!!!!! | In your case you are feeding `cp` command from stdin, so you need to use it with `-t`. The following command will do the trick for you:
git diff-tree --no-commit-id --name-only -r $CI_COMMIT_SHA | xargs -r cp -t /path/to/folder | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "bash, git, gitlab"
} |
Reading Composite Document File V2 Document (.msg) files in ubuntu
I have a large dump of data from an outlook email account that comes entirely in .msg files. A quick call to ubuntu's file method revealed that they were Composite Document File V2 Documents (whatever that means). I would really like to be able to read these files as plaintext. Is that possible at all?
Update: Turns out it wasn't totally possible to do what I wanted for large scale data mining on these kinds of files which was a bummer. In case you face the same issue I made a library to address this issue. <
Documentation isn't great, but it's a pretty small library so it should be self explanatory. | I faced the same problem this morning. I didn't find any information on the file format but it was possible to extract the required information from the file using strings and grep:
strings -e l *.msg | grep pattern
The -e l (that's a small L) converts from UTF-16.
This will only work if you can grep the data you need from the file (i.e. all required lines contain a standard string or pattern). | stackexchange-stackoverflow | {
"answer_score": 12,
"question_score": 12,
"tags": "text, encoding, msg"
} |
regex for in quotation elemenst
i look for this bu there was just between quotation and not after another element.
let me describe more.
i want just fetch in quotation elements which is after a specific element.
look at this :
set policy id 1444 name "#####TEMP#####" from "DMZ" to "DMZ" "10.62.28.178/32" "Any" "ANY" permit
set service "PING"
set policy id 1444
i want all the in quotation elements which are after from in a list and ofcourse before new line. i mean :
list=['"DMZ"','"DMZ"','"10.62.28.178/32"','"Any"','"ANY"']
using `re.findall()` function and the pattern `(\".*?\") \ *` i fetch every in quotation elements in a list which is like below :
list=['"#####TEMP#####"','"DMZ"','"DMZ"','"10.62.28.178/32"','"Any"','"ANY"','"PING"']
but now i want just the in quotation element which are after from just in a list.
tanks for helping. | found
(?!.*from).*?(\".*?\").*?[^\n] | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -2,
"tags": "python, regex"
} |
How to deal with $\int\limits_{L}z\cos(2\pi z \bar{z})\,dz$?
The original integral is:
$$\int\limits_{L}z\cos(2\pi z \bar{z})\,dz$$
where $$L = \\{|z| = 1; \quad 0 \le \arg \le \pi \\}$$
very well seen that integration region is the semi-circle $[0;\pi]$ but I am totally confused how to deal with cosine's arg :( | Notice that because $z\bar z= |z|^2=1$, the integral becomes, $$\int \limits_{L} z \cos 2\pi \, dz = \int \limits_{L} z \, dz = \,?$$ | stackexchange-math | {
"answer_score": 0,
"question_score": 0,
"tags": "complex analysis, complex integration"
} |
Are there any built-in .NET alternatives for using power of a number (Math.Pow) without errors?
`Math.Pow` seems to be not working correctly for big results. Probably that is because it uses `double` for calculations (How is Math.Pow() implemented in .NET Framework?).
For example:
public static void Main()
{
Console.WriteLine((long)Math.Pow(17, 13));
Console.WriteLine(Pow(17, 13));
}
public static long Pow(int num, int pow)
{
long answer = 1;
for (int i = 0; i < pow; i++)
{
answer *= num;
}
return answer;
}
The result from the above code is:
9904578032905936
9904578032905937
**Are there any built-in .NET alternatives for using power of a number without errors?** | The `BigInteger` structure has a `Pow`.aspx) method. This structure resides in the `System.Numerics` namespace, and was introduced in .NET Framework 4.0. You need to add a reference to the `System.Numerics` assembly before using it.
using System;
using System.Numerics;
public static class Program
{
public static void Main(string[] args)
{
Console.WriteLine(BigInteger.Pow(17, 13)); // 9904578032905937
}
}
Note that `BigInteger` is only suitable for integer arithmetic; it cannot handle fractional numbers. | stackexchange-stackoverflow | {
"answer_score": 10,
"question_score": 1,
"tags": "c#, .net, pow, double precision"
} |
Javascript clipboard.readText() not working in IOS Safari?
I have lines:
$(document).ready(function(){
$(window).on('focus', function () {
navigator.clipboard.readText().then(q => {
alert(q);
}).catch(err => {
console.error('Failed to read clipboard contents: ', err);
});
});
});
Run well on Android's browser. But in IOS Safari, nothing happens. Please help ! | Some changes has been done on webkit: <
Answer has been done here: Javascript / Clipboard API / Safari iOS / NotAllowedError Message | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 1,
"tags": "javascript, ios, safari"
} |
Accessing form elements filling fields?
I have a form which has an initial element, I am running a check using the confidence feature to check for other phrases that might match the user's input. If there are then i am going to a menu, from here i am asking the user to input a dtmf value to say whether one of these values where correct. If the user selects an option, i want it to fill that field of which it checked, with that interpretation or possibly go to another form which does the same thing, if i choose to do it using the other form, can u access filled fields from another form?
regards | According to the VoiceXML Specification the scope for that type of variable would only be accessible in the form. But you can assign the values to another variable before leaving the form that has document scope (i.e. defined just below the vxml tag). Or even give it global scope by defining the variable in the root document, which makes it accessible to the whole application. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "vxml, voicexml"
} |
How can I include a cache on my website?
I want to make the performance of my own website a bit better. So I want to implement a cache on my website.
Do you have any tutorials how I can do this?
This is my page. | go to these sites and take idea from them < < | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -3,
"tags": "performance, web"
} |
How is this behaviour of C explained?
so I was playing around with recursion in C and I am not sure why is this happening:
**code A**
int foo(int x)
{
if (x==0) return 0;
else return foo(--x)+x;
}
int main() { printf("%d\n", foo(10));
**code B**
int foo(int x)
{
if (x==0) return 0;
else return foo(x--)+x;
}
int main() { printf("%d\n", foo(10));
Code A prints 45 instead of 55 and I figured that out. It is because the recursive call gets unwounded this way: `9+8+7+...+0 = 45`
Code B on the other hand gets stuck and never returns to the prompt!! i have to `ctrl+c` it. Why does it get stuck? Is it because it never decrements past 10? | That's because in snippet B x gets decremented _after_ the recursive call so the function is always called with foo(10)
**EDIT:**
As James McNellis pointed out in its comment x gets decremented before calling the function but its original value is used in the call instead of the decremented one.
Basically the expression x-- is evaluated before foo(x--) but its value is actually x, therefore the function is called with x = 10 | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 2,
"tags": "c, recursion, decrement"
} |
Proper way to export HTML table as Excel file?
What's the correct way to export an HTML table as an Excel file so that the user can click a button and download the Excel file (ideally using Angular and without using server)?
I've seen many answers like this: Export to xls using angularjs but doing this gives an error similar to the following:
> "The file format and extension dont match... The file could be corrupted..."
and I believe the file is actually in HTML or XML format, not actual Excel.
The warning does not present a good image to the user.
What's the right way to actually export a file as Excel without using the server?
Or is the server required to create the file? | If you are just using tabular data, then I would argue that the best solution would be building a CSV file. This could be natively opened by excel and converted into an XLS file if necessary. You can do so by arranging your data with a data URI. The `octet-stream` will force a file download rather than opening in browser. Here is an example:
<a href="data:application/octet-stream,field1%2Cfield2%0Afoo%2Cbar%0Agoo%2Cgai%0A">CSV</a> | stackexchange-stackoverflow | {
"answer_score": 2,
"question_score": 1,
"tags": "javascript, angularjs, excel"
} |
evaluate the limit of $\frac {x}{|x|^s}$ as $s<1$ and $x$ goes to $0$
Evaluate $lim_{x\to 0} \frac {x}{|x|^s}$ for $s<1$ and $x\in \mathbb R^n$. For $n = 1$, I think this limit is equal to $0$. However I am trying to evaluate it when $x$ is an vector in arbitrary dimension. Does this limit exist? | **Hint:** $\displaystyle\left\|\frac x{\sqrt{\|x\|}}\right\|=\sqrt{\|x\|}$. | stackexchange-math | {
"answer_score": 2,
"question_score": 0,
"tags": "limits, multivariable calculus, normed spaces"
} |
Unable to access jarfile error
I am launching my application through a batch file on windows(10) startup. This is what i have in my batch file -
start javaw -jar javaApplication.jar`
When windows starts i get the
> Unable to access jarfile javaApplcation.jar
However, the problem is that after this error message the application is still being launched and works perfectly. What is the reason that the jar is being accessed but I'm still getting the unable to access the jar error, and how to avoid it? Couldn't find any answers to this specific case. | It is because you have start in front. Just try
javaw -jar ...
or
java -jar ... | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "java, batch file, jar"
} |
stringify detached entity in breeze
Is there a way to stringify detached entity in breeze?
It is possible to do via
creating appropriate manager
...
manager.addEntity(myEntity);
var str = manager.exportEntities(myEntity);
I just search the simplest way to do it without using managers. something like JSON.stringify(myEntity)... but it returns an error.
any suggestions? | The problem is that entities have relationships with other entities, and the resulting graph can be recursive and is also often very large so you will need some method of serializing a possibly recursive entity graph. This is what is done inside of the _exportEntities_ call.
If what you need is just the data properties of an entity then the code can be much simpler. Simply copy all of the _data properties_ of an entity ( list of data properties is available from the entityType) into an empty javascript object and then stringify this copy. Of course this will not give you _entityState_ information or _originalValues_ for the entity, but I can't tell if you need these. | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "json, breeze, stringify"
} |
multiple if statements in c for beginners
code is following:
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#include <stdlib.h>
void main(void)
{
int a, b;
printf("enter a");
scanf("%d",&a);
printf("enter b");
scanf("%d",&b);
if(a==1 && b<=8)
{
printf("you");
}
else if(a==2 && b<=10)
{
printf("you");
}
else
printf("me");
}
getch();
}
i edit again my question i found solution check please if there any syntax error. | You are not following general if-else block property
if(a==1 && b<=8) // This is independent if 1
{
printf("you");
}
Then this is another if-else either of if or else in this block will get executed independently of what has previously happened
if(a==2 && 5<b && b<=10) // This is independent if-else block 2
{
printf("you");
}
else
printf("me");
For achieving what you want it should be if, else if and else block
if(a==1 && b<=8)
{
printf("you");
}
else if(a==2 && 5<b && b<=10)
{
printf("you");
}
else
printf("me"); | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -8,
"tags": "c"
} |
Security considerations with using an NTP server
What are the security considerations to keep in mind when using an NTP server to synchronize time? Wikipedia lists that there are no known high-risk vulnerabilities, but are there any lower risk weak points one should be aware of?
Also, are there any special concerns when using NTP pool servers? | Paper written for GIAC qualification with in depth analysis of NTP security.
An overview of NTP that's a little less verbose.
> NTP is therefore vulnerable to security threats, whether from a malicious hacker who wants to alter the timestamp to commit fraud or a DDoS attack (Distributed Denial of Service - normally caused by malicious malware that floods a server with traffic) that blocks server access.
With regards to the pool servers, please remember they're volunteered servers.
From what I've read in the past, unless you have time critical tasks the highest risk is DDOS. | stackexchange-superuser | {
"answer_score": 1,
"question_score": 0,
"tags": "security, ntp"
} |
Create a Question Asker!
Writing questions for programming puzzles is tiring and takes many minutes to do. This is where you come in. Your job is to write a program that randomly generates plausible-sounding (but not necessarily interesting) code golf questions.
Input: None
Output: One sentence code golf question (see sentence structure)
Guidelines: **No hardcoding**. The questions don't have to be valid, solvable, or nontrivial. Creativity is encouraged. Voting is based on variety and bonus to programs that can create interesting problems.
Samples:
Find the sum of every even number from 1 to 100.
Create a funny sentence without punctuation.
Draw a picture of a cat in 3D.
Sentence structure:
[verb] [noun goal] [of] [noun specific] [preposition] [noun restriction] | # NetLogo
to go
type one-of [ "Print" "Calculate" "Find" "Determine" "Output" ]
type " the "
type one-of [ "sum" "mean" "average" "median" "standard deviation" "product" "geometric mean"]
type " of all "
type one-of [ "prime" "composite" "even" "odd" "perfect" "abundant" "deficient" "square" "triangular" "cubic" "lucky" "friendly" "strictly non-palindromic" ]
type " numbers from "
type random 100
type " to "
type 100 + random 10000
type one-of [ " (inclusive)." " (exclusive)." ]
end
Sample output (obtained randomly):
Find the product of all friendly numbers from 60 to 3112 (inclusive). | stackexchange-codegolf | {
"answer_score": 11,
"question_score": 0,
"tags": "popularity contest, generation, grammars"
} |
Hide custom post type by user roles
I created a custom post type ( Customers ) and i want to show posts of this post type just to the users with Customer role.
there is any way without or with plugin? | as @Tonydjukic mentioned, the best way is get user role first and then showing content to him.
also with this code we can do it :
$user = wp_get_current_user();
$allowed_roles = array( 'administrator', 'customer' );
if ( array_intersect( $allowed_roles, $user->roles ) ) {
} | stackexchange-wordpress | {
"answer_score": 2,
"question_score": 0,
"tags": "plugin development, users, user roles"
} |
removeEventListener not working as i expect
I know there are questions with similars problems, nevertheless I didn't understand how to fix the problem.
I need a solution for this problem: I have a onClick listener added in html document, then, in js I try to remove it but I can't.
Here is my code:
<html>
<head>
</head>
<body>
<div id="my-div" style="background: green" onclick="increase(event)">
0
</div>
<script src="app.js"></script>
</body>
</html>
And in js:
function increase(event){
let div = document.getElementById( event.currentTarget.id );
let number = parseInt(div.innerHTML);
number += 5;
div.innerHTML = number;
div.removeEventListener('click', increase); //but it doesnt get removed...
}
It's like I can't target the event listener added in the html file. How can I target it? | The listener that is set is not `increase`, it's basically an anonymous function `() => increase(event)` to which you don't have a reference.
Since you are setting it as `onclick` attribute, all you need to do is `div.onclick = null`.
However, it would be better to not use `onclick` in the first place since it relies on the functions existing in the global scope, prevents proper separation of code and markup and also prevents securing your page with CSP (content security policy).
If you were to adjust the event listener instead in `app.js` like this...:
document.getElementById('my-div').addEventListener('click', increase)
...then your existing code to remove the listener would work. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "javascript, html"
} |
How to make my e-mail public/visible in my Stack Overflow profile?
I just want to make my e-mail address public so that people can communicate with me if they want to, but I find no option to make my e-mail public. I tried the edit menu there I can change my display name, real name, e-mail, etc., but can't make my e-mail public. What to do? | The email field is a private information of user profile. Except moderator, SE developer & OP nobody can see it.
If you want to share your email you can write it in "about me" section of your profile. I have done same, you can check my profile page. | stackexchange-meta | {
"answer_score": 4,
"question_score": 1,
"tags": "discussion, profile page"
} |
Why convert to assembly language instead of machine code?
When I compile a C program, it is compiled first to assembly code, then assembled into machine code. I'm curious why it doesn't just convert straight to machine code in the first place. | It depends on the compiler and the options you provide to the compiler. These days the most widely used compilers will write out machine language by default, but will generate an assembly listing if you request it. It can be helpful to have the assembly listing because a) sometimes compilers have bugs and you want to check the code it's generated, b) you want to understand how the machine code is affected by the CPU pipeline and cache and most people find it much easier to read assembly than machine code.
These days compilers typically convert your program to a highly abstract representation and allow you to write custom back ends to generate different flavors of machine language or even other high level languages. | stackexchange-softwareengineering | {
"answer_score": 3,
"question_score": 2,
"tags": "assembly"
} |
Stuck in black screen closing steam
I have purchased a brand new dell XPS 15 9560
Specs:
- Windows 10
- Intel i7 7th generation (Kaby Lake)
- 16GB RAM
- NVIDIA GeForce GTX 1050
- 512 GB SSD
Everything works fine, except for steam: I downloaded Portal 2. But when I try to close the game. I am stuck with a black screen (no mouse cursor or so), A hard reboot is all I can do at the moment to get it working again.
The OS was pre-installed with all the necessary drivers, so I did not have to install some custom drivers myself.
Things I tried:
* Open the NVIDIA controle panel and switched the global graphics processor from the 'integrated Intel Graphics processor' to the ´High-end NVIDIA processor' (So the GTX 1050). But this didn't fix the problem.
Are some of you familiar with this problem? Do you have any advise on how to solve the problem?
Thanks for helping! | I was lucky that I ran into this post:
<
Changing the display adapter (Intel Integrated Graphics card) refresh rate (59hz to 60hz) did the trick for me, The reason why this works is not clear to me though.
Maybe it has something to do with when you close a steam game, windows tries to switches back from the NVIDIA card to the Intel card (I configured steam in the NVIDIA control panel it prefers to run steam with the NVIDIA GPU), and probably the NVIDIA card is running at 60 Hz (cannot verify this) while the Intel card is configured (by default) at 59 hz and so you run into trouble. | stackexchange-superuser | {
"answer_score": 1,
"question_score": 0,
"tags": "windows 10, nvidia graphics card, intel graphics, steam"
} |
Python replace function, Can it be done more beautiful?
can this be done in less lines
text = "DKK 5.000,33"
text2 = text.replace('DKK ', '')
text3 = text2.replace('.', '')
text4 = text3.replace(',','.')
print(float(text4))
It outputs what i want, it just looks so bad, and im hoping it can be done more beautiful so i dont have to make 4 new variables to change a text :) | You can call replace on text as many times as you want.
text = "DKK 5.000,33"
text2 = text.replace('DKK ', '').replace('.', '').replace(',','.')
print(float(text2)) | stackexchange-stackoverflow | {
"answer_score": 1,
"question_score": 0,
"tags": "python, replace"
} |
Resizing Bootstrap NavBar
I am creating a website using Bootstrap and want to resize the Navbar height when the browser screen is min-width: 268, I am using a media query to do this but for some reason the media query changes the height of the Navbar before the screen has been made smaller, can someone please help, code is below.
.navbar-inverse {
background-color: #fff;
border-color: transparent;
height: 105px;
}
@media only screen and (min-width: 268px) {
.navbar-inverse {
background-color: #fff;
border-color: transparent;
height: 50px;
}
} | If you want this style to apply when the width is LESS than 286px, use `max-width`. Try this:
@media only screen and (max-width: 268px) {
.navbar-inverse {
background-color: #fff;
border-color: transparent;
height: 50px;
}
} | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": 0,
"tags": "css, asp.net, twitter bootstrap, visual studio 2013, navbar"
} |
Is LiNbO3 a perovskite or not?
I am collecting a database of perovskite materials and could not decide if $\ce{LiNbO3}$ is categorized as perovskite or not. $\ce{LiNbO3}$ has been identified as a perovskite[ [1]]( as well as non-perovskite [2 , appendix] in literature. Which is correct? Usually the structure type of some compounds are written as ($\ce{LiNbO3}$-type or LN-type), are these perovskites or not?
Relevant publications are also appreciated.
**EDIT:**
Goldschmidt tolerance factor of $\ce{LiNbO3}$: **0.748** (should appr. be between 0.8 and 1.1 to be perovskite)
Tau factor of $\ce{LiNbO3}$(as proposed here): **8.678** (should be less than 4.18 to be perovskite. Tau factor is proven to be more accurate than tolerance factor)
These tolerance factors indicate $\ce{LiNbO3}$ should be non-perovskite, however, I found some other materials such as $\ce{BiSrCr2O6}$ that pass tolerance factor tests but still form LN-type structure. This is where the confusion comes :( | LiNbO3 has quite a unique non-perovskite structure (under ambient conditions) and it's referred to as a structural type (LiNbO3-type structure) as a result (see here). This is largely due to Li+ being a very small cation.
The tolerance factor from Victor Goldschmidt is a classifier with moderate accuracy, so it's not surprising that even if a material passes its test, it may still not acquire a perovskite structure.
The other (hidden) assumption that may cause confusion is that these classifiers for perovskite structures are usually trained for conditions at ambient temperature and pressure. So they can fail badly if this condition is no longer valid because a material can be in a non-perovskite phase under ambient conditions, but in the perovskite phase under some other conditions. | stackexchange-chemistry | {
"answer_score": 4,
"question_score": 7,
"tags": "inorganic chemistry, crystal structure, materials"
} |
If$A \leq_T B$ is given, can you reduce $\overline{A}$ to $B$ and vice-versa
If you are given two languages $A$, $B$ and $$A \leq_T B.$$ Is it possible to $\overline{A} \leq_T B$ or $A \leq_T \overline{B}$?
Here is my shot.
Case 1: $\overline{A} \leq_T B$
This is only possible if $A \leq_m B$ exists and $B=\overline{B}$. As you can transform any many-one reduction to its complement, we can show that if $A \leq_m B$, then $\overline{A} \leq_m \overline{B}=B$. Thus $\overline{A} \leq_m B$.
Case 2: $A \leq_T \overline{B}$
This is the same as above but we need to change the role of $A$ and $B$. | You say:
> This is only possible if $A \le_m B$ exists and $B=\overline{B}$
But that condition simplifies to "false" since it can never the case that $B=\overline{B}$.
Anyway the answer to both cases is "yes". If $A \le_T B$ then there is a Turing machine $T$ with oracle $B$ that decides $A$. By complementing $T$'s output we obtain a Turing machine with oracle $B$ that decides $\overline{A}$ showing that $\overline{A} \le_T B$. Moreover, consider a Turing machine $T'$ with oracle $\overline{B}$ that simulates $T$ except for the following: whenever $T$ invokes its oracle for $B$ on some input $w$, $T'$ invokes its oracle for $\overline{B}$ on $w$ and then complements the result. Clearly $T'$ still decides $A$, thus showing that $A \le_T \overline{B}$. | stackexchange-cs | {
"answer_score": 2,
"question_score": 0,
"tags": "formal languages, reductions"
} |
Flutter - Will BLoC stream instances cause memory leak when a widget is closed?
There are some scenarios where screens with their respective BLoCs are frequently created and closed. So I'm somewhat concerned about memory safety of the Streams instances created in this process, because it doesn't seem they are disposed somewhere or whether they are GC-ed. This clearly depends on the specific implementation of DART libraries and flutter. So if you know about their behavior, please let me know.
These are some scenarios I have encountered.
1. Multi-tab browser-like application.
2. Navigation through screens. (But it's not that harmful.)
3. showDialog() senarios when there are BLoCs inside the dialog. This is a far more common senario. There could be a lot of dialog popping up frequently in an app.
I wonder if it is necessary to override dispose() function and explicitly close all streams in BLoCProvider. It seems existing tutorials didn't mention it. | Streams will properly be cleaned as long as they aren't used anymore. The thing is, to simply removing the variable isn't enough to unsure it's unused. It could still run in background.
You need to call `Sink.close()` so that it stops the associated `StreamController`, to ensure resources can later be freed by the GC.
To do that, you have to use `StatefulWidget.dispose` method:
abstract class MyBloc {
Sink foo;
Sink bar;
}
class MyWiget extends StatefulWidget {
@override
_MyWigetState createState() => _MyWigetState();
}
class _MyWigetState extends State<MyWiget> {
MyBloc bloc;
@override
void dispose() {
bloc.bar.close();
bloc.foo.close();
super.dispose();
}
@override
Widget build(BuildContext context) {
// ...
}
} | stackexchange-stackoverflow | {
"answer_score": 9,
"question_score": 8,
"tags": "dart, flutter, rxdart"
} |
Is it possible to have a 2-in-1 USB device that is a Flash Drive and Power Bank?
I spent over an hour with no luck looking for a device that would provide flash storage and provide charging power to another device at the same time. I would think this would be possible as you can plug a phone into a computer and receive data as well as charging power simultaneously. If a 2-in-1 device is possible, does it already exist for purchase? Maybe it has a different name and I am searching with the wrong terminology. | Power banks typically are USB **hosts** so they can negotiate about voltage and current requirements with connected devices and e.g. cut power if required. In contrast to this, a USB flash drive (aka "mass storage device") is a USB **device** , which does not provide a voltage on Vbus.
As far as I know, this contradiction makes it impossible to have both features combined in one device _per standard_. | stackexchange-electronics | {
"answer_score": 1,
"question_score": 0,
"tags": "usb, charging, drive"
} |
jQuery or onClick Div Fade
I apologize if this is in the wrong section..
Could someone possibly point me towards a script or a tutorial on this:
when I click on something, say for instance an "x", I'll click it, then it fades away on click.
If you understand what I mean, could someone point me in the right direction please?
Thanks! | Refer this: <
There is small tutorials for different UI elements with good explanation. | stackexchange-stackoverflow | {
"answer_score": 0,
"question_score": -3,
"tags": "javascript, jquery"
} |
HDMI turns off two monitors
**Setup:**
* 2 monitors [DVI]
* 1 TV [HDMI]
* Card: Ati Radeon 6850
* OS: Windows 10
**Situation:**
When I plug the HDMI into the video card my monitors turn off. Switching one of them off does not make a difference. The moment I unplug the HDMI, the monitors wake up. Drivers are up to date.
What is the cause of this? | So here is what I did here to be able to switch between monitors and TV:
When the 3 cables are plugged in there is no way all the monitors will work.
Go to display settings and mirror TV and one of the monitors. The second monitor should be disconnected. That way the TV works. What I found out is that only one of the monitors can work with the TV, while the other one does not want to. Should be port conflict or something.
Again go to display settings and disable the TV and enable the second monitor. That way both monitors work.
I found a program called monitor profile switcher that remembers setting profiles so that I don't have go through settings every time.
P.S. Get latest drivers as well. And this is not windows 10 specific like I indicated initially. | stackexchange-superuser | {
"answer_score": 0,
"question_score": 0,
"tags": "windows 10, display, multiple monitors, hdmi"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.