qid int64 1 74.7M | question stringlengths 0 58.3k | date stringlengths 10 10 | metadata list | response_j stringlengths 2 48.3k | response_k stringlengths 2 40.5k |
|---|---|---|---|---|---|
276,342 | I am in search for a database with translations so I can have comonly used phrases and words translated by a machine and not by an expensive translator. Is there such a thing as a translation database with words and often used phrases?
If you don't know any would you use such a service?
edit: the database should only... | 2008/11/09 | [
"https://Stackoverflow.com/questions/276342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19929/"
] | >
> edit: the database should only be monitored by people and not some automatic translater since they tend to be VERY bad
>
>
>
I don't think this is enough. If you're going to translate single words, you need to have some idea of the context in which the word will be used.
For instance, consider the english wor... | So what you want is a database phrase book? What do you want that for? You can't use a phrase book to translate books or software etc. You can't use machine translation either, even though it can be a useful tool to start with. You have to use human translators wich know the source and target-language well, preferrably... |
276,342 | I am in search for a database with translations so I can have comonly used phrases and words translated by a machine and not by an expensive translator. Is there such a thing as a translation database with words and often used phrases?
If you don't know any would you use such a service?
edit: the database should only... | 2008/11/09 | [
"https://Stackoverflow.com/questions/276342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19929/"
] | Check: [open-tran.eu](http://open-tran.eu/). It is a database of translations taken from various open source projects. | So what you want is a database phrase book? What do you want that for? You can't use a phrase book to translate books or software etc. You can't use machine translation either, even though it can be a useful tool to start with. You have to use human translators wich know the source and target-language well, preferrably... |
12,619,186 | I have two model name image and comment. here the relation is like image has many comments . Now in my listing page I want to display all imae detail and only the no of comment on that image . can you tell me how should I get that ?
after I write the query my return data is
```
Array
(
[0] => Array
(
... | 2012/09/27 | [
"https://Stackoverflow.com/questions/12619186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1089665/"
] | I found the answer, but I don't quite understand why it works.
I changed the context from serverContextPath (which returns /) to "" and it works.
```
eventConfigureTomcat = {tomcat ->
println "Changing the configuration for tomcat"
println serverContextPath
def ctx=tomcat.host.findChild(serverContextPath)... | This is what worked for me on Grails 2.4.x:
In BuildConfig.groovy:
```
grails.appName = appName;
```
(Not sure how else to access app name. You can also add your app.context in a similar fashion)
Then add scripts/\_Events.groovy with this content:
```
eventConfigureTomcat = { tomcat ->
def ctx = tomcat.host.fi... |
12,619,186 | I have two model name image and comment. here the relation is like image has many comments . Now in my listing page I want to display all imae detail and only the no of comment on that image . can you tell me how should I get that ?
after I write the query my return data is
```
Array
(
[0] => Array
(
... | 2012/09/27 | [
"https://Stackoverflow.com/questions/12619186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1089665/"
] | I found the answer, but I don't quite understand why it works.
I changed the context from serverContextPath (which returns /) to "" and it works.
```
eventConfigureTomcat = {tomcat ->
println "Changing the configuration for tomcat"
println serverContextPath
def ctx=tomcat.host.findChild(serverContextPath)... | None of the answers quite worked for me but Tobia's comment helped me set the ctx variable correctly. In the end, I only had to edit the scripts/\_Events.groovy like this:
```
eventConfigureTomcat = { tomcat ->
def ctx = tomcat.host.findChildren()[0]
ctx.allowLinking = true
println "Added symbolic link su... |
12,619,186 | I have two model name image and comment. here the relation is like image has many comments . Now in my listing page I want to display all imae detail and only the no of comment on that image . can you tell me how should I get that ?
after I write the query my return data is
```
Array
(
[0] => Array
(
... | 2012/09/27 | [
"https://Stackoverflow.com/questions/12619186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1089665/"
] | This is what worked for me on Grails 2.4.x:
In BuildConfig.groovy:
```
grails.appName = appName;
```
(Not sure how else to access app name. You can also add your app.context in a similar fashion)
Then add scripts/\_Events.groovy with this content:
```
eventConfigureTomcat = { tomcat ->
def ctx = tomcat.host.fi... | None of the answers quite worked for me but Tobia's comment helped me set the ctx variable correctly. In the end, I only had to edit the scripts/\_Events.groovy like this:
```
eventConfigureTomcat = { tomcat ->
def ctx = tomcat.host.findChildren()[0]
ctx.allowLinking = true
println "Added symbolic link su... |
31,340,784 | I have two (sorted) text files:
a.txt
```
1
2
3
4
```
b.txt
```
1
3
7
```
I want to create a file only listing the lines in `a.txt` where all lines of file `b.txt` are removed.
So the result should be:
result.txt
```
2
4
``` | 2015/07/10 | [
"https://Stackoverflow.com/questions/31340784",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/868941/"
] | ```
grep a.txt -F -x -v --file=b.txt
| | | +
| | | +--> obtain PATTERN from file
| | +-------> invert match
| +----------> force PATTERN t... | Assuming a.txt and b.txt are already sorted lexically:
```
comm -23 a.txt b.txt
```
Normally `comm` reads two files, which should be sorted lexically,
and produces three text columns as output: lines only in file1; lines only in file2; and lines in both files.
The options -23 suppress the second and third columns. |
12,840 | I'd like to route my multibit traffic through TOR, but have been unsuccessful finding out if it's possible. It's certainly not in the GUI settings on OSX. | 2013/08/21 | [
"https://bitcoin.stackexchange.com/questions/12840",
"https://bitcoin.stackexchange.com",
"https://bitcoin.stackexchange.com/users/6468/"
] | Unfortunately there is a library used in MultiBit/ bitcoinj for networking (called netty) that does not support SOCKS proxies. Thus currently you cannot set up MultiBit to use Tor.
It is something we want to support so there are plans afoot to refactor the code and use a different networking library that does support ... | As it relates to Bitcoin, no. Bitcoin is a peer to peer network for sharing the transactions and would require some server out there running TOR to convert the rest of the network to the same TOR and redistribute the transactions. I have not heard of any plans of implementing this in to Bitcoin transactions of any kind... |
6,250,683 | I have a table and rows are added by users by clicking in a button. I do this with Javascript.
But then I have to get the values with C# and add then to database. C# is mandatory.
How can I do this? | 2011/06/06 | [
"https://Stackoverflow.com/questions/6250683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/374027/"
] | Use [`AJAX`](http://en.wikipedia.org/wiki/Ajax_%28programming%29) to get/send the values from and to the server. | Probably the best way to do this would be to use AJAX. Since you're already using JavaScript, it would be a simple matter of adding the service call at the finalization stage of the action to implement the database changes directly.
<http://msdn.microsoft.com/en-us/library/aa479042.aspx> |
6,250,683 | I have a table and rows are added by users by clicking in a button. I do this with Javascript.
But then I have to get the values with C# and add then to database. C# is mandatory.
How can I do this? | 2011/06/06 | [
"https://Stackoverflow.com/questions/6250683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/374027/"
] | Use [`AJAX`](http://en.wikipedia.org/wiki/Ajax_%28programming%29) to get/send the values from and to the server. | you can do it by using jquery & ajax
if you dont want you can put all new values in new rows in a hidden field (with a proper structure) and read hidden field value in server side |
45,194,155 | Trying to display prettified json in Angular mdModal...
Here's my code:
```
testVm.showPopup = function(id, data, ev) {
var jsonPrettified = JSON.stringify(JSON.parse(data), null, 2);
$mdDialog.show({
parent: angular.element(document.body),
clickOutsideToClose: ... | 2017/07/19 | [
"https://Stackoverflow.com/questions/45194155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2135127/"
] | You should put your `jsonPrettified` into `<pre>` tag. It will save all indents in the string. | Try to use angular 'json' filter, it's easier. You don't need to transform your json object to an string by yourselft, angular does it for you.
var myobject = {
"name": "Daniel",
"lastname": "Delgado",
"age": 23
};
```
$mdDialog.show({
parent: angular.element(document.body),
clickOutsideToClose: true, ... |
3,478,309 | I need to remove every fourth byte in the `byte[]` I have.
Is there some built-in function that could help me to do that or do I have to loop over the array picking and moving each byte one by one?
Similarly what what if I need to place 0 after every three bytes from `byte[]` is there a way to do this faster than man... | 2010/08/13 | [
"https://Stackoverflow.com/questions/3478309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/166921/"
] | Sounds like a good job for a [parallel For loop](http://msdn.microsoft.com/en-us/library/dd460703.aspx) (assuming you can use .NET 4). | The fastest way would probably be to create a wrapper to translate indexes instead of creating a new array. |
3,478,309 | I need to remove every fourth byte in the `byte[]` I have.
Is there some built-in function that could help me to do that or do I have to loop over the array picking and moving each byte one by one?
Similarly what what if I need to place 0 after every three bytes from `byte[]` is there a way to do this faster than man... | 2010/08/13 | [
"https://Stackoverflow.com/questions/3478309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/166921/"
] | Coding it by hand is likely to be very fast, and the bottleneck is the cpu-to-memory bandwidth.
One core can easily max out the memory bandwidth on a modern machine, so multithreading is unlikely to help since the work done is very straightforward (a single read or write per 4th element.) | Sounds like a good job for a [parallel For loop](http://msdn.microsoft.com/en-us/library/dd460703.aspx) (assuming you can use .NET 4). |
3,478,309 | I need to remove every fourth byte in the `byte[]` I have.
Is there some built-in function that could help me to do that or do I have to loop over the array picking and moving each byte one by one?
Similarly what what if I need to place 0 after every three bytes from `byte[]` is there a way to do this faster than man... | 2010/08/13 | [
"https://Stackoverflow.com/questions/3478309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/166921/"
] | Coding it by hand is likely to be very fast, and the bottleneck is the cpu-to-memory bandwidth.
One core can easily max out the memory bandwidth on a modern machine, so multithreading is unlikely to help since the work done is very straightforward (a single read or write per 4th element.) | The fastest way would probably be to create a wrapper to translate indexes instead of creating a new array. |
3,478,309 | I need to remove every fourth byte in the `byte[]` I have.
Is there some built-in function that could help me to do that or do I have to loop over the array picking and moving each byte one by one?
Similarly what what if I need to place 0 after every three bytes from `byte[]` is there a way to do this faster than man... | 2010/08/13 | [
"https://Stackoverflow.com/questions/3478309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/166921/"
] | If you don't mind creating a new array instead of modifying the existing one, you can easily do it with Linq:
```
bytes = bytes.Where((b, i) => (i + 1) % 4 != 0).ToArray();
```
To insert an item every 3 bytes, there is no way to do it using built-in extension methods. But you can create your own extension method:
`... | The fastest way would probably be to create a wrapper to translate indexes instead of creating a new array. |
3,478,309 | I need to remove every fourth byte in the `byte[]` I have.
Is there some built-in function that could help me to do that or do I have to loop over the array picking and moving each byte one by one?
Similarly what what if I need to place 0 after every three bytes from `byte[]` is there a way to do this faster than man... | 2010/08/13 | [
"https://Stackoverflow.com/questions/3478309",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/166921/"
] | Coding it by hand is likely to be very fast, and the bottleneck is the cpu-to-memory bandwidth.
One core can easily max out the memory bandwidth on a modern machine, so multithreading is unlikely to help since the work done is very straightforward (a single read or write per 4th element.) | If you don't mind creating a new array instead of modifying the existing one, you can easily do it with Linq:
```
bytes = bytes.Where((b, i) => (i + 1) % 4 != 0).ToArray();
```
To insert an item every 3 bytes, there is no way to do it using built-in extension methods. But you can create your own extension method:
`... |
237,422 | The recently detected gravitational wave at LIGO were extremely small - requiring a $1 billion interferometer to even detect its presence as it passes Earth.
The gravitational constant G is small: ~$10^{-40}$ times that of the electromagnetic coupling for protons. But then, there are lots of really massive, energetic ... | 2016/02/15 | [
"https://physics.stackexchange.com/questions/237422",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/84150/"
] | The universe is big. But that doesn't mean it hits you all at once.
For background, consider Obler's paradox. Stars that are far away send less power to us because they are far away. But there are more stars far away. So how come the sky is dark at night? You might expect that the big universe full of so many stars wo... | [Here are](http://hyperphysics.phy-astr.gsu.edu/hbase/forces/funfor.html) the four fundamental forces:
[](https://i.stack.imgur.com/Whtsn.png)
What is important is the column that shows "strength" and is connected with the word "large" in the title of your question.
>
>... |
237,422 | The recently detected gravitational wave at LIGO were extremely small - requiring a $1 billion interferometer to even detect its presence as it passes Earth.
The gravitational constant G is small: ~$10^{-40}$ times that of the electromagnetic coupling for protons. But then, there are lots of really massive, energetic ... | 2016/02/15 | [
"https://physics.stackexchange.com/questions/237422",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/84150/"
] | The universe is big. But that doesn't mean it hits you all at once.
For background, consider Obler's paradox. Stars that are far away send less power to us because they are far away. But there are more stars far away. So how come the sky is dark at night? You might expect that the big universe full of so many stars wo... | Are you simply asking whether we should worry that there is an unseen menace about to unleash a "gravitational wave tsunami" upon the Earth? You shouldn't be.
Let's take the empirical evidence. The only source to have been detected is a large black hole merger. The event rate in the universe is only constrained by thi... |
237,422 | The recently detected gravitational wave at LIGO were extremely small - requiring a $1 billion interferometer to even detect its presence as it passes Earth.
The gravitational constant G is small: ~$10^{-40}$ times that of the electromagnetic coupling for protons. But then, there are lots of really massive, energetic ... | 2016/02/15 | [
"https://physics.stackexchange.com/questions/237422",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/84150/"
] | [Here are](http://hyperphysics.phy-astr.gsu.edu/hbase/forces/funfor.html) the four fundamental forces:
[](https://i.stack.imgur.com/Whtsn.png)
What is important is the column that shows "strength" and is connected with the word "large" in the title of your question.
>
>... | Are you simply asking whether we should worry that there is an unseen menace about to unleash a "gravitational wave tsunami" upon the Earth? You shouldn't be.
Let's take the empirical evidence. The only source to have been detected is a large black hole merger. The event rate in the universe is only constrained by thi... |
3,526,749 | I have seen this code posted here on StackOverflow:
```
with TDownloadURL.Create(nil) do
try
URL := 'myurltodownload.com';
filename := 'locationtosaveto';
try
ExecuteTarget(nil);
except
result := false;
end;
if not FileExists(filename) then
result := false;
finally
fre... | 2010/08/19 | [
"https://Stackoverflow.com/questions/3526749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46207/"
] | In the original, if ExecuteTarget throws an exception, it will still test of filename exists.
In yours, if ExecuteTarget throws an exception, result is always false.
Also, unless you skipped a line, on the original, if ExecuteTarget succeeds and the file exists, `result` is never set. | The first version just eat the exception and never raise to upper callers, it treat exception as false return. For your simple version, exception will be thrown out. |
3,526,749 | I have seen this code posted here on StackOverflow:
```
with TDownloadURL.Create(nil) do
try
URL := 'myurltodownload.com';
filename := 'locationtosaveto';
try
ExecuteTarget(nil);
except
result := false;
end;
if not FileExists(filename) then
result := false;
finally
fre... | 2010/08/19 | [
"https://Stackoverflow.com/questions/3526749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46207/"
] | The difference is that your second example passes exceptions back to the caller, while the original traps them and returns false. I'd characterise that style of coding as "I don't care why it failed, I only care whether it succeeded". Which can be reasonable in some cases (like trying to download an update).
So your ... | The first version just eat the exception and never raise to upper callers, it treat exception as false return. For your simple version, exception will be thrown out. |
3,526,749 | I have seen this code posted here on StackOverflow:
```
with TDownloadURL.Create(nil) do
try
URL := 'myurltodownload.com';
filename := 'locationtosaveto';
try
ExecuteTarget(nil);
except
result := false;
end;
if not FileExists(filename) then
result := false;
finally
fre... | 2010/08/19 | [
"https://Stackoverflow.com/questions/3526749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/46207/"
] | The difference is that your second example passes exceptions back to the caller, while the original traps them and returns false. I'd characterise that style of coding as "I don't care why it failed, I only care whether it succeeded". Which can be reasonable in some cases (like trying to download an update).
So your ... | In the original, if ExecuteTarget throws an exception, it will still test of filename exists.
In yours, if ExecuteTarget throws an exception, result is always false.
Also, unless you skipped a line, on the original, if ExecuteTarget succeeds and the file exists, `result` is never set. |
53,603,839 | This is not a duplicate.. in my belief. I'm not asking about its usefulness. I ask for clarification of definition, if I may. Instead of downvoting, kindly, explain. Then I'll remove this post if I deem stupid for the rest of the readers.
```
f=re.match(pattern, str)
pattern= '(?:animal)(?:=)((\w+),)+'
str = 'animal=c... | 2018/12/04 | [
"https://Stackoverflow.com/questions/53603839",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7453606/"
] | `(foo)` is a capture group. `(?:foo)` is a non capture group. `(?<foo>bar)` is a named capture group, where the name is "foo".
The thing with capture groups is that they can later be referenced by referring to the capture group number, or if it is named, the name of the group. It's helpful for when you're trying to se... | When matching a regular expression, anything in the parenthesis () is considered a group. Group 0 is the entire matched string, while groups 1,... are the subgroups identified by () in regular pattern.
```
import re
rr = '(?:animal)(?:=)((\w+),)+'
mystr="animal=cat,dog,cat,tiger,dog"
res = re.search(rr,mystr)
res.grou... |
51,537,075 | I have two pandas columns, where I first compare the two columns and then replace an old string with a new one.
My data:
```
shopping on_List
Banana 1
Apple 0
Grapes 1
None 0
Banana 1
Nuts 0
Lemon 1
```
In order to compare the two I have done the following:
```
results = []
for shop... | 2018/07/26 | [
"https://Stackoverflow.com/questions/51537075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8074805/"
] | I suggest create dictionary for mapping and replace filtered values:
```
d = {'Banana':'Bananas', 'Lemon':'Lemons', 'Apple':'Apples'}
mask = df['on_List'].eq(1) & df['on_List'].notnull()
df['shopping'] = df['shopping'].mask(mask, df['shopping'].map(d)).fillna(df['shopping'])
#slowier solution
#df['shopping'] = df['sh... | ```
val = []
for i in range(len(df)):
if df["shopping"][i] != None and df["on_List"][i] == 1:
if df["shopping"][i] == "Banana":
val.append("Bananas")
elif df["shopping"][i] == "Lemon":
val.append("Lemons")
elif df["shopping"][i] == "Apple":
val.append("App... |
18,036,476 | i have just started php and html and i am creating a small game for personal use. Anyways, i wrote a script were you simply enter data to create an account and then you submit it:
```
<?php include 'header.php';
?>
<br>
<br>
<br>
<table border="1" align="center" cellpadding='25'>
<tr>
<td align='middle'>
<form method... | 2013/08/03 | [
"https://Stackoverflow.com/questions/18036476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2636056/"
] | You are accessing the wrong name in $\_POST
```
$username1 = $_POST ['username'];
$password1 = $_POST ['password'];
``` | To avoid problems within your form, add `</form>` - tag and change to type='text'. the type-attribute tells what type of element, not what name the element is identified as. You have name-attribute for that.
```
<table border="1" align="center" cellpadding='25'>
<tr>
<td align='middle'>
<form method='POST' action='ins... |
18,036,476 | i have just started php and html and i am creating a small game for personal use. Anyways, i wrote a script were you simply enter data to create an account and then you submit it:
```
<?php include 'header.php';
?>
<br>
<br>
<br>
<table border="1" align="center" cellpadding='25'>
<tr>
<td align='middle'>
<form method... | 2013/08/03 | [
"https://Stackoverflow.com/questions/18036476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2636056/"
] | You are accessing the wrong name in $\_POST
```
$username1 = $_POST ['username'];
$password1 = $_POST ['password'];
``` | Change this:
```
$username1 = $_POST ['username1'];
$password1 = $_POST ['password1'];
```
Into this
```
$username1 = $_POST['username'];
$password1 = $_POST['password'];
```
The HTML form inputs are called 'username' and 'password', these names are passed to the `$_POST` variable.
Now, you don't sanitize yo... |
18,036,476 | i have just started php and html and i am creating a small game for personal use. Anyways, i wrote a script were you simply enter data to create an account and then you submit it:
```
<?php include 'header.php';
?>
<br>
<br>
<br>
<table border="1" align="center" cellpadding='25'>
<tr>
<td align='middle'>
<form method... | 2013/08/03 | [
"https://Stackoverflow.com/questions/18036476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2636056/"
] | You are accessing the wrong name in $\_POST
```
$username1 = $_POST ['username'];
$password1 = $_POST ['password'];
``` | There is no errors in your posted code except a closing tag of form. I copied the same code and is working perfectly. What I changed is,
```
<html>
<head>
<title>Althaf</title>
</head>
<body bgcolor="gray">
<b>Welcome to <i>html</i></b><br>
<?php include 'header.php';
?>
<br>
<br>
<br>
<table border="1" align="cent... |
18,036,476 | i have just started php and html and i am creating a small game for personal use. Anyways, i wrote a script were you simply enter data to create an account and then you submit it:
```
<?php include 'header.php';
?>
<br>
<br>
<br>
<table border="1" align="center" cellpadding='25'>
<tr>
<td align='middle'>
<form method... | 2013/08/03 | [
"https://Stackoverflow.com/questions/18036476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2636056/"
] | To avoid problems within your form, add `</form>` - tag and change to type='text'. the type-attribute tells what type of element, not what name the element is identified as. You have name-attribute for that.
```
<table border="1" align="center" cellpadding='25'>
<tr>
<td align='middle'>
<form method='POST' action='ins... | First of all,
There is no `input type="username"`. What you should use is `input type="text"`.
Secondly, there are no elements in the HTML form with their name attributes set to "username1" or "password1". I hope you have noticed that. So modify the PHP file accordingly.
And you'll face a lot of errors even after th... |
18,036,476 | i have just started php and html and i am creating a small game for personal use. Anyways, i wrote a script were you simply enter data to create an account and then you submit it:
```
<?php include 'header.php';
?>
<br>
<br>
<br>
<table border="1" align="center" cellpadding='25'>
<tr>
<td align='middle'>
<form method... | 2013/08/03 | [
"https://Stackoverflow.com/questions/18036476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2636056/"
] | You are accessing the wrong name in $\_POST
```
$username1 = $_POST ['username'];
$password1 = $_POST ['password'];
``` | You are using `name="username"` not `username1` as in your PHP.
```
$username1 = $_POST['username'];
$password1 = $_POST['password'];
```
also the `type` is wrong. |
18,036,476 | i have just started php and html and i am creating a small game for personal use. Anyways, i wrote a script were you simply enter data to create an account and then you submit it:
```
<?php include 'header.php';
?>
<br>
<br>
<br>
<table border="1" align="center" cellpadding='25'>
<tr>
<td align='middle'>
<form method... | 2013/08/03 | [
"https://Stackoverflow.com/questions/18036476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2636056/"
] | You are using `name="username"` not `username1` as in your PHP.
```
$username1 = $_POST['username'];
$password1 = $_POST['password'];
```
also the `type` is wrong. | There is no errors in your posted code except a closing tag of form. I copied the same code and is working perfectly. What I changed is,
```
<html>
<head>
<title>Althaf</title>
</head>
<body bgcolor="gray">
<b>Welcome to <i>html</i></b><br>
<?php include 'header.php';
?>
<br>
<br>
<br>
<table border="1" align="cent... |
18,036,476 | i have just started php and html and i am creating a small game for personal use. Anyways, i wrote a script were you simply enter data to create an account and then you submit it:
```
<?php include 'header.php';
?>
<br>
<br>
<br>
<table border="1" align="center" cellpadding='25'>
<tr>
<td align='middle'>
<form method... | 2013/08/03 | [
"https://Stackoverflow.com/questions/18036476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2636056/"
] | Change this:
```
$username1 = $_POST ['username1'];
$password1 = $_POST ['password1'];
```
Into this
```
$username1 = $_POST['username'];
$password1 = $_POST['password'];
```
The HTML form inputs are called 'username' and 'password', these names are passed to the `$_POST` variable.
Now, you don't sanitize yo... | First of all,
There is no `input type="username"`. What you should use is `input type="text"`.
Secondly, there are no elements in the HTML form with their name attributes set to "username1" or "password1". I hope you have noticed that. So modify the PHP file accordingly.
And you'll face a lot of errors even after th... |
18,036,476 | i have just started php and html and i am creating a small game for personal use. Anyways, i wrote a script were you simply enter data to create an account and then you submit it:
```
<?php include 'header.php';
?>
<br>
<br>
<br>
<table border="1" align="center" cellpadding='25'>
<tr>
<td align='middle'>
<form method... | 2013/08/03 | [
"https://Stackoverflow.com/questions/18036476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2636056/"
] | You are accessing the wrong name in $\_POST
```
$username1 = $_POST ['username'];
$password1 = $_POST ['password'];
``` | Your type in your input tag should be "text":
```
Username: <input type='text' name='username'> <br>
```
And the name you are getting from `$_POST` has to match the name in your form:
```
$username1 = $_POST ['username'];
``` |
18,036,476 | i have just started php and html and i am creating a small game for personal use. Anyways, i wrote a script were you simply enter data to create an account and then you submit it:
```
<?php include 'header.php';
?>
<br>
<br>
<br>
<table border="1" align="center" cellpadding='25'>
<tr>
<td align='middle'>
<form method... | 2013/08/03 | [
"https://Stackoverflow.com/questions/18036476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2636056/"
] | Your type in your input tag should be "text":
```
Username: <input type='text' name='username'> <br>
```
And the name you are getting from `$_POST` has to match the name in your form:
```
$username1 = $_POST ['username'];
``` | There is no errors in your posted code except a closing tag of form. I copied the same code and is working perfectly. What I changed is,
```
<html>
<head>
<title>Althaf</title>
</head>
<body bgcolor="gray">
<b>Welcome to <i>html</i></b><br>
<?php include 'header.php';
?>
<br>
<br>
<br>
<table border="1" align="cent... |
18,036,476 | i have just started php and html and i am creating a small game for personal use. Anyways, i wrote a script were you simply enter data to create an account and then you submit it:
```
<?php include 'header.php';
?>
<br>
<br>
<br>
<table border="1" align="center" cellpadding='25'>
<tr>
<td align='middle'>
<form method... | 2013/08/03 | [
"https://Stackoverflow.com/questions/18036476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2636056/"
] | You are accessing the wrong name in $\_POST
```
$username1 = $_POST ['username'];
$password1 = $_POST ['password'];
``` | First of all,
There is no `input type="username"`. What you should use is `input type="text"`.
Secondly, there are no elements in the HTML form with their name attributes set to "username1" or "password1". I hope you have noticed that. So modify the PHP file accordingly.
And you'll face a lot of errors even after th... |
73,133,136 | ```
df.speed # so nice cause of autocomplete...
df['speed']
df.loc[:,'speed']
```
are returning my data like omitting the selected column name
```
Time
2022-07-27 11:33:16.279157 45.000000
2022-07-27 11:33:16.628157 44.928571
2022-07-27 11:33:17.093157 44.857143
2022-07-27 11:33:17.449157 44.785714
```
... | 2022/07/27 | [
"https://Stackoverflow.com/questions/73133136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5273580/"
] | Here's how you could do it in a simple update using the aggregation pipelined updates:
```
db.collection.updateMany({},
[
{
$set: {
citizens: {
$map: {
input: "$citizens",
in: {
$mergeObjects: [
{
status: {
$cond: [
... | It would have worked like [this](https://mongoplayground.net/p/cKPX4qSAAdY) if your date was already in the right format. Since you need to format it, I think you should use an aggregation pipeline with a $merge stage:
```
db.collection.aggregate([
{$set: {
citizens: {
$map: {
input: "$citize... |
73,133,136 | ```
df.speed # so nice cause of autocomplete...
df['speed']
df.loc[:,'speed']
```
are returning my data like omitting the selected column name
```
Time
2022-07-27 11:33:16.279157 45.000000
2022-07-27 11:33:16.628157 44.928571
2022-07-27 11:33:17.093157 44.857143
2022-07-27 11:33:17.449157 44.785714
```
... | 2022/07/27 | [
"https://Stackoverflow.com/questions/73133136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5273580/"
] | This is an update using the `arrayFilters` syntax.
```
db.collection.updateMany(
{ },
{
$set: { "citizens.$[elem].status": "adult" }
},
{
arrayFilters: [ { "elem.status": { $exists: false } , "elem.birthday": { $lt: "2004/07/27" } } ]
}
)
```
Note the date value `"2004/07/27"` is the day 18 y... | It would have worked like [this](https://mongoplayground.net/p/cKPX4qSAAdY) if your date was already in the right format. Since you need to format it, I think you should use an aggregation pipeline with a $merge stage:
```
db.collection.aggregate([
{$set: {
citizens: {
$map: {
input: "$citize... |
29,215,485 | *Preface*
I'm trying to implement a **Dictionary** data structure that stores Pairs(an object) in a dynamic array.
The array starts off with size [10]. Every time the user tries to add another Pair to the **Dictionary** when the array is full; the dynamic array increments the length of the array by 5.
There are 3 r... | 2015/03/23 | [
"https://Stackoverflow.com/questions/29215485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4132420/"
] | Since your keys are `String`, you need to use the `equals` method for checking key equality:
```
if (array[i] != null && array[i].getKey().equals(key)){
return array[i].getToken();
}
``` | You'll find that a HashMap (or just a Map) will do what you want with a lot less effort. |
23,831,767 | I need to grep a file from a line containing `Pattern A` to a first empty line.
I used `awk` but I don't know how to code this empty line.
```
cat ${file} | awk '/Pattern A/,/Pattern B/'
``` | 2014/05/23 | [
"https://Stackoverflow.com/questions/23831767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3589473/"
] | `sed` might be best:
```
sed -n '/PATTERN/,/^$/p' file
```
To avoid printing the empty line:
```
sed -n '/PATTERN/,/^$/{/^$/d; p}' file
```
or even better - [thanks jthill!](https://stackoverflow.com/questions/23831767/grep-awk-a-file-from-a-to-first-empty-line/23831800?noredirect=1#comment36670072_23831800):
``... | Using `sed`:
```
sed -n '/PATTERN/,/^$/{/^$/q;p;}' file
```
Using `regex` range, you define your range from the `PATTERN` to blank line (`/^$/`). When you encounter a blank line, you quit else you keep printing.
Using `awk`:
```
awk '/PATTERN/{p=1}/^$/&&p{exit}p' file
```
You enable a flag when you encounter... |
23,831,767 | I need to grep a file from a line containing `Pattern A` to a first empty line.
I used `awk` but I don't know how to code this empty line.
```
cat ${file} | awk '/Pattern A/,/Pattern B/'
``` | 2014/05/23 | [
"https://Stackoverflow.com/questions/23831767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3589473/"
] | `sed` might be best:
```
sed -n '/PATTERN/,/^$/p' file
```
To avoid printing the empty line:
```
sed -n '/PATTERN/,/^$/{/^$/d; p}' file
```
or even better - [thanks jthill!](https://stackoverflow.com/questions/23831767/grep-awk-a-file-from-a-to-first-empty-line/23831800?noredirect=1#comment36670072_23831800):
``... | I think this is a nice, readable Perl one-liner:
```
perl -wne '$f=1 if /Pattern A/; exit if /^\s*$/; print if $f' file
```
* Set the flag `$f` when the pattern is matched
* Exit if a blank line (only whitespace between start and end of line) is found
* Print the line if the flag is set
Testing it out:
```
$ cat f... |
23,831,767 | I need to grep a file from a line containing `Pattern A` to a first empty line.
I used `awk` but I don't know how to code this empty line.
```
cat ${file} | awk '/Pattern A/,/Pattern B/'
``` | 2014/05/23 | [
"https://Stackoverflow.com/questions/23831767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3589473/"
] | `sed` might be best:
```
sed -n '/PATTERN/,/^$/p' file
```
To avoid printing the empty line:
```
sed -n '/PATTERN/,/^$/{/^$/d; p}' file
```
or even better - [thanks jthill!](https://stackoverflow.com/questions/23831767/grep-awk-a-file-from-a-to-first-empty-line/23831800?noredirect=1#comment36670072_23831800):
``... | Never use
```
/foo/,/bar/
```
in awk unless you want to get from the first occurrence of "foo" to the last occurrence of "bar" as it makes trivial jobs marginally briefer but even slightly more interesting requirements require a complete re-write.
Just use:
```
/foo/{f=1} f{print; if (/bar/) f=0}
```
or similar ... |
23,831,767 | I need to grep a file from a line containing `Pattern A` to a first empty line.
I used `awk` but I don't know how to code this empty line.
```
cat ${file} | awk '/Pattern A/,/Pattern B/'
``` | 2014/05/23 | [
"https://Stackoverflow.com/questions/23831767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3589473/"
] | Using `sed`:
```
sed -n '/PATTERN/,/^$/{/^$/q;p;}' file
```
Using `regex` range, you define your range from the `PATTERN` to blank line (`/^$/`). When you encounter a blank line, you quit else you keep printing.
Using `awk`:
```
awk '/PATTERN/{p=1}/^$/&&p{exit}p' file
```
You enable a flag when you encounter... | I think this is a nice, readable Perl one-liner:
```
perl -wne '$f=1 if /Pattern A/; exit if /^\s*$/; print if $f' file
```
* Set the flag `$f` when the pattern is matched
* Exit if a blank line (only whitespace between start and end of line) is found
* Print the line if the flag is set
Testing it out:
```
$ cat f... |
23,831,767 | I need to grep a file from a line containing `Pattern A` to a first empty line.
I used `awk` but I don't know how to code this empty line.
```
cat ${file} | awk '/Pattern A/,/Pattern B/'
``` | 2014/05/23 | [
"https://Stackoverflow.com/questions/23831767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3589473/"
] | Using `sed`:
```
sed -n '/PATTERN/,/^$/{/^$/q;p;}' file
```
Using `regex` range, you define your range from the `PATTERN` to blank line (`/^$/`). When you encounter a blank line, you quit else you keep printing.
Using `awk`:
```
awk '/PATTERN/{p=1}/^$/&&p{exit}p' file
```
You enable a flag when you encounter... | Never use
```
/foo/,/bar/
```
in awk unless you want to get from the first occurrence of "foo" to the last occurrence of "bar" as it makes trivial jobs marginally briefer but even slightly more interesting requirements require a complete re-write.
Just use:
```
/foo/{f=1} f{print; if (/bar/) f=0}
```
or similar ... |
41,852,069 | I have a SP that has a very complex SQL statement(s) where I need to be able to compare some column to NULL e.g.
```
...
FROM Categories
WHERE PID = @parentID
```
`@parentID` is a SP parameter which **can** be valid NULL.
`PID` (parent ID) is `uniqueidentifier` which can also be valid NULL (top level category).
I... | 2017/01/25 | [
"https://Stackoverflow.com/questions/41852069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3906993/"
] | Something like:
```
select ..
FROM Categories
WHERE PID = @parentID or (PID is null and @parentID is null)
``` | I think the `if` version is the clearest. A big issue with multiple queries, though, is that the stored procedure compiles the code when it is first run -- and it might make the wrong decision about the execution plan.
One option is to include `recompile`.
Another is to combine the queries, but in a way where each pa... |
41,852,069 | I have a SP that has a very complex SQL statement(s) where I need to be able to compare some column to NULL e.g.
```
...
FROM Categories
WHERE PID = @parentID
```
`@parentID` is a SP parameter which **can** be valid NULL.
`PID` (parent ID) is `uniqueidentifier` which can also be valid NULL (top level category).
I... | 2017/01/25 | [
"https://Stackoverflow.com/questions/41852069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3906993/"
] | Something like:
```
select ..
FROM Categories
WHERE PID = @parentID or (PID is null and @parentID is null)
``` | Here is an elegant and concise way to code this:
```
SELECT *
FROM Categories
WHERE COALESCE(PID, 'NULL-MATCH') = COALESCE(@parentID, 'NULL-MATCH')
``` |
41,852,069 | I have a SP that has a very complex SQL statement(s) where I need to be able to compare some column to NULL e.g.
```
...
FROM Categories
WHERE PID = @parentID
```
`@parentID` is a SP parameter which **can** be valid NULL.
`PID` (parent ID) is `uniqueidentifier` which can also be valid NULL (top level category).
I... | 2017/01/25 | [
"https://Stackoverflow.com/questions/41852069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3906993/"
] | I think the `if` version is the clearest. A big issue with multiple queries, though, is that the stored procedure compiles the code when it is first run -- and it might make the wrong decision about the execution plan.
One option is to include `recompile`.
Another is to combine the queries, but in a way where each pa... | Here is an elegant and concise way to code this:
```
SELECT *
FROM Categories
WHERE COALESCE(PID, 'NULL-MATCH') = COALESCE(@parentID, 'NULL-MATCH')
``` |
5,646,796 | I'm trying to exploit a buffer overflow for an assignment, and I have to access the environment variables (read one of them), but I have no clue where to look for them. I'm using gdb to inspect memory, but I just can't find the environment variables. | 2011/04/13 | [
"https://Stackoverflow.com/questions/5646796",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/49561/"
] | There's a global variable (`char **environ`) which should exist in the running executable's symbol table, if that was compiled with the `-g` option. | I hope that you have found since time.
Environment varialbes are stocked on the esp register, by example on my current exercice, I can show the environment variables with this command (starti is for break at the first instruction):
```sh
(gdb) starti
(gdb) x/50s $esp+450
``` |
73,400,644 | I'm attempting to retrieve a related value based on multiple entries made inside my database. I'm very new to **MySQL** in terms of using `JOIN`s and such and am trying to avoid involving **PHP** unnecessarily.
When I say *"retrieve nested related value"*, take the following example:
```
"Person" table "Lang... | 2022/08/18 | [
"https://Stackoverflow.com/questions/73400644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6425936/"
] | A JOIN joins records of two tables based ON some condition. E. g. you want to join the records in table "Person" with the records of table "Language", so that the value in column `language` is equal to the value in column `languageId` you can do this by giving the following FROM clause:
```
FROM Person INNER JOIN Lang... | ```sql
SELECT greeting.value
FROM person
JOIN language ON person.language = language.languageId
JOIN greeting ON language.greeting = greeting.greetingId
WHERE person.personId = ?
```
Recommendation - make relative columns names equal. I.e. not `language` and `languageId` but in both tables use the same name (for exam... |
6,244,380 | When I use
```
local socket = require("socket.core")
```
It works fine, the dll is located at "dir/socket/core.dll" but when I move the dll to say
"dir/folder/core.dll" and use
```
local socket = require("folder.core.")
```
It returns that it was found however it could not find the specific module in folder.core... | 2011/06/05 | [
"https://Stackoverflow.com/questions/6244380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/784912/"
] | If you want to `require("socket.core")`, the shared library (dll) has to have an exported function called luaopen\_socket\_core (which the LuaSocket library has). Thus, it always needs to be called as `require("socket.core")`.
If you want to move the DLL into some other folder, you have to modify [`package.cpath`](htt... | I think you just need to remove the dot at the end.
```
local socket = require("folder.core")
``` |
15,971,685 | I have a function for creating unique slug for a page title. It checks if the slug is available in the pages table then creates a unique slug by adding a '-int' accordingly. The function works fine for the first three entries eg for 'test slug' entered three time will create 'test-slug-1', 'test-slug-2' and 'test-slug-... | 2013/04/12 | [
"https://Stackoverflow.com/questions/15971685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1655932/"
] | Why don't you just create a slug and leave the rest of the job that involves indexing to MySQL. Here is a `slugify` function ( it is a slightly modified version used by Symfony framework ).
```
function slugify( $text ) {
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
$text = trim($text, '-');
$text ... | ```
$query = "SELECT * FROM $table_name WHERE $field_name LIKE '".$slug."%'";
$result = mysqli_query($db_connect, $query) or die(mysqli_error($db_connect));
//EDITED BASED ON COMMENT SUGGESTIONS
//create array of all matching slug names currently in database
$slugs = array();
while($row = $result->fetch_row()) {
... |
15,971,685 | I have a function for creating unique slug for a page title. It checks if the slug is available in the pages table then creates a unique slug by adding a '-int' accordingly. The function works fine for the first three entries eg for 'test slug' entered three time will create 'test-slug-1', 'test-slug-2' and 'test-slug-... | 2013/04/12 | [
"https://Stackoverflow.com/questions/15971685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1655932/"
] | Just use a single query to do all the heavy lifting for you...
```
$slug = preg_replace("/-$/","",preg_replace('/[^a-z0-9]+/i', "-", strtolower($title)));
$query = "SELECT COUNT(*) AS NumHits FROM $table_name WHERE $field_name LIKE '$slug%'";
$result = mysqli_query($db_connect, $query) or die(mysqli_error($db_conne... | Why don't you just create a slug and leave the rest of the job that involves indexing to MySQL. Here is a `slugify` function ( it is a slightly modified version used by Symfony framework ).
```
function slugify( $text ) {
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
$text = trim($text, '-');
$text ... |
15,971,685 | I have a function for creating unique slug for a page title. It checks if the slug is available in the pages table then creates a unique slug by adding a '-int' accordingly. The function works fine for the first three entries eg for 'test slug' entered three time will create 'test-slug-1', 'test-slug-2' and 'test-slug-... | 2013/04/12 | [
"https://Stackoverflow.com/questions/15971685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1655932/"
] | Just hit the database once, grab everything at once, chances are that's the biggest bottleneck.
```
$query = "SELECT * FROM $table_name WHERE $field_name LIKE '".$slug."%'";
```
Then put your results in an array (let's say `$slugs`)
```
//we only bother doing this if there is a conflicting slug already
if(mysqli... | For the one part I would create an object that is dealing with the part creating the slug and handling the number:
```
// generate new slug:
$slug = new NumberedSlug('Creating Unique Page Title Slugs in PHP');
echo $slug, "\n", $slug->increase(), "\n";
// read existing slug:
$slug = new NumberedSlug('creating-unique-... |
15,971,685 | I have a function for creating unique slug for a page title. It checks if the slug is available in the pages table then creates a unique slug by adding a '-int' accordingly. The function works fine for the first three entries eg for 'test slug' entered three time will create 'test-slug-1', 'test-slug-2' and 'test-slug-... | 2013/04/12 | [
"https://Stackoverflow.com/questions/15971685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1655932/"
] | You can just select slug with the biggest number and increase it with 1:
```
$query = "SELECT $field_name FROM $table_name WHERE $field_name LIKE '".$slug."-[0-9]*' ORDER BY $field_name DESC LIMIT 1";
```
`[0-9]*` in query means any count of numbers.
This query will select row with `$slug` at start and the bigest ... | For the one part I would create an object that is dealing with the part creating the slug and handling the number:
```
// generate new slug:
$slug = new NumberedSlug('Creating Unique Page Title Slugs in PHP');
echo $slug, "\n", $slug->increase(), "\n";
// read existing slug:
$slug = new NumberedSlug('creating-unique-... |
15,971,685 | I have a function for creating unique slug for a page title. It checks if the slug is available in the pages table then creates a unique slug by adding a '-int' accordingly. The function works fine for the first three entries eg for 'test slug' entered three time will create 'test-slug-1', 'test-slug-2' and 'test-slug-... | 2013/04/12 | [
"https://Stackoverflow.com/questions/15971685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1655932/"
] | I wasn't fully satisfied with the answers, so I came up with a slightly different approach.
```
(SELECT CONCAT({$slug}, '-', counter) FROM (
SELECT (@row_number:=@row_number + 1) AS counter, ev.*
FROM (
SELECT REPLACE(slug, {$slug}-, '') AS remainder
FROM products, (SELECT @row_number:=0) AS t
WHERE sl... | You could use the [Fbeen/UniqueSlugBundle](https://github.com/Fbeen/UniqueSlugBundle). This Bundle is lightweight and does what it needs to do. |
15,971,685 | I have a function for creating unique slug for a page title. It checks if the slug is available in the pages table then creates a unique slug by adding a '-int' accordingly. The function works fine for the first three entries eg for 'test slug' entered three time will create 'test-slug-1', 'test-slug-2' and 'test-slug-... | 2013/04/12 | [
"https://Stackoverflow.com/questions/15971685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1655932/"
] | You can just select slug with the biggest number and increase it with 1:
```
$query = "SELECT $field_name FROM $table_name WHERE $field_name LIKE '".$slug."-[0-9]*' ORDER BY $field_name DESC LIMIT 1";
```
`[0-9]*` in query means any count of numbers.
This query will select row with `$slug` at start and the bigest ... | I wasn't fully satisfied with the answers, so I came up with a slightly different approach.
```
(SELECT CONCAT({$slug}, '-', counter) FROM (
SELECT (@row_number:=@row_number + 1) AS counter, ev.*
FROM (
SELECT REPLACE(slug, {$slug}-, '') AS remainder
FROM products, (SELECT @row_number:=0) AS t
WHERE sl... |
15,971,685 | I have a function for creating unique slug for a page title. It checks if the slug is available in the pages table then creates a unique slug by adding a '-int' accordingly. The function works fine for the first three entries eg for 'test slug' entered three time will create 'test-slug-1', 'test-slug-2' and 'test-slug-... | 2013/04/12 | [
"https://Stackoverflow.com/questions/15971685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1655932/"
] | Why don't you just create a slug and leave the rest of the job that involves indexing to MySQL. Here is a `slugify` function ( it is a slightly modified version used by Symfony framework ).
```
function slugify( $text ) {
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
$text = trim($text, '-');
$text ... | You could use the [Fbeen/UniqueSlugBundle](https://github.com/Fbeen/UniqueSlugBundle). This Bundle is lightweight and does what it needs to do. |
15,971,685 | I have a function for creating unique slug for a page title. It checks if the slug is available in the pages table then creates a unique slug by adding a '-int' accordingly. The function works fine for the first three entries eg for 'test slug' entered three time will create 'test-slug-1', 'test-slug-2' and 'test-slug-... | 2013/04/12 | [
"https://Stackoverflow.com/questions/15971685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1655932/"
] | Just use a single query to do all the heavy lifting for you...
```
$slug = preg_replace("/-$/","",preg_replace('/[^a-z0-9]+/i', "-", strtolower($title)));
$query = "SELECT COUNT(*) AS NumHits FROM $table_name WHERE $field_name LIKE '$slug%'";
$result = mysqli_query($db_connect, $query) or die(mysqli_error($db_conne... | I wasn't fully satisfied with the answers, so I came up with a slightly different approach.
```
(SELECT CONCAT({$slug}, '-', counter) FROM (
SELECT (@row_number:=@row_number + 1) AS counter, ev.*
FROM (
SELECT REPLACE(slug, {$slug}-, '') AS remainder
FROM products, (SELECT @row_number:=0) AS t
WHERE sl... |
15,971,685 | I have a function for creating unique slug for a page title. It checks if the slug is available in the pages table then creates a unique slug by adding a '-int' accordingly. The function works fine for the first three entries eg for 'test slug' entered three time will create 'test-slug-1', 'test-slug-2' and 'test-slug-... | 2013/04/12 | [
"https://Stackoverflow.com/questions/15971685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1655932/"
] | For the one part I would create an object that is dealing with the part creating the slug and handling the number:
```
// generate new slug:
$slug = new NumberedSlug('Creating Unique Page Title Slugs in PHP');
echo $slug, "\n", $slug->increase(), "\n";
// read existing slug:
$slug = new NumberedSlug('creating-unique-... | ```
$query = "SELECT * FROM $table_name WHERE $field_name LIKE '".$slug."%'";
$result = mysqli_query($db_connect, $query) or die(mysqli_error($db_connect));
//EDITED BASED ON COMMENT SUGGESTIONS
//create array of all matching slug names currently in database
$slugs = array();
while($row = $result->fetch_row()) {
... |
15,971,685 | I have a function for creating unique slug for a page title. It checks if the slug is available in the pages table then creates a unique slug by adding a '-int' accordingly. The function works fine for the first three entries eg for 'test slug' entered three time will create 'test-slug-1', 'test-slug-2' and 'test-slug-... | 2013/04/12 | [
"https://Stackoverflow.com/questions/15971685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1655932/"
] | Just hit the database once, grab everything at once, chances are that's the biggest bottleneck.
```
$query = "SELECT * FROM $table_name WHERE $field_name LIKE '".$slug."%'";
```
Then put your results in an array (let's say `$slugs`)
```
//we only bother doing this if there is a conflicting slug already
if(mysqli... | ```
$query = "SELECT * FROM $table_name WHERE $field_name LIKE '".$slug."%'";
$result = mysqli_query($db_connect, $query) or die(mysqli_error($db_connect));
//EDITED BASED ON COMMENT SUGGESTIONS
//create array of all matching slug names currently in database
$slugs = array();
while($row = $result->fetch_row()) {
... |
16,216,057 | Im trying to delete Gridview row on button click.
i want to save the clicked row's id into a variable. And use this variable in the hyperlink.
here my RowDataBound code
```
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
... | 2013/04/25 | [
"https://Stackoverflow.com/questions/16216057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2307453/"
] | Firstly:
add a reference to jQuery to the head section of your Master page
```
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
```
Secondly:
add the ProductionOrderId to the datarow as an attribute (as shown below), this way it will be accessible on the client side via jQuery
```
... | An easier way would be to create a helper method:
```
string getLink(MyObject obj)
{
return "~/Producter/Delete?id" + obj.ID;
}
```
And in the view:
```
<asp:HyperLink runat="server" NavigateUrl="<%# getLink(Container.DataItem) %>" ID="HyperLink1"> Delete</asp:HyperLink>
``` |
16,216,057 | Im trying to delete Gridview row on button click.
i want to save the clicked row's id into a variable. And use this variable in the hyperlink.
here my RowDataBound code
```
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
... | 2013/04/25 | [
"https://Stackoverflow.com/questions/16216057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2307453/"
] | Modified the RowDataBound to hold the GridView record ids to the client side:
```
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.style.cursor='Pointer';this.style.backgroundColor... | An easier way would be to create a helper method:
```
string getLink(MyObject obj)
{
return "~/Producter/Delete?id" + obj.ID;
}
```
And in the view:
```
<asp:HyperLink runat="server" NavigateUrl="<%# getLink(Container.DataItem) %>" ID="HyperLink1"> Delete</asp:HyperLink>
``` |
16,216,057 | Im trying to delete Gridview row on button click.
i want to save the clicked row's id into a variable. And use this variable in the hyperlink.
here my RowDataBound code
```
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
... | 2013/04/25 | [
"https://Stackoverflow.com/questions/16216057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2307453/"
] | Firstly:
add a reference to jQuery to the head section of your Master page
```
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
```
Secondly:
add the ProductionOrderId to the datarow as an attribute (as shown below), this way it will be accessible on the client side via jQuery
```
... | Modified the RowDataBound to hold the GridView record ids to the client side:
```
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", "this.style.cursor='Pointer';this.style.backgroundColor... |
11,771,903 | I have tried to develop retrieving the count value from soap webservices and display them to android emulator. Here I have mentioned particular textview means it is not display on my emulator. Why this is not display on my emulator. Please help me. Which line I have to change.
This is my android code:
```
public class... | 2012/08/02 | [
"https://Stackoverflow.com/questions/11771903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1570318/"
] | Remove this line `setContentView(tv);`. I don't seem to find it correct to use two `setContentView()` here.
Because you have already called the `setContentView(R.layout.retrieve);` in the first place and you have initialized your TextView here,
```
TextView tv = (TextView) findViewById(R.id.textView1);
```
So,
``... | I don't know what `append` does.
You can write
```
String s = ""
for(int i = 0; i<resultArr.length;i++) {
s += resultArr[i]+"\n\n";
}
tv.setText(s)
```
Better use `StringBuilder` but above should work |
463,988 | Why the entropy change is not zero in the irreversible adiabatic process?
...while it is defined as the integral of the heat added to the system over its temperature. | 2019/03/02 | [
"https://physics.stackexchange.com/questions/463988",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/224282/"
] | Although entropy change is defined in terms of a reversible differential transfer of heat divided by the temperature at which the heat is transferred, you can have entropy change without heat transfer. Since entropy is a state function independent of the path between states, you can calculate it by assuming any reversi... | The statement
$$
dS = \frac{\delta Q}{T}
$$
is only true of reversible processes. The generally true statement is
$$
dS \ge \frac{\delta Q}{T}.
$$
For an adiabatic process, $\delta Q = 0$, but that still allows for $dS > 0$. |
463,988 | Why the entropy change is not zero in the irreversible adiabatic process?
...while it is defined as the integral of the heat added to the system over its temperature. | 2019/03/02 | [
"https://physics.stackexchange.com/questions/463988",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/224282/"
] | Although entropy change is defined in terms of a reversible differential transfer of heat divided by the temperature at which the heat is transferred, you can have entropy change without heat transfer. Since entropy is a state function independent of the path between states, you can calculate it by assuming any reversi... | If you have an irreversible adiabatic process between two thermodynamic equilibrium end states of a system, there exists no possible reversible adiabatic process between these same two end states. So to get the entropy change for the irreversible adiabatic process, you need to devise an alternative reversible path betw... |
463,988 | Why the entropy change is not zero in the irreversible adiabatic process?
...while it is defined as the integral of the heat added to the system over its temperature. | 2019/03/02 | [
"https://physics.stackexchange.com/questions/463988",
"https://physics.stackexchange.com",
"https://physics.stackexchange.com/users/224282/"
] | If you have an irreversible adiabatic process between two thermodynamic equilibrium end states of a system, there exists no possible reversible adiabatic process between these same two end states. So to get the entropy change for the irreversible adiabatic process, you need to devise an alternative reversible path betw... | The statement
$$
dS = \frac{\delta Q}{T}
$$
is only true of reversible processes. The generally true statement is
$$
dS \ge \frac{\delta Q}{T}.
$$
For an adiabatic process, $\delta Q = 0$, but that still allows for $dS > 0$. |
2,596,731 | If i have $f:\mathbb{R}\to \mathbb{R}$ and i know $f\circ f$ is differentiable then does that mean that $f\circ f\circ f$ is differentiable ?
I can't tell if i need to counter this or prove.
And if i have to counter then what kind of counter? | 2018/01/08 | [
"https://math.stackexchange.com/questions/2596731",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/518004/"
] | No : take $f$ to be an involution (i.e. $f\circ f(x)=x$) that is not differentiable. An example of such a function is
$$
f(x)=\begin{cases}
1 &\text{if $x=-1$} \\
-1 &\text{if $x=1$} \\
x &\text{otherwise} \\
\end{cases}.
$$
Notice how this function is not even continuous. | No. Take for example the function:
$${f(x) =
\begin{cases}
\frac{1}{x} &\text{if } x \neq 0 \\
0 &\text{if } x = 0
\end{cases}}$$
The function $f \circ f$ is continuous and differentiable , but $f \circ f\circ f$ isn't. |
218,576 | Let's say i have a directory, at:
* `/tmp/uploads/`
And inside got several recursive directories and files created by DIFFERENT USERS before.
So now, suddenly how do i make that above directory to be **writable by root only**?
Which means, the existing whatever users won't be suddenly able to write at all (but rea... | 2015/07/27 | [
"https://unix.stackexchange.com/questions/218576",
"https://unix.stackexchange.com",
"https://unix.stackexchange.com/users/34722/"
] | Use attributes:
```
chattr -R +i files
```
(as root) will add the `+i` attribute recursively to your folders and files which will prevent ANY alternations. Note that root will also be locked and you would need to unset the `i` manually every time. Ownership and alike will be left unchanged. | First change user and group to root
`chown -R root:root /tmp/uploads`
then change permissions so that only root can write
`chmod -R 755 /tmp/uploads`
EDIT:
If you only need to restore files owners, I would save your files and owner in a file (There sure are better ways to do this, but this is the first thing tha... |
51,385,911 | I'm trying to emit custom events from my custom object like so:
```
var CustomObject = function () {
this.customEvent = new Event('afterInit')
/* init code goes here*/
this.dispatchEvent(this.customEvent)
}
```
But my object cannot dispatch (i.e. dispatchEvent is not a property of my object) and I cannot... | 2018/07/17 | [
"https://Stackoverflow.com/questions/51385911",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10094791/"
] | Recently, [EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/EventTarget) got a constructor, so you can actually use it for your JS object – before it was just an interface used only by DOM elements:
```
class CustomObject extends EventTarget {
constructor() {
super();
this.customEven... | Objects do not have events. You have to implement that functionality on your own, then you can create new objects that inherit that using the `class` syntax:
```
const handlers = Symbol.for("handlers");
class EventEmitter {
constructor(...args) {
super(...args);
this[handlers] = new Map;
}
on(na... |
35,753,802 | I'm working in Java and I want to put in situation about the thing that I need to do.
I have an integer (for example: 4) and I need to do an array of that number of dimmensions.
If it's 1... it's easy because I can write
```
int[] v1 = new int[X];
```
in this case X doesn't matter...
but the problem is when I hav... | 2016/03/02 | [
"https://Stackoverflow.com/questions/35753802",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3505952/"
] | I just tested this. And it works like charm.
```
'use strict'
function foo () {
return 'foo';
}
exports.foo = foo;
function bar () {
return exports.foo(); // <--- notice
}
exports.bar = bar;
```
>
> Explanation
>
>
>
when you do `sinon.stub(myModule, 'foo').returns('foo2')` then `sinon` stubs the `expor... | I was a bit wary of using `exports` since it's a bit magical (for instance when you're coding in Typescript, you never use it directly), so I'd like to propose an alternate solution, which still requires modifying the source code unfortunately, and which is simply to wrap the function to be stubbed into an object:
```... |
28,071,664 | i.e. user inputs NAME (all in capital) and the code will print out NnAaMmEe.
i want to use the function argv and args. this is the code so far
```
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main(){
int i;
int count;
char str [100];
clrscr();
printf("Enter a string");
sca... | 2015/01/21 | [
"https://Stackoverflow.com/questions/28071664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4183388/"
] | Your code is incorrect in several ways:
* Since you want to use `argc` and `argv`, you need to add them as parameters of `main`, and remove the call of `scanf`
* You do not need nested loops for this - only one loop is sufficient
* If you take length of string with `strlen`, your loop should go from 0 to `len-1`, i.e.... | Modify your program as below, You can obtain the output as you expected. The ascii range of capital letters is from 65 to 90 and for small letters it is 97 to 122.
```
#include <stdio.h>
#include <string.h>
void main(){
int i;
int count;
char str [100];
printf("Enter a string");
scanf("%s", str);
count = strlen(st... |
28,071,664 | i.e. user inputs NAME (all in capital) and the code will print out NnAaMmEe.
i want to use the function argv and args. this is the code so far
```
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main(){
int i;
int count;
char str [100];
clrscr();
printf("Enter a string");
sca... | 2015/01/21 | [
"https://Stackoverflow.com/questions/28071664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4183388/"
] | Your code is incorrect in several ways:
* Since you want to use `argc` and `argv`, you need to add them as parameters of `main`, and remove the call of `scanf`
* You do not need nested loops for this - only one loop is sufficient
* If you take length of string with `strlen`, your loop should go from 0 to `len-1`, i.e.... | You can use the `toupper` and `tolower` functions for converting the values into lower and upper. Use another array to store that values.
In loop,
```
for ( i=0 , j=0 ; i < len ; i++) {
if ( isupper ( str[ i]) ) {
str1 [j++]= str [i] ;
str1 [j++]=tolower(str[i]);
}
else if ( is... |
48,265,852 | I've developed a python script on a Windows machine where at a point it calls another python script with some aruguments aswell.
script.py
=========
```
value="bar"
id="foo"
os.system('"Main.py" %s %s' % (eqid, value))
```
main.py
=======
```
name=sys.argv[1]
send=sys.argv[2]
```
This code works perfectly on W... | 2018/01/15 | [
"https://Stackoverflow.com/questions/48265852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8742209/"
] | You need to tell Linux how to run Main.py i.e. specify `'python "Main.py"'` (this isn't needed on Windows if python is set as the default program to use to open .py files, but it should still work fine to specify it on Windows regardless)
e.g.
```
~ $ cat Main.py
import sys
name=sys.argv[1]
send=sys.argv[2]
print nam... | linux probably doesn't have current dir in it's default path (security issue in case someone codes a malicious `ls` which is executed when you try to know what's in the directory).
So if the .py has the proper shebang you can do:
```
os.system('"./Main.py" %s %s' % (eqid, value))
```
but:
* consider importing the ... |
7,769,580 | I have an x86 and x64 version of a binary that I want to upload to NuGet. What's the recommendation or required method for creating/uploading that package? I can't [find much](http://nuget.org/List/Search?packageType=Packages&searchCategory=All%20Categories&searchTerm=64&sortOrder=package-download-count&pageSize=10) to... | 2011/10/14 | [
"https://Stackoverflow.com/questions/7769580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3619/"
] | We've been [discussing](https://groups.google.com/forum/#!topic/chocolatey/WS32DM6PV8E) a similar issue on the [Chocolatey Google Group](https://groups.google.com/forum/#!forum/chocolatey). There aren't any semantics built into NuGet. The requirement wouldn't be, *what processor architecture are you running on*. It wou... | There doesn't seem to be a specific target for 32 or 64 bit architectures. Bit of a pain, but can you do something with the powershell scripts (install.ps1) to detect the architecture and install accordingly?
See Automatically Running PowerShell Scripts During Package Installation and Removal - <http://docs.nuget.org/... |
7,769,580 | I have an x86 and x64 version of a binary that I want to upload to NuGet. What's the recommendation or required method for creating/uploading that package? I can't [find much](http://nuget.org/List/Search?packageType=Packages&searchCategory=All%20Categories&searchTerm=64&sortOrder=package-download-count&pageSize=10) to... | 2011/10/14 | [
"https://Stackoverflow.com/questions/7769580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3619/"
] | You can add x64 and x86 support to a project by using conditional references. It would appear that for now Nuget does not like having two references with the same name. So we need to add in the second reference manually and then make the references conditional.
Save x64 assemblies in a folder called x64 & x86 assembli... | There doesn't seem to be a specific target for 32 or 64 bit architectures. Bit of a pain, but can you do something with the powershell scripts (install.ps1) to detect the architecture and install accordingly?
See Automatically Running PowerShell Scripts During Package Installation and Removal - <http://docs.nuget.org/... |
7,769,580 | I have an x86 and x64 version of a binary that I want to upload to NuGet. What's the recommendation or required method for creating/uploading that package? I can't [find much](http://nuget.org/List/Search?packageType=Packages&searchCategory=All%20Categories&searchTerm=64&sortOrder=package-download-count&pageSize=10) to... | 2011/10/14 | [
"https://Stackoverflow.com/questions/7769580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3619/"
] | We've been [discussing](https://groups.google.com/forum/#!topic/chocolatey/WS32DM6PV8E) a similar issue on the [Chocolatey Google Group](https://groups.google.com/forum/#!forum/chocolatey). There aren't any semantics built into NuGet. The requirement wouldn't be, *what processor architecture are you running on*. It wou... | You can add x64 and x86 support to a project by using conditional references. It would appear that for now Nuget does not like having two references with the same name. So we need to add in the second reference manually and then make the references conditional.
Save x64 assemblies in a folder called x64 & x86 assembli... |
293,856 | In Support Vector Machine, why is it a quadratic programming problem instead of a linear programming problem to obtain the optimal separating hyperplane. I only find, in book references, that the author choose the quadratic, my question is why???? | 2017/07/22 | [
"https://stats.stackexchange.com/questions/293856",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/170819/"
] | Because the optimal separating hyperplane between classes of data
\begin{equation}
D(\mathbf{x})=\mathbf{w}^T\mathbf{x} + b = c \quad \quad -1 < c < 1,
\end{equation}
is found by minimizing the objective function
\begin{equation}
\begin{split}
Q(\mathbf{w})&=\frac{1}{2} ||\mathbf{w}||^2\\
\mathrm{w.r.t } & \quad y\_... | This has nothing to do with the L1 norm. Both are the Euclidean norm. Conversion to QP is due to practical reasons so that the gradient is continuous at the origin.
See <https://math.stackexchange.com/a/439168/532462> |
293,856 | In Support Vector Machine, why is it a quadratic programming problem instead of a linear programming problem to obtain the optimal separating hyperplane. I only find, in book references, that the author choose the quadratic, my question is why???? | 2017/07/22 | [
"https://stats.stackexchange.com/questions/293856",
"https://stats.stackexchange.com",
"https://stats.stackexchange.com/users/170819/"
] | In order to find an optimal separating hyperplane, the norm of the weight vector $||\overline{w}||$ should be minimized, subject to constraints $y\_i(\overline{w} \cdot \varphi(x\_i) + b) ≥ 1 − \xi\_i$, $\xi\_i \geqslant 0, i=1,\dots, l$ (see [here](https://www.csie.ntu.edu.tw/~cjlin/papers/guide/guide.pdf)).
While it... | This has nothing to do with the L1 norm. Both are the Euclidean norm. Conversion to QP is due to practical reasons so that the gradient is continuous at the origin.
See <https://math.stackexchange.com/a/439168/532462> |
117,290 | When building a plugin, I know that you can hook into a function to run some code like
```
add_action('admin_footer', array($this, 'custom_function'));
```
And within that function, test for post\_type like so:
```
public function custom_function() {
$screen = get_current_screen();
if (self:... | 2013/10/09 | [
"https://wordpress.stackexchange.com/questions/117290",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29049/"
] | Using OOP PHP, add your initializer actions in the `__construct` and create appropriate methods for handling them. From your handler you can initialize any class variable (once) you want and reference it later without having to do any further checks. Here is an example:
```
class my_plugin {
private $post_type;
... | ```
add_Action('init','call_it_to_hook');
function call_it_to_hook() {
global $post;
if($post->post_type == 'custom_post_type') {
add_Action('hook name', 'callback_function');
}
}
callback_function() {
echo "hey";
// thats my place , can do whatever i want here
}
``` |
31,996,036 | What I try to get to work are different MySQL Queries in one Sub, which should fill different ranges in one table.
Here is what I have got so far:
With the Function "ConnectionDB" I want to connect to the remote Database. In the Sub "QueryDatabase" I open the connection and execute two Sql-queries. The first Sql-qu... | 2015/08/13 | [
"https://Stackoverflow.com/questions/31996036",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5224395/"
] | an old thread but i think the current behaviour is a bug, because the following works, and so it should work in a composite component:
**component.xhtml:**
```
<?xml version='1.0' encoding='UTF-8' ?>
<ui:component
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:cc="http://xmlns.jcp.... | I'm doing the same thing, except I'm inserting a PrimeFaces' p:commandButton via the facet - the button works, the only problem are the warnings, so I'm providing a solution for those.
Add a componentType:
```
<cc:interface componentType="myComponent">
```
And a corresponing java class:
```
import javax.faces.comp... |
19,717 | How can I query the question database? For example, at this moment I would like to see the questions with 0 answers for the tag elementary-number-theory. Is there a query syntax? Are there more query possibilities when I use the API to this site? | 2015/02/21 | [
"https://math.meta.stackexchange.com/questions/19717",
"https://math.meta.stackexchange.com",
"https://math.meta.stackexchange.com/users/11210/"
] | You don't really need to check the database per se (which I interpret to mean either the [SEDE](http://data.stackexchange.com/), or the public data dumps). The search options available on the main site should be sufficient.
* `[elementary-number-theory]` will return posts tagged [elementary-number-theory](https://math... | You can type the tag `[elementary-number-theory]` and click "unanswered" (directly below "ASK QUESTION") in order to see the unanswered questions for the tag. However, the results are then automatically sorted by vote count, from highest to lowest.
You're probably better off clicking "newest" (below and between "TAGS"... |
14,260 | "to pull it off" was at one time used meaning "to win."
And in sentences such as,
>
> I don't think you can pull it off.
>
>
>
, it often implies the idea of "success."
But how did this expression originate? | 2011/02/26 | [
"https://english.stackexchange.com/questions/14260",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/4988/"
] | Eric Partridge, in his *A Dictionary of Slang and Unconventional English*, says this comes from late 19th century sporting jargon meaning "to win". He cites two OED references, one from 1870 and the other from 1887. | I have not been able to find any explanation of the origin of the phrase "pull [something] off" beyond the sketchy one that Robusto cites in his answer. For completeness, I give the full entry from Eric Partridge, *A Dictionary of Slang and Unconventional English*, second edition (1938):
>
> **pull off.** To obtain (... |
14,260 | "to pull it off" was at one time used meaning "to win."
And in sentences such as,
>
> I don't think you can pull it off.
>
>
>
, it often implies the idea of "success."
But how did this expression originate? | 2011/02/26 | [
"https://english.stackexchange.com/questions/14260",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/4988/"
] | I found some slightly earlier uses than the *OED*'s 1870. All are from the UK. The majority are from magazines. Nine are about horse-racing, two about rowing, and one each for football and coursing, and one using an analogy of being a good player, and the last about being lucky in general.
From the citations below, it... | I have not been able to find any explanation of the origin of the phrase "pull [something] off" beyond the sketchy one that Robusto cites in his answer. For completeness, I give the full entry from Eric Partridge, *A Dictionary of Slang and Unconventional English*, second edition (1938):
>
> **pull off.** To obtain (... |
14,260 | "to pull it off" was at one time used meaning "to win."
And in sentences such as,
>
> I don't think you can pull it off.
>
>
>
, it often implies the idea of "success."
But how did this expression originate? | 2011/02/26 | [
"https://english.stackexchange.com/questions/14260",
"https://english.stackexchange.com",
"https://english.stackexchange.com/users/4988/"
] | Two immediate lexical progenitors produced transitive use of the colloquial phrasal verb 'to pull off' in the sense of
>
> **2.** *trans. colloq.* To succeed in accomplishing, achieving, or producing (something); to carry off.
>
>
> [*OED*](http://oed.com/), 'to pull off'
>
>
>
Those two progenitors were uses... | I have not been able to find any explanation of the origin of the phrase "pull [something] off" beyond the sketchy one that Robusto cites in his answer. For completeness, I give the full entry from Eric Partridge, *A Dictionary of Slang and Unconventional English*, second edition (1938):
>
> **pull off.** To obtain (... |
345,616 | Background
==========
Protection, Fire Protection, Blast Protection, and Projectile Protection are all mutually exclusive enchantments in survival Minecraft. I just need some clarification of some comments in the official wiki to understand what happens when these are mixed and matched in multiple pieces of armor.
Co... | 2019/01/26 | [
"https://gaming.stackexchange.com/questions/345616",
"https://gaming.stackexchange.com",
"https://gaming.stackexchange.com/users/119924/"
] | The test
--------
I hit my friend with different weapons, who is equipped with full diamond armor, but with different enchantment combinations. (e.g. Only Helmet is enchanted; Helmet and Chestplate; Only Leggings; etc.) I also wrote a tiny plugin that outputs the raw, adjusted damage received by a person and conducted... | No, all enchanted books do not stack. |
2,145,373 | or the reverse, where a repeating expansion in a variable base to be rational?
been trying some trial and error cases without success
by variable base we mean each digit can be in a different base but any digit can occur as many times in the same base or not
Just in case anybody tries to pull a fast one no base $\sqr... | 2017/02/15 | [
"https://math.stackexchange.com/questions/2145373",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/3936/"
] | Consider $.1141144114441144441144444\dots$, where the 1s are in base 3, and the 4s are in base 9. The expansion is nonrepeating, but it represents $${1\over3}+{1\over9}+{4\over9^2}+{1\over3\cdot9^2}+{1\over9^3}+{4\over9^4}+{4\over9^5}+\cdots$$ which is $${4\over9}+{4\over9^2}+{4\over9^3}+{4\over9^4}+{4\over9^5}+\cdots=... | This is more a comment than an answet.
If the expansion is of the form
$x=\sum\_{k=0}^{\infty} d\_k/B\_k$
where $B\_{k+1} >B\_k$
and $0\le d\_k < B\_{k+1}/B\_k$
(the standard decimal system
has $B\_k=10^k$)
then the representation is unique
if and only if
$B\_{k+1}/B\_k$
is an integer for all $k$.
In the factorial sy... |
2,145,373 | or the reverse, where a repeating expansion in a variable base to be rational?
been trying some trial and error cases without success
by variable base we mean each digit can be in a different base but any digit can occur as many times in the same base or not
Just in case anybody tries to pull a fast one no base $\sqr... | 2017/02/15 | [
"https://math.stackexchange.com/questions/2145373",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/3936/"
] | This is more a comment than an answet.
If the expansion is of the form
$x=\sum\_{k=0}^{\infty} d\_k/B\_k$
where $B\_{k+1} >B\_k$
and $0\le d\_k < B\_{k+1}/B\_k$
(the standard decimal system
has $B\_k=10^k$)
then the representation is unique
if and only if
$B\_{k+1}/B\_k$
is an integer for all $k$.
In the factorial sy... | Using bases $\,3,3^2,3^3,3^4,\ldots\,$ with corresponding digits $\,1,2,3,4,\ldots\;$ yields
$${\large{\sum\_{n=1}^\infty \frac{n}{3^n}}} = \frac{3}{4}$$ |
2,145,373 | or the reverse, where a repeating expansion in a variable base to be rational?
been trying some trial and error cases without success
by variable base we mean each digit can be in a different base but any digit can occur as many times in the same base or not
Just in case anybody tries to pull a fast one no base $\sqr... | 2017/02/15 | [
"https://math.stackexchange.com/questions/2145373",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/3936/"
] | Consider $.1141144114441144441144444\dots$, where the 1s are in base 3, and the 4s are in base 9. The expansion is nonrepeating, but it represents $${1\over3}+{1\over9}+{4\over9^2}+{1\over3\cdot9^2}+{1\over9^3}+{4\over9^4}+{4\over9^5}+\cdots$$ which is $${4\over9}+{4\over9^2}+{4\over9^3}+{4\over9^4}+{4\over9^5}+\cdots=... | Using bases $\,3,3^2,3^3,3^4,\ldots\,$ with corresponding digits $\,1,2,3,4,\ldots\;$ yields
$${\large{\sum\_{n=1}^\infty \frac{n}{3^n}}} = \frac{3}{4}$$ |
12,313,258 | I am using CMake to build my system and my unit tests.
I am also doing an out-of-source build.
I've found with the ADD\_TEST() command, that you don't need to install the test executable (it will just be run when you run make install, which is great).
However, my unit tests depend on some input files, which need to... | 2012/09/07 | [
"https://Stackoverflow.com/questions/12313258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/920842/"
] | You may use **configure\_file** with parameter **COPYONLY**. And perform copying to your build dir: ${CMAKE\_CURRENT\_BINARY\_DIR} | Sure, you can do this on the configuration step this way:
```
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${fileFrom} ${fileTo})
```
If your input files depend on something produced by build, you can create a target for it and add it to the `all` target:
```
add_custom_target(copy_my_files ALL
... |
12,313,258 | I am using CMake to build my system and my unit tests.
I am also doing an out-of-source build.
I've found with the ADD\_TEST() command, that you don't need to install the test executable (it will just be run when you run make install, which is great).
However, my unit tests depend on some input files, which need to... | 2012/09/07 | [
"https://Stackoverflow.com/questions/12313258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/920842/"
] | This may not be the best solution, but currently I am doing this:
```
file(COPY my_directory DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
```
Which seems to be doing the trick. | Sure, you can do this on the configuration step this way:
```
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${fileFrom} ${fileTo})
```
If your input files depend on something produced by build, you can create a target for it and add it to the `all` target:
```
add_custom_target(copy_my_files ALL
... |
12,313,258 | I am using CMake to build my system and my unit tests.
I am also doing an out-of-source build.
I've found with the ADD\_TEST() command, that you don't need to install the test executable (it will just be run when you run make install, which is great).
However, my unit tests depend on some input files, which need to... | 2012/09/07 | [
"https://Stackoverflow.com/questions/12313258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/920842/"
] | The question is quite old, but in my opinion there is a better solution to the problem than copying the files you need to `${CMAKE_CURRENT_BINARY_DIR})`. The `add_test` command has a `WORKING_DIRECTORY` option that allows to chose the directory where the tests are run. So I would suggest the following solution:
```
ad... | Sure, you can do this on the configuration step this way:
```
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${fileFrom} ${fileTo})
```
If your input files depend on something produced by build, you can create a target for it and add it to the `all` target:
```
add_custom_target(copy_my_files ALL
... |
12,313,258 | I am using CMake to build my system and my unit tests.
I am also doing an out-of-source build.
I've found with the ADD\_TEST() command, that you don't need to install the test executable (it will just be run when you run make install, which is great).
However, my unit tests depend on some input files, which need to... | 2012/09/07 | [
"https://Stackoverflow.com/questions/12313258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/920842/"
] | You may use **configure\_file** with parameter **COPYONLY**. And perform copying to your build dir: ${CMAKE\_CURRENT\_BINARY\_DIR} | To copy a whole directory at build time (and only if the build succeeds) you can do this after you added your target (e. g. unit test executable):
```
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/testDataDir $<TARGET_FILE_DIR:${PROJ... |
12,313,258 | I am using CMake to build my system and my unit tests.
I am also doing an out-of-source build.
I've found with the ADD\_TEST() command, that you don't need to install the test executable (it will just be run when you run make install, which is great).
However, my unit tests depend on some input files, which need to... | 2012/09/07 | [
"https://Stackoverflow.com/questions/12313258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/920842/"
] | This may not be the best solution, but currently I am doing this:
```
file(COPY my_directory DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
```
Which seems to be doing the trick. | To copy a whole directory at build time (and only if the build succeeds) you can do this after you added your target (e. g. unit test executable):
```
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/testDataDir $<TARGET_FILE_DIR:${PROJ... |
12,313,258 | I am using CMake to build my system and my unit tests.
I am also doing an out-of-source build.
I've found with the ADD\_TEST() command, that you don't need to install the test executable (it will just be run when you run make install, which is great).
However, my unit tests depend on some input files, which need to... | 2012/09/07 | [
"https://Stackoverflow.com/questions/12313258",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/920842/"
] | The question is quite old, but in my opinion there is a better solution to the problem than copying the files you need to `${CMAKE_CURRENT_BINARY_DIR})`. The `add_test` command has a `WORKING_DIRECTORY` option that allows to chose the directory where the tests are run. So I would suggest the following solution:
```
ad... | To copy a whole directory at build time (and only if the build succeeds) you can do this after you added your target (e. g. unit test executable):
```
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/testDataDir $<TARGET_FILE_DIR:${PROJ... |
24,202,323 | I am trying to make a plugin which lists all users from a database with for each user a button to send an email to them. So the only way I can get with their username their email adress is to use the $POST which is given after the button is clicked. With their username I can search the db table to retreive the email. T... | 2014/06/13 | [
"https://Stackoverflow.com/questions/24202323",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1980391/"
] | Without using `typedef` or `using` then it's not possible to access to the container's type. However you can specialize the `bar` function where you know what the container's type is.
```
template<> void bar<Parent::Inner>()
{
// Here, you know what the parent is
}
``` | With a simple `using`:
```
struct Parent
{
struct Inner
{
using parent_type = Parent;
};
};
template<class T>
void bar()
{
//here I would like to get T's parent type
typename T::parent_type t;
}
```
Also note that `bar<Inner>();` is ill-formed. You need
```
bar<Parent::Inner>();
``` |
30,543,567 | Why J2EE why not J7EE or J8EE . We got latest version as Java 8. But, why still, it is being Java Platform 2 ? What is a significance of "2" here ? Or It looks good, that's why they never changed its name or some other reason ? | 2015/05/30 | [
"https://Stackoverflow.com/questions/30543567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1162620/"
] | Java enterprise edition was introduced around the time of Java 2 (which was rebranded from Java 1.2). As part of the branding they included the numeral (originally). Now it is officially [Java EE](http://docs.oracle.com/javaee/7/index.html) (withtout the numeral 2). | Current java is known as Java 2 Platform.
Originally there was JDK1.0 and JDK1.1. They are not compatible to current Java platform. With release of JDK1.2, Java 2 Platform have been born.
>
> Release 1.4 of the Java 2 Platform, Standard Edition (J2SE) represents an advance from J2SE 1.3
>
>
>
[More On](http://ww... |
30,543,567 | Why J2EE why not J7EE or J8EE . We got latest version as Java 8. But, why still, it is being Java Platform 2 ? What is a significance of "2" here ? Or It looks good, that's why they never changed its name or some other reason ? | 2015/05/30 | [
"https://Stackoverflow.com/questions/30543567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1162620/"
] | Java enterprise edition was introduced around the time of Java 2 (which was rebranded from Java 1.2). As part of the branding they included the numeral (originally). Now it is officially [Java EE](http://docs.oracle.com/javaee/7/index.html) (withtout the numeral 2). | There is a good explanation of that in the link below :
[[Java EE vs J2EE vs Jakarta EE]](https://www.baeldung.com/java-enterprise-evolution)
***For J2EE :***
In the first version of Java, Java enterprise extensions were simply a part of the core JDK.
Then, as part of Java 2 in 1999, these extensions were broken out... |
30,543,567 | Why J2EE why not J7EE or J8EE . We got latest version as Java 8. But, why still, it is being Java Platform 2 ? What is a significance of "2" here ? Or It looks good, that's why they never changed its name or some other reason ? | 2015/05/30 | [
"https://Stackoverflow.com/questions/30543567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1162620/"
] | Check the [Version History of Java EE in Wikipedia's content on Java Platform, Enterprise Edition](http://en.wikipedia.org/wiki/Java_Platform,_Enterprise_Edition#Version_history) :-
>
> The platform **was** known as *Java 2 Platform, Enterprise Edition or J2EE*
> until the name was changed to **Java Platform, Enterp... | Current java is known as Java 2 Platform.
Originally there was JDK1.0 and JDK1.1. They are not compatible to current Java platform. With release of JDK1.2, Java 2 Platform have been born.
>
> Release 1.4 of the Java 2 Platform, Standard Edition (J2SE) represents an advance from J2SE 1.3
>
>
>
[More On](http://ww... |
30,543,567 | Why J2EE why not J7EE or J8EE . We got latest version as Java 8. But, why still, it is being Java Platform 2 ? What is a significance of "2" here ? Or It looks good, that's why they never changed its name or some other reason ? | 2015/05/30 | [
"https://Stackoverflow.com/questions/30543567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1162620/"
] | Check the [Version History of Java EE in Wikipedia's content on Java Platform, Enterprise Edition](http://en.wikipedia.org/wiki/Java_Platform,_Enterprise_Edition#Version_history) :-
>
> The platform **was** known as *Java 2 Platform, Enterprise Edition or J2EE*
> until the name was changed to **Java Platform, Enterp... | There is a good explanation of that in the link below :
[[Java EE vs J2EE vs Jakarta EE]](https://www.baeldung.com/java-enterprise-evolution)
***For J2EE :***
In the first version of Java, Java enterprise extensions were simply a part of the core JDK.
Then, as part of Java 2 in 1999, these extensions were broken out... |
30,543,567 | Why J2EE why not J7EE or J8EE . We got latest version as Java 8. But, why still, it is being Java Platform 2 ? What is a significance of "2" here ? Or It looks good, that's why they never changed its name or some other reason ? | 2015/05/30 | [
"https://Stackoverflow.com/questions/30543567",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1162620/"
] | There is a good explanation of that in the link below :
[[Java EE vs J2EE vs Jakarta EE]](https://www.baeldung.com/java-enterprise-evolution)
***For J2EE :***
In the first version of Java, Java enterprise extensions were simply a part of the core JDK.
Then, as part of Java 2 in 1999, these extensions were broken out... | Current java is known as Java 2 Platform.
Originally there was JDK1.0 and JDK1.1. They are not compatible to current Java platform. With release of JDK1.2, Java 2 Platform have been born.
>
> Release 1.4 of the Java 2 Platform, Standard Edition (J2SE) represents an advance from J2SE 1.3
>
>
>
[More On](http://ww... |
8,933,503 | I am making a blackberry application I need to share a common variable in my application between different entry points. The variable is a simple count which keeps track of the amount of notifications on the icon home screen. Every time the scheduled background application updates it will increment the count variable w... | 2012/01/19 | [
"https://Stackoverflow.com/questions/8933503",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152440/"
] | Two things, first you should stop the influx of potentially in-valid email addresses by implementing a 'closed-loop' email verification system. Basically, when a user signs up for your site, you send an email with a link confirming their email address, and when they confirm, their account gets full access to your site.... | The only way to check if an e-mail address is expired or not is to send an e-mail message to it and see if you get a response. But note that doing so may be considered spamming, since it is an unsolicited message.
You can check if an e-mail address if properly formed, and if the mail server it specifies actually exist... |
65,734,671 | Well, as in the question, how to properly use the '<' in xsl, the one that is placed is '& lt', but even so I can't get it to work, what I try to do is that the songs that last less than 5 min are shown per screen but I can't quite make it work:
Here I attach the xml and xsd code
xml:
```
<?xml version="1.0"?>
<?xm... | 2021/01/15 | [
"https://Stackoverflow.com/questions/65734671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] | Try this one:
```py
print(hex(byte[0]))
``` | Using an `f-string` like this just prints two hex digits for each byte:
```py
print(f'{byte[0]:02x}')
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.