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 |
|---|---|---|---|---|---|
144,865 | This is an incentive for new users to put some thought and effort into learning how the site works and how to be productive, before posting their first question.
There should be three badges for this, and a page describing the badges and how to get them should be prominently featured when a new user logs in for the fi... | 2012/08/25 | [
"https://meta.stackexchange.com/questions/144865",
"https://meta.stackexchange.com",
"https://meta.stackexchange.com/users/-1/"
] | I think this idea has a fundamental flaw: new users who start participating by asking questions don't care about badges. They care only to have their questions answered. Badges only come later, once they start playing the game. If they ever do (not everyone does).
How do i parse html in java script in my android with ... | I think this complements [Select from list of reasons when performing downvotes](https://meta.stackexchange.com/q/144851/182513). The idea is encouraging new users to become productive without remarks that might seems snarky to a new user saying "Go read this" or seeing feedback that effectively says "you are asking ba... |
55,647,038 | We have an Angular application which has two languages. The default is German and the other one is English. We are using `ngx-translate` as the `translateService`.
**When you refresh the browser, the application switches back to the default language.**
The `switchLang()` function gets called in our navigation bar:
`... | 2019/04/12 | [
"https://Stackoverflow.com/questions/55647038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9327050/"
] | This is the right behavior. You can use localStorage (or other place) to store the selected language. | Angular service lives entirely in memory. If you want to add a persistence you should save current value to the localStorage on a language change or save this setting to the server |
55,647,038 | We have an Angular application which has two languages. The default is German and the other one is English. We are using `ngx-translate` as the `translateService`.
**When you refresh the browser, the application switches back to the default language.**
The `switchLang()` function gets called in our navigation bar:
`... | 2019/04/12 | [
"https://Stackoverflow.com/questions/55647038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9327050/"
] | This is the right behavior. You can use localStorage (or other place) to store the selected language. | You can use localStorage to store the value in device memory, the following is an example
```
// function select language
selectLanguage(i: number) {
this.lag = this.languages[i];
this.translateService.use(this.languages[i].title.toLowerCase());
localStorage.setItem("language",this.languages[i].title.to... |
55,647,038 | We have an Angular application which has two languages. The default is German and the other one is English. We are using `ngx-translate` as the `translateService`.
**When you refresh the browser, the application switches back to the default language.**
The `switchLang()` function gets called in our navigation bar:
`... | 2019/04/12 | [
"https://Stackoverflow.com/questions/55647038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9327050/"
] | You can use localStorage to store the value in device memory, the following is an example
```
// function select language
selectLanguage(i: number) {
this.lag = this.languages[i];
this.translateService.use(this.languages[i].title.toLowerCase());
localStorage.setItem("language",this.languages[i].title.to... | Angular service lives entirely in memory. If you want to add a persistence you should save current value to the localStorage on a language change or save this setting to the server |
56,276,141 | I'm setting up a device to advertise as a server (peripheral) and a mobile phone to act as the client (central). My issue is: when my central 'reads' from the peripheral, how many packets can the peripheral respond with for a single request?
What I have seen so far is that the peripheral may respond with a 20 byte pac... | 2019/05/23 | [
"https://Stackoverflow.com/questions/56276141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11544982/"
] | Something like :
```
select person_id from vehicle
group by person_id
having
count(case when has_gps then 1 end ) > 0
and
count(case when has_ac then 1 end ) > 0
and
count(*) > 1
```
? | Using `GROUP BY` with `HAVING` give the expected result:
```
SELECT person_id
FROM vehicle
WHERE has_gps = true OR has_ac = true
GROUP BY person_id
HAVING COUNT(*) > 1
```
[Demo on db<>fiddle](https://dbfiddle.uk/?rdbms=postgres_11&fiddle=d1eaf4c12fabc4eb333e2881ece9104a) |
50,413 | I am moving to UAE for my new job soon from India. This is my first job as well. My Employer asked me to send my Banking Details. So what kind of account should I start, where should I start, and what tips can I have for maximum benefit from that account?
What are the basic banking details I should work out before I m... | 2015/08/01 | [
"https://money.stackexchange.com/questions/50413",
"https://money.stackexchange.com",
"https://money.stackexchange.com/users/30811/"
] | >
> My Employer asked me to send my Banking Details.
>
>
>
Why does your employer need your bank account details without you joining yet? Please verify and be sure that this is not some kind of scam.
>
> What are the basic banking details I should work out before I move?
>
>
>
Convert any savings account int... | Most banks have a procedure that you fill out a form on line and the bank gathers all the info need for direct deposit. To start you off you need a basic checking account. I wouldn't give any info to your employer but rather start the direct deposit with you bank first, its safer. |
53,191,404 | I have a `HomeViewController` that is opening a `WelcomeViewController` using segue and is from type Sheet.
In `WelcomeViewController` the User is entering information and then closing(dismissing) it. After `WelcomeViewController` is closed I want to update `HomeViewController` by changing the `String` value of a `Tex... | 2018/11/07 | [
"https://Stackoverflow.com/questions/53191404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2696918/"
] | This is how I solved it using a `delegate`.
Thanks to @ullstrm for the suggestion.
First I added this protocol to `HomeViewController`
```
protocol WelcomeDelegate {
func insertData(_ name: String, birthday: Date)
}
```
Then this `prepare(for segue:)`
```
override func prepare(for segue: NSStoryboardSegue, sen... | Add your code to ViewWillAppear() instead of ViewDidAppear().
or you call a method in the HomeViewController when dismissing WelcomeViewcontroller
```
dismiss(animated: true) {
self.presentedViewController.myMethod()
}
``` |
13,294,003 | I am doing a project which need to store 30 distinct fields for a business logic which later will be used to generate report for each
The 30 distinct fields are not written at one time, the business logic has so many transactions, it's gonna be like:
```
Transaction 1, update field 1-4
Transaction 2, update field 3,... | 2012/11/08 | [
"https://Stackoverflow.com/questions/13294003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/833538/"
] | In general it's wise to split the JSON or XML document out and store it as individual columns. This gives you the ability to set up constraints on the columns for validation and checking, to index columns, to use appropriate data types for each field, and generally use the power of the database.
Mapping it to/from obj... | (1) is more standard, for good reasons. Enables the database to do heavy lifting on things like search and indexing for one thing. |
13,294,003 | I am doing a project which need to store 30 distinct fields for a business logic which later will be used to generate report for each
The 30 distinct fields are not written at one time, the business logic has so many transactions, it's gonna be like:
```
Transaction 1, update field 1-4
Transaction 2, update field 3,... | 2012/11/08 | [
"https://Stackoverflow.com/questions/13294003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/833538/"
] | In general it's wise to split the JSON or XML document out and store it as individual columns. This gives you the ability to set up constraints on the columns for validation and checking, to index columns, to use appropriate data types for each field, and generally use the power of the database.
Mapping it to/from obj... | Always store your XML/JSON fields as separate fields in a relational database. Doing so you will keep your database normalized, allowing the database to do its thing with queries/indices etc. And you will save other developers the headache of deciphering your XML/JSON field.
It will be more work up front to extract t... |
59,987,198 | I'm trying to download a few packages using *python 3.8* but every time i try to install packages like `sklearn` or `scipy` I get this error:
`Could not install packages due to an EnvironmentError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '"C:'`
I reinstalled Visual studios th... | 2020/01/30 | [
"https://Stackoverflow.com/questions/59987198",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11447941/"
] | The default CSS you're importing from Ant is set to truncate. You'll want to change the white-space property:
`white-space: normal;`
You may then notice that the wrapped text is overflowing in the y axis now. You can change your height to accommodate variable height content:
`height: auto;` | You can set some style to your `Menu.Item` :
```js
<Menu.Item key="1" style={{whiteSpace: 'normal', height: 'auto'}}>Option 1Option 1Option 1Option 1Option 1Option 1Option 1Option 1</Menu.Item>
``` |
73,445,422 | I was working with f-strings, and I am fairly new to python. My question is does the f-string formatting cast a variable(an integer) into a string?
```
number = 10
print(f"{number} is not a string")
```
Is `number` cast into a string? | 2022/08/22 | [
"https://Stackoverflow.com/questions/73445422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19214678/"
] | You can test it yourself quite easily
```
number = 10
print(f"{number} is not a string")
print(type(number))
# output is integer
``` | If u can't understand f string or other soln dosent make any sense then try this.
This will help you integrate a variable(integer/char) in a string.
```
a = "blah blah blah {} blah blah ".format(integer_value)
print(a)
``` |
73,445,422 | I was working with f-strings, and I am fairly new to python. My question is does the f-string formatting cast a variable(an integer) into a string?
```
number = 10
print(f"{number} is not a string")
```
Is `number` cast into a string? | 2022/08/22 | [
"https://Stackoverflow.com/questions/73445422",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19214678/"
] | `f"..."` expressions *format* values to strings, integrate the result into a larger string and return that result. That's not quite the same as 'casting'\*.
`number` is an expression here, one that happens to produce an integer object. The integer is then formatted to a string, by calling the `__format__` method on th... | If u can't understand f string or other soln dosent make any sense then try this.
This will help you integrate a variable(integer/char) in a string.
```
a = "blah blah blah {} blah blah ".format(integer_value)
print(a)
``` |
31,575,990 | I use a logo that is line and text based. I am wanting to include a variant of this in my website but create the logo from CSS.
[](https://i.stack.imgur.com/vxS8Z.png)
I'm trying to get "T - S o N" as one line but with the "o" vertically centered bet... | 2015/07/22 | [
"https://Stackoverflow.com/questions/31575990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5145796/"
] | Use the **exact** same code you use to set the cookie, but set the time to zero (and you can use any other content.. Even an empty content)..
If that doesn't work, you're not looking in the rigth/updated place..
JO. | Try specifying the `/` path when you use the `setcookie()` function.
When no value is specified, the default value is the current directory that the cookie is being set it. It can only be unsetted from that same directory. |
37,383,739 | I am able to change design of the `title` attribute inside anchor tag, even though the default one is coming along with changed one.
I'm wondering if it's possible to remove default `title` tooltip as shown below?
[](https://i.stack.imgur.com/E2XrC.gif)
---
Here'... | 2016/05/23 | [
"https://Stackoverflow.com/questions/37383739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3838599/"
] | I don't think there is a simple way to do what you want, while still using the `title` attribute. So the answer to your original question:
>
> Is it possible to remove default title tooltip?
>
>
>
**Answer:** Probably not possible. Each browser decides how to handle the `title` attribute. So unless there is some ... | Use javascript [Element.removeAttribute()](https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute)
```js
//select all anchor with a given title, in this case a[title=Edit]
var anchor = document.querySelectorAll("a[title=Edit]");
for(var i=0; i<anchor.length;i++){
//anchor[i].title = "";
an... |
1,509,472 | I need to create a table (in SQLite) with a column which contains either "-1" or "+1". To save memory it is better not to use "int" as a type of the column. So, I thought about "smallint" and "tinyint". But smallint is not so small (from -32,768 to 32,767) and tinyint can be only positive (from 0 to 255). Are there any... | 2009/10/02 | [
"https://Stackoverflow.com/questions/1509472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175960/"
] | Boolean would do the job with a tiny processing in the application to map boolean to -1 or +1. | If your field can have only two values in it, why not use a bit/boolean? |
1,509,472 | I need to create a table (in SQLite) with a column which contains either "-1" or "+1". To save memory it is better not to use "int" as a type of the column. So, I thought about "smallint" and "tinyint". But smallint is not so small (from -32,768 to 32,767) and tinyint can be only positive (from 0 to 255). Are there any... | 2009/10/02 | [
"https://Stackoverflow.com/questions/1509472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175960/"
] | If your field can have only two values in it, why not use a bit/boolean? | I recommend you do as other answers suggest and use 0/1 or a bit instead, but if you really really need to do this, Can you in your code, cast the value from a unsigned byte to a char, and then to a signed byte? If you can, then Then 1 (00000001) casts to 1, and 255 (11111111) casts to -1 |
1,509,472 | I need to create a table (in SQLite) with a column which contains either "-1" or "+1". To save memory it is better not to use "int" as a type of the column. So, I thought about "smallint" and "tinyint". But smallint is not so small (from -32,768 to 32,767) and tinyint can be only positive (from 0 to 255). Are there any... | 2009/10/02 | [
"https://Stackoverflow.com/questions/1509472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175960/"
] | SQLite 3 presents only an `INTEGER` data type which...
>
> [...] is a signed
> integer, stored in 1, 2, 3, 4, 6, or 8
> bytes depending on the magnitude of
> the value.
>
>
>
Source: <http://www.sqlite.org/datatype3.html> | If your field can have only two values in it, why not use a bit/boolean? |
1,509,472 | I need to create a table (in SQLite) with a column which contains either "-1" or "+1". To save memory it is better not to use "int" as a type of the column. So, I thought about "smallint" and "tinyint". But smallint is not so small (from -32,768 to 32,767) and tinyint can be only positive (from 0 to 255). Are there any... | 2009/10/02 | [
"https://Stackoverflow.com/questions/1509472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175960/"
] | Boolean would do the job with a tiny processing in the application to map boolean to -1 or +1. | I recommend you do as other answers suggest and use 0/1 or a bit instead, but if you really really need to do this, Can you in your code, cast the value from a unsigned byte to a char, and then to a signed byte? If you can, then Then 1 (00000001) casts to 1, and 255 (11111111) casts to -1 |
1,509,472 | I need to create a table (in SQLite) with a column which contains either "-1" or "+1". To save memory it is better not to use "int" as a type of the column. So, I thought about "smallint" and "tinyint". But smallint is not so small (from -32,768 to 32,767) and tinyint can be only positive (from 0 to 255). Are there any... | 2009/10/02 | [
"https://Stackoverflow.com/questions/1509472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175960/"
] | Boolean would do the job with a tiny processing in the application to map boolean to -1 or +1. | SQLite 3 presents only an `INTEGER` data type which...
>
> [...] is a signed
> integer, stored in 1, 2, 3, 4, 6, or 8
> bytes depending on the magnitude of
> the value.
>
>
>
Source: <http://www.sqlite.org/datatype3.html> |
1,509,472 | I need to create a table (in SQLite) with a column which contains either "-1" or "+1". To save memory it is better not to use "int" as a type of the column. So, I thought about "smallint" and "tinyint". But smallint is not so small (from -32,768 to 32,767) and tinyint can be only positive (from 0 to 255). Are there any... | 2009/10/02 | [
"https://Stackoverflow.com/questions/1509472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/175960/"
] | SQLite 3 presents only an `INTEGER` data type which...
>
> [...] is a signed
> integer, stored in 1, 2, 3, 4, 6, or 8
> bytes depending on the magnitude of
> the value.
>
>
>
Source: <http://www.sqlite.org/datatype3.html> | I recommend you do as other answers suggest and use 0/1 or a bit instead, but if you really really need to do this, Can you in your code, cast the value from a unsigned byte to a char, and then to a signed byte? If you can, then Then 1 (00000001) casts to 1, and 255 (11111111) casts to -1 |
4,804,282 | Is there any way you can alter the default value of FNR and then output it to the screen.
I have tried:
```
(piped output....) | awk '{FNR=0} {print $0, FNR}'
```
I am hoping that solution will be interhangeable with NR. | 2011/01/26 | [
"https://Stackoverflow.com/questions/4804282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/590539/"
] | Yes, by using `BEGIN`:
```
$ awk 'BEGIN {FNR=2} {print $0, FNR}' file.txt
one 3
two 4
three 5
four 6
```
However, this seems not to work when input is not `stdin` (i.e. a file argument is given; at least not in GNU awk). | Why not declare your own `offset` variable:
```
(piped output....) | awk 'BEGIN {offset=2} {print $0, FNR+offset}'
``` |
4,804,282 | Is there any way you can alter the default value of FNR and then output it to the screen.
I have tried:
```
(piped output....) | awk '{FNR=0} {print $0, FNR}'
```
I am hoping that solution will be interhangeable with NR. | 2011/01/26 | [
"https://Stackoverflow.com/questions/4804282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/590539/"
] | Yes, by using `BEGIN`:
```
$ awk 'BEGIN {FNR=2} {print $0, FNR}' file.txt
one 3
two 4
three 5
four 6
```
However, this seems not to work when input is not `stdin` (i.e. a file argument is given; at least not in GNU awk). | ```
$ awk 'FNR > 2 {print $0, FNR}' yourfilename
```
FNR isn't necessarily interchangeable with NR. If you specify multiple files, FNR reinitializes to zero before each file. NR doesn't. |
4,804,282 | Is there any way you can alter the default value of FNR and then output it to the screen.
I have tried:
```
(piped output....) | awk '{FNR=0} {print $0, FNR}'
```
I am hoping that solution will be interhangeable with NR. | 2011/01/26 | [
"https://Stackoverflow.com/questions/4804282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/590539/"
] | Yes, by using `BEGIN`:
```
$ awk 'BEGIN {FNR=2} {print $0, FNR}' file.txt
one 3
two 4
three 5
four 6
```
However, this seems not to work when input is not `stdin` (i.e. a file argument is given; at least not in GNU awk). | The correct answer is: DO NOT DO THAT!!!! Leave FNR alone, it is what it is. If you need some counter that represents something other than the number of records read so far in the current file, then simply create a counter to represent that, don't go messing with the meaning of the built-in variables. |
4,804,282 | Is there any way you can alter the default value of FNR and then output it to the screen.
I have tried:
```
(piped output....) | awk '{FNR=0} {print $0, FNR}'
```
I am hoping that solution will be interhangeable with NR. | 2011/01/26 | [
"https://Stackoverflow.com/questions/4804282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/590539/"
] | Why not declare your own `offset` variable:
```
(piped output....) | awk 'BEGIN {offset=2} {print $0, FNR+offset}'
``` | ```
$ awk 'FNR > 2 {print $0, FNR}' yourfilename
```
FNR isn't necessarily interchangeable with NR. If you specify multiple files, FNR reinitializes to zero before each file. NR doesn't. |
4,804,282 | Is there any way you can alter the default value of FNR and then output it to the screen.
I have tried:
```
(piped output....) | awk '{FNR=0} {print $0, FNR}'
```
I am hoping that solution will be interhangeable with NR. | 2011/01/26 | [
"https://Stackoverflow.com/questions/4804282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/590539/"
] | Why not declare your own `offset` variable:
```
(piped output....) | awk 'BEGIN {offset=2} {print $0, FNR+offset}'
``` | The correct answer is: DO NOT DO THAT!!!! Leave FNR alone, it is what it is. If you need some counter that represents something other than the number of records read so far in the current file, then simply create a counter to represent that, don't go messing with the meaning of the built-in variables. |
4,804,282 | Is there any way you can alter the default value of FNR and then output it to the screen.
I have tried:
```
(piped output....) | awk '{FNR=0} {print $0, FNR}'
```
I am hoping that solution will be interhangeable with NR. | 2011/01/26 | [
"https://Stackoverflow.com/questions/4804282",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/590539/"
] | The correct answer is: DO NOT DO THAT!!!! Leave FNR alone, it is what it is. If you need some counter that represents something other than the number of records read so far in the current file, then simply create a counter to represent that, don't go messing with the meaning of the built-in variables. | ```
$ awk 'FNR > 2 {print $0, FNR}' yourfilename
```
FNR isn't necessarily interchangeable with NR. If you specify multiple files, FNR reinitializes to zero before each file. NR doesn't. |
61,035,078 | I'm a little bit stumped by a problem which I can't figure out and I feel it should be a trivial problem to solve.
I have an element *budget* of class Budget. In this class, it has a dictionary *sections* which contains *Section* class objects. In *Section* class, I have another dictionary which is called *allowances*... | 2020/04/04 | [
"https://Stackoverflow.com/questions/61035078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10777811/"
] | First step
==========
I changed `USE_TZ` to `False`, ran and closed the server, and again to `True`. This allowed my side to load, but still had the wrong time.
Second step
===========
I changed TIME\_ZONE not to ‘PL’ as @jatrp5 suggested, but to 'Europe/Warsaw' as I read on [this question](https://stackoverflow.co... | To match your bash time you should change the time zone to `TIME_ZONE = 'PL'`. The universal time zone (UTC) is two hours behind the Polish. |
529,400 | Since my first Windows 98 (and even now on Win7), I could enter the first 6 letters (symbols) of a folder's name and add `~1` after it (when there was just one folder with those six letters in current directory), and it would work as the full name of it. And it appears that if there are more than one folder with the sa... | 2013/01/07 | [
"https://superuser.com/questions/529400",
"https://superuser.com",
"https://superuser.com/users/148699/"
] | [Knowledge base entry](https://web.archive.org/web/20131206010029/http://support.microsoft.com/kb/142982)
Basically on FAT systems all directory entries are still stored in a format compatible with the old 8.3 format; longer names are stored in a series of hidden entries. The short name is there for compatibility. | These are [**8.3 filenames**](http://en.wikipedia.org/wiki/8.3_filename), and date back to the days of MS-DOS, which did not support longer filenames.
Windows 95 and VFAT introduced the `~N` tilde notation as a backward compatibility mechanism, to give each long file name a unique 8.3 short file name, too. |
66,838,983 | I have two files, fisrt "file.txt" have few lines, next file: "output.txt is empty", examples:
```
cat file.txt
Line1 x i 12gb
Line2 x u 13.7gb
Line3 x q 4.3gb
Line4 x t 33gb
Line5 f t 29.04gb
Line6 f t 38gb
```
```
cat output.txt
```
I need to grep lines only w... | 2021/03/28 | [
"https://Stackoverflow.com/questions/66838983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15493736/"
] | With your shown samples, please try following.
```
awk '$NF+0>30' Input_file
```
Simply checking condition if last field(where +0 will take till digits only in it) is greater than 30, if this condition is TRUE then print that line. | I would do it following way using GNU `AWK`, let `file.txt` content be
```
Line1 x i 12gb
Line2 x u 13.7gb
Line3 x q 4.3gb
Line4 x t 33gb
Line5 f t 29.04gb
Line6 f t 38gb
```
then
```
awk '{$0=gensub(/([[:alpha:]]+$)/, " \\1", 1)}$4>=30{print $1, $4, $5}' file.txt
``... |
66,838,983 | I have two files, fisrt "file.txt" have few lines, next file: "output.txt is empty", examples:
```
cat file.txt
Line1 x i 12gb
Line2 x u 13.7gb
Line3 x q 4.3gb
Line4 x t 33gb
Line5 f t 29.04gb
Line6 f t 38gb
```
```
cat output.txt
```
I need to grep lines only w... | 2021/03/28 | [
"https://Stackoverflow.com/questions/66838983",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15493736/"
] | With your shown samples, please try following.
```
awk '$NF+0>30' Input_file
```
Simply checking condition if last field(where +0 will take till digits only in it) is greater than 30, if this condition is TRUE then print that line. | It sounds like this is what you're asking for:
```
$ awk '($NF+0)>30{sub(/[[:alpha:]]/," &",$NF); print $NF}' file.txt
33 gb
38 gb
```
or maybe:
```
$ awk '($NF+0)>30{sub(/[[:alpha:]]/," &",$NF); print $1, $NF}' file.txt
Line4 33 gb
Line6 38 gb
``` |
69,966,403 | I want define a smart initialization method that it understands the chosen first parameter and adjust itself for it!
Here is my code:
```
struct Test {
enum Kind { case vertical, horizontal }
enum VerticalAlignment { case top, center, bottom }
enum HorizontalAlignment { case leading, center, trailing }
... | 2021/11/14 | [
"https://Stackoverflow.com/questions/69966403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13899957/"
] | ```
struct Test {
enum VerticalAlignment { case top, center, bottom }
enum HorizontalAlignment { case leading, center, trailing }
enum Kind { case vertical(VerticalAlignment),
horizontal(HorizontalAlignment) }
init(kind: Kind) {
switch kind {
case .horizontal(let ... | Disclaimer: you should definitely use Yurii Petrov's answer rather than what I'm showing here. This is really abusing Swift's features, and kind of overkill for what you are trying to do... My aim is just to show that this sort of thing can be done.
The idea is that you will have a protocol with an associated type:
`... |
69,580,284 | I have a S3 bucket with paths of the form {productId}/{store}/description.txt. Here's what the bucket might look like at the top level
```
ABC123/Store1/description.txt
ABC123/Store2/description.txt
ABC123/Store3/description.txt
DEF123/Store1/description.txt
DEF123/Store2/description.txt
```
If i had to read all the... | 2021/10/15 | [
"https://Stackoverflow.com/questions/69580284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9439391/"
] | With `boto3` you can use [filtering](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/collections.html#filtering) and you have to **iterate**.
There are few ways of doing this, but I usually download the s3 objects **in parallel**. For example:
```
import boto3
from multiprocessing import Pool
session ... | I believe it is a limitation of the AWS console web interface, having tried (and failed) to do this myself.
Alternatively, perhaps use a 3rd party S3 browser client such as <http://s3browser.com/>
If you have Visual Studio with the AWS Explorer extension installed, you can also browse to Amazon S3 (step 1), select yo... |
66,957 | I am trying to convert a bitcoin address and have the following code from here ([Calculate Segwit address from public address](https://bitcoin.stackexchange.com/questions/65404/calculate-segwit-address-from-public-address), 2nd answer):
```
Step1: $ printf 1L88S26C5oyjL1gkXsBeYwHHjvGvCcidr9 > adr.txt
Step2: $ printf $... | 2017/12/29 | [
"https://bitcoin.stackexchange.com/questions/66957",
"https://bitcoin.stackexchange.com",
"https://bitcoin.stackexchange.com/users/66581/"
] | Payment routing could handle this. Any business has operational costs and will have to make outgoing payments.
If your concern is that channels will mostly consist of payments in a single direction (i.e. from customers to larger businesses), and that this will lead to a high frequency of channel closings or on-chain s... | I think a solution to this problem comes in the form of developing routing algorithms that benefit the network as a whole.
Routing algorithms will look for paths where channels need help in rebalancing themselves -- they do this to help the network as a whole, so that the probability of finding a path is always high f... |
51,938,304 | I have to query 400+ servers to find the business applications/services installed,there is no need for all the default services.
I obtained a list of services from a default system and put those in a **csv** file, but it doesn't seem to want to exclude them. Here is what I have so far:
```
{$excludelist = "c:\powersh... | 2018/08/20 | [
"https://Stackoverflow.com/questions/51938304",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6754112/"
] | You have to return something from `setRutine`, probably the promises result:
```
return await countUsers() /*...*/
``` | Thank you for all your answers, you all helped me a little to understand better my problem and Doug Stevenson was right I changed the setRutine function to return a Promise instead of being an async function.
I post the code:
```
function setRutine(nameF) {
return new Promise( (resolve, reject) => {
if(n... |
31,066,447 | I have the following simplified spring integration flow:
```
int-ws:inbound-gateway ----> int:transformer ----> int-kafka:outbound-channel-adapter
```
Basically:
1. A web service endpoint is exposed using the `int-ws:inbound-gateway`
2. Messages from this endpoint are put onto the `input` channel (the first `--->`)... | 2015/06/26 | [
"https://Stackoverflow.com/questions/31066447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4767508/"
] | Change
`<int:channel id="inputToKafka"/>`
to
`<int:publish-subscribe-channel id="inputToKafka"/>`
Add a second subscriber to the channel.
`<service-activator input-channel="inputToKafka" ... order="2" />`
Where the service generates the response; it will be invoked after a successful send to kafka.
Do not in... | What kind of a response are you expecting from Kafka outbound channel adapter, remember it is `Adapter` not a `Gateway`
You could however introduce another component, `ServiceActivator` With an input channel `sendToInputToKafka` now your transformer will output to this channel.
Your 'ServiceActivator' should have an ... |
13,492,853 | I am trying to install the ADT plugin on Eclipse, but it doesn't seem to be working. I tried using the [ADT Bundle for Mac](http://developer.android.com/sdk/index.html) but I always get the error
`dyld: unknown required load command 0x80000022`
on the console. I tried both `Eclipse Juno` and `Eclipse Indigo` using t... | 2012/11/21 | [
"https://Stackoverflow.com/questions/13492853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1759005/"
] | Use a hash in your URL like:
```
foo.com#formopen
```
Then find that hash on load like:
```
$(function(){
if (window.location.hash){
var hash = window.location.hash.substring(1);
if (hash == "formopen"){
openFeedbackForm();
}
}
});
```
---
**DEMO:**
Code: <http://jsfiddle.net/... | Hey there are many ways to do this.
Method One - Using Query String params
In your url pass in a query string value which indicates that the form should be opened.
So your url would be
```
www.foo.com?feedback=true
```
Then in JS you can do:
```
var params = {};
var ps = window.location.search.split(/\?|&/);
for... |
18,139,643 | I usually declare the rects & colours in static const format in my view controllers like this for example. (these are compile time)
```
#import "something.h"
static const CGRect someRect = { w, x, y, z };
static const uint8_t someColor[] = { 255, 0 , 0}
@implementation
// other methods
@end
```
This way **doesn'... | 2013/08/09 | [
"https://Stackoverflow.com/questions/18139643",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/908749/"
] | Don't try to detect the device at compile-time, that's impossible. You can't know in advance what kind of device your code will run on, since as you said, Apple could release future iOS devices running on armv7s with different hardware characteristics from the iPhone 5/iPod 5.
Instead, you need to detect the device ty... | I agree with Adam for detecting features, however, what I like to do is define constant sizes and positions in relative terms:
```
#define SOMERECT_X 0.25
#define SOMERECT_Y 0.25
#define SOMERECT_W 0.5
#define SOMERECT_H 0.5
```
Then when it comes time to set up, for example someRect:
```
CGRect someRect =
CGR... |
24,484,797 | in wpf, I have a canvas, that when double-clicked, needs to be opened in a separate tab for editing. when switching tabs, I need to be able to see the canvas in its original place, with the changes applied.
Is there a trick to make it the child of both TabItems? if no, is there anything else I can do?
Thanks! | 2014/06/30 | [
"https://Stackoverflow.com/questions/24484797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3491573/"
] | Just zip your stream with a shifted version of itself and sum the two elements.
```
val s1 = Stream.from(0) // 0, 1, 2, 3, ...
val s2 = Stream.from(1) // 1, 2, 3, 4, ...
val sumOfTwo = s1.zip(s2).map{ case (a,b) => a+b } // 1, 3, 5, 7, ...
```
To compute the total sum, just use the scan function that acts like a fol... | [This answer](https://stackoverflow.com/a/8567134/1071311) computes the cumulative sum by using a variable for the accumulated result instead of `scan()`. Example program:
```
import scala.collection.immutable.Stream
object Main extends App {
// 1, 2, 3, ...
val naturals = Stream.from(1)
// cumulative ... |
3,455,653 | I am a junior developer I can't understand how canvas tag is beneficial for us?
I read lot of articles on that but I can't get the root benefit getting from the canvas tag. | 2010/08/11 | [
"https://Stackoverflow.com/questions/3455653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/339020/"
] | The canvas will enable you to draw pixel perfect graphics. | my personal take on canvas (and when I actually found a use case for canvas) is the ability to color pick and color change per pixel in a canvas element - actually moving the image from something we don't have any information about what is happening inside it to an element like all other DOM elements (and yes, I know a... |
3,455,653 | I am a junior developer I can't understand how canvas tag is beneficial for us?
I read lot of articles on that but I can't get the root benefit getting from the canvas tag. | 2010/08/11 | [
"https://Stackoverflow.com/questions/3455653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/339020/"
] | Basically, thanks to canvas, we can now draw/render 2D shapes using HTML5 and the canvas API.
As an example of what's possible now with canvas, [see this](http://muro.deviantart.com/) | my personal take on canvas (and when I actually found a use case for canvas) is the ability to color pick and color change per pixel in a canvas element - actually moving the image from something we don't have any information about what is happening inside it to an element like all other DOM elements (and yes, I know a... |
3,455,653 | I am a junior developer I can't understand how canvas tag is beneficial for us?
I read lot of articles on that but I can't get the root benefit getting from the canvas tag. | 2010/08/11 | [
"https://Stackoverflow.com/questions/3455653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/339020/"
] | Think of the difference between canvas and svg as the difference betwee Photoshop and Illustrator (or Gimp and Inkscape for you OSS folks). One deals with bitmaps and the other vector art.
With canvas, since you are drawing in bitmap, you can smudge, blur, burn, dodge your images easily. But since it's bitmap you can'... | The cool projects that came to mind for me are:
* Visualize gps data. GPS data is just an XML list of coordinates. You could easily build something in canvas to "connect the dots".
* An mobile app where the user can actual sign a document with her finger - canvas allows you to export out the rendered canvas drawing to... |
3,455,653 | I am a junior developer I can't understand how canvas tag is beneficial for us?
I read lot of articles on that but I can't get the root benefit getting from the canvas tag. | 2010/08/11 | [
"https://Stackoverflow.com/questions/3455653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/339020/"
] | Think of the difference between canvas and svg as the difference betwee Photoshop and Illustrator (or Gimp and Inkscape for you OSS folks). One deals with bitmaps and the other vector art.
With canvas, since you are drawing in bitmap, you can smudge, blur, burn, dodge your images easily. But since it's bitmap you can'... | Basically, thanks to canvas, we can now draw/render 2D shapes using HTML5 and the canvas API.
As an example of what's possible now with canvas, [see this](http://muro.deviantart.com/) |
3,455,653 | I am a junior developer I can't understand how canvas tag is beneficial for us?
I read lot of articles on that but I can't get the root benefit getting from the canvas tag. | 2010/08/11 | [
"https://Stackoverflow.com/questions/3455653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/339020/"
] | Think of the difference between canvas and svg as the difference betwee Photoshop and Illustrator (or Gimp and Inkscape for you OSS folks). One deals with bitmaps and the other vector art.
With canvas, since you are drawing in bitmap, you can smudge, blur, burn, dodge your images easily. But since it's bitmap you can'... | my personal take on canvas (and when I actually found a use case for canvas) is the ability to color pick and color change per pixel in a canvas element - actually moving the image from something we don't have any information about what is happening inside it to an element like all other DOM elements (and yes, I know a... |
3,455,653 | I am a junior developer I can't understand how canvas tag is beneficial for us?
I read lot of articles on that but I can't get the root benefit getting from the canvas tag. | 2010/08/11 | [
"https://Stackoverflow.com/questions/3455653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/339020/"
] | Think of the difference between canvas and svg as the difference betwee Photoshop and Illustrator (or Gimp and Inkscape for you OSS folks). One deals with bitmaps and the other vector art.
With canvas, since you are drawing in bitmap, you can smudge, blur, burn, dodge your images easily. But since it's bitmap you can'... | The canvas will enable you to draw pixel perfect graphics. |
3,455,653 | I am a junior developer I can't understand how canvas tag is beneficial for us?
I read lot of articles on that but I can't get the root benefit getting from the canvas tag. | 2010/08/11 | [
"https://Stackoverflow.com/questions/3455653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/339020/"
] | Think of the difference between canvas and svg as the difference betwee Photoshop and Illustrator (or Gimp and Inkscape for you OSS folks). One deals with bitmaps and the other vector art.
With canvas, since you are drawing in bitmap, you can smudge, blur, burn, dodge your images easily. But since it's bitmap you can'... | Some possible uses for Canvas:
* Image drawing program
* Photo editing/manipulation
* 2D Games
* Advanced image viewing such as [Microsoft's Deep Zoom](http://ie.microsoft.com/testdrive/Graphics/DeepZoom/Default.html)
If you can't understand how it's beneficial, then maybe it isn't from your point of view at least. D... |
3,455,653 | I am a junior developer I can't understand how canvas tag is beneficial for us?
I read lot of articles on that but I can't get the root benefit getting from the canvas tag. | 2010/08/11 | [
"https://Stackoverflow.com/questions/3455653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/339020/"
] | The canvas will enable you to draw pixel perfect graphics. | The cool projects that came to mind for me are:
* Visualize gps data. GPS data is just an XML list of coordinates. You could easily build something in canvas to "connect the dots".
* An mobile app where the user can actual sign a document with her finger - canvas allows you to export out the rendered canvas drawing to... |
3,455,653 | I am a junior developer I can't understand how canvas tag is beneficial for us?
I read lot of articles on that but I can't get the root benefit getting from the canvas tag. | 2010/08/11 | [
"https://Stackoverflow.com/questions/3455653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/339020/"
] | Basically, thanks to canvas, we can now draw/render 2D shapes using HTML5 and the canvas API.
As an example of what's possible now with canvas, [see this](http://muro.deviantart.com/) | The cool projects that came to mind for me are:
* Visualize gps data. GPS data is just an XML list of coordinates. You could easily build something in canvas to "connect the dots".
* An mobile app where the user can actual sign a document with her finger - canvas allows you to export out the rendered canvas drawing to... |
3,455,653 | I am a junior developer I can't understand how canvas tag is beneficial for us?
I read lot of articles on that but I can't get the root benefit getting from the canvas tag. | 2010/08/11 | [
"https://Stackoverflow.com/questions/3455653",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/339020/"
] | Some possible uses for Canvas:
* Image drawing program
* Photo editing/manipulation
* 2D Games
* Advanced image viewing such as [Microsoft's Deep Zoom](http://ie.microsoft.com/testdrive/Graphics/DeepZoom/Default.html)
If you can't understand how it's beneficial, then maybe it isn't from your point of view at least. D... | my personal take on canvas (and when I actually found a use case for canvas) is the ability to color pick and color change per pixel in a canvas element - actually moving the image from something we don't have any information about what is happening inside it to an element like all other DOM elements (and yes, I know a... |
21,350,656 | Have written following code in c
```
#include "stdio.h"
#include "string.h"
int main()
{
char str[] = "gatway=10.253.1.0,netmask=255.255.0.0,subnet=10.253.0.0,dns=10.253.0.203";
char name[100],value[100];
char *token1,*token2;
char *commasp = ", ";
char *equ="=";
token1 = strtok(str,commasp);... | 2014/01/25 | [
"https://Stackoverflow.com/questions/21350656",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3150853/"
] | You could use `strtok_r` instead of `strtok`.
```
char *key_value;
char *key_value_s;
key_value = strtok_r(str, ",", &key_value_s);
while (key_value) {
char *key, *value, *s;
key = strtok_r(key_value, "=", &s);
value = strtok_r(NULL, "=", &s);
printf("%s equals %s\n", key, value);
key_value = st... | You can do this in two steps, first parse the main string:
```
#include <stdio.h>
#include <string.h>
int main()
{
char str[] = "gatway=10.253.1.0,netmask=255.255.0.0,subnet=10.253.0.0,dns=10.253.0.203";
char name[100],value[100];
char *commasp = ", ";
char *ptr[256], **t = ptr, *s = str;
*t = st... |
124,446 | I am planning to bring my mother in visitor visa to Germany for a couple of months. At the moment she is staying with my wife in Sri Lanka. Later I planned to file a hardship case and see if I can prove that she is dependent on me to try to bring her for a long stay. Because my wife will soon join me here and mom will ... | 2018/10/23 | [
"https://travel.stackexchange.com/questions/124446",
"https://travel.stackexchange.com",
"https://travel.stackexchange.com/users/75887/"
] | It is always hard to predict how authorities will act, but I cannot see any good reason why it would make it harder for your mother to get a permit to stay with your wife any yourself in Germany if she had been visiting Germany once before.
I am sure you have already found the relevant information on the website of th... | I am not a lawyer, and this is not intended as legal advice, but [§36 AufenthG](https://www.gesetze-im-internet.de/aufenthg_2004/__36.html) says
>
> (2) Sonstigen Familienangehörigen eines Ausländers kann zum
> Familiennachzug eine Aufenthaltserlaubnis erteilt werden, wenn es zur
> Vermeidung einer außergewöhnliche... |
55,805,502 | We have created outlook[standalone application] add-in for Windows using joa addin based on the following link <https://github.com/wolfgangimig/joa>. We need the same to be done for Mac OS also.
As joa is based on COM technology, we are unable to use it for Mac. Kindly suggest me the steps to create outlook add-in for... | 2019/04/23 | [
"https://Stackoverflow.com/questions/55805502",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10888971/"
] | I too created outlook custom addin for windows using joa.As joa uses windows registry for saving data it works only on windows.Refer this link <https://learn.microsoft.com/en-us/outlook/add-ins/quick-start?tabs=visual-studio-code> for Mac os. | Mac version of Outlook does not support COM based addins - they are Windows specific. It only supports JS addins (also supported by the Windows, iOS, and Android versions of Outlook) - see <https://learn.microsoft.com/en-us/outlook/add-ins/> |
22,604,952 | I created an application that writes data to the database every 5 minutes.
However after some time this error appears:
`Error: Data source rejected establishment of connection, message from server: "Too many connections"`
I've been searching around and tells you to close the connection to the database after every r... | 2014/03/24 | [
"https://Stackoverflow.com/questions/22604952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3320956/"
] | This kind of problem arises when you are **NOT** properly closing the connection after usage.
>
> Please use `finally` block after `catch` to close the connections appropriately. This is because to ensure that the connection gets closed properly even when there is an unexpected exception or error. Please note that s... | Restart apache tomcat server will work. This worked for me.
Welcome |
22,604,952 | I created an application that writes data to the database every 5 minutes.
However after some time this error appears:
`Error: Data source rejected establishment of connection, message from server: "Too many connections"`
I've been searching around and tells you to close the connection to the database after every r... | 2014/03/24 | [
"https://Stackoverflow.com/questions/22604952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3320956/"
] | This kind of problem arises when you are **NOT** properly closing the connection after usage.
>
> Please use `finally` block after `catch` to close the connections appropriately. This is because to ensure that the connection gets closed properly even when there is an unexpected exception or error. Please note that s... | As from Java 7, `java.sql.Connection` is `AutoCloseable`. From now on, you can write your code like this:
```
try(Connection con = (Connection) DriverManager.getConnection(url, username, pazzword)) {
//your statements
}catch(RuntimeException e) {
}
``` |
22,604,952 | I created an application that writes data to the database every 5 minutes.
However after some time this error appears:
`Error: Data source rejected establishment of connection, message from server: "Too many connections"`
I've been searching around and tells you to close the connection to the database after every r... | 2014/03/24 | [
"https://Stackoverflow.com/questions/22604952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3320956/"
] | This kind of problem arises when you are **NOT** properly closing the connection after usage.
>
> Please use `finally` block after `catch` to close the connections appropriately. This is because to ensure that the connection gets closed properly even when there is an unexpected exception or error. Please note that s... | This may be because of the configured `max_connections` is not suitable with the Connection Pool size set in JDBC or number of connections you open against DB.
to check number of `max_connections` in mysql:
```
show variables like 'max_connections';
```
make sure you have proper value of opened connections with the... |
22,604,952 | I created an application that writes data to the database every 5 minutes.
However after some time this error appears:
`Error: Data source rejected establishment of connection, message from server: "Too many connections"`
I've been searching around and tells you to close the connection to the database after every r... | 2014/03/24 | [
"https://Stackoverflow.com/questions/22604952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3320956/"
] | As from Java 7, `java.sql.Connection` is `AutoCloseable`. From now on, you can write your code like this:
```
try(Connection con = (Connection) DriverManager.getConnection(url, username, pazzword)) {
//your statements
}catch(RuntimeException e) {
}
``` | Restart apache tomcat server will work. This worked for me.
Welcome |
22,604,952 | I created an application that writes data to the database every 5 minutes.
However after some time this error appears:
`Error: Data source rejected establishment of connection, message from server: "Too many connections"`
I've been searching around and tells you to close the connection to the database after every r... | 2014/03/24 | [
"https://Stackoverflow.com/questions/22604952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3320956/"
] | This may be because of the configured `max_connections` is not suitable with the Connection Pool size set in JDBC or number of connections you open against DB.
to check number of `max_connections` in mysql:
```
show variables like 'max_connections';
```
make sure you have proper value of opened connections with the... | Restart apache tomcat server will work. This worked for me.
Welcome |
22,604,952 | I created an application that writes data to the database every 5 minutes.
However after some time this error appears:
`Error: Data source rejected establishment of connection, message from server: "Too many connections"`
I've been searching around and tells you to close the connection to the database after every r... | 2014/03/24 | [
"https://Stackoverflow.com/questions/22604952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3320956/"
] | This may be because of the configured `max_connections` is not suitable with the Connection Pool size set in JDBC or number of connections you open against DB.
to check number of `max_connections` in mysql:
```
show variables like 'max_connections';
```
make sure you have proper value of opened connections with the... | As from Java 7, `java.sql.Connection` is `AutoCloseable`. From now on, you can write your code like this:
```
try(Connection con = (Connection) DriverManager.getConnection(url, username, pazzword)) {
//your statements
}catch(RuntimeException e) {
}
``` |
22,359,393 | I'm making a script that executes a file a certain amount of times, then if the file executes properly, it generates another file, and this last file I need to store it in a directory. Example: I execute it like this: ./shell 5 DIR
Then, the crpit shell executes another file called simulation 5 times and it creates a d... | 2014/03/12 | [
"https://Stackoverflow.com/questions/22359393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1923616/"
] | Spacing is very important in shell scripts, it's not like programming languages where
`if(x>y)` and `if ( x > y )` are the same thing.
In particular, `if` and `[` are two different commands:
`if[ e == 0 ]` needs to be `if [ e == 0 ]`
More precisely, `if` is a shell *keyword* as are `then`, `else`, and `fi`
`[`... | Does it works if you try `if [ $e == 0 ];` instead of `if[ e == 0 ];` |
22,359,393 | I'm making a script that executes a file a certain amount of times, then if the file executes properly, it generates another file, and this last file I need to store it in a directory. Example: I execute it like this: ./shell 5 DIR
Then, the crpit shell executes another file called simulation 5 times and it creates a d... | 2014/03/12 | [
"https://Stackoverflow.com/questions/22359393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1923616/"
] | Spacing is very important in shell scripts, it's not like programming languages where
`if(x>y)` and `if ( x > y )` are the same thing.
In particular, `if` and `[` are two different commands:
`if[ e == 0 ]` needs to be `if [ e == 0 ]`
More precisely, `if` is a shell *keyword* as are `then`, `else`, and `fi`
`[`... | When assigning variables, Bash doesn't allow leaving spaces in between the `=` sign like is common practice in other languages.
There must be a space separating reserved words like `if`.
So `if [ $# == 3 ]` is valid where `if[ $# == 3 ]` is not.
In Bash, it's important to use `$` in front of variable names when you'... |
68,550,431 | I have an array of paths
```
$to_delete = @(
"D:\test\to_delete\",
"E:\test\to_delete\",
"F:\test\to_delete\"
)
```
The files in these folders I need to select, and then if conditions are met, I would delete one file from one of those folders and put a newly created file into the same drive in the "new" folder
``... | 2021/07/27 | [
"https://Stackoverflow.com/questions/68550431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10071216/"
] | This is how you can draw a part of an oval similar to the one from the picture you attached:
```
let path = UIBezierPath(ovalIn: CGRect(x: 10, y: 10, width: 100, height: 200))
let layer = CAShapeLayer()
layer.path = path.cgPath
layer.fillColor = UIColor.clear.cgColor
layer.strokeColor = UIColor.red... | I got this pretty easily:
[](https://i.stack.imgur.com/I39GQ.png)
That seems to be much like what you're trying to draw. It's just three shape layers. You've already got one, so you'd add two more. |
789,295 | Sometimes after putting my laptop to sleep it's CPU is locked to the slowest frequency - about 600-700MHz.
My laptop is Dell E6420 with i5-2520m.
Kernel version: 4.6.0-040600-generic.
I first came across this bug in 14.04 release. And now we have 16.04 and it's still there.
I am working on my laptop, everythin... | 2016/06/20 | [
"https://askubuntu.com/questions/789295",
"https://askubuntu.com",
"https://askubuntu.com/users/545011/"
] | The issue you have with your LapTop is a known problem with some Dell LapTops.
When you resume from suspend on battery power, the Dell bios will set Clock Modulation to be used as a way to limit performance a little to save battery power. The problem is that the intel\_pstate CPU frequency scaling driver, in its curren... | In ubuntu 20.04 this bug is still here!
I can restore normal operation by removing external power and plug it in again until cpufreq-info says a different than lowest cpu frequency. |
16,307,500 | I am having an issue with some of my files, could use help solving it. I am converting from html to xml. sometimes I have a `<b>` or `<u>` or `<i>` tag on their own and I use
```
<xsl:template match="i">
<emphasis italic="yes">
<xsl:apply-templates select="*|@*|text()"/>
</emphasis>
</xsl:template>
```
or bold for b... | 2013/04/30 | [
"https://Stackoverflow.com/questions/16307500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2183943/"
] | I recently built an application which accepts a large number of uploads on Heroku. I decided to build my own solution instead of using cloudinary or an equivalent. Here are some lessons I learned:
* Don't upload to heroku. Your entire web worker will be locked down for the entire duration of the upload. That's up to a... | I'd never seen Cloudinary before your mention, but it seems like it'd be a great fit for your project.
First and foremost, it could potentially greatly simplify your app. Cloudinary supports [direct uploads from the browser](http://cloudinary.com/blog/direct_image_uploads_from_the_browser_to_the_cloud_with_jquery) via... |
26,955,423 | I'm having a little problem programming in Java.
I have a while loop that works until the game is over, when it runs I need to get a move from the player, I need the program to hold until the player click on the `JFrame` and makes his move, I need a method like `Scanner` from the keyboard, but for the mouse.
Any idea... | 2014/11/16 | [
"https://Stackoverflow.com/questions/26955423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3674127/"
] | GUI applications are **event driven**. This means you don't create such a while loop. You let the program go into its own event loop, and you make the moves and switch the turns as a response to the user's click event.
That is, you create a click event listener, and in its `actionPerformed()` method, you check:
```
i... | Well this might be a good reason to implement it asynchronously.
Assuming you are one threaded, this will not be much of a problem:
You'll add a while(m == null);, waiting for the Move to be an object. |
11,778 | I am new to being a DM and am pretty much learning as I go. I am curious as to what some of the more battle-hardened DMs on this site would consider the optimal Player Character versus DM controlled monster would be? Thanks for any and all suggestions. | 2012/01/09 | [
"https://rpg.stackexchange.com/questions/11778",
"https://rpg.stackexchange.com",
"https://rpg.stackexchange.com/users/2908/"
] | Variety. Sometimes you want an even number of combatants. Sometimes the PCs should be overwhelmed. Sometimes the PCs should overwhelm. It's impossible to arrive at an ideal number, because when you use a number of enemies in a fight, that number becomes less interesting in the next fight. | I agree with valadil about the variety. It can be fun to fight waves of minions sometimes and one powerful solo monster other times. You should keep the experience quota system in mind for deciding difficulty as well.
I used this [Encounter Calculator](http://kassoon.com/dnd/encounter-builder/) for a recent campaign ... |
43,632,266 | I need to return the smallest numbers (can be more than one) that occur in an array.
```
given [1,1,2,3,3,4]
expected [1,1]
given [8,8,2,3]
expected [2]
``` | 2017/04/26 | [
"https://Stackoverflow.com/questions/43632266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3581788/"
] | What about this?
```
a = [1, 1, 2, 3, 3, 4]
min = a.min
a.select { |i| i == min }
=> [1, 1]
``` | Here's one way to solve the problem:
1. Find the smallest number
2. Count how many times it appears
3. Generate an array with the solution instead of selecting elements in the input
Snippet:
```
input = [1,1,2,3,3,4]
highest = input.min
[highest] * input.count(highest)
``` |
43,632,266 | I need to return the smallest numbers (can be more than one) that occur in an array.
```
given [1,1,2,3,3,4]
expected [1,1]
given [8,8,2,3]
expected [2]
``` | 2017/04/26 | [
"https://Stackoverflow.com/questions/43632266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3581788/"
] | What about this?
```
a = [1, 1, 2, 3, 3, 4]
min = a.min
a.select { |i| i == min }
=> [1, 1]
``` | Also, you can use `take_while`:
```
sorted = a.sort
sorted.take_while { |e| e == sorted[0] }
=> [1, 1]
```
Other possible way:
```
a = [1, 1, 2, 3, 3, 4]
Array.new(*a.each_with_object(Hash.new(0)) {|e, acc| acc[e] += 1}.min.reverse)
=> [1, 1]
``` |
43,632,266 | I need to return the smallest numbers (can be more than one) that occur in an array.
```
given [1,1,2,3,3,4]
expected [1,1]
given [8,8,2,3]
expected [2]
``` | 2017/04/26 | [
"https://Stackoverflow.com/questions/43632266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3581788/"
] | What about this?
```
a = [1, 1, 2, 3, 3, 4]
min = a.min
a.select { |i| i == min }
=> [1, 1]
``` | Another way:
```
a = [1,1,2,3,3,4]
a.group_by(&:itself).min.last
``` |
43,632,266 | I need to return the smallest numbers (can be more than one) that occur in an array.
```
given [1,1,2,3,3,4]
expected [1,1]
given [8,8,2,3]
expected [2]
``` | 2017/04/26 | [
"https://Stackoverflow.com/questions/43632266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3581788/"
] | Here's one way to solve the problem:
1. Find the smallest number
2. Count how many times it appears
3. Generate an array with the solution instead of selecting elements in the input
Snippet:
```
input = [1,1,2,3,3,4]
highest = input.min
[highest] * input.count(highest)
``` | Also, you can use `take_while`:
```
sorted = a.sort
sorted.take_while { |e| e == sorted[0] }
=> [1, 1]
```
Other possible way:
```
a = [1, 1, 2, 3, 3, 4]
Array.new(*a.each_with_object(Hash.new(0)) {|e, acc| acc[e] += 1}.min.reverse)
=> [1, 1]
``` |
43,632,266 | I need to return the smallest numbers (can be more than one) that occur in an array.
```
given [1,1,2,3,3,4]
expected [1,1]
given [8,8,2,3]
expected [2]
``` | 2017/04/26 | [
"https://Stackoverflow.com/questions/43632266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3581788/"
] | Another way:
```
a = [1,1,2,3,3,4]
a.group_by(&:itself).min.last
``` | Here's one way to solve the problem:
1. Find the smallest number
2. Count how many times it appears
3. Generate an array with the solution instead of selecting elements in the input
Snippet:
```
input = [1,1,2,3,3,4]
highest = input.min
[highest] * input.count(highest)
``` |
43,632,266 | I need to return the smallest numbers (can be more than one) that occur in an array.
```
given [1,1,2,3,3,4]
expected [1,1]
given [8,8,2,3]
expected [2]
``` | 2017/04/26 | [
"https://Stackoverflow.com/questions/43632266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3581788/"
] | Another way:
```
a = [1,1,2,3,3,4]
a.group_by(&:itself).min.last
``` | Also, you can use `take_while`:
```
sorted = a.sort
sorted.take_while { |e| e == sorted[0] }
=> [1, 1]
```
Other possible way:
```
a = [1, 1, 2, 3, 3, 4]
Array.new(*a.each_with_object(Hash.new(0)) {|e, acc| acc[e] += 1}.min.reverse)
=> [1, 1]
``` |
9,764,504 | We regularly deploy interactive kiosk CPUs to remote phsyical sites, and I've developed a content updater application that performs a nightly sync of media assets between each kiosk (Windows 7 Pro) and a hosted CMS (virtualized Ubuntu server running on linode.com). The content updater is authored in C#/.NET, and it spa... | 2012/03/19 | [
"https://Stackoverflow.com/questions/9764504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/677361/"
] | I had this problem. Took me several days to solve it.
Ended that adding -halfduplex solved my problem.
As stated in the documentation :
halfduplex
When this flag is set to true, Unison network communication is forced to be half duplex (the client and the server never simultaneously emit data). If you experience uns... | Just chiming in; I have the same problem using rsync/cygwin between two Windows 7 computers. Older discussions on the net suggested that the problem only affected ssh connections, but the rsync daemon method fails for me. There are messages pretending that one should recompile rsync from source unsetting HAVE\_SOCKETPA... |
9,764,504 | We regularly deploy interactive kiosk CPUs to remote phsyical sites, and I've developed a content updater application that performs a nightly sync of media assets between each kiosk (Windows 7 Pro) and a hosted CMS (virtualized Ubuntu server running on linode.com). The content updater is authored in C#/.NET, and it spa... | 2012/03/19 | [
"https://Stackoverflow.com/questions/9764504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/677361/"
] | I confirm that the "halfduplex = true" setting solved my hanging issues. I had setup of Win7 and OSX "clients" and Linux server as central syncing point. All the client sync with the server.
The problems started when I introduced the Mac client to the picture since then updates started to happen to both directions. S... | Just chiming in; I have the same problem using rsync/cygwin between two Windows 7 computers. Older discussions on the net suggested that the problem only affected ssh connections, but the rsync daemon method fails for me. There are messages pretending that one should recompile rsync from source unsetting HAVE\_SOCKETPA... |
9,764,504 | We regularly deploy interactive kiosk CPUs to remote phsyical sites, and I've developed a content updater application that performs a nightly sync of media assets between each kiosk (Windows 7 Pro) and a hosted CMS (virtualized Ubuntu server running on linode.com). The content updater is authored in C#/.NET, and it spa... | 2012/03/19 | [
"https://Stackoverflow.com/questions/9764504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/677361/"
] | I had this problem. Took me several days to solve it.
Ended that adding -halfduplex solved my problem.
As stated in the documentation :
halfduplex
When this flag is set to true, Unison network communication is forced to be half duplex (the client and the server never simultaneously emit data). If you experience uns... | I confirm that the "halfduplex = true" setting solved my hanging issues. I had setup of Win7 and OSX "clients" and Linux server as central syncing point. All the client sync with the server.
The problems started when I introduced the Mac client to the picture since then updates started to happen to both directions. S... |
1,240,491 | >
> Finding the maximal order in a number field
>
>
>
Suppose the number field is $K:=\mathbb Q(\alpha)$, then $\mathbb Z[\alpha]$ is not necessarily the integral closure of $\mathbb Z$ in $K$. I know the maximal order must have the smallest discriminant value among the orders in $K$. Is there a way to determine ... | 2015/04/18 | [
"https://math.stackexchange.com/questions/1240491",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/166923/"
] | HINT:
$$\frac{-7^n + 8^{n-2}}{7^{n+1} + 8^{n+2}} =\frac{-(7/8)^n+8^{-2}}{7(7/8)^n+8^2}$$
Now as $-1<7/8<1,\lim\_{n\to\infty}(7/8)^n=0$ | **Hint:**
write
$$
{-7^n + 8^{n-2}\over 7^{n+1} + 8^{n+2}} =
{-\left(\frac78\right)^n + \frac 1{64} \over 7 \left(\frac78\right)^n + 64}
$$ |
1,240,491 | >
> Finding the maximal order in a number field
>
>
>
Suppose the number field is $K:=\mathbb Q(\alpha)$, then $\mathbb Z[\alpha]$ is not necessarily the integral closure of $\mathbb Z$ in $K$. I know the maximal order must have the smallest discriminant value among the orders in $K$. Is there a way to determine ... | 2015/04/18 | [
"https://math.stackexchange.com/questions/1240491",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/166923/"
] | HINT:
$$\frac{-7^n + 8^{n-2}}{7^{n+1} + 8^{n+2}} =\frac{-(7/8)^n+8^{-2}}{7(7/8)^n+8^2}$$
Now as $-1<7/8<1,\lim\_{n\to\infty}(7/8)^n=0$ | As often it's shorter with *equivalents*: as $7^n=o(8^{n-2})$ since $7<8$,
$$-7^n+8^{n-2}\sim\_{\infty}8^{n-2}$$
Similarly, $\,7^{n+1}+8^{n+2}\sim\_{\infty}8^{n+2}$, hence:
$$\frac{-7^n+8^{n-2}}{7^{n+1}+8^{n+2}}\sim\_{\infty}\frac{8^{n-2}}{8^{n+2}}=\frac 1{8^4}=\frac1{4096}.$$ |
1,240,491 | >
> Finding the maximal order in a number field
>
>
>
Suppose the number field is $K:=\mathbb Q(\alpha)$, then $\mathbb Z[\alpha]$ is not necessarily the integral closure of $\mathbb Z$ in $K$. I know the maximal order must have the smallest discriminant value among the orders in $K$. Is there a way to determine ... | 2015/04/18 | [
"https://math.stackexchange.com/questions/1240491",
"https://math.stackexchange.com",
"https://math.stackexchange.com/users/166923/"
] | **Hint:**
write
$$
{-7^n + 8^{n-2}\over 7^{n+1} + 8^{n+2}} =
{-\left(\frac78\right)^n + \frac 1{64} \over 7 \left(\frac78\right)^n + 64}
$$ | As often it's shorter with *equivalents*: as $7^n=o(8^{n-2})$ since $7<8$,
$$-7^n+8^{n-2}\sim\_{\infty}8^{n-2}$$
Similarly, $\,7^{n+1}+8^{n+2}\sim\_{\infty}8^{n+2}$, hence:
$$\frac{-7^n+8^{n-2}}{7^{n+1}+8^{n+2}}\sim\_{\infty}\frac{8^{n-2}}{8^{n+2}}=\frac 1{8^4}=\frac1{4096}.$$ |
12,239,868 | I've just started to develop REST services, but I've come across a difficult situation: sending files from my REST service to my client. So far I've gotten the hang of how to send simple data types (strings, integers, etc) but sending a file is a different matter since there are so many file formats that I don't know w... | 2012/09/02 | [
"https://Stackoverflow.com/questions/12239868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/910190/"
] | If you want to return a File to be downloaded, specially if you want to integrate with some javascript libs of file upload/download, then the code bellow should do the job:
```
@GET
@Path("/{key}")
public Response download(@PathParam("key") String key,
@Context HttpServletResponse response) th... | Since youre using JSON, I would Base64 Encode it before sending it across the wire.
If the files are large, try to look at BSON, or some other format that is better with binary transfers.
You could also zip the files, if they compress well, before base64 encoding them. |
12,239,868 | I've just started to develop REST services, but I've come across a difficult situation: sending files from my REST service to my client. So far I've gotten the hang of how to send simple data types (strings, integers, etc) but sending a file is a different matter since there are so many file formats that I don't know w... | 2012/09/02 | [
"https://Stackoverflow.com/questions/12239868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/910190/"
] | I don't recommend encoding binary data in base64 and wrapping it in JSON. It will just needlessly increase the size of the response and slow things down.
Simply serve your file data using GET and `application/octect-stream`using one of the factory methods of [`javax.ws.rs.core.Response`](http://docs.oracle.com/javaee/... | Since youre using JSON, I would Base64 Encode it before sending it across the wire.
If the files are large, try to look at BSON, or some other format that is better with binary transfers.
You could also zip the files, if they compress well, before base64 encoding them. |
12,239,868 | I've just started to develop REST services, but I've come across a difficult situation: sending files from my REST service to my client. So far I've gotten the hang of how to send simple data types (strings, integers, etc) but sending a file is a different matter since there are so many file formats that I don't know w... | 2012/09/02 | [
"https://Stackoverflow.com/questions/12239868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/910190/"
] | Change the machine address from localhost to IP address you want your client to connect with to call below mentioned service.
Client to call REST webservice:
```
package in.india.client.downloadfiledemo;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFo... | Since youre using JSON, I would Base64 Encode it before sending it across the wire.
If the files are large, try to look at BSON, or some other format that is better with binary transfers.
You could also zip the files, if they compress well, before base64 encoding them. |
12,239,868 | I've just started to develop REST services, but I've come across a difficult situation: sending files from my REST service to my client. So far I've gotten the hang of how to send simple data types (strings, integers, etc) but sending a file is a different matter since there are so many file formats that I don't know w... | 2012/09/02 | [
"https://Stackoverflow.com/questions/12239868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/910190/"
] | I don't recommend encoding binary data in base64 and wrapping it in JSON. It will just needlessly increase the size of the response and slow things down.
Simply serve your file data using GET and `application/octect-stream`using one of the factory methods of [`javax.ws.rs.core.Response`](http://docs.oracle.com/javaee/... | If you want to return a File to be downloaded, specially if you want to integrate with some javascript libs of file upload/download, then the code bellow should do the job:
```
@GET
@Path("/{key}")
public Response download(@PathParam("key") String key,
@Context HttpServletResponse response) th... |
12,239,868 | I've just started to develop REST services, but I've come across a difficult situation: sending files from my REST service to my client. So far I've gotten the hang of how to send simple data types (strings, integers, etc) but sending a file is a different matter since there are so many file formats that I don't know w... | 2012/09/02 | [
"https://Stackoverflow.com/questions/12239868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/910190/"
] | If you want to return a File to be downloaded, specially if you want to integrate with some javascript libs of file upload/download, then the code bellow should do the job:
```
@GET
@Path("/{key}")
public Response download(@PathParam("key") String key,
@Context HttpServletResponse response) th... | Change the machine address from localhost to IP address you want your client to connect with to call below mentioned service.
Client to call REST webservice:
```
package in.india.client.downloadfiledemo;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFo... |
12,239,868 | I've just started to develop REST services, but I've come across a difficult situation: sending files from my REST service to my client. So far I've gotten the hang of how to send simple data types (strings, integers, etc) but sending a file is a different matter since there are so many file formats that I don't know w... | 2012/09/02 | [
"https://Stackoverflow.com/questions/12239868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/910190/"
] | I don't recommend encoding binary data in base64 and wrapping it in JSON. It will just needlessly increase the size of the response and slow things down.
Simply serve your file data using GET and `application/octect-stream`using one of the factory methods of [`javax.ws.rs.core.Response`](http://docs.oracle.com/javaee/... | Change the machine address from localhost to IP address you want your client to connect with to call below mentioned service.
Client to call REST webservice:
```
package in.india.client.downloadfiledemo;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFo... |
14,399,610 | I have a page with a list of about 500 names.
The user would like to type for e.g. `s` on their keyboard and then the page will automatically scroll to the names starting with `s`.
Should I convert the first letter of those names to an `INT`, give that INT as a data-attribute and add a jQuery function to the page or i... | 2013/01/18 | [
"https://Stackoverflow.com/questions/14399610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1237621/"
] | I'd suggest to embed the list of names for each character in a div with the appropriate `id`, such as for the names starting with *S*:
```
<div id="S">
... names with S ...
</div>
```
Then you can use jQuery to react on a keypress, and just do a
```
location.href = '#S';
```
Then, the browser will automatically... | If you're looking for something a bit faster, you can do the following trick (I presume the names are ordered).
You add to the first element that has a certain letter the `id="letter_X"`, and when the user scrolls, you just use the id as an anchor (`my_url#letter_X`).
This is the fastest way I know for doing this, bu... |
14,399,610 | I have a page with a list of about 500 names.
The user would like to type for e.g. `s` on their keyboard and then the page will automatically scroll to the names starting with `s`.
Should I convert the first letter of those names to an `INT`, give that INT as a data-attribute and add a jQuery function to the page or i... | 2013/01/18 | [
"https://Stackoverflow.com/questions/14399610",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1237621/"
] | I'd suggest to embed the list of names for each character in a div with the appropriate `id`, such as for the names starting with *S*:
```
<div id="S">
... names with S ...
</div>
```
Then you can use jQuery to react on a keypress, and just do a
```
location.href = '#S';
```
Then, the browser will automatically... | I think you should use section with an id for the tag. then do a $.scrollTop() from jquery.
```
$(window).scrollTop($('section#user_id').offset().top);
``` |
4,169,952 | I've been programming a lot in standard C for about a two years now. I do not regard myself as an experienced programmer but I can work my way around the basic stuff. Since earlier this year I also started programming in C# to try and expand my programming knowledge but I came to a dilemma.
I plan to do a lot of prog... | 2010/11/12 | [
"https://Stackoverflow.com/questions/4169952",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/505196/"
] | What about [Mono](http://www.mono-project.com/)? Open source .NET. Everyone's a winner! | I think the language you use does not forbid you to developing some free library or so on. The systems are not (all) free for this technology, but it doesn't mean that you can't do open source products with it.
If you develop C#, you are somehow "sponsoring" Microsoft, which doesn't really like open software, which yo... |
50,405,850 | **Now, I'm try to change date format from year-month-day to month/day/year form array.**
**I have an array that contains multiple dates in array i want to change each date format to year-month-day to month/day/year. Please check below array that contains multiple dates. Please help me if know something about that.**
... | 2018/05/18 | [
"https://Stackoverflow.com/questions/50405850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8270025/"
] | Here you go:
```
<?php
$currentDates = [
'2018-05-19',
'2018-05-20',
'2018-05-21',
'2018-05-22',
'2018-05-23',
'2018-05-24',
'2018-05-25',
'2018-05-26',
'2018-05-27',
'2018-05-28',
'2018-05-29',
'2018-05-30',
'2018-05-31',
'2018-06-04',
'2018-06-05',
'201... | ```
<?php
$dates = Array
("2018-05-19", "2018-05-20", "2018-05-21", "2018-05-22","2018-05-23");
print_r($dates);
$newDateFormat = array();
foreach($dates as $date){
$date = date('m/d/Y', strtotime($date));
array_push($newDateFormat,$date);
}
... |
50,405,850 | **Now, I'm try to change date format from year-month-day to month/day/year form array.**
**I have an array that contains multiple dates in array i want to change each date format to year-month-day to month/day/year. Please check below array that contains multiple dates. Please help me if know something about that.**
... | 2018/05/18 | [
"https://Stackoverflow.com/questions/50405850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8270025/"
] | Here you go:
```
<?php
$currentDates = [
'2018-05-19',
'2018-05-20',
'2018-05-21',
'2018-05-22',
'2018-05-23',
'2018-05-24',
'2018-05-25',
'2018-05-26',
'2018-05-27',
'2018-05-28',
'2018-05-29',
'2018-05-30',
'2018-05-31',
'2018-06-04',
'2018-06-05',
'201... | ```
<?php
function convert_YYYYMMDD_to_MMDDYYYY($str)
{
return substr($str, 5, 2) . '/' . substr($str, 8, 2) . '/' . substr($str, 0, 4);
}
for ($i =0 ; $i < count($arr) ; $i++)
{
$arr[$i] = convert_YYYYMMDD_to_MMDDYYYY($arr[$i]);
}
?>
``` |
42,939,508 | I am using Python and Selenium to scrape a webpage, in some cases, I can't get it to work,
\*
I would like to access the element with text 'PInt', wich is the second link in the below code.
The xPath for it (copied from Developer console) is: ***//*[@id="submenu1"]/a[2]**
```
<div id="divTest" onscroll="SetD... | 2017/03/21 | [
"https://Stackoverflow.com/questions/42939508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3624549/"
] | To see a full list of all the ways of selecting elements using selenium, you can read all about it in the [documentation](https://selenium-python.readthedocs.io/locating-elements.html).
Using xpath:
```
res = driver.find_element_by_xpath(u'//*[@id="submenu1"]/a[2]')
```
Using css selector:
```
res = driver.find_el... | To find xPath in chrome:
1. Right click the element you want
2. Inspect, which will open the developer window and highlight the selected element.
3. Right click the highlighted element and choose copy > copy by xpath
Here is a list of all the different ways to locate an element [Locating Elements](http://selenium-pyt... |
42,939,508 | I am using Python and Selenium to scrape a webpage, in some cases, I can't get it to work,
\*
I would like to access the element with text 'PInt', wich is the second link in the below code.
The xPath for it (copied from Developer console) is: ***//*[@id="submenu1"]/a[2]**
```
<div id="divTest" onscroll="SetD... | 2017/03/21 | [
"https://Stackoverflow.com/questions/42939508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3624549/"
] | Try with any of the below xpath. Sometimes automatically generated xpath does not work.
```
//a[contains(text(),'PInt')]
or
//div[@id='submenu1']//a[contains(text(),'PInt')]
```
Also I would suggest you to set some wait time before clicking on above link in case if above xpath does not work | To find xPath in chrome:
1. Right click the element you want
2. Inspect, which will open the developer window and highlight the selected element.
3. Right click the highlighted element and choose copy > copy by xpath
Here is a list of all the different ways to locate an element [Locating Elements](http://selenium-pyt... |
42,939,508 | I am using Python and Selenium to scrape a webpage, in some cases, I can't get it to work,
\*
I would like to access the element with text 'PInt', wich is the second link in the below code.
The xPath for it (copied from Developer console) is: ***//*[@id="submenu1"]/a[2]**
```
<div id="divTest" onscroll="SetD... | 2017/03/21 | [
"https://Stackoverflow.com/questions/42939508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3624549/"
] | Thanks to @JeffC to point me in the right direction.
since the page has some frames, I manage to access the element first by switching to the right frame (using xPath)
and then access the element.
```
driver.switch_to.default_content()
driver.switch_to.frame(driver.find_element_by_xpath('html / frameset / frameset / ... | To find xPath in chrome:
1. Right click the element you want
2. Inspect, which will open the developer window and highlight the selected element.
3. Right click the highlighted element and choose copy > copy by xpath
Here is a list of all the different ways to locate an element [Locating Elements](http://selenium-pyt... |
42,939,508 | I am using Python and Selenium to scrape a webpage, in some cases, I can't get it to work,
\*
I would like to access the element with text 'PInt', wich is the second link in the below code.
The xPath for it (copied from Developer console) is: ***//*[@id="submenu1"]/a[2]**
```
<div id="divTest" onscroll="SetD... | 2017/03/21 | [
"https://Stackoverflow.com/questions/42939508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3624549/"
] | Thanks to @JeffC to point me in the right direction.
since the page has some frames, I manage to access the element first by switching to the right frame (using xPath)
and then access the element.
```
driver.switch_to.default_content()
driver.switch_to.frame(driver.find_element_by_xpath('html / frameset / frameset / ... | To see a full list of all the ways of selecting elements using selenium, you can read all about it in the [documentation](https://selenium-python.readthedocs.io/locating-elements.html).
Using xpath:
```
res = driver.find_element_by_xpath(u'//*[@id="submenu1"]/a[2]')
```
Using css selector:
```
res = driver.find_el... |
42,939,508 | I am using Python and Selenium to scrape a webpage, in some cases, I can't get it to work,
\*
I would like to access the element with text 'PInt', wich is the second link in the below code.
The xPath for it (copied from Developer console) is: ***//*[@id="submenu1"]/a[2]**
```
<div id="divTest" onscroll="SetD... | 2017/03/21 | [
"https://Stackoverflow.com/questions/42939508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3624549/"
] | Thanks to @JeffC to point me in the right direction.
since the page has some frames, I manage to access the element first by switching to the right frame (using xPath)
and then access the element.
```
driver.switch_to.default_content()
driver.switch_to.frame(driver.find_element_by_xpath('html / frameset / frameset / ... | Try with any of the below xpath. Sometimes automatically generated xpath does not work.
```
//a[contains(text(),'PInt')]
or
//div[@id='submenu1']//a[contains(text(),'PInt')]
```
Also I would suggest you to set some wait time before clicking on above link in case if above xpath does not work |
17,288,055 | ```
public class Hangman {
private String secret;
private String disguise;
private int guessCount;
private int wrong;
public Hangman() {
secret="word";
disguise="????";
guessCount=0;
wrong=0;
}
public void makeGuess(char input) {
String temp;
... | 2013/06/25 | [
"https://Stackoverflow.com/questions/17288055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2514022/"
] | Your disquise word is all ???? so no matter what you input, the code `disguise.charAt(i)` will always be a `?` so on every ? will be replaced
What you want is `secret.charAt(i)` like below
```
public void makeGuess(char input) {
String temp;
temp=disguise;
char[] disquiseChars = disquise.toCharArray(); /... | Just replace the Replace function in the loop with a `disguise[i] = input;` and as the loop continues, all the changes are made as needed :)
The issue here is as Java Devil suggested, you're replacing all the '?' with the input!
**Edit :** Sorry I was thinking .NET when I said `disguise[i]`.
Either declare Disguis... |
17,288,055 | ```
public class Hangman {
private String secret;
private String disguise;
private int guessCount;
private int wrong;
public Hangman() {
secret="word";
disguise="????";
guessCount=0;
wrong=0;
}
public void makeGuess(char input) {
String temp;
... | 2013/06/25 | [
"https://Stackoverflow.com/questions/17288055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2514022/"
] | Your disquise word is all ???? so no matter what you input, the code `disguise.charAt(i)` will always be a `?` so on every ? will be replaced
What you want is `secret.charAt(i)` like below
```
public void makeGuess(char input) {
String temp;
temp=disguise;
char[] disquiseChars = disquise.toCharArray(); /... | Take a look at the [String.replace(char,char)](http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#replace(char,%20char)) docs and you will see that it replaces EVERY instance of the oldChar with the newChar. This means that every '?' will be replaced by 'w'. What you want to do instead is replace only the c... |
17,288,055 | ```
public class Hangman {
private String secret;
private String disguise;
private int guessCount;
private int wrong;
public Hangman() {
secret="word";
disguise="????";
guessCount=0;
wrong=0;
}
public void makeGuess(char input) {
String temp;
... | 2013/06/25 | [
"https://Stackoverflow.com/questions/17288055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2514022/"
] | Since your "disguise" contains only `?` and `replace(char oldchar, char newChar)` actually replaces all occurrences of `oldchar`, your whole string is being replaced.
What you really want is to replace a character at a specific position, and for that you could use `StringBuilder#setCharAt`. See my example below:
```
... | Your disquise word is all ???? so no matter what you input, the code `disguise.charAt(i)` will always be a `?` so on every ? will be replaced
What you want is `secret.charAt(i)` like below
```
public void makeGuess(char input) {
String temp;
temp=disguise;
char[] disquiseChars = disquise.toCharArray(); /... |
17,288,055 | ```
public class Hangman {
private String secret;
private String disguise;
private int guessCount;
private int wrong;
public Hangman() {
secret="word";
disguise="????";
guessCount=0;
wrong=0;
}
public void makeGuess(char input) {
String temp;
... | 2013/06/25 | [
"https://Stackoverflow.com/questions/17288055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2514022/"
] | Your disquise word is all ???? so no matter what you input, the code `disguise.charAt(i)` will always be a `?` so on every ? will be replaced
What you want is `secret.charAt(i)` like below
```
public void makeGuess(char input) {
String temp;
temp=disguise;
char[] disquiseChars = disquise.toCharArray(); /... | String chartAt(i) return character not index. If you replace the character than all character occurance will be replaced.
If you go through the Java Documentation then you have to learn why replace(char, char) method does not replace single character. Following qoute is from Java Docs.
>
> public String replace(char... |
17,288,055 | ```
public class Hangman {
private String secret;
private String disguise;
private int guessCount;
private int wrong;
public Hangman() {
secret="word";
disguise="????";
guessCount=0;
wrong=0;
}
public void makeGuess(char input) {
String temp;
... | 2013/06/25 | [
"https://Stackoverflow.com/questions/17288055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2514022/"
] | Since your "disguise" contains only `?` and `replace(char oldchar, char newChar)` actually replaces all occurrences of `oldchar`, your whole string is being replaced.
What you really want is to replace a character at a specific position, and for that you could use `StringBuilder#setCharAt`. See my example below:
```
... | Just replace the Replace function in the loop with a `disguise[i] = input;` and as the loop continues, all the changes are made as needed :)
The issue here is as Java Devil suggested, you're replacing all the '?' with the input!
**Edit :** Sorry I was thinking .NET when I said `disguise[i]`.
Either declare Disguis... |
17,288,055 | ```
public class Hangman {
private String secret;
private String disguise;
private int guessCount;
private int wrong;
public Hangman() {
secret="word";
disguise="????";
guessCount=0;
wrong=0;
}
public void makeGuess(char input) {
String temp;
... | 2013/06/25 | [
"https://Stackoverflow.com/questions/17288055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2514022/"
] | Since your "disguise" contains only `?` and `replace(char oldchar, char newChar)` actually replaces all occurrences of `oldchar`, your whole string is being replaced.
What you really want is to replace a character at a specific position, and for that you could use `StringBuilder#setCharAt`. See my example below:
```
... | Take a look at the [String.replace(char,char)](http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#replace(char,%20char)) docs and you will see that it replaces EVERY instance of the oldChar with the newChar. This means that every '?' will be replaced by 'w'. What you want to do instead is replace only the c... |
17,288,055 | ```
public class Hangman {
private String secret;
private String disguise;
private int guessCount;
private int wrong;
public Hangman() {
secret="word";
disguise="????";
guessCount=0;
wrong=0;
}
public void makeGuess(char input) {
String temp;
... | 2013/06/25 | [
"https://Stackoverflow.com/questions/17288055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2514022/"
] | Since your "disguise" contains only `?` and `replace(char oldchar, char newChar)` actually replaces all occurrences of `oldchar`, your whole string is being replaced.
What you really want is to replace a character at a specific position, and for that you could use `StringBuilder#setCharAt`. See my example below:
```
... | String chartAt(i) return character not index. If you replace the character than all character occurance will be replaced.
If you go through the Java Documentation then you have to learn why replace(char, char) method does not replace single character. Following qoute is from Java Docs.
>
> public String replace(char... |
33,945,896 | I am working on a blog site using WordPress and Susy grids. There is a `<p>` tag (with mild profanity) near the top of the page ([link](http://howtolearnalanguagelikeaboss.com/?p=6)) with `padding-top: 4em`. Somehow this padding is slipping up under the previous two siblings, an `<h1>` and a `<div>`. The html is as fol... | 2015/11/26 | [
"https://Stackoverflow.com/questions/33945896",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2052785/"
] | In [main.css:457,458](http://howtolearnalanguagelikeaboss.com/wp-content/themes/susy-test/css/main.css):
```
header {
width: 100%;
float: left;
margin-left: 0;
margin-right: 0;
}
```
There is a `float: left;` on the header. This effectively takes it out of the normal flow of content. Either stop floating tha... | Try:
```
.entry-content {
display: inline-block;
}
``` |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.